LibreOffice Module unotools (master) 1
ServiceDocumenter.cxx
Go to the documentation of this file.
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 */
10#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
11#include <com/sun/star/system/XSystemShellExecute.hpp>
12#include <com/sun/star/uno/XComponentContext.hpp>
14
15using namespace com::sun::star;
16using uno::Reference;
17using lang::XServiceInfo;
18using lang::XTypeProvider;
19
20void unotools::misc::ServiceDocumenter::showCoreDocs(const Reference<XServiceInfo>& xService)
21{
22 if(!xService.is())
23 return;
24 auto xMSF(m_xContext->getServiceManager());
25 Reference<system::XSystemShellExecute> xShell(xMSF->createInstanceWithContext("com.sun.star.system.SystemShellExecute", m_xContext), uno::UNO_QUERY);
26 xShell->execute(
27 m_sCoreBaseUrl + xService->getImplementationName() + ".html", "",
28 css::system::SystemShellExecuteFlags::URIS_ONLY);
29}
30
31void unotools::misc::ServiceDocumenter::showInterfaceDocs(const Reference<XTypeProvider>& xTypeProvider)
32{
33 if(!xTypeProvider.is())
34 return;
35 auto xMSF(m_xContext->getServiceManager());
36 Reference<system::XSystemShellExecute> xShell(xMSF->createInstanceWithContext("com.sun.star.system.SystemShellExecute", m_xContext), uno::UNO_QUERY);
37 const css::uno::Sequence<css::uno::Type> aTypes = xTypeProvider->getTypes();
38 for(const auto& aType : aTypes)
39 {
40 auto sUrl = aType.getTypeName();
41 sal_Int32 nIdx = 0;
42 while(nIdx != -1)
43 sUrl = sUrl.replaceFirst(".", "_1_1", &nIdx);
44 xShell->execute(
45 m_sServiceBaseUrl + "/interface" + sUrl + ".html", "",
46 css::system::SystemShellExecuteFlags::URIS_ONLY);
47 }
48}
49
50void unotools::misc::ServiceDocumenter::showServiceDocs(const Reference<XServiceInfo>& xService)
51{
52 if(!xService.is())
53 return;
54 auto xMSF(m_xContext->getServiceManager());
55 Reference<system::XSystemShellExecute> xShell(xMSF->createInstanceWithContext("com.sun.star.system.SystemShellExecute", m_xContext), uno::UNO_QUERY);
56 const css::uno::Sequence<OUString> aServiceNames = xService->getSupportedServiceNames();
57 for(const auto& sService : aServiceNames)
58 {
59 auto sUrl = sService;
60 sal_Int32 nIdx = 0;
61 while(nIdx != -1)
62 sUrl = sUrl.replaceFirst(".", "_1_1", &nIdx);
63 xShell->execute(
64 m_sServiceBaseUrl + "/service" + sUrl + ".html", "",
65 css::system::SystemShellExecuteFlags::URIS_ONLY);
66 }
67}
68
69// XServiceInfo
71{
73}
75{
76 return "com.sun.star.comp.unotools.misc.ServiceDocumenter";
77}
79{
80 return { "com.sun.star.script.ServiceDocumenter" };
81}
82
83
84extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
86 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
87{
88 return cppu::acquire(new unotools::misc::ServiceDocumenter(context));
89}
Reference< XComponentContext > m_xContext
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * unotools_ServiceDocument_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
constexpr OUStringLiteral sServiceName
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual void SAL_CALL showCoreDocs(const ::css::uno::Reference< ::css::lang::XServiceInfo > &xService) override
virtual void SAL_CALL showServiceDocs(const ::css::uno::Reference< ::css::lang::XServiceInfo > &xService) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL showInterfaceDocs(const ::css::uno::Reference< ::css::lang::XTypeProvider > &xTypeProvider) override
virtual OUString SAL_CALL getImplementationName() override
Sequence< OUString > aServiceNames
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
unsigned char sal_Bool
const SvXMLTokenMapEntry aTypes[]