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 24 #include "oox/core/fasttokenhandler.hxx" 25 26 #include <com/sun/star/uno/XComponentContext.hpp> 27 #include "oox/helper/helper.hxx" 28 #include "oox/token/tokenmap.hxx" 29 30 namespace oox { 31 namespace core { 32 33 // ============================================================================ 34 35 using namespace ::com::sun::star::uno; 36 37 using ::rtl::OUString; 38 39 // ============================================================================ 40 FastTokenHandler_getImplementationName()41OUString SAL_CALL FastTokenHandler_getImplementationName() 42 { 43 return CREATE_OUSTRING( "com.sun.star.comp.oox.core.FastTokenHandler" ); 44 } 45 FastTokenHandler_getSupportedServiceNames()46Sequence< OUString > SAL_CALL FastTokenHandler_getSupportedServiceNames() 47 { 48 Sequence< OUString > aServiceNames( 1 ); 49 aServiceNames[ 0 ] = CREATE_OUSTRING( "com.sun.star.xml.sax.FastTokenHandler" ); 50 return aServiceNames; 51 } 52 FastTokenHandler_createInstance(const Reference<XComponentContext> &)53Reference< XInterface > SAL_CALL FastTokenHandler_createInstance( const Reference< XComponentContext >& /*rxContext*/ ) throw (Exception) 54 { 55 return static_cast< ::cppu::OWeakObject* >( new FastTokenHandler ); 56 } 57 58 // ============================================================================ 59 FastTokenHandler()60FastTokenHandler::FastTokenHandler() : 61 mrTokenMap( StaticTokenMap::get() ) 62 { 63 } 64 ~FastTokenHandler()65FastTokenHandler::~FastTokenHandler() 66 { 67 } 68 69 // XServiceInfo 70 getImplementationName()71OUString SAL_CALL FastTokenHandler::getImplementationName() throw (RuntimeException) 72 { 73 return FastTokenHandler_getImplementationName(); 74 } 75 supportsService(const OUString & rServiceName)76sal_Bool SAL_CALL FastTokenHandler::supportsService( const OUString& rServiceName ) throw (RuntimeException) 77 { 78 Sequence< OUString > aServiceNames = FastTokenHandler_getSupportedServiceNames(); 79 for( sal_Int32 nIndex = 0, nLength = aServiceNames.getLength(); nIndex < nLength; ++nIndex ) 80 if( aServiceNames[ nIndex ] == rServiceName ) 81 return sal_True; 82 return sal_False; 83 } 84 getSupportedServiceNames()85Sequence< OUString > SAL_CALL FastTokenHandler::getSupportedServiceNames() throw (RuntimeException) 86 { 87 return FastTokenHandler_getSupportedServiceNames(); 88 } 89 90 // XFastTokenHandler 91 getToken(const OUString & rIdentifier)92sal_Int32 FastTokenHandler::getToken( const OUString& rIdentifier ) throw( RuntimeException ) 93 { 94 return mrTokenMap.getTokenFromUnicode( rIdentifier ); 95 } 96 getIdentifier(sal_Int32 nToken)97OUString FastTokenHandler::getIdentifier( sal_Int32 nToken ) throw( RuntimeException ) 98 { 99 return mrTokenMap.getUnicodeTokenName( nToken ); 100 } 101 getUTF8Identifier(sal_Int32 nToken)102Sequence< sal_Int8 > FastTokenHandler::getUTF8Identifier( sal_Int32 nToken ) throw( RuntimeException ) 103 { 104 return mrTokenMap.getUtf8TokenName( nToken ); 105 } 106 getTokenFromUTF8(const Sequence<sal_Int8> & rIdentifier)107sal_Int32 FastTokenHandler::getTokenFromUTF8( const Sequence< sal_Int8 >& rIdentifier ) throw( RuntimeException ) 108 { 109 return mrTokenMap.getTokenFromUtf8( rIdentifier ); 110 } 111 112 // ============================================================================ 113 114 } // namespace core 115 } // namespace oox 116