From 94c78bed2887089fdfb0c36f5b68b9c98bfd5a72 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Fri, 10 Jul 2009 14:03:42 +0200 Subject: #i103452#: replace PRODUCT by !DBG_UTIL; replace assert by OSL_ASSERT where possible --- framework/source/helper/titlehelper.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'framework') diff --git a/framework/source/helper/titlehelper.cxx b/framework/source/helper/titlehelper.cxx index 291ed4f00633..ce5be87dc911 100644 --- a/framework/source/helper/titlehelper.cxx +++ b/framework/source/helper/titlehelper.cxx @@ -616,7 +616,7 @@ void TitleHelper::impl_appendModuleName (::rtl::OUStringBuffer& sTitle) } //***************************************************************************************************************** -#ifndef PRODUCT +#ifdef DBG_UTIL void TitleHelper::impl_appendDebugVersion (::rtl::OUStringBuffer& sTitle) { ::rtl::OUString sDefault ; -- cgit From 36a931bd7ffca530cd91c51326d9f021b5319bc6 Mon Sep 17 00:00:00 2001 From: Vladimir Glazounov Date: Fri, 2 Oct 2009 11:10:40 +0000 Subject: CWS-TOOLING: integrate CWS fwk118 2009-09-22 17:19:38 +0200 cd r276361 : #i105263# GetFileTypeIndex() uses a 1 based index 2009-09-22 11:10:29 +0200 cd r276351 : #i105154# Fix bad element exists exception for ui configuration --- framework/source/uiconfiguration/uiconfigurationmanagerimpl.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'framework') diff --git a/framework/source/uiconfiguration/uiconfigurationmanagerimpl.cxx b/framework/source/uiconfiguration/uiconfigurationmanagerimpl.cxx index 9b2284c0c6b8..5b67b13d8805 100755 --- a/framework/source/uiconfiguration/uiconfigurationmanagerimpl.cxx +++ b/framework/source/uiconfiguration/uiconfigurationmanagerimpl.cxx @@ -1281,7 +1281,7 @@ throw ( ElementExistException, IllegalArgumentException, IllegalAccessException, bInsertData = true; } } - if ( !pDataSettings ) + if ( !pDataSettings || bInsertData ) { aUIElementData.bDefault = false; if ( !m_bUseDefault ) -- cgit From bff284e216792b8d2a4e498beaba806eeddf844a Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Tue, 6 Oct 2009 07:38:24 +0200 Subject: #103496#: move VCL free ConfigItems to unotools --- framework/inc/dispatch/basedispatcher.hxx | 2 +- framework/inc/helper/persistentwindowstate.hxx | 2 +- framework/inc/helper/titlebarupdate.hxx | 2 +- framework/inc/pch/precompiled_framework.hxx | 12 ++++++------ framework/inc/services/desktop.hxx | 2 +- framework/inc/services/frame.hxx | 2 +- framework/inc/services/pluginframe.hxx | 2 +- framework/source/classes/bmkmenu.cxx | 2 +- framework/source/classes/menumanager.cxx | 4 ++-- framework/source/dispatch/closedispatcher.cxx | 2 +- framework/source/dispatch/startmoduledispatcher.cxx | 2 +- framework/source/layoutmanager/layoutmanager.cxx | 2 +- framework/source/loadenv/loadenv.cxx | 2 +- framework/source/services/autorecovery.cxx | 2 +- framework/source/services/backingwindow.cxx | 2 +- framework/source/services/backingwindow.hxx | 2 +- framework/source/services/frame.cxx | 2 +- framework/source/services/sessionlistener.cxx | 4 ++-- framework/source/uielement/menubarmanager.cxx | 6 +++--- framework/source/uielement/newmenucontroller.cxx | 2 +- framework/source/uielement/recentfilesmenucontroller.cxx | 2 +- framework/source/uielement/toolbarmanager.cxx | 4 ++-- framework/source/uielement/toolbarsmenucontroller.cxx | 2 +- 23 files changed, 33 insertions(+), 33 deletions(-) (limited to 'framework') diff --git a/framework/inc/dispatch/basedispatcher.hxx b/framework/inc/dispatch/basedispatcher.hxx index 595f45bfc79a..a62ec3e47890 100644 --- a/framework/inc/dispatch/basedispatcher.hxx +++ b/framework/inc/dispatch/basedispatcher.hxx @@ -70,7 +70,7 @@ #include #include /*DRAFT -#include +#include */ //_________________________________________________________________________________________________________________ diff --git a/framework/inc/helper/persistentwindowstate.hxx b/framework/inc/helper/persistentwindowstate.hxx index 22ef1a481ab7..55d356c80806 100644 --- a/framework/inc/helper/persistentwindowstate.hxx +++ b/framework/inc/helper/persistentwindowstate.hxx @@ -53,7 +53,7 @@ //_________________________________________________________________________________________________________________ // other includes //_________________________________________________________________________________________________________________ -#include +#include #include //_________________________________________________________________________________________________________________ diff --git a/framework/inc/helper/titlebarupdate.hxx b/framework/inc/helper/titlebarupdate.hxx index aa893cd40a57..255229d8e2eb 100644 --- a/framework/inc/helper/titlebarupdate.hxx +++ b/framework/inc/helper/titlebarupdate.hxx @@ -93,7 +93,7 @@ //_________________________________________________________________________________________________________________ #ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX -#include +#include #endif #ifndef _CPPUHELPER_WEAK_HXX_ diff --git a/framework/inc/pch/precompiled_framework.hxx b/framework/inc/pch/precompiled_framework.hxx index eaffedbc0e5c..5d1d1141244b 100644 --- a/framework/inc/pch/precompiled_framework.hxx +++ b/framework/inc/pch/precompiled_framework.hxx @@ -380,23 +380,23 @@ #include "sot/storage.hxx" #include "svtools/acceleratorexecute.hxx" -#include "svtools/cmdoptions.hxx" +#include "unotools/cmdoptions.hxx" #include "svtools/colorcfg.hxx" #include "svtools/ctrltool.hxx" -#include "svtools/dynamicmenuoptions.hxx" +#include "unotools/dynamicmenuoptions.hxx" #include "svtools/filter.hxx" #include "svtools/framestatuslistener.hxx" #include "svtools/helpopt.hxx" -#include "svtools/historyoptions.hxx" +#include "unotools/historyoptions.hxx" #include "svtools/imageitm.hxx" #include "svtools/imgdef.hxx" #include "svtools/inettype.hxx" -#include "svtools/internaloptions.hxx" +#include "unotools/internaloptions.hxx" #include "svtools/lstner.hxx" #include "svtools/menuoptions.hxx" #include "svtools/miscopt.hxx" -#include "svtools/moduleoptions.hxx" -#include "svtools/pathoptions.hxx" +#include "unotools/moduleoptions.hxx" +#include "unotools/pathoptions.hxx" #include "svtools/sfxecode.hxx" #include "svtools/smplhint.hxx" #include "svtools/solar.hrc" diff --git a/framework/inc/services/desktop.hxx b/framework/inc/services/desktop.hxx index 92c575c7b5b5..c1e1e59dc02f 100644 --- a/framework/inc/services/desktop.hxx +++ b/framework/inc/services/desktop.hxx @@ -80,7 +80,7 @@ //_________________________________________________________________________________________________________________ // other includes //_________________________________________________________________________________________________________________ -#include +#include #include #include #include diff --git a/framework/inc/services/frame.hxx b/framework/inc/services/frame.hxx index 32e83aed1974..022bda1786bc 100644 --- a/framework/inc/services/frame.hxx +++ b/framework/inc/services/frame.hxx @@ -87,7 +87,7 @@ //_________________________________________________________________________________________________________________ // other includes //_________________________________________________________________________________________________________________ -#include +#include #include #include #include diff --git a/framework/inc/services/pluginframe.hxx b/framework/inc/services/pluginframe.hxx index 46a90015a56e..af81b51d04ac 100644 --- a/framework/inc/services/pluginframe.hxx +++ b/framework/inc/services/pluginframe.hxx @@ -57,7 +57,7 @@ #ifndef _VCL_ATOM_HXX #include #endif -#include +#include //_________________________________________________________________________________________________________________ diff --git a/framework/source/classes/bmkmenu.cxx b/framework/source/classes/bmkmenu.cxx index efa66b3a6140..44a023d3b70d 100644 --- a/framework/source/classes/bmkmenu.cxx +++ b/framework/source/classes/bmkmenu.cxx @@ -61,7 +61,7 @@ //_________________________________________________________________________________________________________________ #include #include -#include +#include #include #include diff --git a/framework/source/classes/menumanager.cxx b/framework/source/classes/menumanager.cxx index bb850b876e5c..588c59d8f323 100644 --- a/framework/source/classes/menumanager.cxx +++ b/framework/source/classes/menumanager.cxx @@ -66,8 +66,8 @@ #include #include -#include -#include +#include +#include #include #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ diff --git a/framework/source/dispatch/closedispatcher.cxx b/framework/source/dispatch/closedispatcher.cxx index 25b80650e81a..d1ac0c0e044e 100644 --- a/framework/source/dispatch/closedispatcher.cxx +++ b/framework/source/dispatch/closedispatcher.cxx @@ -58,7 +58,7 @@ #include #include #include -#include +#include //_______________________________________________ // namespace diff --git a/framework/source/dispatch/startmoduledispatcher.cxx b/framework/source/dispatch/startmoduledispatcher.cxx index 80f02236065f..9326181c6476 100644 --- a/framework/source/dispatch/startmoduledispatcher.cxx +++ b/framework/source/dispatch/startmoduledispatcher.cxx @@ -60,7 +60,7 @@ #include #include #include -#include +#include //_______________________________________________ // namespace diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index fb10e4fae24c..0887433692b9 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -105,7 +105,7 @@ #include #include #include -#include +#include #include #include diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index 0af8ea0e6587..3bf20e9f6590 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -106,7 +106,7 @@ #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include #endif -#include +#include #include #include #include diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx index 9328ed9d9a5c..2137e1a22ddd 100644 --- a/framework/source/services/autorecovery.cxx +++ b/framework/source/services/autorecovery.cxx @@ -80,7 +80,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/framework/source/services/backingwindow.cxx b/framework/source/services/backingwindow.cxx index 40e4a9f7a6b9..509b37d09529 100644 --- a/framework/source/services/backingwindow.cxx +++ b/framework/source/services/backingwindow.cxx @@ -43,7 +43,7 @@ #include "tools/urlobj.hxx" -#include "svtools/dynamicmenuoptions.hxx" +#include "unotools/dynamicmenuoptions.hxx" #include "svtools/imagemgr.hxx" #include "svtools/svtools.hrc" diff --git a/framework/source/services/backingwindow.hxx b/framework/source/services/backingwindow.hxx index 63cfa0742e35..794fbdcc8a1a 100644 --- a/framework/source/services/backingwindow.hxx +++ b/framework/source/services/backingwindow.hxx @@ -38,7 +38,7 @@ #include "vcl/bitmapex.hxx" #include "vcl/toolbox.hxx" -#include "svtools/moduleoptions.hxx" +#include "unotools/moduleoptions.hxx" #include "svtools/acceleratorexecute.hxx" #include "com/sun/star/frame/XDispatchProvider.hpp" diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx index 0e14404de381..2b615240b594 100644 --- a/framework/source/services/frame.cxx +++ b/framework/source/services/frame.cxx @@ -106,7 +106,7 @@ #endif #include #include -#include +#include #ifdef ENABLE_ASSERTIONS #ifndef _RTL_STRBUF_HXX_ diff --git a/framework/source/services/sessionlistener.cxx b/framework/source/services/sessionlistener.cxx index ad0016fc0af6..81338c1cdbbf 100644 --- a/framework/source/services/sessionlistener.cxx +++ b/framework/source/services/sessionlistener.cxx @@ -66,8 +66,8 @@ #include #include #include -#include -#include +#include +#include #include //_______________________________________________ // interface includes diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 4c20b96f00dc..0b26f96829d2 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -82,9 +82,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx index 37580f86f546..d4e5228c6b9c 100644 --- a/framework/source/uielement/newmenucontroller.cxx +++ b/framework/source/uielement/newmenucontroller.cxx @@ -68,7 +68,7 @@ #include #include #include -#include +#include #include //_________________________________________________________________________________________________________________ diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx index 1ca5bf409e6d..9c5ed617b9e0 100644 --- a/framework/source/uielement/recentfilesmenucontroller.cxx +++ b/framework/source/uielement/recentfilesmenucontroller.cxx @@ -62,7 +62,7 @@ #include #include #include -#include +#include #include #include //#include diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 55c8d16af2ec..6be7dc73b4c2 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -85,7 +85,7 @@ //_________________________________________________________________________________________________________________ #include #include -#include +#include #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include #endif @@ -99,7 +99,7 @@ #include #include #include -#include +#include #include //_________________________________________________________________________________________________________________ diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx b/framework/source/uielement/toolbarsmenucontroller.cxx index 3b359eea97c2..a697eaeff3b7 100644 --- a/framework/source/uielement/toolbarsmenucontroller.cxx +++ b/framework/source/uielement/toolbarsmenucontroller.cxx @@ -80,7 +80,7 @@ #endif #include #include -#include +#include #include #include -- cgit From 0b6688eb4333f23e5925fa818c6a405f69ca0224 Mon Sep 17 00:00:00 2001 From: Kurt Zenker Date: Wed, 14 Oct 2009 18:01:12 +0000 Subject: CWS-TOOLING: integrate CWS fwk124_DEV300 2009-10-12 10:48:43 +0200 cd r276822 : #i105764# Remove wrong if-clause which disables the main function of the job service implementation --- framework/source/jobs/job.cxx | 2 -- 1 file changed, 2 deletions(-) (limited to 'framework') diff --git a/framework/source/jobs/job.cxx b/framework/source/jobs/job.cxx index 40d36f9a65f8..c0c5c90d45b3 100644 --- a/framework/source/jobs/job.cxx +++ b/framework/source/jobs/job.cxx @@ -51,7 +51,6 @@ // includes of other projects #include #include -#include //________________________________ // namespace @@ -238,7 +237,6 @@ void Job::execute( /*IN*/ const css::uno::Sequence< css::beans::NamedValue >& lD // Otherwhise we might die by ref count ... css::uno::Reference< css::task::XJobListener > xThis(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY); - if ( ::comphelper::UiEventsLogger::isEnabled() ) try { // create the job -- cgit From 130da5cbf25fb3991c6f27f8afe51e3ca5943657 Mon Sep 17 00:00:00 2001 From: Kurt Zenker Date: Thu, 15 Oct 2009 11:39:37 +0000 Subject: CWS-TOOLING: integrate CWS fwk122 2009-10-06 09:16:04 +0200 mav r276693 : #i10000# let be compiled on all platforms 2009-10-05 17:02:17 +0200 cd r276688 : #i105343# Fix build problems under Linux/Mac 2009-10-05 16:23:29 +0200 cd r276687 : #i105489# Remove uiconfigurationmanagerimpl.obj from makefile.mk 2009-10-05 15:17:05 +0200 cd r276680 : #i105326# Fix crash when opening file with notes 2009-10-05 11:02:22 +0200 mav r276665 : #i105343# allow the view shell to disconnect from listener 2009-10-02 11:33:45 +0200 cd r276619 : #i105489# Revert changes done to aggregate sources due to too much regressions --- .../moduleuiconfigurationmanager.hxx | 92 +- .../inc/uiconfiguration/uiconfigurationmanager.hxx | 81 +- framework/source/uiconfiguration/makefile.mk | 1 - .../moduleuiconfigurationmanager.cxx | 1428 +++++++++++++++++++- .../uiconfiguration/uiconfigurationmanager.cxx | 1157 +++++++++++++++- .../uiconfiguration/uiconfigurationmanagerimpl.cxx | 8 +- framework/util/makefile.mk | 1 - 7 files changed, 2681 insertions(+), 87 deletions(-) (limited to 'framework') diff --git a/framework/inc/uiconfiguration/moduleuiconfigurationmanager.hxx b/framework/inc/uiconfiguration/moduleuiconfigurationmanager.hxx index 62c0477a5169..a0dc92ae50d3 100644 --- a/framework/inc/uiconfiguration/moduleuiconfigurationmanager.hxx +++ b/framework/inc/uiconfiguration/moduleuiconfigurationmanager.hxx @@ -38,7 +38,6 @@ #include #include #include -#include //_________________________________________________________________________________________________________________ // my own includes @@ -78,7 +77,6 @@ namespace framework { - class UIConfigurationManagerImpl; class ModuleUIConfigurationManager : public com::sun::star::lang::XTypeProvider , public com::sun::star::lang::XServiceInfo , public com::sun::star::lang::XComponent , @@ -87,6 +85,7 @@ namespace framework public ::com::sun::star::ui::XUIConfigurationManager , public ::com::sun::star::ui::XModuleUIConfigurationManager , public ::com::sun::star::ui::XUIConfigurationPersistence , + private ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses. public ::cppu::OWeakObject { public: @@ -135,7 +134,94 @@ namespace framework virtual sal_Bool SAL_CALL isReadOnly() throw (::com::sun::star::uno::RuntimeException); private: - ::std::auto_ptr m_pImpl; + // private data types + enum Layer + { + LAYER_DEFAULT, + LAYER_USERDEFINED, + LAYER_COUNT + }; + + enum NotifyOp + { + NotifyOp_Remove, + NotifyOp_Insert, + NotifyOp_Replace + }; + + struct UIElementInfo + { + UIElementInfo( const rtl::OUString& rResourceURL, const rtl::OUString& rUIName ) : + aResourceURL( rResourceURL), aUIName( rUIName ) {} + rtl::OUString aResourceURL; + rtl::OUString aUIName; + }; + + struct UIElementData + { + UIElementData() : bModified( false ), bDefault( true ), bDefaultNode( true ) {}; + + rtl::OUString aResourceURL; + rtl::OUString aName; + bool bModified; // has been changed since last storing + bool bDefault; // default settings + bool bDefaultNode; // this is a default layer element data + com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > xSettings; + }; + + struct UIElementType; + friend struct UIElementType; + typedef ::std::hash_map< rtl::OUString, UIElementData, OUStringHashCode, ::std::equal_to< rtl::OUString > > UIElementDataHashMap; + + struct UIElementType + { + UIElementType() : bModified( false ), + bLoaded( false ), + bDefaultLayer( false ), + nElementType( ::com::sun::star::ui::UIElementType::UNKNOWN ) {} + + + bool bModified; + bool bLoaded; + bool bDefaultLayer; + sal_Int16 nElementType; + UIElementDataHashMap aElementsHashMap; + com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage; + }; + + typedef ::std::vector< UIElementType > UIElementTypesVector; + typedef ::std::vector< ::com::sun::star::ui::ConfigurationEvent > ConfigEventNotifyContainer; + typedef ::std::hash_map< rtl::OUString, UIElementInfo, OUStringHashCode, ::std::equal_to< rtl::OUString > > UIElementInfoHashMap; + + // private methods + void impl_Initialize(); + void implts_notifyContainerListener( const ::com::sun::star::ui::ConfigurationEvent& aEvent, NotifyOp eOp ); + void impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap& aUIElementInfoCollection, sal_Int16 nElementType ); + void impl_preloadUIElementTypeList( Layer eLayer, sal_Int16 nElementType ); + UIElementData* impl_findUIElementData( const rtl::OUString& aResourceURL, sal_Int16 nElementType, bool bLoad = true ); + void impl_requestUIElementData( sal_Int16 nElementType, Layer eLayer, UIElementData& aUIElementData ); + void impl_storeElementTypeData( com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage, UIElementType& rElementType, bool bResetModifyState = true ); + void impl_resetElementTypeData( UIElementType& rUserElementType, UIElementType& rDefaultElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer, ConfigEventNotifyContainer& rReplaceNotifyContainer ); + void impl_reloadElementTypeData( UIElementType& rUserElementType, UIElementType& rDefaultElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer, ConfigEventNotifyContainer& rReplaceNotifyContainer ); + + UIElementTypesVector m_aUIElements[LAYER_COUNT]; + PresetHandler* m_pStorageHandler[::com::sun::star::ui::UIElementType::COUNT]; + com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xDefaultConfigStorage; + com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xUserConfigStorage; + bool m_bReadOnly; + bool m_bInitialized; + bool m_bModified; + bool m_bConfigRead; + bool m_bDisposed; + rtl::OUString m_aXMLPostfix; + rtl::OUString m_aPropUIName; + rtl::OUString m_aPropResourceURL; + rtl::OUString m_aModuleIdentifier; + rtl::OUString m_aModuleShortName; + com::sun::star::uno::Reference< com::sun::star::embed::XTransactedObject > m_xUserRootCommit; + com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; + ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener + com::sun::star::uno::Reference< com::sun::star::lang::XComponent > m_xModuleImageManager; }; } diff --git a/framework/inc/uiconfiguration/uiconfigurationmanager.hxx b/framework/inc/uiconfiguration/uiconfigurationmanager.hxx index 39f1d9503513..e7ecec183570 100644 --- a/framework/inc/uiconfiguration/uiconfigurationmanager.hxx +++ b/framework/inc/uiconfiguration/uiconfigurationmanager.hxx @@ -38,7 +38,6 @@ #include #include #include -#include //_________________________________________________________________________________________________________________ // my own includes @@ -78,7 +77,6 @@ namespace framework { - class UIConfigurationManagerImpl; class UIConfigurationManager : public com::sun::star::lang::XTypeProvider , public com::sun::star::lang::XServiceInfo , public com::sun::star::lang::XComponent , @@ -86,6 +84,7 @@ namespace framework public ::com::sun::star::ui::XUIConfigurationManager , public ::com::sun::star::ui::XUIConfigurationPersistence , public ::com::sun::star::ui::XUIConfigurationStorage , + private ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses. public ::cppu::OWeakObject { public: @@ -131,7 +130,83 @@ namespace framework virtual sal_Bool SAL_CALL hasStorage() throw (::com::sun::star::uno::RuntimeException); private: - ::std::auto_ptr m_pImpl; + // private data types + enum NotifyOp + { + NotifyOp_Remove, + NotifyOp_Insert, + NotifyOp_Replace + }; + + struct UIElementInfo + { + UIElementInfo( const rtl::OUString& rResourceURL, const rtl::OUString& rUIName ) : + aResourceURL( rResourceURL), aUIName( rUIName ) {} + rtl::OUString aResourceURL; + rtl::OUString aUIName; + }; + + struct UIElementData + { + UIElementData() : bModified( false ), bDefault( true ) {}; + + rtl::OUString aResourceURL; + rtl::OUString aName; + bool bModified; // has been changed since last storing + bool bDefault; // default settings + com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > xSettings; + }; + + struct UIElementType; + friend struct UIElementType; + typedef ::std::hash_map< rtl::OUString, UIElementData, OUStringHashCode, ::std::equal_to< rtl::OUString > > UIElementDataHashMap; + + struct UIElementType + { + UIElementType() : bModified( false ), + bLoaded( false ), + bDefaultLayer( false ), + nElementType( ::com::sun::star::ui::UIElementType::UNKNOWN ) {} + + + bool bModified; + bool bLoaded; + bool bDefaultLayer; + sal_Int16 nElementType; + UIElementDataHashMap aElementsHashMap; + com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage; + }; + + typedef ::std::vector< UIElementType > UIElementTypesVector; + typedef ::std::vector< ::com::sun::star::ui::ConfigurationEvent > ConfigEventNotifyContainer; + typedef ::std::hash_map< rtl::OUString, UIElementInfo, OUStringHashCode, ::std::equal_to< rtl::OUString > > UIElementInfoHashMap; + + // private methods + void impl_Initialize(); + void implts_notifyContainerListener( const ::com::sun::star::ui::ConfigurationEvent& aEvent, NotifyOp eOp ); + void impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap& aUIElementInfoCollection, sal_Int16 nElementType ); + void impl_preloadUIElementTypeList( sal_Int16 nElementType ); + UIElementData* impl_findUIElementData( const rtl::OUString& aResourceURL, sal_Int16 nElementType, bool bLoad = true ); + void impl_requestUIElementData( sal_Int16 nElementType, UIElementData& aUIElementData ); + void impl_storeElementTypeData( com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& xStorage, UIElementType& rElementType, bool bResetModifyState = true ); + void impl_resetElementTypeData( UIElementType& rDocElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer ); + void impl_reloadElementTypeData( UIElementType& rDocElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer, ConfigEventNotifyContainer& rReplaceNotifyContainer ); + + UIElementTypesVector m_aUIElements; + com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xDocConfigStorage; + bool m_bReadOnly; + bool m_bInitialized; + bool m_bModified; + bool m_bConfigRead; + bool m_bDisposed; + rtl::OUString m_aXMLPostfix; + rtl::OUString m_aPropUIName; + rtl::OUString m_aPropResourceURL; + rtl::OUString m_aModuleIdentifier; + com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; + ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener + com::sun::star::uno::Reference< com::sun::star::lang::XComponent > m_xImageManager; + com::sun::star::uno::Reference< com::sun::star::uno::XInterface > m_xAccConfig; }; } diff --git a/framework/source/uiconfiguration/makefile.mk b/framework/source/uiconfiguration/makefile.mk index c7d6eb435d4f..3ef9006072a2 100644 --- a/framework/source/uiconfiguration/makefile.mk +++ b/framework/source/uiconfiguration/makefile.mk @@ -43,7 +43,6 @@ ENABLE_EXCEPTIONS= TRUE SLOFILES= \ $(SLO)$/uiconfigurationmanager.obj \ - $(SLO)$/uiconfigurationmanagerimpl.obj \ $(SLO)$/moduleuiconfigurationmanager.obj \ $(SLO)$/moduleuicfgsupplier.obj \ $(SLO)$/windowstateconfiguration.obj \ diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx index 04c87a2c3946..663c2d0d6dd8 100644 --- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx +++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx @@ -38,7 +38,6 @@ #include #include #include -#include #ifndef __FRAMEWORK_XML_STATUSBARCONFIGURATION_HXX_ #include @@ -114,127 +113,1292 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( ModuleUIConfigurationManager DEFINE_INIT_SERVICE ( ModuleUIConfigurationManager, {} ) -ModuleUIConfigurationManager::ModuleUIConfigurationManager( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager ) -: m_pImpl( new UIConfigurationManagerImpl(xServiceManager,static_cast< OWeakObject* >(this),true) ) +// important: The order and position of the elements must match the constant +// definition of "::com::sun::star::ui::UIElementType" +static const char* UIELEMENTTYPENAMES[] = { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::ModuleUIConfigurationManager" ); + "", // Dummy value for unknown! + UIELEMENTTYPE_MENUBAR_NAME, + UIELEMENTTYPE_POPUPMENU_NAME, + UIELEMENTTYPE_TOOLBAR_NAME, + UIELEMENTTYPE_STATUSBAR_NAME, + UIELEMENTTYPE_FLOATINGWINDOW_NAME, + UIELEMENTTYPE_PROGRESSBAR_NAME +}; + +static const char RESOURCEURL_PREFIX[] = "private:resource/"; +static const sal_Int32 RESOURCEURL_PREFIX_SIZE = 17; +static const char RESOURCEURL_CUSTOM_ELEMENT[] = "custom_"; + +static sal_Int16 RetrieveTypeFromResourceURL( const rtl::OUString& aResourceURL ) +{ + + if (( aResourceURL.indexOf( OUString( RTL_CONSTASCII_USTRINGPARAM( RESOURCEURL_PREFIX ))) == 0 ) && + ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE )) + { + OUString aTmpStr = aResourceURL.copy( RESOURCEURL_PREFIX_SIZE ); + sal_Int32 nIndex = aTmpStr.indexOf( '/' ); + if (( nIndex > 0 ) && ( aTmpStr.getLength() > nIndex )) + { + OUString aTypeStr( aTmpStr.copy( 0, nIndex )); + for ( int i = 0; i < UIElementType::COUNT; i++ ) + { + if ( aTypeStr.equalsAscii( UIELEMENTTYPENAMES[i] )) + return sal_Int16( i ); + } + } + } + + return UIElementType::UNKNOWN; +} + +static OUString RetrieveNameFromResourceURL( const rtl::OUString& aResourceURL ) +{ + if (( aResourceURL.indexOf( OUString( RTL_CONSTASCII_USTRINGPARAM( RESOURCEURL_PREFIX ))) == 0 ) && + ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE )) + { + sal_Int32 nIndex = aResourceURL.lastIndexOf( '/' ); + if (( nIndex > 0 ) && (( nIndex+1 ) < aResourceURL.getLength())) + return aResourceURL.copy( nIndex+1 ); + } + + return OUString(); +} + +void ModuleUIConfigurationManager::impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap& aUIElementInfoCollection, sal_Int16 nElementType ) +{ + // preload list of element types on demand + impl_preloadUIElementTypeList( LAYER_USERDEFINED, nElementType ); + impl_preloadUIElementTypeList( LAYER_DEFAULT, nElementType ); + + UIElementDataHashMap& rUserElements = m_aUIElements[LAYER_USERDEFINED][nElementType].aElementsHashMap; + UIElementDataHashMap::const_iterator pUserIter = rUserElements.begin(); + + OUString aCustomUrlPrefix( RTL_CONSTASCII_USTRINGPARAM( RESOURCEURL_CUSTOM_ELEMENT )); + while ( pUserIter != rUserElements.end() ) + { + sal_Int32 nIndex = pUserIter->second.aResourceURL.indexOf( aCustomUrlPrefix, RESOURCEURL_PREFIX_SIZE ); + if ( nIndex > RESOURCEURL_PREFIX_SIZE ) + { + // Performance: Retrieve user interface name only for custom user interface elements. + // It's only used by them! + UIElementData* pDataSettings = impl_findUIElementData( pUserIter->second.aResourceURL, nElementType ); + if ( pDataSettings ) + { + // Retrieve user interface name from XPropertySet interface + rtl::OUString aUIName; + Reference< XPropertySet > xPropSet( pDataSettings->xSettings, UNO_QUERY ); + if ( xPropSet.is() ) + { + Any a = xPropSet->getPropertyValue( m_aPropUIName ); + a >>= aUIName; + } + + UIElementInfo aInfo( pUserIter->second.aResourceURL, aUIName ); + aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pUserIter->second.aResourceURL, aInfo )); + } + } + else + { + // The user interface name for standard user interface elements is stored in the WindowState.xcu file + UIElementInfo aInfo( pUserIter->second.aResourceURL, OUString() ); + aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pUserIter->second.aResourceURL, aInfo )); + } + ++pUserIter; + } + + UIElementDataHashMap& rDefaultElements = m_aUIElements[LAYER_DEFAULT][nElementType].aElementsHashMap; + UIElementDataHashMap::const_iterator pDefIter = rDefaultElements.begin(); + + while ( pDefIter != rDefaultElements.end() ) + { + UIElementInfoHashMap::const_iterator pIterInfo = aUIElementInfoCollection.find( pDefIter->second.aResourceURL ); + if ( pIterInfo == aUIElementInfoCollection.end() ) + { + sal_Int32 nIndex = pDefIter->second.aResourceURL.indexOf( aCustomUrlPrefix, RESOURCEURL_PREFIX_SIZE ); + if ( nIndex > RESOURCEURL_PREFIX_SIZE ) + { + // Performance: Retrieve user interface name only for custom user interface elements. + // It's only used by them! + UIElementData* pDataSettings = impl_findUIElementData( pDefIter->second.aResourceURL, nElementType ); + if ( pDataSettings ) + { + // Retrieve user interface name from XPropertySet interface + rtl::OUString aUIName; + Reference< XPropertySet > xPropSet( pDataSettings->xSettings, UNO_QUERY ); + if ( xPropSet.is() ) + { + Any a = xPropSet->getPropertyValue( m_aPropUIName ); + a >>= aUIName; + } + + UIElementInfo aInfo( pDefIter->second.aResourceURL, aUIName ); + aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pDefIter->second.aResourceURL, aInfo )); + } + } + else + { + // The user interface name for standard user interface elements is stored in the WindowState.xcu file + UIElementInfo aInfo( pDefIter->second.aResourceURL, OUString() ); + aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pDefIter->second.aResourceURL, aInfo )); + } + } + + ++pDefIter; + } +} + +void ModuleUIConfigurationManager::impl_preloadUIElementTypeList( Layer eLayer, sal_Int16 nElementType ) +{ + UIElementType& rElementTypeData = m_aUIElements[eLayer][nElementType]; + + if ( !rElementTypeData.bLoaded ) + { + Reference< XStorage > xElementTypeStorage = rElementTypeData.xStorage; + if ( xElementTypeStorage.is() ) + { + rtl::OUStringBuffer aBuf( RESOURCEURL_PREFIX_SIZE ); + aBuf.appendAscii( RESOURCEURL_PREFIX ); + aBuf.appendAscii( UIELEMENTTYPENAMES[ nElementType ] ); + aBuf.appendAscii( "/" ); + OUString aResURLPrefix( aBuf.makeStringAndClear() ); + + UIElementDataHashMap& rHashMap = rElementTypeData.aElementsHashMap; + Reference< XNameAccess > xNameAccess( xElementTypeStorage, UNO_QUERY ); + Sequence< OUString > aUIElementNames = xNameAccess->getElementNames(); + for ( sal_Int32 n = 0; n < aUIElementNames.getLength(); n++ ) + { + UIElementData aUIElementData; + + // Resource name must be without ".xml" + sal_Int32 nIndex = aUIElementNames[n].lastIndexOf( '.' ); + if (( nIndex > 0 ) && ( nIndex < aUIElementNames[n].getLength() )) + { + OUString aExtension( aUIElementNames[n].copy( nIndex+1 )); + OUString aUIElementName( aUIElementNames[n].copy( 0, nIndex )); + + if (( aUIElementName.getLength() > 0 ) && + ( aExtension.equalsIgnoreAsciiCaseAsciiL( "xml", 3 ))) + { + aUIElementData.aResourceURL = aResURLPrefix + aUIElementName; + aUIElementData.aName = aUIElementNames[n]; + + if ( eLayer == LAYER_USERDEFINED ) + { + aUIElementData.bModified = false; + aUIElementData.bDefault = false; + aUIElementData.bDefaultNode = false; + } + + // Create hash_map entries for all user interface elements inside the storage. We don't load the + // settings to speed up the process. + rHashMap.insert( UIElementDataHashMap::value_type( aUIElementData.aResourceURL, aUIElementData )); + } + } + } + } + } + + rElementTypeData.bLoaded = true; +} + +void ModuleUIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType, Layer eLayer, UIElementData& aUIElementData ) +{ + UIElementType& rElementTypeData = m_aUIElements[eLayer][nElementType]; + + Reference< XStorage > xElementTypeStorage = rElementTypeData.xStorage; + if ( xElementTypeStorage.is() && aUIElementData.aName.getLength() ) + { + try + { + Reference< XStream > xStream = xElementTypeStorage->openStreamElement( aUIElementData.aName, ElementModes::READ ); + Reference< XInputStream > xInputStream = xStream->getInputStream(); + + if ( xInputStream.is() ) + { + switch ( nElementType ) + { + case ::com::sun::star::ui::UIElementType::UNKNOWN: + break; + + case ::com::sun::star::ui::UIElementType::MENUBAR: + { + try + { + MenuConfiguration aMenuCfg( m_xServiceManager ); + Reference< XIndexAccess > xContainer( aMenuCfg.CreateMenuBarConfigurationFromXML( xInputStream )); + RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xContainer ); + if ( pRootItemContainer ) + aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY ); + else + aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( xContainer, sal_True ) ), UNO_QUERY ); + return; + } + catch ( ::com::sun::star::lang::WrappedTargetException& ) + { + } + } + break; + + case ::com::sun::star::ui::UIElementType::POPUPMENU: + { + break; + } + + case ::com::sun::star::ui::UIElementType::TOOLBAR: + { + try + { + Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY ); + ToolBoxConfiguration::LoadToolBox( m_xServiceManager, xInputStream, xIndexContainer ); + RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xIndexContainer ); + aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY ); + return; + } + catch ( ::com::sun::star::lang::WrappedTargetException& ) + { + } + + break; + } + + case ::com::sun::star::ui::UIElementType::STATUSBAR: + { + try + { + Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY ); + StatusBarConfiguration::LoadStatusBar( m_xServiceManager, xInputStream, xIndexContainer ); + RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xIndexContainer ); + aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY ); + return; + } + catch ( ::com::sun::star::lang::WrappedTargetException& ) + { + } + + break; + } + + case ::com::sun::star::ui::UIElementType::FLOATINGWINDOW: + { + break; + } + } + } + } + catch ( ::com::sun::star::embed::InvalidStorageException& ) + { + } + catch ( ::com::sun::star::lang::IllegalArgumentException& ) + { + } + catch ( ::com::sun::star::io::IOException& ) + { + } + catch ( ::com::sun::star::embed::StorageWrappedTargetException& ) + { + } + } + + // At least we provide an empty settings container! + aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer() ), UNO_QUERY ); +} + +ModuleUIConfigurationManager::UIElementData* ModuleUIConfigurationManager::impl_findUIElementData( const rtl::OUString& aResourceURL, sal_Int16 nElementType, bool bLoad ) +{ + // preload list of element types on demand + impl_preloadUIElementTypeList( LAYER_USERDEFINED, nElementType ); + impl_preloadUIElementTypeList( LAYER_DEFAULT, nElementType ); + + // first try to look into our user-defined vector/hash_map combination + UIElementDataHashMap& rUserHashMap = m_aUIElements[LAYER_USERDEFINED][nElementType].aElementsHashMap; + UIElementDataHashMap::iterator pIter = rUserHashMap.find( aResourceURL ); + if ( pIter != rUserHashMap.end() ) + { + // Default data settings data must be retrieved from the default layer! + if ( !pIter->second.bDefault ) + { + if ( !pIter->second.xSettings.is() && bLoad ) + impl_requestUIElementData( nElementType, LAYER_USERDEFINED, pIter->second ); + return &(pIter->second); + } + } + + // Not successfull, we have to look into our default vector/hash_map combination + UIElementDataHashMap& rDefaultHashMap = m_aUIElements[LAYER_DEFAULT][nElementType].aElementsHashMap; + pIter = rDefaultHashMap.find( aResourceURL ); + if ( pIter != rDefaultHashMap.end() ) + { + if ( !pIter->second.xSettings.is() && bLoad ) + impl_requestUIElementData( nElementType, LAYER_DEFAULT, pIter->second ); + return &(pIter->second); + } + + // Nothing has been found! + return NULL; +} + +void ModuleUIConfigurationManager::impl_storeElementTypeData( Reference< XStorage > xStorage, UIElementType& rElementType, bool bResetModifyState ) +{ + UIElementDataHashMap& rHashMap = rElementType.aElementsHashMap; + UIElementDataHashMap::iterator pIter = rHashMap.begin(); + + while ( pIter != rHashMap.end() ) + { + UIElementData& rElement = pIter->second; + if ( rElement.bModified ) + { + if ( rElement.bDefault ) + { + xStorage->removeElement( rElement.aName ); + rElement.bModified = sal_False; // mark as not modified + } + else + { + Reference< XStream > xStream( xStorage->openStreamElement( rElement.aName, ElementModes::WRITE|ElementModes::TRUNCATE ), UNO_QUERY ); + Reference< XOutputStream > xOutputStream( xStream->getOutputStream() ); + + if ( xOutputStream.is() ) + { + switch( rElementType.nElementType ) + { + case ::com::sun::star::ui::UIElementType::MENUBAR: + { + try + { + MenuConfiguration aMenuCfg( m_xServiceManager ); + aMenuCfg.StoreMenuBarConfigurationToXML( rElement.xSettings, xOutputStream ); + } + catch ( ::com::sun::star::lang::WrappedTargetException& ) + { + } + } + break; + + case ::com::sun::star::ui::UIElementType::TOOLBAR: + { + try + { + ToolBoxConfiguration::StoreToolBox( m_xServiceManager, xOutputStream, rElement.xSettings ); + } + catch ( ::com::sun::star::lang::WrappedTargetException& ) + { + } + } + break; + + case ::com::sun::star::ui::UIElementType::STATUSBAR: + { + try + { + StatusBarConfiguration::StoreStatusBar( m_xServiceManager, xOutputStream, rElement.xSettings ); + } + catch ( ::com::sun::star::lang::WrappedTargetException& ) + { + } + } + break; + + default: + break; + } + } + + // mark as not modified if we store to our own storage + if ( bResetModifyState ) + rElement.bModified = sal_False; + } + } + + ++pIter; + } + + // commit element type storage + Reference< XTransactedObject > xTransactedObject( xStorage, UNO_QUERY ); + if ( xTransactedObject.is() ) + xTransactedObject->commit(); + + // mark UIElementType as not modified if we store to our own storage + if ( bResetModifyState ) + rElementType.bModified = sal_False; +} + +// This is only allowed to be called on the LAYER_USER_DEFINED! +void ModuleUIConfigurationManager::impl_resetElementTypeData( + UIElementType& rUserElementType, + UIElementType& rDefaultElementType, + ConfigEventNotifyContainer& rRemoveNotifyContainer, + ConfigEventNotifyContainer& rReplaceNotifyContainer ) +{ + UIElementDataHashMap& rHashMap = rUserElementType.aElementsHashMap; + UIElementDataHashMap::iterator pIter = rHashMap.begin(); + + Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + Reference< XInterface > xIfac( xThis, UNO_QUERY ); + Reference< XNameAccess > xDefaultNameAccess( rDefaultElementType.xStorage, UNO_QUERY ); + sal_Int16 nType = rUserElementType.nElementType; + + // Make copies of the event structures to be thread-safe. We have to unlock our mutex before calling + // our listeners! + while ( pIter != rHashMap.end() ) + { + UIElementData& rElement = pIter->second; + if ( !rElement.bDefault ) + { + if ( xDefaultNameAccess->hasByName( rElement.aName )) + { + // Replace settings with data from default layer + Reference< XIndexAccess > xOldSettings( rElement.xSettings ); + impl_requestUIElementData( nType, LAYER_DEFAULT, rElement ); + + ConfigurationEvent aReplaceEvent; + aReplaceEvent.ResourceURL = rElement.aResourceURL; + aReplaceEvent.Accessor <<= xThis; + aReplaceEvent.Source = xIfac; + aReplaceEvent.ReplacedElement <<= xOldSettings; + aReplaceEvent.Element <<= rElement.xSettings; + + rReplaceNotifyContainer.push_back( aReplaceEvent ); + + // Mark element as default and not modified. That means "not active" + // in the user layer anymore. + rElement.bModified = false; + rElement.bDefault = true; + } + else + { + // Remove user-defined settings from user layer + ConfigurationEvent aEvent; + aEvent.ResourceURL = rElement.aResourceURL; + aEvent.Accessor <<= xThis; + aEvent.Source = xIfac; + aEvent.Element <<= rElement.xSettings; + + rRemoveNotifyContainer.push_back( aEvent ); + + // Mark element as default and not modified. That means "not active" + // in the user layer anymore. + rElement.bModified = false; + rElement.bDefault = true; + } + } + + ++pIter; + } + + // Remove all settings from our user interface elements + rHashMap.clear(); +} + +void ModuleUIConfigurationManager::impl_reloadElementTypeData( + UIElementType& rUserElementType, + UIElementType& rDefaultElementType, + ConfigEventNotifyContainer& rRemoveNotifyContainer, + ConfigEventNotifyContainer& rReplaceNotifyContainer ) +{ + UIElementDataHashMap& rHashMap = rUserElementType.aElementsHashMap; + UIElementDataHashMap::iterator pIter = rHashMap.begin(); + Reference< XStorage > xUserStorage( rUserElementType.xStorage ); + Reference< XStorage > xDefaultStorage( rDefaultElementType.xStorage ); + Reference< XNameAccess > xUserNameAccess( rUserElementType.xStorage, UNO_QUERY ); + Reference< XNameAccess > xDefaultNameAccess( rDefaultElementType.xStorage, UNO_QUERY ); + + Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + Reference< XInterface > xIfac( xThis, UNO_QUERY ); + sal_Int16 nType = rUserElementType.nElementType; + + while ( pIter != rHashMap.end() ) + { + UIElementData& rElement = pIter->second; + if ( rElement.bModified ) + { + if ( xUserNameAccess->hasByName( rElement.aName )) + { + // Replace settings with data from user layer + Reference< XIndexAccess > xOldSettings( rElement.xSettings ); + + impl_requestUIElementData( nType, LAYER_USERDEFINED, rElement ); + + ConfigurationEvent aReplaceEvent; + + aReplaceEvent.ResourceURL = rElement.aResourceURL; + aReplaceEvent.Accessor <<= xThis; + aReplaceEvent.Source = xIfac; + aReplaceEvent.ReplacedElement <<= xOldSettings; + aReplaceEvent.Element <<= rElement.xSettings; + rReplaceNotifyContainer.push_back( aReplaceEvent ); + + rElement.bModified = false; + } + else if ( xDefaultNameAccess->hasByName( rElement.aName )) + { + // Replace settings with data from default layer + Reference< XIndexAccess > xOldSettings( rElement.xSettings ); + + impl_requestUIElementData( nType, LAYER_DEFAULT, rElement ); + + ConfigurationEvent aReplaceEvent; + + aReplaceEvent.ResourceURL = rElement.aResourceURL; + aReplaceEvent.Accessor <<= xThis; + aReplaceEvent.Source = xIfac; + aReplaceEvent.ReplacedElement <<= xOldSettings; + aReplaceEvent.Element <<= rElement.xSettings; + rReplaceNotifyContainer.push_back( aReplaceEvent ); + + // Mark element as default and not modified. That means "not active" + // in the user layer anymore. + rElement.bModified = false; + rElement.bDefault = true; + } + else + { + // Element settings are not in any storage => remove + ConfigurationEvent aRemoveEvent; + + aRemoveEvent.ResourceURL = rElement.aResourceURL; + aRemoveEvent.Accessor <<= xThis; + aRemoveEvent.Source = xIfac; + aRemoveEvent.Element <<= rElement.xSettings; + + rRemoveNotifyContainer.push_back( aRemoveEvent ); + + // Mark element as default and not modified. That means "not active" + // in the user layer anymore. + rElement.bModified = false; + rElement.bDefault = true; + } + } + ++pIter; + } + + rUserElementType.bModified = sal_False; +} + +void ModuleUIConfigurationManager::impl_Initialize() +{ + // Initialize the top-level structures with the storage data + if ( m_xUserConfigStorage.is() ) + { + // Try to access our module sub folder + for ( sal_Int16 i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; + i++ ) + { + Reference< XStorage > xElementTypeStorage; + try + { + if ( m_pStorageHandler[i] ) + xElementTypeStorage = m_pStorageHandler[i]->getWorkingStorageUser(); + } + catch ( com::sun::star::container::NoSuchElementException& ) + { + } + catch ( ::com::sun::star::embed::InvalidStorageException& ) + { + } + catch ( ::com::sun::star::lang::IllegalArgumentException& ) + { + } + catch ( ::com::sun::star::io::IOException& ) + { + } + catch ( ::com::sun::star::embed::StorageWrappedTargetException& ) + { + } + + m_aUIElements[LAYER_USERDEFINED][i].nElementType = i; + m_aUIElements[LAYER_USERDEFINED][i].bModified = false; + m_aUIElements[LAYER_USERDEFINED][i].xStorage = xElementTypeStorage; + m_aUIElements[LAYER_USERDEFINED][i].bDefaultLayer = false; + } + } + + if ( m_xDefaultConfigStorage.is() ) + { + Reference< XNameAccess > xNameAccess( m_xDefaultConfigStorage, UNO_QUERY_THROW ); + + // Try to access our module sub folder + for ( sal_Int16 i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; + i++ ) + { + Reference< XStorage > xElementTypeStorage; + try + { + Any a = xNameAccess->getByName( OUString::createFromAscii( UIELEMENTTYPENAMES[i] )); + a >>= xElementTypeStorage; + } + catch ( com::sun::star::container::NoSuchElementException& ) + { + } + + m_aUIElements[LAYER_DEFAULT][i].nElementType = i; + m_aUIElements[LAYER_DEFAULT][i].bModified = false; + m_aUIElements[LAYER_DEFAULT][i].xStorage = xElementTypeStorage; + m_aUIElements[LAYER_DEFAULT][i].bDefaultLayer = true; + } + } +} + +ModuleUIConfigurationManager::ModuleUIConfigurationManager( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager ) : + ThreadHelpBase( &Application::GetSolarMutex() ) + , m_xDefaultConfigStorage( 0 ) + , m_xUserConfigStorage( 0 ) + , m_bReadOnly( true ) + , m_bInitialized( false ) + , m_bModified( false ) + , m_bConfigRead( false ) + , m_bDisposed( false ) + , m_aXMLPostfix( RTL_CONSTASCII_USTRINGPARAM( ".xml" )) + , m_aPropUIName( RTL_CONSTASCII_USTRINGPARAM( "UIName" )) + , m_aPropResourceURL( RTL_CONSTASCII_USTRINGPARAM( "ResourceURL" )) + , m_xServiceManager( xServiceManager ) + , m_aListenerContainer( m_aLock.getShareableOslMutex() ) +{ + for ( int i = 0; i < ::com::sun::star::ui::UIElementType::COUNT; i++ ) + m_pStorageHandler[i] = 0; + + // Make sure we have a default initialized entry for every layer and user interface element type! + // The following code depends on this! + m_aUIElements[LAYER_DEFAULT].resize( ::com::sun::star::ui::UIElementType::COUNT ); + m_aUIElements[LAYER_USERDEFINED].resize( ::com::sun::star::ui::UIElementType::COUNT ); } ModuleUIConfigurationManager::~ModuleUIConfigurationManager() { + for ( int i = 0; i < ::com::sun::star::ui::UIElementType::COUNT; i++ ) + delete m_pStorageHandler[i]; } // XComponent void SAL_CALL ModuleUIConfigurationManager::dispose() throw (::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::dispose" ); - m_pImpl->dispose(); + Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY ); + + css::lang::EventObject aEvent( xThis ); + m_aListenerContainer.disposeAndClear( aEvent ); + + { + ResetableGuard aGuard( m_aLock ); + try + { + if ( m_xModuleImageManager.is() ) + m_xModuleImageManager->dispose(); + } + catch ( Exception& ) + { + } + + m_xModuleImageManager.clear(); + m_aUIElements[LAYER_USERDEFINED].clear(); + m_aUIElements[LAYER_DEFAULT].clear(); + m_xDefaultConfigStorage.clear(); + m_xUserConfigStorage.clear(); + m_xUserRootCommit.clear(); + m_bConfigRead = false; + m_bModified = false; + m_bDisposed = true; + } } void SAL_CALL ModuleUIConfigurationManager::addEventListener( const Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::addEventListener" ); - m_pImpl->addEventListener(xListener); + { + ResetableGuard aGuard( m_aLock ); + + /* SAFE AREA ----------------------------------------------------------------------------------------------- */ + if ( m_bDisposed ) + throw DisposedException(); + } + + m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener ); } void SAL_CALL ModuleUIConfigurationManager::removeEventListener( const Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::removeEventListener" ); - m_pImpl->removeEventListener(xListener); + /* SAFE AREA ----------------------------------------------------------------------------------------------- */ + m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener ); } // XInitialization void SAL_CALL ModuleUIConfigurationManager::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::initialize" ); - m_pImpl->initialize(aArguments); + ResetableGuard aLock( m_aLock ); + + if ( !m_bInitialized ) + { + ::comphelper::SequenceAsHashMap lArgs(aArguments); + m_aModuleIdentifier = lArgs.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("ModuleIdentifier"), ::rtl::OUString()); + m_aModuleShortName = lArgs.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("ModuleShortName"), ::rtl::OUString()); + + for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ ) + { + rtl::OUString aResourceType; + if ( i == ::com::sun::star::ui::UIElementType::MENUBAR ) + aResourceType = PresetHandler::RESOURCETYPE_MENUBAR(); + else if ( i == ::com::sun::star::ui::UIElementType::TOOLBAR ) + aResourceType = PresetHandler::RESOURCETYPE_TOOLBAR(); + else if ( i == ::com::sun::star::ui::UIElementType::STATUSBAR ) + aResourceType = PresetHandler::RESOURCETYPE_STATUSBAR(); + + if ( aResourceType.getLength() > 0 ) + { + m_pStorageHandler[i] = new PresetHandler( m_xServiceManager ); + m_pStorageHandler[i]->connectToResource( PresetHandler::E_MODULES, + aResourceType, // this path wont be used later ... seee next lines! + m_aModuleShortName, + css::uno::Reference< css::embed::XStorage >()); // no document root used here! + } + } + + // initialize root storages for all resource types + m_xUserRootCommit = css::uno::Reference< css::embed::XTransactedObject >( + m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getOrCreateRootStorageUser(), css::uno::UNO_QUERY); // can be empty + m_xDefaultConfigStorage = m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getParentStorageShare( + m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getWorkingStorageShare()); + m_xUserConfigStorage = m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getParentStorageUser( + m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getWorkingStorageUser()); + + if ( m_xUserConfigStorage.is() ) + { + Reference< XPropertySet > xPropSet( m_xUserConfigStorage, UNO_QUERY ); + if ( xPropSet.is() ) + { + long nOpenMode = 0; + Any a = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenMode" ))); + if ( a >>= nOpenMode ) + m_bReadOnly = !( nOpenMode & ElementModes::WRITE ); + } + } + + impl_Initialize(); + + m_bInitialized = true; + } } // XUIConfiguration void SAL_CALL ModuleUIConfigurationManager::addConfigurationListener( const Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::addConfigurationListener" ); - m_pImpl->addConfigurationListener(xListener); + { + ResetableGuard aGuard( m_aLock ); + + /* SAFE AREA ----------------------------------------------------------------------------------------------- */ + if ( m_bDisposed ) + throw DisposedException(); + } + + m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XUIConfigurationListener >* ) NULL ), xListener ); } void SAL_CALL ModuleUIConfigurationManager::removeConfigurationListener( const Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::removeConfigurationListener" ); - m_pImpl->removeConfigurationListener(xListener); + /* SAFE AREA ----------------------------------------------------------------------------------------------- */ + m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XUIConfigurationListener >* ) NULL ), xListener ); } // XUIConfigurationManager void SAL_CALL ModuleUIConfigurationManager::reset() throw (::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::reset" ); - m_pImpl->reset(); + ResetableGuard aGuard( m_aLock ); + + /* SAFE AREA ----------------------------------------------------------------------------------------------- */ + if ( m_bDisposed ) + throw DisposedException(); + + bool bResetStorage( false ); + + if ( !isReadOnly() ) + { + // Remove all elements from our user-defined storage! + try + { + for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ ) + { + UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][i]; + Reference< XStorage > xSubStorage( rElementType.xStorage, UNO_QUERY ); + + if ( xSubStorage.is() ) + { + bool bCommitSubStorage( false ); + Reference< XNameAccess > xSubStorageNameAccess( xSubStorage, UNO_QUERY ); + Sequence< OUString > aUIElementStreamNames = xSubStorageNameAccess->getElementNames(); + for ( sal_Int32 j = 0; j < aUIElementStreamNames.getLength(); j++ ) + { + xSubStorage->removeElement( aUIElementStreamNames[j] ); + bCommitSubStorage = true; + } + + if ( bCommitSubStorage ) + { + Reference< XTransactedObject > xTransactedObject( xSubStorage, UNO_QUERY ); + if ( xTransactedObject.is() ) + xTransactedObject->commit(); + m_pStorageHandler[i]->commitUserChanges(); + } + } + } + + bResetStorage = true; + + // remove settings from user defined layer and notify listener about removed settings data! + ConfigEventNotifyContainer aRemoveEventNotifyContainer; + ConfigEventNotifyContainer aReplaceEventNotifyContainer; + for ( sal_Int16 j = 1; j < ::com::sun::star::ui::UIElementType::COUNT; j++ ) + { + try + { + UIElementType& rUserElementType = m_aUIElements[LAYER_USERDEFINED][j]; + UIElementType& rDefaultElementType = m_aUIElements[LAYER_DEFAULT][j]; + + impl_resetElementTypeData( rUserElementType, rDefaultElementType, aRemoveEventNotifyContainer, aReplaceEventNotifyContainer ); + rUserElementType.bModified = sal_False; + } + catch ( Exception& ) + { + throw IOException(); + } + } + + m_bModified = sal_False; + + // Unlock mutex before notify our listeners + aGuard.unlock(); + + // Notify our listeners + sal_uInt32 k = 0; + for ( k = 0; k < aRemoveEventNotifyContainer.size(); k++ ) + implts_notifyContainerListener( aRemoveEventNotifyContainer[k], NotifyOp_Remove ); + for ( k = 0; k < aReplaceEventNotifyContainer.size(); k++ ) + implts_notifyContainerListener( aReplaceEventNotifyContainer[k], NotifyOp_Replace ); + } + catch ( ::com::sun::star::lang::IllegalArgumentException& ) + { + } + catch ( ::com::sun::star::container::NoSuchElementException& ) + { + } + catch ( ::com::sun::star::embed::InvalidStorageException& ) + { + } + catch ( ::com::sun::star::embed::StorageWrappedTargetException& ) + { + } + } } Sequence< Sequence< PropertyValue > > SAL_CALL ModuleUIConfigurationManager::getUIElementsInfo( sal_Int16 ElementType ) throw ( IllegalArgumentException, RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::getUIElementsInfo" ); - return m_pImpl->getUIElementsInfo(ElementType); + if (( ElementType < 0 ) || ( ElementType >= ::com::sun::star::ui::UIElementType::COUNT )) + throw IllegalArgumentException(); + + ResetableGuard aGuard( m_aLock ); + if ( m_bDisposed ) + throw DisposedException(); + + Sequence< Sequence< PropertyValue > > aElementInfoSeq; + UIElementInfoHashMap aUIElementInfoCollection; + + if ( ElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) + { + for ( sal_Int16 i = 0; i < ::com::sun::star::ui::UIElementType::COUNT; i++ ) + impl_fillSequenceWithElementTypeInfo( aUIElementInfoCollection, sal_Int16( i ) ); + } + else + impl_fillSequenceWithElementTypeInfo( aUIElementInfoCollection, ElementType ); + + Sequence< PropertyValue > aUIElementInfo( 2 ); + aUIElementInfo[0].Name = m_aPropResourceURL; + aUIElementInfo[1].Name = m_aPropUIName; + + aElementInfoSeq.realloc( aUIElementInfoCollection.size() ); + UIElementInfoHashMap::const_iterator pIter = aUIElementInfoCollection.begin(); + + sal_Int32 n = 0; + while ( pIter != aUIElementInfoCollection.end() ) + { + aUIElementInfo[0].Value <<= pIter->second.aResourceURL; + aUIElementInfo[1].Value <<= pIter->second.aUIName; + aElementInfoSeq[n++] = aUIElementInfo; + ++pIter; + } + + return aElementInfoSeq; } Reference< XIndexContainer > SAL_CALL ModuleUIConfigurationManager::createSettings() throw (::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::createSettings" ); + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); // Creates an empty item container which can be filled from outside - return m_pImpl->createSettings(); + return Reference< XIndexContainer >( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY ); } sal_Bool SAL_CALL ModuleUIConfigurationManager::hasSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::hasSettings" ); - return m_pImpl->hasSettings(ResourceURL); + sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL ); + + if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) || + ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT )) + throw IllegalArgumentException(); + else + { + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType, false ); + if ( pDataSettings ) + return sal_True; + } + + return sal_False; } Reference< XIndexAccess > SAL_CALL ModuleUIConfigurationManager::getSettings( const ::rtl::OUString& ResourceURL, sal_Bool bWriteable ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::getSettings" ); - return m_pImpl->getSettings(ResourceURL,bWriteable); + sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL ); + + if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) || + ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT )) + throw IllegalArgumentException(); + else + { + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType ); + if ( pDataSettings ) + { + // Create a copy of our data if someone wants to change the data. + if ( bWriteable ) + return Reference< XIndexAccess >( static_cast< OWeakObject * >( new RootItemContainer( pDataSettings->xSettings ) ), UNO_QUERY ); + else + return pDataSettings->xSettings; + } + } + + throw NoSuchElementException(); } void SAL_CALL ModuleUIConfigurationManager::replaceSettings( const ::rtl::OUString& ResourceURL, const Reference< ::com::sun::star::container::XIndexAccess >& aNewData ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::replaceSettings" ); - return m_pImpl->replaceSettings(ResourceURL,aNewData); + sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL ); + + if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) || + ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT )) + throw IllegalArgumentException(); + else if ( m_bReadOnly ) + throw IllegalAccessException(); + else + { + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType ); + if ( pDataSettings ) + { + if ( !pDataSettings->bDefaultNode ) + { + // we have a settings entry in our user-defined layer - replace + Reference< XIndexAccess > xOldSettings = pDataSettings->xSettings; + + // Create a copy of the data if the container is not const + Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY ); + if ( xReplace.is() ) + pDataSettings->xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY ); + else + pDataSettings->xSettings = aNewData; + pDataSettings->bDefault = false; + pDataSettings->bModified = true; + m_bModified = true; + + // Modify type container + UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType]; + rElementType.bModified = true; + + Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + + // Create event to notify listener about replaced element settings + ConfigurationEvent aEvent; + Reference< XInterface > xIfac( xThis, UNO_QUERY ); + + aEvent.ResourceURL = ResourceURL; + aEvent.Accessor <<= xThis; + aEvent.Source = xIfac; + aEvent.ReplacedElement <<= xOldSettings; + aEvent.Element <<= pDataSettings->xSettings; + + aGuard.unlock(); + + implts_notifyContainerListener( aEvent, NotifyOp_Replace ); + } + else + { + // we have no settings in our user-defined layer - insert + UIElementData aUIElementData; + + aUIElementData.bDefault = false; + aUIElementData.bDefaultNode = false; + aUIElementData.bModified = true; + + // Create a copy of the data if the container is not const + Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY ); + if ( xReplace.is() ) + aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY ); + else + aUIElementData.xSettings = aNewData; + aUIElementData.aName = RetrieveNameFromResourceURL( ResourceURL ) + m_aXMLPostfix; + aUIElementData.aResourceURL = ResourceURL; + m_bModified = true; + + // Modify type container + UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType]; + rElementType.bModified = true; + + UIElementDataHashMap& rElements = rElementType.aElementsHashMap; + + // Check our user element settings hash map as it can already contain settings that have been set to default! + // If no node can be found, we have to insert it. + UIElementDataHashMap::iterator pIter = rElements.find( ResourceURL ); + if ( pIter != rElements.end() ) + pIter->second = aUIElementData; + else + rElements.insert( UIElementDataHashMap::value_type( ResourceURL, aUIElementData )); + + Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + Reference< XInterface > xIfac( xThis, UNO_QUERY ); + + // Create event to notify listener about replaced element settings + ConfigurationEvent aEvent; + + aEvent.ResourceURL = ResourceURL; + aEvent.Accessor <<= xThis; + aEvent.Source = xIfac; + aEvent.ReplacedElement <<= pDataSettings->xSettings; + aEvent.Element <<= aUIElementData.xSettings; + + aGuard.unlock(); + + implts_notifyContainerListener( aEvent, NotifyOp_Replace ); + } + } + else + throw NoSuchElementException(); + } } void SAL_CALL ModuleUIConfigurationManager::removeSettings( const ::rtl::OUString& ResourceURL ) throw ( NoSuchElementException, IllegalArgumentException, IllegalAccessException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::removeSettings" ); - m_pImpl->removeSettings(ResourceURL); + sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL ); + + if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) || + ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT )) + throw IllegalArgumentException(); + else if ( m_bReadOnly ) + throw IllegalAccessException(); + else + { + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType ); + if ( pDataSettings ) + { + // If element settings are default, we don't need to change anything! + if ( pDataSettings->bDefault ) + return; + else + { + Reference< XIndexAccess > xRemovedSettings = pDataSettings->xSettings; + pDataSettings->bDefault = true; + + // check if this is a default layer node + if ( !pDataSettings->bDefaultNode ) + pDataSettings->bModified = true; // we have to remove this node from the user layer! + pDataSettings->xSettings.clear(); + m_bModified = true; // user layer must be written + + // Modify type container + UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType]; + rElementType.bModified = true; + + Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + Reference< XInterface > xIfac( xThis, UNO_QUERY ); + + // Check if we have settings in the default layer which replaces the user-defined one! + UIElementData* pDefaultDataSettings = impl_findUIElementData( ResourceURL, nElementType ); + if ( pDefaultDataSettings ) + { + // Create event to notify listener about replaced element settings + ConfigurationEvent aEvent; + + aEvent.ResourceURL = ResourceURL; + aEvent.Accessor <<= xThis; + aEvent.Source = xIfac; + aEvent.Element <<= xRemovedSettings; + aEvent.ReplacedElement <<= pDefaultDataSettings->xSettings; + + aGuard.unlock(); + + implts_notifyContainerListener( aEvent, NotifyOp_Replace ); + } + else + { + // Create event to notify listener about removed element settings + ConfigurationEvent aEvent; + + aEvent.ResourceURL = ResourceURL; + aEvent.Accessor <<= xThis; + aEvent.Source = xIfac; + aEvent.Element <<= xRemovedSettings; + + aGuard.unlock(); + + implts_notifyContainerListener( aEvent, NotifyOp_Remove ); + } + } + } + else + throw NoSuchElementException(); + } } void SAL_CALL ModuleUIConfigurationManager::insertSettings( const ::rtl::OUString& NewResourceURL, const Reference< XIndexAccess >& aNewData ) throw ( ElementExistException, IllegalArgumentException, IllegalAccessException, RuntimeException ) { - m_pImpl->insertSettings(NewResourceURL,aNewData); + sal_Int16 nElementType = RetrieveTypeFromResourceURL( NewResourceURL ); + + if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) || + ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT )) + throw IllegalArgumentException(); + else if ( m_bReadOnly ) + throw IllegalAccessException(); + else + { + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + UIElementData* pDataSettings = impl_findUIElementData( NewResourceURL, nElementType ); + if ( !pDataSettings ) + { + UIElementData aUIElementData; + + aUIElementData.bDefault = false; + aUIElementData.bDefaultNode = false; + aUIElementData.bModified = true; + + // Create a copy of the data if the container is not const + Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY ); + if ( xReplace.is() ) + aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY ); + else + aUIElementData.xSettings = aNewData; + aUIElementData.aName = RetrieveNameFromResourceURL( NewResourceURL ) + m_aXMLPostfix; + aUIElementData.aResourceURL = NewResourceURL; + m_bModified = true; + + UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType]; + rElementType.bModified = true; + + UIElementDataHashMap& rElements = rElementType.aElementsHashMap; + rElements.insert( UIElementDataHashMap::value_type( NewResourceURL, aUIElementData )); + + Reference< XIndexAccess > xInsertSettings( aUIElementData.xSettings ); + Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + Reference< XInterface > xIfac( xThis, UNO_QUERY ); + + // Create event to notify listener about removed element settings + ConfigurationEvent aEvent; + + aEvent.ResourceURL = NewResourceURL; + aEvent.Accessor <<= xThis; + aEvent.Source = xIfac; + aEvent.Element <<= xInsertSettings; + + aGuard.unlock(); + + implts_notifyContainerListener( aEvent, NotifyOp_Insert ); + } + else + throw ElementExistException(); + } } Reference< XInterface > SAL_CALL ModuleUIConfigurationManager::getImageManager() throw (::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::getImageManager" ); - return m_pImpl->getImageManager(); + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + if ( !m_xModuleImageManager.is() ) + { + m_xModuleImageManager = Reference< XComponent >( static_cast< cppu::OWeakObject *>( new ModuleImageManager( m_xServiceManager )), + UNO_QUERY ); + Reference< XInitialization > xInit( m_xModuleImageManager, UNO_QUERY ); + + Sequence< Any > aPropSeq( 3 ); + PropertyValue aPropValue; + aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UserConfigStorage" )); + aPropValue.Value = makeAny( m_xUserConfigStorage ); + aPropSeq[0] = makeAny( aPropValue ); + aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModuleIdentifier" )); + aPropValue.Value = makeAny( m_aModuleIdentifier ); + aPropSeq[1] = makeAny( aPropValue ); + aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UserRootCommit" )); + aPropValue.Value = makeAny( m_xUserRootCommit ); + aPropSeq[2] = makeAny( aPropValue ); + + xInit->initialize( aPropSeq ); + } + + return Reference< XInterface >( m_xModuleImageManager, UNO_QUERY ); + +// return Reference< XInterface >(); } Reference< XInterface > SAL_CALL ModuleUIConfigurationManager::getShortCutManager() throw (::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::getShortCutManager" ); - return m_pImpl->getShortCutManager(); + ResetableGuard aGuard( m_aLock ); + Reference< XMultiServiceFactory > xSMGR = m_xServiceManager; + ::rtl::OUString aModule = /*m_aModuleShortName*/m_aModuleIdentifier; + aGuard.unlock(); + + Reference< XInterface > xManager = xSMGR->createInstance(SERVICENAME_MODULEACCELERATORCONFIGURATION); + Reference< XInitialization > xInit (xManager, UNO_QUERY_THROW); + + PropertyValue aProp; + aProp.Name = ::rtl::OUString::createFromAscii("ModuleIdentifier"); + aProp.Value <<= aModule; + + Sequence< Any > lArgs(1); + lArgs[0] <<= aProp; + + xInit->initialize(lArgs); + + return xManager; } Reference< XInterface > SAL_CALL ModuleUIConfigurationManager::getEventsManager() throw (::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::getEventsManager" ); return Reference< XInterface >(); } @@ -242,46 +1406,210 @@ Reference< XInterface > SAL_CALL ModuleUIConfigurationManager::getEventsManager( sal_Bool SAL_CALL ModuleUIConfigurationManager::isDefaultSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::isDefaultSettings" ); - return m_pImpl->isDefaultSettings(ResourceURL); + sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL ); + + if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) || + ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT )) + throw IllegalArgumentException(); + else + { + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType, false ); + if ( pDataSettings && pDataSettings->bDefaultNode ) + return sal_True; + } + + return sal_False; } Reference< XIndexAccess > SAL_CALL ModuleUIConfigurationManager::getDefaultSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::getDefaultSettings" ); - return m_pImpl->getDefaultSettings(ResourceURL); + sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL ); + + if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) || + ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT )) + throw IllegalArgumentException(); + else + { + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + // preload list of element types on demand + impl_preloadUIElementTypeList( LAYER_DEFAULT, nElementType ); + + // Look into our default vector/hash_map combination + UIElementDataHashMap& rDefaultHashMap = m_aUIElements[LAYER_DEFAULT][nElementType].aElementsHashMap; + UIElementDataHashMap::iterator pIter = rDefaultHashMap.find( ResourceURL ); + if ( pIter != rDefaultHashMap.end() ) + { + if ( !pIter->second.xSettings.is() ) + impl_requestUIElementData( nElementType, LAYER_DEFAULT, pIter->second ); + return pIter->second.xSettings; + } + } + + // Nothing has been found! + throw NoSuchElementException(); } // XUIConfigurationPersistence void SAL_CALL ModuleUIConfigurationManager::reload() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::reload" ); - m_pImpl->reload(); + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + if ( m_xUserConfigStorage.is() && m_bModified && !m_bReadOnly ) + { + // Try to access our module sub folder + ConfigEventNotifyContainer aRemoveNotifyContainer; + ConfigEventNotifyContainer aReplaceNotifyContainer; + for ( sal_Int16 i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ ) + { + try + { + UIElementType& rUserElementType = m_aUIElements[LAYER_USERDEFINED][i]; + UIElementType& rDefaultElementType = m_aUIElements[LAYER_DEFAULT][i]; + + if ( rUserElementType.bModified ) + impl_reloadElementTypeData( rUserElementType, rDefaultElementType, aRemoveNotifyContainer, aReplaceNotifyContainer ); + } + catch ( Exception& ) + { + throw IOException(); + } + } + + m_bModified = sal_False; + + // Unlock mutex before notify our listeners + aGuard.unlock(); + + // Notify our listeners + for ( sal_uInt32 j = 0; j < aRemoveNotifyContainer.size(); j++ ) + implts_notifyContainerListener( aRemoveNotifyContainer[j], NotifyOp_Remove ); + for ( sal_uInt32 k = 0; k < aReplaceNotifyContainer.size(); k++ ) + implts_notifyContainerListener( aReplaceNotifyContainer[k], NotifyOp_Replace ); + } } void SAL_CALL ModuleUIConfigurationManager::store() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::store" ); - m_pImpl->store(); + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + if ( m_xUserConfigStorage.is() && m_bModified && !m_bReadOnly ) + { + // Try to access our module sub folder + for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ ) + { + try + { + UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][i]; + Reference< XStorage > xStorage( rElementType.xStorage, UNO_QUERY ); + + if ( rElementType.bModified && xStorage.is() ) + { + impl_storeElementTypeData( xStorage, rElementType ); + m_pStorageHandler[i]->commitUserChanges(); + } + } + catch ( Exception& ) + { + throw IOException(); + } + } + + m_bModified = false; + } } void SAL_CALL ModuleUIConfigurationManager::storeToStorage( const Reference< XStorage >& Storage ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::storeToStorage" ); - m_pImpl->storeToStorage(Storage); + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + if ( m_xUserConfigStorage.is() && m_bModified && !m_bReadOnly ) + { + // Try to access our module sub folder + for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ ) + { + try + { + Reference< XStorage > xElementTypeStorage( Storage->openStorageElement( + OUString::createFromAscii( UIELEMENTTYPENAMES[i] ), ElementModes::READWRITE )); + UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][i]; + + if ( rElementType.bModified && xElementTypeStorage.is() ) + impl_storeElementTypeData( xElementTypeStorage, rElementType, false ); // store data to storage, but don't reset modify flag! + } + catch ( Exception& ) + { + throw IOException(); + } + } + + Reference< XTransactedObject > xTransactedObject( Storage, UNO_QUERY ); + if ( xTransactedObject.is() ) + xTransactedObject->commit(); + } } sal_Bool SAL_CALL ModuleUIConfigurationManager::isModified() throw (::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::isModified" ); - return m_pImpl->isModified(); + ResetableGuard aGuard( m_aLock ); + + return m_bModified; } sal_Bool SAL_CALL ModuleUIConfigurationManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleUIConfigurationManager::isReadOnly" ); - return m_pImpl->isReadOnly(); + ResetableGuard aGuard( m_aLock ); + + return m_bReadOnly; +} + +void ModuleUIConfigurationManager::implts_notifyContainerListener( const ConfigurationEvent& aEvent, NotifyOp eOp ) +{ + ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >*) NULL ) ); + if ( pContainer != NULL ) + { + ::cppu::OInterfaceIteratorHelper pIterator( *pContainer ); + while ( pIterator.hasMoreElements() ) + { + try + { + switch ( eOp ) + { + case NotifyOp_Replace: + ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementReplaced( aEvent ); + break; + case NotifyOp_Insert: + ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementInserted( aEvent ); + break; + case NotifyOp_Remove: + ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementRemoved( aEvent ); + break; + } + } + catch( css::uno::RuntimeException& ) + { + pIterator.remove(); + } + } + } } } // namespace framework diff --git a/framework/source/uiconfiguration/uiconfigurationmanager.cxx b/framework/source/uiconfiguration/uiconfigurationmanager.cxx index 67049d9eb4dc..3309333fb327 100644 --- a/framework/source/uiconfiguration/uiconfigurationmanager.cxx +++ b/framework/source/uiconfiguration/uiconfigurationmanager.cxx @@ -38,7 +38,6 @@ #include #include #include -#include #ifndef __FRAMEWORK_XML_STATUSBARCONFIGURATION_HXX_ #include @@ -111,9 +110,511 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( UIConfigurationManager DEFINE_INIT_SERVICE ( UIConfigurationManager, {} ) -UIConfigurationManager::UIConfigurationManager( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager ) -: m_pImpl( new UIConfigurationManagerImpl(xServiceManager,static_cast< OWeakObject* >(this),false) ) + +// important: The order and position of the elements must match the constant +// definition of "::com::sun::star::ui::UIElementType" +static const char* UIELEMENTTYPENAMES[] = +{ + "", // Dummy value for unknown! + UIELEMENTTYPE_MENUBAR_NAME, + UIELEMENTTYPE_POPUPMENU_NAME, + UIELEMENTTYPE_TOOLBAR_NAME, + UIELEMENTTYPE_STATUSBAR_NAME, + UIELEMENTTYPE_FLOATINGWINDOW_NAME, + UIELEMENTTYPE_PROGRESSBAR_NAME +}; + +static const char RESOURCEURL_PREFIX[] = "private:resource/"; +static const sal_Int32 RESOURCEURL_PREFIX_SIZE = 17; + +static sal_Int16 RetrieveTypeFromResourceURL( const rtl::OUString& aResourceURL ) +{ + + if (( aResourceURL.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( RESOURCEURL_PREFIX ))) == 0 ) && + ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE )) + { + rtl::OUString aTmpStr = aResourceURL.copy( RESOURCEURL_PREFIX_SIZE ); + sal_Int32 nIndex = aTmpStr.indexOf( '/' ); + if (( nIndex > 0 ) && ( aTmpStr.getLength() > nIndex )) + { + rtl::OUString aTypeStr( aTmpStr.copy( 0, nIndex )); + for ( int i = 0; i < UIElementType::COUNT; i++ ) + { + if ( aTypeStr.equalsAscii( UIELEMENTTYPENAMES[i] )) + return sal_Int16( i ); + } + } + } + + return UIElementType::UNKNOWN; +} + +static rtl::OUString RetrieveNameFromResourceURL( const rtl::OUString& aResourceURL ) +{ + if (( aResourceURL.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( RESOURCEURL_PREFIX ))) == 0 ) && + ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE )) + { + sal_Int32 nIndex = aResourceURL.lastIndexOf( '/' ); + if (( nIndex > 0 ) && (( nIndex+1 ) < aResourceURL.getLength())) + return aResourceURL.copy( nIndex+1 ); + } + + return rtl::OUString(); +} + +void UIConfigurationManager::impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap& aUIElementInfoCollection, sal_Int16 nElementType ) { + // preload list of element types on demand + impl_preloadUIElementTypeList( nElementType ); + + UIElementDataHashMap& rUserElements = m_aUIElements[nElementType].aElementsHashMap; + UIElementDataHashMap::const_iterator pUserIter = rUserElements.begin(); + + while ( pUserIter != rUserElements.end() ) + { + UIElementData* pDataSettings = impl_findUIElementData( pUserIter->second.aResourceURL, nElementType ); + if ( pDataSettings && !pDataSettings->bDefault ) + { + // Retrieve user interface name from XPropertySet interface + rtl::OUString aUIName; + Reference< XPropertySet > xPropSet( pDataSettings->xSettings, UNO_QUERY ); + if ( xPropSet.is() ) + { + Any a = xPropSet->getPropertyValue( m_aPropUIName ); + a >>= aUIName; + } + + UIElementInfo aInfo( pUserIter->second.aResourceURL, aUIName ); + aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pUserIter->second.aResourceURL, aInfo )); + } + ++pUserIter; + } +} + +void UIConfigurationManager::impl_preloadUIElementTypeList( sal_Int16 nElementType ) +{ + UIElementType& rElementTypeData = m_aUIElements[nElementType]; + + if ( !rElementTypeData.bLoaded ) + { + Reference< XStorage > xElementTypeStorage = rElementTypeData.xStorage; + if ( xElementTypeStorage.is() ) + { + rtl::OUStringBuffer aBuf( RESOURCEURL_PREFIX_SIZE ); + aBuf.appendAscii( RESOURCEURL_PREFIX ); + aBuf.appendAscii( UIELEMENTTYPENAMES[ nElementType ] ); + aBuf.appendAscii( "/" ); + rtl::OUString aResURLPrefix( aBuf.makeStringAndClear() ); + + UIElementDataHashMap& rHashMap = rElementTypeData.aElementsHashMap; + Reference< XNameAccess > xNameAccess( xElementTypeStorage, UNO_QUERY ); + Sequence< rtl::OUString > aUIElementNames = xNameAccess->getElementNames(); + for ( sal_Int32 n = 0; n < aUIElementNames.getLength(); n++ ) + { + UIElementData aUIElementData; + + // Resource name must be without ".xml" + sal_Int32 nIndex = aUIElementNames[n].lastIndexOf( '.' ); + if (( nIndex > 0 ) && ( nIndex < aUIElementNames[n].getLength() )) + { + rtl::OUString aExtension( aUIElementNames[n].copy( nIndex+1 )); + rtl::OUString aUIElementName( aUIElementNames[n].copy( 0, nIndex )); + + if (( aUIElementName.getLength() > 0 ) && + ( aExtension.equalsIgnoreAsciiCaseAsciiL( "xml", 3 ))) + { + aUIElementData.aResourceURL = aResURLPrefix + aUIElementName; + aUIElementData.aName = aUIElementNames[n]; + aUIElementData.bModified = false; + aUIElementData.bDefault = false; + + // Create hash_map entries for all user interface elements inside the storage. We don't load the + // settings to speed up the process. + rHashMap.insert( UIElementDataHashMap::value_type( aUIElementData.aResourceURL, aUIElementData )); + } + } + } + } + } + + rElementTypeData.bLoaded = true; +} + +void UIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType, UIElementData& aUIElementData ) +{ + UIElementType& rElementTypeData = m_aUIElements[nElementType]; + + Reference< XStorage > xElementTypeStorage = rElementTypeData.xStorage; + if ( xElementTypeStorage.is() && aUIElementData.aName.getLength() ) + { + try + { + Reference< XStream > xStream = xElementTypeStorage->openStreamElement( aUIElementData.aName, ElementModes::READ ); + Reference< XInputStream > xInputStream = xStream->getInputStream(); + + if ( xInputStream.is() ) + { + switch ( nElementType ) + { + case ::com::sun::star::ui::UIElementType::UNKNOWN: + break; + + case ::com::sun::star::ui::UIElementType::MENUBAR: + { + try + { + MenuConfiguration aMenuCfg( m_xServiceManager ); + Reference< XIndexAccess > xContainer( aMenuCfg.CreateMenuBarConfigurationFromXML( xInputStream )); + RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xContainer ); + if ( pRootItemContainer ) + aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY ); + else + aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( xContainer, sal_True ) ), UNO_QUERY ); + return; + } + catch ( ::com::sun::star::lang::WrappedTargetException& ) + { + } + } + break; + + case ::com::sun::star::ui::UIElementType::POPUPMENU: + { + break; + } + + case ::com::sun::star::ui::UIElementType::TOOLBAR: + { + try + { + Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY ); + ToolBoxConfiguration::LoadToolBox( m_xServiceManager, xInputStream, xIndexContainer ); + RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xIndexContainer ); + aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY ); + return; + } + catch ( ::com::sun::star::lang::WrappedTargetException& ) + { + } + + break; + } + + case ::com::sun::star::ui::UIElementType::STATUSBAR: + { + try + { + Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY ); + StatusBarConfiguration::LoadStatusBar( m_xServiceManager, xInputStream, xIndexContainer ); + RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xIndexContainer ); + aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY ); + return; + } + catch ( ::com::sun::star::lang::WrappedTargetException& ) + { + } + + break; + } + + case ::com::sun::star::ui::UIElementType::FLOATINGWINDOW: + { + break; + } + } + } + } + catch ( ::com::sun::star::embed::InvalidStorageException& ) + { + } + catch ( ::com::sun::star::lang::IllegalArgumentException& ) + { + } + catch ( ::com::sun::star::io::IOException& ) + { + } + catch ( ::com::sun::star::embed::StorageWrappedTargetException& ) + { + } + } + + // At least we provide an empty settings container! + aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer()), UNO_QUERY ); +} + +UIConfigurationManager::UIElementData* UIConfigurationManager::impl_findUIElementData( const rtl::OUString& aResourceURL, sal_Int16 nElementType, bool bLoad ) +{ + // preload list of element types on demand + impl_preloadUIElementTypeList( nElementType ); + + // try to look into our document vector/hash_map combination + UIElementDataHashMap& rUserHashMap = m_aUIElements[nElementType].aElementsHashMap; + UIElementDataHashMap::iterator pIter = rUserHashMap.find( aResourceURL ); + if ( pIter != rUserHashMap.end() ) + { + // Default data settings data means removed! + if ( pIter->second.bDefault ) + return &(pIter->second); + else + { + if ( !pIter->second.xSettings.is() && bLoad ) + impl_requestUIElementData( nElementType, pIter->second ); + return &(pIter->second); + } + } + + // Nothing has been found! + return NULL; +} + +void UIConfigurationManager::impl_storeElementTypeData( Reference< XStorage >& xStorage, UIElementType& rElementType, bool bResetModifyState ) +{ + UIElementDataHashMap& rHashMap = rElementType.aElementsHashMap; + UIElementDataHashMap::iterator pIter = rHashMap.begin(); + + while ( pIter != rHashMap.end() ) + { + UIElementData& rElement = pIter->second; + if ( rElement.bModified ) + { + if ( rElement.bDefault ) + { + xStorage->removeElement( rElement.aName ); + rElement.bModified = sal_False; // mark as not modified + } + else + { + Reference< XStream > xStream( xStorage->openStreamElement( rElement.aName, ElementModes::WRITE|ElementModes::TRUNCATE ), UNO_QUERY ); + Reference< XOutputStream > xOutputStream( xStream->getOutputStream() ); + + if ( xOutputStream.is() ) + { + switch( rElementType.nElementType ) + { + case ::com::sun::star::ui::UIElementType::MENUBAR: + { + try + { + MenuConfiguration aMenuCfg( m_xServiceManager ); + aMenuCfg.StoreMenuBarConfigurationToXML( rElement.xSettings, xOutputStream ); + } + catch ( ::com::sun::star::lang::WrappedTargetException& ) + { + } + } + break; + + case ::com::sun::star::ui::UIElementType::TOOLBAR: + { + try + { + ToolBoxConfiguration::StoreToolBox( m_xServiceManager, xOutputStream, rElement.xSettings ); + } + catch ( ::com::sun::star::lang::WrappedTargetException& ) + { + } + } + break; + + case ::com::sun::star::ui::UIElementType::STATUSBAR: + { + try + { + StatusBarConfiguration::StoreStatusBar( m_xServiceManager, xOutputStream, rElement.xSettings ); + } + catch ( ::com::sun::star::lang::WrappedTargetException& ) + { + } + } + break; + + default: + break; + } + } + + // mark as not modified if we store to our own storage + if ( bResetModifyState ) + rElement.bModified = sal_False; + } + } + + ++pIter; + } + + // commit element type storage + Reference< XTransactedObject > xTransactedObject( xStorage, UNO_QUERY ); + if ( xTransactedObject.is() ) + xTransactedObject->commit(); + + // mark UIElementType as not modified if we store to our own storage + if ( bResetModifyState ) + rElementType.bModified = sal_False; +} + +void UIConfigurationManager::impl_resetElementTypeData( + UIElementType& rDocElementType, + ConfigEventNotifyContainer& rRemoveNotifyContainer ) +{ + UIElementDataHashMap& rHashMap = rDocElementType.aElementsHashMap; + UIElementDataHashMap::iterator pIter = rHashMap.begin(); + + Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + Reference< XInterface > xIfac( xThis, UNO_QUERY ); + + // Make copies of the event structures to be thread-safe. We have to unlock our mutex before calling + // our listeners! + while ( pIter != rHashMap.end() ) + { + UIElementData& rElement = pIter->second; + if ( !rElement.bDefault ) + { + // Remove user-defined settings from document + ConfigurationEvent aEvent; + aEvent.ResourceURL = rElement.aResourceURL; + aEvent.Accessor <<= xThis; + aEvent.Source = xIfac; + aEvent.Element <<= rElement.xSettings; + + rRemoveNotifyContainer.push_back( aEvent ); + + // Mark element as default. + rElement.bModified = false; + rElement.bDefault = true; + } + else + rElement.bModified = false; + + ++pIter; + } + + // Remove all settings from our user interface elements + rHashMap.clear(); +} + +void UIConfigurationManager::impl_reloadElementTypeData( + UIElementType& rDocElementType, + ConfigEventNotifyContainer& rRemoveNotifyContainer, + ConfigEventNotifyContainer& rReplaceNotifyContainer ) +{ + UIElementDataHashMap& rHashMap = rDocElementType.aElementsHashMap; + UIElementDataHashMap::iterator pIter = rHashMap.begin(); + Reference< XStorage > xElementStorage( rDocElementType.xStorage ); + Reference< XNameAccess > xElementNameAccess( xElementStorage, UNO_QUERY ); + + Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + Reference< XInterface > xIfac( xThis, UNO_QUERY ); + sal_Int16 nType = rDocElementType.nElementType; + + while ( pIter != rHashMap.end() ) + { + UIElementData& rElement = pIter->second; + if ( rElement.bModified ) + { + if ( xElementNameAccess->hasByName( rElement.aName )) + { + // Replace settings with data from user layer + Reference< XIndexAccess > xOldSettings( rElement.xSettings ); + + impl_requestUIElementData( nType, rElement ); + + ConfigurationEvent aReplaceEvent; + + aReplaceEvent.ResourceURL = rElement.aResourceURL; + aReplaceEvent.Accessor <<= xThis; + aReplaceEvent.Source = xIfac; + aReplaceEvent.ReplacedElement <<= xOldSettings; + aReplaceEvent.Element <<= rElement.xSettings; + rReplaceNotifyContainer.push_back( aReplaceEvent ); + + rElement.bModified = false; + } + else + { + // Element settings are not in any storage => remove + ConfigurationEvent aRemoveEvent; + + aRemoveEvent.ResourceURL = rElement.aResourceURL; + aRemoveEvent.Accessor <<= xThis; + aRemoveEvent.Source = xIfac; + aRemoveEvent.Element <<= rElement.xSettings; + + rRemoveNotifyContainer.push_back( aRemoveEvent ); + + // Mark element as default and not modified. That means "not active" in the document anymore + rElement.bModified = false; + rElement.bDefault = true; + } + } + ++pIter; + } + + rDocElementType.bModified = sal_False; +} + +void UIConfigurationManager::impl_Initialize() +{ + // Initialize the top-level structures with the storage data + if ( m_xDocConfigStorage.is() ) + { + long nModes = m_bReadOnly ? ElementModes::READ : ElementModes::READWRITE; + + // Try to access our module sub folder + for ( sal_Int16 i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; + i++ ) + { + Reference< XStorage > xElementTypeStorage; + try + { + xElementTypeStorage = m_xDocConfigStorage->openStorageElement( rtl::OUString::createFromAscii( UIELEMENTTYPENAMES[i] ), nModes ); + } + catch ( com::sun::star::container::NoSuchElementException& ) + { + } + catch ( ::com::sun::star::embed::InvalidStorageException& ) + { + } + catch ( ::com::sun::star::lang::IllegalArgumentException& ) + { + } + catch ( ::com::sun::star::io::IOException& ) + { + } + catch ( ::com::sun::star::embed::StorageWrappedTargetException& ) + { + } + + m_aUIElements[i].nElementType = i; + m_aUIElements[i].bModified = false; + m_aUIElements[i].xStorage = xElementTypeStorage; + m_aUIElements[i].bDefaultLayer = false; + } + } + else + { + // We have no storage, just initialize ui element types with empty storage! + for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ ) + m_aUIElements[i].xStorage = m_xDocConfigStorage; + } +} + +UIConfigurationManager::UIConfigurationManager( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager ) : + ThreadHelpBase( &Application::GetSolarMutex() ) + , m_xDocConfigStorage( 0 ) + , m_bReadOnly( true ) + , m_bInitialized( false ) + , m_bModified( false ) + , m_bConfigRead( false ) + , m_bDisposed( false ) + , m_aXMLPostfix( RTL_CONSTASCII_USTRINGPARAM( ".xml" )) + , m_aPropUIName( RTL_CONSTASCII_USTRINGPARAM( "UIName" )) + , m_aPropResourceURL( RTL_CONSTASCII_USTRINGPARAM( "ResourceURL" )) + , m_xServiceManager( xServiceManager ) + , m_aListenerContainer( m_aLock.getShareableOslMutex() ) +{ + // Make sure we have a default initialized entry for every layer and user interface element type! + // The following code depends on this! + m_aUIElements.resize( ::com::sun::star::ui::UIElementType::COUNT ); } UIConfigurationManager::~UIConfigurationManager() @@ -123,86 +624,507 @@ UIConfigurationManager::~UIConfigurationManager() // XComponent void SAL_CALL UIConfigurationManager::dispose() throw (::com::sun::star::uno::RuntimeException) { - m_pImpl->dispose(); + Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY ); + + css::lang::EventObject aEvent( xThis ); + m_aListenerContainer.disposeAndClear( aEvent ); + + { + ResetableGuard aGuard( m_aLock ); + try + { + if ( m_xImageManager.is() ) + m_xImageManager->dispose(); + } + catch ( Exception& ) + { + } + + m_xImageManager.clear(); + m_aUIElements.clear(); + m_xDocConfigStorage.clear(); + m_bConfigRead = false; + m_bModified = false; + m_bDisposed = true; + } } void SAL_CALL UIConfigurationManager::addEventListener( const Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) { + { + ResetableGuard aGuard( m_aLock ); - m_pImpl->addEventListener(xListener); + /* SAFE AREA ----------------------------------------------------------------------------------------------- */ + if ( m_bDisposed ) + throw DisposedException(); + } + + m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener ); } void SAL_CALL UIConfigurationManager::removeEventListener( const Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) { - m_pImpl->removeEventListener(xListener); + /* SAFE AREA ----------------------------------------------------------------------------------------------- */ + m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener ); } // XUIConfigurationManager void SAL_CALL UIConfigurationManager::addConfigurationListener( const Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) { - m_pImpl->addConfigurationListener(xListener); + { + ResetableGuard aGuard( m_aLock ); + + /* SAFE AREA ----------------------------------------------------------------------------------------------- */ + if ( m_bDisposed ) + throw DisposedException(); + } + + m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XUIConfigurationListener >* ) NULL ), xListener ); } void SAL_CALL UIConfigurationManager::removeConfigurationListener( const Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) { - m_pImpl->removeConfigurationListener(xListener); + /* SAFE AREA ----------------------------------------------------------------------------------------------- */ + m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XUIConfigurationListener >* ) NULL ), xListener ); } void SAL_CALL UIConfigurationManager::reset() throw (::com::sun::star::uno::RuntimeException) { - m_pImpl->reset(); + ResetableGuard aGuard( m_aLock ); + + /* SAFE AREA ----------------------------------------------------------------------------------------------- */ + if ( m_bDisposed ) + throw DisposedException(); + + if ( isReadOnly() ) + return; + + bool bResetStorage( false ); + if ( m_xDocConfigStorage.is() ) + { + try + { + // Remove all elements from our user-defined storage! + bool bCommit( false ); + for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ ) + { + UIElementType& rElementType = m_aUIElements[i]; + Reference< XStorage > xSubStorage( rElementType.xStorage, UNO_QUERY ); + + if ( xSubStorage.is() ) + { + bool bCommitSubStorage( false ); + Reference< XNameAccess > xSubStorageNameAccess( xSubStorage, UNO_QUERY ); + Sequence< rtl::OUString > aUIElementStreamNames = xSubStorageNameAccess->getElementNames(); + for ( sal_Int32 j = 0; j < aUIElementStreamNames.getLength(); j++ ) + { + xSubStorage->removeElement( aUIElementStreamNames[j] ); + bCommitSubStorage = true; + bCommit = true; + } + + if ( bCommitSubStorage ) + { + Reference< XTransactedObject > xTransactedObject( xSubStorage, UNO_QUERY ); + if ( xTransactedObject.is() ) + xTransactedObject->commit(); + } + } + } + + // Commit changes + if ( bCommit ) + { + Reference< XTransactedObject > xTransactedObject( m_xDocConfigStorage, UNO_QUERY ); + if ( xTransactedObject.is() ) + xTransactedObject->commit(); + } + bResetStorage = true; + + // remove settings from user defined layer and notify listener about removed settings data! + // Try to access our module sub folder + ConfigEventNotifyContainer aRemoveEventNotifyContainer; + for ( sal_Int16 j = 1; j < ::com::sun::star::ui::UIElementType::COUNT; j++ ) + { + UIElementType& rDocElementType = m_aUIElements[j]; + + impl_resetElementTypeData( rDocElementType, aRemoveEventNotifyContainer ); + rDocElementType.bModified = sal_False; + } + + m_bModified = sal_False; + + // Unlock mutex before notify our listeners + aGuard.unlock(); + + // Notify our listeners + for ( sal_uInt32 k = 0; k < aRemoveEventNotifyContainer.size(); k++ ) + implts_notifyContainerListener( aRemoveEventNotifyContainer[k], NotifyOp_Remove ); + } + catch ( ::com::sun::star::lang::IllegalArgumentException& ) + { + } + catch ( ::com::sun::star::container::NoSuchElementException& ) + { + } + catch ( ::com::sun::star::embed::InvalidStorageException& ) + { + } + catch ( ::com::sun::star::embed::StorageWrappedTargetException& ) + { + } + } } Sequence< Sequence< PropertyValue > > SAL_CALL UIConfigurationManager::getUIElementsInfo( sal_Int16 ElementType ) throw ( IllegalArgumentException, RuntimeException ) { - return m_pImpl->getUIElementsInfo(ElementType); + if (( ElementType < 0 ) || ( ElementType >= ::com::sun::star::ui::UIElementType::COUNT )) + throw IllegalArgumentException(); + + ResetableGuard aGuard( m_aLock ); + if ( m_bDisposed ) + throw DisposedException(); + + Sequence< Sequence< PropertyValue > > aElementInfoSeq; + UIElementInfoHashMap aUIElementInfoCollection; + + if ( ElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) + { + for ( sal_Int16 i = 0; i < ::com::sun::star::ui::UIElementType::COUNT; i++ ) + impl_fillSequenceWithElementTypeInfo( aUIElementInfoCollection, sal_Int16( i ) ); + } + else + impl_fillSequenceWithElementTypeInfo( aUIElementInfoCollection, ElementType ); + + Sequence< PropertyValue > aUIElementInfo( 2 ); + aUIElementInfo[0].Name = m_aPropResourceURL; + aUIElementInfo[1].Name = m_aPropUIName; + + aElementInfoSeq.realloc( aUIElementInfoCollection.size() ); + UIElementInfoHashMap::const_iterator pIter = aUIElementInfoCollection.begin(); + + sal_Int32 n = 0; + while ( pIter != aUIElementInfoCollection.end() ) + { + aUIElementInfo[0].Value <<= pIter->second.aResourceURL; + aUIElementInfo[1].Value <<= pIter->second.aUIName; + aElementInfoSeq[n++] = aUIElementInfo; + ++pIter; + } + + return aElementInfoSeq; } Reference< XIndexContainer > SAL_CALL UIConfigurationManager::createSettings() throw (::com::sun::star::uno::RuntimeException) { - return m_pImpl->createSettings(); + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + // Creates an empty item container which can be filled from outside + return Reference< XIndexContainer >( static_cast< OWeakObject * >( new RootItemContainer()), UNO_QUERY ); } sal_Bool SAL_CALL UIConfigurationManager::hasSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { - return m_pImpl->hasSettings(ResourceURL); + sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL ); + + if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) || + ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT )) + throw IllegalArgumentException(); + else + { + UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType, false ); + if ( pDataSettings && !pDataSettings->bDefault ) + return sal_True; + } + + return sal_False; } Reference< XIndexAccess > SAL_CALL UIConfigurationManager::getSettings( const ::rtl::OUString& ResourceURL, sal_Bool bWriteable ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { - return m_pImpl->getSettings(ResourceURL,bWriteable); + sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL ); + + if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) || + ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT )) + throw IllegalArgumentException(); + else + { + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType ); + if ( pDataSettings && !pDataSettings->bDefault ) + { + // Create a copy of our data if someone wants to change the data. + if ( bWriteable ) + return Reference< XIndexAccess >( static_cast< OWeakObject * >( new RootItemContainer( pDataSettings->xSettings ) ), UNO_QUERY ); + else + return pDataSettings->xSettings; + } + } + + throw NoSuchElementException(); } void SAL_CALL UIConfigurationManager::replaceSettings( const ::rtl::OUString& ResourceURL, const Reference< ::com::sun::star::container::XIndexAccess >& aNewData ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException) { - return m_pImpl->replaceSettings(ResourceURL,aNewData); + sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL ); + + if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) || + ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT )) + throw IllegalArgumentException(); + else if ( m_bReadOnly ) + throw IllegalAccessException(); + else + { + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType ); + if ( pDataSettings && !pDataSettings->bDefault ) + { + // we have a settings entry in our user-defined layer - replace + Reference< XIndexAccess > xOldSettings = pDataSettings->xSettings; + + // Create a copy of the data if the container is not const + Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY ); + if ( xReplace.is() ) + pDataSettings->xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY ); + else + pDataSettings->xSettings = aNewData; + + pDataSettings->bDefault = false; + pDataSettings->bModified = true; + m_bModified = true; + + // Modify type container + UIElementType& rElementType = m_aUIElements[nElementType]; + rElementType.bModified = true; + + Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + + // Create event to notify listener about replaced element settings + ConfigurationEvent aEvent; + Reference< XInterface > xIfac( xThis, UNO_QUERY ); + + aEvent.ResourceURL = ResourceURL; + aEvent.Accessor <<= xThis; + aEvent.Source = xIfac; + aEvent.ReplacedElement <<= xOldSettings; + aEvent.Element <<= pDataSettings->xSettings; + + aGuard.unlock(); + + implts_notifyContainerListener( aEvent, NotifyOp_Replace ); + } + else + throw NoSuchElementException(); + } } void SAL_CALL UIConfigurationManager::removeSettings( const ::rtl::OUString& ResourceURL ) throw ( NoSuchElementException, IllegalArgumentException, IllegalAccessException, RuntimeException) { - m_pImpl->removeSettings(ResourceURL); + sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL ); + + if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) || + ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT )) + throw IllegalArgumentException(); + else if ( m_bReadOnly ) + throw IllegalAccessException(); + else + { + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType ); + if ( pDataSettings ) + { + // If element settings are default, we don't need to change anything! + if ( pDataSettings->bDefault ) + return; + else + { + Reference< XIndexAccess > xRemovedSettings = pDataSettings->xSettings; + pDataSettings->bDefault = true; + + // check if this is a default layer node + pDataSettings->bModified = true; // we have to remove this node from the user layer! + pDataSettings->xSettings.clear(); + m_bModified = true; // user layer must be written + + // Modify type container + UIElementType& rElementType = m_aUIElements[nElementType]; + rElementType.bModified = true; + + Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + Reference< XInterface > xIfac( xThis, UNO_QUERY ); + + // Create event to notify listener about removed element settings + ConfigurationEvent aEvent; + + aEvent.ResourceURL = ResourceURL; + aEvent.Accessor <<= xThis; + aEvent.Source = xIfac; + aEvent.Element <<= xRemovedSettings; + + aGuard.unlock(); + + implts_notifyContainerListener( aEvent, NotifyOp_Remove ); + } + } + else + throw NoSuchElementException(); + } } void SAL_CALL UIConfigurationManager::insertSettings( const ::rtl::OUString& NewResourceURL, const Reference< XIndexAccess >& aNewData ) throw ( ElementExistException, IllegalArgumentException, IllegalAccessException, RuntimeException ) { - m_pImpl->insertSettings(NewResourceURL,aNewData); + sal_Int16 nElementType = RetrieveTypeFromResourceURL( NewResourceURL ); + + if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) || + ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT )) + throw IllegalArgumentException(); + else if ( m_bReadOnly ) + throw IllegalAccessException(); + else + { + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + bool bInsertData( false ); + UIElementData aUIElementData; + UIElementData* pDataSettings = impl_findUIElementData( NewResourceURL, nElementType ); + + if ( pDataSettings && !pDataSettings->bDefault ) + throw ElementExistException(); + + if ( !pDataSettings ) + { + pDataSettings = &aUIElementData; + bInsertData = true; + } + + { + pDataSettings->bDefault = false; + pDataSettings->bModified = true; + + // Create a copy of the data if the container is not const + Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY ); + if ( xReplace.is() ) + pDataSettings->xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY ); + else + pDataSettings->xSettings = aNewData; + + m_bModified = true; + + UIElementType& rElementType = m_aUIElements[nElementType]; + rElementType.bModified = true; + + if ( bInsertData ) + { + pDataSettings->aName = RetrieveNameFromResourceURL( NewResourceURL ) + m_aXMLPostfix; + pDataSettings->aResourceURL = NewResourceURL; + + UIElementDataHashMap& rElements = rElementType.aElementsHashMap; + rElements.insert( UIElementDataHashMap::value_type( NewResourceURL, *pDataSettings )); + } + + Reference< XIndexAccess > xInsertSettings( aUIElementData.xSettings ); + Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + Reference< XInterface > xIfac( xThis, UNO_QUERY ); + + // Create event to notify listener about removed element settings + ConfigurationEvent aEvent; + + aEvent.ResourceURL = NewResourceURL; + aEvent.Accessor <<= xThis; + aEvent.Source = xIfac; + aEvent.Element <<= xInsertSettings; + + aGuard.unlock(); + + implts_notifyContainerListener( aEvent, NotifyOp_Insert ); + } + } } Reference< XInterface > SAL_CALL UIConfigurationManager::getImageManager() throw (::com::sun::star::uno::RuntimeException) { - return m_pImpl->getImageManager(); + if ( m_bDisposed ) + throw DisposedException(); + + if ( !m_xImageManager.is() ) + { + m_xImageManager = Reference< XComponent >( static_cast< cppu::OWeakObject *>( new ImageManager( m_xServiceManager )), + UNO_QUERY ); + Reference< XInitialization > xInit( m_xImageManager, UNO_QUERY ); + + Sequence< Any > aPropSeq( 2 ); + PropertyValue aPropValue; + aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UserConfigStorage" )); + aPropValue.Value = makeAny( m_xDocConfigStorage ); + aPropSeq[0] = makeAny( aPropValue ); + aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModuleIdentifier" )); + aPropValue.Value = makeAny( m_aModuleIdentifier ); + aPropSeq[1] = makeAny( aPropValue ); + + xInit->initialize( aPropSeq ); + } + + return Reference< XInterface >( m_xImageManager, UNO_QUERY ); } Reference< XInterface > SAL_CALL UIConfigurationManager::getShortCutManager() throw (::com::sun::star::uno::RuntimeException) { - return m_pImpl->getShortCutManager(); + // SAFE -> + ResetableGuard aGuard( m_aLock ); + + if (m_xAccConfig.is()) + return m_xAccConfig; + + Reference< XMultiServiceFactory > xSMGR = m_xServiceManager; + Reference< XStorage > xDocumentRoot = m_xDocConfigStorage; + + aGuard.unlock(); + // <- SAFE + + Reference< XInterface > xAccConfig = xSMGR->createInstance(SERVICENAME_DOCUMENTACCELERATORCONFIGURATION); + Reference< XInitialization > xInit (xAccConfig, UNO_QUERY_THROW); + + PropertyValue aProp; + aProp.Name = ::rtl::OUString::createFromAscii("DocumentRoot"); + aProp.Value <<= xDocumentRoot; + + Sequence< Any > lArgs(1); + lArgs[0] <<= aProp; + + xInit->initialize(lArgs); + + // SAFE -> + aGuard.lock(); + m_xAccConfig = xAccConfig; + aGuard.unlock(); + // <- SAFE + + return xAccConfig; } Reference< XInterface > SAL_CALL UIConfigurationManager::getEventsManager() throw (::com::sun::star::uno::RuntimeException) @@ -213,38 +1135,223 @@ Reference< XInterface > SAL_CALL UIConfigurationManager::getEventsManager() thro // XUIConfigurationStorage void SAL_CALL UIConfigurationManager::setStorage( const Reference< XStorage >& Storage ) throw (::com::sun::star::uno::RuntimeException) { - m_pImpl->setStorage(Storage); + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + if ( m_xDocConfigStorage.is() ) + { + try + { + // Dispose old storage to be sure that it will be closed + Reference< XComponent > xComponent( m_xDocConfigStorage, UNO_QUERY ); + if ( xComponent.is() ) + xComponent->dispose(); + } + catch ( Exception& ) + { + } + } + + // We store the new storage. Be careful it could be an empty reference! + m_xDocConfigStorage = Storage; + m_bReadOnly = sal_True; + + Reference< XUIConfigurationStorage > xAccUpdate(m_xAccConfig, UNO_QUERY); + if ( xAccUpdate.is() ) + xAccUpdate->setStorage( m_xDocConfigStorage ); + + if ( m_xImageManager.is() ) + { + ImageManager* pImageManager = (ImageManager*)m_xImageManager.get(); + if ( pImageManager ) + pImageManager->setStorage( m_xDocConfigStorage ); + } + + if ( m_xDocConfigStorage.is() ) + { + Reference< XPropertySet > xPropSet( m_xDocConfigStorage, UNO_QUERY ); + if ( xPropSet.is() ) + { + try + { + long nOpenMode = 0; + Any a = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenMode" ))); + if ( a >>= nOpenMode ) + m_bReadOnly = !( nOpenMode & ElementModes::WRITE ); + } + catch ( com::sun::star::beans::UnknownPropertyException& ) + { + } + catch ( com::sun::star::lang::WrappedTargetException& ) + { + } + } + } + + impl_Initialize(); } sal_Bool SAL_CALL UIConfigurationManager::hasStorage() throw (::com::sun::star::uno::RuntimeException) { - return m_pImpl->hasStorage(); + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + return ( m_xDocConfigStorage.is() ); } // XUIConfigurationPersistence void SAL_CALL UIConfigurationManager::reload() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) { - m_pImpl->reload(); + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + if ( m_xDocConfigStorage.is() && m_bModified && !m_bReadOnly ) + { + // Try to access our module sub folder + ConfigEventNotifyContainer aRemoveNotifyContainer; + ConfigEventNotifyContainer aReplaceNotifyContainer; + for ( sal_Int16 i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ ) + { + try + { + UIElementType& rDocElementType = m_aUIElements[i]; + if ( rDocElementType.bModified ) + impl_reloadElementTypeData( rDocElementType, aRemoveNotifyContainer, aReplaceNotifyContainer ); + } + catch ( Exception& ) + { + throw IOException(); + } + } + + m_bModified = sal_False; + + // Unlock mutex before notify our listeners + aGuard.unlock(); + + // Notify our listeners + for ( sal_uInt32 j = 0; j < aRemoveNotifyContainer.size(); j++ ) + implts_notifyContainerListener( aRemoveNotifyContainer[j], NotifyOp_Remove ); + for ( sal_uInt32 k = 0; k < aReplaceNotifyContainer.size(); k++ ) + implts_notifyContainerListener( aReplaceNotifyContainer[k], NotifyOp_Replace ); + } } void SAL_CALL UIConfigurationManager::store() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) { - m_pImpl->store(); + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + if ( m_xDocConfigStorage.is() && m_bModified && !m_bReadOnly ) + { + // Try to access our module sub folder + for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ ) + { + try + { + UIElementType& rElementType = m_aUIElements[i]; + Reference< XStorage > xStorage( rElementType.xStorage, UNO_QUERY ); + + if ( rElementType.bModified && xStorage.is() ) + impl_storeElementTypeData( xStorage, rElementType ); + } + catch ( Exception& ) + { + throw IOException(); + } + } + + m_bModified = false; + Reference< XTransactedObject > xTransactedObject( m_xDocConfigStorage, UNO_QUERY ); + if ( xTransactedObject.is() ) + xTransactedObject->commit(); + } } void SAL_CALL UIConfigurationManager::storeToStorage( const Reference< XStorage >& Storage ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) { - m_pImpl->storeToStorage(Storage); + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + throw DisposedException(); + + if ( m_xDocConfigStorage.is() && m_bModified && !m_bReadOnly ) + { + // Try to access our module sub folder + for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ ) + { + try + { + Reference< XStorage > xElementTypeStorage( Storage->openStorageElement( + rtl::OUString::createFromAscii( UIELEMENTTYPENAMES[i] ), ElementModes::READWRITE )); + UIElementType& rElementType = m_aUIElements[i]; + + if ( rElementType.bModified && xElementTypeStorage.is() ) + impl_storeElementTypeData( xElementTypeStorage, rElementType, false ); // store data to storage, but don't reset modify flag! + } + catch ( Exception& ) + { + throw IOException(); + } + } + + Reference< XTransactedObject > xTransactedObject( Storage, UNO_QUERY ); + if ( xTransactedObject.is() ) + xTransactedObject->commit(); + } } sal_Bool SAL_CALL UIConfigurationManager::isModified() throw (::com::sun::star::uno::RuntimeException) { - return m_pImpl->isModified(); + ResetableGuard aGuard( m_aLock ); + + return m_bModified; } sal_Bool SAL_CALL UIConfigurationManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException) { - return m_pImpl->isReadOnly(); + ResetableGuard aGuard( m_aLock ); + + return m_bReadOnly; +} + +void UIConfigurationManager::implts_notifyContainerListener( const ConfigurationEvent& aEvent, NotifyOp eOp ) +{ + ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >*) NULL ) ); + if ( pContainer != NULL ) + { + ::cppu::OInterfaceIteratorHelper pIterator( *pContainer ); + while ( pIterator.hasMoreElements() ) + { + try + { + switch ( eOp ) + { + case NotifyOp_Replace: + ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementReplaced( aEvent ); + break; + case NotifyOp_Insert: + ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementInserted( aEvent ); + break; + case NotifyOp_Remove: + ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementRemoved( aEvent ); + break; + } + } + catch( css::uno::RuntimeException& ) + { + pIterator.remove(); + } + } + } } } // namespace framework diff --git a/framework/source/uiconfiguration/uiconfigurationmanagerimpl.cxx b/framework/source/uiconfiguration/uiconfigurationmanagerimpl.cxx index 5b67b13d8805..40c2c3f10708 100755 --- a/framework/source/uiconfiguration/uiconfigurationmanagerimpl.cxx +++ b/framework/source/uiconfiguration/uiconfigurationmanagerimpl.cxx @@ -148,12 +148,12 @@ void UIConfigurationManagerImpl::impl_fillSequenceWithElementTypeInfo( UIElement while ( pUserIter != rUserElements.end() ) { sal_Int32 nIndex = pUserIter->second.aResourceURL.indexOf( aCustomUrlPrefix, RESOURCEURL_PREFIX_SIZE ); - if ( !m_bUseDefault && nIndex > RESOURCEURL_PREFIX_SIZE ) + if ( nIndex > RESOURCEURL_PREFIX_SIZE ) { // Performance: Retrieve user interface name only for custom user interface elements. // It's only used by them! UIElementData* pDataSettings = impl_findUIElementData( pUserIter->second.aResourceURL, nElementType ); - if ( pDataSettings && ( !m_bUseDefault || !pDataSettings->bDefault) ) + if ( pDataSettings && ( m_bUseDefault || !pDataSettings->bDefault )) { // Retrieve user interface name from XPropertySet interface rtl::OUString aUIName; @@ -1268,7 +1268,7 @@ throw ( ElementExistException, IllegalArgumentException, IllegalAccessException, if ( m_bDisposed ) throw DisposedException(); - bool bInsertData( m_bUseDefault ); + bool bInsertData( false ); UIElementData aUIElementData; UIElementData* pDataSettings = impl_findUIElementData( NewResourceURL, nElementType ); if ( !m_bUseDefault ) @@ -1281,7 +1281,7 @@ throw ( ElementExistException, IllegalArgumentException, IllegalAccessException, bInsertData = true; } } - if ( !pDataSettings || bInsertData ) + if ( !pDataSettings || !m_bUseDefault ) { aUIElementData.bDefault = false; if ( !m_bUseDefault ) diff --git a/framework/util/makefile.mk b/framework/util/makefile.mk index 60a44dba706f..0a07f3cf137d 100644 --- a/framework/util/makefile.mk +++ b/framework/util/makefile.mk @@ -334,7 +334,6 @@ SHL4OBJS= \ $(SLO)$/uicategorydescription.obj \ $(SLO)$/uicommanddescription.obj \ $(SLO)$/uiconfigurationmanager.obj \ - $(SLO)$/uiconfigurationmanagerimpl.obj \ $(SLO)$/uielementfactorymanager.obj \ $(SLO)$/urltransformer.obj \ $(SLO)$/vclstatusindicator.obj \ -- cgit From 9f2fde7ab5de20926bb25a6b298b4e5dffb66eb2 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Fri, 16 Oct 2009 00:05:16 +0200 Subject: #i103496#: split svtools; improve ConfitItems --- framework/inc/classes/protocolhandlercache.hxx | 1 + framework/inc/framework.hrc | 2 +- framework/inc/helper/mischelper.hxx | 2 +- framework/inc/helpid.hrc | 2 +- framework/inc/pch/precompiled_framework.hxx | 14 +++++++------- framework/inc/services/licensedlg.hxx | 2 +- framework/inc/services/substitutepathvars.hxx | 1 + framework/inc/xml/eventsconfiguration.hxx | 2 +- framework/inc/xml/imagesconfiguration.hxx | 2 +- framework/inc/xml/statusbarconfiguration.hxx | 2 +- framework/inc/xml/toolboxconfiguration.hxx | 2 +- framework/source/classes/protocolhandlercache.cxx | 4 ++++ framework/source/services/autorecovery.cxx | 2 +- framework/source/services/backingcomp.cxx | 4 ++-- framework/source/services/backingwindow.cxx | 2 +- framework/source/services/mediatypedetectionhelper.cxx | 2 +- framework/source/services/substitutepathvars.cxx | 5 +++++ framework/source/uielement/controlmenucontroller.cxx | 2 +- framework/source/uielement/langselectionmenucontroller.cxx | 2 +- .../source/uielement/langselectionstatusbarcontroller.cxx | 2 +- framework/source/uielement/toolbarmanager.cxx | 2 +- 21 files changed, 35 insertions(+), 24 deletions(-) (limited to 'framework') diff --git a/framework/inc/classes/protocolhandlercache.hxx b/framework/inc/classes/protocolhandlercache.hxx index 4dbafe373117..595b358a789a 100644 --- a/framework/inc/classes/protocolhandlercache.hxx +++ b/framework/inc/classes/protocolhandlercache.hxx @@ -194,6 +194,7 @@ class HandlerCFGAccess : public ::utl::ConfigItem void setCache(HandlerCache* pCache) {m_pCache = pCache;}; virtual void Notify(const css::uno::Sequence< rtl::OUString >& lPropertyNames); + virtual void Commit(); }; } // namespace framework diff --git a/framework/inc/framework.hrc b/framework/inc/framework.hrc index 6f35d20c2d22..57fb2e94b07a 100644 --- a/framework/inc/framework.hrc +++ b/framework/inc/framework.hrc @@ -31,7 +31,7 @@ #ifndef _FRAMEWORK_HRC #define _FRAMEWORK_HRC -#include "svtools/solar.hrc" +#include "svl/solar.hrc" #define RID_FWK_START 260 diff --git a/framework/inc/helper/mischelper.hxx b/framework/inc/helper/mischelper.hxx index 435b87a4f248..1bd908b266c6 100644 --- a/framework/inc/helper/mischelper.hxx +++ b/framework/inc/helper/mischelper.hxx @@ -36,7 +36,7 @@ #include #include -#include +#include namespace framework { diff --git a/framework/inc/helpid.hrc b/framework/inc/helpid.hrc index 49921efcee37..6195a6372452 100644 --- a/framework/inc/helpid.hrc +++ b/framework/inc/helpid.hrc @@ -32,7 +32,7 @@ // include ------------------------------------------------------------------ -#include +#include // Help-Ids ----------------------------------------------------------------- diff --git a/framework/inc/pch/precompiled_framework.hxx b/framework/inc/pch/precompiled_framework.hxx index 5d1d1141244b..fd211dd81ee9 100644 --- a/framework/inc/pch/precompiled_framework.hxx +++ b/framework/inc/pch/precompiled_framework.hxx @@ -388,24 +388,24 @@ #include "svtools/framestatuslistener.hxx" #include "svtools/helpopt.hxx" #include "unotools/historyoptions.hxx" -#include "svtools/imageitm.hxx" +#include "svl/imageitm.hxx" #include "svtools/imgdef.hxx" -#include "svtools/inettype.hxx" +#include "svl/inettype.hxx" #include "unotools/internaloptions.hxx" -#include "svtools/lstner.hxx" +#include "svl/lstner.hxx" #include "svtools/menuoptions.hxx" #include "svtools/miscopt.hxx" #include "unotools/moduleoptions.hxx" #include "unotools/pathoptions.hxx" #include "svtools/sfxecode.hxx" -#include "svtools/smplhint.hxx" -#include "svtools/solar.hrc" +#include "svl/smplhint.hxx" +#include "svl/solar.hrc" #include "svtools/statusbarcontroller.hxx" -#include "svtools/svarray.hxx" +#include "svl/svarray.hxx" #include "svtools/svmedit.hxx" #include "svtools/toolboxcontroller.hxx" #include "svtools/transfer.hxx" -#include "svtools/urihelper.hxx" +#include "svl/urihelper.hxx" #include "svtools/xtextedt.hxx" #include "toolkit/awt/vclxmenu.hxx" diff --git a/framework/inc/services/licensedlg.hxx b/framework/inc/services/licensedlg.hxx index 86e3f6c7fc57..4f5b9f0c65fa 100644 --- a/framework/inc/services/licensedlg.hxx +++ b/framework/inc/services/licensedlg.hxx @@ -42,7 +42,7 @@ #include #include #include -#include +#include namespace framework { diff --git a/framework/inc/services/substitutepathvars.hxx b/framework/inc/services/substitutepathvars.hxx index a95e913695b0..215def2ea08c 100644 --- a/framework/inc/services/substitutepathvars.hxx +++ b/framework/inc/services/substitutepathvars.hxx @@ -139,6 +139,7 @@ class SubstitutePathVariables_Impl : public utl::ConfigItem /** is called from the ConfigManager before application ends or from the PropertyChangeListener if the sub tree broadcasts changes. */ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames ); + virtual void Commit(); private: // Wrapper methods for low-level functions diff --git a/framework/inc/xml/eventsconfiguration.hxx b/framework/inc/xml/eventsconfiguration.hxx index ca446a7e1386..69e6f85c6f90 100644 --- a/framework/inc/xml/eventsconfiguration.hxx +++ b/framework/inc/xml/eventsconfiguration.hxx @@ -31,7 +31,7 @@ #ifndef __FRAMEWORK_XML_EVENTSCONFIGURATION_HXX_ #define __FRAMEWORK_XML_EVENTSCONFIGURATION_HXX_ -#include +#include #include #include #include diff --git a/framework/inc/xml/imagesconfiguration.hxx b/framework/inc/xml/imagesconfiguration.hxx index 452d2c045da4..d0961892b96b 100644 --- a/framework/inc/xml/imagesconfiguration.hxx +++ b/framework/inc/xml/imagesconfiguration.hxx @@ -31,7 +31,7 @@ #ifndef __FRAMEWORK_XML_IMAGESCONFIGURATION_HXX_ #define __FRAMEWORK_XML_IMAGESCONFIGURATION_HXX_ -#include +#include #include #include #include diff --git a/framework/inc/xml/statusbarconfiguration.hxx b/framework/inc/xml/statusbarconfiguration.hxx index 9bcfa9564a33..8619ae423622 100644 --- a/framework/inc/xml/statusbarconfiguration.hxx +++ b/framework/inc/xml/statusbarconfiguration.hxx @@ -1,7 +1,7 @@ #ifndef __FRAMEWORK_CLASSES_STATUSBARCONFIGURATION_HXX_ #define __FRAMEWORK_CLASSES_STATUSBARCONFIGURATION_HXX_ -#include +#include #include #include #include diff --git a/framework/inc/xml/toolboxconfiguration.hxx b/framework/inc/xml/toolboxconfiguration.hxx index c3f827bc95a1..924c601ac689 100644 --- a/framework/inc/xml/toolboxconfiguration.hxx +++ b/framework/inc/xml/toolboxconfiguration.hxx @@ -1,7 +1,7 @@ #ifndef __FRAMEWORK_XML_TOOLBOXCONFIGURATION_HXX_ #define __FRAMEWORK_XML_TOOLBOXCONFIGURATION_HXX_ -#include +#include #include #include #include diff --git a/framework/source/classes/protocolhandlercache.cxx b/framework/source/classes/protocolhandlercache.cxx index 034b35259186..f426eb530c90 100644 --- a/framework/source/classes/protocolhandlercache.cxx +++ b/framework/source/classes/protocolhandlercache.cxx @@ -357,4 +357,8 @@ void HandlerCFGAccess::Notify(const css::uno::Sequence< rtl::OUString >& /*lProp } } +void HandlerCFGAccess::Commit() +{ +} + } // namespace framework diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx index 2137e1a22ddd..bc6272d6c38c 100644 --- a/framework/source/services/autorecovery.cxx +++ b/framework/source/services/autorecovery.cxx @@ -91,7 +91,7 @@ #include #include #include -#include +#include #include diff --git a/framework/source/services/backingcomp.cxx b/framework/source/services/backingcomp.cxx index 5a299150611e..7f190a678763 100644 --- a/framework/source/services/backingcomp.cxx +++ b/framework/source/services/backingcomp.cxx @@ -75,9 +75,9 @@ #include #ifndef _SOLAR_HRC -#include +#include #endif -#include +#include #include #include diff --git a/framework/source/services/backingwindow.cxx b/framework/source/services/backingwindow.cxx index 509b37d09529..0bdd57cb2209 100644 --- a/framework/source/services/backingwindow.cxx +++ b/framework/source/services/backingwindow.cxx @@ -45,7 +45,7 @@ #include "unotools/dynamicmenuoptions.hxx" #include "svtools/imagemgr.hxx" -#include "svtools/svtools.hrc" +#include "svl/svtools.hrc" #include "comphelper/processfactory.hxx" #include "comphelper/sequenceashashmap.hxx" diff --git a/framework/source/services/mediatypedetectionhelper.cxx b/framework/source/services/mediatypedetectionhelper.cxx index 41d57b47899e..aca9b8f79523 100644 --- a/framework/source/services/mediatypedetectionhelper.cxx +++ b/framework/source/services/mediatypedetectionhelper.cxx @@ -36,7 +36,7 @@ //_________________________________________________________________________________________________________________ #include #include -#include +#include #include #include diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx index 966ce1756c64..21b2be8b1c53 100644 --- a/framework/source/services/substitutepathvars.cxx +++ b/framework/source/services/substitutepathvars.cxx @@ -319,6 +319,11 @@ void SubstitutePathVariables_Impl::Notify( const com::sun::star::uno::Sequence< // NOT implemented yet! } +void SubstitutePathVariables_Impl::Commit() +{ +} + + //_________________________________________________________________________________________________________________ // private methods //_________________________________________________________________________________________________________________ diff --git a/framework/source/uielement/controlmenucontroller.cxx b/framework/source/uielement/controlmenucontroller.cxx index 311db615ed2a..caa356d850fa 100644 --- a/framework/source/uielement/controlmenucontroller.cxx +++ b/framework/source/uielement/controlmenucontroller.cxx @@ -62,7 +62,7 @@ #include #include #ifndef _SOLAR_HRC -#include +#include #endif #include #include diff --git a/framework/source/uielement/langselectionmenucontroller.cxx b/framework/source/uielement/langselectionmenucontroller.cxx index 555682677e33..ec1508cb0fd7 100644 --- a/framework/source/uielement/langselectionmenucontroller.cxx +++ b/framework/source/uielement/langselectionmenucontroller.cxx @@ -68,7 +68,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx b/framework/source/uielement/langselectionstatusbarcontroller.cxx index bccd553b57d3..dd8f66337720 100644 --- a/framework/source/uielement/langselectionstatusbarcontroller.cxx +++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx @@ -71,7 +71,7 @@ #include #include #include -#include +#include #include #include diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 6be7dc73b4c2..5e1c7cc93da2 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -91,7 +91,7 @@ #endif #include #include -#include +#include #include #include #include -- cgit From fd1be11b2f7031ebd5f2cd1339132f56a9f0e60d Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Fri, 16 Oct 2009 15:28:14 +0000 Subject: #i105947# Add missing readConfigurationData() call. --- framework/source/uifactory/windowcontentfactorymanager.cxx | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'framework') diff --git a/framework/source/uifactory/windowcontentfactorymanager.cxx b/framework/source/uifactory/windowcontentfactorymanager.cxx index fcadc1694e54..239c6aff5c1f 100644 --- a/framework/source/uifactory/windowcontentfactorymanager.cxx +++ b/framework/source/uifactory/windowcontentfactorymanager.cxx @@ -220,6 +220,13 @@ throw (uno::Exception, uno::RuntimeException) // module identifier, user interface element type and name // SAFE ResetableGuard aLock( m_aLock ); + + if ( !m_bConfigRead ) + { + m_bConfigRead = sal_True; + m_pConfigAccess->readConfigurationData(); + } + aImplementationName = m_pConfigAccess->getFactorySpecifierFromTypeNameModule( aType, aName, aModuleId ); if ( aImplementationName.getLength() > 0 ) { -- cgit From 5cf5683f944d08fdb9ac22c4a21b095ec1af2ac5 Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Tue, 20 Oct 2009 05:35:27 +0000 Subject: #i106041# check the dispatch in impl_select not before --- framework/source/helper/popupmenucontrollerbase.cxx | 6 ++++-- framework/source/uielement/fontmenucontroller.cxx | 4 +++- framework/source/uielement/fontsizemenucontroller.cxx | 4 +++- framework/source/uielement/headermenucontroller.cxx | 4 +++- framework/source/uielement/objectmenucontroller.cxx | 4 +++- 5 files changed, 16 insertions(+), 6 deletions(-) (limited to 'framework') diff --git a/framework/source/helper/popupmenucontrollerbase.cxx b/framework/source/helper/popupmenucontrollerbase.cxx index 7a768b11a32d..af46386edb35 100644 --- a/framework/source/helper/popupmenucontrollerbase.cxx +++ b/framework/source/helper/popupmenucontrollerbase.cxx @@ -186,7 +186,9 @@ void SAL_CALL PopupMenuControllerBase::highlight( const css::awt::MenuEvent& ) t void PopupMenuControllerBase::impl_select(const Reference< XDispatch >& _xDispatch,const ::com::sun::star::util::URL& aURL) { Sequence aArgs; - _xDispatch->dispatch( aURL, aArgs ); + OSL_ENSURE(_xDispatch.is(),"PopupMenuControllerBase::impl_select: No dispatch"); + if ( _xDispatch.is() ) + _xDispatch->dispatch( aURL, aArgs ); } void SAL_CALL PopupMenuControllerBase::select( const css::awt::MenuEvent& rEvent ) throw (RuntimeException) @@ -204,7 +206,7 @@ void SAL_CALL PopupMenuControllerBase::select( const css::awt::MenuEvent& rEvent xServiceManager = m_xServiceManager; aLock.unlock(); - if ( xPopupMenu.is() && xDispatch.is() ) + if ( xPopupMenu.is() ) { VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXPopupMenu::GetImplementation( xPopupMenu ); if ( pPopupMenu ) diff --git a/framework/source/uielement/fontmenucontroller.cxx b/framework/source/uielement/fontmenucontroller.cxx index ee1014f25b77..e12843f7514d 100644 --- a/framework/source/uielement/fontmenucontroller.cxx +++ b/framework/source/uielement/fontmenucontroller.cxx @@ -188,7 +188,9 @@ void FontMenuController::impl_select(const Reference< XDispatch >& _xDispatch,co m_xFrame, aTargetURL, Sequence()); - _xDispatch->dispatch( aTargetURL, aArgs ); + OSL_ENSURE(_xDispatch.is(),"FontMenuController::impl_select: No dispatch"); + if ( _xDispatch.is() ) + _xDispatch->dispatch( aTargetURL, aArgs ); } void SAL_CALL FontMenuController::activate( const css::awt::MenuEvent& ) throw (RuntimeException) diff --git a/framework/source/uielement/fontsizemenucontroller.cxx b/framework/source/uielement/fontsizemenucontroller.cxx index bbf3915d2e06..2f7bce27d151 100644 --- a/framework/source/uielement/fontsizemenucontroller.cxx +++ b/framework/source/uielement/fontsizemenucontroller.cxx @@ -326,7 +326,9 @@ void FontSizeMenuController::impl_select(const Reference< XDispatch >& _xDispatc Sequence aArgs; if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# UiEventLogHelper(::rtl::OUString::createFromAscii("FontSizeMenuController")).log(m_xServiceManager, m_xFrame, aTargetURL, aArgs); - _xDispatch->dispatch( aTargetURL, aArgs ); + OSL_ENSURE(_xDispatch.is(),"FontSizeMenuController::impl_select: No dispatch"); + if ( _xDispatch.is() ) + _xDispatch->dispatch( aTargetURL, aArgs ); } // XPopupMenuController diff --git a/framework/source/uielement/headermenucontroller.cxx b/framework/source/uielement/headermenucontroller.cxx index 4e90d86fe0c9..56f45c5c52c2 100644 --- a/framework/source/uielement/headermenucontroller.cxx +++ b/framework/source/uielement/headermenucontroller.cxx @@ -254,7 +254,9 @@ void HeaderMenuController::impl_select(const Reference< XDispatch >& _xDispatch, Sequence aArgs; if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# UiEventLogHelper(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(m_bFooter ? "FooterMenuController" : "HeaderMenuController"))).log(m_xServiceManager, m_xFrame, aTargetURL, aArgs); - _xDispatch->dispatch( aTargetURL, aArgs ); + OSL_ENSURE(_xDispatch.is(),"HeaderMenuController::impl_select: No dispatch"); + if ( _xDispatch.is() ) + _xDispatch->dispatch( aTargetURL, aArgs ); } void SAL_CALL HeaderMenuController::updatePopupMenu() throw (::com::sun::star::uno::RuntimeException) diff --git a/framework/source/uielement/objectmenucontroller.cxx b/framework/source/uielement/objectmenucontroller.cxx index 9f7d3bb64f5e..937fb7ded0dc 100644 --- a/framework/source/uielement/objectmenucontroller.cxx +++ b/framework/source/uielement/objectmenucontroller.cxx @@ -160,7 +160,9 @@ void ObjectMenuController::impl_select(const Reference< XDispatch >& _xDispatch, Sequence aArgs; if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# UiEventLogHelper(::rtl::OUString::createFromAscii("ObjectMenuController")).log(m_xServiceManager, m_xFrame, aTargetURL, aArgs); - _xDispatch->dispatch( aTargetURL, aArgs ); + OSL_ENSURE(_xDispatch.is(),"ObjectMenuController::impl_select: No dispatch"); + if ( _xDispatch.is() ) + _xDispatch->dispatch( aTargetURL, aArgs ); } } -- cgit From 23740dc4a7e81c8c5129e26fe579cf81363d6388 Mon Sep 17 00:00:00 2001 From: Vladimir Glazounov Date: Wed, 21 Oct 2009 14:48:59 +0000 Subject: CWS-TOOLING: integrate CWS fwk123 2009-10-14 10:18:49 +0200 cd r276885 : #i99971# Use AttachThreadInput to force SetForegroundWindow 2009-10-14 08:56:20 +0200 mav r276881 : #i105476# let the allocated memory live long anough 2009-10-14 08:53:51 +0200 mav r276880 : #i105476# let ZipFile use mutex while creating the requested stream 2009-10-14 08:51:52 +0200 mav r276879 : #i105476# let buffered IO use mutex ( patch from MHU ) 2009-10-09 12:20:22 +0200 cd r276803 : #i99971# Use configuration to control window to front/focus handling 2009-10-09 12:19:22 +0200 cd r276802 : #i99971# New configuration item to force set focus and window to front for new document windows 2009-10-09 12:18:23 +0200 cd r276801 : #i99971# Introduction of a new show flag to force window to front 2009-10-06 11:04:16 +0200 ab r276695 : #i105386# Call xmlInitParser() before registering input callbacks --- framework/source/helper/statusindicatorfactory.cxx | 19 +++++++++++++-- framework/source/loadenv/loadenv.cxx | 28 ++++++++++++++++------ 2 files changed, 38 insertions(+), 9 deletions(-) (limited to 'framework') diff --git a/framework/source/helper/statusindicatorfactory.cxx b/framework/source/helper/statusindicatorfactory.cxx index b2139488a0ee..ee59097aa3fc 100644 --- a/framework/source/helper/statusindicatorfactory.cxx +++ b/framework/source/helper/statusindicatorfactory.cxx @@ -67,6 +67,7 @@ // includes of other projects #include #include +#include #include #include @@ -361,6 +362,7 @@ void StatusIndicatorFactory::implts_makeParentVisibleIfAllowed() css::uno::Reference< css::frame::XFrame > xFrame (m_xFrame.get() , css::uno::UNO_QUERY); css::uno::Reference< css::awt::XWindow > xPluggWindow(m_xPluggWindow.get(), css::uno::UNO_QUERY); + css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR( m_xSMGR.get(), css::uno::UNO_QUERY); aReadLock.unlock(); // <- SAFE ---------------------------------- @@ -432,8 +434,21 @@ void StatusIndicatorFactory::implts_makeParentVisibleIfAllowed() // is visible too. impl_showProgress(); - if (xParentWindow.is()) - xParentWindow->setVisible(sal_True); + ::vos::OClearableGuard aSolarGuard(Application::GetSolarMutex()); + Window* pWindow = VCLUnoHelper::GetWindow(xParentWindow); + if ( pWindow ) + { + bool bForceFrontAndFocus(false); + ::comphelper::ConfigurationHelper::readDirectKey( + xSMGR, + ::rtl::OUString::createFromAscii("org.openoffice.Office.Common/View"), + ::rtl::OUString::createFromAscii("NewDocumentHandling"), + ::rtl::OUString::createFromAscii("ForceFocusAndToFront"), + ::comphelper::ConfigurationHelper::E_READONLY) >>= bForceFrontAndFocus; + + pWindow->Show(sal_True, bForceFrontAndFocus ? SHOW_FOREGROUNDTASK : 0 ); + } + /* #i75167# dont disturb window manager handling .-) css::uno::Reference< css::awt::XTopWindow > xParentWindowTop(xParentWindow, css::uno::UNO_QUERY); diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index 0af8ea0e6587..ee39e583e5e7 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -1740,14 +1740,28 @@ void LoadEnv::impl_reactForLoadingState() void LoadEnv::impl_makeFrameWindowVisible(const css::uno::Reference< css::awt::XWindow >& xWindow , sal_Bool bForceToFront) { - css::uno::Reference< css::awt::XTopWindow > xTopWindow(xWindow, css::uno::UNO_QUERY); - - if (xWindow.is()) - xWindow->setVisible(sal_True); - - if (xTopWindow.is() && bForceToFront) - xTopWindow->toFront(); + // SAFE -> ---------------------------------- + ReadGuard aReadLock(m_aLock); + css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR( m_xSMGR.get(), css::uno::UNO_QUERY ); + aReadLock.unlock(); + // <- SAFE ---------------------------------- + ::vos::OClearableGuard aSolarGuard(Application::GetSolarMutex()); + Window* pWindow = VCLUnoHelper::GetWindow(xWindow); + if ( pWindow ) + { + bool bForceFrontAndFocus(false); + css::uno::Any a = ::comphelper::ConfigurationHelper::readDirectKey( + xSMGR, + ::rtl::OUString::createFromAscii("org.openoffice.Office.Common/View"), + ::rtl::OUString::createFromAscii("NewDocumentHandling"), + ::rtl::OUString::createFromAscii("ForceFocusAndToFront"), + ::comphelper::ConfigurationHelper::E_READONLY); + a >>= bForceFrontAndFocus; + + pWindow->Show(sal_True, (bForceFrontAndFocus || bForceToFront) ? SHOW_FOREGROUNDTASK : 0 ); + } + /* #i19976# We tried to prevent a toFront() call in case the user putted the loading document into the background .. -- cgit From 5074096e42b7b91f50d8e9f1be02e87233d8e60f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 22 Oct 2009 16:23:16 +0200 Subject: #i105747# grab focus to first button if backing window gets focused --- framework/source/services/backingwindow.cxx | 7 +++++++ framework/source/services/backingwindow.hxx | 1 + 2 files changed, 8 insertions(+) (limited to 'framework') diff --git a/framework/source/services/backingwindow.cxx b/framework/source/services/backingwindow.cxx index 40e4a9f7a6b9..c5d845a9d333 100644 --- a/framework/source/services/backingwindow.cxx +++ b/framework/source/services/backingwindow.cxx @@ -231,6 +231,13 @@ BackingWindow::~BackingWindow() delete mpAccExec; } +void BackingWindow::GetFocus() +{ + if( IsVisible() ) + maWriterButton.GrabFocus(); + Window::GetFocus(); +} + class ImageContainerRes : public Resource { public: diff --git a/framework/source/services/backingwindow.hxx b/framework/source/services/backingwindow.hxx index 63cfa0742e35..0b9afa6d38de 100644 --- a/framework/source/services/backingwindow.hxx +++ b/framework/source/services/backingwindow.hxx @@ -173,6 +173,7 @@ namespace framework virtual void DataChanged( const DataChangedEvent& rDCEvt ); virtual Window* GetParentLabelFor( const Window* pLabel ) const; virtual Window* GetParentLabeledBy( const Window* pLabeled ) const; + virtual void GetFocus(); void setOwningFrame( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& xFrame ); }; -- cgit From 3a9b9be6eae79098781092c3564c3f8206186f6b Mon Sep 17 00:00:00 2001 From: os Date: Fri, 30 Oct 2009 14:49:21 +0100 Subject: #i103838# nothing to dispatch if xPopupMenu.execute() returns NULL --- framework/source/uielement/langselectionstatusbarcontroller.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'framework') diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx b/framework/source/uielement/langselectionstatusbarcontroller.cxx index bccd553b57d3..b87a6e333f11 100644 --- a/framework/source/uielement/langselectionstatusbarcontroller.cxx +++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx @@ -337,7 +337,7 @@ void LangSelectionStatusbarController::LangMenu()throw (::com::sun::star::uno::R mRectangle.Y = mMousePos.Y(); sal_Int16 nId = xPopupMenu->execute( xParent, mRectangle, com::sun::star::awt::PopupMenuDirection::EXECUTE_UP+16 ); //click "More..." - if ( m_xFrame.is() ) + if ( nId && m_xFrame.is() ) { uno::Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); util::URL aURL; -- cgit From 7b39c8dc2d865324cab015c2a2ed04d26376cb44 Mon Sep 17 00:00:00 2001 From: mb93783 Date: Tue, 3 Nov 2009 18:41:58 +0100 Subject: some fixes for warnings and errors found while building on more platforms --- framework/source/layoutmanager/layoutmanager.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'framework') diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 0887433692b9..9c3c85008569 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -455,7 +455,7 @@ LayoutManager::LayoutManager( const Reference< XMultiServiceFactory >& xServiceM m_pMiscOptions = new SvtMiscOptions(); - m_pMiscOptions->AddListener( LINK( this, LayoutManager, OptionsChanged ) ); + m_pMiscOptions->AddListenerLink( LINK( this, LayoutManager, OptionsChanged ) ); Application::AddEventListener( LINK( this, LayoutManager, SettingsChanged ) ); m_eSymbolsSize = m_pMiscOptions->GetSymbolsSize(); m_eSymbolsStyle = m_pMiscOptions->GetCurrentSymbolsStyle(); @@ -469,7 +469,7 @@ LayoutManager::~LayoutManager() Application::RemoveEventListener( LINK( this, LayoutManager, SettingsChanged ) ); if ( m_pMiscOptions ) { - m_pMiscOptions->RemoveListener( LINK( this, LayoutManager, OptionsChanged ) ); + m_pMiscOptions->RemoveListenerLink( LINK( this, LayoutManager, OptionsChanged ) ); delete m_pMiscOptions; m_pMiscOptions = 0; } @@ -7127,7 +7127,7 @@ throw( RuntimeException ) Application::RemoveEventListener( LINK( this, LayoutManager, SettingsChanged ) ); if ( m_pMiscOptions ) { - m_pMiscOptions->RemoveListener( LINK( this, LayoutManager, OptionsChanged ) ); + m_pMiscOptions->RemoveListenerLink( LINK( this, LayoutManager, OptionsChanged ) ); delete m_pMiscOptions; m_pMiscOptions = 0; } -- cgit From 820bd98dc89219439df5bb460e5bcbbfe71d1845 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Mon, 9 Nov 2009 18:22:51 +0100 Subject: vcl107: #i91205# add document path menu on Mac --- framework/source/helper/titlebarupdate.cxx | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'framework') diff --git a/framework/source/helper/titlebarupdate.cxx b/framework/source/helper/titlebarupdate.cxx index c57840b4d442..feec90e5a167 100644 --- a/framework/source/helper/titlebarupdate.cxx +++ b/framework/source/helper/titlebarupdate.cxx @@ -371,6 +371,12 @@ void TitleBarUpdate::impl_updateIcon(const css::uno::Reference< css::frame::XFra { WorkWindow* pWorkWindow = (WorkWindow*)pWindow; pWorkWindow->SetIcon( (sal_uInt16)nIcon ); + + css::uno::Reference< css::frame::XModel > xModel = xController->getModel(); + rtl::OUString aURL; + if( xModel.is() ) + aURL = xModel->getURL(); + pWorkWindow->SetRepresentedURL( aURL ); } aSolarLock.clear(); -- cgit From a4d4ea40f2e8b5a3b3ea469bfa36104d751b6d96 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Wed, 11 Nov 2009 07:25:37 +0100 Subject: #i103496#: sandbox removed --- framework/qa/complex/api_internal/makefile.mk | 2 +- framework/qa/complex/broken_document/makefile.mk | 2 +- framework/qa/complex/contextMenuInterceptor/makefile.mk | 2 +- framework/qa/complex/disposing/makefile.mk | 2 +- framework/qa/complex/framework/recovery/makefile.mk | 2 +- framework/qa/complex/imageManager/interfaces/makefile.mk | 2 +- framework/qa/complex/imageManager/makefile.mk | 2 +- framework/qa/complex/path_settings/makefile.mk | 2 +- framework/qa/complex/path_substitution/makefile.mk | 2 +- framework/qa/complex/sequence/makefile.mk | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) (limited to 'framework') diff --git a/framework/qa/complex/api_internal/makefile.mk b/framework/qa/complex/api_internal/makefile.mk index 36556d6f03fe..2178f1eefb91 100755 --- a/framework/qa/complex/api_internal/makefile.mk +++ b/framework/qa/complex/api_internal/makefile.mk @@ -40,7 +40,7 @@ PACKAGE = complex$/api_internal #----- compile .java files ----------------------------------------- -JARFILES = mysql.jar sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar mysql.jar +JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar mysql.jar JAVAFILES = CheckAPI.java JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) diff --git a/framework/qa/complex/broken_document/makefile.mk b/framework/qa/complex/broken_document/makefile.mk index 6f20fc5aa474..3fe22b6adb74 100755 --- a/framework/qa/complex/broken_document/makefile.mk +++ b/framework/qa/complex/broken_document/makefile.mk @@ -40,7 +40,7 @@ PACKAGE = complex$/broken_document #----- compile .java files ----------------------------------------- -JARFILES = mysql.jar sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar +JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar JAVAFILES = LoadDocument.java JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) diff --git a/framework/qa/complex/contextMenuInterceptor/makefile.mk b/framework/qa/complex/contextMenuInterceptor/makefile.mk index b9cfad982ded..e95e37191138 100644 --- a/framework/qa/complex/contextMenuInterceptor/makefile.mk +++ b/framework/qa/complex/contextMenuInterceptor/makefile.mk @@ -40,7 +40,7 @@ PACKAGE = contextMenuInterceptor #----- compile .java files ----------------------------------------- -JARFILES = mysql.jar mysql.jar sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar +JARFILES = mysql.jar mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar JAVAFILES = ContextMenuInterceptor.java CheckContextMenuInterceptor.java JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) diff --git a/framework/qa/complex/disposing/makefile.mk b/framework/qa/complex/disposing/makefile.mk index 1dd1194db1af..7f686ff5f6d8 100755 --- a/framework/qa/complex/disposing/makefile.mk +++ b/framework/qa/complex/disposing/makefile.mk @@ -40,7 +40,7 @@ PACKAGE = complex$/disposing #----- compile .java files ----------------------------------------- -JARFILES = mysql.jar sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar +JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar JAVAFILES = $(TARGET).java JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) diff --git a/framework/qa/complex/framework/recovery/makefile.mk b/framework/qa/complex/framework/recovery/makefile.mk index fb08f7438399..0b86efd4d05b 100755 --- a/framework/qa/complex/framework/recovery/makefile.mk +++ b/framework/qa/complex/framework/recovery/makefile.mk @@ -40,7 +40,7 @@ PACKAGE = complex$/framework$/recovery #----- compile .java files ----------------------------------------- -JARFILES = mysql.jar mysql.jar sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar +JARFILES = mysql.jar mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar JAVAFILES = RecoveryTest.java RecoveryTools.java CrashThread.java TimeoutThread.java KlickButtonThread.java JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) diff --git a/framework/qa/complex/imageManager/interfaces/makefile.mk b/framework/qa/complex/imageManager/interfaces/makefile.mk index d9da36437e25..49a28defb9dd 100755 --- a/framework/qa/complex/imageManager/interfaces/makefile.mk +++ b/framework/qa/complex/imageManager/interfaces/makefile.mk @@ -40,7 +40,7 @@ PACKAGE = imageManager$/interfaces #----- compile .java files ----------------------------------------- -JARFILES = sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar +JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar JAVAFILES = _XComponent.java _XUIConfiguration.java _XImageManager.java \ _XUIConfigurationPersistence.java _XInitialization.java _XTypeProvider.java diff --git a/framework/qa/complex/imageManager/makefile.mk b/framework/qa/complex/imageManager/makefile.mk index eb52b2beba1d..8537d18abc69 100755 --- a/framework/qa/complex/imageManager/makefile.mk +++ b/framework/qa/complex/imageManager/makefile.mk @@ -40,7 +40,7 @@ PACKAGE = imageManager #----- compile .java files ----------------------------------------- -JARFILES = mysql.jar mysql.jar sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar +JARFILES = mysql.jar mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar JAVAFILES = CheckImageManager.java JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) diff --git a/framework/qa/complex/path_settings/makefile.mk b/framework/qa/complex/path_settings/makefile.mk index 605c95a68468..8f6ee0302f87 100755 --- a/framework/qa/complex/path_settings/makefile.mk +++ b/framework/qa/complex/path_settings/makefile.mk @@ -40,7 +40,7 @@ PACKAGE = complex$/path_settings #----- compile .java files ----------------------------------------- -JARFILES = sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar mysql.jar +JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar mysql.jar JAVAFILES = PathSettingsTest.java JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) diff --git a/framework/qa/complex/path_substitution/makefile.mk b/framework/qa/complex/path_substitution/makefile.mk index 3ca7dadd9953..453ae89d270c 100755 --- a/framework/qa/complex/path_substitution/makefile.mk +++ b/framework/qa/complex/path_substitution/makefile.mk @@ -40,7 +40,7 @@ PACKAGE = complex$/path_substitution #----- compile .java files ----------------------------------------- -JARFILES = sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar mysql.jar +JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar mysql.jar JAVAFILES = PathSubstitutionTest.java JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) diff --git a/framework/qa/complex/sequence/makefile.mk b/framework/qa/complex/sequence/makefile.mk index 97b9e7dbb220..959ea5cba57e 100755 --- a/framework/qa/complex/sequence/makefile.mk +++ b/framework/qa/complex/sequence/makefile.mk @@ -40,7 +40,7 @@ PACKAGE = complex$/sequence #----- compile .java files ----------------------------------------- -JARFILES = mysql.jar sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar CheckSequenceOfEnum.jar +JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar CheckSequenceOfEnum.jar JAVAFILES = CheckSequenceOfEnum.java ENUMSEQUENCEIDL = com.sun.star.enumexample.XEnumSequence -- cgit From ee56b6b0862f2c3d92cb535542c124db739819cf Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Fri, 20 Nov 2009 09:22:11 +0000 Subject: #i107003# Make toolbar invisible before calling doLazyDelete. This prevents possible crashes in scenarios where a modal dialog is visible. --- framework/source/uielement/toolbarmanager.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'framework') diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 55c8d16af2ec..294ab6ef3b74 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -341,9 +341,11 @@ void ToolBarManager::Destroy() delete static_cast< AddonsParams* >( m_pToolBar->GetItemData( nItemId )); } + // Hide toolbar as lazy delete can destroy the toolbar much later. + m_pToolBar->Hide(); /* #i99167# removed change for i93173 since there is some weird crash */ // #i93173# delete toolbar lazily as we can still be in one of its handlers - m_pToolBar->doLazyDelete(); + m_pToolBar->doLazyDelete(); Link aEmpty; m_pToolBar->SetSelectHdl( aEmpty ); -- cgit From f565a4b3d9b47ca3336df4f8d8d56d4e2dcceec5 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Wed, 25 Nov 2009 14:05:01 +0000 Subject: #i107087# TabWindowService must set member pointer to zero on VCLEVENT_OBJECT_DYING. The window life time is controlled by the docking window! Adding missing RemoveEventListener call. --- framework/inc/classes/fwktabwindow.hxx | 1 + framework/inc/services/tabwindowservice.hxx | 91 +++++++++++++------------- framework/source/classes/fwktabwindow.cxx | 6 +- framework/source/services/tabwindowservice.cxx | 27 +++++--- 4 files changed, 71 insertions(+), 54 deletions(-) (limited to 'framework') diff --git a/framework/inc/classes/fwktabwindow.hxx b/framework/inc/classes/fwktabwindow.hxx index 80e4b8144bb0..ecd9acecd7b9 100644 --- a/framework/inc/classes/fwktabwindow.hxx +++ b/framework/inc/classes/fwktabwindow.hxx @@ -125,6 +125,7 @@ public: ~FwkTabWindow(); void AddEventListener( const Link& rEventListener ); + void RemoveEventListener( const Link& rEventListener ); FwkTabPage* AddTabPage( sal_Int32 nIndex, const css::uno::Sequence< css::beans::NamedValue >& rProperties ); void ActivatePage( sal_Int32 nIndex ); void RemovePage( sal_Int32 nIndex ); diff --git a/framework/inc/services/tabwindowservice.hxx b/framework/inc/services/tabwindowservice.hxx index 8423a01f1793..f6b930906ca3 100644 --- a/framework/inc/services/tabwindowservice.hxx +++ b/framework/inc/services/tabwindowservice.hxx @@ -48,13 +48,13 @@ #include #include #include -#include +#include #include - + //_________________________________________________________________________________________________________________ // interface includes //_________________________________________________________________________________________________________________ - + #include #include #include @@ -62,7 +62,7 @@ //_________________________________________________________________________________________________________________ // other includes //_________________________________________________________________________________________________________________ - + #include #include @@ -81,31 +81,31 @@ namespace framework{ //_________________________________________________________________________________________________________________ struct TTabPageInfo -{ - public: - - TTabPageInfo() - : m_nIndex ( -1 ) - , m_bCreated (sal_False) - , m_pPage ( NULL ) - , m_lProperties ( ) - {} - - TTabPageInfo(::sal_Int32 nID) - : m_nIndex ( nID ) - , m_bCreated (sal_False) - , m_pPage ( NULL ) - , m_lProperties ( ) - {} - - public: - - ::sal_Int32 m_nIndex; +{ + public: + + TTabPageInfo() + : m_nIndex ( -1 ) + , m_bCreated (sal_False) + , m_pPage ( NULL ) + , m_lProperties ( ) + {} + + TTabPageInfo(::sal_Int32 nID) + : m_nIndex ( nID ) + , m_bCreated (sal_False) + , m_pPage ( NULL ) + , m_lProperties ( ) + {} + + public: + + ::sal_Int32 m_nIndex; ::sal_Bool m_bCreated; FwkTabPage* m_pPage; css::uno::Sequence< css::beans::NamedValue > m_lProperties; -}; - +}; + typedef ::std::hash_map< ::sal_Int32 , TTabPageInfo , Int32HashCode , @@ -118,10 +118,11 @@ typedef ::std::hash_map< ::sal_Int32 , class TabWindowService : public css::lang::XTypeProvider , public css::lang::XServiceInfo , public css::awt::XSimpleTabController + , public css::lang::XComponent , public ThreadHelpBase , public TransactionBase - , public PropertySetHelper - , public ::cppu::OWeakObject + , public PropertySetHelper + , public ::cppu::OWeakObject { //------------------------------------------------------------------------------------------------------------- // public methods @@ -132,7 +133,7 @@ class TabWindowService : public css::lang::XTypeProvider //--------------------------------------------------------------------------------------------------------- // constructor / destructor //--------------------------------------------------------------------------------------------------------- - + TabWindowService( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); virtual ~TabWindowService(); @@ -186,8 +187,8 @@ class TabWindowService : public css::lang::XTypeProvider DECL_DLLPRIVATE_LINK( EventListener, VclSimpleEvent * ); - void impl_checkTabIndex (::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException); - TTabPageInfoHash::iterator impl_getTabPageInfo(::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException); + void impl_checkTabIndex (::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException); + TTabPageInfoHash::iterator impl_getTabPageInfo(::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException); FwkTabWindow* mem_TabWin (); /* ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); @@ -203,26 +204,26 @@ class TabWindowService : public css::lang::XTypeProvider private: /// reference to factory, which has created this instance - css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; - + css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; + /// the tab window as XWindow ( to hold window* alive !) - css::uno::Reference< css::awt::XWindow > m_xTabWin; - - /// the VCL tab window - FwkTabWindow* m_pTabWin; - - /// container of inserted tab pages - TTabPageInfoHash m_lTabPageInfos; - + css::uno::Reference< css::awt::XWindow > m_xTabWin; + + /// the VCL tab window + FwkTabWindow* m_pTabWin; + + /// container of inserted tab pages + TTabPageInfoHash m_lTabPageInfos; + /// container of the added TabListener ::cppu::OMultiTypeInterfaceContainerHelper m_lListener; - + /// counter of the tabpage indexes - ::sal_Int32 m_nPageIndexCounter; - + ::sal_Int32 m_nPageIndexCounter; + /// index of the current active page ::sal_Int32 m_nCurrentPageIndex; - + /// title of the tabcontrolled window ::rtl::OUString m_sTitle; diff --git a/framework/source/classes/fwktabwindow.cxx b/framework/source/classes/fwktabwindow.cxx index d737a2d77308..c841e6fb0b8d 100644 --- a/framework/source/classes/fwktabwindow.cxx +++ b/framework/source/classes/fwktabwindow.cxx @@ -65,7 +65,6 @@ namespace framework { // class FwkTabControl --------------------------------------------------- - FwkTabControl::FwkTabControl( Window* pParent, const ResId& rResId ) : TabControl( pParent, rResId ) @@ -336,6 +335,11 @@ void FwkTabWindow::AddEventListener( const Link& rEventListener ) m_aTabCtrl.AddEventListener( rEventListener ); } +void FwkTabWindow::RemoveEventListener( const Link& rEventListener ) +{ + m_aTabCtrl.RemoveEventListener( rEventListener ); +} + // ----------------------------------------------------------------------- FwkTabPage* FwkTabWindow::AddTabPage( sal_Int32 nIndex, const uno::Sequence< beans::NamedValue >& rProperties ) diff --git a/framework/source/services/tabwindowservice.cxx b/framework/source/services/tabwindowservice.cxx index fb3c08876687..af026ee2afb0 100644 --- a/framework/source/services/tabwindowservice.cxx +++ b/framework/source/services/tabwindowservice.cxx @@ -75,18 +75,20 @@ namespace framework{ // css::uno::XInterface, XTypeProvider, XServiceInfo //***************************************************************************************************************** -DEFINE_XINTERFACE_5 ( TabWindowService , +DEFINE_XINTERFACE_6 ( TabWindowService , OWeakObject , DIRECT_INTERFACE(css::lang::XTypeProvider ), DIRECT_INTERFACE(css::lang::XServiceInfo ), + DIRECT_INTERFACE(css::lang::XComponent), DIRECT_INTERFACE(css::awt::XSimpleTabController), DIRECT_INTERFACE(css::beans::XPropertySet ), DIRECT_INTERFACE(css::beans::XPropertySetInfo ) ) -DEFINE_XTYPEPROVIDER_5 ( TabWindowService , +DEFINE_XTYPEPROVIDER_6 ( TabWindowService , css::lang::XTypeProvider , css::lang::XServiceInfo , + css::lang::XComponent , css::awt::XSimpleTabController , css::beans::XPropertySet , css::beans::XPropertySetInfo @@ -100,7 +102,7 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( TabWindowService , DEFINE_INIT_SERVICE ( TabWindowService, { - impl_initializePropInfo(); + impl_initializePropInfo(); m_aTransactionManager.setWorkingMode( E_WORK ); } ) @@ -141,7 +143,7 @@ TabWindowService::TabWindowService( const css::uno::Reference< css::lang::XMulti // destructor //***************************************************************************************************************** TabWindowService::~TabWindowService() -{ +{ } //***************************************************************************************************************** @@ -286,8 +288,11 @@ void SAL_CALL TabWindowService::dispose() m_lListener.disposeAndClear (aEvent); + if (m_pTabWin) + m_pTabWin->RemoveEventListener( LINK( this, TabWindowService, EventListener ) ); + m_pTabWin = NULL; - m_xTabWin.clear (); + m_xTabWin.clear(); } //***************************************************************************************************************** @@ -357,6 +362,7 @@ css::uno::Any SAL_CALL TabWindowService::impl_getPropertyValue(const ::rtl::OUSt //***************************************************************************************************************** IMPL_LINK( TabWindowService, EventListener, VclSimpleEvent*, pEvent ) { + if ( !pEvent && !pEvent->ISA(VclWindowEvent)) return 0; @@ -369,6 +375,11 @@ IMPL_LINK( TabWindowService, EventListener, VclSimpleEvent*, pEvent ) if (nEventId == VCLEVENT_OBJECT_DYING) { m_lListener.disposeAndClear (aEvent); + + m_pTabWin->RemoveEventListener( LINK( this, TabWindowService, EventListener ) ); + m_pTabWin = NULL; + m_xTabWin.clear(); + return 0; } @@ -454,9 +465,9 @@ FwkTabWindow* TabWindowService::mem_TabWin () FwkTabWindow* pWin = NULL; if ( ! m_xTabWin.is ()) - { - Window* pFakeParent = dynamic_cast< Window* >(Application::GetDefaultDevice ()); - + { + Window* pFakeParent = dynamic_cast< Window* >(Application::GetDefaultDevice ()); + m_pTabWin = new FwkTabWindow (pFakeParent); m_xTabWin = VCLUnoHelper::GetInterface (m_pTabWin); -- cgit From 84c0ebe7d3e7dbc3796967d52f9535fecc9e6947 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Thu, 26 Nov 2009 14:14:53 +0000 Subject: #i107087# Remove event listener from tab window on TabWindowService dtor --- framework/source/services/tabwindowservice.cxx | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'framework') diff --git a/framework/source/services/tabwindowservice.cxx b/framework/source/services/tabwindowservice.cxx index af026ee2afb0..dfce492ddcd7 100644 --- a/framework/source/services/tabwindowservice.cxx +++ b/framework/source/services/tabwindowservice.cxx @@ -144,6 +144,11 @@ TabWindowService::TabWindowService( const css::uno::Reference< css::lang::XMulti //***************************************************************************************************************** TabWindowService::~TabWindowService() { + // SAFE-> + ResetableGuard aGuard(m_aLock); + + if (m_pTabWin) + m_pTabWin->RemoveEventListener( LINK( this, TabWindowService, EventListener ) ); } //***************************************************************************************************************** -- cgit From 245aaeb38f6d1f0ed1ac892da302772e6f71a9f3 Mon Sep 17 00:00:00 2001 From: Mikhail Voitenko Date: Thu, 26 Nov 2009 14:15:24 +0000 Subject: #i105172# try to store documents on shutdown --- framework/source/services/sessionlistener.cxx | 50 ++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 9 deletions(-) (limited to 'framework') diff --git a/framework/source/services/sessionlistener.cxx b/framework/source/services/sessionlistener.cxx index ad0016fc0af6..4a58a483ea3c 100644 --- a/framework/source/services/sessionlistener.cxx +++ b/framework/source/services/sessionlistener.cxx @@ -60,6 +60,7 @@ #include #include #include +#include #include #include #include @@ -234,6 +235,46 @@ void SAL_CALL SessionListener::doSave( sal_Bool bShutdown, sal_Bool /*bCancelabl throw (RuntimeException) { if (bShutdown) + { + if ( m_rSessionManager.is() ) + m_rSessionManager->queryInteraction( static_cast< css::frame::XSessionManagerListener* >( this ) ); + + } + // we don't have anything to do so tell the session manager we're done + else if( m_rSessionManager.is() ) + m_rSessionManager->saveDone( this ); +} + + + +void SAL_CALL SessionListener::approveInteraction( sal_Bool bInteractionGranted ) + throw (RuntimeException) +{ + sal_Bool bClosed = sal_False; + if ( bInteractionGranted ) + { + ResetableGuard aGuard(m_aLock); + + // close the office documents in normal way + try + { + css::uno::Reference< css::frame::XDesktop > xDesktop( m_xSMGR->createInstance(SERVICENAME_DESKTOP), css::uno::UNO_QUERY_THROW); + bClosed = xDesktop->terminate(); + + if ( m_rSessionManager.is() ) + { + // false means that the application closing has been cancelled + if ( !bClosed ) + m_rSessionManager->cancelShutdown(); + else + m_rSessionManager->interactionDone( this ); + } + } + catch( css::uno::Exception& ) + {} + } + + if ( !bClosed ) { sal_Bool bDispatched = sal_False; ResetableGuard aGuard(m_aLock); @@ -262,17 +303,8 @@ void SAL_CALL SessionListener::doSave( sal_Bool bShutdown, sal_Bool /*bCancelabl m_rSessionManager->saveDone(this); } } - // we don't have anything to do so tell the session manager we're done - else if( m_rSessionManager.is() ) - m_rSessionManager->saveDone( this ); } - - -void SAL_CALL SessionListener::approveInteraction( sal_Bool /*bInteractionGranted*/ ) - throw (RuntimeException) -{} - void SessionListener::shutdownCanceled() throw (RuntimeException) {} -- cgit From d5c799bd36d600f4ebbce76f12333324bc1f6c09 Mon Sep 17 00:00:00 2001 From: Jens-Heiner Rechtien Date: Fri, 27 Nov 2009 12:39:32 +0000 Subject: dba33a: summary migration from SVN 2009-11-06 13:10:39 +0000 msc r277387 : minor fix for automatic test 2009-11-06 13:09:33 +0000 msc r277385 : minor fix for automatic test 2009-11-06 12:30:57 +0000 fs r277383 : argh. On some virtual machines, waiting 5 seconds for the event to arrive is not enough. Increasing the timeout ... 2009-11-06 12:13:34 +0000 fs r277382 : this diagnostic code should not have slipped in 2009-11-05 13:21:06 +0000 fs r277369 : SHL2NOCHECK=TRUE (requested by hjs) 2009-11-04 14:09:46 +0000 msc r277355 : minor fix for automatic testing 2009-11-04 13:23:02 +0000 msc r277352 : minor fix for automatic testing 2009-11-04 10:53:28 +0000 msc r277341 : minor fix for automated testscript 2009-11-04 08:30:58 +0000 msc r277333 : minor fix for automatic test 2009-11-04 08:15:43 +0000 msc r277332 : minor fix for automatic test 2009-11-03 14:25:44 +0000 fs r277324 : #i10000# 2009-11-03 09:47:47 +0000 fs r277315 : found yet another help ID zombie ... moved formhelpid.hrc content to propctrlr.hrc, where it belongs 2009-11-03 08:50:24 +0000 fs r277312 : use createTempFileURL, which cares for some more specialities ... 2009-11-03 08:44:55 +0000 fs r277311 : when creating a temp file for purpose of getting a temp file URL, the delete the file immediately. On some machines/JVMs, the file exists, with write access denied, which isn't Good (TM) 2009-10-22 13:06:17 +0000 fs r277126 : removed wrong assertion 2009-10-21 08:10:35 +0000 fs r277077 : reverted the previous change, which was nonsense 2009-10-21 07:19:43 +0000 fs r277076 : export the component_foo functions, now that some of the objects are built with VISIBILITY_HIDDEN=TRUE 2009-10-21 07:08:35 +0000 fs r277075 : spare useless call 2009-10-20 21:26:31 +0000 fs r277072 : #i10000# 2009-10-20 08:06:04 +0000 fs r277039 : CWS-TOOLING: rebase CWS dba33a to trunk@277035 (milestone: DEV300:m62) 2009-10-16 09:55:25 +0000 fs r276960 : remove one of the superfluous implts_doLayout calls introduced with the previous patch 2009-10-15 13:18:52 +0000 fs r276941 : removed the basic tests. According to cn, they're not used anymore (for a long time), and according to 'du -h', they take up 6.0M on my hard disc. For too much for useless code, /me thinks. 2009-10-15 13:06:51 +0000 fs r276940 : #i10000# remove useless include (otherwise the compiler warning it provokes would need to be fixed by declaring VISIBILITY_HIDDEN=TRUE in the makefile.mk) 2009-10-15 12:52:39 +0000 fs r276939 : #i10000# 2009-10-15 12:44:26 +0000 fs r276938 : #i10000# 2009-10-15 12:00:33 +0000 fs r276936 : #i10000# 2009-10-15 10:31:37 +0000 fs r276934 : #i105259# prepare for the Hidden arg 2009-10-15 10:31:05 +0000 fs r276933 : IsMaximized -> const 2009-10-15 09:50:15 +0000 fs r276932 : during #i105259#: introduce an option to the layout manager to preserve, if possible, the size of the content window when layouting. Enable this option for embedded (SFX-based) documents opened for outplace editing. (the option is incompatible with in-place editing, anyway) This is because such embedded objects couple the (content) window size to the VisAreaSize, in that both are used interchangeably. When an embedded object is closed, it remembers the VisAreaSize, and restores it upon next open. This, however, leads to different content window sizes when the window is closed with another toolbar set than used during opening. This patch here prevents those different content window sizes. Also, now the content window size doesn't change when, explicitly or implicitly, a toolbar is shown or hidden. Instead, the content window size stays the same, and the container window size is adjusted. 2009-10-15 09:32:41 +0000 fs r276931 : during #i105259#: UNO access to more attributes of top windows 2009-10-15 09:30:28 +0000 fs r276930 : indention corrected (better readable) 2009-10-15 09:26:46 +0000 fs r276929 : during #i105259#: access to more attributes of top windows 2009-10-14 10:04:39 +0000 fs r276889 : connecting via services manager, not naming service 2009-10-12 11:31:08 +0000 fs r276831 : during #i105806# FillPropertySet: do not attempt to set *AutoStyleName if it doesn't exist 2009-10-12 11:24:44 +0000 fs r276830 : #i105806# getPropertyValue: throw an UnknownPropertyException for, well, unknown properties 2009-10-08 08:20:58 +0000 fs r276774 : implSubmit: re-throw WrappedTargetExceptions unmodified 2009-10-07 19:19:42 +0000 fs r276770 : #i105198# do not pass an CommandType if we do not have a command 2009-10-07 17:39:36 +0000 fs r276768 : export the OWeakObject::disposeWeakConnectionPoint symbol 2009-10-07 12:59:17 +0000 fs r276754 : #i87693# 2009-10-07 11:19:22 +0000 fs r276752 : #i10000# 2009-10-07 10:21:08 +0000 fs r276748 : #105482# do not require a controller, at least not in *all* circumstances (executed reports have a model, the ReportDefinition, but no Controller) 2009-10-07 10:04:08 +0000 fs r276747 : copying the changes from CWS fwk121 herein, in particular the fix for issue #i105371# 2009-10-07 09:58:30 +0000 fs r276746 : copying the changes from CWS fwk121 herein, in particular the fix for issue #i105371# 2009-10-07 09:48:14 +0000 fs r276744 : removed (now) pointless assertion 2009-10-07 06:59:19 +0000 fs r276740 : export the OWeakObject::disposeWeakConnectionPoint symbol 2009-10-07 06:44:43 +0000 fs r276739 : OComponentHelper::release & WeakAggComponentImplHelperBase::release: when our ref count drops to 0, call OWeakObject's disposeWeakConnectionPoint before (temporarily) incrementing the ref count, again. This ensures that our adapter cannot create references to the dying object anymore. (A complex test case in dbaccess (#i105505#) triggered such a situation, but in another class using an analogous release/dispose/destroy pattern, namely WeakComponentImplHelperBase) 2009-10-07 06:37:20 +0000 fs r276738 : found during some new complex test cases: call disposeWeakConnectionPoint before actually starting to destroy the object, this ensures no other threads will resurrect it while it is dying 2009-10-06 21:58:24 +0000 fs r276734 : oops, two small corrections to the previous fix (hey, complex test cases are cool) 2009-10-06 21:51:16 +0000 fs r276733 : log the name of the data source which cannot be revoked 2009-10-06 21:50:41 +0000 fs r276732 : more detailed error message when cleanup fails 2009-10-06 21:50:01 +0000 fs r276731 : reworked the ModelImpl caching. The new and improved UNO API test for css.sdb.RowSet revealed some inconsistencies, in whether the objects are cached by their URL, or by their registration name. This has been changed to caching by registration name. 2009-10-06 13:50:34 +0000 fs r276714 : print diagnostics when we cannot clean up the test case 2009-10-06 13:45:02 +0000 fs r276713 : this test failed all the time, since the core (rightfully) threw an exception. Disabled it for the moment, until issue 84253 is fixed 2009-10-06 12:52:46 +0000 fs r276711 : rewrote this test. Now we do not re-use the same .odb across different test cases, as this leads to unreliable (timing-dependent) results/failures. Instead, every test sets up a new odb file. Also, did some re-factoring, improved the cleanup code, and caught a few more errors. 2009-10-06 12:51:07 +0000 fs r276710 : DBTools taking a logger now 2009-10-06 12:50:42 +0000 fs r276709 : taking a PrintWriter for logging purpose 2009-10-06 12:50:03 +0000 fs r276708 : DBTools taking a logger now 2009-10-06 12:49:22 +0000 fs r276707 : typo 2009-10-06 12:49:03 +0000 fs r276706 : typo 2009-10-06 12:48:52 +0000 fs r276705 : wrappers around some database-related services - initial versions only, to evolve over time, and intended to finally replace the DBTools class 2009-10-06 12:48:02 +0000 fs r276704 : typo 2009-10-06 12:38:42 +0000 fs r276702 : some better diagnostics, done during getting the API tests to work more reliably 2009-10-06 10:35:51 +0000 fs r276698 : when living in, e.g., the DataSourceBrowser, we can't expect to find an XModifiable2, so don't assert its existence 2009-10-05 12:47:52 +0000 oj r276677 : #i105607# check for read moved into if scope 2009-10-05 11:37:06 +0000 fs r276676 : when saving a file fails, retrieve the error message from the InteractionRequestStringResolver - this is better than any generic message we can create 2009-10-05 10:04:23 +0000 oj r276673 : #i105607# check for read moved into if scope 2009-10-05 09:46:17 +0000 fs r276671 : #i10000# 2009-10-05 08:43:58 +0000 fs r276664 : #i105505# release: dispose the (base classes) weak connection point before disposing ourself, and in particular before temporarily incrementing our ref count, again. This way, we prevent that a separate thread re-surrects us (using the weak connection point's queryAdapted) while we're in the process of destruction 2009-10-05 08:41:49 +0000 fs r276663 : #i105505# +disposeWeakConnectionPoint (outsourced into dedicated method from ::release) 2009-10-05 08:40:26 +0000 fs r276662 : no need to derived from OSubComponent, its features are not used, directly derive from WeakComponentImplFoo instead 2009-10-05 08:39:38 +0000 fs r276661 : #i105505# diagnostics 2009-10-05 08:39:16 +0000 fs r276660 : #i105505# +testDocumentRevenants 2009-10-05 08:36:01 +0000 fs r276659 : #i105560# reverted the removal of GenericController::openHelpAgent - this is needed in module reportdesign 2009-10-04 19:53:30 +0000 fs r276657 : #105560# remove unused code thanks to cmc@openoffice.org for submitting the patch 2009-10-04 19:50:28 +0000 fs r276656 : #i105550# remove unused 'fire' method (thanks to cmc) 2009-10-03 16:13:15 +0000 fs r276655 : CWS-TOOLING: rebase CWS dba33a to trunk@276429 (milestone: DEV300:m60) 2009-10-02 19:20:48 +0000 fs r276651 : #i104117# lotta changed IDs ... 2009-10-02 10:52:24 +0000 fs r276634 : #i105505# If a model is created, and is a revenant of a previous incarnation, then ensure it is properly initialized. In particular, in its ctor, set the state to "Initializing", not "Initialized", and then let the ModelImpl call attachResource. This ensures that the model is initialized completely, including firing the necessary events. 2009-10-02 10:51:08 +0000 fs r276633 : #i105505# always do an attachResource at the newly loaded model, even if it (internally) was not really loaded, but only a revenant of a previous incarnation of this document 2009-10-01 11:10:13 +0000 fs r276597 : do not rely on the name 'Standard' for the one and only form in a document 2009-10-01 10:36:29 +0000 fs r276590 : #i105509# don't rely on default form component names, use indexes 2009-10-01 09:12:20 +0000 fs r276582 : #i105505# 2009-09-30 07:55:21 +0000 fs r276542 : removed some unsed methods / spared some unnecessary pixel<->logic conversion 2009-09-30 07:53:22 +0000 fs r276541 : removed unneeded methods 2009-09-30 06:35:59 +0000 fs r276538 : #i10000# 2009-09-29 13:45:02 +0000 fs r276531 : refactored the Roadmap* classes, to be able to fix above-mentioned #i105113# 2009-09-29 10:27:10 +0000 fs r276520 : #i105367# 2009-09-29 08:46:45 +0000 fs r276510 : #i104956# cleaned up the makefiles 2009-09-28 21:00:07 +0000 fs r276505 : #i104117# sourced those IDs out from extension.hrc 2009-09-28 20:59:05 +0000 fs r276504 : no need to let one FREE... 2009-09-28 20:53:36 +0000 fs r276503 : #i104117# cleaned up the mess with help IDs in module extensions. Formerly, extensions used to use help IDs which were declared in module svx, and vice versa. Also, help ID ranges were not respected. 2009-09-28 11:25:36 +0000 fs r276489 : typo 2009-09-28 11:25:10 +0000 fs r276488 : #i105235# 2009-09-24 11:53:16 +0000 fs r276423 : #i105234# do not zoom the control when they view information is still uninitialized (happens at least in Writer when opening a form document) 2009-09-24 09:42:28 +0000 fs r276415 : #i105234# proper zoom handling for the nav bar 2009-09-24 09:42:19 +0000 fs r276414 : #i105234# setZoom: care for precision errors caused by implicit conversion float->double 2009-09-16 11:11:43 +0000 fs r276195 : #i105082# consolidated the sub storage handling, by delegating more functionality into the DocumentStorageAccess class. As a result, there won't be that many unnecessary commits anymore. Also, the two different storage caches (in ModelImpl::m_aStorages and DocumentStorageAccess::m_aExposedStorages) have been consolidated. This is not really part of the fix of issue 105082, but it helped reducing the calls to the storage/package implementation. 2009-09-15 21:42:27 +0000 fs r276190 : don't calculate space for BOLD if the text is not really bold (speeds up rendering for large tree structures) 2009-09-15 20:20:23 +0000 fs r276188 : getTypeInfo: fill m_aTypeInfoRows only if really all type infos could be retrieved 2009-09-15 20:19:29 +0000 fs r276187 : do not continue loading when the controller initialization throws an error 2009-09-14 12:25:57 +0000 fs r276119 : oops, this patch was not intended for this CWS 2009-09-14 12:13:57 +0000 fs r276114 : #cr6875455# introduce a ReferenceDevice property for various control models 2009-09-14 10:33:02 +0000 fs r276106 : removed dead file 2009-09-09 08:37:31 +0000 fs r275972 : remove OSL_TRACE in VCLXButton dtor 2009-09-08 11:19:17 +0000 oj r275926 : i76534# remove mnemonic from fixed text 2009-09-07 08:39:37 +0000 fs r275874 : create CWS dba33a from cws/dba32g@275857 (CWS: dba32g) --- framework/inc/macros/registration.hxx | 6 +- framework/inc/properties.h | 17 +- framework/inc/services.h | 1 + framework/inc/services/layoutmanager.hxx | 38 +-- framework/source/layoutmanager/layoutmanager.cxx | 302 +++++++++++------------ framework/source/layoutmanager/makefile.mk | 2 + framework/source/register/makefile.mk | 2 + framework/source/xml/menuconfiguration.cxx | 4 - 8 files changed, 178 insertions(+), 194 deletions(-) (limited to 'framework') diff --git a/framework/inc/macros/registration.hxx b/framework/inc/macros/registration.hxx index 7a48fad1f84c..d026c1b0f04c 100644 --- a/framework/inc/macros/registration.hxx +++ b/framework/inc/macros/registration.hxx @@ -139,7 +139,7 @@ ________________________________________________________________________________ // define helper to get information about service environment //***************************************************************************************************************** #define COMPONENTGETIMPLEMENTATIONENVIRONMENT \ - extern "C" void SAL_CALL component_getImplementationEnvironment( const sal_Char** ppEnvironmentTypeName , \ + extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( const sal_Char** ppEnvironmentTypeName , \ uno_Environment** ) \ { \ *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ; \ @@ -150,7 +150,7 @@ ________________________________________________________________________________ // define registration of service //***************************************************************************************************************** #define COMPONENTWRITEINFO( INFOS ) \ - extern "C" sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/ , \ + extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/ , \ void* pRegistryKey ) \ { \ LOG_REGISTRATION_WRITEINFO( "\t[start]\n" ) \ @@ -185,7 +185,7 @@ ________________________________________________________________________________ // define method to instanciate new services //***************************************************************************************************************** #define COMPONENTGETFACTORY( IFFACTORIES ) \ - extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplementationName , \ + extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplementationName , \ void* pServiceManager , \ void* /*pRegistryKey*/ ) \ { \ diff --git a/framework/inc/properties.h b/framework/inc/properties.h index d09fde5a5fc4..d2619cd9ee87 100644 --- a/framework/inc/properties.h +++ b/framework/inc/properties.h @@ -193,25 +193,26 @@ namespace framework{ //_______________________________________________ /** properties for "LayoutManager" class */ -#define LAYOUTMANAGER_PROPNAME_ASCII_MENUBARCLOSER "MenuBarCloser" -#define LAYOUTMANAGER_PROPNAME_ASCII_AUTOMATICTOOLBARS "AutomaticToolbars" -#define LAYOUTMANAGER_PROPNAME_ASCII_REFRESHVISIBILITY "RefreshContextToolbarVisibility" -#define LAYOUTMANAGER_PROPNAME_ASCII_HIDECURRENTUI "HideCurrentUI" -#define LAYOUTMANAGER_PROPNAME_ASCII_LOCKCOUNT "LockCount" +#define LAYOUTMANAGER_PROPNAME_ASCII_MENUBARCLOSER "MenuBarCloser" +#define LAYOUTMANAGER_PROPNAME_ASCII_AUTOMATICTOOLBARS "AutomaticToolbars" +#define LAYOUTMANAGER_PROPNAME_ASCII_REFRESHVISIBILITY "RefreshContextToolbarVisibility" +#define LAYOUTMANAGER_PROPNAME_ASCII_HIDECURRENTUI "HideCurrentUI" +#define LAYOUTMANAGER_PROPNAME_ASCII_LOCKCOUNT "LockCount" +#define LAYOUTMANAGER_PROPNAME_ASCII_PRESERVE_CONTENT_SIZE "PreserveContentSize" #define LAYOUTMANAGER_PROPNAME_MENUBARCLOSER ::rtl::OUString::createFromAscii( LAYOUTMANAGER_PROPNAME_ASCII_MENUBARCLOSER ) #define LAYOUTMANAGER_PROPNAME_AUTOMATICTOOLBARS ::rtl::OUString::createFromAscii( LAYOUTMANAGER_PROPNAME_ASCII_AUTOMATICTOOLBARS ) #define LAYOUTMANAGER_PROPNAME_REFRESHVISIBILITY ::rtl::OUString::createFromAscii( LAYOUTMANAGER_PROPNAME_ASCII_REFRESHVISIBILITY ) #define LAYOUTMANAGER_PROPNAME_HIDECURRENTUI ::rtl::OUString::createFromAscii( LAYOUTMANAGER_PROPNAME_ASCII_HIDECURRENTUI ) #define LAYOUTMANAGER_PROPNAME_LOCKCOUNT ::rtl::OUString::createFromAscii( LAYOUTMANAGER_PROPNAME_ASCII_LOCKCOUNT ) +#define LAYOUTMANAGER_PROPNAME_PRESERVE_CONTENT_SIZE ::rtl::OUString::createFromAscii( LAYOUTMANAGER_PROPNAME_ASCII_PRESERVE_CONTENT_SIZE ) #define LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER 0 #define LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS 1 #define LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY 2 #define LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI 3 #define LAYOUTMANAGER_PROPHANDLE_LOCKCOUNT 4 - -#define LAYOUTMANAGER_PROPCOUNT 5 +#define LAYOUTMANAGER_PROPHANDLE_PRESERVE_CONTENT_SIZE 5 //_______________________________________________ /** properties for "UICommandDescription" class */ @@ -271,7 +272,7 @@ namespace framework{ #define TABWINDOWSERVICE_PROPNAME_WINDOW ::rtl::OUString::createFromAscii( TABWINDOWSERVICE_PROPNAME_ASCII_WINDOW ) #define TABWINDOWSERVICE_PROPHANDLE_WINDOW 0 -#define TABWINDOWSERVICE_PROPCOUNT 1 +#define TABWINDOWSERVICE_PROPCOUNT 1 //_______________________________________________ /** properties of tabreg service */ diff --git a/framework/inc/services.h b/framework/inc/services.h index e9f3e1bfe3ce..70f4f8fde9a2 100644 --- a/framework/inc/services.h +++ b/framework/inc/services.h @@ -127,6 +127,7 @@ namespace framework{ #define SERVICENAME_IMAGEMANAGER DECLARE_ASCII("com.sun.star.ui.ImageManager" ) #define SERVICENAME_TABWINDOWSERVICE DECLARE_ASCII("com.sun.star.ui.dialogs.TabContainerWindow" ) #define SERVICENAME_WINDOWCONTENTFACTORYMANAGER DECLARE_ASCII("com.sun.star.ui.WindowContentFactoryManager" ) +#define SERVICENAME_DISPLAYACCESS DECLARE_ASCII("com.sun.star.awt.DisplayAccess" ) //_________________________________________________________________________________________________________________ // used implementationnames by framework diff --git a/framework/inc/services/layoutmanager.hxx b/framework/inc/services/layoutmanager.hxx index 86dec1a938bf..8c412e5d6237 100644 --- a/framework/inc/services/layoutmanager.hxx +++ b/framework/inc/services/layoutmanager.hxx @@ -69,6 +69,7 @@ #include #include #include +#include #include #include #include @@ -78,8 +79,9 @@ // other includes //_________________________________________________________________________________________________________________ #include +#include #include -#include +#include #include #include #include @@ -89,22 +91,23 @@ class MenuBar; namespace framework { class GlobalSettings; - class LayoutManager : public css::lang::XTypeProvider , - public css::lang::XServiceInfo , - public ::com::sun::star::frame::XLayoutManager , - public css::awt::XWindowListener , - public css::frame::XFrameActionListener , - public ::com::sun::star::ui::XUIConfigurationListener , - public ::com::sun::star::frame::XInplaceLayout , - public css::awt::XDockableWindowListener , - public ::com::sun::star::frame::XMenuBarMergingAcceptor, - public css::frame::XLayoutManagerEventBroadcaster , + typedef ::cppu::WeakImplHelper9 < ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::frame::XLayoutManager + , ::com::sun::star::awt::XWindowListener + , ::com::sun::star::frame::XFrameActionListener + , ::com::sun::star::ui::XUIConfigurationListener + , ::com::sun::star::frame::XInplaceLayout + , ::com::sun::star::awt::XDockableWindowListener + , ::com::sun::star::frame::XMenuBarMergingAcceptor + , ::com::sun::star::frame::XLayoutManagerEventBroadcaster + > LayoutManager_Base; + typedef ::comphelper::OPropertyContainer LayoutManager_PBase; + class LayoutManager : public LayoutManager_Base , // base classes // Order is neccessary for right initialization! private ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses. public ::cppu::OBroadcastHelper , - public ::cppu::OPropertySetHelper , // => XPropertySet / XFastPropertySet / XMultiPropertySet - public ::cppu::OWeakObject // => XWeak, XInterface + public LayoutManager_PBase { public: enum { DOCKINGAREAS_COUNT = 4 }; @@ -388,6 +391,7 @@ namespace framework // layouting methods sal_Bool implts_compareRectangles( const ::com::sun::star::awt::Rectangle& rRect1, const ::com::sun::star::awt::Rectangle& rRect2 ); + sal_Bool implts_resizeContainerWindow( const ::com::sun::star::awt::Size& rContainerSize, const ::com::sun::star::awt::Point& rComponentPos ); ::Size implts_getTopBottomDockingAreaSizes(); ::Size implts_getContainerWindowOutputSize(); ::com::sun::star::awt::Rectangle implts_getDockingAreaWindowSizes(); @@ -399,7 +403,8 @@ namespace framework void implts_findNextDockingPos( ::com::sun::star::ui::DockingArea DockingArea, const ::Size& aUIElementSize, ::Point& rVirtualPos, ::Point& rPixelPos ); ::com::sun::star::awt::Rectangle implts_calcDockingAreaSizes(); void implts_setDockingAreaWindowSizes( const com::sun::star::awt::Rectangle& rBorderSpace ); - sal_Bool implts_doLayout( sal_Bool bForceRequestBorderSpace ); + sal_Bool implts_doLayout( sal_Bool bForceRequestBorderSpace, sal_Bool bOuterResize ); + void implts_doLayout_notify( sal_Bool bOuterResize ); // internal methods to control status/progress bar ::Size implts_getStatusBarSize(); @@ -449,15 +454,15 @@ namespace framework virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); virtual ::com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException); - static const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > impl_getStaticPropertyDescriptor(); - css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; /** reference to factory, which has created this instance. */ css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; + css::uno::Reference< css::container::XIndexAccess > m_xDisplayAccess; css::uno::Reference< css::frame::XFrame > m_xFrame; css::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xModuleCfgMgr; css::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xDocCfgMgr; css::uno::WeakReference< css::frame::XModel > m_xModel; css::uno::Reference< css::awt::XWindow > m_xContainerWindow; + css::uno::Reference< css::awt::XTopWindow2 > m_xContainerTopWindow; css::uno::Reference< css::awt::XWindow > m_xDockAreaWindows[DOCKINGAREAS_COUNT]; sal_Int32 m_nLockCount; UIElementVector m_aUIElements; @@ -474,6 +479,7 @@ namespace framework bool m_bStoreWindowState; bool m_bHideCurrentUI; bool m_bGlobalSettings; + bool m_bPreserveContentSize; DockingOperation m_eDockOperation; UIElement m_aDockUIElement; css::awt::Rectangle m_aDockingArea; diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index fb10e4fae24c..491738dea73f 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -67,17 +67,13 @@ #include #include #include -#ifndef _COM_SUN_STAR_LANG_XYSTEMDEPENDENT_HPP_ #include -#endif #include #include #include #include #include -#ifndef _COM_SUN_STAR_UI_XMODULEUICONFIGURATIONMANAGER_HPP_ #include -#endif #include #include #include @@ -92,18 +88,18 @@ // other includes //_________________________________________________________________________________________________________________ #include +#include #include #include #include #include #include #include -#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include -#endif #include #include #include +#include #include #include @@ -354,40 +350,8 @@ static void impl_setDockingWindowVisibility( const css::uno::Reference< css::lan //***************************************************************************************************************** // XInterface, XTypeProvider, XServiceInfo //***************************************************************************************************************** -DEFINE_XINTERFACE_14 ( LayoutManager , - OWeakObject , - DIRECT_INTERFACE( css::lang::XTypeProvider ), - DIRECT_INTERFACE( css::lang::XServiceInfo ), - DIRECT_INTERFACE( ::com::sun::star::frame::XLayoutManager ), - DIRECT_INTERFACE( css::awt::XWindowListener ), - DIRECT_INTERFACE( css::frame::XFrameActionListener ), - DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfigurationListener ), - DIRECT_INTERFACE( ::com::sun::star::frame::XInplaceLayout ), - DIRECT_INTERFACE( css::awt::XDockableWindowListener ), - DIRECT_INTERFACE( ::com::sun::star::frame::XMenuBarMergingAcceptor ), - DIRECT_INTERFACE( css::frame::XLayoutManagerEventBroadcaster ), - DERIVED_INTERFACE( css::lang::XEventListener, css::frame::XFrameActionListener ), - DIRECT_INTERFACE( ::com::sun::star::beans::XMultiPropertySet ), - DIRECT_INTERFACE( ::com::sun::star::beans::XFastPropertySet ), - DIRECT_INTERFACE( ::com::sun::star::beans::XPropertySet ) - ) - -DEFINE_XTYPEPROVIDER_14 ( LayoutManager , - css::lang::XTypeProvider , - css::lang::XServiceInfo , - ::com::sun::star::frame::XLayoutManager , - css::awt::XWindowListener , - css::frame::XFrameActionListener , - css::lang::XEventListener , - ::com::sun::star::ui::XUIConfigurationListener , - ::com::sun::star::frame::XInplaceLayout , - css::awt::XDockableWindowListener , - ::com::sun::star::frame::XMenuBarMergingAcceptor , - css::frame::XLayoutManagerEventBroadcaster , - ::com::sun::star::beans::XMultiPropertySet , - ::com::sun::star::beans::XFastPropertySet , - ::com::sun::star::beans::XPropertySet - ) +IMPLEMENT_FORWARD_XTYPEPROVIDER2( LayoutManager, LayoutManager_Base, LayoutManager_PBase ) +IMPLEMENT_FORWARD_XINTERFACE2( LayoutManager, LayoutManager_Base, LayoutManager_PBase ) DEFINE_XSERVICEINFO_MULTISERVICE ( LayoutManager , ::cppu::OWeakObject , @@ -398,15 +362,14 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( LayoutManager DEFINE_INIT_SERVICE ( LayoutManager, {} ) -LayoutManager::LayoutManager( const Reference< XMultiServiceFactory >& xServiceManager ) : - ThreadHelpBase( &Application::GetSolarMutex() ) +LayoutManager::LayoutManager( const Reference< XMultiServiceFactory >& xServiceManager ) + : LayoutManager_Base ( ) + , ThreadHelpBase ( &Application::GetSolarMutex() ) , ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >( m_aLock.getShareableOslMutex() ) - , ::cppu::OPropertySetHelper ( *(static_cast< ::cppu::OBroadcastHelper* >(this)) ) - , ::cppu::OWeakObject ( ) + , LayoutManager_PBase ( *(static_cast< ::cppu::OBroadcastHelper* >(this)) ) , m_xSMGR( xServiceManager ) - , m_xURLTransformer( Reference< XURLTransformer >( xServiceManager->createInstance( - SERVICENAME_URLTRANSFORMER), - UNO_QUERY )) + , m_xURLTransformer( xServiceManager->createInstance( SERVICENAME_URLTRANSFORMER ), UNO_QUERY ) + , m_xDisplayAccess( xServiceManager->createInstance( SERVICENAME_DISPLAYACCESS ), UNO_QUERY ) , m_nLockCount( 0 ) , m_bActive( sal_False ) , m_bInplaceMenuSet( sal_False ) @@ -421,6 +384,7 @@ LayoutManager::LayoutManager( const Reference< XMultiServiceFactory >& xServiceM , m_bStoreWindowState( sal_False ) , m_bHideCurrentUI( false ) , m_bGlobalSettings( sal_False ) + , m_bPreserveContentSize( false ) , m_eDockOperation( DOCKOP_ON_COLROW ) , m_pInplaceMenuBar( NULL ) , m_xModuleManager( Reference< XModuleManager >( @@ -462,6 +426,15 @@ LayoutManager::LayoutManager( const Reference< XMultiServiceFactory >& xServiceM m_aAsyncLayoutTimer.SetTimeout( 50 ); m_aAsyncLayoutTimer.SetTimeoutHdl( LINK( this, LayoutManager, AsyncLayoutHdl ) ); + + + registerProperty( LAYOUTMANAGER_PROPNAME_AUTOMATICTOOLBARS, LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS, css::beans::PropertyAttribute::TRANSIENT, &m_bAutomaticToolbars, ::getCppuType( &m_bAutomaticToolbars ) ); + registerProperty( LAYOUTMANAGER_PROPNAME_HIDECURRENTUI, LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI, css::beans::PropertyAttribute::TRANSIENT, &m_bHideCurrentUI, ::getCppuType( &m_bHideCurrentUI ) ); + registerProperty( LAYOUTMANAGER_PROPNAME_LOCKCOUNT, LAYOUTMANAGER_PROPHANDLE_LOCKCOUNT, css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY, &m_nLockCount, getCppuType( &m_nLockCount ) ); + registerProperty( LAYOUTMANAGER_PROPNAME_MENUBARCLOSER, LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER, css::beans::PropertyAttribute::TRANSIENT, &m_bMenuBarCloser, ::getCppuType( &m_bMenuBarCloser ) ); + const sal_Bool bRefreshVisibility = sal_False; + registerPropertyNoMember( LAYOUTMANAGER_PROPNAME_REFRESHVISIBILITY, LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY, css::beans::PropertyAttribute::TRANSIENT, ::getCppuType( &bRefreshVisibility ), &bRefreshVisibility ); + registerProperty( LAYOUTMANAGER_PROPNAME_PRESERVE_CONTENT_SIZE, LAYOUTMANAGER_PROPHANDLE_PRESERVE_CONTENT_SIZE, css::beans::PropertyAttribute::TRANSIENT, &m_bPreserveContentSize, ::getCppuType( &m_bPreserveContentSize ) ); } LayoutManager::~LayoutManager() @@ -3240,7 +3213,7 @@ void LayoutManager::implts_updateUIElementsVisibleState( sal_Bool bSetVisible ) if ( bSetVisible ) { implts_createNonContextSensitiveToolBars(); - doLayout(); + implts_doLayout_notify( sal_False ); } else { @@ -3516,7 +3489,7 @@ sal_Bool LayoutManager::implts_showProgressBar() if ( !pWindow->IsVisible() ) { pWindow->Show(); - doLayout(); + implts_doLayout_notify( sal_False ); } return sal_True; } @@ -3557,7 +3530,7 @@ sal_Bool LayoutManager::implts_hideProgressBar() ( bHideStatusBar || bInternalStatusBar )) { pWindow->Hide(); - doLayout(); + implts_doLayout_notify( sal_False ); return sal_True; } @@ -3829,6 +3802,7 @@ throw ( RuntimeException ) { m_aDockingArea = css::awt::Rectangle(); m_xContainerWindow = m_xDockingAreaAcceptor->getContainerWindow(); + m_xContainerTopWindow.set( m_xContainerWindow, UNO_QUERY ); m_xContainerWindow->addWindowListener( Reference< css::awt::XWindowListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); // we always must keep a connection to the window of our frame for resize events @@ -3913,7 +3887,7 @@ throw ( RuntimeException ) implts_createNonContextSensitiveToolBars(); } implts_sortUIElements(); - implts_doLayout( sal_True ); + implts_doLayout( sal_True, sal_False ); } } @@ -5477,26 +5451,33 @@ throw (RuntimeException) implts_notifyListeners( css::frame::LayoutManagerEvents::UNLOCK, a ); if ( bDoLayout ) - doLayout(); + implts_doLayout_notify( sal_True ); } void SAL_CALL LayoutManager::doLayout() throw (RuntimeException) { - sal_Bool bLayouted = implts_doLayout( sal_False ); + implts_doLayout_notify( sal_True ); +} +void LayoutManager::implts_doLayout_notify( sal_Bool bOuterResize ) +{ + sal_Bool bLayouted = implts_doLayout( sal_False, bOuterResize ); if ( bLayouted ) implts_notifyListeners( css::frame::LayoutManagerEvents::LAYOUT, Any() ); } -sal_Bool LayoutManager::implts_doLayout( sal_Bool bForceRequestBorderSpace ) +sal_Bool LayoutManager::implts_doLayout( sal_Bool bForceRequestBorderSpace, sal_Bool bOuterResize ) { RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::implts_doLayout" ); sal_Bool bNoLock( sal_False ); css::awt::Rectangle aCurrBorderSpace; Reference< css::awt::XWindow > xContainerWindow; + Reference< css::awt::XTopWindow2 > xContainerTopWindow; + Reference< css::awt::XWindow > xComponentWindow; Reference< XDockingAreaAcceptor > xDockingAreaAcceptor; + bool bPreserveContentSize( false ); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ ReadGuard aReadLock( m_aLock ); @@ -5507,8 +5488,11 @@ sal_Bool LayoutManager::implts_doLayout( sal_Bool bForceRequestBorderSpace ) bNoLock = ( m_nLockCount == 0 ); xContainerWindow = m_xContainerWindow; + xContainerTopWindow = m_xContainerTopWindow; + xComponentWindow = m_xFrame->getComponentWindow(); xDockingAreaAcceptor = m_xDockingAreaAcceptor; aCurrBorderSpace = m_aDockingArea; + bPreserveContentSize = m_bPreserveContentSize; aReadLock.unlock(); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ @@ -5516,7 +5500,8 @@ sal_Bool LayoutManager::implts_doLayout( sal_Bool bForceRequestBorderSpace ) if ( bNoLock && xDockingAreaAcceptor.is() && - xContainerWindow.is() ) + xContainerWindow.is() && + xComponentWindow.is() ) { bLayouted = sal_True; @@ -5532,11 +5517,44 @@ sal_Bool LayoutManager::implts_doLayout( sal_Bool bForceRequestBorderSpace ) if ( !bEqual || bForceRequestBorderSpace || bMustDoLayout ) { - bGotRequestedBorderSpace = xDockingAreaAcceptor->requestDockingAreaSpace( aBorderSpace ); - if ( bGotRequestedBorderSpace ) + // we always resize the content window (instead of the complete container window) if we're not set up + // to (attempt to) preserve the content window's size + if ( bOuterResize && !bPreserveContentSize ) + bOuterResize = sal_False; + + // maximized windows can resized their content window only, not their container window + if ( bOuterResize && xContainerTopWindow.is() && xContainerTopWindow->getIsMaximized() ) + bOuterResize = sal_False; + + // if the component window does not have a size (yet), then we can't use it to calc the container + // window size + css::awt::Rectangle aComponentRect = xComponentWindow->getPosSize(); + if ( bOuterResize && ( aComponentRect.Width == 0 ) && ( aComponentRect.Height == 0 ) ) + bOuterResize = sal_False; + + bGotRequestedBorderSpace = sal_False; + if ( bOuterResize ) { - xDockingAreaAcceptor->setDockingAreaSpace( aBorderSpace ); + Reference< awt::XDevice > xDevice( xContainerWindow, uno::UNO_QUERY ); + awt::DeviceInfo aContainerInfo = xDevice->getInfo(); + awt::Size aRequestedSize( aComponentRect.Width + aContainerInfo.LeftInset + aContainerInfo.RightInset + aBorderSpace.X + aBorderSpace.Width, + aComponentRect.Height + aContainerInfo.TopInset + aContainerInfo.BottomInset + aBorderSpace.Y + aBorderSpace.Height ); + awt::Point aComponentPos( aBorderSpace.X, aBorderSpace.Y ); + + bGotRequestedBorderSpace = implts_resizeContainerWindow( aRequestedSize, aComponentPos ); + } + + // if we did not do an container window resize, or it failed, then use the DockingAcceptor as usual + if ( !bGotRequestedBorderSpace ) + { + bGotRequestedBorderSpace = xDockingAreaAcceptor->requestDockingAreaSpace( aBorderSpace ); + if ( bGotRequestedBorderSpace ) + xDockingAreaAcceptor->setDockingAreaSpace( aBorderSpace ); + } + + if ( bGotRequestedBorderSpace ) + { /* SAFE AREA ----------------------------------------------------------------------------------------------- */ aWriteGuard.lock(); m_aDockingArea = aBorderSpace; @@ -5603,6 +5621,52 @@ sal_Bool LayoutManager::implts_compareRectangles( const css::awt::Rectangle& rRe ( rRect1.Height == rRect2.Height )); } +sal_Bool LayoutManager::implts_resizeContainerWindow( const awt::Size& rContainerSize, + const awt::Point& rComponentPos ) +{ + /* SAFE AREA ----------------------------------------------------------------------------------------------- */ + ReadGuard aReadLock( m_aLock ); + Reference< awt::XWindow > xContainerWindow = m_xContainerWindow; + Reference< awt::XTopWindow2 > xContainerTopWindow = m_xContainerTopWindow; + Reference< awt::XWindow > xComponentWindow = m_xFrame->getComponentWindow(); + Reference< container::XIndexAccess > xDisplayAccess = m_xDisplayAccess; + aReadLock.unlock(); + /* SAFE AREA ----------------------------------------------------------------------------------------------- */ + + // calculate the maximum size we have for the container window + awt::Rectangle aWorkArea; + try + { + sal_Int32 nDisplay = xContainerTopWindow->getDisplay(); + Reference< beans::XPropertySet > xDisplayInfo( xDisplayAccess->getByIndex( nDisplay ), UNO_QUERY_THROW ); + OSL_VERIFY( xDisplayInfo->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "WorkArea" ) ) ) >>= aWorkArea ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + if ( ( aWorkArea.Width > 0 ) && ( aWorkArea.Height > 0 ) ) + { + if ( ( rContainerSize.Width > aWorkArea.Width ) + || ( rContainerSize.Height > aWorkArea.Height ) + ) + return sal_False; + // Strictly, this is not correct. If we have a multi-screen display (css.awt.DisplayAccess.MultiDisplay == true), + // the the "effective work area" would be much larger than the work area of a single display, since we could in theory + // position the container window across multiple screens. + // However, this should suffice as a heuristics here ... (nobody really wants to check whethere the different screens are + // stacked horizontally or vertically, whether their work areas can really be combined, or are separated by non-work-areas, + // and the like ... right?) + } + + // resize our container window + xContainerWindow->setPosSize( 0, 0, rContainerSize.Width, rContainerSize.Height, css::awt::PosSize::SIZE ); + // position the component window + xComponentWindow->setPosSize( rComponentPos.X, rComponentPos.Y, 0, 0, css::awt::PosSize::POS ); + return sal_True; +} + void SAL_CALL LayoutManager::setVisible( sal_Bool bVisible ) throw (::com::sun::star::uno::RuntimeException) { @@ -7028,7 +7092,7 @@ IMPL_LINK( LayoutManager, AsyncLayoutHdl, Timer *, EMPTYARG ) aReadLock.unlock(); implts_setDockingAreaWindowSizes( aDockingArea ); - implts_doLayout( sal_True ); + implts_doLayout( sal_True, sal_False ); return 0; } @@ -7079,7 +7143,8 @@ throw ( RuntimeException ) /* SAFE AREA ----------------------------------------------------------------------------------------------- */ implts_reset( sal_True ); - implts_doLayout( sal_True ); + implts_doLayout( sal_True, sal_False ); + implts_doLayout( sal_True, sal_True ); } else if (( aEvent.Action == FrameAction_FRAME_UI_ACTIVATED ) || ( aEvent.Action == FrameAction_FRAME_UI_DEACTIVATING )) @@ -7106,7 +7171,6 @@ throw ( RuntimeException ) // SAFE AREA ----------------------------------------------------------------------------------------------- implts_reset( sal_False ); - } } @@ -7148,6 +7212,7 @@ throw( RuntimeException ) } m_xInplaceMenuBar.clear(); m_xContainerWindow.clear(); + m_xContainerTopWindow.clear(); implts_destroyDockingAreaWindows(); if ( m_xModuleCfgMgr.is() ) @@ -7198,6 +7263,7 @@ throw( RuntimeException ) } m_xInplaceMenuBar.clear(); m_xContainerWindow.clear(); + m_xContainerTopWindow.clear(); } else if ( rEvent.Source == Reference< XInterface >( m_xDocCfgMgr, UNO_QUERY )) { @@ -7412,65 +7478,21 @@ sal_Bool SAL_CALL LayoutManager::convertFastPropertyValue( Any& aConverted sal_Int32 nHandle , const Any& aValue ) throw( com::sun::star::lang::IllegalArgumentException ) { - // Initialize state with FALSE !!! - // (Handle can be invalid) - sal_Bool bReturn = sal_False; - - switch( nHandle ) - { - case LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER : - bReturn = PropHelper::willPropertyBeChanged( - com::sun::star::uno::makeAny(m_bMenuBarCloser), - aValue, - aOldValue, - aConvertedValue); - break; - case LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS: - bReturn = PropHelper::willPropertyBeChanged( - com::sun::star::uno::makeAny(m_bAutomaticToolbars), - aValue, - aOldValue, - aConvertedValue); - break; - case LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY: - bReturn = PropHelper::willPropertyBeChanged( - com::sun::star::uno::makeAny(sal_False), - aValue, - aOldValue, - aConvertedValue); - break; - case LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI: - bReturn = PropHelper::willPropertyBeChanged( - com::sun::star::uno::makeAny(m_bHideCurrentUI), - aValue, - aOldValue, - aConvertedValue); - break; - } - - // Return state of operation. - return bReturn ; + return LayoutManager_PBase::convertFastPropertyValue( aConvertedValue, aOldValue, nHandle, aValue ); } void SAL_CALL LayoutManager::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , const com::sun::star::uno::Any& aValue ) throw( com::sun::star::uno::Exception ) { + if ( nHandle != LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY ) + LayoutManager_PBase::setFastPropertyValue_NoBroadcast( nHandle, aValue ); + switch( nHandle ) { case LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER: - { - sal_Bool bCloserState = sal_False; - aValue >>= bCloserState; - implts_setMenuBarCloser( bCloserState ); - break; - } - case LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS: - { - sal_Bool bValue = sal_Bool(); - if ( aValue >>= bValue ) - m_bAutomaticToolbars = bValue; + implts_updateMenuBarClose(); break; - } + case LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY: { sal_Bool bValue = sal_Bool(); @@ -7478,40 +7500,17 @@ void SAL_CALL LayoutManager::setFastPropertyValue_NoBroadcast( sal_Int32 implts_refreshContextToolbarsVisibility(); break; } + case LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI: - { - sal_Bool bValue = sal_Bool(); - if ( aValue >>= bValue ) - { - m_bHideCurrentUI = bValue; - implts_setCurrentUIVisibility( !bValue ); - } + implts_setCurrentUIVisibility( !m_bHideCurrentUI ); break; - } } } void SAL_CALL LayoutManager::getFastPropertyValue( com::sun::star::uno::Any& aValue , sal_Int32 nHandle ) const { - switch( nHandle ) - { - case LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER: - aValue <<= m_bMenuBarCloser; - break; - case LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS: - aValue <<= m_bAutomaticToolbars; - break; - case LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY: - aValue <<= sal_False; - break; - case LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI: - aValue <<= m_bHideCurrentUI; - break; - case LAYOUTMANAGER_PROPHANDLE_LOCKCOUNT: - aValue <<= m_nLockCount; - break; - } + LayoutManager_PBase::getFastPropertyValue( aValue, nHandle ); } ::cppu::IPropertyArrayHelper& SAL_CALL LayoutManager::getInfoHelper() @@ -7530,9 +7529,9 @@ void SAL_CALL LayoutManager::getFastPropertyValue( com::sun::star::uno::Any& aVa if( pInfoHelper == NULL ) { // Define static member to give structure of properties to baseclass "OPropertySetHelper". - // "impl_getStaticPropertyDescriptor" is a non exported and static funtion, who will define a static propertytable. - // "sal_True" say: Table is sorted by name. - static ::cppu::OPropertyArrayHelper aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True ); + uno::Sequence< beans::Property > aProperties; + describeProperties( aProperties ); + static ::cppu::OPropertyArrayHelper aInfoHelper( aProperties, sal_True ); pInfoHelper = &aInfoHelper; } } @@ -7564,28 +7563,5 @@ com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CA return (*pInfo); } -const com::sun::star::uno::Sequence< com::sun::star::beans::Property > LayoutManager::impl_getStaticPropertyDescriptor() -{ - // Create a new static property array to initialize sequence! - // Table of all predefined properties of this class. Its used from OPropertySetHelper-class! - // Don't forget to change the defines (see begin of this file), if you add, change or delete a property in this list!!! - // It's necessary for methods of OPropertySetHelper. - // ATTENTION: - // YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!! - - static const com::sun::star::beans::Property pProperties[] = - { - com::sun::star::beans::Property( LAYOUTMANAGER_PROPNAME_AUTOMATICTOOLBARS, LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS, ::getCppuType((const sal_Bool*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT ), - com::sun::star::beans::Property( LAYOUTMANAGER_PROPNAME_HIDECURRENTUI, LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI, ::getCppuType((const sal_Bool*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT ), - com::sun::star::beans::Property( LAYOUTMANAGER_PROPNAME_LOCKCOUNT, LAYOUTMANAGER_PROPHANDLE_LOCKCOUNT, ::getCppuType((const sal_Int32*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT|com::sun::star::beans::PropertyAttribute::READONLY ), - com::sun::star::beans::Property( LAYOUTMANAGER_PROPNAME_MENUBARCLOSER, LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER, ::getCppuType((const sal_Bool*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT ), - com::sun::star::beans::Property( LAYOUTMANAGER_PROPNAME_REFRESHVISIBILITY, LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY, ::getCppuType((const sal_Bool*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT ) - }; - // Use it to initialize sequence! - static const com::sun::star::uno::Sequence< com::sun::star::beans::Property > lPropertyDescriptor( pProperties, LAYOUTMANAGER_PROPCOUNT ); - // Return static "PropertyDescriptor" - return lPropertyDescriptor; -} - } // namespace framework diff --git a/framework/source/layoutmanager/makefile.mk b/framework/source/layoutmanager/makefile.mk index b9b6bcf248ff..3af616971ad7 100644 --- a/framework/source/layoutmanager/makefile.mk +++ b/framework/source/layoutmanager/makefile.mk @@ -39,6 +39,8 @@ ENABLE_EXCEPTIONS= TRUE .INCLUDE : settings.mk +VISIBILITY_HIDDEN = TRUE + # --- Generate ----------------------------------------------------- SLOFILES= \ diff --git a/framework/source/register/makefile.mk b/framework/source/register/makefile.mk index 1e15c55bd23a..7d7f00e94512 100644 --- a/framework/source/register/makefile.mk +++ b/framework/source/register/makefile.mk @@ -40,6 +40,8 @@ LIBTARGET= NO .INCLUDE : settings.mk +VISIBILITY_HIDDEN = TRUE + # --- Generate ----------------------------------------------------- SLOFILES= \ diff --git a/framework/source/xml/menuconfiguration.cxx b/framework/source/xml/menuconfiguration.cxx index 7b0520219ef6..dcaf354891f6 100644 --- a/framework/source/xml/menuconfiguration.cxx +++ b/framework/source/xml/menuconfiguration.cxx @@ -44,10 +44,6 @@ #include #include -#ifndef _FRAMEWORK_SERVICES_LAYOUTMANAGER_HXX_ -#include -#endif - #ifndef _FRAMEWORK_UIELEMENT_ROOTITEMCONTAINER_HXX_ #include #endif -- cgit From 83551c86578375623fa8e670bbfe1c976b3bd665 Mon Sep 17 00:00:00 2001 From: Mikhail Voitenko Date: Thu, 3 Dec 2009 10:37:54 +0000 Subject: #i105172# allow to request storing of documents from the user on session shutdown --- framework/inc/services/autorecovery.hxx | 7 +- framework/inc/services/sessionlistener.hxx | 20 +++- framework/source/services/autorecovery.cxx | 143 ++++++++++++++++---------- framework/source/services/sessionlistener.cxx | 142 ++++++++++++++++++------- 4 files changed, 217 insertions(+), 95 deletions(-) (limited to 'framework') diff --git a/framework/inc/services/autorecovery.hxx b/framework/inc/services/autorecovery.hxx index 8f6c62a2f39e..ed3630ed1583 100644 --- a/framework/inc/services/autorecovery.hxx +++ b/framework/inc/services/autorecovery.hxx @@ -239,7 +239,8 @@ class AutoRecovery : public css::lang::XTypeProvider E_SESSION_SAVE = 64, E_SESSION_RESTORE = 128, E_DISABLE_AUTORECOVERY = 256, - E_SET_AUTOSAVE_STATE = 512 + E_SET_AUTOSAVE_STATE = 512, + E_SESSION_QUIET_QUIT = 1024 }; //--------------------------------------- @@ -882,6 +883,10 @@ class AutoRecovery : public css::lang::XTypeProvider // TODO document me void implts_doSessionSave(const DispatchParams& aParams); + //--------------------------------------- + // TODO document me + void implts_doSessionQuietQuit(const DispatchParams& aParams); + //--------------------------------------- // TODO document me void implts_doSessionRestore(const DispatchParams& aParams); diff --git a/framework/inc/services/sessionlistener.hxx b/framework/inc/services/sessionlistener.hxx index cbb22a322d48..c8e54d4bcbaa 100644 --- a/framework/inc/services/sessionlistener.hxx +++ b/framework/inc/services/sessionlistener.hxx @@ -49,7 +49,7 @@ #include -#include +#include #include #include #include @@ -98,7 +98,7 @@ namespace framework{ class SessionListener : // interfaces public css::lang::XTypeProvider, public css::lang::XInitialization, - public css::frame::XSessionManagerListener, + public css::frame::XSessionManagerListener2, public css::frame::XStatusListener, public css::lang::XServiceInfo, // baseclasses (order important for initialization!) @@ -120,6 +120,18 @@ class SessionListener : // interfaces // 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: //--------------------------------------- @@ -163,6 +175,10 @@ class SessionListener : // interfaces 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); diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx index 9328ed9d9a5c..1555b7db33a1 100644 --- a/framework/source/services/autorecovery.cxx +++ b/framework/source/services/autorecovery.cxx @@ -170,6 +170,7 @@ static const ::rtl::OUString CMD_DO_RECOVERY = ::rtl::OUString:: static const ::rtl::OUString CMD_DO_ENTRY_BACKUP = ::rtl::OUString::createFromAscii("/doEntryBackup" ); // try to store a temp or original file to a user defined location static const ::rtl::OUString CMD_DO_ENTRY_CLEANUP = ::rtl::OUString::createFromAscii("/doEntryCleanUp" ); // remove the specified entry from the recovery cache static const ::rtl::OUString CMD_DO_SESSION_SAVE = ::rtl::OUString::createFromAscii("/doSessionSave" ); // save all open documents if e.g. a window manager closes an user session +static const ::rtl::OUString CMD_DO_SESSION_QUIET_QUIT = ::rtl::OUString::createFromAscii("/doSessionQuietQuit" ); // let the current session be quietly closed ( the saving should be done using doSessionSave previously ) if e.g. a window manager closes an user session static const ::rtl::OUString CMD_DO_SESSION_RESTORE = ::rtl::OUString::createFromAscii("/doSessionRestore" ); // restore a saved user session from disc static const ::rtl::OUString CMD_DO_DISABLE_RECOVERY = ::rtl::OUString::createFromAscii("/disableRecovery" ); // disable recovery and auto save (!) temp. for this office session static const ::rtl::OUString CMD_DO_SET_AUTOSAVE_STATE = ::rtl::OUString::createFromAscii("/setAutoSaveState" ); // disable/enable auto save (not crash save) for this office session @@ -724,6 +725,16 @@ void AutoRecovery::implts_dispatch(const DispatchParams& aParams) implts_doSessionSave(aParams); } else + if ( + ((eJob & AutoRecovery::E_SESSION_QUIET_QUIT ) == AutoRecovery::E_SESSION_QUIET_QUIT ) && + ((eJob & AutoRecovery::E_DISABLE_AUTORECOVERY) != AutoRecovery::E_DISABLE_AUTORECOVERY) + ) + { + LOG_RECOVERY("... do session quiet quit ...") + bAllowAutoSaveReactivation = sal_False; + implts_doSessionQuietQuit(aParams); + } + else if ( ((eJob & AutoRecovery::E_SESSION_RESTORE ) == AutoRecovery::E_SESSION_RESTORE ) && ((eJob & AutoRecovery::E_DISABLE_AUTORECOVERY) != AutoRecovery::E_DISABLE_AUTORECOVERY) @@ -1986,6 +1997,30 @@ void AutoRecovery::implts_changeAllDocVisibility(sal_Bool bVisible) // <- SAFE ---------------------------------- } +//----------------------------------------------- +/* Currently the document is not closed in case of crash, + so the lock file must be removed explicitly +*/ +void lc_removeLockFile(AutoRecovery::TDocumentInfo& rInfo) +{ + if ( rInfo.Document.is() ) + { + try + { + css::uno::Reference< css::frame::XStorable > xStore(rInfo.Document, css::uno::UNO_QUERY_THROW); + ::rtl::OUString aURL = xStore->getLocation(); + if ( aURL.getLength() ) + { + ::svt::DocumentLockFile aLockFile( aURL ); + aLockFile.RemoveFile(); + } + } + catch( const css::uno::Exception& ) + {} + } +} + + //----------------------------------------------- void AutoRecovery::implts_prepareSessionShutdown() { @@ -2004,6 +2039,10 @@ void AutoRecovery::implts_prepareSessionShutdown() { AutoRecovery::TDocumentInfo& rInfo = *pIt; + // WORKAROUND... Since the documents are not closed the lock file must be removed explicitly + // it is not done on documents saving since shutdown can be cancelled + lc_removeLockFile( rInfo ); + // Prevent us from deregistration of these documents. // Because we close these documents by ourself (see XClosable below) ... // it's fact, that we reach our deregistration method. There we @@ -2014,31 +2053,38 @@ void AutoRecovery::implts_prepareSessionShutdown() // reset modified flag of these documents (ignoring the notification about it!) // Otherwise a message box is shown on closing these models. implts_stopModifyListeningOnDoc(rInfo); - css::uno::Reference< css::util::XModifiable > xModify(rInfo.Document, css::uno::UNO_QUERY); - if (xModify.is()) - xModify->setModified(sal_False); - // close the model. - css::uno::Reference< css::util::XCloseable > xClose(rInfo.Document, css::uno::UNO_QUERY); - if (xClose.is()) + // if the session save is still running the documents should not be thrown away, + // actually that would be a bad sign, that means that the SessionManager tryes + // to kill the session before the saving is ready + if ((m_eJob & AutoRecovery::E_SESSION_SAVE) != AutoRecovery::E_SESSION_SAVE) { - try + css::uno::Reference< css::util::XModifiable > xModify(rInfo.Document, css::uno::UNO_QUERY); + if (xModify.is()) + xModify->setModified(sal_False); + + // close the model. + css::uno::Reference< css::util::XCloseable > xClose(rInfo.Document, css::uno::UNO_QUERY); + if (xClose.is()) { - xClose->close(sal_False); - } - /* - catch(const css::lang::DisposedException&) - { - // closed ... disposed ... always the same .-) - } - */ - catch(const css::uno::Exception&) + try { - // At least it's only a try to close these documents before anybody else it does. - // So it seams to be possible to ignore any error here .-) + xClose->close(sal_False); } + /* + catch(const css::lang::DisposedException&) + { + // closed ... disposed ... always the same .-) + } + */ + catch(const css::uno::Exception&) + { + // At least it's only a try to close these documents before anybody else it does. + // So it seams to be possible to ignore any error here .-) + } - rInfo.Document.clear(); + rInfo.Document.clear(); + } } } @@ -2046,30 +2092,6 @@ void AutoRecovery::implts_prepareSessionShutdown() // <- SAFE } -//----------------------------------------------- -/* Currently the document is not closed in case of crash, - so the lock file must be removed explicitly -*/ -void lc_removeLockFile(AutoRecovery::TDocumentInfo& rInfo) -{ - if ( rInfo.Document.is() ) - { - try - { - css::uno::Reference< css::frame::XStorable > xStore(rInfo.Document, css::uno::UNO_QUERY_THROW); - ::rtl::OUString aURL = xStore->getLocation(); - if ( aURL.getLength() ) - { - ::svt::DocumentLockFile aLockFile( aURL ); - aLockFile.RemoveFile(); - } - } - catch( const css::uno::Exception& ) - {} - } -} - - //----------------------------------------------- /* TODO WORKAROUND: @@ -2750,6 +2772,9 @@ void AutoRecovery::implts_informListener( sal_Int32 eJ if ((eJob & AutoRecovery::E_SESSION_SAVE) == AutoRecovery::E_SESSION_SAVE) sFeature.append(CMD_DO_SESSION_SAVE); else + if ((eJob & AutoRecovery::E_SESSION_QUIET_QUIT) == AutoRecovery::E_SESSION_QUIET_QUIT) + sFeature.append(CMD_DO_SESSION_QUIET_QUIT); + else if ((eJob & AutoRecovery::E_SESSION_RESTORE) == AutoRecovery::E_SESSION_RESTORE) sFeature.append(CMD_DO_SESSION_RESTORE); else @@ -2792,6 +2817,9 @@ sal_Int32 AutoRecovery::implst_classifyJob(const css::util::URL& aURL) if (aURL.Path.equals(CMD_DO_SESSION_SAVE)) return AutoRecovery::E_SESSION_SAVE; else + if (aURL.Path.equals(CMD_DO_SESSION_QUIET_QUIT)) + return AutoRecovery::E_SESSION_QUIET_QUIT; + else if (aURL.Path.equals(CMD_DO_SESSION_RESTORE)) return AutoRecovery::E_SESSION_RESTORE; else @@ -2968,14 +2996,6 @@ void AutoRecovery::implts_doSessionSave(const DispatchParams& aParams) { LOG_RECOVERY("AutoRecovery::implts_doSessionSave()") - // try to make sure next time office will be started user wont be - // notified about any other might be running office instance - // remove ".lock" file from disc ! - // it is done as a first action for session save since Gnome sessions - // do not provide enough time for shutdown, and the dialog looks to be - // confusing for the user - AutoRecovery::st_impl_removeLockFile(); - // Be sure to know all open documents realy .-) implts_verifyCacheAgainstDesktopDocumentList(); @@ -2991,7 +3011,8 @@ void AutoRecovery::implts_doSessionSave(const DispatchParams& aParams) AutoRecovery::ETimerType eSuggestedTimer = AutoRecovery::E_DONT_START_TIMER; do { - eSuggestedTimer = implts_saveDocs(bAllowUserIdleLoop, sal_True, &aParams); + // do not remove lock files of the documents, it will be done on session quit + eSuggestedTimer = implts_saveDocs(bAllowUserIdleLoop, sal_False, &aParams); } while(eSuggestedTimer == AutoRecovery::E_CALL_ME_BACK); @@ -3002,6 +3023,23 @@ void AutoRecovery::implts_doSessionSave(const DispatchParams& aParams) // any "handle" state ... implts_resetHandleStates(sal_False); + // flush config cached back to disc. + impl_flushALLConfigChanges(); +} + +//----------------------------------------------- +void AutoRecovery::implts_doSessionQuietQuit(const DispatchParams& /*aParams*/) +{ + LOG_RECOVERY("AutoRecovery::implts_doSessionQuietQuit()") + + // try to make sure next time office will be started user wont be + // notified about any other might be running office instance + // remove ".lock" file from disc ! + // it is done as a first action for session save since Gnome sessions + // do not provide enough time for shutdown, and the dialog looks to be + // confusing for the user + AutoRecovery::st_impl_removeLockFile(); + // reset all modified documents, so the dont show any UI on closing ... // and close all documents, so we can shutdown the OS! implts_prepareSessionShutdown(); @@ -3020,6 +3058,7 @@ void AutoRecovery::implts_doSessionSave(const DispatchParams& aParams) impl_flushALLConfigChanges(); } + //----------------------------------------------- void AutoRecovery::implts_doSessionRestore(const DispatchParams& aParams) { diff --git a/framework/source/services/sessionlistener.cxx b/framework/source/services/sessionlistener.cxx index 4a58a483ea3c..6dd559adf0e7 100644 --- a/framework/source/services/sessionlistener.cxx +++ b/framework/source/services/sessionlistener.cxx @@ -104,12 +104,13 @@ namespace framework{ //*********************************************** // XInterface, XTypeProvider, XServiceInfo -DEFINE_XINTERFACE_5( +DEFINE_XINTERFACE_6( SessionListener, OWeakObject, DIRECT_INTERFACE(css::lang::XTypeProvider), DIRECT_INTERFACE(css::lang::XInitialization), DIRECT_INTERFACE(css::frame::XSessionManagerListener), + DIRECT_INTERFACE(css::frame::XSessionManagerListener2), DIRECT_INTERFACE(css::frame::XStatusListener), DIRECT_INTERFACE(css::lang::XServiceInfo)) @@ -117,7 +118,7 @@ DEFINE_XTYPEPROVIDER_5( SessionListener, css::lang::XTypeProvider, css::lang::XInitialization, - css::frame::XSessionManagerListener, + css::frame::XSessionManagerListener2, css::frame::XStatusListener, css::lang::XServiceInfo) @@ -138,7 +139,10 @@ SessionListener::SessionListener(const css::uno::Reference< css::lang::XMultiSer : ThreadHelpBase (&Application::GetSolarMutex()) , OWeakObject ( ) , m_xSMGR (xSMGR ) - , m_bRestored( false ) + , m_bRestored( sal_False ) + , m_bSessionStoreRequested( sal_False ) + , m_bAllowUserInteractionOnQuit( sal_False ) + , m_bTerminated( sal_False ) { } @@ -151,6 +155,63 @@ SessionListener::~SessionListener() } } +void SessionListener::StoreSession( sal_Bool bAsync ) +{ + ResetableGuard aGuard(m_aLock); + try + { + // xd create SERVICENAME_AUTORECOVERY -> 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(m_xSMGR->createInstance(SERVICENAME_AUTORECOVERY), UNO_QUERY_THROW); + css::uno::Reference< XURLTransformer > xURLTransformer(m_xSMGR->createInstance(SERVICENAME_URLTRANSFORMER), UNO_QUERY_THROW); + URL aURL; + aURL.Complete = OUString::createFromAscii("vnd.sun.star.autorecovery:/doSessionSave"); + xURLTransformer->parseStrict(aURL); + + // in case of asynchronous call the notification will trigger saveDone() + if ( bAsync ) + xDispatch->addStatusListener(this, aURL); + + Sequence< PropertyValue > args(1); + args[0] = PropertyValue(OUString::createFromAscii("DispatchAsynchron"),-1,makeAny(bAsync),PropertyState_DIRECT_VALUE); + xDispatch->dispatch(aURL, args); + } catch (com::sun::star::uno::Exception& e) { + OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8); + OSL_ENSURE(sal_False, aMsg.getStr()); + // save failed, but tell manager to go on if we havent yet dispatched the request + // in case of synchronous saving the notification is done by the caller + if ( bAsync && m_rSessionManager.is() ) + m_rSessionManager->saveDone(this); + } +} + +void SessionListener::QuitSessionQuietly() +{ + ResetableGuard aGuard(m_aLock); + try + { + // xd create SERVICENAME_AUTORECOVERY -> 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(m_xSMGR->createInstance(SERVICENAME_AUTORECOVERY), UNO_QUERY_THROW); + css::uno::Reference< XURLTransformer > xURLTransformer(m_xSMGR->createInstance(SERVICENAME_URLTRANSFORMER), UNO_QUERY_THROW); + URL aURL; + aURL.Complete = OUString::createFromAscii("vnd.sun.star.autorecovery:/doSessionQuietQuit"); + xURLTransformer->parseStrict(aURL); + + Sequence< PropertyValue > args(1); + args[0] = PropertyValue(OUString::createFromAscii("DispatchAsynchron"),-1,makeAny(sal_False),PropertyState_DIRECT_VALUE); + xDispatch->dispatch(aURL, args); + } catch (com::sun::star::uno::Exception& e) { + OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8); + OSL_ENSURE(sal_False, aMsg.getStr()); + } +} + void SAL_CALL SessionListener::disposing(const com::sun::star::lang::EventObject&) throw (RuntimeException) { } @@ -171,6 +232,8 @@ void SAL_CALL SessionListener::initialize(const Sequence< Any >& args) v.Value >>= aSMgr; else if (v.Name.equalsAscii("SessionManager")) v.Value >>= m_rSessionManager; + else if (v.Name.equalsAscii("AllowUserInteractionOnQuit")) + v.Value >>= m_bAllowUserInteractionOnQuit; } } } @@ -236,9 +299,11 @@ void SAL_CALL SessionListener::doSave( sal_Bool bShutdown, sal_Bool /*bCancelabl { if (bShutdown) { - if ( m_rSessionManager.is() ) + m_bSessionStoreRequested = sal_True; // there is no need to protect it with mutex + if ( m_bAllowUserInteractionOnQuit && m_rSessionManager.is() ) m_rSessionManager->queryInteraction( static_cast< css::frame::XSessionManagerListener* >( this ) ); - + else + StoreSession( sal_True ); } // we don't have anything to do so tell the session manager we're done else if( m_rSessionManager.is() ) @@ -250,63 +315,60 @@ void SAL_CALL SessionListener::doSave( sal_Bool bShutdown, sal_Bool /*bCancelabl void SAL_CALL SessionListener::approveInteraction( sal_Bool bInteractionGranted ) throw (RuntimeException) { - sal_Bool bClosed = sal_False; + // do AutoSave as the first step + sal_Bool bDispatched = sal_False; + ResetableGuard aGuard(m_aLock); + if ( bInteractionGranted ) { - ResetableGuard aGuard(m_aLock); - // close the office documents in normal way try { + // first of all let the session be stored to be sure that we lose no information + StoreSession( sal_False ); + css::uno::Reference< css::frame::XDesktop > xDesktop( m_xSMGR->createInstance(SERVICENAME_DESKTOP), css::uno::UNO_QUERY_THROW); - bClosed = xDesktop->terminate(); + m_bTerminated = xDesktop->terminate(); if ( m_rSessionManager.is() ) { // false means that the application closing has been cancelled - if ( !bClosed ) + if ( !m_bTerminated ) m_rSessionManager->cancelShutdown(); else m_rSessionManager->interactionDone( this ); } } catch( css::uno::Exception& ) - {} - } - - if ( !bClosed ) - { - sal_Bool bDispatched = sal_False; - ResetableGuard aGuard(m_aLock); - try { - // xd create SERVICENAME_AUTORECOVERY -> XDispatch - // xd->dispatch("vnd.sun.star.autorecovery:/doSessionSave, async=true - // on stop event m_rSessionManager->saveDone(this); - - css::uno::Reference< XDispatch > xDispatch(m_xSMGR->createInstance(SERVICENAME_AUTORECOVERY), UNO_QUERY_THROW); - css::uno::Reference< XURLTransformer > xURLTransformer(m_xSMGR->createInstance(SERVICENAME_URLTRANSFORMER), UNO_QUERY_THROW); - URL aURL; - aURL.Complete = OUString::createFromAscii("vnd.sun.star.autorecovery:/doSessionSave"); - xURLTransformer->parseStrict(aURL); - xDispatch->addStatusListener(this, aURL); - Sequence< PropertyValue > args(1); - args[0] = PropertyValue(OUString::createFromAscii("DispatchAsynchron"),-1,makeAny(sal_True),PropertyState_DIRECT_VALUE); - xDispatch->dispatch(aURL, args); - bDispatched = sal_True; - // on stop event set call m_rSessionManager->saveDone(this); - } catch (com::sun::star::uno::Exception& e) { - OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8); - OSL_ENSURE(sal_False, aMsg.getStr()); - // save failed, but tell manager to go on if we havent yet dispatched the request - if (m_rSessionManager.is() && !bDispatched) - m_rSessionManager->saveDone(this); + StoreSession( sal_True ); + m_rSessionManager->interactionDone( this ); } + + if ( m_rSessionManager.is() ) + m_rSessionManager->saveDone(this); + } + else + { + StoreSession( sal_True ); } } void SessionListener::shutdownCanceled() throw (RuntimeException) -{} +{ + // set the state back + m_bSessionStoreRequested = sal_False; // there is no need to protect it with mutex +} + +void SessionListener::doQuit() + throw (RuntimeException) +{ + if ( m_bSessionStoreRequested && !m_bTerminated ) + { + // let the session be closed quietly in this case + QuitSessionQuietly(); + } +} } -- cgit From 1639d24851a22f6a48a3ef8c8f46a7ecce5e8356 Mon Sep 17 00:00:00 2001 From: Mikhail Voitenko Date: Thu, 3 Dec 2009 14:16:35 +0000 Subject: #i10000# remove unused variable --- framework/source/services/sessionlistener.cxx | 1 - 1 file changed, 1 deletion(-) (limited to 'framework') diff --git a/framework/source/services/sessionlistener.cxx b/framework/source/services/sessionlistener.cxx index 6dd559adf0e7..88cf96bdb584 100644 --- a/framework/source/services/sessionlistener.cxx +++ b/framework/source/services/sessionlistener.cxx @@ -316,7 +316,6 @@ void SAL_CALL SessionListener::approveInteraction( sal_Bool bInteractionGranted throw (RuntimeException) { // do AutoSave as the first step - sal_Bool bDispatched = sal_False; ResetableGuard aGuard(m_aLock); if ( bInteractionGranted ) -- cgit