diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-09 16:38:11 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-02-06 12:03:30 +0100 |
commit | 53052e5bfa6509395fa17b7517463c57f44999fe (patch) | |
tree | b5812ed96088c5aac10bd64e0f9a35b83369a34b /framework | |
parent | 4ff873bda2a3af12e5c4848843ea6b7d9592bb6b (diff) |
fwk: Constructor feature for single-instance WindowStateConfiguration.
Change-Id: I0537d7a30b6c6807bf746a52dbd2c7fc66607ae2
Diffstat (limited to 'framework')
10 files changed, 187 insertions, 211 deletions
diff --git a/framework/inc/services/layoutmanager.hxx b/framework/inc/services/layoutmanager.hxx index 167f954cc86c..569a1a80531d 100644 --- a/framework/inc/services/layoutmanager.hxx +++ b/framework/inc/services/layoutmanager.hxx @@ -29,7 +29,6 @@ #include <properties.h> #include <stdtypes.h> #include <uielement/menubarmanager.hxx> -#include <uiconfiguration/windowstateconfiguration.hxx> #include <framework/addonsoptions.hxx> #include <uielement/uielement.hxx> #include <helper/ilayoutnotifications.hxx> diff --git a/framework/inc/uiconfiguration/windowstateconfiguration.hxx b/framework/inc/uiconfiguration/windowstateconfiguration.hxx deleted file mode 100644 index 092d7a5368f1..000000000000 --- a/framework/inc/uiconfiguration/windowstateconfiguration.hxx +++ /dev/null @@ -1,112 +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_UICONFIGURATION_WINDOWSTATECONFIGURATION_HXX -#define INCLUDED_FRAMEWORK_INC_UICONFIGURATION_WINDOWSTATECONFIGURATION_HXX - -/** Attention: stl headers must(!) be included at first. Otherwise it can make trouble - with solaris headers ... -*/ -#include <vector> -#include <list> -#include <boost/unordered_map.hpp> - -#include <threadhelp/threadhelpbase.hxx> -#include <macros/generic.hxx> -#include <macros/xinterface.hxx> -#include <macros/xtypeprovider.hxx> -#include <macros/xserviceinfo.hxx> -#include <stdtypes.h> - -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XTypeProvider.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/frame/XModuleManager2.hpp> - -#include <cppuhelper/implbase2.hxx> -#include <rtl/ustring.hxx> - -namespace framework -{ - -#define WINDOWSTATE_PROPERTY_LOCKED "Locked" -#define WINDOWSTATE_PROPERTY_DOCKED "Docked" -#define WINDOWSTATE_PROPERTY_VISIBLE "Visible" -#define WINDOWSTATE_PROPERTY_DOCKINGAREA "DockingArea" -#define WINDOWSTATE_PROPERTY_DOCKPOS "DockPos" -#define WINDOWSTATE_PROPERTY_DOCKSIZE "DockSize" -#define WINDOWSTATE_PROPERTY_POS "Pos" -#define WINDOWSTATE_PROPERTY_SIZE "Size" -#define WINDOWSTATE_PROPERTY_UINAME "UIName" -#define WINDOWSTATE_PROPERTY_INTERNALSTATE "InternalState" -#define WINDOWSTATE_PROPERTY_STYLE "Style" -#define WINDOWSTATE_PROPERTY_CONTEXT "ContextSensitive" -#define WINDOWSTATE_PROPERTY_HIDEFROMENU "HideFromToolbarMenu" -#define WINDOWSTATE_PROPERTY_NOCLOSE "NoClose" -#define WINDOWSTATE_PROPERTY_SOFTCLOSE "SoftClose" -#define WINDOWSTATE_PROPERTY_CONTEXTACTIVE "ContextActive" - -class WindowStateConfiguration : private ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses. - public ::cppu::WeakImplHelper2< css::container::XNameAccess, css::lang::XServiceInfo> -{ - public: - WindowStateConfiguration( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ); - virtual ~WindowStateConfiguration(); - - // XInterface, XTypeProvider, XServiceInfo - DECLARE_XSERVICEINFO - - // XNameAccess - virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName ) - throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames() - throw (::com::sun::star::uno::RuntimeException); - - virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) - throw (::com::sun::star::uno::RuntimeException); - - // XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType() - throw (::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements() - throw (::com::sun::star::uno::RuntimeException); - - typedef ::boost::unordered_map< OUString, - OUString, - OUStringHash, - ::std::equal_to< OUString > > ModuleToWindowStateFileMap; - - typedef ::boost::unordered_map< OUString, - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >, - OUStringHash, - ::std::equal_to< OUString > > ModuleToWindowStateConfigHashMap; - - private: - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xContext; - ModuleToWindowStateFileMap m_aModuleToFileHashMap; - ModuleToWindowStateConfigHashMap m_aModuleToWindowStateHashMap; - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > m_xModuleManager; -}; - -} // namespace framework - -#endif // __FRAMEWORK_UIELEMENT_WINDOWSTATECONFIGURATION_HXX_ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uiconfiguration/windowstateproperties.hxx b/framework/inc/uiconfiguration/windowstateproperties.hxx new file mode 100644 index 000000000000..b4653c4a1f27 --- /dev/null +++ b/framework/inc/uiconfiguration/windowstateproperties.hxx @@ -0,0 +1,42 @@ +/* -*- 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_UICONFIGURATION_WINDOWSTATEPROPERTIES_HXX +#define INCLUDED_FRAMEWORK_INC_UICONFIGURATION_WINDOWSTATEPROPERTIES_HXX + +#define WINDOWSTATE_PROPERTY_LOCKED "Locked" +#define WINDOWSTATE_PROPERTY_DOCKED "Docked" +#define WINDOWSTATE_PROPERTY_VISIBLE "Visible" +#define WINDOWSTATE_PROPERTY_DOCKINGAREA "DockingArea" +#define WINDOWSTATE_PROPERTY_DOCKPOS "DockPos" +#define WINDOWSTATE_PROPERTY_DOCKSIZE "DockSize" +#define WINDOWSTATE_PROPERTY_POS "Pos" +#define WINDOWSTATE_PROPERTY_SIZE "Size" +#define WINDOWSTATE_PROPERTY_UINAME "UIName" +#define WINDOWSTATE_PROPERTY_INTERNALSTATE "InternalState" +#define WINDOWSTATE_PROPERTY_STYLE "Style" +#define WINDOWSTATE_PROPERTY_CONTEXT "ContextSensitive" +#define WINDOWSTATE_PROPERTY_HIDEFROMENU "HideFromToolbarMenu" +#define WINDOWSTATE_PROPERTY_NOCLOSE "NoClose" +#define WINDOWSTATE_PROPERTY_SOFTCLOSE "SoftClose" +#define WINDOWSTATE_PROPERTY_CONTEXTACTIVE "ContextActive" + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 906b1aa795e7..b5ce84c42919 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -24,12 +24,12 @@ #include <framework/sfxhelperfunctions.hxx> #include <uielement/menubarwrapper.hxx> #include <framework/addonsoptions.hxx> -#include <uiconfiguration/windowstateconfiguration.hxx> #include <classes/fwkresid.hxx> #include <classes/resource.hrc> #include <toolkit/helper/convert.hxx> #include <uielement/progressbarwrapper.hxx> #include <uiconfiguration/globalsettings.hxx> +#include <uiconfiguration/windowstateproperties.hxx> #include <toolbarlayoutmanager.hxx> #include <com/sun/star/beans/XPropertySet.hpp> diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx index 35e903c42a3d..71a29b432422 100644 --- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx +++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx @@ -18,13 +18,13 @@ */ #include <toolbarlayoutmanager.hxx> +#include <uiconfiguration/windowstateproperties.hxx> #include <uielement/addonstoolbarwrapper.hxx> #include <helpers.hxx> #include <services.h> #include <services/layoutmanager.hxx> #include <classes/resource.hrc> #include <classes/fwkresid.hxx> -#include <uiconfiguration/windowstateconfiguration.hxx> #include <com/sun/star/awt/PosSize.hpp> #include <com/sun/star/awt/Toolkit.hpp> diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.hxx b/framework/source/layoutmanager/toolbarlayoutmanager.hxx index 7c475f246db0..4c2a64c15065 100644 --- a/framework/source/layoutmanager/toolbarlayoutmanager.hxx +++ b/framework/source/layoutmanager/toolbarlayoutmanager.hxx @@ -36,7 +36,6 @@ #include <stdtypes.h> #include <properties.h> #include <uiconfiguration/globalsettings.hxx> -#include <uiconfiguration/windowstateconfiguration.hxx> #include <framework/addonsoptions.hxx> #include <uielement/uielement.hxx> #include <helper/ilayoutnotifications.hxx> diff --git a/framework/source/register/registerservices.cxx b/framework/source/register/registerservices.cxx index 5e12cb771cc9..829b5944c59e 100644 --- a/framework/source/register/registerservices.cxx +++ b/framework/source/register/registerservices.cxx @@ -34,14 +34,12 @@ ) =================================================================================================================*/ #include <services/desktop.hxx> -#include "uiconfiguration/windowstateconfiguration.hxx" #include <services/sessionlistener.hxx> #include <services/ContextChangeEventMultiplexer.hxx> COMPONENTGETFACTORY ( fwk, IFFACTORY( ::framework::Desktop ) else - IFFACTORY( ::framework::WindowStateConfiguration ) else IFFACTORY( ::framework::SessionListener ) else IFFACTORY( ::framework::SessionListener ) else IFFACTORY( ::framework::ContextChangeEventMultiplexer ) diff --git a/framework/source/uiconfiguration/windowstateconfiguration.cxx b/framework/source/uiconfiguration/windowstateconfiguration.cxx index dc3b9aaa7726..a0c306025111 100644 --- a/framework/source/uiconfiguration/windowstateconfiguration.cxx +++ b/framework/source/uiconfiguration/windowstateconfiguration.cxx @@ -17,11 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "uiconfiguration/windowstateconfiguration.hxx" -#include <threadhelp/resetableguard.hxx> -#include "services.h" - -#include "helper/mischelper.hxx" +#include <uiconfiguration/windowstateproperties.hxx> +#include <helper/mischelper.hxx> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -29,19 +26,23 @@ #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XContainer.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/frame/ModuleManager.hpp> +#include <com/sun/star/frame/XModuleManager2.hpp> #include <com/sun/star/awt/Point.hpp> #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/ui/DockingArea.hpp> #include <com/sun/star/util/XChangesBatch.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> -#include <rtl/ustrbuf.hxx> -#include <cppuhelper/weak.hxx> +#include <cppuhelper/compbase2.hxx> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/supportsservice.hxx> #include <tools/debug.hxx> -//_________________________________________________________________________________________________________________ -// Defines -//_________________________________________________________________________________________________________________ +#include <vector> +#include <boost/unordered_map.hpp> using namespace com::sun::star::uno; using namespace com::sun::star::lang; @@ -51,32 +52,11 @@ using namespace com::sun::star::configuration; using namespace com::sun::star::container; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::ui; +using namespace framework; #undef WINDOWSTATE_MASK_POS -//_________________________________________________________________________________________________________________ -// Namespace -//_________________________________________________________________________________________________________________ - -static const char CONFIGURATION_ROOT_ACCESS[] = "/org.openoffice.Office.UI."; -static const char CONFIGURATION_WINDOWSTATE_ACCESS[] = "/UIElements/States"; - -static const char CONFIGURATION_PROPERTY_LOCKED[] = WINDOWSTATE_PROPERTY_LOCKED; -static const char CONFIGURATION_PROPERTY_DOCKED[] = WINDOWSTATE_PROPERTY_DOCKED; -static const char CONFIGURATION_PROPERTY_VISIBLE[] = WINDOWSTATE_PROPERTY_VISIBLE; -static const char CONFIGURATION_PROPERTY_DOCKINGAREA[] = WINDOWSTATE_PROPERTY_DOCKINGAREA; -static const char CONFIGURATION_PROPERTY_DOCKPOS[] = WINDOWSTATE_PROPERTY_DOCKPOS; -static const char CONFIGURATION_PROPERTY_DOCKSIZE[] = WINDOWSTATE_PROPERTY_DOCKSIZE; -static const char CONFIGURATION_PROPERTY_POS[] = WINDOWSTATE_PROPERTY_POS; -static const char CONFIGURATION_PROPERTY_SIZE[] = WINDOWSTATE_PROPERTY_SIZE; -static const char CONFIGURATION_PROPERTY_UINAME[] = WINDOWSTATE_PROPERTY_UINAME; -static const char CONFIGURATION_PROPERTY_INTERNALSTATE[] = WINDOWSTATE_PROPERTY_INTERNALSTATE; -static const char CONFIGURATION_PROPERTY_STYLE[] = WINDOWSTATE_PROPERTY_STYLE; -static const char CONFIGURATION_PROPERTY_CONTEXT[] = WINDOWSTATE_PROPERTY_CONTEXT; -static const char CONFIGURATION_PROPERTY_HIDEFROMMENU[] = WINDOWSTATE_PROPERTY_HIDEFROMENU; -static const char CONFIGURATION_PROPERTY_NOCLOSE[] = WINDOWSTATE_PROPERTY_NOCLOSE; -static const char CONFIGURATION_PROPERTY_SOFTCLOSE[] = WINDOWSTATE_PROPERTY_SOFTCLOSE; -static const char CONFIGURATION_PROPERTY_CONTEXTACTIVE[] = WINDOWSTATE_PROPERTY_CONTEXTACTIVE; +namespace { // Zero based indexes, order must be the same as WindowStateMask && CONFIGURATION_PROPERTIES! static const sal_Int16 PROPERTY_LOCKED = 0; @@ -99,36 +79,30 @@ static const sal_Int16 PROPERTY_DOCKSIZE = 15; // Order must be the same as WindowStateMask!! static const char* CONFIGURATION_PROPERTIES[] = { - CONFIGURATION_PROPERTY_LOCKED, - CONFIGURATION_PROPERTY_DOCKED, - CONFIGURATION_PROPERTY_VISIBLE, - CONFIGURATION_PROPERTY_CONTEXT, - CONFIGURATION_PROPERTY_HIDEFROMMENU, - CONFIGURATION_PROPERTY_NOCLOSE, - CONFIGURATION_PROPERTY_SOFTCLOSE, - CONFIGURATION_PROPERTY_CONTEXTACTIVE, - CONFIGURATION_PROPERTY_DOCKINGAREA, - CONFIGURATION_PROPERTY_POS, - CONFIGURATION_PROPERTY_SIZE, - CONFIGURATION_PROPERTY_UINAME, - CONFIGURATION_PROPERTY_INTERNALSTATE, - CONFIGURATION_PROPERTY_STYLE, - CONFIGURATION_PROPERTY_DOCKPOS, - CONFIGURATION_PROPERTY_DOCKSIZE, + WINDOWSTATE_PROPERTY_LOCKED, + WINDOWSTATE_PROPERTY_DOCKED, + WINDOWSTATE_PROPERTY_VISIBLE, + WINDOWSTATE_PROPERTY_CONTEXT, + WINDOWSTATE_PROPERTY_HIDEFROMENU, + WINDOWSTATE_PROPERTY_NOCLOSE, + WINDOWSTATE_PROPERTY_SOFTCLOSE, + WINDOWSTATE_PROPERTY_CONTEXTACTIVE, + WINDOWSTATE_PROPERTY_DOCKINGAREA, + WINDOWSTATE_PROPERTY_POS, + WINDOWSTATE_PROPERTY_SIZE, + WINDOWSTATE_PROPERTY_UINAME, + WINDOWSTATE_PROPERTY_INTERNALSTATE, + WINDOWSTATE_PROPERTY_STYLE, + WINDOWSTATE_PROPERTY_DOCKPOS, + WINDOWSTATE_PROPERTY_DOCKSIZE, 0 }; -namespace framework -{ - //***************************************************************************************************************** // Configuration access class for WindowState supplier implementation //***************************************************************************************************************** -class ConfigurationAccess_WindowState : // Order is necessary for right initialization! - private ThreadHelpBase , - // interfaces - public ::cppu::WeakImplHelper2< XNameContainer, XContainerListener > +class ConfigurationAccess_WindowState : public ::cppu::WeakImplHelper2< XNameContainer, XContainerListener > { public: ConfigurationAccess_WindowState( const OUString& aWindowStateConfigFile, const Reference< XComponentContext >& rxContext ); @@ -236,6 +210,7 @@ class ConfigurationAccess_WindowState : // Order is necessary for right initiali OUStringHash, ::std::equal_to< OUString > > ResourceURLToInfoCache; + osl::Mutex m_aMutex; OUString m_aConfigWindowAccess; Reference< XMultiServiceFactory > m_xConfigProvider; Reference< XNameAccess > m_xConfigAccess; @@ -249,14 +224,13 @@ class ConfigurationAccess_WindowState : // Order is necessary for right initiali //***************************************************************************************************************** ConfigurationAccess_WindowState::ConfigurationAccess_WindowState( const OUString& aModuleName, const Reference< XComponentContext >& rxContext ) : - ThreadHelpBase(), - m_aConfigWindowAccess( CONFIGURATION_ROOT_ACCESS ), + m_aConfigWindowAccess( "/org.openoffice.Office.UI." ), m_bConfigAccessInitialized( sal_False ), m_bModified( sal_False ) { // Create configuration hierachical access name m_aConfigWindowAccess += aModuleName; - m_aConfigWindowAccess += CONFIGURATION_WINDOWSTATE_ACCESS; + m_aConfigWindowAccess += "/UIElements/States"; m_xConfigProvider = theDefaultProvider::get( rxContext ); // Initialize access array with property names. @@ -271,7 +245,7 @@ ConfigurationAccess_WindowState::ConfigurationAccess_WindowState( const OUString ConfigurationAccess_WindowState::~ConfigurationAccess_WindowState() { // SAFE - ResetableGuard aLock( m_aLock ); + osl::MutexGuard g(m_aMutex); Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY ); if ( xContainer.is() ) xContainer->removeContainerListener(m_xConfigListener); @@ -282,7 +256,7 @@ Any SAL_CALL ConfigurationAccess_WindowState::getByName( const OUString& rResour throw ( NoSuchElementException, WrappedTargetException, RuntimeException) { // SAFE - ResetableGuard aLock( m_aLock ); + osl::MutexGuard g(m_aMutex); ResourceURLToInfoCache::const_iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL ); if ( pIter != m_aResourceURLToInfoCache.end() ) @@ -301,7 +275,7 @@ Sequence< OUString > SAL_CALL ConfigurationAccess_WindowState::getElementNames() throw ( RuntimeException ) { // SAFE - ResetableGuard aLock( m_aLock ); + osl::MutexGuard g(m_aMutex); if ( !m_bConfigAccessInitialized ) { @@ -319,7 +293,7 @@ sal_Bool SAL_CALL ConfigurationAccess_WindowState::hasByName( const OUString& rR throw (::com::sun::star::uno::RuntimeException) { // SAFE - ResetableGuard aLock( m_aLock ); + osl::MutexGuard g(m_aMutex); ResourceURLToInfoCache::const_iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL ); if ( pIter != m_aResourceURLToInfoCache.end() ) @@ -345,7 +319,7 @@ sal_Bool SAL_CALL ConfigurationAccess_WindowState::hasElements() throw ( RuntimeException ) { // SAFE - ResetableGuard aLock( m_aLock ); + osl::MutexGuard g(m_aMutex); if ( !m_bConfigAccessInitialized ) { @@ -364,7 +338,7 @@ void SAL_CALL ConfigurationAccess_WindowState::removeByName( const OUString& rRe throw( NoSuchElementException, WrappedTargetException, RuntimeException ) { // SAFE - ResetableGuard aLock( m_aLock ); + osl::ResettableMutexGuard g(m_aMutex); ResourceURLToInfoCache::iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL ); if ( pIter != m_aResourceURLToInfoCache.end() ) @@ -382,7 +356,7 @@ throw( NoSuchElementException, WrappedTargetException, RuntimeException ) Reference< XNameContainer > xNameContainer( m_xConfigAccess, UNO_QUERY ); if ( xNameContainer.is() ) { - aLock.unlock(); + g.clear(); xNameContainer->removeByName( rResourceURL ); Reference< XChangesBatch > xFlush( m_xConfigAccess, UNO_QUERY ); @@ -399,7 +373,7 @@ void SAL_CALL ConfigurationAccess_WindowState::insertByName( const OUString& rRe throw( IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException ) { // SAFE - ResetableGuard aLock( m_aLock ); + osl::ResettableMutexGuard g(m_aMutex); Sequence< PropertyValue > aPropSet; if ( aPropertySet >>= aPropSet ) @@ -431,7 +405,7 @@ throw( IllegalArgumentException, ElementExistException, WrappedTargetException, if ( xNameContainer.is() ) { Reference< XSingleServiceFactory > xFactory( m_xConfigAccess, UNO_QUERY ); - aLock.unlock(); + g.clear(); try { @@ -464,7 +438,7 @@ void SAL_CALL ConfigurationAccess_WindowState::replaceByName( const OUString& rR throw( IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException ) { // SAFE - ResetableGuard aLock( m_aLock ); + osl::ResettableMutexGuard g(m_aMutex); Sequence< PropertyValue > aPropSet; if ( aPropertySet >>= aPropSet ) @@ -507,7 +481,7 @@ throw( IllegalArgumentException, NoSuchElementException, WrappedTargetException, WindowStateInfo aWinStateInfo( pIter->second ); OUString aResourceURL( pIter->first ); m_bModified = sal_False; - aLock.unlock(); + g.clear(); try { @@ -550,7 +524,7 @@ void SAL_CALL ConfigurationAccess_WindowState::disposing( const EventObject& aEv { // SAFE // remove our reference to the config access - ResetableGuard aLock( m_aLock ); + osl::MutexGuard g(m_aMutex); Reference< XInterface > xIfac1( aEvent.Source, UNO_QUERY ); Reference< XInterface > xIfac2( m_xConfigAccess, UNO_QUERY ); @@ -1269,8 +1243,7 @@ sal_Bool ConfigurationAccess_WindowState::impl_initializeConfigAccess() aArgs[1] <<= aPropValue; m_xConfigAccess = Reference< XNameAccess >( m_xConfigProvider->createInstanceWithArguments( - SERVICENAME_CFGUPDATEACCESS, aArgs ), - UNO_QUERY ); + "com.sun.star.configuration.ConfigurationUpdateAccess", aArgs ), UNO_QUERY ); if ( m_xConfigAccess.is() ) { // Add as container listener @@ -1294,28 +1267,79 @@ sal_Bool ConfigurationAccess_WindowState::impl_initializeConfigAccess() return sal_False; } +typedef ::cppu::WeakComponentImplHelper2< css::container::XNameAccess, + css::lang::XServiceInfo> WindowStateConfiguration_BASE; -//***************************************************************************************************************** -// XInterface, XTypeProvider, XServiceInfo -//***************************************************************************************************************** -DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2( WindowStateConfiguration , - ::cppu::OWeakObject , - "com.sun.star.ui.WindowStateConfiguration" , - IMPLEMENTATIONNAME_WINDOWSTATECONFIGURATION - ) +class WindowStateConfiguration : private osl::Mutex, + public WindowStateConfiguration_BASE +{ +public: + WindowStateConfiguration( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~WindowStateConfiguration(); + + virtual OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException) + { + return OUString("com.sun.star.comp.framework.WindowStateConfiguration"); + } + + 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.ui.WindowStateConfiguration"); + return aSeq; + } + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) + throw ( css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException); -DEFINE_INIT_SERVICE ( WindowStateConfiguration, {} ) + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() + throw (css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) + throw (css::uno::RuntimeException); + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() + throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (css::uno::RuntimeException); + + typedef ::boost::unordered_map< OUString, + OUString, + OUStringHash, + ::std::equal_to< OUString > > ModuleToWindowStateFileMap; + + typedef ::boost::unordered_map< OUString, + css::uno::Reference< css::container::XNameAccess >, + OUStringHash, + ::std::equal_to< OUString > > ModuleToWindowStateConfigHashMap; + +private: + css::uno::Reference< css::uno::XComponentContext> m_xContext; + ModuleToWindowStateFileMap m_aModuleToFileHashMap; + ModuleToWindowStateConfigHashMap m_aModuleToWindowStateHashMap; +}; WindowStateConfiguration::WindowStateConfiguration( const Reference< XComponentContext >& rxContext ) : - ThreadHelpBase(), + WindowStateConfiguration_BASE(*static_cast<osl::Mutex *>(this)), m_xContext( rxContext ) { - m_xModuleManager = ModuleManager::create( m_xContext ); + css::uno::Reference< css::frame::XModuleManager2 > xModuleManager = + ModuleManager::create( m_xContext ); Reference< XNameAccess > xEmptyNameAccess; Sequence< OUString > aElementNames; try { - aElementNames = m_xModuleManager->getElementNames(); + aElementNames = xModuleManager->getElementNames(); } catch (const ::com::sun::star::uno::RuntimeException &) { @@ -1326,7 +1350,7 @@ WindowStateConfiguration::WindowStateConfiguration( const Reference< XComponentC for ( sal_Int32 i = 0; i < aElementNames.getLength(); i++ ) { aModuleIdentifier = aElementNames[i]; - if ( m_xModuleManager->getByName( aModuleIdentifier ) >>= aSeq ) + if ( xModuleManager->getByName( aModuleIdentifier ) >>= aSeq ) { OUString aWindowStateFileStr; for ( sal_Int32 y = 0; y < aSeq.getLength(); y++ ) @@ -1354,7 +1378,7 @@ WindowStateConfiguration::WindowStateConfiguration( const Reference< XComponentC WindowStateConfiguration::~WindowStateConfiguration() { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); m_aModuleToFileHashMap.clear(); m_aModuleToWindowStateHashMap.clear(); } @@ -1362,7 +1386,7 @@ WindowStateConfiguration::~WindowStateConfiguration() Any SAL_CALL WindowStateConfiguration::getByName( const OUString& aModuleIdentifier ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); ModuleToWindowStateFileMap::const_iterator pIter = m_aModuleToFileHashMap.find( aModuleIdentifier ); if ( pIter != m_aModuleToFileHashMap.end() ) @@ -1394,7 +1418,7 @@ throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::la Sequence< OUString > SAL_CALL WindowStateConfiguration::getElementNames() throw (::com::sun::star::uno::RuntimeException) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); Sequence< OUString > aSeq( m_aModuleToFileHashMap.size() ); @@ -1412,7 +1436,7 @@ throw (::com::sun::star::uno::RuntimeException) sal_Bool SAL_CALL WindowStateConfiguration::hasByName( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); ModuleToWindowStateFileMap::const_iterator pIter = m_aModuleToFileHashMap.find( aName ); return ( pIter != m_aModuleToFileHashMap.end() ); @@ -1432,6 +1456,31 @@ throw (::com::sun::star::uno::RuntimeException) return sal_True; } -} // namespace framework +struct Instance { + explicit Instance( + css::uno::Reference<css::uno::XComponentContext> const & context): + instance(static_cast<cppu::OWeakObject *>( + new WindowStateConfiguration(context))) + { + } + + css::uno::Reference<css::uno::XInterface> instance; +}; + +struct Singleton: + public rtl::StaticWithArg< + Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton> +{}; + +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_comp_framework_WindowStateConfiguration_get_implementation( + css::uno::XComponentContext *context, + css::uno::Sequence<css::uno::Any> const &) +{ + return cppu::acquire(static_cast<cppu::OWeakObject *>( + Singleton::get(context).instance.get())); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx b/framework/source/uielement/toolbarsmenucontroller.cxx index 9553572cf291..2e2f633dc391 100644 --- a/framework/source/uielement/toolbarsmenucontroller.cxx +++ b/framework/source/uielement/toolbarsmenucontroller.cxx @@ -25,9 +25,9 @@ #include "services.h" #include <classes/resource.hrc> #include <classes/fwkresid.hxx> -#include <uiconfiguration/windowstateconfiguration.hxx> #include <framework/imageproducer.hxx> #include <framework/sfxhelperfunctions.hxx> +#include <uiconfiguration/windowstateproperties.hxx> #include <com/sun/star/awt/XDevice.hpp> #include <com/sun/star/beans/PropertyValue.hpp> diff --git a/framework/util/fwk.component b/framework/util/fwk.component index 494886648ad9..0db78c8c73de 100644 --- a/framework/util/fwk.component +++ b/framework/util/fwk.component @@ -167,7 +167,8 @@ <service name="com.sun.star.ui.WindowContentFactoryManager"/> <singleton name="com.sun.star.ui.theWindowContentFactoryManager"/> </implementation> - <implementation name="com.sun.star.comp.framework.WindowStateConfiguration"> + <implementation name="com.sun.star.comp.framework.WindowStateConfiguration" + constructor="com_sun_star_comp_framework_WindowStateConfiguration_get_implementation"> <service name="com.sun.star.ui.WindowStateConfiguration"/> <singleton name="com.sun.star.ui.theWindowStateConfiguration"/> </implementation> |