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 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_vcl.hxx" 30 31 #include "com/sun/star/lang/XServiceInfo.hpp" 32 #include "com/sun/star/util/XStringMapping.hpp" 33 34 #include "cppuhelper/implbase2.hxx" 35 #include "rtl/ustrbuf.hxx" 36 #include "vcl/svapp.hxx" 37 38 using ::rtl::OUString; 39 using namespace ::com::sun::star::uno; 40 using namespace ::com::sun::star::lang; 41 using namespace ::com::sun::star::util; 42 43 // ----------------------------------------------------------------------- 44 45 namespace vcl 46 { 47 48 class StringMirror : public ::cppu::WeakAggImplHelper2< XStringMapping, XServiceInfo > 49 { 50 public: 51 StringMirror() 52 {} 53 54 virtual ~StringMirror() 55 {} 56 57 // XServiceInfo 58 virtual OUString SAL_CALL getImplementationName( ) throw (RuntimeException); 59 virtual ::sal_Bool SAL_CALL supportsService( const OUString& ) throw (RuntimeException); 60 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); 61 62 // XStringMapping 63 virtual sal_Bool SAL_CALL mapStrings( Sequence< OUString >& io_rStrings ) throw (RuntimeException) 64 { 65 sal_Int32 nItems = io_rStrings.getLength(); 66 for( sal_Int32 n = 0; n < nItems; n++ ) 67 { 68 rtl::OUString& rStr( io_rStrings.getArray()[n] ); 69 70 sal_Int32 nLen = rStr.getLength(); 71 rtl::OUStringBuffer aMirror( nLen ); 72 for(sal_Int32 i = nLen - 1; i >= 0; i--) 73 { 74 sal_Unicode cChar = rStr[ i ]; 75 aMirror.append(sal_Unicode(GetMirroredChar(cChar))); 76 } 77 rStr = aMirror.makeStringAndClear(); 78 } 79 return sal_True; 80 } 81 }; 82 83 Sequence< OUString > StringMirror_getSupportedServiceNames() 84 { 85 static OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.StringMirror" ) ); 86 static Sequence< OUString > aServiceNames( &aServiceName, 1 ); 87 return aServiceNames; 88 } 89 90 OUString StringMirror_getImplementationName() 91 { 92 return OUString( RTL_CONSTASCII_USTRINGPARAM( "vcl::StringMirror" ) ); 93 } 94 95 Reference< XInterface > SAL_CALL StringMirror_createInstance( const Reference< XMultiServiceFactory >& ) 96 { 97 return static_cast< ::cppu::OWeakObject * >( new StringMirror ); 98 } 99 100 101 // XServiceInfo 102 OUString SAL_CALL StringMirror::getImplementationName() throw (RuntimeException) 103 { 104 return StringMirror_getImplementationName(); 105 } 106 107 sal_Bool SAL_CALL StringMirror::supportsService( const OUString& i_rServiceName ) throw (RuntimeException) 108 { 109 Sequence< OUString > aSN( StringMirror_getSupportedServiceNames() ); 110 for( sal_Int32 nService = 0; nService < aSN.getLength(); nService++ ) 111 { 112 if( aSN[nService] == i_rServiceName ) 113 return sal_True; 114 } 115 return sal_False; 116 } 117 118 Sequence< OUString > SAL_CALL StringMirror::getSupportedServiceNames() throw (RuntimeException) 119 { 120 return StringMirror_getSupportedServiceNames(); 121 } 122 123 } // namespace vcl 124