1*ca5ec200SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ca5ec200SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ca5ec200SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ca5ec200SAndrew Rist  * distributed with this work for additional information
6*ca5ec200SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ca5ec200SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ca5ec200SAndrew Rist  * "License"); you may not use this file except in compliance
9*ca5ec200SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ca5ec200SAndrew Rist  *
11*ca5ec200SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ca5ec200SAndrew Rist  *
13*ca5ec200SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ca5ec200SAndrew Rist  * software distributed under the License is distributed on an
15*ca5ec200SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ca5ec200SAndrew Rist  * KIND, either express or implied.  See the License for the
17*ca5ec200SAndrew Rist  * specific language governing permissions and limitations
18*ca5ec200SAndrew Rist  * under the License.
19*ca5ec200SAndrew Rist  *
20*ca5ec200SAndrew Rist  *************************************************************/
21*ca5ec200SAndrew Rist 
22*ca5ec200SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "oox/core/fasttokenhandler.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
27cdf0e10cSrcweir #include "oox/helper/helper.hxx"
28cdf0e10cSrcweir #include "oox/token/tokenmap.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir namespace oox {
31cdf0e10cSrcweir namespace core {
32cdf0e10cSrcweir 
33cdf0e10cSrcweir // ============================================================================
34cdf0e10cSrcweir 
35cdf0e10cSrcweir using namespace ::com::sun::star::uno;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir using ::rtl::OUString;
38cdf0e10cSrcweir 
39cdf0e10cSrcweir // ============================================================================
40cdf0e10cSrcweir 
FastTokenHandler_getImplementationName()41cdf0e10cSrcweir OUString SAL_CALL FastTokenHandler_getImplementationName()
42cdf0e10cSrcweir {
43cdf0e10cSrcweir     return CREATE_OUSTRING( "com.sun.star.comp.oox.core.FastTokenHandler" );
44cdf0e10cSrcweir }
45cdf0e10cSrcweir 
FastTokenHandler_getSupportedServiceNames()46cdf0e10cSrcweir Sequence< OUString > SAL_CALL FastTokenHandler_getSupportedServiceNames()
47cdf0e10cSrcweir {
48cdf0e10cSrcweir     Sequence< OUString > aServiceNames( 1 );
49cdf0e10cSrcweir     aServiceNames[ 0 ] = CREATE_OUSTRING( "com.sun.star.xml.sax.FastTokenHandler" );
50cdf0e10cSrcweir     return aServiceNames;
51cdf0e10cSrcweir }
52cdf0e10cSrcweir 
FastTokenHandler_createInstance(const Reference<XComponentContext> &)53cdf0e10cSrcweir Reference< XInterface > SAL_CALL FastTokenHandler_createInstance( const Reference< XComponentContext >& /*rxContext*/ ) throw (Exception)
54cdf0e10cSrcweir {
55cdf0e10cSrcweir     return static_cast< ::cppu::OWeakObject* >( new FastTokenHandler );
56cdf0e10cSrcweir }
57cdf0e10cSrcweir 
58cdf0e10cSrcweir // ============================================================================
59cdf0e10cSrcweir 
FastTokenHandler()60cdf0e10cSrcweir FastTokenHandler::FastTokenHandler() :
61cdf0e10cSrcweir     mrTokenMap( StaticTokenMap::get() )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir }
64cdf0e10cSrcweir 
~FastTokenHandler()65cdf0e10cSrcweir FastTokenHandler::~FastTokenHandler()
66cdf0e10cSrcweir {
67cdf0e10cSrcweir }
68cdf0e10cSrcweir 
69cdf0e10cSrcweir // XServiceInfo
70cdf0e10cSrcweir 
getImplementationName()71cdf0e10cSrcweir OUString SAL_CALL FastTokenHandler::getImplementationName() throw (RuntimeException)
72cdf0e10cSrcweir {
73cdf0e10cSrcweir     return FastTokenHandler_getImplementationName();
74cdf0e10cSrcweir }
75cdf0e10cSrcweir 
supportsService(const OUString & rServiceName)76cdf0e10cSrcweir sal_Bool SAL_CALL FastTokenHandler::supportsService( const OUString& rServiceName ) throw (RuntimeException)
77cdf0e10cSrcweir {
78cdf0e10cSrcweir     Sequence< OUString > aServiceNames = FastTokenHandler_getSupportedServiceNames();
79cdf0e10cSrcweir     for( sal_Int32 nIndex = 0, nLength = aServiceNames.getLength(); nIndex < nLength; ++nIndex )
80cdf0e10cSrcweir         if( aServiceNames[ nIndex ] == rServiceName )
81cdf0e10cSrcweir             return sal_True;
82cdf0e10cSrcweir     return sal_False;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
getSupportedServiceNames()85cdf0e10cSrcweir Sequence< OUString > SAL_CALL FastTokenHandler::getSupportedServiceNames() throw (RuntimeException)
86cdf0e10cSrcweir {
87cdf0e10cSrcweir     return FastTokenHandler_getSupportedServiceNames();
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir // XFastTokenHandler
91cdf0e10cSrcweir 
getToken(const OUString & rIdentifier)92cdf0e10cSrcweir sal_Int32 FastTokenHandler::getToken( const OUString& rIdentifier ) throw( RuntimeException )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir     return mrTokenMap.getTokenFromUnicode( rIdentifier );
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
getIdentifier(sal_Int32 nToken)97cdf0e10cSrcweir OUString FastTokenHandler::getIdentifier( sal_Int32 nToken ) throw( RuntimeException )
98cdf0e10cSrcweir {
99cdf0e10cSrcweir     return mrTokenMap.getUnicodeTokenName( nToken );
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
getUTF8Identifier(sal_Int32 nToken)102cdf0e10cSrcweir Sequence< sal_Int8 > FastTokenHandler::getUTF8Identifier( sal_Int32 nToken ) throw( RuntimeException )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     return mrTokenMap.getUtf8TokenName( nToken );
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
getTokenFromUTF8(const Sequence<sal_Int8> & rIdentifier)107cdf0e10cSrcweir sal_Int32 FastTokenHandler::getTokenFromUTF8( const Sequence< sal_Int8 >& rIdentifier ) throw( RuntimeException )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir     return mrTokenMap.getTokenFromUtf8( rIdentifier );
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir // ============================================================================
113cdf0e10cSrcweir 
114cdf0e10cSrcweir } // namespace core
115cdf0e10cSrcweir } // namespace oox
116