diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-03-16 13:36:35 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-03-16 13:36:35 +0100 |
commit | c2297610c51057e3a8f4716ffc0b9a570c4876e8 (patch) | |
tree | 38ae59942d09e7f1567df6a2fc6d34adb061134f /sd/source | |
parent | 263bcb1a8f686afe66f4fe53b76929423fc6ce43 (diff) |
slidecopy: de/activate panels via the drawing framework
Instead of simply letting svtool's ToolPanelDeck decide on panel activation, requests are re-routed through
the view's ConfigurationController. So, clicking onto a tab just requests the activation of the respective
resource, which in turn - when the requested configuration becomes the active configuration - will activate
the ToolPanel.
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/ui/framework/factories/TaskPanelFactory.cxx | 176 | ||||
-rw-r--r-- | sd/source/ui/inc/TaskPaneViewShell.hxx | 15 | ||||
-rw-r--r-- | sd/source/ui/inc/taskpane/PanelId.hxx | 56 | ||||
-rw-r--r-- | sd/source/ui/inc/taskpane/ToolPanelViewShell.hxx | 23 | ||||
-rw-r--r-- | sd/source/ui/toolpanel/TaskPaneToolPanel.cxx | 18 | ||||
-rw-r--r-- | sd/source/ui/toolpanel/TaskPaneToolPanel.hxx | 10 | ||||
-rw-r--r-- | sd/source/ui/toolpanel/TaskPaneViewShell.cxx | 8 | ||||
-rw-r--r-- | sd/source/ui/toolpanel/ToolPanelDeck.cxx | 68 | ||||
-rw-r--r-- | sd/source/ui/toolpanel/ToolPanelDeck.hxx | 26 | ||||
-rw-r--r-- | sd/source/ui/toolpanel/ToolPanelViewShell.cxx | 139 | ||||
-rw-r--r-- | sd/source/ui/view/ViewShellBase.cxx | 8 | ||||
-rw-r--r-- | sd/source/ui/view/ViewShellImplementation.cxx | 2 |
12 files changed, 434 insertions, 115 deletions
diff --git a/sd/source/ui/framework/factories/TaskPanelFactory.cxx b/sd/source/ui/framework/factories/TaskPanelFactory.cxx index 65a2bb23cb33..1500cda89870 100644 --- a/sd/source/ui/framework/factories/TaskPanelFactory.cxx +++ b/sd/source/ui/framework/factories/TaskPanelFactory.cxx @@ -32,9 +32,11 @@ #include "precompiled_sd.hxx" #include "TaskPanelFactory.hxx" #include "TaskPaneViewShell.hxx" +#include "taskpane/ToolPanelViewShell.hxx" #include "DrawController.hxx" #include "framework/FrameworkHelper.hxx" #include <cppuhelper/compbase1.hxx> +#include <tools/diagnose_ex.h> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -89,14 +91,11 @@ class TaskPanelResource { public: TaskPanelResource ( - const Reference<XResourceId>& rxResourceId, - const TaskPaneViewShell::PanelId ePaneId); + const Reference<XResourceId>& rxResourceId ); virtual ~TaskPanelResource (); virtual void SAL_CALL disposing (); - TaskPaneViewShell::PanelId GetPaneId () const; - // XResource virtual Reference<XResourceId> SAL_CALL getResourceId (void) @@ -107,7 +106,6 @@ public: private: const Reference<XResourceId> mxResourceId; - const TaskPaneViewShell::PanelId mePaneId; }; } // end of anonymous namespace. @@ -189,56 +187,102 @@ void SAL_CALL TaskPanelFactory::initialize( //===== XResourceController =================================================== -Reference<XResource> SAL_CALL TaskPanelFactory::createResource ( - const Reference<XResourceId>& rxResourceId) - throw (RuntimeException) +namespace { - Reference<XResource> xResource; - - if ( ! rxResourceId.is()) - return NULL; + void lcl_collectResourceURLs( const Reference< XResourceId >& i_rResourceId, ::std::vector< ::rtl::OUString >& o_rResourceURLs ) + { + ENSURE_OR_RETURN_VOID( i_rResourceId.is(), "illegal resource ID" ); + o_rResourceURLs.resize(0); - OUString sResourceURL (rxResourceId->getResourceURL()); + Reference< XResourceId > xResourceId( i_rResourceId ); + ::rtl::OUString sResourceURL = xResourceId->getResourceURL(); + while ( sResourceURL.getLength() > 0 ) + { + o_rResourceURLs.push_back( sResourceURL ); + xResourceId = xResourceId->getAnchor(); + sResourceURL = xResourceId->getResourceURL(); + } + } - if (sResourceURL.match(FrameworkHelper::msTaskPanelURLPrefix)) + toolpanel::PanelId lcl_getPanelId( const ::rtl::OUString& i_rResourceURL ) { - TaskPaneViewShell::PanelId ePaneId (TaskPaneViewShell::PID_UNKNOWN); + toolpanel::PanelId ePanelId( toolpanel::PID_UNKNOWN ); - if (sResourceURL.equals(FrameworkHelper::msMasterPagesTaskPanelURL)) + // TODO: this translation table PanelId<->PanelResourceURL is used in multiple files, + // perhaps it is worth putting this into a dedicated helper/meta-data class. + if ( i_rResourceURL.equals( FrameworkHelper::msMasterPagesTaskPanelURL ) ) { - ePaneId = TaskPaneViewShell::PID_MASTER_PAGES; + ePanelId = toolpanel::PID_MASTER_PAGES; } - else if (sResourceURL.equals(FrameworkHelper::msLayoutTaskPanelURL)) + else if ( i_rResourceURL.equals( FrameworkHelper::msLayoutTaskPanelURL ) ) { - ePaneId = TaskPaneViewShell::PID_LAYOUT; + ePanelId = toolpanel::PID_LAYOUT; } - else if (sResourceURL.equals(FrameworkHelper::msTableDesignPanelURL)) + else if ( i_rResourceURL.equals( FrameworkHelper::msTableDesignPanelURL ) ) { - ePaneId = TaskPaneViewShell::PID_TABLE_DESIGN; + ePanelId = toolpanel::PID_TABLE_DESIGN; } - else if (sResourceURL.equals(FrameworkHelper::msCustomAnimationTaskPanelURL)) + else if ( i_rResourceURL.equals( FrameworkHelper::msCustomAnimationTaskPanelURL ) ) { - ePaneId = TaskPaneViewShell::PID_CUSTOM_ANIMATION; + ePanelId = toolpanel::PID_CUSTOM_ANIMATION; } - else if (sResourceURL.equals(FrameworkHelper::msSlideTransitionTaskPanelURL)) + else if ( i_rResourceURL.equals( FrameworkHelper::msSlideTransitionTaskPanelURL ) ) { - ePaneId = TaskPaneViewShell::PID_SLIDE_TRANSITION; + ePanelId = toolpanel::PID_SLIDE_TRANSITION; } + else + { + OSL_ENSURE( false, "lcl_getPanelId: cannot translate the given resource URL!" ); + } + + return ePanelId; + } +} + +Reference<XResource> SAL_CALL TaskPanelFactory::createResource ( + const Reference<XResourceId>& rxResourceId) + throw (RuntimeException) +{ + Reference<XResource> xResource; + + if ( ! rxResourceId.is()) + return NULL; + + OUString sResourceURL (rxResourceId->getResourceURL()); - if (ePaneId!=TaskPaneViewShell::PID_UNKNOWN && mpViewShellBase!=NULL) + if ( sResourceURL.match( FrameworkHelper::msTaskPanelURLPrefix ) ) + { + toolpanel::PanelId ePanelId( lcl_getPanelId( sResourceURL ) ); + + if ( ( ePanelId != toolpanel::PID_UNKNOWN ) && ( mpViewShellBase != NULL ) ) { - toolpanel::TaskPaneViewShell* pTaskPane - = dynamic_cast<toolpanel::TaskPaneViewShell*>( - FrameworkHelper::Instance(*mpViewShellBase) - ->GetViewShell(FrameworkHelper::msRightPaneURL).get()); - if (pTaskPane != NULL) + ::boost::shared_ptr< FrameworkHelper > pFrameworkHelper( FrameworkHelper::Instance( *mpViewShellBase ) ); + + // assume that the top-level anchor is the URL of the pane + ::std::vector< ::rtl::OUString > aResourceURLs; + lcl_collectResourceURLs( rxResourceId, aResourceURLs ); + + const ::rtl::OUString sPaneURL = aResourceURLs[ aResourceURLs.size() - 1 ]; + const ::boost::shared_ptr< ViewShell > pPaneViewShell( pFrameworkHelper->GetViewShell( sPaneURL ) ); + + toolpanel::TaskPaneViewShell* pTaskPane = dynamic_cast< toolpanel::TaskPaneViewShell* >( pPaneViewShell.get() ); + if ( pTaskPane != NULL ) + { + xResource = new TaskPanelResource( rxResourceId ); + pTaskPane->ShowPanel(ePanelId); + pTaskPane->ExpandPanel(ePanelId); + } + else { - xResource = new TaskPanelResource( - rxResourceId, - ePaneId); - pTaskPane->ShowPanel(ePaneId); - pTaskPane->ExpandPanel(ePaneId); + toolpanel::ToolPanelViewShell* pToolPanel = dynamic_cast< toolpanel::ToolPanelViewShell* >( pPaneViewShell.get() ); + if ( pToolPanel != NULL ) + { + xResource = new TaskPanelResource( rxResourceId ); + pToolPanel->ActivatePanel( ePanelId ); + } } + + OSL_POSTCOND( xResource.is(), "TaskPanelFactory::createResource: did not find the given resource!" ); } } @@ -252,16 +296,46 @@ void SAL_CALL TaskPanelFactory::releaseResource ( const Reference<XResource>& rxResource) throw (RuntimeException) { - toolpanel::TaskPaneViewShell* pTaskPane - = dynamic_cast<toolpanel::TaskPaneViewShell*>( - FrameworkHelper::Instance(*mpViewShellBase) - ->GetViewShell(FrameworkHelper::msRightPaneURL).get()); + ENSURE_OR_RETURN_VOID( rxResource.is(), "illegal resource" ); + const Reference< XResourceId > xResourceId( rxResource->getResourceId(), UNO_SET_THROW ); - rtl::Reference<TaskPanelResource> pResource = dynamic_cast<TaskPanelResource*>( - rxResource.get()); + // assume that the top-level anchor is the URL of the pane + ::std::vector< ::rtl::OUString > aResourceURLs; + lcl_collectResourceURLs( xResourceId, aResourceURLs ); - if (pTaskPane != NULL && pResource.is()) - pTaskPane->CollapsePanel(pResource->GetPaneId()); + OSL_ENSURE( !aResourceURLs.empty(), "TaskPanelFactory::releaseResource: illegal resource/URL!" ); + if ( !aResourceURLs.empty() ) + { + const ::rtl::OUString sPaneURL = aResourceURLs[ aResourceURLs.size() - 1 ]; + ::boost::shared_ptr< FrameworkHelper > pFrameworkHelper( FrameworkHelper::Instance( *mpViewShellBase ) ); + const ::boost::shared_ptr< ViewShell > pPaneViewShell( pFrameworkHelper->GetViewShell( sPaneURL ) ); + if ( pPaneViewShell != NULL ) + { + toolpanel::PanelId ePanelId( lcl_getPanelId( xResourceId->getResourceURL() ) ); + toolpanel::TaskPaneViewShell* pTaskPane( dynamic_cast< toolpanel::TaskPaneViewShell* >( pPaneViewShell.get() ) ); + toolpanel::ToolPanelViewShell* pToolPanel = dynamic_cast< toolpanel::ToolPanelViewShell* >( pPaneViewShell.get() ); + + if ( ( ePanelId != toolpanel::PID_UNKNOWN ) + && ( ( pTaskPane != NULL ) + || ( pToolPanel != NULL ) + ) + ) + { + if ( pTaskPane != NULL ) + { + pTaskPane->CollapsePanel( ePanelId ); + } + if ( pToolPanel != NULL ) + { + pToolPanel->DeactivatePanel( ePanelId ); + } + } + else + { + OSL_ENSURE( false, "TaskPanelFactory::releaseResource: don't know what to do with this resource!" ); + } + } + } Reference<XComponent> xComponent (rxResource, UNO_QUERY); if (xComponent.is()) @@ -293,11 +367,9 @@ void TaskPanelFactory::ThrowIfDisposed (void) const namespace { TaskPanelResource::TaskPanelResource ( - const Reference<XResourceId>& rxResourceId, - const TaskPaneViewShell::PanelId ePaneId) + const Reference<XResourceId>& rxResourceId) : TaskPanelResourceInterfaceBase(m_aMutex), - mxResourceId(rxResourceId), - mePaneId(ePaneId) + mxResourceId(rxResourceId) { } @@ -318,14 +390,6 @@ void SAL_CALL TaskPanelResource::disposing () -TaskPaneViewShell::PanelId TaskPanelResource::GetPaneId () const -{ - return mePaneId; -} - - - - Reference<XResourceId> SAL_CALL TaskPanelResource::getResourceId () throw (css::uno::RuntimeException) { diff --git a/sd/source/ui/inc/TaskPaneViewShell.hxx b/sd/source/ui/inc/TaskPaneViewShell.hxx index a290291f7e7c..d116b23e2140 100644 --- a/sd/source/ui/inc/TaskPaneViewShell.hxx +++ b/sd/source/ui/inc/TaskPaneViewShell.hxx @@ -34,6 +34,7 @@ #include "ViewShell.hxx" #include "glob.hxx" #include "framework/FrameworkHelper.hxx" +#include "taskpane/PanelId.hxx" #include <vcl/button.hxx> #include <sfx2/shell.hxx> #include <sfx2/viewfac.hxx> @@ -68,20 +69,6 @@ public: TYPEINFO(); SFX_DECL_INTERFACE(SD_IF_SDTASKPANEVIEWSHELL) - /** List of top level panels that can be shown in the task pane. - */ - enum PanelId - { - PID__START = 0, - PID_UNKNOWN = PID__START, - PID_MASTER_PAGES, - PID_LAYOUT, - PID_TABLE_DESIGN, - PID_CUSTOM_ANIMATION, - PID_SLIDE_TRANSITION, - PID__END = PID_SLIDE_TRANSITION - }; - TaskPaneViewShell ( SfxViewFrame* pFrame, ViewShellBase& rViewShellBase, diff --git a/sd/source/ui/inc/taskpane/PanelId.hxx b/sd/source/ui/inc/taskpane/PanelId.hxx new file mode 100644 index 000000000000..dbd618118ecf --- /dev/null +++ b/sd/source/ui/inc/taskpane/PanelId.hxx @@ -0,0 +1,56 @@ +/************************************************************************* + * 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_UI_TASKPANE_PANELID_HXX +#define SD_UI_TASKPANE_PANELID_HXX + +//...................................................................................................................... +namespace sd { namespace toolpanel +{ +//...................................................................................................................... + + //================================================================================================================== + //= PanelId + //================================================================================================================== + /** List of top level panels that can be shown in the task pane. + */ + enum PanelId + { + PID__START = 0, + PID_UNKNOWN = PID__START, + PID_MASTER_PAGES, + PID_LAYOUT, + PID_TABLE_DESIGN, + PID_CUSTOM_ANIMATION, + PID_SLIDE_TRANSITION, + PID__END = PID_SLIDE_TRANSITION + }; + +//...................................................................................................................... +} } // namespace sd::toolpanel +//...................................................................................................................... + +#endif // SD_UI_TASKPANE_PANELID_HXX diff --git a/sd/source/ui/inc/taskpane/ToolPanelViewShell.hxx b/sd/source/ui/inc/taskpane/ToolPanelViewShell.hxx index ab687b55de47..a4eb499076e6 100644 --- a/sd/source/ui/inc/taskpane/ToolPanelViewShell.hxx +++ b/sd/source/ui/inc/taskpane/ToolPanelViewShell.hxx @@ -33,6 +33,7 @@ #include "ViewShell.hxx" #include "glob.hxx" +#include "taskpane/PanelId.hxx" #include "framework/FrameworkHelper.hxx" #include <vcl/button.hxx> #include <sfx2/shell.hxx> @@ -70,20 +71,6 @@ public: TYPEINFO(); SFX_DECL_INTERFACE(SD_IF_SDTOOLPANELSHELL) - /** List of top level panels that can be shown in the task pane. - */ - enum PanelId - { - PID__START = 0, - PID_UNKNOWN = PID__START, - PID_MASTER_PAGES, - PID_LAYOUT, - PID_TABLE_DESIGN, - PID_CUSTOM_ANIMATION, - PID_SLIDE_TRANSITION, - PID__END = PID_SLIDE_TRANSITION - }; - ToolPanelViewShell ( SfxViewFrame* pFrame, ViewShellBase& rViewShellBase, @@ -112,6 +99,14 @@ public: TaskPaneShellManager& GetSubShellManager (void) const; + /** 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 ); + /** 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. diff --git a/sd/source/ui/toolpanel/TaskPaneToolPanel.cxx b/sd/source/ui/toolpanel/TaskPaneToolPanel.cxx index 11735d5433bd..3e5a7ba3065f 100644 --- a/sd/source/ui/toolpanel/TaskPaneToolPanel.cxx +++ b/sd/source/ui/toolpanel/TaskPaneToolPanel.cxx @@ -38,18 +38,34 @@ 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; + /** === end UNO using === **/ + //================================================================================================================== //= TaskPaneToolPanel //================================================================================================================== //------------------------------------------------------------------------------------------------------------------ TaskPaneToolPanel::TaskPaneToolPanel( ToolPanelDeck& i_rPanelDeck, ::std::auto_ptr< ControlFactory >& i_rControlFactory, - const Image& i_rImage, const USHORT i_nTitleResId, const ULONG i_nHelpId ) + const Image& i_rImage, const USHORT i_nTitleResId, const ULONG i_nHelpId, const Reference< XResourceId >& i_rPanelResourceId ) :m_pPanelDeck( &i_rPanelDeck ) ,m_pControlFactory( i_rControlFactory ) ,m_pControl() ,m_aImage( i_rImage ) ,m_sTitle( SdResId( i_nTitleResId ) ) ,m_aHelpId( i_nHelpId ) + ,m_xPanelResourceId( i_rPanelResourceId ) { ENSURE_OR_THROW( m_pControlFactory.get(), "illegal control factory" ); } diff --git a/sd/source/ui/toolpanel/TaskPaneToolPanel.hxx b/sd/source/ui/toolpanel/TaskPaneToolPanel.hxx index d879d6549a0e..0ff352f58abb 100644 --- a/sd/source/ui/toolpanel/TaskPaneToolPanel.hxx +++ b/sd/source/ui/toolpanel/TaskPaneToolPanel.hxx @@ -58,8 +58,8 @@ namespace sd { namespace toolpanel ::std::auto_ptr< ControlFactory >& i_rControlFactory, const Image& i_rImage, const USHORT i_nTitleResId, - const ULONG i_nHelpId/*, - const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResourceId >& i_rPanelContent*/ + const ULONG i_nHelpId, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResourceId >& i_rPanelResourceId ); ~TaskPaneToolPanel(); @@ -73,6 +73,10 @@ namespace sd { namespace toolpanel virtual bool HasFocus() const; virtual void Dispose(); + // own attributes + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResourceId >& + getResourceId() const { return m_xPanelResourceId; } + private: bool impl_ensureControl(); @@ -83,6 +87,8 @@ namespace sd { namespace toolpanel const Image m_aImage; const String m_sTitle; const SmartId m_aHelpId; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResourceId > + m_xPanelResourceId; }; //...................................................................................................................... diff --git a/sd/source/ui/toolpanel/TaskPaneViewShell.cxx b/sd/source/ui/toolpanel/TaskPaneViewShell.cxx index c0acf9788e50..3c33ff41620f 100644 --- a/sd/source/ui/toolpanel/TaskPaneViewShell.cxx +++ b/sd/source/ui/toolpanel/TaskPaneViewShell.cxx @@ -131,7 +131,7 @@ public: /** Make a new panel known to the translation table that translates between internal indices as returned by ControlContainer::AddControl() and public indices defined by - TaskPaneViewShell::PanelId. + PanelId. */ void AddPanel (sal_uInt32 nInternalId, PanelId nPublicId); @@ -152,7 +152,7 @@ public: private: /** This map translates between internal indices returned by ControlContainer::AddControl() and public indices defined by - TaskPaneViewShell::PanelId. + PanelId. */ typedef ::std::vector<PanelId> InternalIdToPanelIdMap; InternalIdToPanelIdMap maIndexMap; @@ -790,7 +790,7 @@ void TaskPaneViewShell::Implementation::AddPanel ( -TaskPaneViewShell::PanelId +PanelId TaskPaneViewShell::Implementation::GetPublicId ( sal_uInt32 nInternalId) const { @@ -805,7 +805,7 @@ TaskPaneViewShell::PanelId sal_uInt32 TaskPaneViewShell::Implementation::GetInternalId ( - TaskPaneViewShell::PanelId nPublicId) const + PanelId nPublicId) const { sal_uInt32 nId = mnInvalidId; for (sal_uInt32 nI=0; nI<maIndexMap.size(); nI++) diff --git a/sd/source/ui/toolpanel/ToolPanelDeck.cxx b/sd/source/ui/toolpanel/ToolPanelDeck.cxx index c2a0d45b211f..e32b2960dacf 100644 --- a/sd/source/ui/toolpanel/ToolPanelDeck.cxx +++ b/sd/source/ui/toolpanel/ToolPanelDeck.cxx @@ -29,15 +29,38 @@ #include "ToolPanelDeck.hxx" #include "taskpane/ToolPanelViewShell.hxx" #include "taskpane/ControlContainer.hxx" +#include "framework/FrameworkHelper.hxx" #include "TaskPaneToolPanel.hxx" +/** === begin UNO includes === **/ +#include <com/sun/star/drawing/framework/ResourceActivationMode.hpp> +/** === end UNO includes === **/ + #include <svtools/toolpanel/tablayouter.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 //================================================================================================================== @@ -72,22 +95,61 @@ namespace sd { namespace toolpanel return; } - SetLayouter( new ::svt::TabDeckLayouter( *this, i_eTabAlignment, i_eTabContent ) ); + SetLayouter( new ::svt::TabDeckLayouter( *this, *this, i_eTabAlignment, i_eTabContent ) ); } //------------------------------------------------------------------------------------------------------------------ size_t ToolPanelDeck::CreateAndInsertPanel( ::std::auto_ptr< ControlFactory >& i_rControlFactory, - const Image& i_rImage, const USHORT i_nTitleResId, const ULONG i_nHelpId ) + const Image& i_rImage, const USHORT i_nTitleResId, const ULONG i_nHelpId, const Reference< XResourceId >& i_rPanelResourceId ) { // create panel ::svt::PToolPanel pNewPanel( new TaskPaneToolPanel( *this, i_rControlFactory, - i_rImage, i_nTitleResId, i_nHelpId + i_rImage, i_nTitleResId, i_nHelpId, + i_rPanelResourceId ) ); // insert as new panel return InsertPanel( pNewPanel, GetPanelCount() ); } + //------------------------------------------------------------------------------------------------------------------ + 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 now 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 index 65ad6f80ad83..845f391e298d 100644 --- a/sd/source/ui/toolpanel/ToolPanelDeck.hxx +++ b/sd/source/ui/toolpanel/ToolPanelDeck.hxx @@ -30,6 +30,10 @@ #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> @@ -59,11 +63,31 @@ namespace sd { namespace toolpanel ::std::auto_ptr< ControlFactory >& i_rControlFactory, const Image& i_rImage, const USHORT i_nTitleResId, - const ULONG i_nHelpId + const ULONG i_nHelpId, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResourceId >& i_rPanelResourceId ); void SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment, const ::svt::TabItemContent i_eTabContent ); + /** 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; }; diff --git a/sd/source/ui/toolpanel/ToolPanelViewShell.cxx b/sd/source/ui/toolpanel/ToolPanelViewShell.cxx index 4f40d629c9ce..fcf7761bf27d 100644 --- a/sd/source/ui/toolpanel/ToolPanelViewShell.cxx +++ b/sd/source/ui/toolpanel/ToolPanelViewShell.cxx @@ -40,7 +40,6 @@ #include "PaneDockingWindow.hxx" #include "FrameView.hxx" #include "Window.hxx" -#include "PaneDockingWindow.hxx" #include "ToolPanelDeck.hxx" #include "sdmod.hxx" #include "app.hrc" @@ -50,9 +49,12 @@ #include "strings.hrc" #include "sdresid.hxx" #include "framework/FrameworkHelper.hxx" + +/** === begin UNO includes === **/ #include <com/sun/star/drawing/framework/XResourceId.hpp> #include <com/sun/star/drawing/framework/ResourceActivationMode.hpp> #include <com/sun/star/drawing/XDrawSubController.hpp> +/** === end UNO includes === **/ #include <svx/dlgctrl.hxx> #include <sfx2/imagemgr.hxx> @@ -95,6 +97,7 @@ using ::com::sun::star::uno::Type; using ::com::sun::star::accessibility::XAccessible; using ::com::sun::star::drawing::XDrawSubController; using ::com::sun::star::frame::XFrame; +using ::com::sun::star::drawing::framework::XResourceId; /** === end UNO using === **/ using ::sd::framework::FrameworkHelper; @@ -109,18 +112,18 @@ namespace sd { namespace toolpanel { */ struct PanelDescriptor { - ToolPanelViewShell::PanelId nId; - ::svt::PToolPanel pPanel; - bool bHidden; + PanelId nId; + ::svt::PToolPanel pPanel; + bool bHidden; PanelDescriptor() - :nId( ToolPanelViewShell::PID_UNKNOWN ) + :nId( PID_UNKNOWN ) ,pPanel() ,bHidden( false ) { } - PanelDescriptor( const ToolPanelViewShell::PanelId i_nPanelId, const ::svt::PToolPanel& i_rPanel ) + PanelDescriptor( const PanelId i_nPanelId, const ::svt::PToolPanel& i_rPanel ) :nId( i_nPanelId ) ,pPanel( i_rPanel ) ,bHidden( false ) @@ -157,6 +160,23 @@ public: void TogglePanelVisibility( const size_t i_nLogicalPanelIndex, ToolPanelDeck& i_rPanelDeck ); + /** ensures the panel with the given ID is visible, and directly activates it, bypassing the configuration controller + */ + void ActivatePanelDirectly( const PanelId i_nPanelId, ToolPanelDeck& i_rPanelDeck ); + + /** 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, ToolPanelDeck& i_rPanelDeck ); + +protected: + // IToolPanelDeckListener overridables + virtual void PanelInserted( const ::svt::PToolPanel& i_pPanel, const size_t i_nPosition ); + virtual void PanelRemoved( const size_t i_nPosition ); + virtual void ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ); + virtual void Dying(); + private: void RegisterPanel( size_t i_nPosition, PanelId i_nPanelId, const ::svt::PToolPanel& i_rPanel ); @@ -201,38 +221,84 @@ void ToolPanelViewShell::Implementation::Setup( ToolPanelViewShell& i_rViewShell 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 }, + { &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 }, + { &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 }, + { &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 }, + { &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 } + { &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( i_rViewShell.GetViewShellBase() ) ); + const Reference< XResourceId > xToolPanelId( pFrameworkHelper->CreateResourceId( FrameworkHelper::msToolPanelViewURL, FrameworkHelper::msToolPanelPaneURL ) ); + + // want to activate the "Layout" panel later on, need to translate its PanelId to an actual position const PanelId nPanelIdToActivate = PID_LAYOUT; size_t nPanelPosToActivate = size_t( -1 ); + // create the panels Reference< XFrame > xFrame( i_rViewShell.GetViewShellBase().GetViewFrame()->GetFrame()->GetFrameInterface() ); const BOOL bHiContrast( i_rPanelDeck.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 size_t nPanelPos = i_rPanelDeck.CreateAndInsertPanel( (*aPanels[i].pFactory)( i_rViewShell ), - GetImage( xFrame, aCommandName.makeStringAndClear(), FALSE, bHiContrast ), + aPanelImage, aPanels[i].nTitleResourceID, - aPanels[i].nHelpID + aPanels[i].nHelpID, + xPanelId ); + + // remember it RegisterPanel( nPanelPos, aPanels[i].nPanelID, i_rPanelDeck.GetPanel( nPanelPos ) ); if ( nPanelIdToActivate == aPanels[i].nPanelID ) @@ -240,7 +306,7 @@ void ToolPanelViewShell::Implementation::Setup( ToolPanelViewShell& i_rViewShell } // activate default panel - i_rPanelDeck.ActivatePanel( nPanelPosToActivate ); + i_rPanelDeck.ActivatePanelResource( nPanelPosToActivate ); } // --------------------------------------------------------------------------------------------------------------------- @@ -604,7 +670,17 @@ bool ToolPanelViewShell::RelocateToParentWindow( ::Window* pParentWindow ) return true; } +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell::DeactivatePanel( const PanelId i_ePanelId ) +{ + mpImpl->DeactivatePanelDirectly( i_ePanelId, *mpPanelDeck ); +} +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell::ActivatePanel( const PanelId i_ePanelId ) +{ + mpImpl->ActivatePanelDirectly( i_ePanelId, *mpPanelDeck ); +} // ===================================================================================================================== @@ -639,7 +715,7 @@ void ToolPanelViewShell::Implementation::TogglePanelVisibility( const size_t i_n // if there has not been an active panel before, activate the newly inserted one ::boost::optional< size_t > aActivePanel( i_rPanelDeck.GetActivePanel() ); if ( !aActivePanel ) - i_rPanelDeck.ActivatePanel( nActualPanelIndex ); + i_rPanelDeck.ActivatePanelResource( nActualPanelIndex ); } else { @@ -649,6 +725,39 @@ void ToolPanelViewShell::Implementation::TogglePanelVisibility( const size_t i_n } // --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell::Implementation::DeactivatePanelDirectly( const PanelId i_nPanelId, ToolPanelDeck& i_rPanelDeck ) +{ + for ( size_t i=0; i<maPanels.size(); ++i ) + { + if ( maPanels[i].nId == i_nPanelId ) + { + if ( i_rPanelDeck.GetActivePanel() == i ) + i_rPanelDeck.ActivatePanelDirectly( ::boost::optional< size_t >() ); + return; + } + } +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell::Implementation::ActivatePanelDirectly( const PanelId i_nPanelId, ToolPanelDeck& i_rPanelDeck ) +{ + size_t nActualPanelIndex(0); + for ( size_t i=0; i<maPanels.size(); ++i ) + { + if ( maPanels[i].nId == i_nPanelId ) + { + if ( maPanels[i].bHidden ) + TogglePanelVisibility( i, i_rPanelDeck ); + i_rPanelDeck.ActivatePanelDirectly( nActualPanelIndex ); + return; + } + if ( !maPanels[i].bHidden ) + ++nActualPanelIndex; + } + OSL_ENSURE( false, "ToolPanelViewShell::ActivatePanelDirectly: don't have a panel with the given ID!" ); +} + +// --------------------------------------------------------------------------------------------------------------------- void ToolPanelViewShell::Implementation::RegisterPanel( size_t i_nPosition, PanelId i_nPanelId, const ::svt::PToolPanel& i_rPanel ) { OSL_PRECOND( maPanels[ i_nPosition ].nId == PID_UNKNOWN, "ToolPanelViewShell::Implementation::RegisterPanel: " diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx index 844a5e11b841..c0cf73187ef4 100644 --- a/sd/source/ui/view/ViewShellBase.cxx +++ b/sd/source/ui/view/ViewShellBase.cxx @@ -1658,8 +1658,8 @@ void ViewShellBase::Implementation::ProcessTaskPaneSlot (SfxRequest& rRequest) // Set the visibility state of the toolpanel and one of its top // level panels. BOOL bShowToolPanel = TRUE; - toolpanel::TaskPaneViewShell::PanelId nPanelId ( - toolpanel::TaskPaneViewShell::PID_UNKNOWN); + toolpanel::PanelId nPanelId ( + toolpanel::PID_UNKNOWN); bool bPanelIdGiven = false; // Extract the given arguments. @@ -1680,7 +1680,7 @@ void ViewShellBase::Implementation::ProcessTaskPaneSlot (SfxRequest& rRequest) if (pPanelId != NULL) { nPanelId = static_cast< - toolpanel::TaskPaneViewShell::PanelId>( + toolpanel::PanelId>( pPanelId->GetValue()); bPanelIdGiven = true; } @@ -1690,7 +1690,7 @@ void ViewShellBase::Implementation::ProcessTaskPaneSlot (SfxRequest& rRequest) // Ignore the request for some combinations of panels and view // shell types. if (bPanelIdGiven - && ! (nPanelId==toolpanel::TaskPaneViewShell::PID_LAYOUT + && ! (nPanelId==toolpanel::PID_LAYOUT && mrBase.GetMainViewShell()!=NULL && mrBase.GetMainViewShell()->GetShellType()==ViewShell::ST_OUTLINE)) { diff --git a/sd/source/ui/view/ViewShellImplementation.cxx b/sd/source/ui/view/ViewShellImplementation.cxx index e46b1afd213d..eb8863cfe49c 100644 --- a/sd/source/ui/view/ViewShellImplementation.cxx +++ b/sd/source/ui/view/ViewShellImplementation.cxx @@ -198,7 +198,7 @@ void ViewShell::Implementation::ProcessModifyPageSlot ( // Make the layout menu visible in the tool pane. SfxBoolItem aMakeToolPaneVisible (ID_VAL_ISVISIBLE, TRUE); SfxUInt32Item aPanelId (ID_VAL_PANEL_INDEX, - ::sd::toolpanel::TaskPaneViewShell::PID_LAYOUT); + ::sd::toolpanel::PID_LAYOUT); SfxViewFrame* pFrame = mrViewShell.GetViewFrame(); if (pFrame!=NULL && pFrame->GetDispatcher()!=NULL) { |