[Libreoffice-commits] core.git: 2 commits - desktop/source framework/inc framework/source framework/util
Matúš Kukan
matus.kukan at collabora.com
Tue Feb 11 02:31:31 PST 2014
desktop/source/app/app.cxx | 14
framework/inc/services/ContextChangeEventMultiplexer.hxx | 139 --------
framework/inc/services/desktop.hxx | 6
framework/inc/services/sessionlistener.hxx | 157 ----------
framework/source/register/registerservices.cxx | 8
framework/source/services/ContextChangeEventMultiplexer.cxx | 173 +++++++----
framework/source/services/sessionlistener.cxx | 186 ++++++++----
framework/util/fwk.component | 6
8 files changed, 259 insertions(+), 430 deletions(-)
New commits:
commit c864bd31056677277919078c4fd04966ef8b14de
Author: Matúš Kukan <matus.kukan at collabora.com>
Date: Wed Jan 22 18:39:49 2014 +0100
fwk: Constructor feature for one instance ContextChangeEventMultiplexer.
Change-Id: Ibb89e4dd46fc5d1f8a85f96b7e4677fa764bb112
diff --git a/framework/inc/services/ContextChangeEventMultiplexer.hxx b/framework/inc/services/ContextChangeEventMultiplexer.hxx
deleted file mode 100644
index 1d7e2b1..0000000
--- a/framework/inc/services/ContextChangeEventMultiplexer.hxx
+++ /dev/null
@@ -1,139 +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_FRAMEWORK_INC_SERVICES_CONTEXTCHANGEEVENTMULTIPLEXER_HXX
-#define INCLUDED_FRAMEWORK_INC_SERVICES_CONTEXTCHANGEEVENTMULTIPLEXER_HXX
-
-#include <com/sun/star/ui/XContextChangeEventMultiplexer.hpp>
-
-#include <cppuhelper/compbase4.hxx>
-#include <cppuhelper/basemutex.hxx>
-
-#include "macros/xserviceinfo.hxx"
-
-#include <map>
-#include <boost/noncopyable.hpp>
-
-
-namespace
-{
- typedef ::cppu::WeakComponentImplHelper4 <
- css::ui::XContextChangeEventMultiplexer,
- css::lang::XSingleComponentFactory,
- css::lang::XServiceInfo,
- css::lang::XEventListener
- > ContextChangeEventMultiplexerInterfaceBase;
-}
-
-
-namespace cssu = ::com::sun::star::uno;
-namespace cssl = ::com::sun::star::lang;
-
-namespace framework {
-
-class ContextChangeEventMultiplexer
- : private ::boost::noncopyable,
- private ::cppu::BaseMutex,
- public ContextChangeEventMultiplexerInterfaceBase
-{
-public:
- ContextChangeEventMultiplexer(const cssu::Reference<css::uno::XComponentContext>& rxContext);
- virtual ~ContextChangeEventMultiplexer (void);
-
- virtual void SAL_CALL disposing (void);
-
- // XContextChangeEventMultiplexer
- virtual void SAL_CALL addContextChangeEventListener (
- const cssu::Reference<css::ui::XContextChangeEventListener>& rxListener,
- const cssu::Reference<cssu::XInterface>& rxEventFocus)
- throw(cssu::RuntimeException, cssl::IllegalArgumentException);
- virtual void SAL_CALL removeContextChangeEventListener (
- const cssu::Reference<css::ui::XContextChangeEventListener>& rxListener,
- const cssu::Reference<cssu::XInterface>& rxEventFocus)
- throw(cssu::RuntimeException, cssl::IllegalArgumentException);
- virtual void SAL_CALL removeAllContextChangeEventListeners (
- const cssu::Reference<css::ui::XContextChangeEventListener>& rxListener)
- throw(cssu::RuntimeException, cssl::IllegalArgumentException);
- virtual void SAL_CALL broadcastContextChangeEvent (
- const css::ui::ContextChangeEventObject& rContextChangeEventObject,
- const cssu::Reference<cssu::XInterface>& rxEventFocus)
- throw(cssu::RuntimeException);
-
- // XSingleComponentFactory
- virtual cssu::Reference<cssu::XInterface> SAL_CALL createInstanceWithContext (
- const cssu::Reference<cssu::XComponentContext>& rxContext)
- throw (cssu::Exception, cssu::RuntimeException);
- virtual cssu::Reference<cssu::XInterface > SAL_CALL createInstanceWithArgumentsAndContext (
- const cssu::Sequence<cssu::Any>& rArguments,
- const cssu::Reference<cssu::XComponentContext>& rxContext)
- throw (cssu::Exception, cssu::RuntimeException);
-
- // XServiceInfo
- virtual ::rtl::OUString SAL_CALL getImplementationName (void)
- throw (cssu::RuntimeException);
- virtual sal_Bool SAL_CALL supportsService (
- const ::rtl::OUString& rsServiceName)
- throw (cssu::RuntimeException);
- virtual cssu::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames (void)
- throw (cssu::RuntimeException);
-
- // XEventListener
- virtual void SAL_CALL disposing (
- const css::lang::EventObject& rEvent)
- throw (cssu::RuntimeException);
-
- static ::rtl::OUString SAL_CALL impl_getStaticImplementationName (void);
- static cssu::Reference<cssu::XInterface> SAL_CALL impl_createFactory (
- const cssu::Reference<cssl::XMultiServiceFactory>& xServiceManager);
-
-private:
- typedef ::std::vector<cssu::Reference<css::ui::XContextChangeEventListener> > ListenerContainer;
- class FocusDescriptor
- {
- public:
- ListenerContainer maListeners;
- ::rtl::OUString msCurrentApplicationName;
- ::rtl::OUString msCurrentContextName;
- };
- typedef ::std::map<cssu::Reference<cssu::XInterface>, FocusDescriptor> ListenerMap;
- ListenerMap maListeners;
-
- /** Notify all listeners in the container that is associated with
- the given event focus.
-
- Typically called twice from broadcastEvent(), once for the
- given event focus and onece for NULL.
- */
- void BroadcastEventToSingleContainer (
- const css::ui::ContextChangeEventObject& rEventObject,
- const cssu::Reference<cssu::XInterface>& rxEventFocus);
- FocusDescriptor* GetFocusDescriptor (
- const cssu::Reference<cssu::XInterface>& rxEventFocus,
- const bool bCreateWhenMissing);
-
- static cssu::Sequence< ::rtl::OUString > SAL_CALL static_GetSupportedServiceNames (void);
- static cssu::Reference<cssu::XInterface> SAL_CALL static_CreateInstance (
- const cssu::Reference<cssu::XComponentContext>& rxComponentContext)
- throw (cssu::Exception);
-};
-
-} // end of namespace framework
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/register/registerservices.cxx b/framework/source/register/registerservices.cxx
index 06735d5..c0d5cf3 100644
--- a/framework/source/register/registerservices.cxx
+++ b/framework/source/register/registerservices.cxx
@@ -35,11 +35,8 @@
=================================================================================================================*/
#include <services/desktop.hxx>
-#include <services/ContextChangeEventMultiplexer.hxx>
-
COMPONENTGETFACTORY ( fwk,
- IFFACTORY( ::framework::Desktop ) else
- IFFACTORY( ::framework::ContextChangeEventMultiplexer )
+ IFFACTORY( ::framework::Desktop )
)
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/services/ContextChangeEventMultiplexer.cxx b/framework/source/services/ContextChangeEventMultiplexer.cxx
index 53c319e..5bdcaf0 100644
--- a/framework/source/services/ContextChangeEventMultiplexer.cxx
+++ b/framework/source/services/ContextChangeEventMultiplexer.cxx
@@ -17,25 +17,107 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "services/ContextChangeEventMultiplexer.hxx"
-#include "services.h"
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/ui/XContextChangeEventMultiplexer.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <cppuhelper/compbase3.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <cppuhelper/basemutex.hxx>
+
+#include <algorithm>
+#include <map>
+#include <vector>
+#include <boost/noncopyable.hpp>
-using ::rtl::OUString;
+namespace cssl = css::lang;
+namespace cssu = css::uno;
using namespace css;
-using namespace cssu;
+using namespace css::uno;
-namespace framework {
+namespace {
-#define IMPLEMENTATION_NAME "org.apache.openoffice.comp.framework.ContextChangeEventMultiplexer"
+typedef ::cppu::WeakComponentImplHelper3 <
+ css::ui::XContextChangeEventMultiplexer,
+ css::lang::XServiceInfo,
+ css::lang::XEventListener
+ > ContextChangeEventMultiplexerInterfaceBase;
-ContextChangeEventMultiplexer::ContextChangeEventMultiplexer (
- const cssu::Reference<cssu::XComponentContext>& rxContext)
+class ContextChangeEventMultiplexer
+ : private ::boost::noncopyable,
+ private ::cppu::BaseMutex,
+ public ContextChangeEventMultiplexerInterfaceBase
+{
+public:
+ ContextChangeEventMultiplexer();
+ virtual ~ContextChangeEventMultiplexer (void);
+
+ virtual void SAL_CALL disposing (void);
+
+ // XContextChangeEventMultiplexer
+ virtual void SAL_CALL addContextChangeEventListener (
+ const cssu::Reference<css::ui::XContextChangeEventListener>& rxListener,
+ const cssu::Reference<cssu::XInterface>& rxEventFocus)
+ throw(cssu::RuntimeException, cssl::IllegalArgumentException);
+ virtual void SAL_CALL removeContextChangeEventListener (
+ const cssu::Reference<css::ui::XContextChangeEventListener>& rxListener,
+ const cssu::Reference<cssu::XInterface>& rxEventFocus)
+ throw(cssu::RuntimeException, cssl::IllegalArgumentException);
+ virtual void SAL_CALL removeAllContextChangeEventListeners (
+ const cssu::Reference<css::ui::XContextChangeEventListener>& rxListener)
+ throw(cssu::RuntimeException, cssl::IllegalArgumentException);
+ virtual void SAL_CALL broadcastContextChangeEvent (
+ const css::ui::ContextChangeEventObject& rContextChangeEventObject,
+ const cssu::Reference<cssu::XInterface>& rxEventFocus)
+ throw(cssu::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName (void)
+ throw (cssu::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService (
+ const ::rtl::OUString& rsServiceName)
+ throw (cssu::RuntimeException);
+ virtual cssu::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames (void)
+ throw (cssu::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing (
+ const css::lang::EventObject& rEvent)
+ throw (cssu::RuntimeException);
+
+private:
+ typedef ::std::vector<cssu::Reference<css::ui::XContextChangeEventListener> > ListenerContainer;
+ class FocusDescriptor
+ {
+ public:
+ ListenerContainer maListeners;
+ ::rtl::OUString msCurrentApplicationName;
+ ::rtl::OUString msCurrentContextName;
+ };
+ typedef ::std::map<cssu::Reference<cssu::XInterface>, FocusDescriptor> ListenerMap;
+ ListenerMap maListeners;
+
+ /** Notify all listeners in the container that is associated with
+ the given event focus.
+
+ Typically called twice from broadcastEvent(), once for the
+ given event focus and onece for NULL.
+ */
+ void BroadcastEventToSingleContainer (
+ const css::ui::ContextChangeEventObject& rEventObject,
+ const cssu::Reference<cssu::XInterface>& rxEventFocus);
+ FocusDescriptor* GetFocusDescriptor (
+ const cssu::Reference<cssu::XInterface>& rxEventFocus,
+ const bool bCreateWhenMissing);
+};
+
+ContextChangeEventMultiplexer::ContextChangeEventMultiplexer()
: ContextChangeEventMultiplexerInterfaceBase(m_aMutex),
maListeners()
{
- (void)rxContext;
}
ContextChangeEventMultiplexer::~ContextChangeEventMultiplexer (void)
@@ -229,30 +311,10 @@ ContextChangeEventMultiplexer::FocusDescriptor* ContextChangeEventMultiplexer::G
return NULL;
}
-// XSingleComponentFactory
-cssu::Reference<cssu::XInterface> SAL_CALL ContextChangeEventMultiplexer::createInstanceWithContext (
- const cssu::Reference<cssu::XComponentContext>& rxContext)
- throw (cssu::Exception, cssu::RuntimeException)
-{
- (void)rxContext;
- return cssu::Reference<cssu::XInterface>();
-}
-
-cssu::Reference<cssu::XInterface > SAL_CALL ContextChangeEventMultiplexer::createInstanceWithArgumentsAndContext (
- const cssu::Sequence<cssu::Any>& rArguments,
- const cssu::Reference<cssu::XComponentContext>& rxContext)
- throw (cssu::Exception, cssu::RuntimeException)
-{
- (void)rArguments;
- (void)rxContext;
- return cssu::Reference<cssu::XInterface>();
-}
-
-// XServiceInfo
-::rtl::OUString SAL_CALL ContextChangeEventMultiplexer::getImplementationName (void)
+OUString SAL_CALL ContextChangeEventMultiplexer::getImplementationName()
throw(cssu::RuntimeException)
{
- return impl_getStaticImplementationName();
+ return OUString("org.apache.openoffice.comp.framework.ContextChangeEventMultiplexer");
}
sal_Bool SAL_CALL ContextChangeEventMultiplexer::supportsService ( const ::rtl::OUString& rsServiceName)
@@ -261,10 +323,11 @@ sal_Bool SAL_CALL ContextChangeEventMultiplexer::supportsService ( const ::rtl::
return cppu::supportsService(this, rsServiceName);
}
-cssu::Sequence<OUString> SAL_CALL ContextChangeEventMultiplexer::getSupportedServiceNames (void)
+css::uno::Sequence<OUString> SAL_CALL ContextChangeEventMultiplexer::getSupportedServiceNames()
throw (cssu::RuntimeException)
{
- return static_GetSupportedServiceNames();
+ // it's a singleton, not a service
+ return css::uno::Sequence<OUString>();
}
void SAL_CALL ContextChangeEventMultiplexer::disposing ( const css::lang::EventObject& rEvent)
@@ -283,37 +346,29 @@ void SAL_CALL ContextChangeEventMultiplexer::disposing ( const css::lang::EventO
maListeners.erase(iDescriptor);
}
-// Local and static methods.
-OUString SAL_CALL ContextChangeEventMultiplexer::impl_getStaticImplementationName (void)
-{
- return OUString(IMPLEMENTATION_NAME);
-}
+struct Instance {
+ explicit Instance():
+ instance(static_cast<cppu::OWeakObject *>(
+ new ContextChangeEventMultiplexer()))
+ {
+ }
-cssu::Sequence<OUString> SAL_CALL ContextChangeEventMultiplexer::static_GetSupportedServiceNames (void)
-{
- return css::uno::Sequence<OUString>();
-}
+ css::uno::Reference<css::uno::XInterface> instance;
+};
+
+struct Singleton:
+ public rtl::Static<Instance, Singleton>
+{};
-cssu::Reference<cssu::XInterface> ContextChangeEventMultiplexer::impl_createFactory (
- const cssu::Reference<cssl::XMultiServiceFactory>& rxServiceManager)
-{
- (void)rxServiceManager;
- return cppu::createSingleComponentFactory(
- ContextChangeEventMultiplexer::static_CreateInstance,
- ContextChangeEventMultiplexer::impl_getStaticImplementationName(),
- ContextChangeEventMultiplexer::static_GetSupportedServiceNames()
- );
}
-cssu::Reference<cssu::XInterface> SAL_CALL ContextChangeEventMultiplexer::static_CreateInstance (
- const cssu::Reference<cssu::XComponentContext>& rxComponentContext)
- throw (cssu::Exception)
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+org_apache_openoffice_comp_framework_ContextChangeEventMultiplexer_get_implementation(
+ css::uno::XComponentContext *,
+ css::uno::Sequence<css::uno::Any> const &)
{
- ContextChangeEventMultiplexer* pObject = new ContextChangeEventMultiplexer(rxComponentContext);
- cssu::Reference<cssu::XInterface> xService (static_cast<XWeak*>(pObject), cssu::UNO_QUERY);
- return xService;
+ return cppu::acquire(static_cast<cppu::OWeakObject *>(
+ Singleton::get().instance.get()));
}
-} // end of namespace framework
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index 47a817f..9d5fbb1 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -43,7 +43,8 @@
constructor="com_sun_star_comp_framework_DocumentAcceleratorConfiguration_get_implementation">
<service name="com.sun.star.ui.DocumentAcceleratorConfiguration"/>
</implementation>
- <implementation name="org.apache.openoffice.comp.framework.ContextChangeEventMultiplexer">
+ <implementation name="org.apache.openoffice.comp.framework.ContextChangeEventMultiplexer"
+ constructor="org_apache_openoffice_comp_framework_ContextChangeEventMultiplexer_get_implementation">
<singleton name="com.sun.star.ui.ContextChangeEventMultiplexer"/>
</implementation>
<implementation name="com.sun.star.comp.framework.Frame"
commit 72139db6b421fea2980e9c8df96bc70463777623
Author: Matúš Kukan <matus.kukan at collabora.com>
Date: Wed Jan 22 17:49:31 2014 +0100
fwk: Constructor feature for one instance SessionListener.
Converted as usual service implementation.
Change-Id: I37c2f25e8a463abb236753c1299cc0aeb3007cd9
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 74f9650..d09e22b 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -2358,23 +2358,15 @@ void Desktop::OpenClients()
try
{
// specifies whether the UI-interaction on Session shutdown is allowed
- sal_Bool bAllowUI = isUIOnSessionShutdownAllowed();
-
- xSessionListener = SessionListener::createWithOnQuitFlag(::comphelper::getProcessComponentContext(), bAllowUI);
-
-// css::beans::NamedValue aProperty( OUString( "AllowUserInteractionOnQuit" ),
- // css::uno::makeAny( bAllowUI ) );
- // css::uno::Sequence< css::uno::Any > aArgs( 1 );
- // aArgs[0] <<= aProperty;
-
- // xSessionListener->initialize( aArgs );
+ xSessionListener = SessionListener::createWithOnQuitFlag(
+ ::comphelper::getProcessComponentContext(), isUIOnSessionShutdownAllowed());
}
catch(const com::sun::star::uno::Exception& e)
{
SAL_WARN( "desktop.app", "Registration of session listener failed" << e.Message);
}
- if ( !bExistsRecoveryData )
+ if ( !bExistsRecoveryData && xSessionListener.is() )
{
// session management
try
diff --git a/framework/inc/services/desktop.hxx b/framework/inc/services/desktop.hxx
index de5121a..218a7c9 100644
--- a/framework/inc/services/desktop.hxx
+++ b/framework/inc/services/desktop.hxx
@@ -32,10 +32,7 @@
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/frame/XDesktop2.hpp>
-#include <com/sun/star/frame/WindowArrange.hpp>
-#include <com/sun/star/frame/TerminationVetoException.hpp>
#include <com/sun/star/frame/XTerminateListener.hpp>
-#include <com/sun/star/frame/XWindowArranger.hpp>
#include <com/sun/star/frame/XTask.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/frame/XModel.hpp>
@@ -51,9 +48,10 @@
#include <com/sun/star/lang/Locale.hpp>
#include <com/sun/star/frame/XDispatchResultListener.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
-#include <com/sun/star/frame/FeatureStateEvent.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp>
#include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <unotools/cmdoptions.hxx>
#include <cppuhelper/propshlp.hxx>
diff --git a/framework/inc/services/sessionlistener.hxx b/framework/inc/services/sessionlistener.hxx
deleted file mode 100644
index 42f0fb7..0000000
--- a/framework/inc/services/sessionlistener.hxx
+++ /dev/null
@@ -1,157 +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_FRAMEWORK_INC_SERVICES_SESSIONLISTENER_HXX
-#define INCLUDED_FRAMEWORK_INC_SERVICES_SESSIONLISTENER_HXX
-
-#include <classes/filtercache.hxx>
-#include <threadhelp/threadhelpbase.hxx>
-#include <macros/generic.hxx>
-#include <macros/xinterface.hxx>
-#include <macros/xtypeprovider.hxx>
-#include <macros/xserviceinfo.hxx>
-#include <general.h>
-
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-
-
-#include <com/sun/star/frame/XSessionManagerListener2.hpp>
-#include <com/sun/star/frame/XSessionManagerClient.hpp>
-#include <com/sun/star/frame/XStatusListener.hpp>
-#include <com/sun/star/frame/FeatureStateEvent.hpp>
-#include <com/sun/star/lang/EventObject.hpp>
-#include <com/sun/star/uno/Sequence.hxx>
-#include <com/sun/star/uno/Any.hxx>
-
-#include <cppuhelper/implbase4.hxx>
-
-namespace framework{
-
-/// @HTML
-/** @short implements flat/deep detection of file/stream formats and provides
- further read/write access to the global office type configuration.
-
- @descr Using of this class makes it possible to get information about the
- format type of a given URL or stream. The returned internal type name
- can be used to get more information about this format. Further this
- class provides full access to the configuration data and following
- implementations will support some special query modes.
-
- @author as96863
-
- @docdate 10.03.2003 by as96863
-
- @todo <ul>
- <li>implementation of query mode</li>
- <li>simple restore mechanism of last consistent cache state,
- if flush failed</li>
- </ul>
- */
-
-class SessionListener :
- // baseclasses (order important for initialization!)
- // Struct for right initalization of mutex member! Must be the first one of baseclasses!
- private ThreadHelpBase,
- // interfaces
- public cppu::WeakImplHelper4<
- css::lang::XInitialization,
- css::frame::XSessionManagerListener2,
- css::frame::XStatusListener,
- css::lang::XServiceInfo>
-{
- //-------------------------------------------
- // member
-
- private:
-
- /** reference to the uno service manager, which created this service.
- It can be used to create own needed helper services. */
- css::uno::Reference< css::uno::XComponentContext > m_xContext;
-
- css::uno::Reference< css::frame::XSessionManagerClient > m_rSessionManager;
-
- // restore handling
- sal_Bool m_bRestored;
-
- sal_Bool m_bSessionStoreRequested;
-
- sal_Bool m_bAllowUserInteractionOnQuit;
- sal_Bool m_bTerminated;
-
-
- // in case of synchronous call the caller should do saveDone() call himself!
- void StoreSession( sal_Bool bAsync );
-
- // let session quietly close the documents, remove lock files, store configuration and etc.
- void QuitSessionQuietly();
-
- public:
-
- //---------------------------------------
- // XInterface, XTypeProvider, XServiceInfo
-
- DECLARE_XSERVICEINFO
-
- //---------------------------------------
-
- /** @short initialize new instance of this class.
-
- @param xSMGR
- reference to the global uno service manager, which created this new
- factory instance. It must be used during runtime to create own
- needed services.
- */
-
- SessionListener( const css::uno::Reference< css::uno::XComponentContext >& xContext );
-
- virtual ~SessionListener();
-
- virtual void SAL_CALL disposing(const com::sun::star::lang::EventObject&) throw (css::uno::RuntimeException);
-
-
- // XInitialization
- virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& args) throw (css::uno::RuntimeException);
-
- // XSessionManagerListener
- virtual void SAL_CALL doSave( sal_Bool bShutdown, sal_Bool bCancelable )
- throw (css::uno::RuntimeException);
- virtual void SAL_CALL approveInteraction( sal_Bool bInteractionGranted )
- throw (css::uno::RuntimeException);
- virtual void SAL_CALL shutdownCanceled()
- throw (css::uno::RuntimeException);
- virtual sal_Bool SAL_CALL doRestore()
- throw (css::uno::RuntimeException);
-
- // XSessionManagerListener2
- virtual void SAL_CALL doQuit()
- throw (::com::sun::star::uno::RuntimeException);
-
- // XStatusListener
- virtual void SAL_CALL statusChanged(const com::sun::star::frame::FeatureStateEvent& event)
- throw (css::uno::RuntimeException);
-
- void doSaveImpl( sal_Bool bShutdown, sal_Bool bCancelable ) throw (css::uno::RuntimeException);
-};
-
-} // namespace framework
-
-#endif // INCLUDED_FRAMEWORK_INC_SERVICES_SESSIONLISTENER_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/register/registerservices.cxx b/framework/source/register/registerservices.cxx
index 829b594..06735d5 100644
--- a/framework/source/register/registerservices.cxx
+++ b/framework/source/register/registerservices.cxx
@@ -34,14 +34,11 @@
)
=================================================================================================================*/
#include <services/desktop.hxx>
-#include <services/sessionlistener.hxx>
#include <services/ContextChangeEventMultiplexer.hxx>
COMPONENTGETFACTORY ( fwk,
IFFACTORY( ::framework::Desktop ) else
- IFFACTORY( ::framework::SessionListener ) else
- IFFACTORY( ::framework::SessionListener ) else
IFFACTORY( ::framework::ContextChangeEventMultiplexer )
)
diff --git a/framework/source/services/sessionlistener.cxx b/framework/source/services/sessionlistener.cxx
index 4449b82..d1f7d28 100644
--- a/framework/source/services/sessionlistener.cxx
+++ b/framework/source/services/sessionlistener.cxx
@@ -17,73 +17,149 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <services/sessionlistener.hxx>
+#include <sal/types.h>
+
#include <services/desktop.hxx>
-#include <threadhelp/readguard.hxx>
-#include <threadhelp/resetableguard.hxx>
+#include <classes/filtercache.hxx>
#include <protocols.h>
-#include <services.h>
-
-#include <osl/thread.h>
+#include <general.h>
#include <vcl/svapp.hxx>
#include <unotools/tempfile.hxx>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/beans/PropertyState.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/frame/theAutoRecovery.hpp>
-#include <com/sun/star/frame/XFramesSupplier.hpp>
-#include <com/sun/star/frame/XStorable.hpp>
-#include <com/sun/star/frame/XComponentLoader.hpp>
-#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/frame/Desktop.hpp>
-#include <com/sun/star/util/XModifiable.hpp>
-#include <com/sun/star/util/XChangesBatch.hpp>
+#include <com/sun/star/frame/FeatureStateEvent.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XSessionManagerListener2.hpp>
+#include <com/sun/star/frame/XSessionManagerClient.hpp>
+#include <com/sun/star/frame/XStatusListener.hpp>
+#include <com/sun/star/lang/EventObject.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/util/URLTransformer.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/util/URL.hpp>
-#include <osl/time.h>
-#include <comphelper/processfactory.hxx>
+#include <cppuhelper/implbase4.hxx>
+#include <cppuhelper/supportsservice.hxx>
#include <unotools/pathoptions.hxx>
-#include <stdio.h>
#include <com/sun/star/uno/Any.hxx>
-
#include <com/sun/star/uno/Sequence.hxx>
+using namespace css;
using namespace com::sun::star::uno;
using namespace com::sun::star::util;
-using namespace com::sun::star::frame;
-using namespace com::sun::star::lang;
using namespace com::sun::star::beans;
-using namespace com::sun::star::container;
+using namespace framework;
+
+namespace {
+
+/// @HTML
+/** @short implements flat/deep detection of file/stream formats and provides
+ further read/write access to the global office type configuration.
+
+ @descr Using of this class makes it possible to get information about the
+ format type of a given URL or stream. The returned internal type name
+ can be used to get more information about this format. Further this
+ class provides full access to the configuration data and following
+ implementations will support some special query modes.
+
+ @author as96863
+
+ @docdate 10.03.2003 by as96863
+
+ @todo <ul>
+ <li>implementation of query mode</li>
+ <li>simple restore mechanism of last consistent cache state,
+ if flush failed</li>
+ </ul>
+ */
+typedef cppu::WeakImplHelper4<
+ css::lang::XInitialization,
+ css::frame::XSessionManagerListener2,
+ css::frame::XStatusListener,
+ css::lang::XServiceInfo> SessionListener_BASE;
+
+class SessionListener : public SessionListener_BASE
+{
+private:
+ osl::Mutex m_aMutex;
+
+ /** reference to the uno service manager, which created this service.
+ It can be used to create own needed helper services. */
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+
+ css::uno::Reference< css::frame::XSessionManagerClient > m_rSessionManager;
+
+ // restore handling
+ sal_Bool m_bRestored;
+
+ sal_Bool m_bSessionStoreRequested;
+
+ sal_Bool m_bAllowUserInteractionOnQuit;
+ sal_Bool m_bTerminated;
-namespace framework{
+ // in case of synchronous call the caller should do saveDone() call himself!
+ void StoreSession( sal_Bool bAsync );
-// XInterface, XTypeProvider, XServiceInfo
+ // let session quietly close the documents, remove lock files, store configuration and etc.
+ void QuitSessionQuietly();
-DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2(
- SessionListener,
- cppu::OWeakObject,
- "com.sun.star.frame.SessionListener",
- IMPLEMENTATIONNAME_SESSIONLISTENER)
+public:
+ SessionListener( const css::uno::Reference< css::uno::XComponentContext >& xContext );
-DEFINE_INIT_SERVICE(SessionListener,
- {
- /* Add special code for initialization here, if you have to use your own instance
- during your ctor is still in progress! */
- }
- )
+ virtual ~SessionListener();
+
+ virtual OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException)
+ {
+ return OUString("com.sun.star.comp.frame.SessionListener");
+ }
+
+ virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
+ throw (css::uno::RuntimeException)
+ {
+ return cppu::supportsService(this, ServiceName);
+ }
+
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
+ throw (css::uno::RuntimeException)
+ {
+ css::uno::Sequence< OUString > aSeq(1);
+ aSeq[0] = OUString("com.sun.star.frame.SessionListener");
+ return aSeq;
+ }
+
+ virtual void SAL_CALL disposing(const com::sun::star::lang::EventObject&) throw (css::uno::RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& args) throw (css::uno::RuntimeException);
+
+ // XSessionManagerListener
+ virtual void SAL_CALL doSave( sal_Bool bShutdown, sal_Bool bCancelable )
+ throw (css::uno::RuntimeException);
+ virtual void SAL_CALL approveInteraction( sal_Bool bInteractionGranted )
+ throw (css::uno::RuntimeException);
+ virtual void SAL_CALL shutdownCanceled()
+ throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL doRestore()
+ throw (css::uno::RuntimeException);
+
+ // XSessionManagerListener2
+ virtual void SAL_CALL doQuit()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XStatusListener
+ virtual void SAL_CALL statusChanged(const com::sun::star::frame::FeatureStateEvent& event)
+ throw (css::uno::RuntimeException);
+
+ void doSaveImpl( sal_Bool bShutdown, sal_Bool bCancelable ) throw (css::uno::RuntimeException);
+};
SessionListener::SessionListener(const css::uno::Reference< css::uno::XComponentContext >& rxContext )
- : ThreadHelpBase (&Application::GetSolarMutex())
- , m_xContext (rxContext )
+ : m_xContext( rxContext )
, m_bRestored( sal_False )
, m_bSessionStoreRequested( sal_False )
, m_bAllowUserInteractionOnQuit( sal_False )
@@ -105,15 +181,15 @@ SessionListener::~SessionListener()
void SessionListener::StoreSession( sal_Bool bAsync )
{
SAL_INFO("fwk.session", "SessionListener::StoreSession");
- ResetableGuard aGuard(m_aLock);
+ osl::MutexGuard g(m_aMutex);
try
{
- // xd create SERVICENAME_AUTORECOVERY -> XDispatch
+ // xd create SERVICENAME_AUTORECOVERY -> frame::XDispatch
// xd->dispatch("vnd.sun.star.autorecovery:/doSessionSave, async=bAsync
// on stop event m_rSessionManager->saveDone(this); in case of asynchronous call
// in case of synchronous call the caller should do saveDone() call himself!
- css::uno::Reference< XDispatch > xDispatch = css::frame::theAutoRecovery::get( m_xContext );
+ css::uno::Reference< frame::XDispatch > xDispatch = css::frame::theAutoRecovery::get( m_xContext );
css::uno::Reference< XURLTransformer > xURLTransformer = URLTransformer::create( m_xContext );
URL aURL;
aURL.Complete = "vnd.sun.star.autorecovery:/doSessionSave";
@@ -138,14 +214,14 @@ void SessionListener::StoreSession( sal_Bool bAsync )
void SessionListener::QuitSessionQuietly()
{
SAL_INFO("fwk.session", "SessionListener::QuitSessionQuietly");
- ResetableGuard aGuard(m_aLock);
+ osl::MutexGuard g(m_aMutex);
try
{
- // xd create SERVICENAME_AUTORECOVERY -> XDispatch
+ // xd create SERVICENAME_AUTORECOVERY -> frame::XDispatch
// xd->dispatch("vnd.sun.star.autorecovery:/doSessionQuietQuit, async=false
// it is done synchronously to avoid conflict with normal quit process
- css::uno::Reference< XDispatch > xDispatch = css::frame::theAutoRecovery::get( m_xContext );
+ css::uno::Reference< frame::XDispatch > xDispatch = css::frame::theAutoRecovery::get( m_xContext );
css::uno::Reference< XURLTransformer > xURLTransformer = URLTransformer::create( m_xContext );
URL aURL;
aURL.Complete = "vnd.sun.star.autorecovery:/doSessionQuietQuit";
@@ -189,7 +265,7 @@ void SAL_CALL SessionListener::initialize(const Sequence< Any >& args)
}
}
if (!m_rSessionManager.is())
- m_rSessionManager = css::uno::Reference< XSessionManagerClient >
+ m_rSessionManager = css::uno::Reference< frame::XSessionManagerClient >
(m_xContext->getServiceManager()->createInstanceWithContext(aSMgr, m_xContext), UNO_QUERY);
if (m_rSessionManager.is())
@@ -198,7 +274,7 @@ void SAL_CALL SessionListener::initialize(const Sequence< Any >& args)
}
}
-void SAL_CALL SessionListener::statusChanged(const FeatureStateEvent& event)
+void SAL_CALL SessionListener::statusChanged(const frame::FeatureStateEvent& event)
throw (css::uno::RuntimeException)
{
SAL_INFO("fwk.session", "SessionListener::statusChanged");
@@ -223,10 +299,10 @@ sal_Bool SAL_CALL SessionListener::doRestore()
throw (RuntimeException)
{
SAL_INFO("fwk.session", "SessionListener::doRestore");
- ResetableGuard aGuard(m_aLock);
+ osl::MutexGuard g(m_aMutex);
m_bRestored = sal_False;
try {
- css::uno::Reference< XDispatch > xDispatch = css::frame::theAutoRecovery::get( m_xContext );
+ css::uno::Reference< frame::XDispatch > xDispatch = css::frame::theAutoRecovery::get( m_xContext );
URL aURL;
aURL.Complete = "vnd.sun.star.autorecovery:/doSessionRestore";
@@ -267,7 +343,7 @@ void SAL_CALL SessionListener::approveInteraction( sal_Bool bInteractionGranted
{
SAL_INFO("fwk.session", "SessionListener::approveInteraction");
// do AutoSave as the first step
- ResetableGuard aGuard(m_aLock);
+ osl::MutexGuard g(m_aMutex);
if ( bInteractionGranted )
{
@@ -337,4 +413,12 @@ void SessionListener::doQuit()
}
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_frame_SessionListener_get_implementation(
+ css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new SessionListener(context));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index 0db78c8..47a817f 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -19,7 +19,8 @@
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
prefix="fwk" xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.comp.frame.SessionListener">
+ <implementation name="com.sun.star.comp.frame.SessionListener"
+ constructor="com_sun_star_comp_frame_SessionListener_get_implementation">
<service name="com.sun.star.frame.SessionListener"/>
</implementation>
<implementation name="com.sun.star.comp.framework.AddonsToolBarFactory"
More information about the Libreoffice-commits
mailing list