diff options
author | RĂ¼diger Timm <rt@openoffice.org> | 2008-12-16 16:42:03 +0000 |
---|---|---|
committer | RĂ¼diger Timm <rt@openoffice.org> | 2008-12-16 16:42:03 +0000 |
commit | 55793925843be0fdb248aff23e28e02c6e20b833 (patch) | |
tree | c64606f5245460509c396800394ccfcdbad06ee1 /framework | |
parent | 5ce69216375b2ab068124a8dbb785e91e820460e (diff) |
CWS-TOOLING: integrate CWS alf01
2008-12-10 09:35:35 +0100 as r265152 : #158798# hide internal service
2008-12-09 15:29:11 +0100 cd r265098 : #158857# Check index correctly, must be zero
2008-12-09 12:06:21 +0100 mhu r265075 : #158857# Fixed compiler warning(s).
2008-12-09 11:09:34 +0100 cd r265064 : #158857# Added access to the window state configuration to support setting title of internal docking windows via <Module>WindowState.xcu files
2008-12-09 10:43:53 +0100 as r265063 : #158798# make resizes working better
2008-12-08 17:08:05 +0100 mhu r265010 : #158857# Fixed compiler warning(s).
2008-12-08 15:19:04 +0100 as r264999 : #158857# make WindowContentFactories.xcs part of installation set
2008-12-08 13:23:37 +0100 as r264993 : #158857# actualize size on child window
2008-12-08 10:14:05 +0100 cd r264977 : #158857# More helper functions and support to show/hide internal docking windows
2008-12-08 10:13:08 +0100 cd r264976 : #158857# SfxTitleDockingWindow now uses a factory for content window. Additional documentation for special IDs
2008-12-05 07:58:07 +0100 as r264885 : remove obsolete code (not referenced inside makefile any longer)
2008-12-04 18:57:08 +0100 mhu r264871 : #158857# Fixed compiler warning.
2008-12-04 16:13:12 +0100 mhu r264851 : #158857# Fixed compiler warning.
2008-12-04 15:46:45 +0100 as r264849 : solve merge conflicts right
2008-12-04 09:20:26 +0100 cd r264818 : 2008-12-04 09:19:32 +0100 cd r264817 : 2008-12-04 09:19:07 +0100 cd r264816 : Resolved conflicts
2008-12-04 09:13:27 +0100 cd r264815 : New window content factory manager with configuration support added.
2008-12-03 15:15:50 +0100 as r264791 : #158798# make sure tab window will show its content the first time its made visible
2008-12-03 10:59:30 +0100 as r264752 : #158798# new helper service for a dockable tab control window
2008-12-02 15:39:48 +0100 as r264707 : #158798# fix crash in MouseButtonDown for TabControl
2008-12-02 10:28:20 +0100 cd r264665 : #158857# Resolved conflicts on merge
2008-12-02 09:58:36 +0100 cd r264662 : #158857# Added predefined slots for the internal docking windows. Currently only ten predefined docking windows are possible
2008-12-01 09:44:49 +0100 cd r264586 : #158857# Fix problem with close the floated docking window with closer
2008-11-28 13:42:34 +0100 cd r264550 : #158857# First additional code to create a docking window. Very preliminary and not near to final code
2008-11-28 11:53:51 +0100 cd r264538 : #158857# First additional code to create a docking window. Very preliminary and not near to final code
2008-11-28 11:32:38 +0100 cd r264534 : #158857# First version of docking window factory and additional helper classes
2008-11-21 09:46:36 +0100 jsc r264110 : #158798# remove warnings
2008-11-20 17:59:07 +0100 pb r264090 : fix: #158798# tabcontainerwindow.obj and tabdialog.obj added
2008-11-20 17:55:57 +0100 pb r264089 : fix: #i158798# implementation of service TabContainerWindow
2008-11-20 17:52:52 +0100 pb r264088 : fix: #158798# implementation of the TabDialog and its Pages for the TabContainerWindow service
2008-11-20 17:51:26 +0100 pb r264087 : fix: #i158798# TabContainerWindow added
2008-11-20 17:50:11 +0100 pb r264086 : fix: #158798# tabcontainerwindow.obj and tabdialog.obj added
2008-11-20 17:47:16 +0100 pb r264085 : fix: #158798# new resource: TabDialog DLG_TABCONTAINER
2008-11-20 17:46:06 +0100 pb r264084 : fix: #i158798# added ids for TABCONTAINER...
2008-11-20 17:43:19 +0100 pb r264082 : fix: #158798# IMPLEMENTATION/SERVICENAME_TABCONTAINERWINDOW added
2008-11-20 17:43:00 +0100 pb r264081 : fix: #i158798# implementation of service TabContainerWindow
2008-11-20 17:40:42 +0100 pb r264080 : fix: #158798# TabContainerWindow.idl added
2008-11-20 17:36:57 +0100 pb r264079 : fix: #158798# new service TabContainerWindow
2008-11-20 17:33:05 +0100 pb r264077 : fix: #158798# show tooltip if only a image is shown
2008-11-18 15:10:08 +0100 jsc r263770 : CWS-TOOLING: rebase CWS alf01 to trunk@263288 (milestone: DEV300:m35)
2008-11-18 09:55:21 +0100 jsc r263749 : merge from trunk
2008-11-18 09:54:30 +0100 jsc r263748 : merge from trunk
2008-11-13 17:01:17 +0100 pl r263655 : fix some warnings
2008-10-21 15:38:37 +0200 pl r262572 : #i95201# add: EnablePage
2008-10-20 18:57:53 +0200 pl r262335 : #i95201# add: images for tab items
2008-10-20 17:26:50 +0200 pl r262330 : #i95201# remove old tools list
Diffstat (limited to 'framework')
25 files changed, 2153 insertions, 1166 deletions
diff --git a/framework/inc/classes/fwktabwindow.hxx b/framework/inc/classes/fwktabwindow.hxx new file mode 100644 index 0000000000..3fd4e2ea81 --- /dev/null +++ b/framework/inc/classes/fwktabwindow.hxx @@ -0,0 +1,140 @@ +/************************************************************************* + * + * 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: backingwindow.hxx,v $ + * $Revision: 1.10 $ + * + * 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 FRAMEWORK_TABWINDOW_HXX +#define FRAMEWORK_TABWINDOW_HXX + +#include <general.h> + +#include <vector> + +#include <com/sun/star/uno/Reference.h> +#include <vcl/tabctrl.hxx> +#include <vcl/tabdlg.hxx> +#include <vcl/tabpage.hxx> +#include <vcl/button.hxx> + +namespace com { namespace sun { namespace star { + namespace awt { + class XWindow; + class XContainerWindowProvider; + class XContainerWindowEventHandler; } + namespace beans { + struct NamedValue; } +} } } + +namespace framework +{ + +class FwkTabControl : public TabControl +{ +public: + FwkTabControl( Window* pParent, const ResId& rResId ); + + void BroadcastEvent( ULONG nEvent );
+}; + +class FwkTabPage : public TabPage +{ +private: + rtl::OUString m_sPageURL; + rtl::OUString m_sEventHdl; + css::uno::Reference< css::awt::XWindow > m_xPage;
+ css::uno::Reference< css::awt::XContainerWindowEventHandler > m_xEventHdl; + css::uno::Reference< css::awt::XContainerWindowProvider > m_xWinProvider; + + void CreateDialog(); + sal_Bool CallMethod( const rtl::OUString& rMethod ); + +public: + FwkTabPage( + Window* pParent, + const rtl::OUString& rPageURL, + const rtl::OUString& rEventHdl, + const css::uno::Reference< css::awt::XContainerWindowProvider >& rProvider ); + + virtual ~FwkTabPage(); + + virtual void ActivatePage(); + virtual void DeactivatePage(); + virtual void Resize(); + + void Reset(); + void Save(); +}; + +struct TabEntry +{ + sal_Int32 m_nIndex; + FwkTabPage* m_pPage; + ::rtl::OUString m_sPageURL; + ::rtl::OUString m_sEventHdl; + + TabEntry() : + m_nIndex( -1 ), m_pPage( NULL ) {} + + TabEntry( sal_Int32 nIndex, ::rtl::OUString sURL, ::rtl::OUString sEvent ) : + m_nIndex( nIndex ), m_pPage( NULL ), m_sPageURL( sURL ), m_sEventHdl( sEvent ) {} + + ~TabEntry() { delete m_pPage; } +}; + +typedef std::vector< TabEntry* > TabEntryList; + +class FwkTabWindow : public Window +{ +private: + FwkTabControl m_aTabCtrl; + TabEntryList m_TabList; + + css::uno::Reference< css::awt::XContainerWindowProvider > m_xWinProvider; + + void ClearEntryList(); + TabEntry* FindEntry( sal_Int32 nIndex ) const; + + DECL_DLLPRIVATE_LINK( ActivatePageHdl, TabControl * ); + DECL_DLLPRIVATE_LINK( DeactivatePageHdl, TabControl * ); + DECL_DLLPRIVATE_LINK( CloseHdl, PushButton * ); + +public: + FwkTabWindow( Window* pParent ); + ~FwkTabWindow(); + + void AddEventListener( 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 ); + sal_Int32 GetActivePageId() const;
+ virtual void Resize(); +}; + +} // namespace framework + +#endif + diff --git a/framework/inc/classes/sfxhelperfunctions.hxx b/framework/inc/classes/sfxhelperfunctions.hxx index 56dd459075..75c1d9d365 100644 --- a/framework/inc/classes/sfxhelperfunctions.hxx +++ b/framework/inc/classes/sfxhelperfunctions.hxx @@ -41,6 +41,8 @@ typedef svt::ToolboxController* ( *pfunc_setToolBoxControllerCreator)( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const ::rtl::OUString& aCommandURL ); typedef svt::StatusbarController* ( *pfunc_setStatusBarControllerCreator)( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, StatusBar* pStatusBar, unsigned short nID, const ::rtl::OUString& aCommandURL ); typedef void ( *pfunc_getRefreshToolbars)( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ); +typedef void ( *pfunc_createDockingWindow)( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& rResourceURL ); +typedef bool ( *pfunc_isDockingWindowVisible)( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& rResourceURL ); namespace framework { @@ -57,6 +59,13 @@ pfunc_getRefreshToolbars SAL_CALL SetRefreshToolbars( pfunc_getRefreshToolbars p void SAL_CALL RefreshToolbars( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ); +pfunc_createDockingWindow SAL_CALL SetDockingWindowCreator( pfunc_createDockingWindow pCreateDockingWindow ); + +void SAL_CALL CreateDockingWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& rResourceURL ); + +pfunc_isDockingWindowVisible SAL_CALL SetIsDockingWindowVisible( pfunc_isDockingWindowVisible pIsDockingWindowVisible ); + +bool SAL_CALL IsDockingWindowVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& rResourceURL ); } #endif // __FRAMEWORK_CLASSES_SFXHELPERFUNCTIONS_HXX_ diff --git a/framework/inc/framework.hrc b/framework/inc/framework.hrc index 694dc4d5e6..068bdd0802 100644 --- a/framework/inc/framework.hrc +++ b/framework/inc/framework.hrc @@ -1,7 +1,7 @@ /************************************************************************* * * 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 @@ -30,7 +30,7 @@ #ifndef _FRAMEWORK_HRC #define _FRAMEWORK_HRC - + #include "svtools/solar.hrc" #define RID_FWK_START 260 @@ -80,5 +80,9 @@ #define BMP_BACKING_BACKGROUND_RTL_LEFT 4 #define BMP_BACKING_BACKGROUND_RTL_RIGHT 5 +// Ids of TabWindow +#define WIN_TABWINDOW (RID_FWK_DIALOG_START+101) +#define TC_TABCONTROL 1 #endif + diff --git a/framework/inc/properties.h b/framework/inc/properties.h index 2b1727ec26..9bead3c4e7 100644 --- a/framework/inc/properties.h +++ b/framework/inc/properties.h @@ -255,7 +255,7 @@ namespace framework{ #define OFFICEFACTORY_PROPNAME_ICON ::rtl::OUString::createFromAscii( OFFICEFACTORY_PROPNAME_ASCII_ICON ) //_______________________________________________ -/** properties for tab window */ +/** properties for tab window (old) */ #define TABWINDOW_PROPNAME_ASCII_PARENTWINDOW "ParentWindow" #define TABWINDOW_PROPNAME_ASCII_TOPWINDOW "TopWindow" #define TABWINDOW_PROPNAME_PARENTWINDOW ::rtl::OUString::createFromAscii( TABWINDOW_PROPNAME_ASCII_PARENTWINDOW ) @@ -266,6 +266,14 @@ namespace framework{ #define TABWINDOW_PROPCOUNT 2 //_______________________________________________ +/** properties for tab window service (new) */ +#define TABWINDOWSERVICE_PROPNAME_ASCII_WINDOW "Window" +#define TABWINDOWSERVICE_PROPNAME_WINDOW ::rtl::OUString::createFromAscii( TABWINDOWSERVICE_PROPNAME_ASCII_WINDOW ) + +#define TABWINDOWSERVICE_PROPHANDLE_WINDOW 0 +#define TABWINDOWSERVICE_PROPCOUNT 1
+ +//_______________________________________________ /** properties of tabreg service */ static const char* TABREG_PROPNAME_ASCII_TITLE = "title"; diff --git a/framework/inc/services.h b/framework/inc/services.h index 348bb467fa..ac9dde220e 100644 --- a/framework/inc/services.h +++ b/framework/inc/services.h @@ -1,7 +1,7 @@ /************************************************************************* * * 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 @@ -125,6 +125,8 @@ namespace framework{ #define SERVICENAME_TABWINDOW DECLARE_ASCII("com.sun.star.frame.TabWindow" ) #define SERVICENAME_STRINGABBREVIATION DECLARE_ASCII("com.sun.star.util.UriAbbreviation" ) #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" ) //_________________________________________________________________________________________________________________ // used implementationnames by framework @@ -209,7 +211,10 @@ namespace framework{ #define IMPLEMENTATIONNAME_LANGSELECTIONSTATUSBARCONTROLLER DECLARE_ASCII("com.sun.star.comp.framework.LangSelectionStatusbarController" ) #define IMPLEMENTATIONNAME_LANGUAGESELECTIONMENUCONTROLLER DECLARE_ASCII("com.sum.star.comp.framework.LanguageSelectionMenuController" ) #define IMPLEMENTATIONNAME_IMAGEMANAGER DECLARE_ASCII("com.sun.star.comp.framework.ImageManager" ) +#define IMPLEMENTATIONNAME_TABWINDOWSERVICE DECLARE_ASCII("com.sun.star.comp.framework.TabWindowService" ) +#define IMPLEMENTATIONNAME_WINDOWCONTENTFACTORYMANAGER DECLARE_ASCII("com.sun.star.comp.framework.WindowContentFactoryManager" ) } // namespace framework #endif // #ifndef __FRAMEWORK_SERVICES_H_ + diff --git a/framework/inc/services/tabwindowservice.hxx b/framework/inc/services/tabwindowservice.hxx new file mode 100644 index 0000000000..198d84be0b --- /dev/null +++ b/framework/inc/services/tabwindowservice.hxx @@ -0,0 +1,234 @@ +/************************************************************************* + * + * 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: urltransformer.hxx,v $ + * $Revision: 1.8 $ + * + * 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 __FRAMEWORK_SERVICES_TABWINDOWSERVICE_HXX_ +#define __FRAMEWORK_SERVICES_TABWINDOWSERVICE_HXX_ + +/** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble + with solaris headers ... +*/ +#include <vector> + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#include <classes/fwktabwindow.hxx> +#include <classes/propertysethelper.hxx> +#include <threadhelp/threadhelpbase.hxx> +#include <macros/generic.hxx> +#include <macros/debug.hxx> +#include <macros/xinterface.hxx> +#include <macros/xtypeprovider.hxx> +#include <macros/xserviceinfo.hxx> +#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> + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ +
+#include <cppuhelper/weak.hxx> +#include <vcl/window.hxx> + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +namespace framework{ + +//_________________________________________________________________________________________________________________ +// exported const +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// exported definitions +//_________________________________________________________________________________________________________________ + +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;
+ ::sal_Bool m_bCreated; + FwkTabPage* m_pPage; + css::uno::Sequence< css::beans::NamedValue > m_lProperties; +};
+
+typedef ::std::hash_map< ::sal_Int32 , + TTabPageInfo , + Int32HashCode , + ::std::equal_to< ::sal_Int32 > > TTabPageInfoHash; + +/*-************************************************************************************************************//** + @short implements a helper service providing a dockable tab control window +*//*-*************************************************************************************************************/ + +class TabWindowService : public css::lang::XTypeProvider + , public css::lang::XServiceInfo + , public css::awt::XSimpleTabController + , public ThreadHelpBase + , public TransactionBase + , public PropertySetHelper
+ , public ::cppu::OWeakObject
+{ + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + + public: + + //--------------------------------------------------------------------------------------------------------- + // constructor / destructor + //--------------------------------------------------------------------------------------------------------- +
+ TabWindowService( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); + virtual ~TabWindowService(); + + //--------------------------------------------------------------------------------------------------------- + // XInterface, XTypeProvider, XServiceInfo + //--------------------------------------------------------------------------------------------------------- + + FWK_DECLARE_XINTERFACE + FWK_DECLARE_XTYPEPROVIDER + DECLARE_XSERVICEINFO + + //--------------------------------------------------------------------------------------------------------- + // XSimpleTabController + //--------------------------------------------------------------------------------------------------------- + + virtual sal_Int32 SAL_CALL insertTab() throw ( css::uno::RuntimeException ); + virtual void SAL_CALL removeTab( sal_Int32 nID ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException ); + virtual void SAL_CALL setTabProps( sal_Int32 nID, const css::uno::Sequence< css::beans::NamedValue >& aProperties ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException ); + virtual css::uno::Sequence< css::beans::NamedValue > SAL_CALL getTabProps( sal_Int32 nID ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException ); + virtual void SAL_CALL activateTab( sal_Int32 nID ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException ); + virtual sal_Int32 SAL_CALL getActiveTabID() throw ( css::uno::RuntimeException ); + virtual void SAL_CALL addTabListener( const css::uno::Reference< css::awt::XTabListener >& Listener ) throw ( css::uno::RuntimeException ); + virtual void SAL_CALL removeTabListener( const css::uno::Reference< css::awt::XTabListener >& Listener ) throw ( css::uno::RuntimeException ); + + //--------------------------------------------------------------------------------------------------------- + // XComponent + //--------------------------------------------------------------------------------------------------------- + + virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException ); + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw ( css::uno::RuntimeException ); + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw ( css::uno::RuntimeException ); + + //------------------------------------------------------------------------------------------------------------- + // protected methods + //------------------------------------------------------------------------------------------------------------- + + protected: + + //------------------------------------------------------------------------------------------------------------- + // private methods + //------------------------------------------------------------------------------------------------------------- + + private: + + void impl_initializePropInfo(); + virtual void SAL_CALL impl_setPropertyValue(const ::rtl::OUString& sProperty, + sal_Int32 nHandle , + const css::uno::Any& aValue ); + virtual css::uno::Any SAL_CALL impl_getPropertyValue(const ::rtl::OUString& sProperty, + sal_Int32 nHandle ); + + 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);
+ FwkTabWindow* mem_TabWin (); +/* + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + const css::uno::Sequence< css::beans::Property > impl_getStaticPropertyDescriptor(); + static css::uno::Reference < css::beans::XPropertySetInfo > SAL_CALL + createPropertySetInfo( ::cppu::IPropertyArrayHelper& rProperties ) SAL_THROW( () ); +*/ + //------------------------------------------------------------------------------------------------------------- + // variables + // (should be private everyway!) + //------------------------------------------------------------------------------------------------------------- + + private: + + /// reference to factory, which has created this instance + 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;
+
+ /// container of the added TabListener + ::cppu::OMultiTypeInterfaceContainerHelper m_lListener; +
+ /// counter of the tabpage indexes + ::sal_Int32 m_nPageIndexCounter;
+
+ /// index of the current active page + ::sal_Int32 m_nCurrentPageIndex; +
+ /// title of the tabcontrolled window + ::rtl::OUString m_sTitle; + +}; // class TabWindowService + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_SERVICES_TABWINDOWSERVICE_HXX_ + diff --git a/framework/inc/stdtypes.h b/framework/inc/stdtypes.h index 907ea4ba8b..5af49e0178 100644 --- a/framework/inc/stdtypes.h +++ b/framework/inc/stdtypes.h @@ -78,12 +78,20 @@ struct OUStringHashCode struct ShortHashCode { - size_t operator()( const sal_Int16& nShort ) const + size_t operator()( const ::sal_Int16& nShort ) const { return (size_t)nShort; } }; +struct Int32HashCode +{ + size_t operator()( const ::sal_Int32& nValue ) const + { + return (size_t)nValue; + } +};
+ struct KeyEventHashCode { size_t operator()( const css::awt::KeyEvent& aEvent ) const diff --git a/framework/inc/uifactory/windowcontentfactorymanager.hxx b/framework/inc/uifactory/windowcontentfactorymanager.hxx new file mode 100644 index 0000000000..69dd2d3e8a --- /dev/null +++ b/framework/inc/uifactory/windowcontentfactorymanager.hxx @@ -0,0 +1,98 @@ +/************************************************************************* + * + * 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: uielementfactorymanager.hxx,v $ + * $Revision: 1.7 $ + * + * 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 __FRAMEWORK_UIFACTORY_WINDOWCONTENTFACTORYMANAGER_HXX_ +#define __FRAMEWORK_UIFACTORY_WINDOWCONTENTFACTORYMANAGER_HXX_ + +/** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble + with solaris headers ... +*/ +#include <vector> +#include <list> + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ +#include <threadhelp/threadhelpbase.hxx> +#include <macros/generic.hxx> +#include <macros/xinterface.hxx> +#include <macros/xtypeprovider.hxx> +#include <macros/xserviceinfo.hxx> +#include <stdtypes.h> + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include "com/sun/star/frame/XModuleManager.hpp" + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ +#include <cppuhelper/weak.hxx> +#include <rtl/ustring.hxx> + +namespace framework +{ + +class ConfigurationAccess_WindowContentFactoryManager; +class WindowContentFactoryManager : public com::sun::star::lang::XTypeProvider , + public com::sun::star::lang::XServiceInfo , + public com::sun::star::lang::XSingleComponentFactory , + private ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses. + public ::cppu::OWeakObject +{ + public: + WindowContentFactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ); + virtual ~WindowContentFactoryManager(); + + // XInterface, XTypeProvider, XServiceInfo + FWK_DECLARE_XINTERFACE + FWK_DECLARE_XTYPEPROVIDER + DECLARE_XSERVICEINFO + + // XSingleComponentFactory + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithContext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& Context ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArgumentsAndContext( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& Context ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + + private: + void RetrieveTypeNameFromResourceURL( const ::rtl::OUString& aResourceURL, rtl::OUString& aType, rtl::OUString& aName ); + + sal_Bool m_bConfigRead; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > m_xModuleManager; + ConfigurationAccess_WindowContentFactoryManager* m_pConfigAccess; +}; + +} // namespace framework + +#endif // __FRAMEWORK_UIFACTORY_WINDOWCONTENTFACTORYMANAGER_HXX_ diff --git a/framework/source/classes/fwktabwindow.cxx b/framework/source/classes/fwktabwindow.cxx new file mode 100644 index 0000000000..d933492e14 --- /dev/null +++ b/framework/source/classes/fwktabwindow.cxx @@ -0,0 +1,392 @@ +/************************************************************************* + * + * 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: backingwindow.cxx,v $ + * $Revision: 1.12 $ + * + * 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. + * + ************************************************************************/ + +// autogen include statement, do not remove +#include "precompiled_framework.hxx" + +#include <classes/fwktabwindow.hxx> +#include "framework.hrc" +#include <classes/fwkresid.hxx> + +#include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/awt/XContainerWindowEventHandler.hpp> +#include <com/sun/star/awt/XContainerWindowProvider.hpp> +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/awt/XWindowPeer.hpp> +#include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +#include <comphelper/processfactory.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <tools/stream.hxx> +#include <vcl/bitmap.hxx> +#include <vcl/image.hxx> +#include <vcl/msgbox.hxx> + +const ::rtl::OUString SERVICENAME_WINPROVIDER + = ::rtl::OUString::createFromAscii("com.sun.star.awt.ContainerWindowProvider"); +const ::rtl::OUString EXTERNAL_EVENT = ::rtl::OUString::createFromAscii("external_event"); +const ::rtl::OUString BACK_METHOD = ::rtl::OUString::createFromAscii("back"); +const ::rtl::OUString INITIALIZE_METHOD = ::rtl::OUString::createFromAscii("initialize"); +const ::rtl::OUString OK_METHOD = ::rtl::OUString::createFromAscii("ok"); + +using namespace ::com::sun::star; + +namespace framework +{ + +// class FwkTabControl --------------------------------------------------- + +FwkTabControl::FwkTabControl( Window* pParent, const ResId& rResId ) : + + TabControl( pParent, rResId ) +{ +} + +// ----------------------------------------------------------------------- + +void FwkTabControl::BroadcastEvent( ULONG nEvent ) +{ + if ( VCLEVENT_TABPAGE_ACTIVATE == nEvent || VCLEVENT_TABPAGE_DEACTIVATE == nEvent ) + ImplCallEventListeners( nEvent, (void*)(ULONG)GetCurPageId() ); + else + { + DBG_ERRORFILE( "FwkTabControl::BroadcastEvent(): illegal event" ); + } +}
+ +// class FwkTabPage ------------------------------------------------ + +FwkTabPage::FwkTabPage( + Window* pParent, const rtl::OUString& rPageURL, const rtl::OUString& rEventHdl, + const css::uno::Reference< css::awt::XContainerWindowProvider >& rProvider ) : + + TabPage( pParent, WB_DIALOGCONTROL ), + + m_sPageURL ( rPageURL ), + m_sEventHdl ( rEventHdl ), + m_xWinProvider ( rProvider ) + +{ +} + +// ----------------------------------------------------------------------- + +FwkTabPage::~FwkTabPage() +{ + Hide(); + DeactivatePage(); +} + +// ----------------------------------------------------------------------- + +void FwkTabPage::CreateDialog() +{ + try + { + uno::Reference< uno::XInterface > xHandler; + if ( m_sEventHdl.getLength() > 0 ) + { + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); + m_xEventHdl = uno::Reference< awt::XContainerWindowEventHandler >( + xFactory->createInstance( m_sEventHdl ), uno::UNO_QUERY ); + xHandler = m_xEventHdl; + } + uno::Reference< awt::XWindowPeer > xParent( VCLUnoHelper::GetInterface( this ), uno::UNO_QUERY ); + m_xPage = uno::Reference < awt::XWindow >( + m_xWinProvider->createContainerWindow( + m_sPageURL, rtl::OUString(), xParent, xHandler ), uno::UNO_QUERY );
+ + CallMethod( INITIALIZE_METHOD ); + } + catch ( lang::IllegalArgumentException& ) + { + DBG_ERRORFILE( "FwkTabPage::CreateDialog(): illegal argument" ); + } + catch ( uno::Exception& ) + { + DBG_ERRORFILE( "FwkTabPage::CreateDialog(): exception of XDialogProvider2::createContainerWindow()" ); + } +} + +// ----------------------------------------------------------------------- + +sal_Bool FwkTabPage::CallMethod( const rtl::OUString& rMethod ) +{ + sal_Bool bRet = sal_False; + if ( m_xEventHdl.is() ) + { + try + { + bRet = m_xEventHdl->callHandlerMethod( m_xPage, uno::makeAny( rMethod ), EXTERNAL_EVENT ); + } + catch ( uno::Exception& ) + { + DBG_ERRORFILE( "FwkTabPage::CallMethod(): exception of XDialogEventHandler::callHandlerMethod()" ); + } + } + return bRet; +} + +// ----------------------------------------------------------------------- + +void FwkTabPage::ActivatePage() +{ + TabPage::ActivatePage(); + + if ( !m_xPage.is() ) + CreateDialog(); + + if ( m_xPage.is() )
+ {
+ Resize (); + m_xPage->setVisible( sal_True );
+ } +} + +// ----------------------------------------------------------------------- + +void FwkTabPage::DeactivatePage() +{ + TabPage::DeactivatePage(); + + if ( m_xPage.is() ) + m_xPage->setVisible( sal_False ); +} + +// ----------------------------------------------------------------------- + +void FwkTabPage::Resize() +{ + if ( m_xPage.is () ) + { + Size aSize = GetSizePixel (); + Point aPos = GetPosPixel (); + + m_xPage->setPosSize( 0, 0, aSize.Width()-1 , aSize.Height()-1, awt::PosSize::POSSIZE ); + } +} + +// ----------------------------------------------------------------------- + +void FwkTabPage::Reset() +{ + CallMethod( BACK_METHOD ); + ActivatePage(); +} + +// ----------------------------------------------------------------------- + +void FwkTabPage::Save() +{ + CallMethod( OK_METHOD ); +} + +// class FwkTabWindow --------------------------------------------- + +FwkTabWindow::FwkTabWindow( Window* pParent ) : + + Window( pParent, FwkResId( WIN_TABWINDOW ) ), + + m_aTabCtrl ( this, FwkResId( TC_TABCONTROL ) ) +{ + uno::Reference < lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); + m_xWinProvider = uno::Reference < awt::XContainerWindowProvider >( + xFactory->createInstance( SERVICENAME_WINPROVIDER ), uno::UNO_QUERY ); +
+ SetPaintTransparent(true);
+ + m_aTabCtrl.SetActivatePageHdl( LINK( this, FwkTabWindow, ActivatePageHdl ) ); + m_aTabCtrl.SetDeactivatePageHdl( LINK( this, FwkTabWindow, DeactivatePageHdl ) ); + m_aTabCtrl.Show(); +} + +// ----------------------------------------------------------------------- + +FwkTabWindow::~FwkTabWindow() +{ + ClearEntryList(); +} + +// ----------------------------------------------------------------------- + +void FwkTabWindow::ClearEntryList() +{ + TabEntryList::const_iterator pIt; + for ( pIt = m_TabList.begin(); + pIt != m_TabList.end(); + ++pIt ) + { + delete *pIt; + } + + m_TabList.clear(); +} + +// ----------------------------------------------------------------------- + +TabEntry* FwkTabWindow::FindEntry( sal_Int32 nIndex ) const +{ + TabEntry* pEntry = NULL; + + TabEntryList::const_iterator pIt; + for ( pIt = m_TabList.begin(); + pIt != m_TabList.end(); + ++pIt ) + { + if ( (*pIt)->m_nIndex == nIndex ) + { + pEntry = *pIt; + break; + } + } + + return pEntry; +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( FwkTabWindow, ActivatePageHdl, TabControl *, EMPTYARG ) +{ + const USHORT nId = m_aTabCtrl.GetCurPageId(); + FwkTabPage* pTabPage = static_cast< FwkTabPage* >( m_aTabCtrl.GetTabPage( nId ) ); + if ( !pTabPage ) + { + TabEntry* pEntry = FindEntry( nId ); + if ( pEntry ) + { + pTabPage = new FwkTabPage( &m_aTabCtrl, pEntry->m_sPageURL, pEntry->m_sEventHdl, m_xWinProvider ); + pTabPage->Show(); + pTabPage->ActivatePage(); + m_aTabCtrl.SetTabPage( nId, pTabPage ); + } + } + m_aTabCtrl.BroadcastEvent( VCLEVENT_TABPAGE_ACTIVATE ); + return 1; +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( FwkTabWindow, DeactivatePageHdl, TabControl *, EMPTYARG ) +{ + m_aTabCtrl.BroadcastEvent( VCLEVENT_TABPAGE_DEACTIVATE ); + return 1; +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( FwkTabWindow, CloseHdl, PushButton *, EMPTYARG ) +{ +// Close(); + return 0; +} + +// ----------------------------------------------------------------------- + +void FwkTabWindow::AddEventListener( const Link& rEventListener ) +{ + m_aTabCtrl.AddEventListener( rEventListener ); +} + +// ----------------------------------------------------------------------- + +FwkTabPage* FwkTabWindow::AddTabPage( sal_Int32 nIndex, const uno::Sequence< beans::NamedValue >& rProperties ) +{ + ::rtl::OUString sTitle, sToolTip, sPageURL, sEventHdl; + uno::Reference< graphic::XGraphic > xImage; + bool bDisabled = false; + + sal_Int32 i = 0, nLen = rProperties.getLength(); + for ( i = 0; i < nLen; ++i ) + { + beans::NamedValue aValue = rProperties[i]; + ::rtl::OUString sName = aValue.Name; + uno::Any aAny = aValue.Value; + + if ( sName.equalsAscii("Title") ) + aAny >>= sTitle; + else if ( sName.equalsAscii("ToolTip") ) + aAny >>= sToolTip; + else if ( sName.equalsAscii("PageURL") ) + aAny >>= sPageURL; + else if ( sName.equalsAscii("EventHdl") ) + aAny >>= sEventHdl; + else if ( sName.equalsAscii("Image") ) + aAny >>= xImage; + else if ( sName.equalsAscii("Disabled") ) + aAny >>= bDisabled; + } + + TabEntry* pEntry = new TabEntry( nIndex, sPageURL, sEventHdl ); + m_TabList.push_back( pEntry ); + USHORT nIdx = static_cast< USHORT >( nIndex ); + m_aTabCtrl.InsertPage( nIdx, sTitle ); + if ( sToolTip.getLength() > 0 ) + m_aTabCtrl.SetHelpText( nIdx, sToolTip ); + if ( xImage.is() ) + m_aTabCtrl.SetPageImage( nIdx, Image( xImage ) ); + if ( bDisabled ) + m_aTabCtrl.EnablePage( nIdx, false );
+
+ return pEntry->m_pPage; +} + +// ----------------------------------------------------------------------- + +void FwkTabWindow::ActivatePage( sal_Int32 nIndex ) +{ + m_aTabCtrl.SetCurPageId( static_cast< USHORT >( nIndex ) ); + ActivatePageHdl( &m_aTabCtrl ); +} + +// ----------------------------------------------------------------------- + +void FwkTabWindow::RemovePage( sal_Int32 nIndex ) +{ + m_aTabCtrl.RemovePage( static_cast< USHORT >( nIndex ) ); +} + +// ----------------------------------------------------------------------- + +sal_Int32 FwkTabWindow::GetActivePageId() const +{ + return m_aTabCtrl.GetCurPageId(); +} + +// ----------------------------------------------------------------------- +void FwkTabWindow::Resize()
+{
+ Size aPageSize = GetSizePixel(); + m_aTabCtrl.SetTabPageSizePixel( aPageSize ); +}
+ +} // namespace framework + diff --git a/framework/source/classes/makefile.mk b/framework/source/classes/makefile.mk index 5129458888..a80bf0b87a 100644 --- a/framework/source/classes/makefile.mk +++ b/framework/source/classes/makefile.mk @@ -59,7 +59,8 @@ SLOFILES= \ $(SLO)$/fwkresid.obj \ $(SLO)$/framelistanalyzer.obj \ $(SLO)$/sfxhelperfunctions.obj \ - $(SLO)$/menuextensionsupplier.obj + $(SLO)$/menuextensionsupplier.obj \ + $(SLO)$/fwktabwindow.obj SRS1NAME=$(TARGET) SRC1FILES =\ diff --git a/framework/source/classes/sfxhelperfunctions.cxx b/framework/source/classes/sfxhelperfunctions.cxx index d3b052e9c8..f6d65257ad 100644 --- a/framework/source/classes/sfxhelperfunctions.cxx +++ b/framework/source/classes/sfxhelperfunctions.cxx @@ -38,6 +38,9 @@ static pfunc_setToolBoxControllerCreator pToolBoxControllerCreator = NULL; static pfunc_setStatusBarControllerCreator pStatusBarControllerCreator = NULL; static pfunc_getRefreshToolbars pRefreshToolbars = NULL; +static pfunc_createDockingWindow pCreateDockingWindow = NULL; +static pfunc_isDockingWindowVisible pIsDockingWindowVisible = NULL; + using namespace ::com::sun::star::uno; @@ -48,6 +51,7 @@ namespace framework pfunc_setToolBoxControllerCreator SAL_CALL SetToolBoxControllerCreator( pfunc_setToolBoxControllerCreator pSetToolBoxControllerCreator ) { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); pfunc_setToolBoxControllerCreator pOldSetToolBoxControllerCreator = pToolBoxControllerCreator; pToolBoxControllerCreator = pSetToolBoxControllerCreator; return pOldSetToolBoxControllerCreator; @@ -55,14 +59,21 @@ pfunc_setToolBoxControllerCreator SAL_CALL SetToolBoxControllerCreator( pfunc_se svt::ToolboxController* SAL_CALL CreateToolBoxController( const Reference< XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const ::rtl::OUString& aCommandURL ) { - if ( pToolBoxControllerCreator ) - return (*pToolBoxControllerCreator)( rFrame, pToolbox, nID, aCommandURL ); + pfunc_setToolBoxControllerCreator pFactory = NULL; + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + pFactory = pToolBoxControllerCreator; + } + + if ( pFactory ) + return (*pFactory)( rFrame, pToolbox, nID, aCommandURL ); else return NULL; } pfunc_setStatusBarControllerCreator SAL_CALL SetStatusBarControllerCreator( pfunc_setStatusBarControllerCreator pSetStatusBarControllerCreator ) { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); pfunc_setStatusBarControllerCreator pOldSetStatusBarControllerCreator = pSetStatusBarControllerCreator; pStatusBarControllerCreator = pSetStatusBarControllerCreator; return pOldSetStatusBarControllerCreator; @@ -70,14 +81,21 @@ pfunc_setStatusBarControllerCreator SAL_CALL SetStatusBarControllerCreator( pfun svt::StatusbarController* SAL_CALL CreateStatusBarController( const Reference< XFrame >& rFrame, StatusBar* pStatusBar, unsigned short nID, const ::rtl::OUString& aCommandURL ) { - if ( pStatusBarControllerCreator ) - return (*pStatusBarControllerCreator)( rFrame, pStatusBar, nID, aCommandURL ); + pfunc_setStatusBarControllerCreator pFactory = NULL; + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + pFactory = pStatusBarControllerCreator; + } + + if ( pFactory ) + return (*pFactory)( rFrame, pStatusBar, nID, aCommandURL ); else return NULL; } pfunc_getRefreshToolbars SAL_CALL SetRefreshToolbars( pfunc_getRefreshToolbars pNewRefreshToolbarsFunc ) { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); pfunc_getRefreshToolbars pOldFunc = pRefreshToolbars; pRefreshToolbars = pNewRefreshToolbarsFunc; @@ -86,8 +104,58 @@ pfunc_getRefreshToolbars SAL_CALL SetRefreshToolbars( pfunc_getRefreshToolbars p void SAL_CALL RefreshToolbars( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ) { - if ( pRefreshToolbars ) - (*pRefreshToolbars)( rFrame ); + pfunc_getRefreshToolbars pCallback = NULL; + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + pCallback = pRefreshToolbars; + } + + if ( pCallback ) + (*pCallback)( rFrame ); +} + +pfunc_createDockingWindow SAL_CALL SetDockingWindowCreator( pfunc_createDockingWindow pNewCreateDockingWindow ) +{ + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + pfunc_createDockingWindow pOldFunc = pCreateDockingWindow; + pCreateDockingWindow = pNewCreateDockingWindow; + + return pOldFunc; +} + +void SAL_CALL CreateDockingWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& rResourceURL ) +{ + pfunc_createDockingWindow pFactory = NULL; + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + pFactory = pCreateDockingWindow; + } + + if ( pFactory ) + (*pFactory)( rFrame, rResourceURL ); +} + +pfunc_isDockingWindowVisible SAL_CALL SetIsDockingWindowVisible( pfunc_isDockingWindowVisible pNewIsDockingWindowVisible) +{ + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + pfunc_isDockingWindowVisible pOldFunc = pIsDockingWindowVisible; + pIsDockingWindowVisible = pNewIsDockingWindowVisible; + + return pOldFunc; +} + +bool SAL_CALL IsDockingWindowVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& rResourceURL ) +{ + pfunc_isDockingWindowVisible pCall = NULL; + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + pCall = pIsDockingWindowVisible; + } + + if ( pIsDockingWindowVisible ) + return (*pIsDockingWindowVisible)( rFrame, rResourceURL ); + else + return false; } } diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 34c0dbb494..8bb13f7a33 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -126,6 +126,10 @@ using namespace ::com::sun::star::frame; #define UIRESOURCE_URL_ASCII "private:resource" #define UIRESOURCE_URL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( UIRESOURCE_URL_ASCII )) +// ATTENTION! +// This value is directly copied from the sfx2 project. +// You have to change BOTH values, see sfx2/inc/sfx2/sfxsids.hrc (SID_DOCKWIN_START) +static const sal_Int32 DOCKWIN_ID_BASE = 9800; // convert alignment constant to vcl's WindowAlign type static WindowAlign ImplConvertAlignment( sal_Int16 aAlignment ) @@ -299,6 +303,43 @@ static sal_Bool implts_isFrameOrWindowTop( const css::uno::Reference< css::frame return sal_False; } +static void impl_setDockingWindowVisibility( const css::uno::Reference< css::lang::XMultiServiceFactory>& rSMGR, const css::uno::Reference< css::frame::XFrame >& rFrame, const ::rtl::OUString& rDockingWindowName, bool bVisible ) +{ + const ::rtl::OUString aDockWinPrefixCommand( RTL_CONSTASCII_USTRINGPARAM( "DockingWindow" )); + css::uno::WeakReference< css::frame::XDispatchHelper > xDispatchHelper; + + sal_Int32 nID = rDockingWindowName.toInt32(); + sal_Int32 nIndex = nID - DOCKWIN_ID_BASE; + + css::uno::Reference< css::frame::XDispatchProvider > xProvider(rFrame, css::uno::UNO_QUERY); + if ( nIndex >= 0 && xProvider.is() ) + { + ::rtl::OUString aDockWinCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:" )); + ::rtl::OUString aDockWinArgName( aDockWinPrefixCommand ); + + aDockWinArgName += ::rtl::OUString::valueOf( nIndex ); + + css::uno::Sequence< css::beans::PropertyValue > aArgs(1); + aArgs[0].Name = aDockWinArgName; + aArgs[0].Value = css::uno::makeAny( bVisible ); + + css::uno::Reference< css::frame::XDispatchHelper > xDispatcher( xDispatchHelper ); + if ( !xDispatcher.is()) + { + xDispatcher = css::uno::Reference< css::frame::XDispatchHelper >( + rSMGR->createInstance(SERVICENAME_DISPATCHHELPER), css::uno::UNO_QUERY_THROW); + } + + aDockWinCommand = aDockWinCommand + aDockWinArgName; + xDispatcher->executeDispatch( + xProvider, + aDockWinCommand, + ::rtl::OUString::createFromAscii("_self"), + 0, + aArgs); + } +} + //***************************************************************************************************************** // XInterface, XTypeProvider, XServiceInfo //***************************************************************************************************************** @@ -4249,6 +4290,13 @@ throw (RuntimeException) implts_createProgressBar(); bNotify = sal_True; } + else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" )) + { + aWriteLock.unlock(); + + // The docking window is created by a factory method located in the sfx2 library. + CreateDockingWindow( xFrame, aElementName ); + } } /* SAFE AREA ----------------------------------------------------------------------------------------------- */ @@ -4305,7 +4353,7 @@ throw (RuntimeException) bMustLayouted = sal_True; bNotify = sal_True; } - else + else if ( aElementType.equalsIgnoreAsciiCaseAscii( "toolbar" )) { UIElementVector::iterator pIter; @@ -4364,6 +4412,16 @@ throw (RuntimeException) } } } + else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" )) + { + css::uno::Reference< css::frame::XFrame > xFrame( m_xFrame ); + css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR( m_xSMGR ); + aWriteLock.unlock(); + + impl_setDockingWindowVisibility( xSMGR, xFrame, aElementName, false ); + bMustLayouted = sal_False; + bNotify = sal_False; + } } aWriteLock.unlock(); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ @@ -4445,7 +4503,7 @@ throw (::com::sun::star::uno::RuntimeException) bResult = sal_True; bNotify = sal_True; } - else + else if ( aElementType.equalsIgnoreAsciiCaseAscii( "toolbar" )) { if ( m_bVisible ) { @@ -4526,6 +4584,13 @@ throw (::com::sun::star::uno::RuntimeException) } } } + else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" )) + { + css::uno::Reference< css::frame::XFrame > xFrame( m_xFrame ); + aWriteLock.unlock(); + + CreateDockingWindow( xFrame, aElementName ); + } } if ( bNotify ) @@ -4636,7 +4701,7 @@ throw (RuntimeException) { bNotify = bResult = implts_showProgressBar(); } - else + else if ( aElementType.equalsIgnoreAsciiCaseAscii( "toolbar" )) { UIElementVector::iterator pIter; @@ -4677,6 +4742,15 @@ throw (RuntimeException) } } } + else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" )) + { + ReadGuard aReadGuard( m_aLock ); + css::uno::Reference< css::frame::XFrame > xFrame( m_xFrame ); + css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR( m_xSMGR ); + aReadGuard.unlock(); + + impl_setDockingWindowVisibility( xSMGR, xFrame, aElementName, true ); + } } if ( bNotify ) @@ -4752,7 +4826,7 @@ throw (RuntimeException) { bResult = bNotify = implts_hideProgressBar(); } - else + else if ( aElementType.equalsIgnoreAsciiCaseAscii( "toolbar" )) { UIElementVector::iterator pIter; @@ -4781,6 +4855,15 @@ throw (RuntimeException) } } } + else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" )) + { + ReadGuard aReadGuard( m_aLock ); + css::uno::Reference< css::frame::XFrame > xFrame( m_xFrame ); + css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR( m_xSMGR ); + aReadGuard.unlock(); + + impl_setDockingWindowVisibility( xSMGR, xFrame, aElementName, false ); + } } if ( bNotify ) @@ -5225,7 +5308,7 @@ throw (RuntimeException) if ( m_aProgressBarElement.m_xUIElement.is() ) return m_aProgressBarElement.m_bVisible; } - else + else if ( aElementType.equalsIgnoreAsciiCaseAscii( "toolbar" )) { UIElementVector::const_iterator pIter; @@ -5246,6 +5329,14 @@ throw (RuntimeException) } } } + else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" )) + { + ReadGuard aReadGuard( m_aLock ); + css::uno::Reference< css::frame::XFrame > xFrame( m_xFrame ); + aReadGuard.unlock(); + + return IsDockingWindowVisible( xFrame, aElementName ); + } } return sal_False; diff --git a/framework/source/register/registerservices.cxx b/framework/source/register/registerservices.cxx index 3456fa5112..48d383ce7b 100644 --- a/framework/source/register/registerservices.cxx +++ b/framework/source/register/registerservices.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * 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 @@ -61,13 +61,10 @@ =================================================================================================================*/ #include <services/urltransformer.hxx> #include <services/desktop.hxx> - - +#include <services/tabwindowservice.hxx> #include <services/frame.hxx> #include <services/modulemanager.hxx> - #include <dispatch/oxt_handler.hxx> - #include <jobs/jobexecutor.hxx> #include <recording/dispatchrecordersupplier.hxx> #include <recording/dispatchrecorder.hxx> @@ -87,10 +84,7 @@ #include <uielement/footermenucontroller.hxx> #include <uielement/controlmenucontroller.hxx> #include <uielement/macrosmenucontroller.hxx> - -#ifndef __FRAMEWORK_UIELEMENT_UICOMMANDDESCRIPTION_HXX_ #include <uielement/uicommanddescription.hxx> -#endif #include <uiconfiguration/uiconfigurationmanager.hxx> #include <uiconfiguration/moduleuicfgsupplier.hxx> #include <uiconfiguration/moduleuiconfigurationmanager.hxx> @@ -109,10 +103,7 @@ #include <helper/statusindicatorfactory.hxx> #include <uielement/recentfilesmenucontroller.hxx> #include <uifactory/statusbarfactory.hxx> - -#ifndef __FRAMEWORK_UIELEMENT_UICATEGORYDESCRPTION_HXX_ #include <uiconfiguration/uicategorydescription.hxx> -#endif #include <services/sessionlistener.hxx> #include <uielement/logoimagestatusbarcontroller.hxx> #include <uielement/logotextstatusbarcontroller.hxx> @@ -120,13 +111,11 @@ #include <services/taskcreatorsrv.hxx> #include <uielement/simpletextstatusbarcontroller.hxx> #include <services/uriabbreviation.hxx> - #include <dispatch/popupmenudispatcher.hxx> - #include <uielement/langselectionstatusbarcontroller.hxx> #include <uielement/langselectionmenucontroller.hxx> - #include <uiconfiguration/imagemanager.hxx> +#include <uifactory/windowcontentfactorymanager.hxx> COMPONENTGETIMPLEMENTATIONENVIRONMENT @@ -184,6 +173,8 @@ COMPONENTWRITEINFO ( COMPONENTINFO( ::framework::URLTransformer COMPONENTINFO( ::framework::ImageManager ) COMPONENTINFO( ::framework::LangSelectionStatusbarController ) COMPONENTINFO( ::framework::LanguageSelectionMenuController ) + COMPONENTINFO( ::framework::TabWindowService ) + COMPONENTINFO( ::framework::WindowContentFactoryManager ) ) COMPONENTGETFACTORY ( IFFACTORY( ::framework::URLTransformer ) else @@ -241,6 +232,8 @@ COMPONENTGETFACTORY ( IFFACTORY( ::framework::URLTransformer ) else IFFACTORY( ::framework::ImageManager ) else IFFACTORY( ::framework::PopupMenuDispatcher ) else IFFACTORY( ::framework::LangSelectionStatusbarController ) else - IFFACTORY( ::framework::LanguageSelectionMenuController ) + IFFACTORY( ::framework::LanguageSelectionMenuController ) else + IFFACTORY( ::framework::WindowContentFactoryManager ) else + IFFACTORY( ::framework::TabWindowService ) ) diff --git a/framework/source/services/fwk_services.src b/framework/source/services/fwk_services.src index c629d779ac..b3916da9e3 100644 --- a/framework/source/services/fwk_services.src +++ b/framework/source/services/fwk_services.src @@ -1,7 +1,7 @@ /************************************************************************* * * 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 @@ -170,4 +170,13 @@ Resource RES_BACKING_IMAGES_HC }; }; +Window WIN_TABWINDOW +{ + OutputSize = TRUE ; + SVLook = TRUE ; + TabControl TC_TABCONTROL + { + OutputSize = TRUE ; + }; +}; diff --git a/framework/source/services/makefile.mk b/framework/source/services/makefile.mk index 304def5e9d..a7360e854e 100644 --- a/framework/source/services/makefile.mk +++ b/framework/source/services/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -41,22 +41,23 @@ ENABLE_EXCEPTIONS= TRUE # --- Generate ----------------------------------------------------- -SLOFILES= \ - $(SLO)$/desktop.obj \ - $(SLO)$/frame.obj \ - $(SLO)$/urltransformer.obj \ - $(SLO)$/mediatypedetectionhelper.obj \ - $(SLO)$/substitutepathvars.obj \ - $(SLO)$/pathsettings.obj \ - $(SLO)$/backingcomp.obj \ - $(SLO)$/backingwindow.obj \ - $(SLO)$/dispatchhelper.obj \ - $(SLO)$/license.obj \ - $(SLO)$/modulemanager.obj \ - $(SLO)$/autorecovery.obj \ - $(SLO)$/sessionlistener.obj \ - $(SLO)$/taskcreatorsrv.obj \ - $(SLO)$/uriabbreviation.obj +SLOFILES=\ + $(SLO)$/desktop.obj \ + $(SLO)$/frame.obj \ + $(SLO)$/urltransformer.obj \ + $(SLO)$/mediatypedetectionhelper.obj \ + $(SLO)$/substitutepathvars.obj \ + $(SLO)$/pathsettings.obj \ + $(SLO)$/backingcomp.obj \ + $(SLO)$/backingwindow.obj \ + $(SLO)$/dispatchhelper.obj \ + $(SLO)$/license.obj \ + $(SLO)$/modulemanager.obj \ + $(SLO)$/autorecovery.obj \ + $(SLO)$/sessionlistener.obj \ + $(SLO)$/taskcreatorsrv.obj \ + $(SLO)$/uriabbreviation.obj \ + $(SLO)$/tabwindowservice.obj SRS1NAME=$(TARGET) SRC1FILES= fwk_services.src diff --git a/framework/source/services/tabwindowservice.cxx b/framework/source/services/tabwindowservice.cxx new file mode 100644 index 0000000000..0736f0cf49 --- /dev/null +++ b/framework/source/services/tabwindowservice.cxx @@ -0,0 +1,476 @@ +/************************************************************************* + * + * 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: urltransformer.cxx,v $ + * $Revision: 1.17 $ + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_framework.hxx" + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#include <services/tabwindowservice.hxx> +#include <classes/fwktabwindow.hxx> +#include <threadhelp/resetableguard.hxx> +#include <services.h> +#include <properties.h> + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ + +#include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> + +//_________________________________________________________________________________________________________________ +// includes of other projects +//_________________________________________________________________________________________________________________ + +#include <toolkit/helper/vclunohelper.hxx> +#include <tools/urlobj.hxx> +#include <rtl/ustrbuf.hxx> +#include <vcl/svapp.hxx> + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +namespace framework{ + +//_________________________________________________________________________________________________________________ +// non exported definitions +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// declarations +//_________________________________________________________________________________________________________________ + +//***************************************************************************************************************** +// css::uno::XInterface, XTypeProvider, XServiceInfo +//***************************************************************************************************************** + +DEFINE_XINTERFACE_5 ( TabWindowService , + OWeakObject , + DIRECT_INTERFACE(css::lang::XTypeProvider ), + DIRECT_INTERFACE(css::lang::XServiceInfo ), + DIRECT_INTERFACE(css::awt::XSimpleTabController), + DIRECT_INTERFACE(css::beans::XPropertySet ), + DIRECT_INTERFACE(css::beans::XPropertySetInfo ) + ) + +DEFINE_XTYPEPROVIDER_5 ( TabWindowService , + css::lang::XTypeProvider , + css::lang::XServiceInfo , + css::awt::XSimpleTabController , + css::beans::XPropertySet , + css::beans::XPropertySetInfo + ) + +DEFINE_XSERVICEINFO_MULTISERVICE ( TabWindowService , + OWeakObject , + SERVICENAME_TABWINDOWSERVICE , + IMPLEMENTATIONNAME_TABWINDOWSERVICE + ) + +DEFINE_INIT_SERVICE ( TabWindowService, + { + impl_initializePropInfo();
+ m_aTransactionManager.setWorkingMode( E_WORK ); + } + ) + +//***************************************************************************************************************** +// constructor +//***************************************************************************************************************** +TabWindowService::TabWindowService( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ) + // Init baseclasses first + // Attention: + // Don't change order of initialization! + // ThreadHelpBase is a struct with a mutex as member. We can't use a mutex as member, while + // we must garant right initialization and a valid value of this! First initialize + // baseclasses and then members. And we need the mutex for other baseclasses !!! + : ThreadHelpBase ( &Application::GetSolarMutex() ) + , TransactionBase ( ) + , PropertySetHelper ( xFactory , + &m_aLock , + &m_aTransactionManager , + sal_False ) // FALSE => dont release shared mutex on calling us! + , OWeakObject ( ) + + // Init member + , m_xFactory ( xFactory ) + , m_xTabWin ( ) + , m_pTabWin ( NULL ) + , m_lTabPageInfos ( ) + , m_lListener ( m_aLock.getShareableOslMutex()) + , m_nPageIndexCounter ( 1 ) + , m_nCurrentPageIndex ( 0 ) +{ + // Safe impossible cases. + // Method not defined for all incoming parameter. + LOG_ASSERT( xFactory.is(), "TabWindowService::TabWindowService()\nInvalid parameter detected!\n" ) +} + +//***************************************************************************************************************** +// destructor +//***************************************************************************************************************** +TabWindowService::~TabWindowService() +{
+} + +//***************************************************************************************************************** +// XSimpleTabController +//***************************************************************************************************************** +::sal_Int32 SAL_CALL TabWindowService::insertTab() + throw ( css::uno::RuntimeException ) +{ + // SAFE -> + ResetableGuard aGuard( m_aLock ); + + ::sal_Int32 nID = m_nPageIndexCounter++; + TTabPageInfo aInfo(m_nPageIndexCounter); + + m_lTabPageInfos[nID] = aInfo; + + return nID; +} + +//***************************************************************************************************************** +// XSimpleTabController +//***************************************************************************************************************** +void SAL_CALL TabWindowService::removeTab(::sal_Int32 nID) + throw (css::lang::IndexOutOfBoundsException, + css::uno::RuntimeException ) +{ + // SAFE -> + ResetableGuard aGuard(m_aLock); + + // throws suitable IndexOutOfBoundsException .-) + TTabPageInfoHash::iterator pIt = impl_getTabPageInfo (nID); + m_lTabPageInfos.erase(pIt); + + FwkTabWindow* pTabWin = mem_TabWin (); + if (pTabWin) + pTabWin->RemovePage(nID); +} + +//***************************************************************************************************************** +// XSimpleTabController +//***************************************************************************************************************** +void SAL_CALL TabWindowService::setTabProps( ::sal_Int32 nID , + const css::uno::Sequence< css::beans::NamedValue >& lProperties) + throw (css::lang::IndexOutOfBoundsException, + css::uno::RuntimeException ) +{ + // SAFE -> + ResetableGuard aGuard(m_aLock); + + // throws suitable IndexOutOfBoundsException .-) + TTabPageInfoHash::iterator pIt = impl_getTabPageInfo (nID); + TTabPageInfo& rInfo = pIt->second; + rInfo.m_lProperties = lProperties; + + if ( ! rInfo.m_bCreated) + { + FwkTabWindow* pTabWin = mem_TabWin (); + if (pTabWin) + { + pTabWin->AddTabPage(rInfo.m_nIndex, rInfo.m_lProperties); + pTabWin->ActivatePage (rInfo.m_nIndex); + rInfo.m_bCreated = sal_True; + } + } +} + +//***************************************************************************************************************** +// XSimpleTabController +//***************************************************************************************************************** +css::uno::Sequence< css::beans::NamedValue > SAL_CALL TabWindowService::getTabProps(::sal_Int32 nID) + throw (css::lang::IndexOutOfBoundsException, + css::uno::RuntimeException ) +{ + // SAFE -> + ResetableGuard aGuard(m_aLock); + + // throws suitable IndexOutOfBoundsException .-) + TTabPageInfoHash::const_iterator pIt = impl_getTabPageInfo (nID); + const TTabPageInfo& rInfo = pIt->second; + + return rInfo.m_lProperties; +} + +//***************************************************************************************************************** +// XSimpleTabController +//***************************************************************************************************************** +void SAL_CALL TabWindowService::activateTab(::sal_Int32 nID) + throw (css::lang::IndexOutOfBoundsException, + css::uno::RuntimeException ) +{ + // SAFE -> + ResetableGuard aGuard(m_aLock); + + // throws suitable IndexOutOfBoundsException .-) + impl_checkTabIndex (nID); + m_nCurrentPageIndex = nID; + + FwkTabWindow* pTabWin = mem_TabWin (); + if (pTabWin) + pTabWin->ActivatePage(nID); +} + +//***************************************************************************************************************** +// XSimpleTabController +//***************************************************************************************************************** +::sal_Int32 SAL_CALL TabWindowService::getActiveTabID() + throw (css::uno::RuntimeException) +{ + // SAFE-> + ResetableGuard aGuard( m_aLock ); + return m_nCurrentPageIndex; +} + +//***************************************************************************************************************** +// XSimpleTabController +//***************************************************************************************************************** +void SAL_CALL TabWindowService::addTabListener(const css::uno::Reference< css::awt::XTabListener >& xListener) + throw (css::uno::RuntimeException) +{ + m_lListener.addInterface(::getCppuType((const css::uno::Reference< css::awt::XTabListener >*)NULL), xListener); +} + +//***************************************************************************************************************** +// XSimpleTabController +//***************************************************************************************************************** +void SAL_CALL TabWindowService::removeTabListener(const css::uno::Reference< css::awt::XTabListener >& xListener) + throw (css::uno::RuntimeException) +{ + m_lListener.removeInterface(::getCppuType((const css::uno::Reference< css::awt::XTabListener >*)NULL), xListener); +} + +//***************************************************************************************************************** +// XComponent +//***************************************************************************************************************** +void SAL_CALL TabWindowService::dispose() + throw (css::uno::RuntimeException) +{ + // SAFE-> + ResetableGuard aGuard(m_aLock); + + css::uno::Reference< css::uno::XInterface > xThis(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY); + css::lang::EventObject aEvent(xThis); + + m_lListener.disposeAndClear (aEvent); + + m_pTabWin = NULL; + m_xTabWin.clear (); +} + +//***************************************************************************************************************** +// XComponent +//***************************************************************************************************************** +void SAL_CALL TabWindowService::addEventListener(const css::uno::Reference< css::lang::XEventListener >& xListener) + throw (css::uno::RuntimeException) +{ + m_lListener.addInterface(::getCppuType((const css::uno::Reference< css::lang::XEventListener >*)NULL), xListener); +} + +//***************************************************************************************************************** +// XComponent +//***************************************************************************************************************** +void SAL_CALL TabWindowService::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener) + throw (css::uno::RuntimeException) +{ + m_lListener.removeInterface(::getCppuType((const css::uno::Reference< css::lang::XEventListener >*)NULL), xListener); +} + +//***************************************************************************************************************** +void TabWindowService::impl_initializePropInfo() +{ + impl_setPropertyChangeBroadcaster(static_cast< css::awt::XSimpleTabController* >(this)); + + impl_addPropertyInfo( + css::beans::Property( + TABWINDOWSERVICE_PROPNAME_WINDOW, + TABWINDOWSERVICE_PROPHANDLE_WINDOW, + ::getCppuType((const css::uno::Reference< css::awt::XWindow >*)NULL), + css::beans::PropertyAttribute::TRANSIENT)); +} + +//***************************************************************************************************************** +void SAL_CALL TabWindowService::impl_setPropertyValue(const ::rtl::OUString& /*sProperty*/, + sal_Int32 /*nHandle */, + const css::uno::Any& /*aValue */) + +{ +} + +//***************************************************************************************************************** +css::uno::Any SAL_CALL TabWindowService::impl_getPropertyValue(const ::rtl::OUString& /*sProperty*/, + sal_Int32 nHandle ) +{ + /* There is no need to lock any mutex here. Because we share the + solar mutex with our base class. And we said to our base class: "dont release it on calling us" .-) + see ctor of PropertySetHelper for further informations. + */ + css::uno::Any aValue; + + switch (nHandle) + { + case TABWINDOWSERVICE_PROPHANDLE_WINDOW: + { + mem_TabWin (); // force "creation on demand" of m_xTabWin :-) + aValue <<= m_xTabWin; + } + break; + } + + return aValue; +} + +//***************************************************************************************************************** +// TabWindowService +//***************************************************************************************************************** +IMPL_LINK( TabWindowService, EventListener, VclSimpleEvent*, pEvent ) +{ + if ( + ( ! pEvent ) || + ( pEvent->ISA(VclWindowEvent) ) + ) + return 0; + + ULONG nEventId = pEvent->GetId(); + VclWindowEvent* pWinEvt = static_cast< VclWindowEvent* >(pEvent); + + css::uno::Reference< css::uno::XInterface > xThis ( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY ); + css::lang::EventObject aEvent( xThis ); + + if (nEventId == VCLEVENT_OBJECT_DYING) + { + m_lListener.disposeAndClear (aEvent); + return 0; + } + + ::cppu::OInterfaceContainerHelper* pContainer = m_lListener.getContainer(::getCppuType((const css::uno::Reference< css::awt::XTabListener >*) NULL)); + if ( ! pContainer) + return 0; + + ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); + while (pIterator.hasMoreElements()) + { + try + { + css::awt::XTabListener* pListener = (css::awt::XTabListener*)pIterator.next(); + + switch (nEventId) + { + case VCLEVENT_TABPAGE_ACTIVATE : + pListener->activated( (sal_Int32)(ULONG)pWinEvt->GetData() ); + break; + + case VCLEVENT_TABPAGE_DEACTIVATE : + pListener->deactivated( (sal_Int32)(ULONG)pWinEvt->GetData() ); + break; + + case VCLEVENT_TABPAGE_INSERTED : + pListener->inserted( (sal_Int32)(ULONG)pWinEvt->GetData() ); + break; + + case VCLEVENT_TABPAGE_REMOVED : + pListener->removed( (sal_Int32)(ULONG)pWinEvt->GetData() ); + break; + + case VCLEVENT_TABPAGE_PAGETEXTCHANGED : + case VCLEVENT_TABPAGE_REMOVEDALL : + break; + } + } + catch(const css::uno::RuntimeException&) + { + pIterator.remove(); + } + } + + return 0; +} + +//***************************************************************************************************************** +// TabWindowService +//***************************************************************************************************************** +void TabWindowService::impl_checkTabIndex (::sal_Int32 nID) + throw (css::lang::IndexOutOfBoundsException) +{ + if ( + (nID <= 0 ) || + (nID > m_nPageIndexCounter) + ) + { + throw css::lang::IndexOutOfBoundsException( + ::rtl::OUString::createFromAscii("Tab index out of bounds."), + css::uno::Reference< css::uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY )); + } +} + +//***************************************************************************************************************** +// TabWindowService +//***************************************************************************************************************** +TTabPageInfoHash::iterator TabWindowService::impl_getTabPageInfo(::sal_Int32 nID) + throw (css::lang::IndexOutOfBoundsException) +{ + TTabPageInfoHash::iterator pIt = m_lTabPageInfos.find(nID); + if (pIt == m_lTabPageInfos.end ()) + throw css::lang::IndexOutOfBoundsException( + ::rtl::OUString::createFromAscii("Tab index out of bounds."), + css::uno::Reference< css::uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY )); + return pIt; +} + +//***************************************************************************************************************** +// TabWindowService +//***************************************************************************************************************** +FwkTabWindow* TabWindowService::mem_TabWin () +{ + FwkTabWindow* pWin = NULL; + + if ( ! m_xTabWin.is ()) + {
+ Window* pFakeParent = dynamic_cast< Window* >(Application::GetDefaultDevice ());
+
+ m_pTabWin = new FwkTabWindow (pFakeParent); + m_xTabWin = VCLUnoHelper::GetInterface (m_pTabWin); + + m_pTabWin->AddEventListener( LINK( this, TabWindowService, EventListener ) ); + } + + if (m_xTabWin.is ()) + pWin = m_pTabWin; + + return pWin; +} + +} // namespace framework diff --git a/framework/source/threadhelp/fairrwlock.cxx b/framework/source/threadhelp/fairrwlock.cxx deleted file mode 100644 index 1feab9bdf3..0000000000 --- a/framework/source/threadhelp/fairrwlock.cxx +++ /dev/null @@ -1,250 +0,0 @@ -/************************************************************************* - * - * 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: fairrwlock.cxx,v $ - * $Revision: 1.7 $ - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_framework.hxx" - -//_________________________________________________________________________________________________________________ -// my own includes -//_________________________________________________________________________________________________________________ -#include <threadhelp/fairrwlock.hxx> -#include <threadhelp/resetableguard.hxx> -#include <macros/debug.hxx> - -//_________________________________________________________________________________________________________________ -// interface includes -//_________________________________________________________________________________________________________________ -#include <com/sun/star/uno/XInterface.hpp> -#include <com/sun/star/lang/DisposedException.hpp> - -//_________________________________________________________________________________________________________________ -// other includes -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// const -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// namespace -//_________________________________________________________________________________________________________________ - -namespace framework{ - -//_________________________________________________________________________________________________________________ -// non exported const -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// non exported declarations -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// definitions -//_________________________________________________________________________________________________________________ - -/*-****************************************************************************************************//** - @short standard ctor - @descr Initialize instance with right start values for correct working. - no reader could exist => m_nReadCount = 0 - don't block first comming writer => m_aWriteCondition.set() - - @seealso - - - @param - - @return - - - @onerror - -*//*-*****************************************************************************************************/ -FairRWLock::FairRWLock() - : m_nReadCount( 0 ) -{ - m_aWriteCondition.set(); -} - -/*-****************************************************************************************************//** - @short set lock for reading - @descr A guard should call this method to acquire read access on your member. - Writing isn't allowed then - but nobody could check it for you! - - @seealso method releaseReadAccess() - - @param - - @return - - - @onerror - -*//*-*****************************************************************************************************/ -void SAL_CALL FairRWLock::acquireReadAccess() -{ - // Put call in "SERIALIZE"-queue! - // After successful acquiring this mutex we are alone ... - ResetableGuard aSerializeGuard( m_aSerializer ); - - // ... but we should synchronize us with other reader! - // May be - they will unregister himself by using releaseReadAccess()! - ResetableGuard aAccessGuard( m_aAccessLock ); - - // Now we must register us as reader by increasing counter. - // If this the first writer we must close door for possible writer. - // Other reader don't look for this barrier - they work parallel to us! - if( m_nReadCount == 0 ) - { - m_aWriteCondition.reset(); - } - ++m_nReadCount; -} - -/*-****************************************************************************************************//** - @short reset lock for reading - @descr A guard should call this method to release read access on your member. - - @seealso method acquireReadAccess() - - @param - - @return - - - @onerror - -*//*-*****************************************************************************************************/ -void SAL_CALL FairRWLock::releaseReadAccess() -{ - // The access lock is enough at this point - // because it's not allowed to wait for all reader or writer here! - // That will cause a deadlock! - ResetableGuard aAccessGuard( m_aAccessLock ); - - // Unregister as reader first! - // Open writer barrier then if it was the last reader. - --m_nReadCount; - if( m_nReadCount == 0 ) - { - m_aWriteCondition.set(); - } -} - -/*-****************************************************************************************************//** - @short set lock for writing - @descr A guard should call this method to acquire write access on your member. - Reading is allowed too - of course. - After successfully calling of this method you are the only writer. - - @seealso method setWorkingMode() - @seealso method releaseWriteAccess() - - @param "eRejectReason" , is the reason for rejected calls. - @param "eExceptionMode" , use to enable/disable throwing exceptions automaticly for rejected calls - @return - - - @onerror - -*//*-*****************************************************************************************************/ -void SAL_CALL FairRWLock::acquireWriteAccess() -{ - // You have to stand in our serialize-queue till all reader - // are registered (not for releasing them!) or writer finished their work! - // Don't use a guard to do so - because you must hold the mutex till - // you call releaseWriteAccess()! - // After succesfull acquire you have to wait for current working reader. - // Used condition will open by last gone reader object. - m_aSerializer.acquire(); - m_aWriteCondition.wait(); - - #ifdef ENABLE_MUTEXDEBUG - // A writer is an exclusiv accessor! - LOG_ASSERT2( m_nReadCount!=0, "FairRWLock::acquireWriteAccess()", "No threadsafe code detected ... : Read count != 0!" ) - #endif -} - -/*-****************************************************************************************************//** - @short reset lock for writing - @descr A guard should call this method to release write access on your member. - - @seealso method acquireWriteAccess() - - @param - - @return - - - @onerror - -*//*-*****************************************************************************************************/ -void SAL_CALL FairRWLock::releaseWriteAccess() -{ - // The only one you have to do here is to release - // hold seriliaze-mutex. All other user of these instance are blocked - // by these mutex! - // You don't need any other mutex here - you are the only one in the moment! - - #ifdef ENABLE_MUTEXDEBUG - // A writer is an exclusiv accessor! - LOG_ASSERT2( m_nReadCount!=0, "FairRWLock::releaseWriteAccess()", "No threadsafe code detected ... : Read count != 0!" ) - #endif - - m_aSerializer.release(); -} - -/*-****************************************************************************************************//** - @short downgrade a write access to a read access - @descr A guard should call this method to change a write to a read access. - New readers can work too - new writer are blocked! - - @attention Don't call this method if you are not a writer! - Results are not defined then ... - An upgrade can't be implemented realy ... because acquiring new access - will be the same - there no differences! - - @seealso - - - @param - - @return - - - @onerror - -*//*-*****************************************************************************************************/ -void SAL_CALL FairRWLock::downgradeWriteAccess() -{ - // You must be a writer to call this method! - // We can't check it - but otherwise it's your problem ... - // Thats why you don't need any mutex here. - - #ifdef ENABLE_MUTEXDEBUG - // A writer is an exclusiv accessor! - LOG_ASSERT2( m_nReadCount!=0, "FairRWLock::downgradeWriteAccess()", "No threadsafe code detected ... : Read count != 0!" ) - #endif - - // Register himself as "new" reader. - // This value must be 0 before - because we support single writer access only! - ++m_nReadCount; - // Close barrier for other writer! - // Why? - // You hold the serializer mutex - next one can be a reader OR a writer. - // They must blocked then - because you will be a reader after this call - // and writer use this condition to wait for current reader! - m_aWriteCondition.reset(); - // Open door for next waiting thread in serialize queue! - m_aSerializer.release(); -} - -} // namespace framework diff --git a/framework/source/threadhelp/gate.cxx b/framework/source/threadhelp/gate.cxx deleted file mode 100644 index 2de412b804..0000000000 --- a/framework/source/threadhelp/gate.cxx +++ /dev/null @@ -1,167 +0,0 @@ -/************************************************************************* - * - * 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: gate.cxx,v $ - * $Revision: 1.4 $ - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_framework.hxx" - -//_________________________________________________________________________________________________________________ -// my own includes -//_________________________________________________________________________________________________________________ -#include <threadhelp/gate.hxx> -#include <threadhelp/resetableguard.hxx> - -//_________________________________________________________________________________________________________________ -// interface includes -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// other includes -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// const -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// namespace -//_________________________________________________________________________________________________________________ - -namespace framework{ - -//_________________________________________________________________________________________________________________ -// non exported const -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// non exported declarations -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// definitions -//_________________________________________________________________________________________________________________ - -//***************************************************************************************************************** -// constructor -//***************************************************************************************************************** -Gate::Gate() - : m_bClosed ( sal_False ) - , m_bGapOpen ( sal_False ) -{ - open(); -} - -//***************************************************************************************************************** -// destructor -//***************************************************************************************************************** -Gate::~Gate() -{ - open(); -} - -//***************************************************************************************************************** -// public method -//***************************************************************************************************************** -void Gate::open() -{ - // We must safe access to our internal member! - ResetableGuard aLock( m_aAccessLock ); - // Set condition -> wait don't block any longer -> gate is open - m_aPassage.set(); - // Check if operation was successful! - // Check returns false if condition isn't set => m_bClosed will be true then => we must return false; opening failed - m_bClosed = ( m_aPassage.check() == sal_False ); -} - -//***************************************************************************************************************** -// public method -//***************************************************************************************************************** -void Gate::close() -{ - // We must safe access to our internal member! - ResetableGuard aLock( m_aAccessLock ); - // Reset condition -> wait blocks now -> gate is closed - m_aPassage.reset(); - // Check if operation was successful! - // Check returns false if condition was reseted => m_bClosed will be true then => we can return true; closing ok - m_bClosed = ( m_aPassage.check() == sal_False ); -} - -//***************************************************************************************************************** -// public method -//***************************************************************************************************************** -void Gate::openGap() -{ - // We must safe access to our internal member! - ResetableGuard aLock( m_aAccessLock ); - // Open passage for current waiting threads. - m_aPassage.set(); - // Check state of condition. - // If condition is set check() returns true => m_bGapOpen will be true too => we can use it as return value. - m_bGapOpen = ( m_aPassage.check() == sal_True ); -} - -//***************************************************************************************************************** -// public method -//***************************************************************************************************************** -sal_Bool Gate::wait( const TimeValue* pTimeOut ) -{ - // We must safe access to our internal member! - ResetableGuard aLock( m_aAccessLock ); - // If gate not closed - caller can pass it. - sal_Bool bSuccessful = sal_True; - if( m_bClosed == sal_True ) - { - // Otherwise first new thread must close an open gap! - if( m_bGapOpen == sal_True ) - { - m_bGapOpen = sal_False; - m_aPassage.reset(); - } - // Then we must release used access lock - - // because next call will block ... - // and if we hold the access lock nobody else can use this object without a dadlock! - aLock.unlock(); - // Wait for opening gate ... - bSuccessful = ( m_aPassage.wait( pTimeOut ) == osl_cond_result_ok ); - } - - return bSuccessful; -} - -//***************************************************************************************************************** -// public method -//***************************************************************************************************************** -sal_Bool Gate::isOpen() const -{ - // I think we never need the access lock for pure reading of this bool member ... - return !m_bClosed; -} - -} // namespace framework diff --git a/framework/source/threadhelp/readguard.cxx b/framework/source/threadhelp/readguard.cxx deleted file mode 100644 index 428034375a..0000000000 --- a/framework/source/threadhelp/readguard.cxx +++ /dev/null @@ -1,170 +0,0 @@ -/************************************************************************* - * - * 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: readguard.cxx,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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_framework.hxx" - -//_________________________________________________________________________________________________________________ -// my own includes -//_________________________________________________________________________________________________________________ -#include <threadhelp/readguard.hxx> - -//_________________________________________________________________________________________________________________ -// interface includes -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// other includes -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// const -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// namespace -//_________________________________________________________________________________________________________________ - -namespace framework{ - -//_________________________________________________________________________________________________________________ -// non exported const -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// non exported declarations -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// definitions -//_________________________________________________________________________________________________________________ - -/*-****************************************************************************************************//** - @short ctor - @descr These ctors initialize the guard with a reference to used lock member of object to protect. - Null isn't allowed as value! - - @seealso - - - @param "pLock" ,reference to used lock member of object to protect - @param "rLock" ,reference to used lock member of object to protect - @return - - - @onerror - -*//*-*****************************************************************************************************/ -ReadGuard::ReadGuard( IRWLock* pLock ) - : m_pLock ( pLock ) - , m_bLocked ( sal_False ) -{ - lock(); -} - -//***************************************************************************************************************** -ReadGuard::ReadGuard( IRWLock& rLock ) - : m_pLock ( &rLock ) - , m_bLocked ( sal_False ) -{ - lock(); -} - -/*-****************************************************************************************************//** - @short dtor - @descr We unlock the used lock member automaticly if user forget it. - - @seealso - - - @param - - @return - - - @onerror - -*//*-*****************************************************************************************************/ -ReadGuard::~ReadGuard() -{ - unlock(); -} - -/*-****************************************************************************************************//** - @short set read lock - @descr Call this method to set the read lock. The call will block till all current threads are synchronized! - - @seealso method unlock() - - @param - - @return - - - @onerror - -*//*-*****************************************************************************************************/ -void ReadGuard::lock() -{ - if( m_bLocked == sal_False ) - { - m_pLock->acquireReadAccess(); - m_bLocked = sal_True; - } -} - -/*-****************************************************************************************************//** - @short unset read lock - @descr Call this method to unlock the rw-lock temp.! - Normaly we do it at dtor automaticly for you ... - - @seealso method lock() - - @param - - @return - - - @onerror - -*//*-*****************************************************************************************************/ -void ReadGuard::unlock() -{ - if( m_bLocked == sal_True ) - { - m_pLock->releaseReadAccess(); - m_bLocked = sal_False; - } -} - -/*-****************************************************************************************************//** - @short return internal lock state - @descr For user they dont know what they are doing there ... - - @seealso - - - @param - - @return true, if lock is set, false otherwise. - - @onerror - -*//*-*****************************************************************************************************/ -sal_Bool ReadGuard::isLocked() const -{ - return m_bLocked; -} - -} // namespace framework diff --git a/framework/source/threadhelp/resetableguard.cxx b/framework/source/threadhelp/resetableguard.cxx deleted file mode 100644 index 642293f659..0000000000 --- a/framework/source/threadhelp/resetableguard.cxx +++ /dev/null @@ -1,141 +0,0 @@ -/************************************************************************* - * - * 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: resetableguard.cxx,v $ - * $Revision: 1.4 $ - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_framework.hxx" - -//_________________________________________________________________________________________________________________ -// my own includes -//_________________________________________________________________________________________________________________ -#include <threadhelp/resetableguard.hxx> - -//_________________________________________________________________________________________________________________ -// interface includes -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// other includes -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// const -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// namespace -//_________________________________________________________________________________________________________________ - -namespace framework{ - -using namespace ::osl ; - -//_________________________________________________________________________________________________________________ -// non exported const -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// non exported declarations -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// definitions -//_________________________________________________________________________________________________________________ - -//***************************************************************************************************************** -// constructor -//***************************************************************************************************************** -ResetableGuard::ResetableGuard( Mutex* pMutex ) - : m_pMutex ( pMutex ) - , m_bLocked ( sal_False ) -{ - lock(); -} - -//***************************************************************************************************************** -// constructor -//***************************************************************************************************************** -ResetableGuard::ResetableGuard( Mutex& rMutex ) - : m_pMutex ( &rMutex ) - , m_bLocked ( sal_False ) -{ - lock(); -} - -//***************************************************************************************************************** -// destructor -//***************************************************************************************************************** -ResetableGuard::~ResetableGuard() -{ - unlock(); -} - -//***************************************************************************************************************** -// public method -//***************************************************************************************************************** -void ResetableGuard::lock() -{ - if( m_bLocked == sal_False ) - { - m_bLocked = m_pMutex->acquire(); - } -} - -//***************************************************************************************************************** -// public method -//***************************************************************************************************************** -void ResetableGuard::unlock() -{ - if( m_bLocked == sal_True ) - { - m_bLocked = !(m_pMutex->release()); - } -} - -//***************************************************************************************************************** -// public method -//***************************************************************************************************************** -sal_Bool ResetableGuard::tryToLock() -{ - if( m_bLocked == sal_False ) - { - m_bLocked = m_pMutex->tryToAcquire(); - } - return m_bLocked; -} - -//***************************************************************************************************************** -// public method -//***************************************************************************************************************** -sal_Bool ResetableGuard::isLocked() const -{ - return m_bLocked; -} - -} // namespace framework diff --git a/framework/source/threadhelp/transactionguard.cxx b/framework/source/threadhelp/transactionguard.cxx deleted file mode 100644 index 80d79bcf3f..0000000000 --- a/framework/source/threadhelp/transactionguard.cxx +++ /dev/null @@ -1,162 +0,0 @@ -/************************************************************************* - * - * 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: transactionguard.cxx,v $ - * $Revision: 1.4 $ - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_framework.hxx" - -//_________________________________________________________________________________________________________________ -// my own includes -//_________________________________________________________________________________________________________________ -#include <threadhelp/transactionguard.hxx> - -//_________________________________________________________________________________________________________________ -// interface includes -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// other includes -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// const -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// namespace -//_________________________________________________________________________________________________________________ - -namespace framework{ - -//_________________________________________________________________________________________________________________ -// non exported const -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// non exported declarations -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// definitions -//_________________________________________________________________________________________________________________ - -/*-************************************************************************************************************//** - @short ctors - @descr Use these ctor methods to initialize the guard right. - Given reference must be valid - otherwise crashes could occure! - - @attention It's not neccessary to lock any mutex here! Because a ctor should not be called - from different threads at the same time ... this class use no refcount mechanism! - - @seealso - - - @param "pManager" pointer to transaction manager for using to register a request - @param "rManager" same as reference - @param "eMode" enable/disable throwing of exceptions for rejected calls - @param "eReason" returns reason for rejected calls if "eMode=E_NOEXCEPTIONS"! - @return - - - @onerror - -*//*-*************************************************************************************************************/ -TransactionGuard::TransactionGuard( ITransactionManager* pManager, EExceptionMode eMode, ERejectReason* eReason ) - : m_pManager( pManager ) -{ - // If exception mode is set to E_HARDEXCETIONS we don't need a buffer to return reason! - // We handle it private. If a call is rejected, our manager throw some exceptions ... and the reason - // could be ignorable ... - if( eReason == NULL ) - { - ERejectReason eMyReason; - m_pManager->acquire( eMode, eMyReason ); - } - else - { - m_pManager->acquire( eMode, *eReason ); - } -} - -//***************************************************************************************************************** -TransactionGuard::TransactionGuard( ITransactionManager& rManager, EExceptionMode eMode, ERejectReason* eReason ) - : m_pManager( &rManager ) -{ - // If exception mode is set to E_HARDEXCETIONS we don't need a buffer to return reason! - // We handle it private. If a call is rejected, our manager throw some exceptions ... and the reason - // could be ignorable ... - if( eReason == NULL ) - { - ERejectReason eMyReason; - m_pManager->acquire( eMode, eMyReason ); - } - else - { - m_pManager->acquire( eMode, *eReason ); - } -} - -/*-************************************************************************************************************//** - @short dtor - @descr We must release the transaction manager and can forget his pointer. - - @seealso - - - @param - - @return - - - @onerror - -*//*-*************************************************************************************************************/ -TransactionGuard::~TransactionGuard() -{ - stop(); -} - -/*-************************************************************************************************************//** - @short stop current transaction - @descr We must release the transaction manager and can forget his pointer. - - @attention We don't support any start() method here - because it is not easy to - detect if a transaction already started or not! - (combination of EExceptionMode and ERejectReason) - - @seealso - - - @param - - @return - - - @onerror - -*//*-*************************************************************************************************************/ -void TransactionGuard::stop() -{ - if( m_pManager != NULL ) - { - m_pManager->release(); - m_pManager = NULL; - } -} - -} // namespace framework diff --git a/framework/source/threadhelp/writeguard.cxx b/framework/source/threadhelp/writeguard.cxx deleted file mode 100644 index 0649cd95fa..0000000000 --- a/framework/source/threadhelp/writeguard.cxx +++ /dev/null @@ -1,214 +0,0 @@ -/************************************************************************* - * - * 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: writeguard.cxx,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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_framework.hxx" - -//_________________________________________________________________________________________________________________ -// my own includes -//_________________________________________________________________________________________________________________ -#include <threadhelp/writeguard.hxx> -#include <macros/debug.hxx> - -//_________________________________________________________________________________________________________________ -// interface includes -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// other includes -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// const -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// namespace -//_________________________________________________________________________________________________________________ - -namespace framework{ - -//_________________________________________________________________________________________________________________ -// non exported const -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// non exported declarations -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// definitions -//_________________________________________________________________________________________________________________ - -/*-****************************************************************************************************//** - @short ctor - @descr These ctors initialize the guard with a reference to used lock member of object to protect. - Null isn't allowed as value! - - @seealso - - - @param "pLock" ,reference to used lock member of object to protect - @param "rLock" ,reference to used lock member of object to protect - @return - - - @onerror - -*//*-*****************************************************************************************************/ -WriteGuard::WriteGuard( IRWLock* pLock ) - : m_pLock ( pLock ) - , m_eMode ( E_NOLOCK ) -{ - lock(); -} - -//***************************************************************************************************************** -WriteGuard::WriteGuard( IRWLock& rLock ) - : m_pLock ( &rLock ) - , m_eMode ( E_NOLOCK ) -{ - lock(); -} - -/*-****************************************************************************************************//** - @short dtor - @descr We unlock the used lock member automaticly if user forget it. - - @seealso - - - @param - - @return - - - @onerror - -*//*-*****************************************************************************************************/ -WriteGuard::~WriteGuard() -{ - unlock(); -} - -/*-****************************************************************************************************//** - @short set write lock - @descr Call this method to set the write lock. The call will block till all current threads are synchronized! - - @seealso method unlock() - - @param - - @return - - - @onerror - -*//*-*****************************************************************************************************/ -void WriteGuard::lock() -{ - switch( m_eMode ) - { - case E_NOLOCK : { - // Acquire write access and set return state. - // Mode is set later if it was successful! - m_pLock->acquireWriteAccess(); - m_eMode = E_WRITELOCK; - } - break; - case E_READLOCK : { - // User has downgrade to read access before! - // We must release it before we can set a new write access! - m_pLock->releaseReadAccess (); - m_pLock->acquireWriteAccess(); - m_eMode = E_WRITELOCK; - } - break; - } -} - -/*-****************************************************************************************************//** - @short unset write lock - @descr Call this method to unlock the rw-lock temp.! - Normaly we do it at dtor automaticly for you ... - - @seealso method lock() - - @param - - @return - - - @onerror - -*//*-*****************************************************************************************************/ -void WriteGuard::unlock() -{ - switch( m_eMode ) - { - case E_READLOCK : { - // Use has downgraded to a read lock! - m_pLock->releaseReadAccess(); - m_eMode = E_NOLOCK; - } - break; - case E_WRITELOCK : { - m_pLock->releaseWriteAccess(); - m_eMode = E_NOLOCK; - } - break; - } -} - -/*-****************************************************************************************************//** - @short downgrade write access to read access without new blocking! - @descr If this write lock is set you can change it to a "read lock". - An "upgrade" is the same like new calling "lock()"! - - @seealso - - - @param - - @return - - - @onerror - -*//*-*****************************************************************************************************/ -void WriteGuard::downgrade() -{ - if( m_eMode == E_WRITELOCK ) - { - m_pLock->downgradeWriteAccess(); - m_eMode = E_READLOCK; - } -} - -/*-****************************************************************************************************//** - @short return internal lock state - @descr For user they dont know what they are doing there ... - - @seealso - - - @param - - @return Current set lock mode. - - @onerror No error should occure. -*//*-*****************************************************************************************************/ -ELockMode WriteGuard::getMode() const -{ - return m_eMode; -} - -} // namespace framework diff --git a/framework/source/uifactory/makefile.mk b/framework/source/uifactory/makefile.mk index d742b7675f..a70beb52f3 100644 --- a/framework/source/uifactory/makefile.mk +++ b/framework/source/uifactory/makefile.mk @@ -48,7 +48,8 @@ SLOFILES= \ $(SLO)$/addonstoolboxfactory.obj \ $(SLO)$/toolbarcontrollerfactory.obj \ $(SLO)$/statusbarfactory.obj \ - $(SLO)$/statusbarcontrollerfactory.obj + $(SLO)$/statusbarcontrollerfactory.obj \ + $(SLO)$/windowcontentfactorymanager.obj # --- Targets ------------------------------------------------------ diff --git a/framework/source/uifactory/windowcontentfactorymanager.cxx b/framework/source/uifactory/windowcontentfactorymanager.cxx new file mode 100644 index 0000000000..9bf91be17a --- /dev/null +++ b/framework/source/uifactory/windowcontentfactorymanager.cxx @@ -0,0 +1,550 @@ +/*************************************************************************
+ *
+ * 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: uielementfactorymanager.cxx,v $
+ * $Revision: 1.10.12.1 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_framework.hxx"
+
+//_________________________________________________________________________________________________________________
+// my own includes
+//_________________________________________________________________________________________________________________
+#include <uifactory/windowcontentfactorymanager.hxx>
+#include <threadhelp/resetableguard.hxx>
+#include "services.h"
+
+//_________________________________________________________________________________________________________________
+// interface includes
+//_________________________________________________________________________________________________________________
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/awt/XToolkit.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+
+//_________________________________________________________________________________________________________________
+// includes of other projects
+//_________________________________________________________________________________________________________________
+#include <rtl/ustrbuf.hxx>
+#include <cppuhelper/weak.hxx>
+#include <tools/urlobj.hxx>
+#include <vcl/svapp.hxx>
+
+//_________________________________________________________________________________________________________________
+// Defines
+//_________________________________________________________________________________________________________________
+//
+
+using namespace ::com::sun::star;
+
+//_________________________________________________________________________________________________________________
+// Namespace
+//_________________________________________________________________________________________________________________
+//
+
+namespace framework
+{
+
+// global function needed by both implementations
+static rtl::OUString getHashKeyFromStrings( const rtl::OUString& aType, const rtl::OUString& aName, const rtl::OUString& aModuleName )
+{
+ rtl::OUStringBuffer aKey( aType );
+ aKey.appendAscii( "^" );
+ aKey.append( aName );
+ aKey.appendAscii( "^" );
+ aKey.append( aModuleName );
+ return aKey.makeStringAndClear();
+}
+
+
+//*****************************************************************************************************************
+// Configuration access class for UIElementFactoryManager implementation
+//*****************************************************************************************************************
+
+class ConfigurationAccess_WindowContentFactoryManager : // interfaces
+ public lang::XTypeProvider ,
+ public container::XContainerListener ,
+ // baseclasses
+ // Order is neccessary for right initialization!
+ private ThreadHelpBase ,
+ public ::cppu::OWeakObject
+{
+ public:
+ FWK_DECLARE_XINTERFACE
+ FWK_DECLARE_XTYPEPROVIDER
+
+ ConfigurationAccess_WindowContentFactoryManager( uno::Reference< lang::XMultiServiceFactory >& rServiceManager );
+ virtual ~ConfigurationAccess_WindowContentFactoryManager();
+
+ void readConfigurationData();
+
+ rtl::OUString getFactorySpecifierFromTypeNameModule( const rtl::OUString& rType, const rtl::OUString& rName, const rtl::OUString& rModule );
+
+ // container.XContainerListener
+ virtual void SAL_CALL elementInserted( const container::ContainerEvent& aEvent ) throw(uno::RuntimeException);
+ virtual void SAL_CALL elementRemoved ( const container::ContainerEvent& aEvent ) throw(uno::RuntimeException);
+ virtual void SAL_CALL elementReplaced( const container::ContainerEvent& aEvent ) throw(uno::RuntimeException);
+
+ // lang.XEventListener
+ virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) throw(uno::RuntimeException);
+
+ private:
+ class FactoryMap : public std::hash_map< rtl::OUString,
+ rtl::OUString,
+ OUStringHashCode,
+ ::std::equal_to< ::rtl::OUString > >
+ {
+ inline void free()
+ {
+ FactoryMap().swap( *this );
+ }
+ };
+
+ sal_Bool impl_getElementProps( const uno::Any& rElement, rtl::OUString& rType, rtl::OUString& rName, rtl::OUString& rModule, rtl::OUString& rServiceSpecifier ) const;
+
+ rtl::OUString m_aPropType;
+ rtl::OUString m_aPropName;
+ rtl::OUString m_aPropModule;
+ rtl::OUString m_aPropFactory;
+ FactoryMap m_aFactoryMap;
+ uno::Reference< lang::XMultiServiceFactory > m_xServiceManager;
+ uno::Reference< lang::XMultiServiceFactory > m_xConfigProvider;
+ uno::Reference< container::XNameAccess > m_xConfigAccess;
+ bool m_bConfigAccessInitialized;
+ bool m_bConfigDirty;
+};
+
+//*****************************************************************************************************************
+// XInterface, XTypeProvider
+//*****************************************************************************************************************
+DEFINE_XINTERFACE_3 ( ConfigurationAccess_WindowContentFactoryManager ,
+ OWeakObject ,
+ DIRECT_INTERFACE ( lang::XTypeProvider ),
+ DIRECT_INTERFACE ( container::XContainerListener ),
+ DERIVED_INTERFACE( lang::XEventListener, XContainerListener )
+ )
+
+DEFINE_XTYPEPROVIDER_3 ( ConfigurationAccess_WindowContentFactoryManager ,
+ lang::XTypeProvider ,
+ container::XContainerListener ,
+ lang::XEventListener
+ )
+
+ConfigurationAccess_WindowContentFactoryManager::ConfigurationAccess_WindowContentFactoryManager( uno::Reference< lang::XMultiServiceFactory >& rServiceManager ) :
+ ThreadHelpBase(),
+ m_aPropType( RTL_CONSTASCII_USTRINGPARAM( "Type" )),
+ m_aPropName( RTL_CONSTASCII_USTRINGPARAM( "Name" )),
+ m_aPropModule( RTL_CONSTASCII_USTRINGPARAM( "Module" )),
+ m_aPropFactory( RTL_CONSTASCII_USTRINGPARAM( "FactoryImplementation" )),
+ m_xServiceManager( rServiceManager ),
+ m_bConfigAccessInitialized( false ),
+ m_bConfigDirty( true )
+{
+ m_xConfigProvider = uno::Reference< lang::XMultiServiceFactory >( rServiceManager->createInstance(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.ConfigurationProvider" ))),
+ uno::UNO_QUERY );
+}
+
+ConfigurationAccess_WindowContentFactoryManager::~ConfigurationAccess_WindowContentFactoryManager()
+{
+ // SAFE
+ ResetableGuard aLock( m_aLock );
+
+ uno::Reference< container::XContainer > xContainer( m_xConfigAccess, uno::UNO_QUERY );
+ if ( xContainer.is() )
+ xContainer->removeContainerListener( this );
+}
+
+rtl::OUString ConfigurationAccess_WindowContentFactoryManager::getFactorySpecifierFromTypeNameModule( const rtl::OUString& rType, const rtl::OUString& rName, const rtl::OUString& rModule )
+{
+ // SAFE
+ ResetableGuard aLock( m_aLock );
+
+ // Make sure that we read the configuration data at least once.
+ // May be more dependent on the dirty flag!
+ readConfigurationData();
+
+ FactoryMap::const_iterator pIter =
+ m_aFactoryMap.find( getHashKeyFromStrings( rType, rName, rModule ));
+ if ( pIter != m_aFactoryMap.end() )
+ return pIter->second;
+ else
+ {
+ pIter = m_aFactoryMap.find( getHashKeyFromStrings( rType, rName, rtl::OUString() ));
+ if ( pIter != m_aFactoryMap.end() )
+ return pIter->second;
+ else
+ {
+ // Support factories which uses a defined prefix for their element names.
+ sal_Int32 nIndex = rName.indexOf( '_' );
+ if ( nIndex > 0 )
+ {
+ rtl::OUString aName = rName.copy( 0, nIndex );
+ pIter = m_aFactoryMap.find( getHashKeyFromStrings( rType, aName, rtl::OUString() ));
+ if ( pIter != m_aFactoryMap.end() )
+ return pIter->second;
+ }
+
+ pIter = m_aFactoryMap.find( getHashKeyFromStrings( rType, rtl::OUString(), rtl::OUString() ));
+ if ( pIter != m_aFactoryMap.end() )
+ return pIter->second;
+ }
+ }
+
+ return rtl::OUString();
+}
+
+// container.XContainerListener
+void SAL_CALL ConfigurationAccess_WindowContentFactoryManager::elementInserted( const container::ContainerEvent& ) throw(uno::RuntimeException)
+{
+ // SAFE
+ ResetableGuard aLock( m_aLock );
+ m_bConfigDirty = true;
+}
+
+void SAL_CALL ConfigurationAccess_WindowContentFactoryManager::elementRemoved ( const container::ContainerEvent& ) throw(uno::RuntimeException)
+{
+ // SAFE
+ ResetableGuard aLock( m_aLock );
+ m_bConfigDirty = true;
+}
+
+void SAL_CALL ConfigurationAccess_WindowContentFactoryManager::elementReplaced( const container::ContainerEvent& ) throw(uno::RuntimeException)
+{
+ // SAFE
+ ResetableGuard aLock( m_aLock );
+ m_bConfigDirty = true;
+}
+
+// lang.XEventListener
+void SAL_CALL ConfigurationAccess_WindowContentFactoryManager::disposing( const lang::EventObject& ) throw(uno::RuntimeException)
+{
+ // SAFE
+ // remove our reference to the config access
+ ResetableGuard aLock( m_aLock );
+ m_xConfigAccess.clear();
+}
+
+void ConfigurationAccess_WindowContentFactoryManager::readConfigurationData()
+{
+ // SAFE
+ ResetableGuard aLock( m_aLock );
+
+ bool bConfigAccessInitialized(m_bConfigAccessInitialized);
+ if ( !m_bConfigAccessInitialized )
+ {
+ uno::Sequence< uno::Any > aArgs( 1 );
+ beans::PropertyValue aPropValue;
+
+ aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ));
+ aPropValue.Value <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.UI.WindowContentFactories/Registered/ContentFactories" ));
+ aArgs[0] <<= aPropValue;
+
+ try
+ {
+ m_xConfigAccess = uno::Reference< container::XNameAccess >( m_xConfigProvider->createInstanceWithArguments(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.ConfigurationAccess" )),
+ aArgs ),
+ uno::UNO_QUERY );
+ }
+ catch ( lang::WrappedTargetException& )
+ {
+ }
+
+ m_bConfigAccessInitialized = sal_True;
+ }
+
+ if ( m_xConfigAccess.is() && m_bConfigDirty )
+ {
+ uno::Sequence< rtl::OUString > aUIElementFactories = m_xConfigAccess->getElementNames();
+
+ uno::Any a;
+ rtl::OUString aType;
+ rtl::OUString aName;
+ rtl::OUString aModule;
+ rtl::OUString aService;
+ rtl::OUString aHashKey;
+
+ uno::Reference< beans::XPropertySet > xPropertySet;
+
+ m_aFactoryMap.clear();
+ for ( sal_Int32 i = 0; i < aUIElementFactories.getLength(); i++ )
+ {
+ if ( impl_getElementProps( m_xConfigAccess->getByName( aUIElementFactories[i] ), aType, aName, aModule, aService ))
+ {
+ // Create hash key from type, name and module as they are together a primary key to
+ // the UNO service that implements the user interface element factory.
+ aHashKey = getHashKeyFromStrings( aType, aName, aModule );
+ m_aFactoryMap.insert( FactoryMap::value_type( aHashKey, aService ));
+ }
+ }
+
+ uno::Reference< container::XContainer > xContainer( m_xConfigAccess, uno::UNO_QUERY );
+ m_bConfigDirty = false;
+
+ aLock.unlock();
+ // UNSAFE
+
+ if ( xContainer.is() && !bConfigAccessInitialized)
+ xContainer->addContainerListener( this );
+ }
+}
+
+sal_Bool ConfigurationAccess_WindowContentFactoryManager::impl_getElementProps( const uno::Any& aElement, rtl::OUString& rType, rtl::OUString& rName, rtl::OUString& rModule, rtl::OUString& rServiceSpecifier ) const
+{
+ uno::Reference< beans::XPropertySet > xPropertySet;
+ uno::Reference< container::XNameAccess > xNameAccess;
+ aElement >>= xPropertySet;
+ aElement >>= xNameAccess;
+
+ if ( xPropertySet.is() )
+ {
+ try
+ {
+ xPropertySet->getPropertyValue( m_aPropType ) >>= rType;
+ xPropertySet->getPropertyValue( m_aPropName ) >>= rName;
+ xPropertySet->getPropertyValue( m_aPropModule ) >>= rModule;
+ xPropertySet->getPropertyValue( m_aPropFactory ) >>= rServiceSpecifier;
+ }
+ catch ( beans::UnknownPropertyException& )
+ {
+ return sal_False;
+ }
+ catch ( lang::WrappedTargetException& )
+ {
+ return sal_False;
+ }
+ }
+
+ return sal_True;
+}
+
+//*****************************************************************************************************************
+// XInterface, XTypeProvider, XServiceInfo
+//*****************************************************************************************************************
+DEFINE_XINTERFACE_3 ( WindowContentFactoryManager ,
+ OWeakObject ,
+ DIRECT_INTERFACE( lang::XTypeProvider ),
+ DIRECT_INTERFACE( lang::XServiceInfo ),
+ DIRECT_INTERFACE( lang::XSingleComponentFactory )
+ )
+
+DEFINE_XTYPEPROVIDER_3 ( WindowContentFactoryManager ,
+ lang::XTypeProvider ,
+ lang::XServiceInfo ,
+ lang::XSingleComponentFactory
+ )
+
+DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( WindowContentFactoryManager ,
+ ::cppu::OWeakObject ,
+ SERVICENAME_WINDOWCONTENTFACTORYMANAGER ,
+ IMPLEMENTATIONNAME_WINDOWCONTENTFACTORYMANAGER
+ )
+
+DEFINE_INIT_SERVICE ( WindowContentFactoryManager, {} )
+
+WindowContentFactoryManager::WindowContentFactoryManager( const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) :
+ ThreadHelpBase( &Application::GetSolarMutex() ),
+ m_bConfigRead( sal_False ),
+ m_xServiceManager( xServiceManager )
+{
+ m_pConfigAccess = new ConfigurationAccess_WindowContentFactoryManager( m_xServiceManager );
+ m_pConfigAccess->acquire();
+ m_xModuleManager = uno::Reference< frame::XModuleManager >( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), uno::UNO_QUERY );
+}
+
+WindowContentFactoryManager::~WindowContentFactoryManager()
+{
+ ResetableGuard aLock( m_aLock );
+
+ // reduce reference count
+ m_pConfigAccess->release();
+}
+
+void WindowContentFactoryManager::RetrieveTypeNameFromResourceURL( const rtl::OUString& aResourceURL, rtl::OUString& aType, rtl::OUString& aName )
+{
+ const sal_Int32 RESOURCEURL_PREFIX_SIZE = 17;
+ const char RESOURCEURL_PREFIX[] = "private:resource/";
+
+ 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 nToken = 0;
+ sal_Int32 nPart = 0;
+ do
+ {
+ ::rtl::OUString sToken = aTmpStr.getToken( 0, '/', nToken);
+ if ( sToken.getLength() )
+ {
+ if ( nPart == 0 )
+ aType = sToken;
+ else if ( nPart == 1 )
+ aName = sToken;
+ else
+ break;
+ nPart++;
+ }
+ }
+ while( nToken >=0 );
+ }
+}
+
+// XSingleComponentFactory
+uno::Reference< uno::XInterface > SAL_CALL WindowContentFactoryManager::createInstanceWithContext(
+ const uno::Reference< uno::XComponentContext >& /*xContext*/ )
+throw (uno::Exception, uno::RuntimeException)
+{
+/*
+ // Currently this method cannot be implemented for generic use. There is no way for external
+ code to get a handle to the dialog model.
+
+ uno::Reference< lang::XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), uno::UNO_QUERY );
+
+ const ::rtl::OUString sToolkitService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.Toolkit"));
+ uno::Reference< awt::XToolkit > xToolkit( xServiceManager->createInstance( sToolkitService ), uno::UNO_QUERY_THROW );
+
+ const ::rtl::OUString sDialogModelService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlDialogModel"));
+ uno::Reference< awt::XControlModel > xDialogModel( xServiceManager->createInstance( sDialogModelService ), uno::UNO_QUERY_THROW );
+
+ const ::rtl::OUString sDecoration(RTL_CONSTASCII_USTRINGPARAM("Decoration"));
+ uno::Reference< beans::XPropertySet > xPropSet( xDialogModel, uno::UNO_QUERY_THROW );
+ xPropSet->setPropertyValue( sDecoration, uno::makeAny(false));
+
+ const ::rtl::OUString sDialogService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlDialog"));
+ uno::Reference< awt::XControl > xDialogControl( xServiceManager->createInstance( sDialogService ), uno::UNO_QUERY_THROW );
+
+ xDialogControl->setModel( xDialogModel );
+
+ uno::Reference< awt::XWindowPeer > xWindowParentPeer( xToolkit->getDesktopWindow(), uno::UNO_QUERY );
+ xDialogControl->createPeer( xToolkit, xWindowParentPeer );
+ uno::Reference< uno::XInterface > xWindow( xDialogControl->getPeer(), uno::UNO_QUERY );
+*/
+ uno::Reference< uno::XInterface > xWindow;
+ return xWindow;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL WindowContentFactoryManager::createInstanceWithArgumentsAndContext(
+ const uno::Sequence< uno::Any >& Arguments, const uno::Reference< uno::XComponentContext >& Context )
+throw (uno::Exception, uno::RuntimeException)
+{
+ uno::Reference< uno::XInterface > xWindow;
+ uno::Reference< frame::XFrame > xFrame;
+ ::rtl::OUString aResourceURL;
+
+ for (sal_Int32 i=0; i < Arguments.getLength(); i++ )
+ {
+ beans::PropertyValue aPropValue;
+ if ( Arguments[i] >>= aPropValue )
+ {
+ if ( aPropValue.Name.equalsAscii( "Frame" ))
+ aPropValue.Value >>= xFrame;
+ else if ( aPropValue.Name.equalsAscii( "ResourceURL" ))
+ aPropValue.Value >>= aResourceURL;
+ }
+ }
+
+ uno::Reference< frame::XModuleManager > xModuleManager;
+ // SAFE
+ {
+ ResetableGuard aLock( m_aLock );
+ xModuleManager = m_xModuleManager;
+ }
+ // UNSAFE
+
+ // Determine the module identifier
+ ::rtl::OUString aType;
+ ::rtl::OUString aName;
+ ::rtl::OUString aModuleId;
+ try
+ {
+ if ( xFrame.is() && xModuleManager.is() )
+ aModuleId = xModuleManager->identify( uno::Reference< uno::XInterface >( xFrame, uno::UNO_QUERY ) );
+ }
+ catch ( frame::UnknownModuleException& )
+ {
+ }
+
+ RetrieveTypeNameFromResourceURL( aResourceURL, aType, aName );
+ if ( aType.getLength() > 0 &&
+ aName.getLength() > 0 &&
+ aModuleId.getLength() > 0 )
+ {
+ ::rtl::OUString aImplementationName;
+ uno::Reference< uno::XInterface > xHolder( static_cast<cppu::OWeakObject*>(this), uno::UNO_QUERY );
+
+ // Detetmine the implementation name of the window content factory dependent on the
+ // module identifier, user interface element type and name
+ // SAFE
+ ResetableGuard aLock( m_aLock );
+ aImplementationName = m_pConfigAccess->getFactorySpecifierFromTypeNameModule( aType, aName, aModuleId );
+ if ( aImplementationName.getLength() > 0 )
+ {
+ aLock.unlock();
+ // UNSAFE
+
+ uno::Reference< lang::XMultiServiceFactory > xServiceManager( Context->getServiceManager(), uno::UNO_QUERY );
+ if ( xServiceManager.is() )
+ {
+ uno::Reference< lang::XSingleComponentFactory > xFactory(
+ xServiceManager->createInstance( aImplementationName ), uno::UNO_QUERY );
+ if ( xFactory.is() )
+ {
+ // Be careful: We call external code. Therefore here we have to catch all exceptions
+ try
+ {
+ xWindow = xFactory->createInstanceWithArgumentsAndContext( Arguments, Context );
+ }
+ catch ( uno::RuntimeException& )
+ {
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ }
+ }
+ }
+ }
+
+ // UNSAFE
+ if ( !xWindow.is())
+ {
+ // Fallback: Use internal factory code to create a toolkit dialog as a content window
+ xWindow = createInstanceWithContext(Context);
+ }
+
+ return xWindow;
+}
+
+} // namespace framework
diff --git a/framework/util/makefile.mk b/framework/util/makefile.mk index a6c3d21373..7f755a9528 100644 --- a/framework/util/makefile.mk +++ b/framework/util/makefile.mk @@ -297,7 +297,7 @@ SHL4OBJS= \ $(SLO)$/simpletextstatusbarcontroller.obj \ $(SLO)$/spinfieldtoolbarcontroller.obj \ $(SLO)$/statusbarcontrollerfactory.obj\ - $(SLO)$/statusbarfactory.obj \ + $(SLO)$/statusbarfactory.obj \ $(SLO)$/statusbarmanager.obj \ $(SLO)$/statusbar.obj \ $(SLO)$/statusbarwrapper.obj \ @@ -305,30 +305,33 @@ SHL4OBJS= \ $(SLO)$/statusindicatorinterfacewrapper.obj \ $(SLO)$/statusindicator.obj \ $(SLO)$/stillinteraction.obj \ - $(SLO)$/storageholder.obj \ - $(SLO)$/tagwindowasmodified.obj \ + $(SLO)$/storageholder.obj \ + $(SLO)$/tabwindowservice.obj \ + $(SLO)$/fwktabwindow.obj \ + $(SLO)$/tagwindowasmodified.obj \ $(SLO)$/targethelper.obj \ $(SLO)$/taskcreator.obj \ - $(SLO)$/taskcreatorsrv.obj \ + $(SLO)$/taskcreatorsrv.obj \ $(SLO)$/titlebarupdate.obj \ $(SLO)$/togglebuttontoolbarcontroller.obj \ $(SLO)$/toolbarcontrollerfactory.obj\ $(SLO)$/toolbarmanager.obj \ - $(SLO)$/toolbarmerger.obj \ + $(SLO)$/toolbarmerger.obj \ $(SLO)$/toolbar.obj \ $(SLO)$/toolbarsmenucontroller.obj \ $(SLO)$/toolbarwrapper.obj \ $(SLO)$/toolboxfactory.obj \ - $(SLO)$/uicategorydescription.obj \ + $(SLO)$/uicategorydescription.obj \ $(SLO)$/uicommanddescription.obj \ $(SLO)$/uiconfigurationmanager.obj \ $(SLO)$/uielementfactorymanager.obj \ - $(SLO)$/uriabbreviation.obj \ + $(SLO)$/uriabbreviation.obj \ $(SLO)$/urltransformer.obj \ - $(SLO)$/vclstatusindicator.obj \ - $(SLO)$/wakeupthread.obj \ - $(SLO)$/windowcommanddispatch.obj \ - $(SLO)$/windowstateconfiguration.obj \ + $(SLO)$/vclstatusindicator.obj \ + $(SLO)$/wakeupthread.obj \ + $(SLO)$/windowcommanddispatch.obj \ + $(SLO)$/windowstateconfiguration.obj \ + $(SLO)$/windowcontentfactorymanager.obj SHL4STDLIBS= \ $(FWILIB) \ |