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 #pragma once
10 
11 #include <cppuhelper/implbase.hxx>
12 #include <com/sun/star/script/XServiceDocumenter.hpp>
13 #include <com/sun/star/lang/XServiceInfo.hpp>
14 
15 namespace com::sun::star::uno { class XComponentContext; }
16 
17 namespace unotools::misc {
18 
19 class ServiceDocumenter : public ::cppu::WeakImplHelper<
20     css::script::XServiceDocumenter, css::lang::XServiceInfo>
21 {
22     public:
ServiceDocumenter(css::uno::Reference<css::uno::XComponentContext> const & xContext)23         ServiceDocumenter(css::uno::Reference< css::uno::XComponentContext> const& xContext)
24             : m_xContext(xContext)
25             , m_sCoreBaseUrl("http://example.com")
26             , m_sServiceBaseUrl("https://api.libreoffice.org/docs/idl/ref")
27             {};
28 
29         //  XServiceInfo
30         virtual sal_Bool SAL_CALL supportsService(const OUString& sServiceName) override;
31         virtual OUString SAL_CALL getImplementationName() override;
32         virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
33 
34         // XServiceDocumenter
getCoreBaseUrl()35         virtual OUString SAL_CALL getCoreBaseUrl() override
36             { return m_sCoreBaseUrl; };
setCoreBaseUrl(const OUString & sCoreBaseUrl)37         virtual void SAL_CALL setCoreBaseUrl( const OUString& sCoreBaseUrl ) override
38             { m_sCoreBaseUrl = sCoreBaseUrl; };
getServiceBaseUrl()39         virtual OUString SAL_CALL getServiceBaseUrl() override
40             { return m_sServiceBaseUrl; };
setServiceBaseUrl(const OUString & sServiceBaseUrl)41         virtual void SAL_CALL setServiceBaseUrl( const OUString& sServiceBaseUrl ) override
42             { m_sServiceBaseUrl = sServiceBaseUrl; };
43         virtual void SAL_CALL showServiceDocs( const ::css::uno::Reference< ::css::lang::XServiceInfo >& xService) override;
44         virtual void SAL_CALL showInterfaceDocs( const ::css::uno::Reference< ::css::lang::XTypeProvider >& xTypeProvider ) override;
45         virtual void SAL_CALL showCoreDocs( const ::css::uno::Reference< ::css::lang::XServiceInfo >& xService) override;
46     protected:
~ServiceDocumenter()47         virtual ~ServiceDocumenter() override
48             {};
49     private:
50         css::uno::Reference< css::uno::XComponentContext> m_xContext;
51         OUString m_sCoreBaseUrl;
52         OUString m_sServiceBaseUrl;
53 };
54 
55 }
56 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
57