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 INCLUDED_XMLHELP_SOURCE_CXXHELP_PROVIDER_PROVIDER_HXX 21 #define INCLUDED_XMLHELP_SOURCE_CXXHELP_PROVIDER_PROVIDER_HXX 22 23 #include <memory> 24 #include <rtl/ustring.hxx> 25 #include <ucbhelper/providerhelper.hxx> 26 #include <com/sun/star/container/XContainerListener.hpp> 27 #include <com/sun/star/container/XContainer.hpp> 28 #include <com/sun/star/lang/XComponent.hpp> 29 #include <com/sun/star/lang/XSingleServiceFactory.hpp> 30 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 31 32 namespace chelp { 33 34 // UNO service name for the provider. This name will be used by the UCB to 35 // create instances of the provider. 36 37 #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME1 "com.sun.star.help.XMLHelp" 38 39 #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME2 "com.sun.star.ucb.HelpContentProvider" 40 41 // URL scheme. This is the scheme the provider will be able to create 42 // contents for. The UCB will select the provider ( i.e. in order to create 43 // contents ) according to this scheme. 44 45 #define MYUCP_URL_SCHEME "vnd.sun.star.help" 46 #define MYUCP_CONTENT_TYPE "application/vnd.sun.star.xmlhelp" // UCB Content Type. 47 48 class Databases; 49 50 class ContentProvider : 51 public ::ucbhelper::ContentProviderImplHelper, 52 public css::container::XContainerListener, 53 public css::lang::XComponent 54 { 55 public: 56 explicit ContentProvider( 57 const css::uno::Reference< css::uno::XComponentContext >& rxContext ); 58 59 virtual ~ContentProvider() override; 60 61 // XInterface 62 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; 63 virtual void SAL_CALL acquire() 64 throw() override; 65 virtual void SAL_CALL release() 66 throw() override; 67 68 // XTypeProvider 69 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; 70 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; 71 72 // XServiceInfo 73 virtual OUString SAL_CALL getImplementationName() override; 74 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; 75 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; 76 77 static OUString getImplementationName_Static(); 78 79 static css::uno::Sequence< OUString > getSupportedServiceNames_Static(); 80 81 static css::uno::Reference< css::lang::XSingleServiceFactory > createServiceFactory( 82 const css::uno::Reference< css::lang::XMultiServiceFactory >& rxServiceMgr ); 83 84 // XContentProvider 85 virtual css::uno::Reference< css::ucb::XContent > SAL_CALL queryContent( 86 const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier ) override; 87 88 // Additional interfaces 89 90 // XComponent 91 92 virtual void SAL_CALL 93 dispose( ) override; 94 95 virtual void SAL_CALL addEventListener(const css::uno::Reference<css::lang::XEventListener> &)96 addEventListener( const css::uno::Reference< css::lang::XEventListener >& ) override {} 97 98 virtual void SAL_CALL removeEventListener(const css::uno::Reference<css::lang::XEventListener> &)99 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& ) override {} 100 101 // XContainerListener ( derive from XEventListener ) 102 103 virtual void SAL_CALL disposing(const css::lang::EventObject &)104 disposing( const css::lang::EventObject& /*Source*/ ) override 105 { 106 m_xContainer.clear(); 107 } 108 109 virtual void SAL_CALL elementInserted(const css::container::ContainerEvent &)110 elementInserted( const css::container::ContainerEvent& ) override {} 111 112 virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent &)113 elementRemoved( const css::container::ContainerEvent& ) override {} 114 115 virtual void SAL_CALL 116 elementReplaced( const css::container::ContainerEvent& Event ) override; 117 118 // Non-interface methods. 119 120 private: 121 bool isInitialized; 122 std::unique_ptr<Databases> m_pDatabases; 123 css::uno::Reference<css::container::XContainer> m_xContainer; 124 125 // private methods 126 127 void init(); 128 129 static void subst( OUString& instpath ); 130 }; 131 132 } 133 134 #endif 135 136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 137