1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _PROVIDER_HXX 25 #define _PROVIDER_HXX 26 27 #include <rtl/ustring.hxx> 28 #include <osl/mutex.hxx> 29 #include <ucbhelper/providerhelper.hxx> 30 #include <com/sun/star/container/XHierarchicalNameAccess.hpp> 31 #include <com/sun/star/container/XContainerListener.hpp> 32 #include <com/sun/star/container/XContainer.hpp> 33 #include <com/sun/star/lang/XComponent.hpp> 34 35 36 namespace chelp { 37 38 //========================================================================= 39 40 // UNO service name for the provider. This name will be used by the UCB to 41 // create instances of the provider. 42 43 //#define MYUCP_CONTENT_PROVIDER_SERVICE_NAME "com.sun.star.ucb.CHelpContentProvider" 44 #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME1 "com.sun.star.help.XMLHelp" 45 #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME_LENGTH1 25 46 47 #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME2 "com.sun.star.ucb.HelpContentProvider" 48 #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME_LENGTH2 36 49 50 // URL scheme. This is the scheme the provider will be able to create 51 // contents for. The UCB will select the provider ( i.e. in order to create 52 // contents ) according to this scheme. 53 54 #define MYUCP_URL_SCHEME "vnd.sun.star.help" 55 #define MYUCP_URL_SCHEME_LENGTH 18 56 #define MYUCP_CONTENT_TYPE "application/vnd.sun.star.xmlhelp" // UCB Content Type. 57 58 //========================================================================= 59 60 61 class Databases; 62 63 64 class ContentProvider : 65 public ::ucbhelper::ContentProviderImplHelper, 66 public ::com::sun::star::container::XContainerListener, 67 public ::com::sun::star::lang::XComponent 68 { 69 public: 70 ContentProvider( 71 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rSMgr ); 72 73 virtual ~ContentProvider(); 74 75 // XInterface 76 XINTERFACE_DECL() 77 78 // XTypeProvider 79 XTYPEPROVIDER_DECL() 80 81 // XServiceInfo 82 XSERVICEINFO_DECL() 83 84 // XContentProvider 85 virtual ::com::sun::star::uno::Reference< 86 ::com::sun::star::ucb::XContent > SAL_CALL 87 queryContent( const ::com::sun::star::uno::Reference< 88 ::com::sun::star::ucb::XContentIdentifier >& Identifier ); 89 90 ////////////////////////////////////////////////////////////////////// 91 // Additional interfaces 92 ////////////////////////////////////////////////////////////////////// 93 94 // XComponent 95 96 virtual void SAL_CALL 97 dispose( ); 98 99 virtual void SAL_CALL addEventListener(const::com::sun::star::uno::Reference<::com::sun::star::lang::XEventListener> & xListener)100 addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) 101 { 102 (void)xListener; 103 } 104 105 virtual void SAL_CALL removeEventListener(const::com::sun::star::uno::Reference<::com::sun::star::lang::XEventListener> & aListener)106 removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) 107 { 108 (void)aListener; 109 } 110 111 // XConainerListener ( deriver from XEventListener ) 112 113 virtual void SAL_CALL disposing(const::com::sun::star::lang::EventObject & Source)114 disposing( const ::com::sun::star::lang::EventObject& Source ) 115 { 116 (void)Source; 117 m_xContainer = com::sun::star::uno::Reference<com::sun::star::container::XContainer>(0); 118 } 119 120 virtual void SAL_CALL elementInserted(const::com::sun::star::container::ContainerEvent & Event)121 elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) 122 { 123 (void)Event; 124 } 125 126 virtual void SAL_CALL elementRemoved(const::com::sun::star::container::ContainerEvent & Event)127 elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) 128 { 129 (void)Event; 130 } 131 132 virtual void SAL_CALL 133 elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ); 134 135 136 ////////////////////////////////////////////////////////////////////// 137 // Non-interface methods. 138 ////////////////////////////////////////////////////////////////////// 139 140 private: 141 142 osl::Mutex m_aMutex; 143 bool isInitialized; 144 rtl::OUString m_aScheme; 145 Databases* m_pDatabases; 146 com::sun::star::uno::Reference<com::sun::star::container::XContainer> m_xContainer; 147 148 // private methods 149 150 void init(); 151 152 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > 153 getConfiguration() const; 154 155 ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess > 156 getHierAccess( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& sProvider, 157 const char* file ) const; 158 159 ::rtl::OUString 160 getKey( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess, 161 const char* key ) const; 162 163 sal_Bool 164 getBooleanKey( 165 const ::com::sun::star::uno::Reference< 166 ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess, 167 const char* key) const; 168 169 void subst( rtl::OUString& instpath ) const; 170 }; 171 172 } 173 174 #endif 175