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