[Libreoffice-commits] core.git: svtools/source svtools/util

Matúš Kukan matus.kukan at collabora.com
Wed Jan 8 05:35:29 PST 2014


 svtools/source/hatchwindow/documentcloser.cxx |   78 +++++++++++++++++-------
 svtools/source/inc/documentcloser.hxx         |   82 --------------------------
 svtools/source/uno/miscservices.cxx           |    8 --
 svtools/util/svt.component                    |    3 
 4 files changed, 56 insertions(+), 115 deletions(-)

New commits:
commit ceffe83515be125df6c3811760ec59b95942a978
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Mon Dec 23 10:27:49 2013 +0100

    svt: Use constructor feature for ODocumentCloser.
    
    Change-Id: Ia1a9593e3d1dbc41cf25f6a983cb340f48538226
    Signed-off-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/svtools/source/hatchwindow/documentcloser.cxx b/svtools/source/hatchwindow/documentcloser.cxx
index 9bd1746..1e198da 100644
--- a/svtools/source/hatchwindow/documentcloser.cxx
+++ b/svtools/source/hatchwindow/documentcloser.cxx
@@ -17,29 +17,63 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <com/sun/star/uno/XComponentContext.hpp>
 #include <com/sun/star/util/XCloseBroadcaster.hpp>
 #include <com/sun/star/util/XCloseable.hpp>
 #include <com/sun/star/lang/DisposedException.hpp>
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/frame/DoubleInitializationException.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
 #include <com/sun/star/awt/XVclWindowPeer.hpp>
 #include <comphelper/processfactory.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/interfacecontainer.h>
 #include <cppuhelper/supportsservice.hxx>
 #include <osl/mutex.hxx>
 #include <osl/thread.hxx>
+#include <rtl/ref.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/dialog.hxx>
 #include <tools/link.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
 
-#include "documentcloser.hxx"
-
 using namespace ::com::sun::star;
 
