diff options
author | Thomas Lange [tl] <tl@openoffice.org> | 2010-01-06 12:22:41 +0100 |
---|---|---|
committer | Thomas Lange [tl] <tl@openoffice.org> | 2010-01-06 12:22:41 +0100 |
commit | d1bb71fa133c82868cba447e1a736db5292db39b (patch) | |
tree | def9642c61b4d7585250eacb357e062ee3594368 /framework | |
parent | 28687b22eef200c32a37f6901cd40c0328b8766d (diff) | |
parent | 0de34b05f3c1a0409d23b63b9e69d4d7abbe1090 (diff) |
cws tl74: merge with DEV300_m68; AND Unix LF conversion for some files!
Diffstat (limited to 'framework')
80 files changed, 3464 insertions, 641 deletions
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/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/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 <cppuhelper/weakref.hxx> #include <cppuhelper/interfacecontainer.h> /*DRAFT -#include <svtools/historyoptions.hxx> +#include <unotools/historyoptions.hxx> */ //_________________________________________________________________________________________________________________ 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 ff4cf43572fa..fd9c790aec7e 100644 --- a/framework/inc/helper/mischelper.hxx +++ b/framework/inc/helper/mischelper.hxx @@ -1,127 +1,127 @@ -/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: acceleratorinfo.hxx,v $
- * $Revision: 1.6 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef __MISC_HELPER_HXX_
-#define __MISC_HELPER_HXX_
-
-#include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
-#include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/frame/XFrame.hpp>
-
-#include <i18npool/lang.h>
-#include <svtools/languageoptions.hxx>
-#include <rtl/ustring.hxx>
-
-#include <set>
-
-class SvtLanguageTable;
-
-
-// flags for script types in use within selection
-#define LS_SCRIPT_LATIN 0x0001
-#define LS_SCRIPT_ASIAN 0x0002
-#define LS_SCRIPT_COMPLEX 0x0004
-
-
-namespace framework
-{
-
-// menu ids for language status bar control
-enum LangMenuIDs
-{
- MID_LANG_SEL_1,
- MID_LANG_SEL_2,
- MID_LANG_SEL_3,
- MID_LANG_SEL_4,
- MID_LANG_SEL_5,
- MID_LANG_SEL_6,
- MID_LANG_SEL_7,
- MID_LANG_SEL_8,
- MID_LANG_SEL_9,
- MID_LANG_SEL_NONE,
- MID_LANG_SEL_RESET,
- MID_LANG_SEL_MORE,
-
- MID_LANG_PARA_SEPERATOR,
- MID_LANG_PARA_STRING,
-
- MID_LANG_PARA_1,
- MID_LANG_PARA_2,
- MID_LANG_PARA_3,
- MID_LANG_PARA_4,
- MID_LANG_PARA_5,
- MID_LANG_PARA_6,
- MID_LANG_PARA_7,
- MID_LANG_PARA_8,
- MID_LANG_PARA_9,
- MID_LANG_PARA_NONE,
- MID_LANG_PARA_RESET,
- MID_LANG_PARA_MORE,
-};
-
-
-inline bool IsScriptTypeMatchingToLanguage( sal_Int16 nScriptType, LanguageType nLang )
-{
- return 0 != (nScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ));
-}
-
-
-class LanguageGuessingHelper
-{
- mutable ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XLanguageGuessing > m_xLanguageGuesser;
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
-
-public:
- LanguageGuessingHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xServiceManager) : m_xServiceManager(_xServiceManager){}
-
- ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XLanguageGuessing > GetGuesser() const;
-};
-
+/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: acceleratorinfo.hxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __MISC_HELPER_HXX_ +#define __MISC_HELPER_HXX_ + +#include <com/sun/star/linguistic2/XLanguageGuessing.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/frame/XFrame.hpp> + +#include <i18npool/lang.h> +#include <svl/languageoptions.hxx> +#include <rtl/ustring.hxx> + +#include <set> + +class SvtLanguageTable; + + +// flags for script types in use within selection +#define LS_SCRIPT_LATIN 0x0001 +#define LS_SCRIPT_ASIAN 0x0002 +#define LS_SCRIPT_COMPLEX 0x0004 + + +namespace framework +{ + +// menu ids for language status bar control +enum LangMenuIDs +{ + MID_LANG_SEL_1, + MID_LANG_SEL_2, + MID_LANG_SEL_3, + MID_LANG_SEL_4, + MID_LANG_SEL_5, + MID_LANG_SEL_6, + MID_LANG_SEL_7, + MID_LANG_SEL_8, + MID_LANG_SEL_9, + MID_LANG_SEL_NONE, + MID_LANG_SEL_RESET, + MID_LANG_SEL_MORE, + + MID_LANG_PARA_SEPERATOR, + MID_LANG_PARA_STRING, + + MID_LANG_PARA_1, + MID_LANG_PARA_2, + MID_LANG_PARA_3, + MID_LANG_PARA_4, + MID_LANG_PARA_5, + MID_LANG_PARA_6, + MID_LANG_PARA_7, + MID_LANG_PARA_8, + MID_LANG_PARA_9, + MID_LANG_PARA_NONE, + MID_LANG_PARA_RESET, + MID_LANG_PARA_MORE, +}; + + +inline bool IsScriptTypeMatchingToLanguage( sal_Int16 nScriptType, LanguageType nLang ) +{ + return 0 != (nScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage( nLang )); +} + + +class LanguageGuessingHelper +{ + mutable ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XLanguageGuessing > m_xLanguageGuesser; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; + +public: + LanguageGuessingHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xServiceManager) : m_xServiceManager(_xServiceManager){} + + ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XLanguageGuessing > GetGuesser() const; +}; + ::rtl::OUString RetrieveLabelFromCommand( const ::rtl::OUString& aCmdURL ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xServiceFactory ,::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xUICommandLabels ,const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _xFrame ,::rtl::OUString& _rModuleIdentifier ,sal_Bool& _rIni - ,const sal_Char* _pName);
-
-void FillLangItems( std::set< ::rtl::OUString > &rLangItems,
- const SvtLanguageTable &rLanguageTable,
- const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > &rxFrame,
- const LanguageGuessingHelper & rLangGuessHelper,
- sal_Int16 nScriptType,
- const ::rtl::OUString & rCurLang,
- const ::rtl::OUString & rKeyboardLang,
- const ::rtl::OUString & rGuessedTextLang );
-
-} // namespace framework
-
-#endif // __MISC_HELPER_HXX_
-
+ ,const sal_Char* _pName); + +void FillLangItems( std::set< ::rtl::OUString > &rLangItems, + const SvtLanguageTable &rLanguageTable, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > &rxFrame, + const LanguageGuessingHelper & rLangGuessHelper, + sal_Int16 nScriptType, + const ::rtl::OUString & rCurLang, + const ::rtl::OUString & rKeyboardLang, + const ::rtl::OUString & rGuessedTextLang ); + +} // namespace framework + +#endif // __MISC_HELPER_HXX_ + 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 <svtools/moduleoptions.hxx> +#include <unotools/moduleoptions.hxx> #include <cppuhelper/weak.hxx> //_________________________________________________________________________________________________________________ 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 <svtools/moduleoptions.hxx> +#include <unotools/moduleoptions.hxx> #endif #ifndef _CPPUHELPER_WEAK_HXX_ 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 <svtools/solar.hrc> +#include <svl/solar.hrc> // Help-Ids ----------------------------------------------------------------- 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/pch/precompiled_framework.hxx b/framework/inc/pch/precompiled_framework.hxx index eaffedbc0e5c..fd211dd81ee9 100644 --- a/framework/inc/pch/precompiled_framework.hxx +++ b/framework/inc/pch/precompiled_framework.hxx @@ -380,32 +380,32 @@ #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 "svtools/imageitm.hxx" +#include "unotools/historyoptions.hxx" +#include "svl/imageitm.hxx" #include "svtools/imgdef.hxx" -#include "svtools/inettype.hxx" -#include "svtools/internaloptions.hxx" -#include "svtools/lstner.hxx" +#include "svl/inettype.hxx" +#include "unotools/internaloptions.hxx" +#include "svl/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" +#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/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/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 }; //--------------------------------------- @@ -884,6 +885,10 @@ class AutoRecovery : public css::lang::XTypeProvider //--------------------------------------- // TODO document me + void implts_doSessionQuietQuit(const DispatchParams& aParams); + + //--------------------------------------- + // TODO document me void implts_doSessionRestore(const DispatchParams& aParams); //--------------------------------------- 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 <svtools/cmdoptions.hxx> +#include <unotools/cmdoptions.hxx> #include <cppuhelper/propshlp.hxx> #include <cppuhelper/interfacecontainer.hxx> #include <cppuhelper/weak.hxx> 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 <svtools/cmdoptions.hxx> +#include <unotools/cmdoptions.hxx> #include <cppuhelper/interfacecontainer.hxx> #include <cppuhelper/weak.hxx> #include <rtl/string.hxx> 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 <com/sun/star/ui/XUIElementFactory.hpp> #include <com/sun/star/frame/XInplaceLayout.hpp> #include <com/sun/star/ui/DockingArea.hpp> +#include <com/sun/star/awt/XTopWindow2.hpp> #include <com/sun/star/awt/XDockableWindow.hpp> #include <com/sun/star/awt/XDockableWindowListener.hpp> #include <com/sun/star/frame/XMenuBarMergingAcceptor.hpp> @@ -78,8 +79,9 @@ // other includes //_________________________________________________________________________________________________________________ #include <cppuhelper/propshlp.hxx> +#include <cppuhelper/implbase9.hxx> #include <cppuhelper/interfacecontainer.hxx> -#include <cppuhelper/weak.hxx> +#include <comphelper/propertycontainer.hxx> #include <vcl/wintypes.hxx> #include <svtools/miscopt.hxx> #include <vcl/toolbox.hxx> @@ -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/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 <vcl/dialog.hxx> #include <vcl/scrbar.hxx> #include <svtools/svmedit.hxx> -#include <svtools/lstner.hxx> +#include <svl/lstner.hxx> namespace framework { 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 <vcl/threadex.hxx> #endif -#include <svtools/cmdoptions.hxx> +#include <unotools/cmdoptions.hxx> //_________________________________________________________________________________________________________________ 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 <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/frame/XSessionManagerListener.hpp> +#include <com/sun/star/frame/XSessionManagerListener2.hpp> #include <com/sun/star/frame/XSessionManagerClient.hpp> #include <com/sun/star/frame/XStatusListener.hpp> #include <com/sun/star/frame/FeatureStateEvent.hpp> @@ -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/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/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 <macros/xinterface.hxx> #include <macros/xtypeprovider.hxx> #include <macros/xserviceinfo.hxx> -#include <general.h>
+#include <general.h> #include <stdtypes.h> -
+ //_________________________________________________________________________________________________________________ // interface includes //_________________________________________________________________________________________________________________ -
+ #include <com/sun/star/awt/XSimpleTabController.hpp> #include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -62,7 +62,7 @@ //_________________________________________________________________________________________________________________ // other includes //_________________________________________________________________________________________________________________ -
+ #include <cppuhelper/weak.hxx> #include <vcl/window.hxx> @@ -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/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 <vector> #include <list> #include <hash_map> -#include <memory> //_________________________________________________________________________________________________________________ // 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<UIConfigurationManagerImpl> 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 <vector> #include <list> #include <hash_map> -#include <memory> //_________________________________________________________________________________________________________________ // 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<UIConfigurationManagerImpl> 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/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 <svtools/svarray.hxx> +#include <svl/svarray.hxx> #include <tools/string.hxx> #include <tools/stream.hxx> #include <com/sun/star/uno/Sequence.hxx> 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 <svtools/svarray.hxx> +#include <svl/svarray.hxx> #include <tools/string.hxx> #include <tools/stream.hxx> #include <tools/color.hxx> 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 <svtools/svarray.hxx> +#include <svl/svarray.hxx> #include <tools/string.hxx> #include <tools/stream.hxx> #include <vcl/status.hxx> 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 <svtools/svarray.hxx> +#include <svl/svarray.hxx> #include <vcl/bitmap.hxx> #include <tools/string.hxx> #include <com/sun/star/io/XInputStream.hpp> 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 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 <tools/config.hxx> #include <vcl/svapp.hxx> -#include <svtools/dynamicmenuoptions.hxx> +#include <unotools/dynamicmenuoptions.hxx> #include <svtools/menuoptions.hxx> #include <rtl/logfile.hxx> 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/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 <comphelper/extract.hxx> #include <svtools/menuoptions.hxx> -#include <svtools/historyoptions.hxx> -#include <svtools/pathoptions.hxx> +#include <unotools/historyoptions.hxx> +#include <unotools/pathoptions.hxx> #include <unotools/localfilehelper.hxx> #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ 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/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 <vcl/window.hxx> #include <vcl/svapp.hxx> #include <vos/mutex.hxx> -#include <svtools/moduleoptions.hxx> +#include <unotools/moduleoptions.hxx> //_______________________________________________ // 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 <vcl/window.hxx> #include <vcl/svapp.hxx> #include <vos/mutex.hxx> -#include <svtools/moduleoptions.hxx> +#include <unotools/moduleoptions.hxx> //_______________________________________________ // namespace 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<PropertyValue> 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/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 <comphelper/sequenceashashmap.hxx> #include <comphelper/mediadescriptor.hxx> +#include <comphelper/configurationhelper.hxx> #include <vcl/svapp.hxx> #include <vos/mutex.hxx> @@ -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/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(); diff --git a/framework/source/helper/titlehelper.cxx b/framework/source/helper/titlehelper.cxx index 88a6484ca92c..b021d4f4de9d 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 ; 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 <rtl/ustrbuf.hxx> #include <vcl/svapp.hxx> -#include <comphelper/uieventslogger.hxx> //________________________________ // 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 diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index fb10e4fae24c..01934dfb47df 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -67,17 +67,13 @@ #include <com/sun/star/lang/XMultiComponentFactory.hpp> #include <com/sun/star/awt/XTopWindow.hpp> #include <com/sun/star/awt/XSystemDependentMenuPeer.hpp> -#ifndef _COM_SUN_STAR_LANG_XYSTEMDEPENDENT_HPP_ #include <com/sun/star/lang/SystemDependent.hpp> -#endif #include <com/sun/star/awt/VclWindowPeerAttribute.hpp> #include <com/sun/star/awt/PosSize.hpp> #include <com/sun/star/awt/XDevice.hpp> #include <com/sun/star/awt/XSystemDependentWindowPeer.hpp> #include <com/sun/star/awt/XTopWindow.hpp> -#ifndef _COM_SUN_STAR_UI_XMODULEUICONFIGURATIONMANAGER_HPP_ #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp> -#endif #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> #include <com/sun/star/ui/UIElementType.hpp> #include <com/sun/star/container/XNameReplace.hpp> @@ -92,20 +88,20 @@ // other includes //_________________________________________________________________________________________________________________ #include <svtools/imgdef.hxx> +#include <tools/diagnose_ex.h> #include <vcl/window.hxx> #include <vcl/wrkwin.hxx> #include <vcl/dockingarea.hxx> #include <vcl/svapp.hxx> #include <vcl/i18nhelp.hxx> #include <vcl/wall.hxx> -#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include <toolkit/unohlp.hxx> -#endif #include <toolkit/awt/vclxwindow.hxx> #include <toolkit/awt/vclxmenu.hxx> #include <comphelper/mediadescriptor.hxx> +#include <comphelper/uno3.hxx> #include <rtl/logfile.hxx> -#include <svtools/cmdoptions.hxx> +#include <unotools/cmdoptions.hxx> #include <algorithm> #include <boost/bind.hpp> @@ -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 >( @@ -455,13 +419,22 @@ 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(); 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() @@ -469,7 +442,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; } @@ -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 ); - } } @@ -7127,7 +7191,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; } @@ -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/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index 0af8ea0e6587..9fb939e9db0b 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -106,7 +106,7 @@ #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include <toolkit/unohlp.hxx> #endif -#include <svtools/moduleoptions.hxx> +#include <unotools/moduleoptions.hxx> #include <svtools/sfxecode.hxx> #include <unotools/processfactory.hxx> #include <comphelper/configurationhelper.hxx> @@ -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 .. 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/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx index 9328ed9d9a5c..9b19503f887e 100644 --- a/framework/source/services/autorecovery.cxx +++ b/framework/source/services/autorecovery.cxx @@ -80,7 +80,7 @@ #include <comphelper/configurationhelper.hxx> #include <comphelper/mediadescriptor.hxx> #include <vcl/svapp.hxx> -#include <svtools/pathoptions.hxx> +#include <unotools/pathoptions.hxx> #include <tools/link.hxx> #include <tools/string.hxx> #include <unotools/tempfile.hxx> @@ -91,7 +91,7 @@ #include <osl/file.hxx> #include <unotools/bootstrap.hxx> #include <unotools/configmgr.hxx> -#include <svtools/documentlockfile.hxx> +#include <svl/documentlockfile.hxx> #include <tools/urlobj.hxx> @@ -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 @@ -725,6 +726,16 @@ void AutoRecovery::implts_dispatch(const DispatchParams& 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) ) @@ -1987,6 +1998,30 @@ void AutoRecovery::implts_changeAllDocVisibility(sal_Bool bVisible) } //----------------------------------------------- +/* 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() { LOG_RECOVERY("AutoRecovery::implts_prepareSessionShutdown() starts ...") @@ -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(); + } } } @@ -2047,30 +2093,6 @@ void AutoRecovery::implts_prepareSessionShutdown() } //----------------------------------------------- -/* 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: #i64599# @@ -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/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 <rtl/ustrbuf.hxx> #ifndef _SOLAR_HRC -#include <svtools/solar.hrc> +#include <svl/solar.hrc> #endif -#include <svtools/urihelper.hxx> +#include <svl/urihelper.hxx> #include <osl/file.hxx> #include <unotools/configmgr.hxx> diff --git a/framework/source/services/backingwindow.cxx b/framework/source/services/backingwindow.cxx index 40e4a9f7a6b9..a354b01d3c32 100644 --- a/framework/source/services/backingwindow.cxx +++ b/framework/source/services/backingwindow.cxx @@ -43,9 +43,9 @@ #include "tools/urlobj.hxx" -#include "svtools/dynamicmenuoptions.hxx" +#include "unotools/dynamicmenuoptions.hxx" #include "svtools/imagemgr.hxx" -#include "svtools/svtools.hrc" +#include "svl/svtools.hrc" #include "comphelper/processfactory.hxx" #include "comphelper/sequenceashashmap.hxx" @@ -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..e02206cf5f29 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" @@ -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 ); }; 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 <toolkit/awt/vclxwindow.hxx> #include <comphelper/processfactory.hxx> -#include <svtools/moduleoptions.hxx> +#include <unotools/moduleoptions.hxx> #ifdef ENABLE_ASSERTIONS #ifndef _RTL_STRBUF_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 <services/mediatypedetectionhelper.hxx> #include <services.h> -#include <svtools/inettype.hxx> +#include <svl/inettype.hxx> #include <tools/string.hxx> #include <rtl/logfile.hxx> diff --git a/framework/source/services/sessionlistener.cxx b/framework/source/services/sessionlistener.cxx index ad0016fc0af6..95cbc52dcd04 100644 --- a/framework/source/services/sessionlistener.cxx +++ b/framework/source/services/sessionlistener.cxx @@ -60,14 +60,15 @@ #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDesktop.hpp> #include <com/sun/star/util/XModifiable.hpp> #include <com/sun/star/util/XChangesBatch.hpp> #include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/util/URL.hpp> #include <osl/time.h> #include <comphelper/processfactory.hxx> -#include <svtools/pathoptions.hxx> -#include <svtools/internaloptions.hxx> +#include <unotools/pathoptions.hxx> +#include <unotools/internaloptions.hxx> #include <stdio.h> //_______________________________________________ // interface includes @@ -103,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)) @@ -116,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) @@ -137,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 ) { } @@ -150,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) { } @@ -170,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; } } } @@ -235,46 +299,73 @@ void SAL_CALL SessionListener::doSave( sal_Bool bShutdown, sal_Bool /*bCancelabl { if (bShutdown) { - 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); - } + 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() ) m_rSessionManager->saveDone( this ); } +void SAL_CALL SessionListener::approveInteraction( sal_Bool bInteractionGranted ) + throw (RuntimeException) +{ + // do AutoSave as the first step + ResetableGuard aGuard(m_aLock); + + if ( bInteractionGranted ) + { + // 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); + m_bTerminated = xDesktop->terminate(); -void SAL_CALL SessionListener::approveInteraction( sal_Bool /*bInteractionGranted*/ ) - throw (RuntimeException) -{} + if ( m_rSessionManager.is() ) + { + // false means that the application closing has been cancelled + if ( !m_bTerminated ) + m_rSessionManager->cancelShutdown(); + else + m_rSessionManager->interactionDone( this ); + } + } + catch( css::uno::Exception& ) + { + 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(); + } +} } 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/services/tabwindowservice.cxx b/framework/source/services/tabwindowservice.cxx index fb3c08876687..dfce492ddcd7 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,12 @@ TabWindowService::TabWindowService( const css::uno::Reference< css::lang::XMulti // destructor //***************************************************************************************************************** TabWindowService::~TabWindowService() -{
+{ + // SAFE-> + ResetableGuard aGuard(m_aLock); + + if (m_pTabWin) + m_pTabWin->RemoveEventListener( LINK( this, TabWindowService, EventListener ) ); } //***************************************************************************************************************** @@ -286,8 +293,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 +367,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 +380,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 +470,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); 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 <uielement/uielementtypenames.hxx> #include <xml/menuconfiguration.hxx> #include <xml/toolboxconfiguration.hxx> -#include <uiconfigurationmanagerimpl.hxx> #ifndef __FRAMEWORK_XML_STATUSBARCONFIGURATION_HXX_ #include <xml/statusbarconfiguration.hxx> @@ -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 <uielement/uielementtypenames.hxx> #include <xml/menuconfiguration.hxx> #include <xml/toolboxconfiguration.hxx> -#include <uiconfigurationmanagerimpl.hxx> #ifndef __FRAMEWORK_XML_STATUSBARCONFIGURATION_HXX_ #include <xml/statusbarconfiguration.hxx> @@ -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 9b2284c0c6b8..40c2c3f10708 100755..100644 --- 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 ) + if ( !pDataSettings || !m_bUseDefault ) { aUIElementData.bDefault = false; if ( !m_bUseDefault ) 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 <rtl/ustrbuf.hxx> #include <rtl/strbuf.hxx> #ifndef _SOLAR_HRC -#include <svtools/solar.hrc> +#include <svl/solar.hrc> #endif #include <tools/rcid.h> #include <vcl/image.hxx> 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<PropertyValue>()); - _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<PropertyValue> 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<PropertyValue> 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/langselectionmenucontroller.cxx b/framework/source/uielement/langselectionmenucontroller.cxx index 8d5e5b6ddfce..acc18287f3d2 100644 --- a/framework/source/uielement/langselectionmenucontroller.cxx +++ b/framework/source/uielement/langselectionmenucontroller.cxx @@ -69,7 +69,7 @@ #include <com/sun/star/linguistic2/XLanguageGuessing.hpp> #include <i18npool/mslangid.hxx> -#include <svtools/languageoptions.hxx> +#include <svl/languageoptions.hxx> #include <com/sun/star/awt/MenuItemStyle.hpp> #include <svtools/langtab.hxx> #include <classes/fwlresid.hxx> @@ -82,7 +82,7 @@ #include "helper/mischelper.hxx" #include <map> -#include <set>
+#include <set> //_________________________________________________________________________________________________________________ // Defines @@ -264,8 +264,8 @@ void LanguageSelectionMenuController::fillPopupMenu( Reference< css::awt::XPopup SvtLanguageTable aLanguageTable; - // get languages to be displayed in the menu
- std::set< OUString > aLangItems;
+ // get languages to be displayed in the menu + std::set< OUString > aLangItems; FillLangItems( aLangItems, aLanguageTable, m_xFrame, m_aLangGuessHelper, m_nScriptType, m_aCurLang, m_aKeyboardLang, m_aGuessedTextLang ); diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx b/framework/source/uielement/langselectionstatusbarcontroller.cxx index 3edc7466942a..a2a3a02877ca 100644 --- a/framework/source/uielement/langselectionstatusbarcontroller.cxx +++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx @@ -70,7 +70,7 @@ #include <toolkit/unohlp.hxx> #include <tools/gen.hxx> #include <com/sun/star/awt/Command.hpp> -#include <svtools/languageoptions.hxx> +#include <svl/languageoptions.hxx> #include <com/sun/star/linguistic2/XLanguageGuessing.hpp> #include <dispatch/uieventloghelper.hxx> @@ -277,11 +277,12 @@ throw (::com::sun::star::uno::RuntimeException) com::sun::star::awt::Rectangle aRectangle; Window* pWindow = VCLUnoHelper::GetWindow( m_xParentWindow ); - const Point aMousePos = pWindow->GetPointerPosPixel(); - aRectangle.X = aMousePos.X(); - aRectangle.Y = aMousePos.Y(); - sal_Int16 nId = xPopupMenu->execute( xParent, aRectangle, com::sun::star::awt::PopupMenuDirection::EXECUTE_UP+16 ); - if ( m_xFrame.is() ) + const Point mMousePos = pWindow->GetPointerPosPixel(); + mRectangle.X = mMousePos.X(); + mRectangle.Y = mMousePos.Y(); + sal_Int16 nId = xPopupMenu->execute( xParent, mRectangle, com::sun::star::awt::PopupMenuDirection::EXECUTE_UP+16 ); + //click "More..." + if ( nId && m_xFrame.is() ) { uno::Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); util::URL aURL; @@ -392,7 +393,7 @@ throw ( RuntimeException ) // - It displays the language in use in the status bar // - and it stores the relevant data for creating the menu // at some later point in the member variables - // m_nScriptType, m_aCurLang, m_aKeyboardLang, m_aGuessedText
+ // m_nScriptType, m_aCurLang, m_aKeyboardLang, m_aGuessedText RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::statusChanged" ); vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); 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 <comphelper/processfactory.hxx> #include <comphelper/extract.hxx> #include <svtools/menuoptions.hxx> -#include <svtools/historyoptions.hxx> -#include <svtools/pathoptions.hxx> -#include <svtools/cmdoptions.hxx> +#include <unotools/historyoptions.hxx> +#include <unotools/pathoptions.hxx> +#include <unotools/cmdoptions.hxx> #include <unotools/localfilehelper.hxx> #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include <toolkit/unohlp.hxx> 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 <osl/file.hxx> #include <svtools/menuoptions.hxx> #include <svtools/acceleratorexecute.hxx> -#include <svtools/moduleoptions.hxx> +#include <unotools/moduleoptions.hxx> #include <dispatch/uieventloghelper.hxx> //_________________________________________________________________________________________________________________ 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<PropertyValue> 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 ); } } 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 <vcl/i18nhelp.hxx> #include <tools/urlobj.hxx> #include <rtl/ustrbuf.hxx> -#include <svtools/historyoptions.hxx> +#include <unotools/historyoptions.hxx> #include <cppuhelper/implbase1.hxx> #include <osl/file.hxx> //#include <tools/solar.hrc> diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 55c8d16af2ec..6463dd634c20 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -85,13 +85,13 @@ //_________________________________________________________________________________________________________________ #include <svtools/imgdef.hxx> #include <svtools/toolboxcontroller.hxx> -#include <svtools/cmdoptions.hxx> +#include <unotools/cmdoptions.hxx> #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include <toolkit/unohlp.hxx> #endif #include <comphelper/mediadescriptor.hxx> #include <svtools/miscopt.hxx> -#include <svtools/imageitm.hxx> +#include <svl/imageitm.hxx> #include <svtools/framestatuslistener.hxx> #include <vcl/svapp.hxx> #include <vcl/menu.hxx> @@ -99,7 +99,7 @@ #include <vcl/taskpanelist.hxx> #include <rtl/logfile.hxx> #include <svtools/menuoptions.hxx> -#include <svtools/cmdoptions.hxx> +#include <unotools/cmdoptions.hxx> #include <boost/bind.hpp> //_________________________________________________________________________________________________________________ @@ -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 ); 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 <vcl/window.hxx> #include <svtools/menuoptions.hxx> -#include <svtools/cmdoptions.hxx> +#include <unotools/cmdoptions.hxx> #include <dispatch/uieventloghelper.hxx> #include <rtl/logfile.hxx> 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 ) { 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 <xml/saxnamespacefilter.hxx> #include <services.h> -#ifndef _FRAMEWORK_SERVICES_LAYOUTMANAGER_HXX_ -#include <services/layoutmanager.hxx> -#endif - #ifndef _FRAMEWORK_UIELEMENT_ROOTITEMCONTAINER_HXX_ #include <uielement/rootitemcontainer.hxx> #endif diff --git a/framework/util/makefile.mk b/framework/util/makefile.mk index a508f5d29a92..7c39001f683f 100644 --- a/framework/util/makefile.mk +++ b/framework/util/makefile.mk @@ -335,7 +335,6 @@ SHL4OBJS= \ $(SLO)$/uicategorydescription.obj \ $(SLO)$/uicommanddescription.obj \ $(SLO)$/uiconfigurationmanager.obj \ - $(SLO)$/uiconfigurationmanagerimpl.obj \ $(SLO)$/uielementfactorymanager.obj \ $(SLO)$/urltransformer.obj \ $(SLO)$/vclstatusindicator.obj \ |