1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 // MARKER(update_precomp.py): autogen include statement, do not remove 24 #include "precompiled_framework.hxx" 25 26 #include "services/uriabbreviation.hxx" 27 #include "services.h" 28 29 #include "sal/config.h" 30 #include "cppuhelper/factory.hxx" 31 #include "cppuhelper/implementationentry.hxx" 32 33 #include "tools/urlobj.hxx" 34 35 // component helper namespace 36 namespace css = ::com::sun::star; 37 38 // framework namespace 39 namespace framework 40 { 41 42 namespace css = ::com::sun::star; 43 44 //_________________________________________________________________________________________________________________ 45 // declarations 46 //_________________________________________________________________________________________________________________ 47 48 //***************************************************************************************************************** 49 // XInterface, XTypeProvider, XServiceInfo 50 //***************************************************************************************************************** 51 DEFINE_XSERVICEINFO_MULTISERVICE_2 ( UriAbbreviation , 52 ::cppu::OWeakObject , 53 SERVICENAME_STRINGABBREVIATION , 54 IMPLEMENTATIONNAME_URIABBREVIATION 55 ) 56 57 DEFINE_INIT_SERVICE ( UriAbbreviation, 58 { 59 } 60 ) 61 62 UriAbbreviation::UriAbbreviation(css::uno::Reference< css::uno::XComponentContext > const & context) : 63 m_xContext(context) 64 { 65 } 66 67 // ::com::sun::star::util::XStringAbbreviation: 68 ::rtl::OUString SAL_CALL UriAbbreviation::abbreviateString(const css::uno::Reference< css::util::XStringWidth > & xStringWidth, ::sal_Int32 nWidth, const ::rtl::OUString & aString) throw (css::uno::RuntimeException) 69 { 70 ::rtl::OUString aResult( aString ); 71 if ( xStringWidth.is() ) 72 { 73 // Use INetURLObject to abbreviate URLs 74 INetURLObject aURL( aString ); 75 aResult = aURL.getAbbreviated( xStringWidth, nWidth, INetURLObject::DECODE_UNAMBIGUOUS ); 76 } 77 78 return aResult; 79 } 80 81 } // namespace framework 82 83 84 85 86 87