[Libreoffice-commits] core.git: 2 commits - offapi/com offapi/UnoApi_offapi.mk unotools/Library_utl.mk unotools/source unotools/util
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Fri Sep 18 16:50:53 PDT 2015
offapi/UnoApi_offapi.mk | 2
offapi/com/sun/star/script/XServiceDocumenter.idl | 31 ++++++++
offapi/com/sun/star/script/theServiceDocumenter.idl | 26 ++++++
unotools/Library_utl.mk | 2
unotools/source/misc/ServiceDocumenter.cxx | 64 ++++++++++++++++
unotools/source/misc/ServiceDocumenter.hxx | 50 +++++++++++++
unotools/source/misc/unotoolsservices.cxx | 27 +++++++
unotools/source/ucbhelper/XTempFile.hxx | 49 +++---------
unotools/source/ucbhelper/xtempfile.cxx | 76 ++------------------
unotools/util/utl.component | 3
10 files changed, 228 insertions(+), 102 deletions(-)
New commits:
commit 4abd8fe7cc30e305169cef8027209a7cb66e29f1
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Sep 19 00:58:47 2015 +0200
add implementation for theServiceDocumenter singleton
- make utl library use servicedecl.hxx
- thus remove superflous XServiceInfo implementation for XTempFile
- make XTempfile,hxx first include to ensure the header file is
self-contained
- while touching this, fix some indenting in XTempFile.hxx
Change-Id: Id51d99e817d406a919a63505ba01f3372f3111bf
diff --git a/unotools/Library_utl.mk b/unotools/Library_utl.mk
index 52f2eff..a3481de 100644
--- a/unotools/Library_utl.mk
+++ b/unotools/Library_utl.mk
@@ -104,6 +104,8 @@ $(eval $(call gb_Library_add_exception_objects,utl,\
unotools/source/misc/mediadescriptor \
unotools/source/misc/sharedunocomponent \
unotools/source/misc/syslocale \
+ unotools/source/misc/unotoolsservices \
+ unotools/source/misc/ServiceDocumenter \
unotools/source/streaming/streamhelper \
unotools/source/streaming/streamwrap \
unotools/source/ucbhelper/localfilehelper \
diff --git a/unotools/source/misc/ServiceDocumenter.cxx b/unotools/source/misc/ServiceDocumenter.cxx
new file mode 100644
index 0000000..8991cc3
--- /dev/null
+++ b/unotools/source/misc/ServiceDocumenter.cxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#include <ServiceDocumenter.hxx>
+#include <comphelper/servicedecl.hxx>
+#include <com/sun/star/system/XSystemShellExecute.hpp>
+using namespace com::sun::star;
+using uno::Reference;
+using lang::XServiceInfo;
+using lang::XTypeProvider;
+
+void unotools::misc::ServiceDocumenter::showCoreDocs(const Reference<XServiceInfo>& xService)
+{
+ if(!xService.is())
+ return;
+ auto xMSF(m_xContext->getServiceManager());
+ Reference<system::XSystemShellExecute> xShell(xMSF->createInstanceWithContext("com.sun.star.system.SystemShellExecute", m_xContext), uno::UNO_QUERY);
+ xShell->execute(m_sCoreBaseUrl + xService->getImplementationName(), "", 0);
+}
+
+void unotools::misc::ServiceDocumenter::showInterfaceDocs(const Reference<XTypeProvider>& xTypeProvider)
+{
+ if(!xTypeProvider.is())
+ return;
+ auto xMSF(m_xContext->getServiceManager());
+ Reference<system::XSystemShellExecute> xShell(xMSF->createInstanceWithContext("com.sun.star.system.SystemShellExecute", m_xContext), uno::UNO_QUERY);
+ for(auto aType : xTypeProvider->getTypes())
+ {
+ auto sUrl = aType.getTypeName();
+ sal_Int32 nIdx = 0;
+ while(nIdx != -1)
+ sUrl = sUrl.replaceFirst(".", "_1_1", &nIdx);
+ xShell->execute(m_sServiceBaseUrl + "/interface" + sUrl + ".html", "", 0);
+ }
+}
+
+void unotools::misc::ServiceDocumenter::showServiceDocs(const Reference<XServiceInfo>& xService)
+{
+ if(!xService.is())
+ return;
+ auto xMSF(m_xContext->getServiceManager());
+ Reference<system::XSystemShellExecute> xShell(xMSF->createInstanceWithContext("com.sun.star.system.SystemShellExecute", m_xContext), uno::UNO_QUERY);
+ for(auto sService : xService->getSupportedServiceNames())
+ {
+ auto sUrl = sService;
+ sal_Int32 nIdx = 0;
+ while(nIdx != -1)
+ sUrl = sUrl.replaceFirst(".", "_1_1", &nIdx);
+ xShell->execute(m_sServiceBaseUrl + "/service" + sUrl + ".html", "", 0);
+ }
+}
+
+namespace sdecl = ::comphelper::service_decl;
+sdecl::class_< unotools::misc::ServiceDocumenter > ServiceDocumenterImpl;
+extern const sdecl::ServiceDecl ServiceDocumenterDecl(
+ ServiceDocumenterImpl,
+ "com.sun.star.comp.unotools.misc.ServiceDocumenter",
+ "");
+
diff --git a/unotools/source/misc/ServiceDocumenter.hxx b/unotools/source/misc/ServiceDocumenter.hxx
new file mode 100644
index 0000000..ad84623
--- /dev/null
+++ b/unotools/source/misc/ServiceDocumenter.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#ifndef INCLUDED_UNOTOOLS_INC_SERVICEDOCUMENTER_HXX
+#define INCLUDED_UNOTOOLS_INC_SERVICEDOCUMENTER_HXX
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <cppuhelper/implbase.hxx>
+#include <com/sun/star/script/XServiceDocumenter.hpp>
+
+namespace unotools { namespace misc {
+
+class ServiceDocumenter : public ::cppu::WeakImplHelper<
+ ::com::sun::star::script::XServiceDocumenter>
+{
+ public:
+ ServiceDocumenter(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const& xContext)
+ : m_xContext(xContext)
+ , m_sCoreBaseUrl("http://example.com")
+ , m_sServiceBaseUrl("http://api.libreoffice.org/docs/idl/ref")
+ {};
+ // XServiceDocumenter
+ virtual OUString getCoreBaseUrl() SAL_OVERRIDE
+ { return m_sCoreBaseUrl; };
+ virtual void setCoreBaseUrl( const OUString& sCoreBaseUrl ) SAL_OVERRIDE
+ { m_sCoreBaseUrl = sCoreBaseUrl; };
+ virtual OUString getServiceBaseUrl() SAL_OVERRIDE
+ { return m_sServiceBaseUrl; };
+ virtual void setServiceBaseUrl( const OUString& sServiceBaseUrl ) SAL_OVERRIDE
+ { m_sServiceBaseUrl = sServiceBaseUrl; };
+ virtual void showServiceDocs( const ::css::uno::Reference< ::css::lang::XServiceInfo >& xService) SAL_OVERRIDE;
+ virtual void showInterfaceDocs( const ::css::uno::Reference< ::css::lang::XTypeProvider >& xTypeProvider ) SAL_OVERRIDE;
+ virtual void showCoreDocs( const ::css::uno::Reference< ::css::lang::XServiceInfo >& xService) SAL_OVERRIDE;
+ protected:
+ virtual ~ServiceDocumenter()
+ {};
+ private:
+ css::uno::Reference< css::uno::XComponentContext> m_xContext;
+ OUString m_sCoreBaseUrl;
+ OUString m_sServiceBaseUrl;
+};
+
+}}
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/misc/unotoolsservices.cxx b/unotools/source/misc/unotoolsservices.cxx
new file mode 100644
index 0000000..2455ed0
--- /dev/null
+++ b/unotools/source/misc/unotoolsservices.cxx
@@ -0,0 +1,27 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <comphelper/servicedecl.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <uno/environment.h>
+
+namespace sdecl = ::comphelper::service_decl;
+
+extern sdecl::ServiceDecl const OTempFileServiceDecl;
+extern sdecl::ServiceDecl const ServiceDocumenterDecl;
+
+
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL utl_component_getFactory(
+ sal_Char const* pImplName, void*, void*)
+{
+ return component_getFactoryHelper( pImplName,
+ OTempFileServiceDecl, ServiceDocumenterDecl);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/ucbhelper/XTempFile.hxx b/unotools/source/ucbhelper/XTempFile.hxx
index 9aa6c40..855e073f 100644
--- a/unotools/source/ucbhelper/XTempFile.hxx
+++ b/unotools/source/ucbhelper/XTempFile.hxx
@@ -34,28 +34,25 @@
class SvStream;
namespace utl { class TempFile; }
-typedef ::cppu::WeakImplHelper< ::com::sun::star::io::XTempFile
- , ::com::sun::star::io::XInputStream
- , ::com::sun::star::io::XOutputStream
- , ::com::sun::star::io::XTruncate
- , ::com::sun::star::lang::XServiceInfo
- >
- OTempFileBase;
-class OTempFileService :
- public OTempFileBase,
- public ::cppu::PropertySetMixin< ::com::sun::star::io::XTempFile >
+typedef ::cppu::WeakImplHelper< ::com::sun::star::io::XTempFile
+ , ::com::sun::star::io::XInputStream
+ , ::com::sun::star::io::XOutputStream
+ , ::com::sun::star::io::XTruncate > OTempFileBase;
+
+class OTempFileService : public OTempFileBase
+ , public ::cppu::PropertySetMixin< ::com::sun::star::io::XTempFile >
{
protected:
- ::utl::TempFile* mpTempFile;
- ::osl::Mutex maMutex;
- SvStream* mpStream;
- bool mbRemoveFile;
- bool mbInClosed;
- bool mbOutClosed;
+ ::utl::TempFile* mpTempFile;
+ ::osl::Mutex maMutex;
+ SvStream* mpStream;
+ bool mbRemoveFile;
+ bool mbInClosed;
+ bool mbOutClosed;
- sal_Int64 mnCachedPos;
- bool mbHasCachedPos;
+ sal_Int64 mnCachedPos;
+ bool mbHasCachedPos;
void checkError () const;
void checkConnected ();
@@ -120,24 +117,8 @@ public:
// XTruncate
virtual void SAL_CALL truncate()
throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- // XServiceInfo
- virtual OUString SAL_CALL getImplementationName()
- throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
- throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
- throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- //::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface > SAL_CALL XTempFile_createInstance( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context);
- static OUString getImplementationName_Static ();
- static ::com::sun::star::uno::Sequence < OUString > getSupportedServiceNames_Static();
-
- static ::com::sun::star::uno::Reference < com::sun::star::lang::XSingleComponentFactory > createServiceFactory_Static();
-
-private:
- OTempFileService( OTempFileService & ) SAL_DELETED_FUNCTION;
virtual ~OTempFileService ();
-
};
#endif
diff --git a/unotools/source/ucbhelper/xtempfile.cxx b/unotools/source/ucbhelper/xtempfile.cxx
index 0ec6f47..2f59ebc 100644
--- a/unotools/source/ucbhelper/xtempfile.cxx
+++ b/unotools/source/ucbhelper/xtempfile.cxx
@@ -17,13 +17,14 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include "XTempFile.hxx"
#include <cppuhelper/factory.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/servicedecl.hxx>
#include <osl/file.hxx>
#include <unotools/configmgr.hxx>
#include <unotools/tempfile.hxx>
-#include "XTempFile.hxx"
OTempFileService::OTempFileService(css::uno::Reference< css::uno::XComponentContext > const & context)
: ::cppu::PropertySetMixin< css::io::XTempFile >(
@@ -411,72 +412,11 @@ throw ( css::io::IOException, css::uno::RuntimeException, std::exception )
checkError();
}
-// XServiceInfo
-
-OUString SAL_CALL OTempFileService::getImplementationName()
-throw ( css::uno::RuntimeException, std::exception )
-{
- return getImplementationName_Static();
-}
-
-sal_Bool SAL_CALL OTempFileService::supportsService( OUString const & rServiceName )
-throw ( css::uno::RuntimeException, std::exception )
-{
- return cppu::supportsService(this, rServiceName);
-}
-
-css::uno::Sequence < OUString > SAL_CALL OTempFileService::getSupportedServiceNames()
-throw ( css::uno::RuntimeException, std::exception )
-{
- return getSupportedServiceNames_Static();
-}
-
-OUString OTempFileService::getImplementationName_Static ()
-{
- return OUString ( "com.sun.star.io.comp.TempFile" );
-}
-css::uno::Sequence < OUString > OTempFileService::getSupportedServiceNames_Static()
-{
- css::uno::Sequence < OUString > aNames ( 1 );
- aNames[0] = "com.sun.star.io.TempFile";
- return aNames;
-}
-css::uno::Reference < css::uno::XInterface >SAL_CALL XTempFile_createInstance(
- css::uno::Reference< css::uno::XComponentContext > const & context)
-{
- return static_cast< ::cppu::OWeakObject * >( new OTempFileService(context) );
-}
-
-css::uno::Reference < css::lang::XSingleComponentFactory > OTempFileService::createServiceFactory_Static()
-{
- return ::cppu::createSingleComponentFactory( XTempFile_createInstance, getImplementationName_Static(), getSupportedServiceNames_Static() );
-}
-
-/**
- * This function is called to get service factories for an implementation.
- * @param pImplName name of implementation
- * @param pServiceManager generic uno interface providing a service manager to instantiate components
- * @param pRegistryKey registry data key to read and write component persistent data
- * @return a component factory (generic uno interface)
- */
-extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL utl_component_getFactory(
- const sal_Char * pImplName, void * pServiceManager,
- SAL_UNUSED_PARAMETER void * /*pRegistryKey*/ )
-{
- void * pRet = 0;
- css::uno::Reference< css::lang::XMultiServiceFactory > xSMgr(
- static_cast< css::lang::XMultiServiceFactory * >( pServiceManager ) );
- css::uno::Reference< css::lang::XSingleComponentFactory > xFactory;
-
- if (OTempFileService::getImplementationName_Static().equalsAscii( pImplName ) )
- xFactory = OTempFileService::createServiceFactory_Static();
-
- if ( xFactory.is() )
- {
- xFactory->acquire();
- pRet = xFactory.get();
- }
- return pRet;
-}
+namespace sdecl = ::comphelper::service_decl;
+sdecl::class_< OTempFileService> OTempFileServiceImpl;
+extern const sdecl::ServiceDecl OTempFileServiceDecl(
+ OTempFileServiceImpl,
+ "com.sun.star.io.comp.TempFile",
+ "com.sun.star.io.TempFile");
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/util/utl.component b/unotools/util/utl.component
index ef929f2..8b93713 100644
--- a/unotools/util/utl.component
+++ b/unotools/util/utl.component
@@ -22,4 +22,7 @@
<implementation name="com.sun.star.io.comp.TempFile">
<service name="com.sun.star.io.TempFile"/>
</implementation>
+ <implementation name="com.sun.star.comp.unotools.misc.ServiceDocumenter">
+ <singleton name="com.sun.star.util.theServiceDocumenter"/>
+ </implementation>
</component>
commit 55cb4638a0cd051bc254de935335ce501f12a572
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Sep 19 00:55:07 2015 +0200
add theServiceDocumenter singleton
Change-Id: I491fc5ae67de06cc2cf14d2e4a5cfbef57891c9a
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 505f4f5..0ede4c2 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -319,6 +319,8 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/scanner,\
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/script,\
DocumentDialogLibraryContainer \
DocumentScriptLibraryContainer \
+ XServiceDocumenter \
+ theServiceDocumenter \
))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/script/browse,\
theBrowseNodeFactory \
diff --git a/offapi/com/sun/star/script/XServiceDocumenter.idl b/offapi/com/sun/star/script/XServiceDocumenter.idl
new file mode 100644
index 0000000..32c86ea
--- /dev/null
+++ b/offapi/com/sun/star/script/XServiceDocumenter.idl
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef __com_sun_star_script_XServiceDocumenter_idl__
+#define __com_sun_star_script_XServiceDocumenter_idl__
+
+module com { module sun { module star { module script {
+
+/** provides documentation for UNO services
+ @since LibreOffice 5.1
+ */
+interface XServiceDocumenter
+{
+ [attribute] string ServiceBaseUrl;
+ [attribute] string CoreBaseUrl;
+ void showServiceDocs( [in] com::sun::star::lang::XServiceInfo xService );
+ void showInterfaceDocs( [in] com::sun::star::lang::XTypeProvider xTypeProvider );
+ void showCoreDocs( [in] com::sun::star::lang::XServiceInfo xService );
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/script/theServiceDocumenter.idl b/offapi/com/sun/star/script/theServiceDocumenter.idl
new file mode 100644
index 0000000..871bdbd
--- /dev/null
+++ b/offapi/com/sun/star/script/theServiceDocumenter.idl
@@ -0,0 +1,26 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef __com_sun_star_script_theServiceDocumenter_idl__
+#define __com_sun_star_script_theServiceDocumenter_idl__
+
+#include <com/sun/star/script/XServiceDocumenter.idl>
+
+module com { module sun { module star { module script {
+
+/** Provides documentation for UNO services
+ @since LibreOffice 5.1
+ */
+singleton theServiceDocumenter : XServiceDocumenter;
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list