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>
25
26using namespace ::com::sun::star;
27
28namespace oox::core {
29
30using namespace ::com::sun::star::uno;
31
33 mrTokenMap( StaticTokenMap() )
34{
35}
36
38{
39}
40
41// XServiceInfo
43{
44 return "com.sun.star.comp.oox.core.FastTokenHandler";
45}
46
47sal_Bool SAL_CALL FastTokenHandler::supportsService( const OUString& rServiceName )
48{
49 return cppu::supportsService(this, rServiceName);
50}
51
52Sequence< OUString > SAL_CALL FastTokenHandler::getSupportedServiceNames()
53{
54 Sequence<OUString> aServiceNames { "com.sun.star.xml.sax.FastTokenHandler" };
55 return aServiceNames;
56}
57
59{
61}
62
63sal_Int32 FastTokenHandler::getTokenFromUTF8( const Sequence< sal_Int8 >& rIdentifier )
64{
65 return mrTokenMap.getTokenFromUtf8( rIdentifier );
66}
67
68sal_Int32 FastTokenHandler::getTokenDirect( const char *pToken, sal_Int32 nLength ) const
69{
70 return mrTokenMap.getTokenFromUTF8( pToken, nLength );
71}
72
73} // namespace oox::core
74
75extern "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::Sequence< sal_Int8 > const & getUtf8TokenName(sal_Int32 nToken) const
Returns the UTF8 name of the passed token identifier as byte sequence.
Definition: tokenmap.hxx:49
sal_Int32 getTokenFromUtf8(const css::uno::Sequence< sal_Int8 > &rUtf8Name) const
Returns the token identifier for the passed UTF8 token name.
Definition: tokenmap.hxx:58
sal_Int32 getTokenFromUTF8(const char *pToken, sal_Int32 nLength) const
Returns the token identifier for a UTF8 string passed in pToken.
Definition: tokenmap.hxx:67
Wrapper implementing the com.sun.star.xml.sax.XFastTokenHandler API interface that provides access to...
virtual sal_Int32 getTokenDirect(const char *pToken, sal_Int32 nLength) const override
const TokenMap & mrTokenMap
Reference to global token map singleton.
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier(sal_Int32 nToken) override
virtual sal_Int32 SAL_CALL getTokenFromUTF8(const css::uno::Sequence< sal_Int8 > &Identifier) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ~FastTokenHandler() override
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Sequence< OUString > aServiceNames
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_oox_core_FastTokenHandler_get_implementation(uno::XComponentContext *, uno::Sequence< uno::Any > const &)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
TokenMap & StaticTokenMap()
Definition: tokenmap.cxx:90
DefTokenId nToken
unsigned char sal_Bool
sal_Int32 nLength