LibreOffice Module oox (master)  1
fasttokenhandler.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
21 
22 #include <com/sun/star/uno/XComponentContext.hpp>
23 #include <oox/token/tokenmap.hxx>
25 
26 using namespace ::com::sun::star;
27 
28 namespace oox::core {
29 
30 using namespace ::com::sun::star::uno;
31 
33  mrTokenMap( StaticTokenMap::get() )
34 {
35 }
36 
38 {
39 }
40 
41 // XServiceInfo
43 {
44  return "com.sun.star.comp.oox.core.FastTokenHandler";
45 }
46 
47 sal_Bool SAL_CALL FastTokenHandler::supportsService( const OUString& rServiceName )
48 {
49  return cppu::supportsService(this, rServiceName);
50 }
51 
53 {
54  Sequence<OUString> aServiceNames { "com.sun.star.xml.sax.FastTokenHandler" };
55  return aServiceNames;
56 }
57 
59 {
60  return mrTokenMap.getUtf8TokenName( nToken );
61 }
62 
63 sal_Int32 FastTokenHandler::getTokenFromUTF8( const Sequence< sal_Int8 >& rIdentifier )
64 {
65  return mrTokenMap.getTokenFromUtf8( rIdentifier );
66 }
67 
68 sal_Int32 FastTokenHandler::getTokenDirect( const char *pToken, sal_Int32 nLength ) const
69 {
70  return mrTokenMap.getTokenFromUTF8( pToken, nLength );
71 }
72 
73 } // namespace oox::core
74 
75 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
77  uno::XComponentContext* /*pCtx*/, uno::Sequence<uno::Any> const& /*rSeq*/)
78 {
79  return cppu::acquire(new oox::core::FastTokenHandler());
80 }
81 
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
virtual ~FastTokenHandler() override
const TokenMap & mrTokenMap
Reference to global token map singleton.
sal_Int32 getTokenFromUtf8(const css::uno::Sequence< sal_Int8 > &rUtf8Name) const
Returns the token identifier for the passed UTF8 token name.
Definition: tokenmap.hxx:59
Sequence< OUString > aServiceNames
virtual sal_Int32 SAL_CALL getTokenFromUTF8(const css::uno::Sequence< sal_Int8 > &Identifier) override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier(sal_Int32 nToken) override
sal_Int32 getTokenFromUTF8(const char *pToken, sal_Int32 nLength) const
Returns the token identifier for a UTF8 string passed in pToken.
Definition: tokenmap.hxx:68
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual OUString SAL_CALL getImplementationName() override
css::uno::Sequence< sal_Int8 > const & getUtf8TokenName(sal_Int32 nToken) const
Returns the UTF8 name of the passed token identifier as byte sequence.
Definition: tokenmap.hxx:50
unsigned char sal_Bool
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_oox_core_FastTokenHandler_get_implementation(uno::XComponentContext *, uno::Sequence< uno::Any > const &)
virtual sal_Int32 getTokenDirect(const char *pToken, sal_Int32 nLength) const override
Wrapper implementing the com.sun.star.xml.sax.XFastTokenHandler API interface that provides access to...
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override