1*9f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9f62ea84SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9f62ea84SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9f62ea84SAndrew Rist  * distributed with this work for additional information
6*9f62ea84SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9f62ea84SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9f62ea84SAndrew Rist  * "License"); you may not use this file except in compliance
9*9f62ea84SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9f62ea84SAndrew Rist  *
11*9f62ea84SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9f62ea84SAndrew Rist  *
13*9f62ea84SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9f62ea84SAndrew Rist  * software distributed under the License is distributed on an
15*9f62ea84SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9f62ea84SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9f62ea84SAndrew Rist  * specific language governing permissions and limitations
18*9f62ea84SAndrew Rist  * under the License.
19*9f62ea84SAndrew Rist  *
20*9f62ea84SAndrew Rist  *************************************************************/
21*9f62ea84SAndrew Rist 
22*9f62ea84SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "com/sun/star/lang/XServiceInfo.hpp"
28cdf0e10cSrcweir #include "com/sun/star/util/XStringMapping.hpp"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include "cppuhelper/implbase2.hxx"
31cdf0e10cSrcweir #include "rtl/ustrbuf.hxx"
32cdf0e10cSrcweir #include "vcl/svapp.hxx"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir using ::rtl::OUString;
35cdf0e10cSrcweir using namespace ::com::sun::star::uno;
36cdf0e10cSrcweir using namespace ::com::sun::star::lang;
37cdf0e10cSrcweir using namespace ::com::sun::star::util;
38cdf0e10cSrcweir 
39cdf0e10cSrcweir // -----------------------------------------------------------------------
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace vcl
42cdf0e10cSrcweir {
43cdf0e10cSrcweir 
44cdf0e10cSrcweir class StringMirror : public ::cppu::WeakAggImplHelper2< XStringMapping, XServiceInfo >
45cdf0e10cSrcweir {
46cdf0e10cSrcweir public:
StringMirror()47cdf0e10cSrcweir     StringMirror()
48cdf0e10cSrcweir     {}
49cdf0e10cSrcweir 
~StringMirror()50cdf0e10cSrcweir     virtual ~StringMirror()
51cdf0e10cSrcweir     {}
52cdf0e10cSrcweir 
53cdf0e10cSrcweir     // XServiceInfo
54cdf0e10cSrcweir     virtual OUString SAL_CALL getImplementationName(  ) throw (RuntimeException);
55cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL supportsService( const OUString& ) throw (RuntimeException);
56cdf0e10cSrcweir     virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw (RuntimeException);
57cdf0e10cSrcweir 
58cdf0e10cSrcweir     // XStringMapping
mapStrings(Sequence<OUString> & io_rStrings)59cdf0e10cSrcweir     virtual sal_Bool SAL_CALL mapStrings( Sequence< OUString >& io_rStrings ) throw (RuntimeException)
60cdf0e10cSrcweir     {
61cdf0e10cSrcweir         sal_Int32 nItems = io_rStrings.getLength();
62cdf0e10cSrcweir         for( sal_Int32 n = 0; n < nItems; n++ )
63cdf0e10cSrcweir         {
64cdf0e10cSrcweir             rtl::OUString& rStr( io_rStrings.getArray()[n] );
65cdf0e10cSrcweir 
66cdf0e10cSrcweir             sal_Int32 nLen = rStr.getLength();
67cdf0e10cSrcweir             rtl::OUStringBuffer aMirror( nLen );
68cdf0e10cSrcweir             for(sal_Int32 i = nLen - 1; i >= 0; i--)
69cdf0e10cSrcweir             {
70cdf0e10cSrcweir                 sal_Unicode cChar = rStr[ i ];
71cdf0e10cSrcweir                 aMirror.append(sal_Unicode(GetMirroredChar(cChar)));
72cdf0e10cSrcweir             }
73cdf0e10cSrcweir             rStr = aMirror.makeStringAndClear();
74cdf0e10cSrcweir         }
75cdf0e10cSrcweir         return sal_True;
76cdf0e10cSrcweir     }
77cdf0e10cSrcweir };
78cdf0e10cSrcweir 
StringMirror_getSupportedServiceNames()79cdf0e10cSrcweir Sequence< OUString > StringMirror_getSupportedServiceNames()
80cdf0e10cSrcweir {
81cdf0e10cSrcweir 	static OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.StringMirror" ) );
82cdf0e10cSrcweir 	static Sequence< OUString > aServiceNames( &aServiceName, 1 );
83cdf0e10cSrcweir 	return aServiceNames;
84cdf0e10cSrcweir }
85cdf0e10cSrcweir 
StringMirror_getImplementationName()86cdf0e10cSrcweir OUString StringMirror_getImplementationName()
87cdf0e10cSrcweir {
88cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM( "vcl::StringMirror" ) );
89cdf0e10cSrcweir }
90cdf0e10cSrcweir 
StringMirror_createInstance(const Reference<XMultiServiceFactory> &)91cdf0e10cSrcweir Reference< XInterface > SAL_CALL StringMirror_createInstance( const Reference< XMultiServiceFactory >&  )
92cdf0e10cSrcweir {
93cdf0e10cSrcweir 	return static_cast< ::cppu::OWeakObject * >( new StringMirror );
94cdf0e10cSrcweir }
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 
97cdf0e10cSrcweir // XServiceInfo
getImplementationName()98cdf0e10cSrcweir OUString SAL_CALL StringMirror::getImplementationName() throw (RuntimeException)
99cdf0e10cSrcweir {
100cdf0e10cSrcweir 	return StringMirror_getImplementationName();
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
supportsService(const OUString & i_rServiceName)103cdf0e10cSrcweir sal_Bool SAL_CALL StringMirror::supportsService( const OUString& i_rServiceName ) throw (RuntimeException)
104cdf0e10cSrcweir {
105cdf0e10cSrcweir 	Sequence< OUString > aSN( StringMirror_getSupportedServiceNames() );
106cdf0e10cSrcweir 	for( sal_Int32 nService = 0; nService < aSN.getLength(); nService++ )
107cdf0e10cSrcweir 	{
108cdf0e10cSrcweir 		if( aSN[nService] == i_rServiceName )
109cdf0e10cSrcweir 			return sal_True;
110cdf0e10cSrcweir 	}
111cdf0e10cSrcweir 	return sal_False;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
getSupportedServiceNames()114cdf0e10cSrcweir Sequence< OUString > SAL_CALL StringMirror::getSupportedServiceNames() throw (RuntimeException)
115cdf0e10cSrcweir {
116cdf0e10cSrcweir 	return StringMirror_getSupportedServiceNames();
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir } // namespace vcl
120