diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-04-14 20:21:59 +0200 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-04-14 20:21:59 +0200 |
commit | 958e5f85168c87b1a48b1a4c29f077c0a6b4a2c3 (patch) | |
tree | ce610ce6ede20bc19a4914cabec70a7703163be3 | |
parent | edd98d01793ff8ab444c16b94d71f526d1d3550c (diff) | |
parent | 8555dec9b440d58f4bc19fc088679a827e2870b5 (diff) |
merge
33 files changed, 810 insertions, 2256 deletions
diff --git a/sd/prj/build.lst b/sd/prj/build.lst index 1b565ac71fb0..bc8bf923f7e5 100644..100755 --- a/sd/prj/build.lst +++ b/sd/prj/build.lst @@ -44,4 +44,3 @@ sd sd\source\ui\framework\factories nmake - all sd_framework_factories sd sd sd\source\ui\framework\tools nmake - all sd_framework_tools sd_inc NULL sd sd\source\ui\annotations nmake - all sd_uiannotations sd_inc NULL sd sd\util nmake - all sd_util sd_app sd_cgm sd_core sd_dlg sd_docsh sd_eppt sd_filt sd_func sd_grf sd_unid sd_view sd_xml sd_html sd_ppt sd_accessibility sd_animations sd_toolpanel sd_toolpanel_controls sd_tools sd_slsshell sd_slsmodel sd_slsview sd_slscontroller sd_slscache sd_notes sd_table sd_slideshow sd_presenter sd_undo sd_helper sd_framework_configuration sd_framework_module sd_framework_tools sd_framework_factories sd_text sd_annotations sd_uiannotations NULL -sd sd\workben\custompanel nmake - all sd_workben_panel sd_inc NULL diff --git a/sd/source/ui/dlg/PaneDockingWindow.cxx b/sd/source/ui/dlg/PaneDockingWindow.cxx index c649f00ac52e..c1dedd5d8293 100644 --- a/sd/source/ui/dlg/PaneDockingWindow.cxx +++ b/sd/source/ui/dlg/PaneDockingWindow.cxx @@ -78,17 +78,4 @@ void PaneDockingWindow::StateChanged( StateChangedType nType ) SfxDockingWindow::StateChanged (nType); } -void PaneDockingWindow::EndDocking( const Rectangle& rRect, BOOL bFloatMode ) -{ - SfxDockingWindow::EndDocking( rRect, bFloatMode ); - - if ( maEndDockingHdl.IsSet() ) - maEndDockingHdl.Call( this ); -} - -void PaneDockingWindow::ResetToolBox() -{ - impl_resetToolBox(); -} - } // end of namespace ::sd diff --git a/sd/source/ui/framework/factories/TaskPanelFactory.cxx b/sd/source/ui/framework/factories/TaskPanelFactory.cxx index 574d1c6fec27..1cd156817afc 100644 --- a/sd/source/ui/framework/factories/TaskPanelFactory.cxx +++ b/sd/source/ui/framework/factories/TaskPanelFactory.cxx @@ -259,14 +259,15 @@ void SAL_CALL TaskPanelFactory::releaseResource ( const ::boost::shared_ptr< ViewShell > pPaneViewShell( pFrameworkHelper->GetViewShell( sPaneURL ) ); if ( pPaneViewShell != NULL ) { - toolpanel::PanelId ePanelId( toolpanel::GetStandardPanelId( xResourceId->getResourceURL() ) ); + const ::rtl::OUString sPanelResourceURL( xResourceId->getResourceURL() ); + const toolpanel::PanelId ePanelId( toolpanel::GetStandardPanelId( sPanelResourceURL ) ); toolpanel::ToolPanelViewShell* pToolPanel = dynamic_cast< toolpanel::ToolPanelViewShell* >( pPaneViewShell.get() ); if ( ( ePanelId != toolpanel::PID_UNKNOWN ) && ( pToolPanel != NULL ) ) { - pToolPanel->DeactivatePanel( ePanelId ); + pToolPanel->DeactivatePanel( sPanelResourceURL ); } else { diff --git a/sd/source/ui/framework/factories/ViewShellWrapper.cxx b/sd/source/ui/framework/factories/ViewShellWrapper.cxx index 575f8537de1c..a1c0bd525c9e 100644 --- a/sd/source/ui/framework/factories/ViewShellWrapper.cxx +++ b/sd/source/ui/framework/factories/ViewShellWrapper.cxx @@ -65,8 +65,7 @@ ViewShellWrapper::ViewShellWrapper ( : ViewShellWrapperInterfaceBase(MutexOwner::maMutex), mpViewShell(pViewShell), mxViewId(rxViewId), - mxWindow(rxWindow), - mbIsPane( pViewShell == NULL ? false : ( pViewShell->GetShellType() == ViewShell::ST_TASK_PANE ) ) + mxWindow(rxWindow) { if (rxWindow.is()) { @@ -114,93 +113,6 @@ void SAL_CALL ViewShellWrapper::disposing (void) -//----- XInterface ------------------------------------------------------------ - -Any SAL_CALL ViewShellWrapper::queryInterface( const Type& i_rType ) throw (RuntimeException) -{ - Any aInterface( ViewShellWrapperInterfaceBase::queryInterface( i_rType ) ); - if ( !aInterface.hasValue() ) - { - if ( mbIsPane ) - aInterface = ViewShellWrapper_PaneBase::queryInterface( i_rType ); - else - aInterface = ViewShellWrapper_ViewBase::queryInterface( i_rType ); - } - return aInterface; -} - -void SAL_CALL ViewShellWrapper::acquire() throw () -{ - ViewShellWrapperInterfaceBase::acquire(); -} - -void SAL_CALL ViewShellWrapper::release() throw () -{ - ViewShellWrapperInterfaceBase::release(); -} - -//----- XTypeProvider --------------------------------------------------------- - -Sequence< Type > SAL_CALL ViewShellWrapper::getTypes( ) throw (RuntimeException) -{ - const Sequence< Type > aCommonTypes( ViewShellWrapperInterfaceBase::getTypes() ); - const Sequence< Type > aSpecialTypes( - mbIsPane - ? ViewShellWrapper_PaneBase::getTypes() - : ViewShellWrapper_ViewBase::getTypes() - ); - return ::comphelper::concatSequences( aCommonTypes, aSpecialTypes ); -} - -Sequence< ::sal_Int8 > SAL_CALL ViewShellWrapper::getImplementationId( ) throw (RuntimeException) -{ - static ::cppu::OImplementationId* pViewId = NULL; - static ::cppu::OImplementationId* pPaneId = NULL; - if ( !pViewId ) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if ( !pViewId ) - { - static ::cppu::OImplementationId aViewId; - static ::cppu::OImplementationId aPaneId; - pViewId = &aViewId; - pPaneId = &aPaneId; - } - } - - return ( mbIsPane ? pPaneId : pViewId )->getImplementationId(); -} - -//----- XPane ----------------------------------------------------------------- - -Reference< XInterface > ViewShellWrapper::impl_getPaneWindowOrCanvas( const bool i_bWindow ) -{ - ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); - ::osl::MutexGuard aGuard( maMutex ); - if ( !mpViewShell.get() ) - throw DisposedException( ::rtl::OUString(), *this ); - - ToolPanelViewShell* pToolPanelShell = dynamic_cast< ToolPanelViewShell* >( mpViewShell.get() ); - ENSURE_OR_RETURN( pToolPanelShell != NULL, "XPane should be accessible for a ToolPanelViewShell only", NULL ); - - ::Window* pPaneWindow = pToolPanelShell->GetToolPanelParentWindow(); - ENSURE_OR_RETURN( pPaneWindow, "shell is not able to provide a panel parent", NULL ); - - if ( i_bWindow ) - return VCLUnoHelper::GetInterface( pPaneWindow ); - return pPaneWindow->GetCanvas(); -} - -Reference< XWindow > SAL_CALL ViewShellWrapper::getWindow() throw (RuntimeException) -{ - return Reference< XWindow >( impl_getPaneWindowOrCanvas( true ), UNO_QUERY ); -} - -Reference< XCanvas > SAL_CALL ViewShellWrapper::getCanvas() throw (RuntimeException) -{ - return Reference< XCanvas >( impl_getPaneWindowOrCanvas( false ), UNO_QUERY ); -} - //----- XResource ------------------------------------------------------------- Reference<XResourceId> SAL_CALL ViewShellWrapper::getResourceId (void) diff --git a/sd/source/ui/framework/tools/FrameworkHelper.cxx b/sd/source/ui/framework/tools/FrameworkHelper.cxx index 1ac2718e1bc6..8c63a6871483 100644 --- a/sd/source/ui/framework/tools/FrameworkHelper.cxx +++ b/sd/source/ui/framework/tools/FrameworkHelper.cxx @@ -219,7 +219,7 @@ const OUString FrameworkHelper::msViewTabBarURL( // Task panel URLs. const ::rtl::OUString FrameworkHelper::msTaskPanelURLPrefix( - OUString::createFromAscii("private:resource/toolpanel/")); + OUString::createFromAscii("private:resource/toolpanel/DrawingFramework/")); const ::rtl::OUString FrameworkHelper::msMasterPagesTaskPanelURL( msTaskPanelURLPrefix + OUString::createFromAscii("MasterPages")); const ::rtl::OUString FrameworkHelper::msLayoutTaskPanelURL( diff --git a/sd/source/ui/inc/PaneDockingWindow.hxx b/sd/source/ui/inc/PaneDockingWindow.hxx index 15fda4b046a0..1874df10dd53 100644 --- a/sd/source/ui/inc/PaneDockingWindow.hxx +++ b/sd/source/ui/inc/PaneDockingWindow.hxx @@ -65,16 +65,6 @@ public: virtual ~PaneDockingWindow (void); virtual void StateChanged( StateChangedType nType ); - - virtual void EndDocking( const Rectangle& rRect, BOOL bFloatMode ); - - void SetEndDockingHdl( const Link& i_rEndDockingHdl ) { maEndDockingHdl = i_rEndDockingHdl; } - const Link& GetEndDockingHdl() const { return maEndDockingHdl; } - - void ResetToolBox(); - -private: - Link maEndDockingHdl; }; } // end of namespace ::sd diff --git a/sd/source/ui/inc/framework/ViewShellWrapper.hxx b/sd/source/ui/inc/framework/ViewShellWrapper.hxx index c942d4ec9e18..12483f462d5e 100644 --- a/sd/source/ui/inc/framework/ViewShellWrapper.hxx +++ b/sd/source/ui/inc/framework/ViewShellWrapper.hxx @@ -30,26 +30,22 @@ #include "MutexOwner.hxx" #include <com/sun/star/drawing/framework/XView.hpp> -#include <com/sun/star/drawing/framework/XPane.hpp> #include <com/sun/star/drawing/framework/XRelocatableResource.hpp> #include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <osl/mutex.hxx> -#include <cppuhelper/compbase3.hxx> +#include <cppuhelper/compbase4.hxx> #include <cppuhelper/implbase1.hxx> #include <boost/shared_ptr.hpp> namespace { -typedef ::cppu::WeakComponentImplHelper3 < ::com::sun::star::lang::XUnoTunnel +typedef ::cppu::WeakComponentImplHelper4 < ::com::sun::star::lang::XUnoTunnel , ::com::sun::star::awt::XWindowListener , ::com::sun::star::drawing::framework::XRelocatableResource + , ::com::sun::star::drawing::framework::XView > ViewShellWrapperInterfaceBase; -typedef ::cppu::ImplHelper1 < ::com::sun::star::drawing::framework::XView - > ViewShellWrapper_ViewBase; -typedef ::cppu::ImplHelper1 < ::com::sun::star::drawing::framework::XPane - > ViewShellWrapper_PaneBase; } // end of anonymous namespace. @@ -63,8 +59,6 @@ namespace sd { namespace framework { */ class ViewShellWrapper :private sd::MutexOwner ,public ViewShellWrapperInterfaceBase - ,public ViewShellWrapper_ViewBase - ,public ViewShellWrapper_PaneBase { public: /** Create a new ViewShellWrapper object that wraps the given ViewShell @@ -100,22 +94,6 @@ public: virtual sal_Int64 SAL_CALL getSomething (const com::sun::star::uno::Sequence<sal_Int8>& rId) throw (com::sun::star::uno::RuntimeException); - // XInterface - - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL acquire( ) throw (); - virtual void SAL_CALL release( ) throw (); - - // XTypeProvider - - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException); - - // XPane - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL getWindow( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvas > SAL_CALL getCanvas( ) throw (::com::sun::star::uno::RuntimeException); - // XResource virtual ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId> @@ -163,11 +141,6 @@ private: ::boost::shared_ptr< ViewShell > mpViewShell; const ::com::sun::star::uno::Reference< com::sun::star::drawing::framework::XResourceId > mxViewId; ::com::sun::star::uno::Reference<com::sun::star::awt::XWindow > mxWindow; - const bool mbIsPane; - -private: - // only to be called when mbIsPane is <TRUE/> - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > impl_getPaneWindowOrCanvas( const bool i_bWindow ); }; } } // end of namespace sd::framework diff --git a/sd/source/ui/inc/taskpane/PanelId.hxx b/sd/source/ui/inc/taskpane/PanelId.hxx index 7e26c4e66e68..43018f11f177 100644 --- a/sd/source/ui/inc/taskpane/PanelId.hxx +++ b/sd/source/ui/inc/taskpane/PanelId.hxx @@ -27,6 +27,11 @@ #ifndef SD_UI_TASKPANE_PANELID_HXX #define SD_UI_TASKPANE_PANELID_HXX +namespace rtl +{ + class OUString; +} + //...................................................................................................................... namespace sd { namespace toolpanel { @@ -44,9 +49,7 @@ namespace sd { namespace toolpanel PID_LAYOUT = 2, PID_TABLE_DESIGN = 3, PID_CUSTOM_ANIMATION = 4, - PID_SLIDE_TRANSITION = 5, - - PID_FIRST_CUSTOM_PANEL = 6 + PID_SLIDE_TRANSITION = 5 }; PanelId GetStandardPanelId( const ::rtl::OUString& i_rTaskPanelResourceURL ); diff --git a/sd/source/ui/inc/taskpane/SlideSorterCacheDisplay.hxx b/sd/source/ui/inc/taskpane/SlideSorterCacheDisplay.hxx index 0dadaaced01c..933a25f4067d 100644 --- a/sd/source/ui/inc/taskpane/SlideSorterCacheDisplay.hxx +++ b/sd/source/ui/inc/taskpane/SlideSorterCacheDisplay.hxx @@ -54,7 +54,6 @@ class Window; namespace sd { namespace toolpanel { -class ControlFactory; class TreeNode; /** This panel demonstrates how to create a panel for the task pane. diff --git a/sd/source/ui/inc/taskpane/TitledControl.hxx b/sd/source/ui/inc/taskpane/TitledControl.hxx index 6aaf2bfee200..0aa63344fcd5 100644 --- a/sd/source/ui/inc/taskpane/TitledControl.hxx +++ b/sd/source/ui/inc/taskpane/TitledControl.hxx @@ -45,7 +45,6 @@ class Window; namespace sd { namespace toolpanel { class ControlContainer; -class ControlFactory; /** This wrapper adds a title bar to a control. Both title bar and control are child windows. diff --git a/sd/source/ui/inc/taskpane/ToolPanelViewShell.hxx b/sd/source/ui/inc/taskpane/ToolPanelViewShell.hxx index a82908ec56e3..9f56fa9bf25a 100644 --- a/sd/source/ui/inc/taskpane/ToolPanelViewShell.hxx +++ b/sd/source/ui/inc/taskpane/ToolPanelViewShell.hxx @@ -45,6 +45,10 @@ class PopupMenu; +namespace com { namespace sun { namespace star { namespace ui { + class XUIElement; +} } } } + namespace sd { class PaneDockingWindow; @@ -53,7 +57,6 @@ class TaskPaneShellManager; class TitleToolBox; class TitleBar; class TitledControl; -class ToolPanelDeck; class ToolPanelViewShell_Impl; /** The tool panel is a view shell for some very specific reasons: - It fits better into the concept of panes being docking windows whose @@ -99,17 +102,9 @@ public: TaskPaneShellManager& GetSubShellManager (void) const; - /** returns the window which should be used as parent for tool panel windows - */ - ::Window* GetToolPanelParentWindow(); - - /** activates the given panel, bypassing the configuration controller, deactivates the previously active one. - */ - void ActivatePanel( const PanelId i_ePanelId ); - /** deactivates the given panel, bypassing the configuration controller */ - void DeactivatePanel( const PanelId i_ePanelId ); + void DeactivatePanel( const ::rtl::OUString& i_rPanelResourceURL ); /** Return a pointer to the docking window that is the parent or a predecessor of the content window. @@ -119,14 +114,6 @@ public: */ DockingWindow* GetDockingWindow (void); - /** Called when a mouse button has been pressed but not yet - released, this handler is used to show the popup menu of the - title bar. - */ - DECL_LINK(ToolboxClickHandler, ToolBox*); - DECL_LINK(MenuSelectHandler, Menu*); - DECL_LINK(DockingChanged, PaneDockingWindow*); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> CreateAccessibleDocumentView (::sd::Window* pWindow); @@ -137,6 +124,17 @@ public: */ virtual bool RelocateToParentWindow (::Window* pParentWindow); + /// returns <TRUE/> if and only if the given window is the panel anchor window of our ToolPanelDeck + bool IsPanelAnchorWindow( const ::Window& i_rWindow ) const; + + /** creates an XUIElement for the given standard panel + */ + ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > + CreatePanelUIElement( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rDocFrame, + const ::rtl::OUString& i_rPanelResourceURL + ); + private: ::boost::scoped_ptr< ToolPanelViewShell_Impl > mpImpl; @@ -157,10 +155,6 @@ private: ::std::auto_ptr<PopupMenu> CreatePopupMenu (bool bIsDocking); - /** connects to a (new) (Pane)DockingWindow - */ - void ConnectToDockingWindow(); - /** Initialize the task pane view shell if that has not yet been done before. If mbIsInitialized is already set to <TRUE/> then this method returns immediately. diff --git a/sd/source/ui/toolpanel/CustomToolPanel.cxx b/sd/source/ui/toolpanel/CustomToolPanel.cxx deleted file mode 100644 index 1515bf09104f..000000000000 --- a/sd/source/ui/toolpanel/CustomToolPanel.cxx +++ /dev/null @@ -1,290 +0,0 @@ -/************************************************************************* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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. - * -************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "CustomToolPanel.hxx" -#include "framework/FrameworkHelper.hxx" - -/** === begin UNO includes === **/ -#include <com/sun/star/drawing/framework/ResourceId.hpp> -#include <com/sun/star/awt/PosSize.hpp> -#include <com/sun/star/drawing/framework/XPane2.hpp> -/** === end UNO includes === **/ - -#include <comphelper/processfactory.hxx> -#include <unotools/confignode.hxx> -#include <tools/diagnose_ex.h> - -#if OSL_DEBUG_LEVEL > 0 -#include <rtl/strbuf.hxx> -#endif - -//...................................................................................................................... -namespace sd { namespace toolpanel -{ -//...................................................................................................................... - - /** === begin UNO using === **/ - using ::com::sun::star::uno::Reference; - using ::com::sun::star::uno::XInterface; - using ::com::sun::star::uno::UNO_QUERY; - using ::com::sun::star::uno::UNO_QUERY_THROW; - using ::com::sun::star::uno::UNO_SET_THROW; - using ::com::sun::star::uno::Exception; - using ::com::sun::star::uno::RuntimeException; - using ::com::sun::star::uno::Any; - using ::com::sun::star::uno::makeAny; - using ::com::sun::star::uno::Sequence; - using ::com::sun::star::uno::Type; - using ::com::sun::star::drawing::framework::XConfigurationController; - using ::com::sun::star::drawing::framework::XResourceId; - using ::com::sun::star::drawing::framework::ResourceId; - using ::com::sun::star::drawing::framework::XResource; - using ::com::sun::star::awt::XWindow; - using ::com::sun::star::accessibility::XAccessible; - using ::com::sun::star::drawing::framework::XPane2; - /** === end UNO using === **/ - namespace PosSize = ::com::sun::star::awt::PosSize; - - //================================================================================================================== - //= helper - //================================================================================================================== - namespace - { - ::rtl::OUString lcl_getPanelConfig( const ::utl::OConfigurationNode& i_rPanelConfig, const sal_Char* i_pAsciiPropName ) - { - ::rtl::OUString sConfigValue; - OSL_VERIFY( i_rPanelConfig.getNodeValue( i_pAsciiPropName ) >>= sConfigValue ); - if ( sConfigValue.getLength() == 0 ) - { -#if OSL_DEBUG_LEVEL > 0 - ::rtl::OStringBuffer aMessage; - aMessage.append( "lcl_getPanelConfig: invalid config value (" ); - aMessage.append( i_pAsciiPropName ); - aMessage.append( ") for panel config '" ); - aMessage.append( ::rtl::OUStringToOString( i_rPanelConfig.getLocalName(), RTL_TEXTENCODING_UTF8 ) ); - aMessage.append( "'" ); - OSL_ENSURE( false, aMessage.makeStringAndClear().getStr() ); -#endif - } - return sConfigValue; - } - } - - //================================================================================================================== - //= CustomToolPanel - //================================================================================================================== - //------------------------------------------------------------------------------------------------------------------ - CustomToolPanel::CustomToolPanel( ToolPanelDeck& i_rPanelDeck, const ::utl::OConfigurationNode& i_rPanelConfig, - const Reference< XResourceId >& i_rPaneResourceId, const ::boost::shared_ptr< framework::FrameworkHelper >& i_pFrameworkHelper ) - :TaskPaneToolPanel( i_rPanelDeck, lcl_getPanelConfig( i_rPanelConfig, "DisplayTitle" ), Image() /* TODO */, SmartId() /* TODO */ ) - ,m_pFrameworkHelper( i_pFrameworkHelper ) - ,m_xPanelResourceId() - ,m_xResource() - ,m_xToolPanel() - ,m_bAttemptedPanelCreation( false ) - ,m_nResourceAccessLock( 0 ) - { - ENSURE_OR_THROW( m_pFrameworkHelper.get() != NULL, "invalid framework helper" ); - ENSURE_OR_THROW( i_rPaneResourceId.is(), "invalid pane resource id" ); - try - { - ::rtl::OUString sPanelResourceURL( lcl_getPanelConfig( i_rPanelConfig, "ResourceURL" ) ); - m_xPanelResourceId.set( - ResourceId::createWithAnchor( - ::comphelper::getProcessComponentContext(), - sPanelResourceURL, - i_rPaneResourceId ), - UNO_SET_THROW - ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - - //------------------------------------------------------------------------------------------------------------------ - CustomToolPanel::~CustomToolPanel() - { - } - - //------------------------------------------------------------------------------------------------------------------ - void CustomToolPanel::Activate( ::Window& i_rParentWindow ) - { - OSL_ENSURE( &getPanelWindowAnchor() == &i_rParentWindow, - "CustomToolPanel::Activate: invalid new parent window" ); - // getPanelWindowAnchor() is what is returned in the TaskPane's XPane::getWindow method. So, - // any custom panel which is loaded into the TaskPane will use this window as parent window. - // Consequently, this is the window which shall be passed here, since this method is intended to - // re-create the panel with the given parent. - - // we do not need to do anything here. The XResourceFactory::createResource method of the custom - // tool panel already created and showed the window. - } - - //------------------------------------------------------------------------------------------------------------------ - void CustomToolPanel::Deactivate() - { - // When a certain tool panel is activated, this is routed through the drawing framework, which ensures - // that the resource associated with the previously active panel is deactivated, which calls the - // XResourceFactory::destroyResource at our custom panel's factory. - - // So, we do not have to do anything here - except forgetting the XResource, at it might (or might not, - // if cached by the factory) be re-created next time. - m_xResource.clear(); - m_xToolPanel.clear(); - m_bAttemptedPanelCreation = false; - } - - //------------------------------------------------------------------------------------------------------------------ - void CustomToolPanel::SetSizePixel( const Size& i_rPanelWindowSize ) - { - impl_ensurePanel(); - if ( !m_xToolPanel.is() ) - // if the custom panel does not support XPanel, this just means it is its own responsibility - // to resize/layout everything within the pane window. - return; - - try - { - Reference< XWindow > xPanelWindow( m_xToolPanel->getWindow(), UNO_SET_THROW ); - xPanelWindow->setPosSize( 0, 0, i_rPanelWindowSize.Width(), i_rPanelWindowSize.Height(), - PosSize::POSSIZE ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - - //------------------------------------------------------------------------------------------------------------------ - void CustomToolPanel::GrabFocus() - { - impl_ensurePanel(); - if ( !m_xToolPanel.is() ) - // if the custom panel does not support XPanel, this just means it is its own responsibility - // to care for focus handling - return; - - try - { - Reference< XWindow > xPanelWindow( m_xToolPanel->getWindow(), UNO_SET_THROW ); - xPanelWindow->setFocus(); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - - //------------------------------------------------------------------------------------------------------------------ - void CustomToolPanel::Dispose() - { - // nothing to do here. Lifetime handling of the XResource which this panel represents is done by - // the drawing framework, we ourself do not have resources to release. - TaskPaneToolPanel::Dispose(); - } - - //------------------------------------------------------------------------------------------------------------------ - Reference< XAccessible > CustomToolPanel::CreatePanelAccessible( const Reference< XAccessible >& i_rParentAccessible ) - { - ENSURE_OR_RETURN( !isDisposed(), "CustomToolPanel::CreatePanelAccessible: already disposed!", NULL ); - (void)i_rParentAccessible; - - // an XResource might also be an XPane2, which can provide an XAccessible. Check this first. - const Reference< XPane2 > xPane( m_xResource, UNO_QUERY ); - if ( xPane.is() ) - { - const Reference< XAccessible > xPaneAccessible( xPane->getAccessible() ); - if ( xPaneAccessible.is() ) - return xPaneAccessible; - } - - // if we have an XToolPanel, ask it for its XWindow, and query it - impl_ensurePanel(); - if ( !m_xToolPanel.is() ) - return NULL; - - const Reference< XAccessible > xPanelWindowAccessible( m_xToolPanel->getWindow(), UNO_QUERY ); - if ( xPanelWindowAccessible.is() ) - return xPanelWindowAccessible; - - // maybe the XToolPanel itself can provide an XAccessible? - const Reference< XAccessible > xPanelAccessible( m_xToolPanel, UNO_QUERY ); - if ( xPanelAccessible.is() ) - return xPanelAccessible; - - OSL_ENSURE( false, "CustomToolPanel::CreatePanelAccessible: no XAccessible for the custom panel!" ); - return NULL; - } - - //------------------------------------------------------------------------------------------------------------------ - void CustomToolPanel::LockResourceAccess() - { - ++m_nResourceAccessLock; - } - - //------------------------------------------------------------------------------------------------------------------ - void CustomToolPanel::UnlockResourceAccess() - { - OSL_ENSURE( m_nResourceAccessLock > 0, "CustomToolPanel::UnlockResourceAccess: not locked!" ); - --m_nResourceAccessLock; - } - - //------------------------------------------------------------------------------------------------------------------ - const Reference< XResourceId >& CustomToolPanel::getResourceId() const - { - return m_xPanelResourceId; - } - - //------------------------------------------------------------------------------------------------------------------ - void CustomToolPanel::impl_ensurePanel() - { - ENSURE_OR_RETURN_VOID( !isDisposed(), "already disposed" ); - - if ( ( m_nResourceAccessLock == 0 ) && !m_bAttemptedPanelCreation ) - { - m_bAttemptedPanelCreation = true; - - try - { - Reference< XConfigurationController > xConfigController( m_pFrameworkHelper->GetConfigurationController(), UNO_QUERY_THROW ); - m_xResource.set( xConfigController->getResource( m_xPanelResourceId ), UNO_QUERY_THROW ); - m_xToolPanel.set( m_xResource, UNO_QUERY ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - } - -//...................................................................................................................... -} } // namespace sd::toolpanel -//...................................................................................................................... - diff --git a/sd/source/ui/toolpanel/CustomToolPanel.hxx b/sd/source/ui/toolpanel/CustomToolPanel.hxx deleted file mode 100644 index 7f7f5ec3417d..000000000000 --- a/sd/source/ui/toolpanel/CustomToolPanel.hxx +++ /dev/null @@ -1,113 +0,0 @@ -/************************************************************************* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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 SD_TOOLPANEL_CUSTOMTOOLPANEL_HXX -#define SD_TOOLPANEL_CUSTOMTOOLPANEL_HXX - -#include "TaskPaneToolPanel.hxx" - -/** === begin UNO includes === **/ -#include <com/sun/star/drawing/framework/XPane.hpp> -#include <com/sun/star/drawing/framework/XResourceId.hpp> -#include <com/sun/star/drawing/framework/XResource.hpp> -#include <com/sun/star/ui/XToolPanel.hpp> -/** === end UNO includes === **/ - -#include <boost/shared_ptr.hpp> - -namespace utl -{ - class OConfigurationNode; -} - -namespace sd { namespace framework -{ - class FrameworkHelper; -} } - -//...................................................................................................................... -namespace sd { namespace toolpanel -{ -//...................................................................................................................... - - class ToolPanelDeck; - - //================================================================================================================== - //= CustomToolPanel - //================================================================================================================== - /** is a ::svt::IToolPanel implementation for custom tool panels, i.e. those defined in the configuration, and - implemented by external components. - */ - class CustomToolPanel : public TaskPaneToolPanel - { - public: - CustomToolPanel( - ToolPanelDeck& i_rPanelDeck, - const ::utl::OConfigurationNode& i_rPanelConfig, - const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResourceId >& i_rPaneResourceId, - const ::boost::shared_ptr< framework::FrameworkHelper >& i_pFrameworkHelper - ); - ~CustomToolPanel(); - - // IToolPanel overridables - virtual void Activate( ::Window& i_rParentWindow ); - virtual void Deactivate(); - virtual void SetSizePixel( const Size& i_rPanelWindowSize ); - virtual void GrabFocus(); - virtual void Dispose(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > - CreatePanelAccessible( - const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rParentAccessible - ); - - /** locks (aka prevents) the access to the associated XResource object - */ - void LockResourceAccess(); - /** unlocks (aka allows) the access to the associated XResource object - */ - void UnlockResourceAccess(); - - protected: - // TaskPaneToolPanel overridables - virtual const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResourceId >& getResourceId() const; - - private: - void impl_ensurePanel(); - - private: - ::boost::shared_ptr< framework::FrameworkHelper > m_pFrameworkHelper; - ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResourceId > m_xPanelResourceId; - ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResource > m_xResource; - ::com::sun::star::uno::Reference< ::com::sun::star::ui::XToolPanel > m_xToolPanel; - bool m_bAttemptedPanelCreation; - sal_uInt32 m_nResourceAccessLock; - }; - -//...................................................................................................................... -} } // namespace sd::toolpanel -//...................................................................................................................... - -#endif // SD_TOOLPANEL_CUSTOMTOOLPANEL_HXX diff --git a/sd/source/ui/toolpanel/MethodGuard.hxx b/sd/source/ui/toolpanel/MethodGuard.hxx new file mode 100644 index 000000000000..45b81367c8de --- /dev/null +++ b/sd/source/ui/toolpanel/MethodGuard.hxx @@ -0,0 +1,67 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 SD_METHODGUARD_HXX +#define SD_METHODGUARD_HXX + +#include <osl/mutex.hxx> + +//...................................................................................................................... +namespace sd { namespace toolpanel +{ +//...................................................................................................................... + + //================================================================================================================== + //= MethodGuard + //================================================================================================================== + template < class COMPONENT > + class MethodGuard + { + public: + MethodGuard( COMPONENT& i_rComponent ) + :m_aGuard( i_rComponent.getMutex() ) + { + i_rComponent.checkDisposed(); + } + + ~MethodGuard() + { + } + + inline void clear() + { + m_aGuard.clear(); + } + + private: + ::osl::ClearableMutexGuard m_aGuard; + }; + +//...................................................................................................................... +} } // namespace sd::toolpanel +//...................................................................................................................... + +#endif // SD_METHODGUARD_HXX diff --git a/sd/source/ui/toolpanel/StandardToolPanel.cxx b/sd/source/ui/toolpanel/StandardToolPanel.cxx deleted file mode 100644 index ede20ea3404c..000000000000 --- a/sd/source/ui/toolpanel/StandardToolPanel.cxx +++ /dev/null @@ -1,163 +0,0 @@ -/************************************************************************* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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. - * -************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "StandardToolPanel.hxx" -#include "ToolPanelDeck.hxx" -#include "sdresid.hxx" - -/** === begin UNO includes === **/ -/** === end UNO includes === **/ - -#include <tools/diagnose_ex.h> - -//...................................................................................................................... -namespace sd { namespace toolpanel -{ -//...................................................................................................................... - - /** === begin UNO using === **/ - using ::com::sun::star::uno::Reference; - using ::com::sun::star::uno::XInterface; - using ::com::sun::star::uno::UNO_QUERY; - using ::com::sun::star::uno::UNO_QUERY_THROW; - using ::com::sun::star::uno::UNO_SET_THROW; - using ::com::sun::star::uno::Exception; - using ::com::sun::star::uno::RuntimeException; - using ::com::sun::star::uno::Any; - using ::com::sun::star::uno::makeAny; - using ::com::sun::star::uno::Sequence; - using ::com::sun::star::uno::Type; - using ::com::sun::star::drawing::framework::XResourceId; - using ::com::sun::star::accessibility::XAccessible; - /** === end UNO using === **/ - - //================================================================================================================== - //= StandardToolPanel - //================================================================================================================== - //------------------------------------------------------------------------------------------------------------------ - StandardToolPanel::StandardToolPanel( ToolPanelDeck& i_rPanelDeck, ::std::auto_ptr< ControlFactory >& i_rControlFactory, - const USHORT i_nTitleResId, const Image& i_rImage, const ULONG i_nHelpId, - const Reference< XResourceId >& i_rPanelResourceId ) - :TaskPaneToolPanel( i_rPanelDeck, SdResId( i_nTitleResId ), i_rImage, SmartId( i_nHelpId ) ) - ,m_pControlFactory( i_rControlFactory ) - ,m_xPanelResourceId( i_rPanelResourceId ) - { - ENSURE_OR_THROW( m_pControlFactory.get(), "illegal control factory" ); - } - - //------------------------------------------------------------------------------------------------------------------ - StandardToolPanel::~StandardToolPanel() - { - m_pControl.reset(); - } - - //------------------------------------------------------------------------------------------------------------------ - void StandardToolPanel::Activate( ::Window& i_rParentWindow ) - { - Window* pPanelWindow( impl_getPanelWindow() ); - ENSURE_OR_RETURN_VOID( pPanelWindow, "no window to show" ); - pPanelWindow->SetPosSizePixel( Point(), i_rParentWindow.GetSizePixel() ); - pPanelWindow->Show(); - } - - //------------------------------------------------------------------------------------------------------------------ - void StandardToolPanel::Deactivate() - { - Window* pPanelWindow( impl_getPanelWindow() ); - ENSURE_OR_RETURN_VOID( pPanelWindow, "no window to hide" ); - pPanelWindow->Hide(); - } - - //------------------------------------------------------------------------------------------------------------------ - void StandardToolPanel::SetSizePixel( const Size& i_rPanelWindowSize ) - { - Window* pPanelWindow( impl_getPanelWindow() ); - ENSURE_OR_RETURN_VOID( pPanelWindow, "no window to resize" ); - pPanelWindow->SetSizePixel( i_rPanelWindowSize ); - } - - //------------------------------------------------------------------------------------------------------------------ - void StandardToolPanel::GrabFocus() - { - Window* pPanelWindow( impl_getPanelWindow() ); - ENSURE_OR_RETURN_VOID( pPanelWindow, "no window to focus" ); - pPanelWindow->GrabFocus(); - } - - //------------------------------------------------------------------------------------------------------------------ - void StandardToolPanel::Dispose() - { - m_pControl.reset(); - TaskPaneToolPanel::Dispose(); - } - - //------------------------------------------------------------------------------------------------------------------ - Reference< XAccessible > StandardToolPanel::CreatePanelAccessible( const Reference< XAccessible >& i_rParentAccessible ) - { - ENSURE_OR_RETURN( !isDisposed(), "already disposed!", NULL ); - - Window* pControlWindow( m_pControl->GetWindow() ); - - Reference< XAccessible > xControlAccessible( pControlWindow->GetAccessible( FALSE ) ); - if ( !xControlAccessible.is() ) - { - xControlAccessible = m_pControl->CreateAccessibleObject( i_rParentAccessible ); - OSL_ENSURE( xControlAccessible.is(), "StandardToolPanel::CreatePanelAccessible: invalid XAccessible returned by CreateAccessibleObject!" ); - pControlWindow->SetAccessible( xControlAccessible ); - } - return xControlAccessible; - } - - //------------------------------------------------------------------------------------------------------------------ - const Reference< XResourceId >& StandardToolPanel::getResourceId() const - { - return m_xPanelResourceId; - } - - //------------------------------------------------------------------------------------------------------------------ - ::Window* StandardToolPanel::impl_getPanelWindow() const - { - if ( const_cast< StandardToolPanel* >( this )->impl_ensureControl() ) - return m_pControl->GetWindow(); - return NULL; - } - - //------------------------------------------------------------------------------------------------------------------ - bool StandardToolPanel::impl_ensureControl() - { - if ( m_pControl.get() ) - return true; - if ( isDisposed() ) - return false; - m_pControl = m_pControlFactory->CreateControl( getPanelWindowAnchor() ); - return ( m_pControl.get() != NULL ); - } - -//...................................................................................................................... -} } // namespace sd::toolpanel -//...................................................................................................................... diff --git a/sd/source/ui/toolpanel/TaskPaneToolPanel.cxx b/sd/source/ui/toolpanel/ToolPanel.cxx index 4d0103086932..6dbcae52547a 100644 --- a/sd/source/ui/toolpanel/TaskPaneToolPanel.cxx +++ b/sd/source/ui/toolpanel/ToolPanel.cxx @@ -22,14 +22,18 @@ * <http://www.openoffice.org/license.html> * for a copy of the LGPLv3 License. * -************************************************************************/ + ************************************************************************/ #include "precompiled_sd.hxx" -#include "TaskPaneToolPanel.hxx" -#include "ToolPanelDeck.hxx" +#include "ToolPanel.hxx" +#include "MethodGuard.hxx" +#include <taskpane/TaskPaneTreeNode.hxx> + +/** === begin UNO includes === **/ +#include <com/sun/star/lang/DisposedException.hpp> +/** === end UNO includes === **/ -#include <tools/diagnose_ex.h> #include <vcl/window.hxx> //...................................................................................................................... @@ -49,51 +53,59 @@ namespace sd { namespace toolpanel using ::com::sun::star::uno::makeAny; using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Type; - using ::com::sun::star::drawing::framework::XResourceId; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::awt::XWindow; + using ::com::sun::star::accessibility::XAccessible; /** === end UNO using === **/ + typedef MethodGuard< ToolPanel > ToolPanelGuard; + //================================================================================================================== - //= TaskPaneToolPanel + //= ToolPanel //================================================================================================================== //------------------------------------------------------------------------------------------------------------------ - TaskPaneToolPanel::TaskPaneToolPanel( ToolPanelDeck& i_rPanelDeck, const String& i_rPanelName, const Image& i_rImage, - const SmartId& i_rHelpId ) - :m_pPanelDeck( &i_rPanelDeck ) - ,m_aPanelImage( i_rImage ) - ,m_sPanelName( i_rPanelName ) - ,m_aHelpId( i_rHelpId ) + ToolPanel::ToolPanel( ::std::auto_ptr< TreeNode >& i_rControl ) + :ToolPanel_Base( m_aMutex ) + ,m_pControl( i_rControl ) { } //------------------------------------------------------------------------------------------------------------------ - TaskPaneToolPanel::~TaskPaneToolPanel() + ToolPanel::~ToolPanel() { } //------------------------------------------------------------------------------------------------------------------ - Window& TaskPaneToolPanel::getPanelWindowAnchor() + void ToolPanel::checkDisposed() { - OSL_ENSURE( !isDisposed(), "already disposed!" ); - return m_pPanelDeck->GetPanelWindowAnchor(); + if ( m_pControl.get() == NULL ) + throw DisposedException( ::rtl::OUString(), *this ); } //------------------------------------------------------------------------------------------------------------------ - ::rtl::OUString TaskPaneToolPanel::GetDisplayName() const + Reference< XWindow > SAL_CALL ToolPanel::getWindow() throw (RuntimeException) { - return m_sPanelName; + ToolPanelGuard aGuard( *this ); + return Reference< XWindow >( m_pControl->GetWindow()->GetComponentInterface(), UNO_QUERY_THROW ); } //------------------------------------------------------------------------------------------------------------------ - Image TaskPaneToolPanel::GetImage() const + Reference< XAccessible > SAL_CALL ToolPanel::createAccessible( const Reference< XAccessible >& i_rParentAccessible ) throw (RuntimeException) { - return m_aPanelImage; + ToolPanelGuard aGuard( *this ); + Reference< XAccessible > xAccessible( m_pControl->GetWindow()->GetAccessible( FALSE ) ); + if ( !xAccessible.is() ) + { + xAccessible.set( m_pControl->CreateAccessibleObject( i_rParentAccessible ) ); + m_pControl->GetWindow()->SetAccessible( xAccessible ); + } + return xAccessible; } //------------------------------------------------------------------------------------------------------------------ - void TaskPaneToolPanel::Dispose() + void SAL_CALL ToolPanel::disposing() { - ENSURE_OR_RETURN_VOID( m_pPanelDeck, "disposed twice" ); - m_pPanelDeck = NULL; + m_pControl.reset(); } //...................................................................................................................... diff --git a/sd/source/ui/toolpanel/TaskPaneToolPanel.hxx b/sd/source/ui/toolpanel/ToolPanel.hxx index d92b1c14bf27..2fe4a64c71be 100644 --- a/sd/source/ui/toolpanel/TaskPaneToolPanel.hxx +++ b/sd/source/ui/toolpanel/ToolPanel.hxx @@ -22,21 +22,17 @@ * <http://www.openoffice.org/license.html> * for a copy of the LGPLv3 License. * -************************************************************************/ + ************************************************************************/ -#ifndef SD_TASKPANETOOLPANEL_HXX -#define SD_TASKPANETOOLPANEL_HXX - -#include "taskpane/TaskPaneControlFactory.hxx" +#ifndef SD_TOOLPANEL_HXX +#define SD_TOOLPANEL_HXX /** === begin UNO includes === **/ -#include <com/sun/star/drawing/framework/XResourceId.hpp> +#include <com/sun/star/ui/XToolPanel.hpp> /** === end UNO includes === **/ -#include <svtools/toolpanel/toolpanel.hxx> - -#include <vcl/image.hxx> -#include <vcl/smartid.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase1.hxx> #include <memory> @@ -45,53 +41,40 @@ namespace sd { namespace toolpanel { //...................................................................................................................... - class ToolPanelDeck; + class TreeNode; //================================================================================================================== - //= TaskPaneToolPanel + //= ToolPanel //================================================================================================================== - class TaskPaneToolPanel : public ::svt::ToolPanelBase + typedef ::cppu::WeakComponentImplHelper1 < ::com::sun::star::ui::XToolPanel + > ToolPanel_Base; + class ToolPanel :public ::cppu::BaseMutex + ,public ToolPanel_Base { - protected: - TaskPaneToolPanel( - ToolPanelDeck& i_rPanelDeck, - const String& i_rPanelName, - const Image& i_rImage, - const SmartId& i_rHelpId + public: + ToolPanel( + ::std::auto_ptr< TreeNode >& i_rControl ); - ~TaskPaneToolPanel(); - public: - // IToolPanel overridables - virtual ::rtl::OUString GetDisplayName() const; - virtual Image GetImage() const; - virtual void Dispose(); - // those are still abstract, and waiting to be overloaded - virtual void Activate( ::Window& i_rParentWindow ) = 0; - virtual void Deactivate() = 0; - virtual void SetSizePixel( const Size& i_rPanelWindowSize ) = 0; - virtual void GrabFocus() = 0; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > - CreatePanelAccessible( - const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rParentAccessible - ) = 0; + // XToolPanel + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL getWindow() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL createAccessible( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& ParentAccessible ) throw (::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); - // own overridables - virtual const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResourceId >& getResourceId() const = 0; + ::osl::Mutex& getMutex() { return m_aMutex; } + void checkDisposed(); protected: - bool isDisposed() const { return m_pPanelDeck == NULL; } - Window& getPanelWindowAnchor(); + ~ToolPanel(); private: - ToolPanelDeck* m_pPanelDeck; - const Image m_aPanelImage; - const String m_sPanelName; - const SmartId m_aHelpId; + ::std::auto_ptr< TreeNode > m_pControl; }; //...................................................................................................................... } } // namespace sd::toolpanel //...................................................................................................................... -#endif // SD_TASKPANETOOLPANEL_HXX +#endif // SD_TOOLPANEL_HXX diff --git a/sd/source/ui/toolpanel/ToolPanelDeck.cxx b/sd/source/ui/toolpanel/ToolPanelDeck.cxx deleted file mode 100755 index 53a1caff73d9..000000000000 --- a/sd/source/ui/toolpanel/ToolPanelDeck.cxx +++ /dev/null @@ -1,160 +0,0 @@ -/************************************************************************* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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. - * -************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "ToolPanelDeck.hxx" -#include "taskpane/ToolPanelViewShell.hxx" -#include "taskpane/ControlContainer.hxx" -#include "framework/FrameworkHelper.hxx" -#include "TaskPaneToolPanel.hxx" -#include "strings.hrc" -#include "sdresid.hxx" - -/** === begin UNO includes === **/ -#include <com/sun/star/drawing/framework/ResourceActivationMode.hpp> -/** === end UNO includes === **/ - -#include <svtools/toolpanel/tablayouter.hxx> -#include <svtools/toolpanel/drawerlayouter.hxx> -#include <tools/diagnose_ex.h> - -//...................................................................................................................... -namespace sd { namespace toolpanel -{ -//...................................................................................................................... - - /** === begin UNO using === **/ - using ::com::sun::star::uno::Reference; - using ::com::sun::star::uno::XInterface; - using ::com::sun::star::uno::UNO_QUERY; - using ::com::sun::star::uno::UNO_QUERY_THROW; - using ::com::sun::star::uno::UNO_SET_THROW; - using ::com::sun::star::uno::Exception; - using ::com::sun::star::uno::RuntimeException; - using ::com::sun::star::uno::Any; - using ::com::sun::star::uno::makeAny; - using ::com::sun::star::uno::Sequence; - using ::com::sun::star::uno::Type; - using ::com::sun::star::drawing::framework::XResourceId; - using ::com::sun::star::drawing::framework::ResourceActivationMode_REPLACE; - /** === end UNO using === **/ - using ::sd::framework::FrameworkHelper; - - //================================================================================================================== - //= ToolPanelDeck - //================================================================================================================== - //------------------------------------------------------------------------------------------------------------------ - ToolPanelDeck::ToolPanelDeck( Window& i_rParent, ToolPanelViewShell& i_rViewShell ) - :ToolPanelDeck_Base( i_rParent, WB_DIALOGCONTROL ) - ,m_rViewShell( i_rViewShell ) - { - SetDrawersLayout(); - - const String sPaneTitle( SdResId( STR_RIGHT_PANE_TITLE ) ); - SetAccessibleName( sPaneTitle ); - SetAccessibleDescription( sPaneTitle ); - } - - //------------------------------------------------------------------------------------------------------------------ - ToolPanelDeck::~ToolPanelDeck() - { - } - - //------------------------------------------------------------------------------------------------------------------ - void ToolPanelDeck::SetDrawersLayout() - { - const ::svt::PDeckLayouter pLayouter( GetLayouter() ); - const ::svt::DrawerDeckLayouter* pDrawerLayouter = dynamic_cast< const ::svt::DrawerDeckLayouter* >( pLayouter.get() ); - if ( pDrawerLayouter != NULL ) - // already have the proper layout - return; - SetLayouter( new ::svt::DrawerDeckLayouter( *this, *this ) ); - } - - //------------------------------------------------------------------------------------------------------------------ - void ToolPanelDeck::SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment, const ::svt::TabItemContent i_eTabContent ) - { - ::svt::PDeckLayouter pLayouter( GetLayouter() ); - ::svt::TabDeckLayouter* pTabLayouter = dynamic_cast< ::svt::TabDeckLayouter* >( pLayouter.get() ); - if ( ( pTabLayouter != NULL ) - && ( pTabLayouter->GetTabAlignment() == i_eTabAlignment ) - && ( pTabLayouter->GetTabItemContent() == i_eTabContent ) - ) - // already have the requested layout - return; - - if ( pTabLayouter && ( pTabLayouter->GetTabAlignment() == i_eTabAlignment ) ) - { - // changing only the item content does not require a new layouter instance - pTabLayouter->SetTabItemContent( i_eTabContent ); - return; - } - - SetLayouter( new ::svt::TabDeckLayouter( *this, *this, i_eTabAlignment, i_eTabContent ) ); - } - - //------------------------------------------------------------------------------------------------------------------ - void ToolPanelDeck::ActivatePanelDirectly( const ::boost::optional< size_t >& i_rPanel ) - { - ToolPanelDeck_Base::ActivatePanel( i_rPanel ); - } - - //------------------------------------------------------------------------------------------------------------------ - void ToolPanelDeck::ActivatePanelResource( const size_t i_nPanel ) - { - // determine resource ID for the given panel - ::svt::PToolPanel pPanel( GetPanel( i_nPanel ) ); - const TaskPaneToolPanel* pTaskPanePanel( dynamic_cast< const TaskPaneToolPanel* >( pPanel.get() ) ); - ENSURE_OR_RETURN_VOID( pTaskPanePanel, "did not find the right panel/type at the given position" ); - const Reference< XResourceId > xPanelId( pTaskPanePanel->getResourceId() ); - - // delegate the request to the configuration controller - ::boost::shared_ptr< FrameworkHelper > pFrameworkHelper( FrameworkHelper::Instance( m_rViewShell.GetViewShellBase() ) ); - pFrameworkHelper->GetConfigurationController()->requestResourceActivation( - xPanelId, ResourceActivationMode_REPLACE ); - } - - //------------------------------------------------------------------------------------------------------------------ - void ToolPanelDeck::ActivatePanel( const ::boost::optional< size_t >& i_rPanel ) - { - if ( !i_rPanel ) - { - // this is a de-activate request. Quite improbable that this really happens: We're within the overloaded - // version of IToolPanelDeck::ActivatePanel. The only instance which has access to this IToolPanel - // interface is the panel layouter, which is not expected to call us with a NULL panel position. - // All other instances should not have access to this method, as it is protected in this class here. - OSL_ENSURE( false, "ToolPanelDeck::ActivatePanel: is this legitimate?" ); - // well, handle it nonetheless. - ActivatePanelDirectly( i_rPanel ); - } - else - ActivatePanelResource( *i_rPanel ); - } - -//...................................................................................................................... -} } // namespace sd::toolpanel -//...................................................................................................................... diff --git a/sd/source/ui/toolpanel/ToolPanelDeck.hxx b/sd/source/ui/toolpanel/ToolPanelDeck.hxx deleted file mode 100644 index e140d9577220..000000000000 --- a/sd/source/ui/toolpanel/ToolPanelDeck.hxx +++ /dev/null @@ -1,97 +0,0 @@ -/************************************************************************* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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 SD_TOOLPANELDECK_HXX -#define SD_TOOLPANELDECK_HXX - -#include "taskpane/TaskPaneTreeNode.hxx" -#include "taskpane/TaskPaneControlFactory.hxx" - -/** === begin UNO includes === **/ -#include <com/sun/star/drawing/framework/XResourceId.hpp> -/** === end UNO includes === **/ - -#include <svtools/toolpanel/toolpaneldeck.hxx> -#include <svtools/toolpanel/tabalignment.hxx> -#include <svtools/toolpanel/tabitemcontent.hxx> - -//...................................................................................................................... -namespace sd { namespace toolpanel -{ -//...................................................................................................................... - - class ToolPanelViewShell; - - //================================================================================================================== - //= ToolPanelDeck - //================================================================================================================== - typedef ::svt::ToolPanelDeck ToolPanelDeck_Base; - class ToolPanelDeck : public ToolPanelDeck_Base - { - public: - ToolPanelDeck( - ::Window& i_rParent, - ToolPanelViewShell& i_rViewShell - ); - ~ToolPanelDeck(); - - /** activates a layout where the active panel is selected via tabs at the right/left/top/bottom (depending on - the given TabAlignment value). - */ - void SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment, const ::svt::TabItemContent i_eTabContent ); - - /** activates the "classical" layout with the panels being represneted by stacked drawers - */ - void SetDrawersLayout(); - - /** directly activates the given panel, without re-routing the activation request through the drawing - framework's configuration controller. - */ - void ActivatePanelDirectly( const ::boost::optional< size_t >& i_rPanel ); - - /** activates the given panel by delegating the acvtivation request to the drawing framework's configuration - controller. - */ - void ActivatePanelResource( const size_t i_nPanel ); - - protected: - // IToolPanelDeck - /** this method, which is part of the callback used by the PanelSelector, does not forward the request to - the base class. Instead, it forwards it to the ToolPanelViewShell, which transforms it into a request - to the drawing framework's configuration controller, which in turn will end up in our public - ActivatePanelDirectly method. - */ - virtual void ActivatePanel( const ::boost::optional< size_t >& i_rPanel ); - - private: - ToolPanelViewShell& m_rViewShell; - }; - -//...................................................................................................................... -} } // sd::toolpanel -//...................................................................................................................... - -#endif // SD_TOOLPANELDECK_HXX diff --git a/sd/source/ui/toolpanel/ToolPanelFactory.cxx b/sd/source/ui/toolpanel/ToolPanelFactory.cxx new file mode 100644 index 000000000000..a0315ed30fd0 --- /dev/null +++ b/sd/source/ui/toolpanel/ToolPanelFactory.cxx @@ -0,0 +1,255 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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. + * + ************************************************************************/ + +#include "precompiled_sd.hxx" + +#include "taskpane/ToolPanelViewShell.hxx" +#include "framework/FrameworkHelper.hxx" +#include "PaneChildWindows.hxx" +#include "ViewShellBase.hxx" +#include "app.hrc" + +/** === begin UNO includes === **/ +#include <com/sun/star/ui/XUIElementFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/awt/XWindow.hpp> +/** === end UNO includes === **/ + +#include <sfx2/frame.hxx> +#include <vcl/svapp.hxx> +#include <vos/mutex.hxx> +#include <sfx2/viewfrm.hxx> +#include <cppuhelper/implbase3.hxx> +#include <comphelper/namedvaluecollection.hxx> +#include <toolkit/helper/vclunohelper.hxx> + +//...................................................................................................................... +namespace sd { namespace toolpanel +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::uno::XComponentContext; + using ::com::sun::star::ui::XUIElementFactory; + using ::com::sun::star::ui::XUIElement; + using ::com::sun::star::beans::PropertyValue; + using ::com::sun::star::container::NoSuchElementException; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::lang::XServiceInfo; + using ::com::sun::star::lang::XInitialization; + using ::com::sun::star::frame::XFrame; + using ::com::sun::star::awt::XWindow; + /** === end UNO using === **/ + + //================================================================================================================== + //= ToolPanelFactory + //================================================================================================================== + typedef ::cppu::WeakImplHelper3 < XUIElementFactory + , XServiceInfo + , XInitialization + > ToolPanelFactory_Base; + class ToolPanelFactory : public ToolPanelFactory_Base + { + public: + ToolPanelFactory( const Reference< XComponentContext >& i_rContext ); + + // XUIElementFactory + virtual Reference< XUIElement > SAL_CALL createUIElement( const ::rtl::OUString& ResourceURL, const Sequence< PropertyValue >& Args ) throw (NoSuchElementException, IllegalArgumentException, RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException); + virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); + + // XInitialization + virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException); + + protected: + virtual ~ToolPanelFactory(); + + private: + const Reference< XComponentContext > m_xContext; + }; + + //------------------------------------------------------------------------------------------------------------------ + Reference< XInterface > SAL_CALL ToolPanelFactory_createInstance( const Reference< XComponentContext >& i_rContext ) + { + return Reference< XInterface >( *new ToolPanelFactory( i_rContext ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString ToolPanelFactory_getImplementationName() throw(RuntimeException) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.drawing.ToolPanelFactory" ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL ToolPanelFactory_getSupportedServiceNames (void) + throw (RuntimeException) + { + const ::rtl::OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DefaultToolPanelFactory" ) ); + return Sequence< ::rtl::OUString >( &sServiceName, 1 ); + } + + //------------------------------------------------------------------------------------------------------------------ + ToolPanelFactory::ToolPanelFactory( const Reference< XComponentContext >& i_rContext ) + :m_xContext( i_rContext ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + ToolPanelFactory::~ToolPanelFactory() + { + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XUIElement > SAL_CALL ToolPanelFactory::createUIElement( const ::rtl::OUString& i_rResourceURL, const Sequence< PropertyValue >& i_rArgs ) throw (NoSuchElementException, IllegalArgumentException, RuntimeException) + { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + + const PanelId ePanelId( toolpanel::GetStandardPanelId( i_rResourceURL ) ); + if ( ePanelId == PID_UNKNOWN ) + throw NoSuchElementException( i_rResourceURL, *this ); + + const ::comphelper::NamedValueCollection aArgs( i_rArgs ); + const Reference< XFrame > xDocFrame( aArgs.getOrDefault( "Frame", Reference< XFrame >() ) ); + const Reference< XWindow > xParentWindow( aArgs.getOrDefault( "ParentWindow", Reference< XWindow >() ) ); + if ( !xDocFrame.is() || !xParentWindow.is() ) + throw IllegalArgumentException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "For creating a standard tool panel, a Frame and a Parent window are needed." ) ), + *this, + 2 + ); + + // look up the Sfx(View)Frame for the given XFrame + SfxViewFrame* pViewFrame = NULL; + for ( SfxFrame* pFrame = SfxFrame::GetFirst(); + pFrame != NULL; + pFrame = SfxFrame::GetNext( *pFrame ) + ) + { + if ( pFrame->GetFrameInterface() == xDocFrame ) + { + pViewFrame = pFrame->GetCurrentViewFrame(); + break; + } + } + + if ( !pViewFrame || !pViewFrame->HasChildWindow( SID_RIGHT_PANE ) ) + throw IllegalArgumentException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Illegal frame." ) ), + *this, + 2 + ); + + // retrieve the task pane + ToolPanelChildWindow* pToolPanelWindow( dynamic_cast< ToolPanelChildWindow* >( pViewFrame->GetChildWindow( SID_RIGHT_PANE ) ) ); + if ( !pToolPanelWindow ) + throw IllegalArgumentException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No Impress document, or no Impress Task Pane." ) ), + *this, + 2 + ); + + // retrieve the ViewShellBase, and the view shell of the task pane + ViewShellBase* pViewShellBase = dynamic_cast< ViewShellBase* >( pViewFrame->GetViewShell() ); + ::boost::shared_ptr< framework::FrameworkHelper > pFrameworkHelper; + if ( pViewShellBase ) + pFrameworkHelper = framework::FrameworkHelper::Instance( *pViewShellBase ); + ::boost::shared_ptr< ViewShell > pViewShell; + if ( pFrameworkHelper.get() ) + pViewShell = pFrameworkHelper->GetViewShell( framework::FrameworkHelper::msRightPaneURL ); + ToolPanelViewShell* pToolPanelShell = dynamic_cast< ToolPanelViewShell* >( pViewShell.get() ); + + if ( !pToolPanelShell ) + throw IllegalArgumentException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Wrong document type." ) ), + *this, + 2 + ); + + ::Window* pParentWindow = VCLUnoHelper::GetWindow( xParentWindow ); + if ( !pParentWindow || !pToolPanelShell->IsPanelAnchorWindow( *pParentWindow ) ) + throw IllegalArgumentException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unsupported parent window." ) ), + *this, + 2 + ); + + return pToolPanelShell->CreatePanelUIElement( xDocFrame, i_rResourceURL ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL ToolPanelFactory::getImplementationName( ) throw (RuntimeException) + { + return ToolPanelFactory_getImplementationName(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL ToolPanelFactory::supportsService( const ::rtl::OUString& i_rServiceName ) throw (RuntimeException) + { + const Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() ); + for ( const ::rtl::OUString* pSupported = aSupported.getConstArray(); + pSupported != aSupported.getConstArray() + aSupported.getLength(); + ++pSupported + ) + if ( *pSupported == i_rServiceName ) + return sal_True; + + return sal_False; + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL ToolPanelFactory::getSupportedServiceNames( ) throw (RuntimeException) + { + return ToolPanelFactory_getSupportedServiceNames(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL ToolPanelFactory::initialize( const Sequence< Any >& i_rArguments ) throw (Exception, RuntimeException) + { + ::comphelper::NamedValueCollection aArgs( i_rArguments ); + (void)aArgs; + // TODO + } + +//...................................................................................................................... +} } // namespace sd::toolpanel +//...................................................................................................................... diff --git a/sd/workben/custompanel/ctp_services.cxx b/sd/source/ui/toolpanel/ToolPanelUIElement.cxx index 67fd5af14c7b..e81f683bcfa7 100644 --- a/sd/workben/custompanel/ctp_services.cxx +++ b/sd/source/ui/toolpanel/ToolPanelUIElement.cxx @@ -22,19 +22,22 @@ * <http://www.openoffice.org/license.html> * for a copy of the LGPLv3 License. * -************************************************************************/ + ************************************************************************/ #include "precompiled_sd.hxx" -#include "ctp_factory.hxx" +#include "ToolPanelUIElement.hxx" +#include "MethodGuard.hxx" /** === begin UNO includes === **/ +#include <com/sun/star/ui/UIElementType.hpp> +#include <com/sun/star/lang/XComponent.hpp> /** === end UNO includes === **/ -#include <cppuhelper/implementationentry.hxx> +#include <tools/diagnose_ex.h> //...................................................................................................................... -namespace sd { namespace colortoolpanel +namespace sd { namespace toolpanel { //...................................................................................................................... @@ -50,43 +53,82 @@ namespace sd { namespace colortoolpanel using ::com::sun::star::uno::makeAny; using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Type; + using ::com::sun::star::frame::XFrame; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::ui::XToolPanel; + using ::com::sun::star::lang::DisposedException; /** === end UNO using === **/ + namespace UIElementType = ::com::sun::star::ui::UIElementType; + + typedef MethodGuard< ToolPanelUIElement > UIElementMethodGuard; //================================================================================================================== - //= descriptors for the services implemented in this component + //= ToolPanelUIElement //================================================================================================================== - static struct ::cppu::ImplementationEntry s_aServiceEntries[] = + //------------------------------------------------------------------------------------------------------------------ + ToolPanelUIElement::ToolPanelUIElement( const Reference< XFrame >& i_rFrame, const ::rtl::OUString& i_rResourceURL, + const Reference< XToolPanel >& i_rToolPanel ) + :ToolPanelUIElement_Base( m_aMutex ) + ,m_xFrame( i_rFrame ) + ,m_sResourceURL( i_rResourceURL ) + ,m_xToolPanel( i_rToolPanel ) { - { - ResourceFactory::Create, - ResourceFactory::getImplementationName_static, - ResourceFactory::getSupportedServiceNames_static, - ::cppu::createSingleComponentFactory, NULL, 0 - }, - { 0, 0, 0, 0, 0, 0 } - }; + } -//...................................................................................................................... -} } // namespace sd::colortoolpanel -//...................................................................................................................... + //------------------------------------------------------------------------------------------------------------------ + ToolPanelUIElement::~ToolPanelUIElement() + { + } + + //------------------------------------------------------------------------------------------------------------------ + void ToolPanelUIElement::checkDisposed() + { + if ( !m_xToolPanel.is() ) + throw DisposedException( ::rtl::OUString(), *this ); + } -extern "C" -{ //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ) + Reference< XFrame > SAL_CALL ToolPanelUIElement::getFrame() throw (RuntimeException) { - *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; + UIElementMethodGuard aGuard( *this ); + return m_xFrame; } //------------------------------------------------------------------------------------------------------------------ - sal_Bool SAL_CALL component_writeInfo( void * pServiceManager, void * pRegistryKey ) + ::rtl::OUString SAL_CALL ToolPanelUIElement::getResourceURL() throw (RuntimeException) { - return ::cppu::component_writeInfoHelper( pServiceManager, pRegistryKey, ::sd::colortoolpanel::s_aServiceEntries ); + UIElementMethodGuard aGuard( *this ); + return m_sResourceURL; } //------------------------------------------------------------------------------------------------------------------ - void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) + ::sal_Int16 SAL_CALL ToolPanelUIElement::getType() throw (RuntimeException) { - return ::cppu::component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , ::sd::colortoolpanel::s_aServiceEntries ); + UIElementMethodGuard aGuard( *this ); + return UIElementType::TOOLPANEL; } -} + + //------------------------------------------------------------------------------------------------------------------ + Reference< XInterface > SAL_CALL ToolPanelUIElement::getRealInterface( ) throw (RuntimeException) + { + UIElementMethodGuard aGuard( *this ); + return m_xToolPanel.get(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL ToolPanelUIElement::disposing() + { + try + { + Reference< XComponent > xPanelComponent( m_xToolPanel, UNO_QUERY_THROW ); + xPanelComponent->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + +//...................................................................................................................... +} } // namespace sd::toolpanel +//...................................................................................................................... diff --git a/sd/source/ui/toolpanel/StandardToolPanel.hxx b/sd/source/ui/toolpanel/ToolPanelUIElement.hxx index a40c3d4af5f2..0a74b7bd449e 100644 --- a/sd/source/ui/toolpanel/StandardToolPanel.hxx +++ b/sd/source/ui/toolpanel/ToolPanelUIElement.hxx @@ -22,63 +22,66 @@ * <http://www.openoffice.org/license.html> * for a copy of the LGPLv3 License. * -************************************************************************/ + ************************************************************************/ -#ifndef SD_TOOLPANEL_STANDARDTOOLPANEL_HXX -#define SD_TOOLPANEL_STANDARDTOOLPANEL_HXX +#ifndef SD_TOOLPANELUIELEMENT_HXX +#define SD_TOOLPANELUIELEMENT_HXX -#include "TaskPaneToolPanel.hxx" +/** === begin UNO includes === **/ +#include <com/sun/star/ui/XUIElement.hpp> +#include <com/sun/star/ui/XToolPanel.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/compbase1.hxx> +#include <cppuhelper/basemutex.hxx> + +#include <memory> //...................................................................................................................... namespace sd { namespace toolpanel { //...................................................................................................................... + class TreeNode; + //================================================================================================================== - //= StandardToolPanel + //= ToolPanelUIElement //================================================================================================================== - /** an IToolPanel implementation for one of the standard (aka built-in) tool panels - */ - class StandardToolPanel : public TaskPaneToolPanel + typedef ::cppu::WeakComponentImplHelper1 < ::com::sun::star::ui::XUIElement + > ToolPanelUIElement_Base; + class ToolPanelUIElement :public ::cppu::BaseMutex + ,public ToolPanelUIElement_Base { public: - StandardToolPanel( - ToolPanelDeck& i_rPanelDeck, - ::std::auto_ptr< ControlFactory >& i_rControlFactory, - const USHORT i_nTitleResId, - const Image& i_rImage, - const ULONG i_nHelpId, - const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResourceId >& i_rPanelResourceId + ToolPanelUIElement( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, + const ::rtl::OUString& i_rResourceURL, + const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XToolPanel >& i_rToolPanel ); - ~StandardToolPanel(); - // IToolPanel overridables - virtual void Activate( ::Window& i_rParentWindow ); - virtual void Deactivate(); - virtual void SetSizePixel( const Size& i_rPanelWindowSize ); - virtual void GrabFocus(); - virtual void Dispose(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > - CreatePanelAccessible( - const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rParentAccessible - ); + // XUIElement + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SAL_CALL getFrame() throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getResourceURL() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getType() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getRealInterface( ) throw (::com::sun::star::uno::RuntimeException); - // TaskPaneToolPanel overridables - virtual const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResourceId >& getResourceId() const; + void checkDisposed(); + ::osl::Mutex& getMutex() { return m_aMutex; } - private: - bool impl_ensureControl(); - ::Window* impl_getPanelWindow() const; + protected: + virtual ~ToolPanelUIElement(); + + // OComponentHelper + virtual void SAL_CALL disposing(); private: - ::std::auto_ptr< ControlFactory > m_pControlFactory; - ::std::auto_ptr< TreeNode > m_pControl; - ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResourceId > - m_xPanelResourceId; + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame; + const ::rtl::OUString m_sResourceURL; + const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XToolPanel > m_xToolPanel; }; //...................................................................................................................... } } // namespace sd::toolpanel //...................................................................................................................... -#endif // SD_TOOLPANEL_STANDARDTOOLPANEL_HXX +#endif // SD_TOOLPANELUIELEMENT_HXX diff --git a/sd/source/ui/toolpanel/ToolPanelViewShell.cxx b/sd/source/ui/toolpanel/ToolPanelViewShell.cxx index 678f1da78f56..336ef3b6622c 100755 --- a/sd/source/ui/toolpanel/ToolPanelViewShell.cxx +++ b/sd/source/ui/toolpanel/ToolPanelViewShell.cxx @@ -31,18 +31,18 @@ #include "TaskPaneShellManager.hxx" #include "TaskPaneFocusManager.hxx" -#include "StandardToolPanel.hxx" -#include "CustomToolPanel.hxx" +#include "taskpane/TaskPaneControlFactory.hxx" #include "controls/MasterPagesPanel.hxx" #include "LayoutMenu.hxx" #include "controls/TableDesignPanel.hxx" #include "controls/CustomAnimationPanel.hxx" #include "controls/SlideTransitionPanel.hxx" #include "controls/MasterPagesSelector.hxx" +#include "ToolPanel.hxx" +#include "ToolPanelUIElement.hxx" #include "PaneDockingWindow.hxx" #include "FrameView.hxx" #include "Window.hxx" -#include "ToolPanelDeck.hxx" #include "sdmod.hxx" #include "app.hrc" #include "glob.hrc" @@ -56,10 +56,14 @@ #include <com/sun/star/drawing/framework/XResourceId.hpp> #include <com/sun/star/drawing/framework/ResourceActivationMode.hpp> #include <com/sun/star/drawing/framework/AnchorBindingMode.hpp> +#include <com/sun/star/drawing/framework/ResourceActivationMode.hpp> #include <com/sun/star/drawing/XDrawSubController.hpp> /** === end UNO includes === **/ +#include <svtools/toolpanel/toolpanel.hxx> +#include <svtools/toolpanel/toolpaneldeck.hxx> #include <svx/dlgctrl.hxx> +#include <sfx2/taskpane.hxx> #include <sfx2/imagemgr.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> @@ -79,6 +83,7 @@ #include <tools/diagnose_ex.h> #include <unotools/confignode.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/accimplaccess.hxx> #include <comphelper/componentcontext.hxx> #include <cppuhelper/implbase1.hxx> #include <cppuhelper/basemutex.hxx> @@ -114,6 +119,9 @@ using ::com::sun::star::drawing::framework::XConfigurationControllerBroadcaster; using ::com::sun::star::drawing::framework::XConfigurationController; using ::com::sun::star::drawing::framework::XConfiguration; using ::com::sun::star::drawing::framework::AnchorBindingMode_DIRECT; +using ::com::sun::star::ui::XUIElement; +using ::com::sun::star::ui::XToolPanel; +using ::com::sun::star::drawing::framework::ResourceActivationMode_REPLACE; /** === end UNO using === **/ using ::sd::framework::FrameworkHelper; @@ -121,43 +129,46 @@ using ::sd::framework::FrameworkHelper; namespace sd { namespace toolpanel { // ===================================================================================================================== -// = PanelDescriptor +// = misc helper // ===================================================================================================================== -/** is a helper class for ToolPanelViewShell_Impl, holding the details about a single panel which is not - contained in the IToolPanel implementation itself. -*/ -struct PanelDescriptor +// --------------------------------------------------------------------------------------------------------------------- +PanelId GetStandardPanelId( const ::rtl::OUString& i_rTaskPanelResourceURL, const bool i_bIgnoreUnknown ) { - PanelId nId; - ::svt::PToolPanel pPanel; - bool bHidden; - - PanelDescriptor() - :nId( PID_UNKNOWN ) - ,pPanel() - ,bHidden( false ) + PanelId ePanelId( PID_UNKNOWN ); + + if ( i_rTaskPanelResourceURL.equals( FrameworkHelper::msMasterPagesTaskPanelURL ) ) { + ePanelId = PID_MASTER_PAGES; } - - PanelDescriptor( const PanelId i_nPanelId, const ::svt::PToolPanel& i_rPanel ) - :nId( i_nPanelId ) - ,pPanel( i_rPanel ) - ,bHidden( false ) + else if ( i_rTaskPanelResourceURL.equals( FrameworkHelper::msLayoutTaskPanelURL ) ) + { + ePanelId = PID_LAYOUT; + } + else if ( i_rTaskPanelResourceURL.equals( FrameworkHelper::msTableDesignPanelURL ) ) { + ePanelId = PID_TABLE_DESIGN; + } + else if ( i_rTaskPanelResourceURL.equals( FrameworkHelper::msCustomAnimationTaskPanelURL ) ) + { + ePanelId = PID_CUSTOM_ANIMATION; + } + else if ( i_rTaskPanelResourceURL.equals( FrameworkHelper::msSlideTransitionTaskPanelURL ) ) + { + ePanelId = PID_SLIDE_TRANSITION; + } + else + { + OSL_ENSURE( i_bIgnoreUnknown, "GetStandardPanelId: cannot translate the given resource URL!" ); } -}; -// ===================================================================================================================== -// = PanelSelectorLayout -// ===================================================================================================================== -enum PanelSelectorLayout + return ePanelId; +} + +// --------------------------------------------------------------------------------------------------------------------- +PanelId GetStandardPanelId( const ::rtl::OUString& i_rTaskPanelResourceURL ) { - LAYOUT_DRAWERS, - LAYOUT_TABS_RIGHT, - LAYOUT_TABS_LEFT, - LAYOUT_TABS_TOP, - LAYOUT_TABS_BOTTOM -}; + return GetStandardPanelId( i_rTaskPanelResourceURL, false ); +} // ===================================================================================================================== // = ConfigurationListener - declaration @@ -198,7 +209,8 @@ private: // ===================================================================================================================== /** Inner implementation class of ToolPanelViewShell. */ -class ToolPanelViewShell_Impl : public ::svt::IToolPanelDeckListener +class ToolPanelViewShell_Impl :public ::boost::noncopyable + ,public ::svt::IToolPanelDeckListener { public: static const size_t mnInvalidId = static_cast< size_t >( -1 ); @@ -216,55 +228,30 @@ public: */ void Cleanup(); - /** sets the given layout for the panel selector + /** activates the panel which has the given resource URL */ - void SetLayout( const PanelSelectorLayout i_eLayout, const bool i_bForce = false ); + void ActivatePanelByResource( const ::rtl::OUString& i_rPanelResourceURL ); - /** returns the current layout - */ - PanelSelectorLayout - GetLayout() const { return m_eCurrentLayout; } + /** de-activates the panel given by its resource URL, bypassing the configuration controller - /** called by our configuration controller listener when the request to activate a tool panel has been observed. + If the panel is not active currently, nothing happens. */ - void OnToolPanelActivationRequest( const ::rtl::OUString& i_rResourceURL ); + void DeactivatePanelByResource( const ::rtl::OUString& i_rPanelResourceURL ); /** provides access to the the VCL window of the panel deck */ - ::Window& GetPanelDeck() { return *m_pPanelDeck.get(); } - const ::Window& GetPanelDeck() const { return *m_pPanelDeck.get(); } + ::sfx2::ModuleTaskPane& GetTaskPane() { return *m_pTaskPane; } + const ::sfx2::ModuleTaskPane& GetTaskPane() const { return *m_pTaskPane; } - ::Window* GetToolPanelParentWindow() { return m_pPanelDeck.get() ? &m_pPanelDeck->GetPanelWindowAnchor() : NULL; } - - /** returns the logical number of panels. This is greater than or equal to the number of panels displayed in the - panel deck - */ - size_t GetPanelCount() const - { - return m_aPanels.size(); - } - - const PanelDescriptor& GetPanel( const size_t i_nLogicalPanelIndex ) const - { - return m_aPanels[ i_nLogicalPanelIndex ]; - } - - void TogglePanelVisibility( const size_t i_nLogicalPanelIndex ); - - /** ensures the panel with the given ID is visible, and directly activates it, bypassing the configuration controller - */ - void ActivatePanelDirectly( const PanelId i_nPanelId ); - - /** de-activates the panel given by ID, bypassing the configuration controller - - If the panel is not active currently, nothing happens. - */ - void DeactivatePanelDirectly( const PanelId i_nPanelId ); + ::svt::ToolPanelDeck& GetToolPanelDeck() { return GetTaskPane().GetPanelDeck(); } + const ::svt::ToolPanelDeck& GetToolPanelDeck() const { return GetTaskPane().GetPanelDeck(); } Reference< XAccessible > CreateAccessible( ::sd::Window& i_rWindow ); -protected: + void ConnectToDockingWindow(); + +private: // IToolPanelDeckListener overridables virtual void PanelInserted( const ::svt::PToolPanel& i_pPanel, const size_t i_nPosition ); virtual void PanelRemoved( const size_t i_nPosition ); @@ -273,35 +260,25 @@ protected: virtual void Dying(); private: - void RegisterPanel( size_t i_nPosition, PanelId i_nPanelId, const ::svt::PToolPanel& i_rPanel ); - void UpdateDockingWindowTitle(); - - /** creates the built-in panels, returns the position of the panel to initially activate - */ - struct PanelActivation + struct InitialPanel { - size_t nPanelPos; - bool bActivateAsResource; - - PanelActivation() - :nPanelPos( size_t( -1 ) ) - ,bActivateAsResource( true ) + ::rtl::OUString sPanelResourceURL; + bool bActivateDirectly; + InitialPanel() + :sPanelResourceURL() + ,bActivateDirectly( true ) { } }; - PanelActivation SetupDefaultPanels(); + InitialPanel impl_determineInitialPanel(); + ::rtl::OUString impl_getPanelURL( const ::boost::optional< size_t >& i_rPanel ); - /** creates the custom panels - */ - void SetupCustomPanels(); - - typedef ::std::vector< PanelDescriptor > PanelDescriptors; - PanelDescriptors m_aPanels; - ToolPanelViewShell& m_rPanelViewShell; - ::boost::scoped_ptr< ToolPanelDeck > m_pPanelDeck; - ::rtl::Reference< ConfigurationListener > m_pConfigListener; - PanelSelectorLayout m_eCurrentLayout; - bool m_bInitialized; +private: + ToolPanelViewShell& m_rPanelViewShell; + ::boost::scoped_ptr< ::sfx2::ModuleTaskPane > m_pTaskPane; + ::std::auto_ptr< ::sfx2::TaskPaneController > m_pTaskPaneController; + ::rtl::Reference< ConfigurationListener > m_pConfigListener; + bool m_bInitialized; }; // ===================================================================================================================== @@ -335,17 +312,6 @@ void SAL_CALL ConfigurationListener::notifyConfigurationChange( const Configurat ::osl::MutexGuard aGuard( m_aMutex ); impl_checkDisposed_throw(); -// if ( i_rEvent.Type == FrameworkHelper::msConfigurationUpdateStartEvent ) -// { -// m_pShellImpl->GetPanelDeck().SetUpdateMode( FALSE ); -// return; -// } -// if ( i_rEvent.Type == FrameworkHelper::msConfigurationUpdateEndEvent ) -// { -// m_pShellImpl->GetPanelDeck().SetUpdateMode( TRUE ); -// return; -// } -// // is this an event we're interested in? if ( i_rEvent.Type != FrameworkHelper::msResourceActivationEvent ) return; @@ -360,7 +326,7 @@ void SAL_CALL ConfigurationListener::notifyConfigurationChange( const Configurat if ( sAnchorURL != FrameworkHelper::msTaskPaneURL ) return; - m_pShellImpl->OnToolPanelActivationRequest( i_rEvent.ResourceId->getResourceURL() ); + m_pShellImpl->ActivatePanelByResource( i_rEvent.ResourceId->getResourceURL() ); } // --------------------------------------------------------------------------------------------------------------------- @@ -383,22 +349,6 @@ void ConfigurationListener::dispose() } // ===================================================================================================================== -// = helpers -// ===================================================================================================================== -// --------------------------------------------------------------------------------------------------------------------- -namespace { - -enum MenuId { - MID_UNLOCK_TASK_PANEL = 1, - MID_LOCK_TASK_PANEL = 2, - MID_LAYOUT_TABS = 3, - MID_LAYOUT_DRAWERS = 4, - MID_FIRST_PANEL = 5 -}; - -} // end of anonymouse namespace - -// ===================================================================================================================== // = ToolPanelViewShell // ===================================================================================================================== // --------------------------------------------------------------------------------------------------------------------- @@ -410,75 +360,17 @@ SFX_IMPL_INTERFACE(ToolPanelViewShell, SfxShell, SdResId(STR_TASKPANEVIEWSHELL)) TYPEINIT1(ToolPanelViewShell, ViewShell); // --------------------------------------------------------------------------------------------------------------------- -ToolPanelViewShell_Impl::PanelActivation ToolPanelViewShell_Impl::SetupDefaultPanels() +ToolPanelViewShell_Impl::InitialPanel ToolPanelViewShell_Impl::impl_determineInitialPanel() { - typedef std::auto_ptr<ControlFactory> (*ControlFactoryFactory)( ToolPanelViewShell& i_rToolPanelShell ); - - struct PanelDescriptor - { - ControlFactoryFactory pFactory; - const sal_Char* pImageCommandName; - USHORT nTitleResourceID; - ULONG nHelpID; - PanelId nPanelID; - ::rtl::OUString sResourceURL; - }; - - PanelDescriptor aPanels[] = - { - // "Master Pages" - { &controls::MasterPagesPanel::CreateControlFactory, - "PresentationLayout", - STR_TASKPANEL_MASTER_PAGE_TITLE, - HID_SD_SLIDE_DESIGNS, - PID_MASTER_PAGES, - FrameworkHelper::msMasterPagesTaskPanelURL - }, - // "Layout" - { &LayoutMenu::CreateControlFactory, - "ModifyPage", - STR_TASKPANEL_LAYOUT_MENU_TITLE, - HID_SD_SLIDE_LAYOUTS, - PID_LAYOUT, - FrameworkHelper::msLayoutTaskPanelURL - }, - // "Tables Design" - { &controls::TableDesignPanel::CreateControlFactory, - "InsertTable", - DLG_TABLEDESIGNPANE, - HID_SD_TABLE_DESIGN, - PID_TABLE_DESIGN, - FrameworkHelper::msTableDesignPanelURL - }, - // "Custom Animation" - { &controls::CustomAnimationPanel::CreateControlFactory, - "CustomAnimation", - STR_CUSTOMANIMATIONPANE, - HID_SD_CUSTOM_ANIMATIONS, - PID_CUSTOM_ANIMATION, - FrameworkHelper::msCustomAnimationTaskPanelURL - }, - // "Slide Transition" - { &controls::SlideTransitionPanel::CreateControlFactory, - "RehearseTimings", - STR_SLIDE_TRANSITION_PANE, - HID_SD_SLIDE_TRANSITIONS, - PID_SLIDE_TRANSITION, - FrameworkHelper::msSlideTransitionTaskPanelURL - } - }; - - // compose the resource ID for the ToolPanel view - ::boost::shared_ptr< FrameworkHelper > pFrameworkHelper( FrameworkHelper::Instance( m_rPanelViewShell.GetViewShellBase() ) ); - const Reference< XResourceId > xToolPanelId( pFrameworkHelper->CreateResourceId( FrameworkHelper::msTaskPaneURL, FrameworkHelper::msRightPaneURL ) ); - - // determine which panel should be activated initially. - // Default to PID_LAYOUT, but check whether the requested configuration already contains a tool panel, in this case, + // Default to Layout panel, but check whether the requested configuration already contains a tool panel, in this case, // use that one. - PanelId nPanelToActivate = PID_LAYOUT; - PanelActivation aPanelToActivate; + InitialPanel aPanelToActivate; + aPanelToActivate.sPanelResourceURL = FrameworkHelper::msLayoutTaskPanelURL; + aPanelToActivate.bActivateDirectly = false; try { + ::boost::shared_ptr< FrameworkHelper > pFrameworkHelper( FrameworkHelper::Instance( m_rPanelViewShell.GetViewShellBase() ) ); + const Reference< XResourceId > xToolPanelId( pFrameworkHelper->CreateResourceId( FrameworkHelper::msTaskPaneURL, FrameworkHelper::msRightPaneURL ) ); Reference< XConfigurationController > xCC( pFrameworkHelper->GetConfigurationController(), UNO_QUERY_THROW ); Reference< XConfiguration > xConfiguration( xCC->getRequestedConfiguration(), UNO_QUERY_THROW ); Sequence< Reference< XResourceId > > aViewIds( xConfiguration->getResources( @@ -491,8 +383,8 @@ ToolPanelViewShell_Impl::PanelActivation ToolPanelViewShell_Impl::SetupDefaultPa PanelId nRequestedPanel = GetStandardPanelId( sResourceURL ); if ( nRequestedPanel != PID_UNKNOWN ) { - nPanelToActivate = nRequestedPanel; - aPanelToActivate.bActivateAsResource = false; + aPanelToActivate.sPanelResourceURL = sResourceURL; + aPanelToActivate.bActivateDirectly = true; } } } @@ -500,131 +392,35 @@ ToolPanelViewShell_Impl::PanelActivation ToolPanelViewShell_Impl::SetupDefaultPa { DBG_UNHANDLED_EXCEPTION(); } - - // create the panels - Reference< XFrame > xFrame( m_rPanelViewShell.GetViewShellBase().GetViewFrame()->GetFrame().GetFrameInterface() ); - const BOOL bHiContrast( m_pPanelDeck->GetSettings().GetStyleSettings().GetHighContrastMode() ); - for ( size_t i=0; i < sizeof( aPanels ) / sizeof( aPanels[0] ); ++i ) - { - // compose the command name, and obtain the image for it - ::rtl::OUStringBuffer aCommandName; - aCommandName.appendAscii( ".uno:" ); - aCommandName.appendAscii( aPanels[i].pImageCommandName ); - const Image aPanelImage( GetImage( xFrame, aCommandName.makeStringAndClear(), FALSE, bHiContrast ) ); - - // compose the resource ID of the panel - const Reference< XResourceId > xPanelId( pFrameworkHelper->CreateResourceId( aPanels[i].sResourceURL, xToolPanelId ) ); - - // create and insert the panel - ::std::auto_ptr< ControlFactory > pControlFactory( (*aPanels[i].pFactory)( m_rPanelViewShell ) ); - ::svt::PToolPanel pNewPanel( new StandardToolPanel( - *m_pPanelDeck, - pControlFactory, - aPanels[i].nTitleResourceID, - aPanelImage, - aPanels[i].nHelpID, - xPanelId - ) ); - const size_t nPanelPos = m_pPanelDeck->InsertPanel( pNewPanel, m_pPanelDeck->GetPanelCount() ); - - // remember it - RegisterPanel( nPanelPos, aPanels[i].nPanelID, pNewPanel ); - - if ( nPanelToActivate == aPanels[i].nPanelID ) - aPanelToActivate.nPanelPos = nPanelPos; - } - return aPanelToActivate; } // --------------------------------------------------------------------------------------------------------------------- -void ToolPanelViewShell_Impl::SetupCustomPanels() -{ - // compose the resource ID for the ToolPanel view - ::boost::shared_ptr< FrameworkHelper > pFrameworkHelper( FrameworkHelper::Instance( m_rPanelViewShell.GetViewShellBase() ) ); - const Reference< XResourceId > xToolPanelId( pFrameworkHelper->CreateResourceId( FrameworkHelper::msTaskPaneURL, FrameworkHelper::msRightPaneURL ) ); - - // get the config node holding the custom tool panel descriptions - ::utl::OConfigurationTreeRoot aConfig( ::comphelper::ComponentContext( ::comphelper::getProcessServiceFactory() ), - "/org.openoffice.Office.Impress/MultiPaneGUI/ToolPanel/CustomPanels", false ); - const Sequence< ::rtl::OUString > aCustomPanelDescs( aConfig.getNodeNames() ); - - // create panels - size_t nCustomPanelNo = 0; - for ( const ::rtl::OUString* panelNodeName = aCustomPanelDescs.getConstArray(); - panelNodeName != aCustomPanelDescs.getConstArray() + aCustomPanelDescs.getLength(); - ++panelNodeName - ) - { - ::utl::OConfigurationNode aPanelDesc( aConfig.openNode( *panelNodeName ) ); - - // create and insert the panel - ::svt::PToolPanel pNewPanel( new CustomToolPanel( *m_pPanelDeck, aPanelDesc, xToolPanelId, pFrameworkHelper ) ); - const size_t nPanelPos = m_pPanelDeck->InsertPanel( pNewPanel, m_pPanelDeck->GetPanelCount() ); - - // remember it - RegisterPanel( nPanelPos, PanelId( PID_FIRST_CUSTOM_PANEL + nCustomPanelNo ), pNewPanel ); - ++nCustomPanelNo; - } -} - -// --------------------------------------------------------------------------------------------------------------------- void ToolPanelViewShell_Impl::Setup() { if ( m_bInitialized ) return; m_bInitialized = true; - // standard (built-in) panels - const PanelActivation aPanelToActivate = SetupDefaultPanels(); - - // custom panels - SetupCustomPanels(); - - // activate default panel - if ( aPanelToActivate.bActivateAsResource ) - m_pPanelDeck->ActivatePanelResource( aPanelToActivate.nPanelPos ); - else - m_pPanelDeck->ActivatePanelDirectly( aPanelToActivate.nPanelPos ); - - // add as listener to the panel deck - m_pPanelDeck->AddListener( *this ); - - // initialize panel selector - SetLayout( LAYOUT_DRAWERS, true ); + // initially activate a panel + const InitialPanel aInitialPanel = impl_determineInitialPanel(); + if ( aInitialPanel.sPanelResourceURL.getLength() ) + { + if ( aInitialPanel.bActivateDirectly ) + { + ActivatePanelByResource( aInitialPanel.sPanelResourceURL ); + } + else + { + ::boost::shared_ptr< FrameworkHelper > pFrameworkHelper( FrameworkHelper::Instance( GetAntiImpl().GetViewShellBase() ) ); + pFrameworkHelper->RequestTaskPanel( aInitialPanel.sPanelResourceURL ); + } + } // listen at the configuration m_pConfigListener.set( new ConfigurationListener( *this ) ); - m_pPanelDeck->Show(); -} - -// --------------------------------------------------------------------------------------------------------------------- -void ToolPanelViewShell_Impl::SetLayout( const PanelSelectorLayout i_eLayout, const bool i_bForce ) -{ - if ( !i_bForce && ( m_eCurrentLayout == i_eLayout ) ) - return; - - switch ( i_eLayout ) - { - case LAYOUT_DRAWERS: - m_pPanelDeck->SetDrawersLayout(); - break; - case LAYOUT_TABS_TOP: - m_pPanelDeck->SetTabsLayout( ::svt::TABS_TOP, ::svt::TABITEM_IMAGE_ONLY ); - break; - case LAYOUT_TABS_BOTTOM: - m_pPanelDeck->SetTabsLayout( ::svt::TABS_BOTTOM, ::svt::TABITEM_IMAGE_ONLY ); - break; - case LAYOUT_TABS_LEFT: - m_pPanelDeck->SetTabsLayout( ::svt::TABS_LEFT, ::svt::TABITEM_IMAGE_ONLY ); - break; - case LAYOUT_TABS_RIGHT: - m_pPanelDeck->SetTabsLayout( ::svt::TABS_RIGHT, ::svt::TABITEM_IMAGE_ONLY ); - break; - } - m_eCurrentLayout = i_eLayout; - UpdateDockingWindowTitle(); + m_pTaskPane->Show(); } // --------------------------------------------------------------------------------------------------------------------- @@ -632,56 +428,34 @@ void ToolPanelViewShell_Impl::Cleanup() { if ( m_bInitialized ) { - m_pPanelDeck->RemoveListener( *this ); - // remove the panels which are not under the control of the panel deck currently - for ( PanelDescriptors::iterator panelPos = m_aPanels.begin(); - panelPos != m_aPanels.end(); - ++panelPos - ) - { - if ( panelPos->bHidden ) - panelPos->pPanel->Dispose(); - } - m_aPanels.clear(); - if ( m_pConfigListener.is() ) m_pConfigListener->dispose(); } - m_pPanelDeck.reset(); + GetToolPanelDeck().RemoveListener( *this ); + m_pTaskPaneController.reset(); + m_pTaskPane.reset(); } // --------------------------------------------------------------------------------------------------------------------- -void ToolPanelViewShell_Impl::OnToolPanelActivationRequest( const ::rtl::OUString& i_rResourceURL ) +void ToolPanelViewShell_Impl::ActivatePanelByResource( const ::rtl::OUString& i_rResourceURL ) { - // look up the panel which belongs to the given resource - for ( size_t i=0; i<GetPanelCount(); ++i ) - { - const PanelDescriptor& rPanel = GetPanel( i ); - const TaskPaneToolPanel* pPanel( dynamic_cast< const TaskPaneToolPanel* >( rPanel.pPanel.get() ) ); - ENSURE_OR_CONTINUE( pPanel != NULL, "ToolPanelViewShell::OnToolPanelActivationRequest: illegal panel implementation!" ); - - Reference< XResourceId > xPanelId( pPanel->getResourceId() ); - ::rtl::OUString sPanelURL( xPanelId.is() ? xPanelId->getResourceURL() : ::rtl::OUString() ); - ENSURE_OR_CONTINUE( sPanelURL.getLength(), "illegal panel resource!" ); + // determine position of the requested panel + ::boost::optional< size_t > aPanelPos = GetTaskPane().GetPanelPos( i_rResourceURL ); + OSL_ENSURE( !!aPanelPos, "ToolPanelViewShell_Impl::ActivatePanelByResource: illegal panel resource, or illegal panel deck setup!" ); + if ( !!aPanelPos ) + GetToolPanelDeck().ActivatePanel( *aPanelPos ); +} - if ( sPanelURL == i_rResourceURL ) - { - CustomToolPanel* pCustomPanel = dynamic_cast< CustomToolPanel* >( rPanel.pPanel.get() ); - OSL_ENSURE( ( pCustomPanel != NULL ) == ( rPanel.nId >= PID_FIRST_CUSTOM_PANEL ), - "ToolPanelViewShell::OnToolPanelActivationRequest: inconsistency!" ); - if ( pCustomPanel != NULL ) - { - // if that's a custom tool panel, then temporarily disable the access of the tool panel implementation - // to the XPane object. Otherwise, it would request this resource from the configuration controller during - // the below ActivatePanelDirectly call, which would fail, since the resource is just to be created. - pCustomPanel->LockResourceAccess(); - } - ActivatePanelDirectly( rPanel.nId ); - if ( pCustomPanel != NULL ) - { - pCustomPanel->UnlockResourceAccess(); - } - } +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell_Impl::DeactivatePanelByResource( const ::rtl::OUString& i_rPanelResourceURL ) +{ + // determine position of the requested panel + ::boost::optional< size_t > aPanelPos = GetTaskPane().GetPanelPos( i_rPanelResourceURL ); + OSL_ENSURE( !!aPanelPos, "ToolPanelViewShell_Impl::DeactivatePanelByResource: illegal panel resource, or illegal panel deck setup!" ); + if ( !!aPanelPos ) + { + if ( GetToolPanelDeck().GetActivePanel() == *aPanelPos ) + GetToolPanelDeck().ActivatePanel( ::boost::optional< size_t >() ); } } @@ -709,7 +483,7 @@ ToolPanelViewShell::ToolPanelViewShell( SfxViewFrame* pFrame, ViewShellBase& rVi GetParentWindow()->SetHelpId(HID_SD_TASK_PANE); - ConnectToDockingWindow(); + mpImpl->ConnectToDockingWindow(); SetPool( &GetDoc()->GetPool() ); @@ -775,7 +549,7 @@ void ToolPanelViewShell::ArrangeGUIElements() Initialize(); - mpImpl->GetPanelDeck().SetPosSizePixel( Point(), maViewSize ); + mpImpl->GetTaskPane().SetPosSizePixel( Point(), maViewSize ); } // --------------------------------------------------------------------------------------------------------------------- @@ -796,165 +570,14 @@ void ToolPanelViewShell::KeyInput( const KeyEvent& i_rKeyEvent ) const KeyCode nCode = i_rKeyEvent.GetKeyCode(); if ( nCode == KEY_RETURN ) { - if ( !mpImpl->GetPanelDeck().HasChildPathFocus() ) - mpImpl->GetPanelDeck().GrabFocus(); + if ( !mpImpl->GetTaskPane().HasChildPathFocus() ) + mpImpl->GetTaskPane().GrabFocus(); } else ViewShell::KeyInput( i_rKeyEvent, NULL ); } // --------------------------------------------------------------------------------------------------------------------- -namespace -{ - PanelSelectorLayout lcl_getTabLayoutFromAlignment( const SfxChildAlignment i_eAlignment ) - { - switch ( i_eAlignment ) - { - case SFX_ALIGN_LEFT: - return LAYOUT_TABS_LEFT; - case SFX_ALIGN_TOP: - return LAYOUT_TABS_TOP; - case SFX_ALIGN_BOTTOM: - return LAYOUT_TABS_BOTTOM; - default: - return LAYOUT_TABS_RIGHT; - } - } -} - -// --------------------------------------------------------------------------------------------------------------------- -IMPL_LINK( ToolPanelViewShell, DockingChanged, PaneDockingWindow*, i_pDockingWindow ) -{ - ENSURE_OR_RETURN( i_pDockingWindow == dynamic_cast< PaneDockingWindow* >( GetDockingWindow() ), "unknown source", 0 ); - - if ( mpImpl->GetLayout() == LAYOUT_DRAWERS ) - return 0L; - - mpImpl->SetLayout( lcl_getTabLayoutFromAlignment( i_pDockingWindow->GetAlignment() ) ); - return 0L; -} - -// --------------------------------------------------------------------------------------------------------------------- -IMPL_LINK(ToolPanelViewShell, ToolboxClickHandler, ToolBox*, pToolBox) -{ - if (pToolBox->GetCurItemId() == mnMenuId) - { - pToolBox->EndSelection(); - - DockingWindow* pDockingWindow = GetDockingWindow(); - ::std::auto_ptr<PopupMenu> pMenu = CreatePopupMenu ( - pDockingWindow!=NULL && !pDockingWindow->IsFloatingMode()); - pMenu->SetSelectHdl ( - LINK(this, ToolPanelViewShell, MenuSelectHandler)); - - // pass toolbox button rect so the menu can stay open on button up - Rectangle aRect = pToolBox->GetItemRect(mnMenuId); - aRect.SetPos(pToolBox->GetPosPixel() ); - pMenu->Execute (pDockingWindow, aRect, POPUPMENU_EXECUTE_DOWN); - } - - return 0; -} - -// --------------------------------------------------------------------------------------------------------------------- -IMPL_LINK(ToolPanelViewShell, MenuSelectHandler, Menu*, pMenu) -{ - if (pMenu) - { - pMenu->Deactivate(); - switch (pMenu->GetCurItemId()) - { - case MID_UNLOCK_TASK_PANEL: - { - DockingWindow* pDockingWindow = GetDockingWindow(); - if (pDockingWindow != NULL) - pDockingWindow->SetFloatingMode (TRUE); - } - break; - - case MID_LOCK_TASK_PANEL: - { - DockingWindow* pDockingWindow = GetDockingWindow(); - if (pDockingWindow != NULL) - pDockingWindow->SetFloatingMode (FALSE); - } - break; - - case MID_LAYOUT_DRAWERS: - mpImpl->SetLayout( LAYOUT_DRAWERS ); - break; - - case MID_LAYOUT_TABS: - { - PaneDockingWindow* pDockingWindow = dynamic_cast< PaneDockingWindow* >( GetDockingWindow() ); - OSL_ENSURE( pDockingWindow != NULL, "ToolPanelViewShell::MenuSelectHandler: unknown docking window type!" ); - if ( pDockingWindow ) - mpImpl->SetLayout( lcl_getTabLayoutFromAlignment( pDockingWindow->GetAlignment() ) ); - } - break; - - default: - { - size_t nPanelIndex = size_t( pMenu->GetCurItemId() - MID_FIRST_PANEL ); - mpImpl->TogglePanelVisibility( nPanelIndex ); - } - break; - } - } - - return 0; -} - -// --------------------------------------------------------------------------------------------------------------------- -::std::auto_ptr<PopupMenu> ToolPanelViewShell::CreatePopupMenu ( - bool bIsDocking) -{ - ::std::auto_ptr<PopupMenu> pMenu (new PopupMenu ()); - FloatingWindow* pFloat = static_cast<FloatingWindow*>(pMenu->GetWindow()); - if (pFloat != NULL) - { - pFloat->SetPopupModeFlags ( - pFloat->GetPopupModeFlags() - | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE); - } - - // Add one entry for every tool panel element to individually make - // them visible or hide them. - USHORT nIndex = MID_FIRST_PANEL; - for ( size_t i=0; i<mpImpl->GetPanelCount(); ++i, ++nIndex ) - { - const PanelDescriptor& rPanelDesc( mpImpl->GetPanel(i) ); - pMenu->InsertItem( nIndex, rPanelDesc.pPanel->GetDisplayName(), MIB_CHECKABLE ); - pMenu->SetUserValue( nIndex, rPanelDesc.nId ); - pMenu->CheckItem( nIndex, !rPanelDesc.bHidden ); - } - pMenu->InsertSeparator(); - -#if OSL_DEBUG_LEVEL > 0 - pMenu->InsertItem( MID_LAYOUT_TABS, String::CreateFromAscii( "Tab-Layout (exp.)" ), MIB_CHECKABLE ); - pMenu->CheckItem( MID_LAYOUT_TABS, mpImpl->GetLayout() != LAYOUT_DRAWERS ); - pMenu->InsertItem( MID_LAYOUT_DRAWERS, String::CreateFromAscii( "Drawer-Layout" ), MIB_CHECKABLE ); - pMenu->CheckItem( MID_LAYOUT_DRAWERS, mpImpl->GetLayout() == LAYOUT_DRAWERS ); - - pMenu->InsertSeparator(); -#endif - - // Add entry for docking or un-docking the tool panel. - if (bIsDocking) - pMenu->InsertItem ( - MID_UNLOCK_TASK_PANEL, - String(SdResId(STR_TASKPANEL_MASTER_PAGE_MENU_UNLOCK))); - else - pMenu->InsertItem ( - MID_LOCK_TASK_PANEL, - String(SdResId(STR_TASKPANEL_MASTER_PAGE_MENU_LOCK))); - - pMenu->RemoveDisabledEntries (FALSE, FALSE); - - return pMenu; -} - -// --------------------------------------------------------------------------------------------------------------------- SdPage* ToolPanelViewShell::GetActualPage() { return NULL; @@ -1013,32 +636,11 @@ Reference< XDrawSubController > ToolPanelViewShell::CreateSubController() } // --------------------------------------------------------------------------------------------------------------------- -void ToolPanelViewShell::ConnectToDockingWindow() -{ - PaneDockingWindow* pDockingWindow = dynamic_cast<PaneDockingWindow*>(GetDockingWindow()); - if (pDockingWindow != NULL) - { - pDockingWindow->ResetToolBox(); - mnMenuId = pDockingWindow->AddDropDownToolBoxItem ( - String(SdResId(STR_TASKPANEL_MASTER_PAGE_MENU_TITLE)), - HID_SD_TASK_PANE_VIEW_MENU, - LINK(this, ToolPanelViewShell, ToolboxClickHandler)); - - // be notified when the docking position of the window changes - pDockingWindow->SetEndDockingHdl( LINK( this, ToolPanelViewShell, DockingChanged ) ); - } - - // Tell the focus manager that we want to pass the focus to our - // child. - FocusManager::Instance().RegisterDownLink( GetParentWindow(), &mpImpl->GetPanelDeck() ); -} - -// --------------------------------------------------------------------------------------------------------------------- bool ToolPanelViewShell::RelocateToParentWindow( ::Window* pParentWindow ) { ::Window* pOldParentWindow = GetParentWindow(); - FocusManager::Instance().RemoveLinks( pOldParentWindow, &mpImpl->GetPanelDeck() ); - FocusManager::Instance().RemoveLinks( &mpImpl->GetPanelDeck(), pOldParentWindow ); + FocusManager::Instance().RemoveLinks( pOldParentWindow, &mpImpl->GetTaskPane() ); + FocusManager::Instance().RemoveLinks( &mpImpl->GetTaskPane(), pOldParentWindow ); PaneDockingWindow* pDockingWindow = dynamic_cast< PaneDockingWindow* >( GetDockingWindow() ); if ( pDockingWindow != NULL ) @@ -1048,124 +650,110 @@ bool ToolPanelViewShell::RelocateToParentWindow( ::Window* pParentWindow ) ViewShell::RelocateToParentWindow(pParentWindow); - ConnectToDockingWindow(); + mpImpl->ConnectToDockingWindow(); Resize(); return true; } -// --------------------------------------------------------------------------------------------------------------------- -::Window* ToolPanelViewShell::GetToolPanelParentWindow() -{ - return mpImpl->GetToolPanelParentWindow(); -} - //--------------------------------------------------------------------------------------------------------------------- -void ToolPanelViewShell::DeactivatePanel( const PanelId i_ePanelId ) +bool ToolPanelViewShell::IsPanelAnchorWindow( const ::Window& i_rWindow ) const { - mpImpl->DeactivatePanelDirectly( i_ePanelId ); + return &mpImpl->GetToolPanelDeck().GetPanelWindowAnchor() == &i_rWindow; } -// --------------------------------------------------------------------------------------------------------------------- -void ToolPanelViewShell::ActivatePanel( const PanelId i_ePanelId ) +//--------------------------------------------------------------------------------------------------------------------- +namespace { - mpImpl->ActivatePanelDirectly( i_ePanelId ); -} + typedef std::auto_ptr< ControlFactory > (*ControlFactoryFactory)( ToolPanelViewShell& i_rToolPanelShell ); + struct PanelFactory + { + ControlFactoryFactory pFactory; + ULONG nHelpID; + PanelFactory( const ControlFactoryFactory i_pFactory, const ULONG i_nHelpID ) + :pFactory( i_pFactory ) + ,nHelpID( i_nHelpID ) + { + } + }; -// ===================================================================================================================== -// = ToolPanelViewShell_Impl - implementation -// ===================================================================================================================== -// --------------------------------------------------------------------------------------------------------------------- -ToolPanelViewShell_Impl::ToolPanelViewShell_Impl( ToolPanelViewShell& i_rPanelViewShell, ::Window& i_rPanelDeckParent ) - :m_aPanels() - ,m_rPanelViewShell( i_rPanelViewShell ) - ,m_pPanelDeck( new ToolPanelDeck( i_rPanelDeckParent, i_rPanelViewShell ) ) - ,m_eCurrentLayout( LAYOUT_DRAWERS ) - ,m_bInitialized( false ) -{ + const PanelFactory lcl_describePanel( const PanelId i_ePanelId ) + { + switch ( i_ePanelId ) + { + case PID_MASTER_PAGES: + return PanelFactory( &controls::MasterPagesPanel::CreateControlFactory, HID_SD_SLIDE_DESIGNS ); + case PID_LAYOUT: + return PanelFactory( &LayoutMenu::CreateControlFactory, HID_SD_SLIDE_LAYOUTS ); + case PID_TABLE_DESIGN: + return PanelFactory( &controls::TableDesignPanel::CreateControlFactory, HID_SD_TABLE_DESIGN ); + case PID_CUSTOM_ANIMATION: + return PanelFactory( &controls::CustomAnimationPanel::CreateControlFactory, HID_SD_CUSTOM_ANIMATIONS ); + case PID_SLIDE_TRANSITION: + return PanelFactory( &controls::SlideTransitionPanel::CreateControlFactory, HID_SD_SLIDE_TRANSITIONS ); + default: + break; + } + throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "illegal panel ID" ) ), NULL ); + } } -// --------------------------------------------------------------------------------------------------------------------- -ToolPanelViewShell_Impl::~ToolPanelViewShell_Impl() +//--------------------------------------------------------------------------------------------------------------------- +Reference< XUIElement > ToolPanelViewShell::CreatePanelUIElement( const Reference< XFrame >& i_rDocFrame, const ::rtl::OUString& i_rPanelResourceURL ) { -} + const PanelId ePanelId( GetStandardPanelId( i_rPanelResourceURL ) ); + ENSURE_OR_RETURN( ePanelId != PID_UNKNOWN, "ToolPanelViewShell::CreatePanelUIElement: illegal panel URL!", NULL ); -// --------------------------------------------------------------------------------------------------------------------- -void ToolPanelViewShell_Impl::TogglePanelVisibility( const size_t i_nLogicalPanelIndex ) -{ - ENSURE_OR_RETURN_VOID( i_nLogicalPanelIndex < m_aPanels.size(), "illegal index" ); + // a TreeNode which will resemble the panel + const PanelFactory aPanelFactory( lcl_describePanel( ePanelId ) ); + ::std::auto_ptr< ControlFactory > pControlFactory( (*aPanelFactory.pFactory)( *this ) ); + ::std::auto_ptr< TreeNode > pNode( pControlFactory->CreateControl( mpImpl->GetToolPanelDeck().GetPanelWindowAnchor() ) ); + ENSURE_OR_THROW( ( pNode.get() != NULL ) && ( pNode->GetWindow() != NULL ), + "illegal node returned by the control factory" ); + pNode->GetWindow()->SetHelpId( aPanelFactory.nHelpID ); - // get the actual panel index, within the deck - size_t nActualPanelIndex(0); - for ( size_t i=0; i < i_nLogicalPanelIndex; ++i ) - { - if ( !m_aPanels[i].bHidden ) - ++nActualPanelIndex; - } - if ( m_aPanels[ i_nLogicalPanelIndex ].bHidden ) - { - OSL_VERIFY( m_pPanelDeck->InsertPanel( m_aPanels[ i_nLogicalPanelIndex ].pPanel, nActualPanelIndex ) == nActualPanelIndex ); - // if there has not been an active panel before, activate the newly inserted one - ::boost::optional< size_t > aActivePanel( m_pPanelDeck->GetActivePanel() ); - if ( !aActivePanel ) - m_pPanelDeck->ActivatePanelResource( nActualPanelIndex ); - } - else - { - OSL_VERIFY( m_pPanelDeck->RemovePanel( nActualPanelIndex ).get() == m_aPanels[ i_nLogicalPanelIndex ].pPanel.get() ); - } - m_aPanels[ i_nLogicalPanelIndex ].bHidden = !m_aPanels[ i_nLogicalPanelIndex ].bHidden; + // create an XToolPanel + Reference< XToolPanel > xPanel( new ToolPanel( pNode ) ); + + // create an XUIElement providing this panel + const Reference< XUIElement > xUIElement( new ToolPanelUIElement( i_rDocFrame, i_rPanelResourceURL, xPanel ) ); + + return xUIElement; } // --------------------------------------------------------------------------------------------------------------------- -void ToolPanelViewShell_Impl::DeactivatePanelDirectly( const PanelId i_nPanelId ) +void ToolPanelViewShell::DeactivatePanel( const ::rtl::OUString& i_rPanelResourceURL ) { - for ( size_t i=0; i<m_aPanels.size(); ++i ) - { - if ( m_aPanels[i].nId == i_nPanelId ) - { - if ( m_pPanelDeck->GetActivePanel() == i ) - m_pPanelDeck->ActivatePanelDirectly( ::boost::optional< size_t >() ); - return; - } - } + mpImpl->DeactivatePanelByResource( i_rPanelResourceURL ); } +// ===================================================================================================================== +// = ToolPanelViewShell_Impl - implementation +// ===================================================================================================================== // --------------------------------------------------------------------------------------------------------------------- -void ToolPanelViewShell_Impl::ActivatePanelDirectly( const PanelId i_nPanelId ) +ToolPanelViewShell_Impl::ToolPanelViewShell_Impl( ToolPanelViewShell& i_rPanelViewShell, ::Window& i_rPanelDeckParent ) + :m_rPanelViewShell( i_rPanelViewShell ) + ,m_pTaskPane( new ::sfx2::ModuleTaskPane( i_rPanelDeckParent, i_rPanelViewShell.GetViewShellBase().GetViewFrame()->GetFrame()->GetFrameInterface() ) ) + ,m_bInitialized( false ) { - size_t nActualPanelIndex(0); - for ( size_t i=0; i<m_aPanels.size(); ++i ) - { - if ( m_aPanels[i].nId == i_nPanelId ) - { - if ( m_aPanels[i].bHidden ) - TogglePanelVisibility( i ); - m_pPanelDeck->ActivatePanelDirectly( nActualPanelIndex ); - return; - } - if ( !m_aPanels[i].bHidden ) - ++nActualPanelIndex; - } - OSL_ENSURE( false, "ToolPanelViewShell::ActivatePanelDirectly: don't have a panel with the given ID!" ); + const String sPaneTitle( SdResId( STR_RIGHT_PANE_TITLE ) ); + GetToolPanelDeck().SetAccessibleName( sPaneTitle ); + GetToolPanelDeck().SetAccessibleDescription( sPaneTitle ); + + GetToolPanelDeck().AddListener( *this ); } // --------------------------------------------------------------------------------------------------------------------- -void ToolPanelViewShell_Impl::RegisterPanel( size_t i_nPosition, PanelId i_nPanelId, const ::svt::PToolPanel& i_rPanel ) +ToolPanelViewShell_Impl::~ToolPanelViewShell_Impl() { - if ( i_nPosition >= m_aPanels.size() ) - m_aPanels.resize( i_nPosition + 1 ); - - OSL_PRECOND( m_aPanels[ i_nPosition ].nId == PID_UNKNOWN, "ToolPanelViewShell_Impl::RegisterPanel: " - "already registered a panel for this ID!" ); - m_aPanels[ i_nPosition ] = PanelDescriptor( i_nPanelId, i_rPanel ); } // --------------------------------------------------------------------------------------------------------------------- void ToolPanelViewShell_Impl::PanelInserted( const ::svt::PToolPanel& i_pPanel, const size_t i_nPosition ) { + // not interested in (void)i_pPanel; (void)i_nPosition; } @@ -1173,46 +761,60 @@ void ToolPanelViewShell_Impl::PanelInserted( const ::svt::PToolPanel& i_pPanel, // --------------------------------------------------------------------------------------------------------------------- void ToolPanelViewShell_Impl::PanelRemoved( const size_t i_nPosition ) { + // not interested in (void)i_nPosition; } // --------------------------------------------------------------------------------------------------------------------- -void ToolPanelViewShell_Impl::UpdateDockingWindowTitle() +::rtl::OUString ToolPanelViewShell_Impl::impl_getPanelURL( const ::boost::optional< size_t >& i_rPanel ) { - PaneDockingWindow* pDockingWindow = dynamic_cast< PaneDockingWindow* >( m_rPanelViewShell.GetDockingWindow() ); - ENSURE_OR_RETURN_VOID( pDockingWindow, "ToolPanelViewShell_Impl::UpdateDockingWindowTitle: no PaneDockingWindow!?" ); - - ::boost::optional< size_t > aActivePanel( m_pPanelDeck->GetActivePanel() ); - if ( !aActivePanel || ( GetLayout() == LAYOUT_DRAWERS ) ) - pDockingWindow->SetTitle( String( SdResId( STR_RIGHT_PANE_TITLE ) ) ); - else + ::rtl::OUString sPanelURL; + if ( !!i_rPanel ) { - size_t nNewActive( *aActivePanel ); - for ( size_t i=0; i < m_aPanels.size(); ++i ) - { - if ( m_aPanels[i].bHidden ) - continue; - - if ( !nNewActive ) - { - pDockingWindow->SetTitle( m_aPanels[i].pPanel->GetDisplayName() ); - break; - } - --nNewActive; - } + sPanelURL = GetTaskPane().GetPanelResourceURL( *i_rPanel ); + const PanelId ePanelId( GetStandardPanelId( sPanelURL, true ) ); + if ( ePanelId == PID_UNKNOWN ) + sPanelURL = ::rtl::OUString(); } + return sPanelURL; } // --------------------------------------------------------------------------------------------------------------------- void ToolPanelViewShell_Impl::ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ) { - if ( GetLayout() == LAYOUT_DRAWERS ) - // no adjustment of the title when we use the classical "drawers" layout - return; + // update the configuration controller, since this change in the active panel might have been triggered by means other + // than the drawing framework, so it does not yet know about it. + + const ::rtl::OUString sOldPanelURL( impl_getPanelURL( i_rOldActive ) ); + const ::rtl::OUString sNewPanelURL( impl_getPanelURL( i_rNewActive ) ); - UpdateDockingWindowTitle( ); - (void)i_rOldActive; - (void)i_rNewActive; + const ::boost::shared_ptr< FrameworkHelper > pFrameworkHelper( FrameworkHelper::Instance( GetAntiImpl().GetViewShellBase() ) ); + if ( sNewPanelURL.getLength() ) + { + // activate the resource belonging to the new panel. This will automatically de-activate the previously active + // panel resource (since ResourceActivationMode_REPLACE is used) + pFrameworkHelper->RequestTaskPanel( sNewPanelURL ); + } + else if ( sOldPanelURL.getLength() ) + { + // there is no new active panel, or it is not one of our standard panels, i.e. it is not covered by the + // resource framework. => Deactivate the old resource. + try + { + Reference< XConfigurationController > xConfigController( pFrameworkHelper->GetConfigurationController(), UNO_QUERY_THROW ); + xConfigController->requestResourceDeactivation( + pFrameworkHelper->CreateResourceId( + sOldPanelURL, + FrameworkHelper::msTaskPaneURL, + FrameworkHelper::msRightPaneURL + ) + ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } } // --------------------------------------------------------------------------------------------------------------------- @@ -1225,47 +827,47 @@ void ToolPanelViewShell_Impl::LayouterChanged( const ::svt::PDeckLayouter& i_rNe // --------------------------------------------------------------------------------------------------------------------- void ToolPanelViewShell_Impl::Dying() { + // not interested in } // --------------------------------------------------------------------------------------------------------------------- -Reference< XAccessible > ToolPanelViewShell_Impl::CreateAccessible( ::sd::Window& i_rWindow ) +void ToolPanelViewShell_Impl::ConnectToDockingWindow() { - ::Window* pAccessibleParent = i_rWindow.GetAccessibleParentWindow(); - m_pPanelDeck->SetAccessibleParentWindow( pAccessibleParent ); - return m_pPanelDeck->GetAccessible(); + m_pTaskPaneController.reset(); + DockingWindow* pDockingWindow( GetAntiImpl().GetDockingWindow() ); + if ( pDockingWindow ) + { + PaneDockingWindow* pPaneDockingWindow = dynamic_cast< PaneDockingWindow* >( pDockingWindow ); + OSL_ENSURE( pPaneDockingWindow, "ToolPanelViewShell_Impl::ConnectToDockingWindow: unsupported docking window type!" ); + if ( pPaneDockingWindow != NULL ) + m_pTaskPaneController.reset( new ::sfx2::TaskPaneController( GetTaskPane(), *pPaneDockingWindow ) ); + } + + // Tell the focus manager that we want to pass the focus to our + // child. + FocusManager::Instance().RegisterDownLink( GetAntiImpl().GetParentWindow(), &GetTaskPane() ); } // --------------------------------------------------------------------------------------------------------------------- -PanelId GetStandardPanelId( const ::rtl::OUString& i_rTaskPanelResourceURL ) +Reference< XAccessible > ToolPanelViewShell_Impl::CreateAccessible( ::sd::Window& i_rWindow ) { - PanelId ePanelId( PID_UNKNOWN ); + Reference< XAccessible > xAccessibleParent; + ::Window* pAccessibleParent = i_rWindow.GetAccessibleParentWindow(); + if ( pAccessibleParent ) + xAccessibleParent.set( pAccessibleParent->GetAccessible() ); - if ( i_rTaskPanelResourceURL.equals( FrameworkHelper::msMasterPagesTaskPanelURL ) ) - { - ePanelId = PID_MASTER_PAGES; - } - else if ( i_rTaskPanelResourceURL.equals( FrameworkHelper::msLayoutTaskPanelURL ) ) - { - ePanelId = PID_LAYOUT; - } - else if ( i_rTaskPanelResourceURL.equals( FrameworkHelper::msTableDesignPanelURL ) ) - { - ePanelId = PID_TABLE_DESIGN; - } - else if ( i_rTaskPanelResourceURL.equals( FrameworkHelper::msCustomAnimationTaskPanelURL ) ) + Reference< XAccessible > xAccessible( GetToolPanelDeck().GetAccessible( FALSE ) ); + if ( !xAccessible.is() ) { - ePanelId = PID_CUSTOM_ANIMATION; - } - else if ( i_rTaskPanelResourceURL.equals( FrameworkHelper::msSlideTransitionTaskPanelURL ) ) - { - ePanelId = PID_SLIDE_TRANSITION; - } - else - { - OSL_ENSURE( false, "GetStandardPanelId: cannot translate the given resource URL!" ); + xAccessible = GetToolPanelDeck().GetAccessible( TRUE ); + ENSURE_OR_RETURN( xAccessible.is(), "ToolPanelViewShell_Impl::CreateAccessible: illegal ToolPanelDeck accessible!", NULL ); + if ( xAccessibleParent.is() ) + { + ::comphelper::OAccessibleImplementationAccess::setAccessibleParent( + xAccessible->getAccessibleContext(), xAccessibleParent ); + } } - - return ePanelId; + return xAccessible; } } } // end of namespace ::sd::toolpanel diff --git a/sd/source/ui/toolpanel/makefile.mk b/sd/source/ui/toolpanel/makefile.mk index ffa272167d53..4d83b8a85a70 100644 --- a/sd/source/ui/toolpanel/makefile.mk +++ b/sd/source/ui/toolpanel/makefile.mk @@ -54,11 +54,10 @@ SLOFILES = \ $(SLO)$/TaskPaneFocusManager.obj \ $(SLO)$/TaskPaneShellManager.obj \ $(SLO)$/TaskPaneTreeNode.obj \ + $(SLO)$/ToolPanel.obj \ $(SLO)$/ToolPanelViewShell.obj \ - $(SLO)$/ToolPanelDeck.obj \ - $(SLO)$/TaskPaneToolPanel.obj \ - $(SLO)$/CustomToolPanel.obj \ - $(SLO)$/StandardToolPanel.obj \ + $(SLO)$/ToolPanelFactory.obj \ + $(SLO)$/ToolPanelUIElement.obj \ \ $(SLO)$/EmptyWindow.obj \ $(SLO)$/LayoutMenu.obj \ diff --git a/sd/source/ui/unoidl/facreg.cxx b/sd/source/ui/unoidl/facreg.cxx index b8dcba6beecd..34c38ce1c11b 100644 --- a/sd/source/ui/unoidl/facreg.cxx +++ b/sd/source/ui/unoidl/facreg.cxx @@ -142,6 +142,17 @@ extern uno::Sequence<OUString> SAL_CALL PresentationFactoryProvider_getSupported } } +namespace sd { namespace toolpanel { + +extern uno::Reference<uno::XInterface> SAL_CALL ToolPanelFactory_createInstance( + const uno::Reference<uno::XComponentContext>& rxContext) + throw(uno::Exception); +extern OUString ToolPanelFactory_getImplementationName(void) throw (uno::RuntimeException); +extern uno::Sequence<OUString> SAL_CALL ToolPanelFactory_getSupportedServiceNames (void) + throw (uno::RuntimeException); + +} } + namespace sd { namespace presenter { extern uno::Reference<uno::XInterface> SAL_CALL SlideRenderer_createInstance( const uno::Reference<uno::XComponentContext>& rxContext) @@ -199,6 +210,7 @@ using namespace ::sd; using namespace ::sd::framework; using namespace ::sd::presenter; using namespace ::sd::slidesorter; +using namespace ::sd::toolpanel; @@ -222,6 +234,7 @@ enum FactoryId BasicToolBarFactoryFactoryId, BasicViewFactoryFactoryId, TaskPanelFactoryFactoryId, + ToolPanelFactoryFactoryId, ResourceIdFactoryId, PresentationFactoryProviderFactoryId, SlideRendererFactoryId, @@ -253,6 +266,7 @@ static ::boost::shared_ptr<FactoryMap> spFactoryMap; (*spFactoryMap)[BasicToolBarFactory_getImplementationName()] = BasicToolBarFactoryFactoryId; (*spFactoryMap)[BasicViewFactory_getImplementationName()] = BasicViewFactoryFactoryId; (*spFactoryMap)[TaskPanelFactory_getImplementationName()] = TaskPanelFactoryFactoryId; + (*spFactoryMap)[ToolPanelFactory_getImplementationName()] = ToolPanelFactoryFactoryId; (*spFactoryMap)[ResourceId_getImplementationName()] = ResourceIdFactoryId; (*spFactoryMap)[PresentationFactoryProvider_getImplementationName()] = PresentationFactoryProviderFactoryId; (*spFactoryMap)[SlideRenderer_getImplementationName()] = SlideRendererFactoryId; @@ -335,6 +349,10 @@ SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( sd::framework::TaskPanelFactory_getSupportedServiceNames()); writeInfo( pKey, + sd::toolpanel::ToolPanelFactory_getImplementationName(), + sd::toolpanel::ToolPanelFactory_getSupportedServiceNames()); + writeInfo( + pKey, sd::framework::ResourceId_getImplementationName(), sd::framework::ResourceId_getSupportedServiceNames()); writeInfo( @@ -484,6 +502,13 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( sd::framework::TaskPanelFactory_getSupportedServiceNames()); break; + case ToolPanelFactoryFactoryId: + xComponentFactory = ::cppu::createSingleComponentFactory( + sd::toolpanel::ToolPanelFactory_createInstance, + sd::toolpanel::ToolPanelFactory_getImplementationName(), + sd::toolpanel::ToolPanelFactory_getSupportedServiceNames()); + break; + case ResourceIdFactoryId: xComponentFactory = ::cppu::createSingleComponentFactory( sd::framework::ResourceId_createInstance, diff --git a/sd/workben/custompanel/Impress.xcu b/sd/workben/custompanel/Impress.xcu deleted file mode 100644 index 6f8ced4924f3..000000000000 --- a/sd/workben/custompanel/Impress.xcu +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!DOCTYPE oor:component-data SYSTEM "../../../../component-update.dtd"> -<oor:component-data oor:name="Impress" oor:package="org.openoffice.Office" xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <node oor:name="MultiPaneGUI"> - <node oor:name="ToolPanel"> - <node oor:name="CustomPanels"> - <node oor:name="org.openoffice.example.colorpanel.SingleColorPanel" oor:op="replace"> - <prop oor:name="ResourceURL" oor:type="xs:string"> - <value>private:resource/toolpanel/SingleColorView</value> - </prop> - <prop oor:name="DisplayTitle" oor:type="xs:string"> - <value>Single Color Panel</value> - </prop> - </node> - </node> - </node> - <node oor:name="Framework"> - <node oor:name="ResourceFactories"> - <node oor:name="org.openoffice.example.colorpanel.1" oor:op="replace"> - <prop oor:name="ServiceName"> - <value>org.openoffice.example.colorpanel.ResourceFactory</value> - </prop> - <node oor:name="ResourceList"> - <node oor:name="SingleColorView" oor:op="replace"> - <prop oor:name="URL"> - <value>private:resource/toolpanel/SingleColorView</value> - </prop> - </node> - </node> - </node> - </node> - </node> - </node> -</oor:component-data> diff --git a/sd/workben/custompanel/colorpanel.map b/sd/workben/custompanel/colorpanel.map deleted file mode 100644 index f4ed78b9e970..000000000000 --- a/sd/workben/custompanel/colorpanel.map +++ /dev/null @@ -1,8 +0,0 @@ -UDK_3_0_0 { - global: - component_getImplementationEnvironment; - component_writeInfo; - component_getFactory; - local: - *; -}; diff --git a/sd/workben/custompanel/ctp_factory.cxx b/sd/workben/custompanel/ctp_factory.cxx deleted file mode 100644 index f63e487fdc3e..000000000000 --- a/sd/workben/custompanel/ctp_factory.cxx +++ /dev/null @@ -1,195 +0,0 @@ -/************************************************************************* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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. - * -************************************************************************/ - -#include "precompiled_sd.hxx" - -#include "ctp_factory.hxx" -#include "ctp_panel.hxx" - -/** === begin UNO includes === **/ -#include <com/sun/star/lang/NotInitializedException.hpp> -#include <com/sun/star/lang/IllegalArgumentException.hpp> -#include <com/sun/star/drawing/framework/XResourceFactoryManager.hpp> -#include <com/sun/star/lang/XComponent.hpp> -/** === end UNO includes === **/ - -//...................................................................................................................... -namespace sd { namespace colortoolpanel -{ -//...................................................................................................................... - - /** === begin UNO using === **/ - using ::com::sun::star::uno::Reference; - using ::com::sun::star::uno::XInterface; - using ::com::sun::star::uno::UNO_QUERY; - using ::com::sun::star::uno::UNO_QUERY_THROW; - using ::com::sun::star::uno::UNO_SET_THROW; - using ::com::sun::star::uno::Exception; - using ::com::sun::star::uno::RuntimeException; - using ::com::sun::star::uno::Any; - using ::com::sun::star::uno::makeAny; - using ::com::sun::star::uno::Sequence; - using ::com::sun::star::uno::Type; - using ::com::sun::star::uno::XComponentContext; - using ::com::sun::star::drawing::framework::XResourceId; - using ::com::sun::star::drawing::framework::XResource; - using ::com::sun::star::lang::NotInitializedException; - using ::com::sun::star::lang::IllegalArgumentException; - using ::com::sun::star::drawing::framework::XResourceFactoryManager; - using ::com::sun::star::lang::WrappedTargetException; - using ::com::sun::star::lang::XComponent; - /** === end UNO using === **/ - - //================================================================================================================== - //= helper - //================================================================================================================== - namespace - { - const ::rtl::OUString& lcl_getSingleColorViewURL() - { - static ::rtl::OUString s_sSingleColorViewURL( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolpanel/SingleColorView" ) ); - return s_sSingleColorViewURL; - } - } - - //================================================================================================================== - //= ResourceFactory - //================================================================================================================== - //------------------------------------------------------------------------------------------------------------------ - ResourceFactory::ResourceFactory( const Reference< XComponentContext >& i_rContext ) - :m_xContext( i_rContext ) - { - } - - //------------------------------------------------------------------------------------------------------------------ - ResourceFactory::~ResourceFactory() - { - } - - //------------------------------------------------------------------------------------------------------------------ - Reference< XResource > SAL_CALL ResourceFactory::createResource( const Reference< XResourceId >& i_rResourceId ) throw (RuntimeException, IllegalArgumentException, WrappedTargetException) - { - FactoryGuard aGuard( *this ); - if ( !i_rResourceId.is() ) - throw IllegalArgumentException( ::rtl::OUString::createFromAscii( "illegal resource ID" ), *this, 1 ); - - const ::rtl::OUString sResourceURL( i_rResourceId->getResourceURL() ); - if ( sResourceURL != lcl_getSingleColorViewURL() ) - throw IllegalArgumentException( ::rtl::OUString::createFromAscii( "unsupported resource URL" ), *this, 1 ); - - return new SingleColorPanel( m_xContext, m_xControllerManager->getConfigurationController(), i_rResourceId ); - } - - //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL ResourceFactory::releaseResource( const Reference< XResource >& i_rResource ) throw (RuntimeException) - { - FactoryGuard aGuard( *this ); - - // here, we could decide to actually not destroy the resource, but cache it. In this case, we would need - // to re-parent the VCL window to another, temporary window, or *at least* hide it. - - // However, for the simplicity of this example, we will simply dispose the component here, which will destroy - // all associated resources, including the VCL window. - Reference< XComponent > xComponent( i_rResource, UNO_QUERY_THROW ); - xComponent->dispose(); - } - - //------------------------------------------------------------------------------------------------------------------ - ::rtl::OUString SAL_CALL ResourceFactory::getImplementationName( ) throw (RuntimeException) - { - return getImplementationName_static(); - } - - //------------------------------------------------------------------------------------------------------------------ - ::rtl::OUString SAL_CALL ResourceFactory::getImplementationName_static( ) throw (RuntimeException) - { - return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.example.colorpanel.ResourceFactory" ) ); - } - - //------------------------------------------------------------------------------------------------------------------ - ::sal_Bool SAL_CALL ResourceFactory::supportsService( const ::rtl::OUString& i_rServiceName ) throw (RuntimeException) - { - const Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() ); - for ( const ::rtl::OUString* serviceName = aServiceNames.getConstArray(); - serviceName != aServiceNames.getConstArray() + aServiceNames.getLength(); - ++serviceName - ) - { - if ( i_rServiceName == *serviceName ) - return sal_True; - } - return sal_False; - } - - //------------------------------------------------------------------------------------------------------------------ - Sequence< ::rtl::OUString > SAL_CALL ResourceFactory::getSupportedServiceNames() throw (RuntimeException) - { - return getSupportedServiceNames_static(); - } - - //------------------------------------------------------------------------------------------------------------------ - Sequence< ::rtl::OUString > SAL_CALL ResourceFactory::getSupportedServiceNames_static() throw (RuntimeException) - { - Sequence< ::rtl::OUString > aServiceNames(1); - aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.example.colorpanel.ResourceFactory" ) ); - return aServiceNames; - } - - //------------------------------------------------------------------------------------------------------------------ - Reference< XInterface > SAL_CALL ResourceFactory::Create( const Reference< XComponentContext >& i_rContext ) throw (RuntimeException) - { - return *( new ResourceFactory( i_rContext ) ); - } - - //------------------------------------------------------------------------------------------------------------------ - void ResourceFactory::checkInitialized( GuardAccess ) const - { - if ( !m_xControllerManager.is() ) - throw NotInitializedException( ::rtl::OUString(), *const_cast< ResourceFactory* >( this ) ); - } - - //------------------------------------------------------------------------------------------------------------------ - void ResourceFactory::checkDisposed( GuardAccess ) const - { - // cannot be disposed currently ... - } - - //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL ResourceFactory::initialize( const Sequence< Any >& i_rArguments ) throw (Exception, RuntimeException) - { - if ( !i_rArguments.getLength() ) - throw IllegalArgumentException(); - - FactoryGuard aGuard( *this, false ); - m_xControllerManager.set( i_rArguments[0], UNO_QUERY_THROW ); - - Reference< XResourceFactoryManager > xFactoryManager( m_xControllerManager->getConfigurationController(), UNO_QUERY_THROW ); - xFactoryManager->addResourceFactory( lcl_getSingleColorViewURL(), this ); - } - -//...................................................................................................................... -} } // namespace sd::colortoolpanel -//...................................................................................................................... diff --git a/sd/workben/custompanel/ctp_factory.hxx b/sd/workben/custompanel/ctp_factory.hxx deleted file mode 100644 index ab6cb3f6a9db..000000000000 --- a/sd/workben/custompanel/ctp_factory.hxx +++ /dev/null @@ -1,114 +0,0 @@ -/************************************************************************* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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 SD_WORKBENCH_CTP_FACTORY_HXX -#define SD_WORKBENCH_CTP_FACTORY_HXX - -/** === begin UNO includes === **/ -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/drawing/framework/XResourceFactory.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/drawing/framework/XControllerManager.hpp> -/** === end UNO includes === **/ - -#include <cppuhelper/implbase3.hxx> -#include <cppuhelper/basemutex.hxx> - -//...................................................................................................................... -namespace sd { namespace colortoolpanel -{ -//...................................................................................................................... - - class FactoryGuard; - - //================================================================================================================== - //= ResourceFactory - //================================================================================================================== - typedef ::cppu::WeakImplHelper3 < ::com::sun::star::drawing::framework::XResourceFactory - , ::com::sun::star::lang::XServiceInfo - , ::com::sun::star::lang::XInitialization - > ResourceFactory_Base; - class ResourceFactory :public ::cppu::BaseMutex - ,public ResourceFactory_Base - { - public: - ResourceFactory( - const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_rContext - ); - ~ResourceFactory(); - - // XResourceFactory - virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResource > SAL_CALL createResource( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResourceId >& xResourceId ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException); - virtual void SAL_CALL releaseResource( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResource >& xResource ) throw (::com::sun::star::uno::RuntimeException); - - // XServiceInfo - virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); - - // XServiceInfo - static versions - static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_rContext ) throw (::com::sun::star::uno::RuntimeException); - - // XInitialization - virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); - - public: - struct GuardAccess { friend class FactoryGuard; private: GuardAccess() { } }; - - void checkInitialized( GuardAccess ) const; - void checkDisposed( GuardAccess ) const; - ::osl::Mutex& getMutex( GuardAccess ) { return m_aMutex; } - - private: - const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > - m_xContext; - ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XControllerManager > - m_xControllerManager; - }; - - class FactoryGuard - { - public: - FactoryGuard( ResourceFactory& i_rFactory, const bool i_bNeedInit = true ) - :m_aGuard( i_rFactory.getMutex( ResourceFactory::GuardAccess() ) ) - { - i_rFactory.checkDisposed( ResourceFactory::GuardAccess() ); - if ( i_bNeedInit ) - i_rFactory.checkInitialized( ResourceFactory::GuardAccess() ); - } - - protected: - ::osl::MutexGuard m_aGuard; - }; - -//...................................................................................................................... -} } // namespace sd::colortoolpanel -//...................................................................................................................... - -#endif // SD_WORKBENCH_CTP_FACTORY_HXX diff --git a/sd/workben/custompanel/delzip b/sd/workben/custompanel/delzip deleted file mode 100644 index e69de29bb2d1..000000000000 --- a/sd/workben/custompanel/delzip +++ /dev/null diff --git a/sd/workben/custompanel/description.xml b/sd/workben/custompanel/description.xml deleted file mode 100644 index a1dbdf4f125d..000000000000 --- a/sd/workben/custompanel/description.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<description - xmlns="http://openoffice.org/extensions/description/2006" - xmlns:d="http://openoffice.org/extensions/description/2006" - xmlns:xlink="http://www.w3.org/1999/xlink"> - - <identifier value="UPDATED_IDENTIFIER"/> - <version value="0.1" /> - <platform value="UPDATED_SUPPORTED_PLATFORM" /> - <display-name> - <name lang="en-US">Custom Tool Panel Example</name> - </display-name> - <dependencies> - <OpenOffice.org-minimal-version value="3.2" d:name="OpenOffice.org 3.2"/> - </dependencies> -</description> diff --git a/sd/workben/custompanel/makefile.mk b/sd/workben/custompanel/makefile.mk deleted file mode 100644 index 6df3190892f8..000000000000 --- a/sd/workben/custompanel/makefile.mk +++ /dev/null @@ -1,93 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# 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. -# -#************************************************************************* - -PRJ=../.. -PRJNAME=sd - -TARGET=colorpanel -ENABLE_EXCEPTIONS=TRUE -LIBTARGET=NO -EXTENSIONNAME:=colored-tool-panel - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -#------------------------------------------------------------------- - -#---- extension version -EXTENSION_VERSION_BASE=0.1 -.IF ( "$(CWS_WORK_STAMP)" == "" ) || ( "$(UPDATER)" == "YES" ) - EXTENSION_VERSION=$(EXTENSION_VERSION_BASE) -.ELSE - EXTENSION_VERSION=$(EXTENSION_VERSION_BASE).cws.$(CWS_WORK_STAMP) -.ENDIF - -#---- extension title package name -EXTENSION_TITLE=Custom Tool Panel Example -EXTENSION_ZIPNAME=$(EXTENSIONNAME)-$(EXTENSION_VERSION_BASE)-$(RTL_OS:l)-$(RTL_ARCH:l) - -#-------------------------------------------------- - -SHL1DLLPRE= -SHL1TARGET=$(TARGET).uno -LIB1TARGET=$(SLB)/$(SHL1TARGET).lib -LIB1OBJFILES= \ - $(SLO)/ctp_factory.obj \ - $(SLO)/ctp_services.obj \ - $(SLO)/ctp_panel.obj - -SHL1STDLIBS= \ - $(CPPULIB) \ - $(SALLIB) \ - $(SALHELPERLIB) \ - $(CPPUHELPERLIB) - -SHL1VERSIONMAP=$(TARGET).map -SHL1LIBS= $(LIB1TARGET) -SHL1DEF= $(MISC)/$(SHL1TARGET).def -SHL1RPATH= OXT -DEF1NAME= $(SHL1TARGET) - -# create Extension ----------------------------- - -COMPONENT_CONFIGDEST=. - -COMPONENT_XCU = \ - $(EXTENSIONDIR)/Impress.xcu - -COMPONENT_LIBRARIES = \ - $(EXTENSIONDIR)$/$(SHL1TARGET)$(DLLPOST) - -# ........ dependencies for packaging the extension ........ -EXTENSION_PACKDEPS=makefile.mk - -# --- Targets ------------------------------------------------------ -.INCLUDE : extension_pre.mk -.INCLUDE : target.mk -.INCLUDE : extension_post.mk - diff --git a/sd/workben/custompanel/manifest.xml b/sd/workben/custompanel/manifest.xml deleted file mode 100644 index 96f62afe4e27..000000000000 --- a/sd/workben/custompanel/manifest.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE manifest:manifest PUBLIC "-//OpenOffice.org//DTD Manifest 1.0//EN" "Manifest.dtd"> -<manifest:manifest xmlns:manifest="http://openoffice.org/2001/manifest"> - <manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-component;type=native" - manifest:full-path="colorpanel.unoSHARED_EXTENSION"/> - <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data" - manifest:full-path="Impress.xcu"/> -</manifest:manifest> |