1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 #include "ServiceDocumenter.hxx"
10 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
11 #include <com/sun/star/system/XSystemShellExecute.hpp>
12 #include <com/sun/star/uno/XComponentContext.hpp>
13 #include <cppuhelper/supportsservice.hxx>
15 using namespace com::sun::star
;
17 using lang::XServiceInfo
;
18 using lang::XTypeProvider
;
20 void unotools::misc::ServiceDocumenter::showCoreDocs(const Reference
<XServiceInfo
>& xService
)
24 auto xMSF(m_xContext
->getServiceManager());
25 Reference
<system::XSystemShellExecute
> xShell(xMSF
->createInstanceWithContext(u
"com.sun.star.system.SystemShellExecute"_ustr
, m_xContext
), uno::UNO_QUERY
);
27 m_sCoreBaseUrl
+ xService
->getImplementationName() + ".html", u
""_ustr
,
28 css::system::SystemShellExecuteFlags::URIS_ONLY
);
31 void unotools::misc::ServiceDocumenter::showInterfaceDocs(const Reference
<XTypeProvider
>& xTypeProvider
)
33 if(!xTypeProvider
.is())
35 auto xMSF(m_xContext
->getServiceManager());
36 Reference
<system::XSystemShellExecute
> xShell(xMSF
->createInstanceWithContext(u
"com.sun.star.system.SystemShellExecute"_ustr
, m_xContext
), uno::UNO_QUERY
);
37 const css::uno::Sequence
<css::uno::Type
> aTypes
= xTypeProvider
->getTypes();
38 for(const auto& aType
: aTypes
)
40 auto sUrl
= aType
.getTypeName();
43 sUrl
= sUrl
.replaceFirst(".", "_1_1", &nIdx
);
45 m_sServiceBaseUrl
+ "/interface" + sUrl
+ ".html", u
""_ustr
,
46 css::system::SystemShellExecuteFlags::URIS_ONLY
);
50 void unotools::misc::ServiceDocumenter::showServiceDocs(const Reference
<XServiceInfo
>& xService
)
54 auto xMSF(m_xContext
->getServiceManager());
55 Reference
<system::XSystemShellExecute
> xShell(xMSF
->createInstanceWithContext(u
"com.sun.star.system.SystemShellExecute"_ustr
, m_xContext
), uno::UNO_QUERY
);
56 const css::uno::Sequence
<OUString
> aServiceNames
= xService
->getSupportedServiceNames();
57 for(const auto& sService
: aServiceNames
)
62 sUrl
= sUrl
.replaceFirst(".", "_1_1", &nIdx
);
64 m_sServiceBaseUrl
+ "/service" + sUrl
+ ".html", u
""_ustr
,
65 css::system::SystemShellExecuteFlags::URIS_ONLY
);
70 sal_Bool
unotools::misc::ServiceDocumenter::supportsService(const OUString
& sServiceName
)
72 return cppu::supportsService(this, sServiceName
);
74 OUString
unotools::misc::ServiceDocumenter::getImplementationName()
76 return u
"com.sun.star.comp.unotools.misc.ServiceDocumenter"_ustr
;
78 css::uno::Sequence
< OUString
> unotools::misc::ServiceDocumenter::getSupportedServiceNames()
80 return { u
"com.sun.star.script.ServiceDocumenter"_ustr
};
84 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
85 unotools_ServiceDocument_get_implementation(
86 css::uno::XComponentContext
* context
, css::uno::Sequence
<css::uno::Any
> const&)
88 return cppu::acquire(new unotools::misc::ServiceDocumenter(context
));