Branch data Line data Source code
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 : :
20 : : #ifndef _PROVIDER_HXX
21 : : #define _PROVIDER_HXX
22 : :
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>
30 : :
31 : :
32 : : namespace chelp {
33 : :
34 : : //=========================================================================
35 : :
36 : : // UNO service name for the provider. This name will be used by the UCB to
37 : : // create instances of the provider.
38 : :
39 : : #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME1 "com.sun.star.help.XMLHelp"
40 : : #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME_LENGTH1 25
41 : :
42 : : #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME2 "com.sun.star.ucb.HelpContentProvider"
43 : : #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME_LENGTH2 36
44 : :
45 : : // URL scheme. This is the scheme the provider will be able to create
46 : : // contents for. The UCB will select the provider ( i.e. in order to create
47 : : // contents ) according to this scheme.
48 : :
49 : : #define MYUCP_URL_SCHEME "vnd.sun.star.help"
50 : : #define MYUCP_URL_SCHEME_LENGTH 18
51 : : #define MYUCP_CONTENT_TYPE "application/vnd.sun.star.xmlhelp" // UCB Content Type.
52 : :
53 : : //=========================================================================
54 : :
55 : :
56 : : class Databases;
57 : :
58 : :
59 : : class ContentProvider :
60 : : public ::ucbhelper::ContentProviderImplHelper,
61 : : public ::com::sun::star::container::XContainerListener,
62 : : public ::com::sun::star::lang::XComponent
63 : : {
64 : : public:
65 : : ContentProvider(
66 : : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rSMgr );
67 : :
68 : : virtual ~ContentProvider();
69 : :
70 : : // XInterface
71 : : XINTERFACE_DECL()
72 : :
73 : : // XTypeProvider
74 : : XTYPEPROVIDER_DECL()
75 : :
76 : : // XServiceInfo
77 : : XSERVICEINFO_DECL()
78 : :
79 : : // XContentProvider
80 : : virtual ::com::sun::star::uno::Reference<
81 : : ::com::sun::star::ucb::XContent > SAL_CALL
82 : : queryContent( const ::com::sun::star::uno::Reference<
83 : : ::com::sun::star::ucb::XContentIdentifier >& Identifier )
84 : : throw( ::com::sun::star::ucb::IllegalIdentifierException,
85 : : ::com::sun::star::uno::RuntimeException );
86 : :
87 : : //////////////////////////////////////////////////////////////////////
88 : : // Additional interfaces
89 : : //////////////////////////////////////////////////////////////////////
90 : :
91 : : // XComponent
92 : :
93 : : virtual void SAL_CALL
94 : : dispose( )
95 : : throw (::com::sun::star::uno::RuntimeException);
96 : :
97 : : virtual void SAL_CALL
98 : 0 : addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener )
99 : : throw (::com::sun::star::uno::RuntimeException)
100 : : {
101 : : (void)xListener;
102 : 0 : }
103 : :
104 : : virtual void SAL_CALL
105 : 0 : removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener )
106 : : throw (::com::sun::star::uno::RuntimeException)
107 : : {
108 : : (void)aListener;
109 : 0 : }
110 : :
111 : : // XConainerListener ( deriver from XEventListener )
112 : :
113 : : virtual void SAL_CALL
114 : 0 : disposing( const ::com::sun::star::lang::EventObject& Source )
115 : : throw (::com::sun::star::uno::RuntimeException)
116 : : {
117 : : (void)Source;
118 [ # # ]: 0 : m_xContainer = com::sun::star::uno::Reference<com::sun::star::container::XContainer>(0);
119 : 0 : }
120 : :
121 : : virtual void SAL_CALL
122 : 0 : elementInserted( const ::com::sun::star::container::ContainerEvent& Event )
123 : : throw (::com::sun::star::uno::RuntimeException)
124 : : {
125 : : (void)Event;
126 : 0 : }
127 : :
128 : : virtual void SAL_CALL
129 : 0 : elementRemoved( const ::com::sun::star::container::ContainerEvent& Event )
130 : : throw (::com::sun::star::uno::RuntimeException)
131 : : {
132 : : (void)Event;
133 : 0 : }
134 : :
135 : : virtual void SAL_CALL
136 : : elementReplaced( const ::com::sun::star::container::ContainerEvent& Event )
137 : : throw (::com::sun::star::uno::RuntimeException);
138 : :
139 : :
140 : : //////////////////////////////////////////////////////////////////////
141 : : // Non-interface methods.
142 : : //////////////////////////////////////////////////////////////////////
143 : :
144 : : private:
145 : :
146 : : osl::Mutex m_aMutex;
147 : : bool isInitialized;
148 : : rtl::OUString m_aScheme;
149 : : Databases* m_pDatabases;
150 : : com::sun::star::uno::Reference<com::sun::star::container::XContainer> m_xContainer;
151 : :
152 : : // private methods
153 : :
154 : : void init();
155 : :
156 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
157 : : getConfiguration() const;
158 : :
159 : : ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >
160 : : getHierAccess( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& sProvider,
161 : : const char* file ) const;
162 : :
163 : : ::rtl::OUString
164 : : getKey( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess,
165 : : const char* key ) const;
166 : :
167 : : sal_Bool
168 : : getBooleanKey(
169 : : const ::com::sun::star::uno::Reference<
170 : : ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess,
171 : : const char* key) const;
172 : :
173 : : void subst( rtl::OUString& instpath ) const;
174 : : };
175 : :
176 : : }
177 : :
178 : : #endif
179 : :
180 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|