bump product version to 5.0.4.1
[LibreOffice.git] / xmlhelp / source / cxxhelp / provider / provider.hxx
blob0e3994d136fb7979d8a2b1e6ee77e79c6b57d10b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_XMLHELP_SOURCE_CXXHELP_PROVIDER_PROVIDER_HXX
21 #define INCLUDED_XMLHELP_SOURCE_CXXHELP_PROVIDER_PROVIDER_HXX
23 #include <rtl/ustring.hxx>
24 #include <osl/mutex.hxx>
25 #include <ucbhelper/providerhelper.hxx>
26 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
27 #include <com/sun/star/container/XContainerListener.hpp>
28 #include <com/sun/star/container/XContainer.hpp>
29 #include <com/sun/star/lang/XComponent.hpp>
31 namespace chelp {
33 // UNO service name for the provider. This name will be used by the UCB to
34 // create instances of the provider.
36 #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME1 "com.sun.star.help.XMLHelp"
38 #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME2 "com.sun.star.ucb.HelpContentProvider"
40 // URL scheme. This is the scheme the provider will be able to create
41 // contents for. The UCB will select the provider ( i.e. in order to create
42 // contents ) according to this scheme.
44 #define MYUCP_URL_SCHEME "vnd.sun.star.help"
45 #define MYUCP_CONTENT_TYPE "application/vnd.sun.star.xmlhelp" // UCB Content Type.
47 class Databases;
49 class ContentProvider :
50 public ::ucbhelper::ContentProviderImplHelper,
51 public ::com::sun::star::container::XContainerListener,
52 public ::com::sun::star::lang::XComponent
54 public:
55 ContentProvider(
56 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
58 virtual ~ContentProvider();
60 // XInterface
61 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType )
62 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
63 virtual void SAL_CALL acquire()
64 throw() SAL_OVERRIDE;
65 virtual void SAL_CALL release()
66 throw() SAL_OVERRIDE;
68 // XTypeProvider
69 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
70 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
71 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
72 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
74 // XServiceInfo
75 virtual OUString SAL_CALL getImplementationName()
76 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
77 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
78 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
79 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
80 throw( css::uno::RuntimeException,
81 std::exception ) SAL_OVERRIDE;
83 static OUString getImplementationName_Static();
85 static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
87 static css::uno::Reference< css::lang::XSingleServiceFactory > createServiceFactory(
88 const css::uno::Reference< css::lang::XMultiServiceFactory >& rxServiceMgr );
90 // XContentProvider
91 virtual css::uno::Reference< css::ucb::XContent > SAL_CALL queryContent(
92 const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier )
93 throw( css::ucb::IllegalIdentifierException,
94 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
96 // Additional interfaces
98 // XComponent
100 virtual void SAL_CALL
101 dispose( )
102 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
104 virtual void SAL_CALL
105 addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener )
106 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
108 (void)xListener;
111 virtual void SAL_CALL
112 removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener )
113 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
115 (void)aListener;
118 // XConainerListener ( deriver from XEventListener )
120 virtual void SAL_CALL
121 disposing( const ::com::sun::star::lang::EventObject& Source )
122 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
124 (void)Source;
125 m_xContainer = com::sun::star::uno::Reference<com::sun::star::container::XContainer>(0);
128 virtual void SAL_CALL
129 elementInserted( const ::com::sun::star::container::ContainerEvent& Event )
130 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
132 (void)Event;
135 virtual void SAL_CALL
136 elementRemoved( const ::com::sun::star::container::ContainerEvent& Event )
137 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
139 (void)Event;
142 virtual void SAL_CALL
143 elementReplaced( const ::com::sun::star::container::ContainerEvent& Event )
144 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
146 // Non-interface methods.
148 private:
150 osl::Mutex m_aMutex;
151 bool isInitialized;
152 OUString m_aScheme;
153 Databases* m_pDatabases;
154 com::sun::star::uno::Reference<com::sun::star::container::XContainer> m_xContainer;
156 // private methods
158 void init();
160 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
161 getConfiguration() const;
163 static ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >
164 getHierAccess( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& sProvider,
165 const char* file );
167 static OUString
168 getKey( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess,
169 const char* key );
171 static bool
172 getBooleanKey(
173 const ::com::sun::star::uno::Reference<
174 ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess,
175 const char* key);
177 static void subst( OUString& instpath );
182 #endif
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */