merge the formfield patch from ooo-build
[ooovba.git] / oox / source / shape / FastTokenHandlerService.cxx
blob716008078b8004e35734cee51340c035c058597e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FastTokenHandlerService.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 #include "FastTokenHandlerService.hxx"
33 namespace oox {
34 namespace shape {
36 using namespace ::com::sun::star;
38 FastTokenHandlerService::FastTokenHandlerService(uno::Reference< uno::XComponentContext > const & context) :
39 m_xContext(context)
42 // com.sun.star.uno.XServiceInfo:
43 ::rtl::OUString SAL_CALL FastTokenHandlerService::getImplementationName() throw (uno::RuntimeException)
45 return FastTokenHandlerService_getImplementationName();
48 ::sal_Bool SAL_CALL FastTokenHandlerService::supportsService(::rtl::OUString const & serviceName) throw (uno::RuntimeException)
50 uno::Sequence< ::rtl::OUString > serviceNames = FastTokenHandlerService_getSupportedServiceNames();
51 for (::sal_Int32 i = 0; i < serviceNames.getLength(); ++i) {
52 if (serviceNames[i] == serviceName)
53 return sal_True;
55 return sal_False;
58 uno::Sequence< ::rtl::OUString > SAL_CALL FastTokenHandlerService::getSupportedServiceNames() throw (uno::RuntimeException)
60 return FastTokenHandlerService_getSupportedServiceNames();
63 ::sal_Int32 SAL_CALL FastTokenHandlerService::getToken(const ::rtl::OUString & Identifier) throw (::com::sun::star::uno::RuntimeException)
65 return mFastTokenHandler.getToken(Identifier);
68 ::rtl::OUString SAL_CALL FastTokenHandlerService::getIdentifier(::sal_Int32 Token) throw (::com::sun::star::uno::RuntimeException)
70 return mFastTokenHandler.getIdentifier(Token);
73 ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL FastTokenHandlerService::getUTF8Identifier( ::sal_Int32 Token ) throw (::com::sun::star::uno::RuntimeException)
75 return mFastTokenHandler.getUTF8Identifier(Token);
78 ::sal_Int32 SAL_CALL FastTokenHandlerService::getTokenFromUTF8(const ::com::sun::star::uno::Sequence< ::sal_Int8 > & Identifier) throw (::com::sun::star::uno::RuntimeException)
80 return mFastTokenHandler.getTokenFromUTF8(Identifier);
83 ::rtl::OUString SAL_CALL FastTokenHandlerService_getImplementationName() {
84 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
85 "com.sun.star.comp.oox.FastTokenHandlerService"));
88 uno::Sequence< ::rtl::OUString > SAL_CALL FastTokenHandlerService_getSupportedServiceNames()
90 uno::Sequence< ::rtl::OUString > s(1);
91 s[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
92 "com.sun.star.xml.sax.FastTokenHandler"));
93 return s;
96 uno::Reference< uno::XInterface > SAL_CALL FastTokenHandlerService_create(
97 const uno::Reference< uno::XComponentContext > & context)
98 SAL_THROW((uno::Exception))
100 return static_cast< ::cppu::OWeakObject * >(new FastTokenHandlerService(context));
103 uno::Reference< uno::XInterface > SAL_CALL
104 FastTokenHandlerService_createInstance
105 ( const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
106 throw( uno::Exception )
108 uno::Reference<beans::XPropertySet>
109 xPropertySet(rSMgr, uno::UNO_QUERY_THROW);
110 uno::Any aDefaultContext = xPropertySet->getPropertyValue
111 (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")));
113 uno::Reference<uno::XComponentContext> xContext;
114 aDefaultContext >>= xContext;
116 return FastTokenHandlerService_create(xContext);