CppunitTest_sc_tiledrendering2: move to tiledrendering folder
[LibreOffice.git] / unotools / source / misc / ServiceDocumenter.cxx
blobaf4869ed138b157ffc50bb3ecd56b3da0d7e400f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
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;
16 using uno::Reference;
17 using lang::XServiceInfo;
18 using lang::XTypeProvider;
20 void unotools::misc::ServiceDocumenter::showCoreDocs(const Reference<XServiceInfo>& xService)
22 if(!xService.is())
23 return;
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);
26 xShell->execute(
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())
34 return;
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();
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", u""_ustr,
46 css::system::SystemShellExecuteFlags::URIS_ONLY);
50 void unotools::misc::ServiceDocumenter::showServiceDocs(const Reference<XServiceInfo>& xService)
52 if(!xService.is())
53 return;
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)
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", u""_ustr,
65 css::system::SystemShellExecuteFlags::URIS_ONLY);
69 // XServiceInfo
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));