+namespace {
 
-// ====================================================================
-// MainThreadFrameCloserRequest
-// ====================================================================
+// the service is implemented as a wrapper to be able to die by refcount
+// the disposing mechanics is required for java related scenarios
+class ODocumentCloser : public ::cppu::WeakImplHelper3< ::com::sun::star::lang::XComponent,
+                                                        ::com::sun::star::lang::XInitialization,
+                                                        ::com::sun::star::lang::XServiceInfo >
+{
+    ::osl::Mutex m_aMutex;
+    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
+    ::cppu::OInterfaceContainerHelper* m_pListenersContainer; // list of listeners
+
+    sal_Bool m_bDisposed;
+    sal_Bool m_bInitialized;
+
+public:
+    ODocumentCloser();
+    ~ODocumentCloser();
+
+// XComponent
+    virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+
+// XInitialization
+    virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+// XServiceInfo
+    virtual OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
+    virtual ::sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+    virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
+};
 
 class MainThreadFrameCloserRequest
 {
@@ -124,9 +158,8 @@ IMPL_STATIC_LINK( MainThreadFrameCloserRequest, worker, MainThreadFrameCloserReq
 // ====================================================================
 
 // --------------------------------------------------------
-ODocumentCloser::ODocumentCloser( const uno::Reference< uno::XComponentContext >& xContext )
-: m_xContext( xContext )
-, m_pListenersContainer( NULL )
+ODocumentCloser::ODocumentCloser()
+: m_pListenersContainer( NULL )
 , m_bDisposed( sal_False )
 , m_bInitialized( sal_False )
 {
@@ -225,7 +258,7 @@ void SAL_CALL ODocumentCloser::initialize( const uno::Sequence< uno::Any >& aArg
 OUString SAL_CALL ODocumentCloser::getImplementationName(  )
     throw (uno::RuntimeException)
 {
-    return impl_staticGetImplementationName();
+    return OUString( "com.sun.star.comp.embed.DocumentCloser" );
 }
 
 ::sal_Bool SAL_CALL ODocumentCloser::supportsService( const OUString& ServiceName )
@@ -237,28 +270,25 @@ OUString SAL_CALL ODocumentCloser::getImplementationName(  )
 uno::Sequence< OUString > SAL_CALL ODocumentCloser::getSupportedServiceNames()
     throw (uno::RuntimeException)
 {
-    return impl_staticGetSupportedServiceNames();
-}
-
-// Static methods
-uno::Sequence< OUString > SAL_CALL ODocumentCloser::impl_staticGetSupportedServiceNames()
-{
     const OUString aServiceName( "com.sun.star.embed.DocumentCloser" );
     return uno::Sequence< OUString >( &aServiceName, 1 );
 }
 
-OUString SAL_CALL ODocumentCloser::impl_staticGetImplementationName()
-{
-    return OUString( "com.sun.star.comp.embed.DocumentCloser" );
 }
 
-// --------------------------------------------------------
-uno::Reference< uno::XInterface > SAL_CALL ODocumentCloser::impl_staticCreateSelfInstance(
-                                const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_embed_DocumentCloser_get_implementation(
+        SAL_UNUSED_PARAMETER css::uno::XComponentContext *,
+        uno_Sequence * arguments)
 {
-    uno::Reference< uno::XComponentContext > xContext(
-        comphelper::getComponentContext( xServiceManager ) );
-    return static_cast< cppu::OWeakObject * >( new ODocumentCloser( xContext ) );
+    assert(arguments != 0 );
+    rtl::Reference<ODocumentCloser> x(new ODocumentCloser);
+    css::uno::Sequence<css::uno::Any> aArgs(
+            reinterpret_cast<css::uno::Any *>(arguments->elements),
+            arguments->nElements);
+    x->initialize(aArgs);
+    x->acquire();
+    return static_cast<cppu::OWeakObject *>(x.get());
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/inc/documentcloser.hxx b/svtools/source/inc/documentcloser.hxx
deleted file mode 100644
index 4fc37f0..0000000
--- a/svtools/source/inc/documentcloser.hxx
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_SVTOOLS_SOURCE_HATCHWINDOW_DOCUMENTCLOSER_HXX
-#define INCLUDED_SVTOOLS_SOURCE_HATCHWINDOW_DOCUMENTCLOSER_HXX
-
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/frame/XFrame.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/embed/XActionsApproval.hpp>
-#include <com/sun/star/embed/Actions.hpp>
-#include <cppuhelper/weakref.hxx>
-#include <osl/mutex.hxx>
-#include <cppuhelper/implbase3.hxx>
-#include <cppuhelper/interfacecontainer.h>
-
-
-// the service is implemented as a wrapper to be able to die by refcount
-// the disposing mechanics is required for java related scenarios
-class ODocumentCloser : public ::cppu::WeakImplHelper3< ::com::sun::star::lang::XComponent,
-                                                        ::com::sun::star::lang::XInitialization,
-                                                        ::com::sun::star::lang::XServiceInfo >
-{
-    ::osl::Mutex m_aMutex;
-    ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
-
-    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
-
-    ::cppu::OInterfaceContainerHelper* m_pListenersContainer; // list of listeners
-
-    sal_Bool m_bDisposed;
-    sal_Bool m_bInitialized;
-
-public:
-    ODocumentCloser( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
-    ~ODocumentCloser();
-
-    static ::com::sun::star::uno::Sequence< OUString > SAL_CALL
-            impl_staticGetSupportedServiceNames();
-
-    static OUString SAL_CALL impl_staticGetImplementationName();
-
-    static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
-        impl_staticCreateSelfInstance(
-            const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
-
-// XComponent
-    virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
-    virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
-    virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
-
-// XInitialization
-    virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
-
-// XServiceInfo
-    virtual OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
-    virtual ::sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
-    virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
-
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/uno/miscservices.cxx b/svtools/source/uno/miscservices.cxx
index 4a7ec73..e12db45 100644
--- a/svtools/source/uno/miscservices.cxx
+++ b/svtools/source/uno/miscservices.cxx
@@ -26,7 +26,6 @@
 #include <com/sun/star/registry/XRegistryKey.hpp>
 #include <osl/diagnose.h>
 #include <uno/mapping.hxx>
-#include "documentcloser.hxx"
 #include "hatchwindow.hxx"
 #include "unowizard.hxx"
 
@@ -109,13 +108,6 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL svt_component_getFactory (
                 SvFilterOptionsDialog_CreateInstance,
                 aServiceNames);
         }
-        else if (rtl_str_compare (pImplementationName, "com.sun.star.comp.embed.DocumentCloser") == 0)
-        {
-            xFactory =  ::cppu::createOneInstanceFactory(xSMgr,
-                ODocumentCloser::impl_staticGetImplementationName(),
-                ODocumentCloser::impl_staticCreateSelfInstance,
-                ODocumentCloser::impl_staticGetSupportedServiceNames());
-        }
         else
         {
             pResult = comphelper::service_decl::component_getFactoryHelper(
diff --git a/svtools/util/svt.component b/svtools/util/svt.component
index bd359af..6d3bb3f 100644
--- a/svtools/util/svt.component
+++ b/svtools/util/svt.component
@@ -47,7 +47,8 @@
       constructor="com_sun_star_comp_svt_FolderPicker_get_implementation">
     <service name="com.sun.star.ui.dialogs.FolderPicker"/>
   </implementation>
-  <implementation name="com.sun.star.comp.embed.DocumentCloser">
+  <implementation name="com.sun.star.comp.embed.DocumentCloser"
+      constructor="com_sun_star_comp_embed_DocumentCloser_get_implementation">
     <service name="com.sun.star.embed.DocumentCloser"/>
   </implementation>
   <implementation name="com.sun.star.comp.embed.HatchWindowFactory"


More information about the Libreoffice-commits mailing list