1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 // MARKER(update_precomp.py): autogen include statement, do not remove 28 #include "precompiled_framework.hxx" 29 30 #include "services/uriabbreviation.hxx" 31 #include "services.h" 32 33 #include "sal/config.h" 34 #include "cppuhelper/factory.hxx" 35 #include "cppuhelper/implementationentry.hxx" 36 37 #include "tools/urlobj.hxx" 38 39 // component helper namespace 40 namespace css = ::com::sun::star; 41 42 // framework namespace 43 namespace framework 44 { 45 46 namespace css = ::com::sun::star; 47 48 //_________________________________________________________________________________________________________________ 49 // declarations 50 //_________________________________________________________________________________________________________________ 51 52 //***************************************************************************************************************** 53 // XInterface, XTypeProvider, XServiceInfo 54 //***************************************************************************************************************** 55 DEFINE_XSERVICEINFO_MULTISERVICE_2 ( UriAbbreviation , 56 ::cppu::OWeakObject , 57 SERVICENAME_STRINGABBREVIATION , 58 IMPLEMENTATIONNAME_URIABBREVIATION 59 ) 60 61 DEFINE_INIT_SERVICE ( UriAbbreviation, 62 { 63 } 64 ) 65 66 UriAbbreviation::UriAbbreviation(css::uno::Reference< css::uno::XComponentContext > const & context) : 67 m_xContext(context) 68 { 69 } 70 71 // ::com::sun::star::util::XStringAbbreviation: 72 ::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) 73 { 74 ::rtl::OUString aResult( aString ); 75 if ( xStringWidth.is() ) 76 { 77 // Use INetURLObject to abbreviate URLs 78 INetURLObject aURL( aString ); 79 aResult = aURL.getAbbreviated( xStringWidth, nWidth, INetURLObject::DECODE_UNAMBIGUOUS ); 80 } 81 82 return aResult; 83 } 84 85 } // namespace framework 86 87 88 89 90 91