xref: /trunk/main/xmlhelp/source/cxxhelp/provider/provider.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _PROVIDER_HXX
29 #define _PROVIDER_HXX
30 
31 #include <rtl/ustring.hxx>
32 #include <osl/mutex.hxx>
33 #include <ucbhelper/providerhelper.hxx>
34 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
35 #include <com/sun/star/container/XContainerListener.hpp>
36 #include <com/sun/star/container/XContainer.hpp>
37 #include <com/sun/star/lang/XComponent.hpp>
38 
39 
40 namespace chelp {
41 
42 //=========================================================================
43 
44 // UNO service name for the provider. This name will be used by the UCB to
45 // create instances of the provider.
46 
47 //#define MYUCP_CONTENT_PROVIDER_SERVICE_NAME         "com.sun.star.ucb.CHelpContentProvider"
48 #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME1   "com.sun.star.help.XMLHelp"
49 #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME_LENGTH1 25
50 
51 #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME2  "com.sun.star.ucb.HelpContentProvider"
52 #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME_LENGTH2 36
53 
54 // URL scheme. This is the scheme the provider will be able to create
55 // contents for. The UCB will select the provider ( i.e. in order to create
56 // contents ) according to this scheme.
57 
58 #define MYUCP_URL_SCHEME        "vnd.sun.star.help"
59 #define MYUCP_URL_SCHEME_LENGTH 18
60 #define MYUCP_CONTENT_TYPE      "application/vnd.sun.star.xmlhelp"    // UCB Content Type.
61 
62 //=========================================================================
63 
64 
65     class Databases;
66 
67 
68     class ContentProvider :
69         public ::ucbhelper::ContentProviderImplHelper,
70         public ::com::sun::star::container::XContainerListener,
71         public ::com::sun::star::lang::XComponent
72     {
73     public:
74         ContentProvider(
75             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rSMgr );
76 
77         virtual ~ContentProvider();
78 
79         // XInterface
80         XINTERFACE_DECL()
81 
82             // XTypeProvider
83             XTYPEPROVIDER_DECL()
84 
85             // XServiceInfo
86             XSERVICEINFO_DECL()
87 
88             // XContentProvider
89             virtual ::com::sun::star::uno::Reference<
90         ::com::sun::star::ucb::XContent > SAL_CALL
91         queryContent( const ::com::sun::star::uno::Reference<
92                       ::com::sun::star::ucb::XContentIdentifier >& Identifier )
93             throw( ::com::sun::star::ucb::IllegalIdentifierException,
94                    ::com::sun::star::uno::RuntimeException );
95 
96         //////////////////////////////////////////////////////////////////////
97         // Additional interfaces
98         //////////////////////////////////////////////////////////////////////
99 
100         // XComponent
101 
102         virtual void SAL_CALL
103         dispose(  )
104             throw (::com::sun::star::uno::RuntimeException);
105 
106         virtual void SAL_CALL
107         addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener )
108             throw (::com::sun::star::uno::RuntimeException)
109         {
110             (void)xListener;
111         }
112 
113         virtual void SAL_CALL
114         removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener )
115             throw (::com::sun::star::uno::RuntimeException)
116         {
117             (void)aListener;
118         }
119 
120         // XConainerListener ( deriver from XEventListener )
121 
122         virtual void SAL_CALL
123         disposing( const ::com::sun::star::lang::EventObject& Source )
124             throw (::com::sun::star::uno::RuntimeException)
125         {
126             (void)Source;
127             m_xContainer = com::sun::star::uno::Reference<com::sun::star::container::XContainer>(0);
128         }
129 
130         virtual void SAL_CALL
131         elementInserted( const ::com::sun::star::container::ContainerEvent& Event )
132             throw (::com::sun::star::uno::RuntimeException)
133         {
134             (void)Event;
135         }
136 
137         virtual void SAL_CALL
138         elementRemoved( const ::com::sun::star::container::ContainerEvent& Event )
139             throw (::com::sun::star::uno::RuntimeException)
140         {
141             (void)Event;
142         }
143 
144         virtual void SAL_CALL
145         elementReplaced( const ::com::sun::star::container::ContainerEvent& Event )
146             throw (::com::sun::star::uno::RuntimeException);
147 
148 
149         //////////////////////////////////////////////////////////////////////
150         // Non-interface methods.
151         //////////////////////////////////////////////////////////////////////
152 
153     private:
154 
155         osl::Mutex     m_aMutex;
156         bool           isInitialized;
157         rtl::OUString  m_aScheme;
158         Databases*     m_pDatabases;
159         com::sun::star::uno::Reference<com::sun::star::container::XContainer> m_xContainer;
160 
161         // private methods
162 
163         void init();
164 
165         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
166         getConfiguration() const;
167 
168         ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >
169         getHierAccess( const ::com::sun::star::uno::Reference<  ::com::sun::star::lang::XMultiServiceFactory >& sProvider,
170                        const char* file ) const;
171 
172         ::rtl::OUString
173         getKey( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess,
174                 const char* key ) const;
175 
176       sal_Bool
177       getBooleanKey(
178                     const ::com::sun::star::uno::Reference<
179                     ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess,
180                     const char* key) const;
181 
182       void subst( rtl::OUString& instpath ) const;
183     };
184 
185 }
186 
187 #endif
188