diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-03-25 10:55:53 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-03-25 10:55:53 +0100 |
commit | ce1737da191a210ecf75faa33c515e5f51168d3a (patch) | |
tree | b4bc4204ac72396645a24da0cbac5b8a8604bbd7 /sd/source/ui | |
parent | 24def11cfb667187a4b92c1e9a710281dcf2bef6 (diff) |
slidecopy: when the ToolPanelViewShell is first created, recognize the fact that the requested configuration already contains a tool panel resource, and properly set up the tool panel deck then
Diffstat (limited to 'sd/source/ui')
-rw-r--r-- | sd/source/ui/framework/factories/TaskPanelFactory.cxx | 38 | ||||
-rw-r--r-- | sd/source/ui/inc/taskpane/PanelId.hxx | 2 | ||||
-rw-r--r-- | sd/source/ui/toolpanel/ToolPanelViewShell.cxx | 99 |
3 files changed, 92 insertions, 47 deletions
diff --git a/sd/source/ui/framework/factories/TaskPanelFactory.cxx b/sd/source/ui/framework/factories/TaskPanelFactory.cxx index 43a1a0280ba4..89bb417fde25 100644 --- a/sd/source/ui/framework/factories/TaskPanelFactory.cxx +++ b/sd/source/ui/framework/factories/TaskPanelFactory.cxx @@ -202,40 +202,6 @@ namespace sResourceURL = xResourceId->getResourceURL(); } } - - toolpanel::PanelId lcl_getPanelId( const ::rtl::OUString& i_rResourceURL ) - { - toolpanel::PanelId ePanelId( toolpanel::PID_UNKNOWN ); - - // 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 ) ) - { - ePanelId = toolpanel::PID_MASTER_PAGES; - } - else if ( i_rResourceURL.equals( FrameworkHelper::msLayoutTaskPanelURL ) ) - { - ePanelId = toolpanel::PID_LAYOUT; - } - else if ( i_rResourceURL.equals( FrameworkHelper::msTableDesignPanelURL ) ) - { - ePanelId = toolpanel::PID_TABLE_DESIGN; - } - else if ( i_rResourceURL.equals( FrameworkHelper::msCustomAnimationTaskPanelURL ) ) - { - ePanelId = toolpanel::PID_CUSTOM_ANIMATION; - } - else if ( i_rResourceURL.equals( FrameworkHelper::msSlideTransitionTaskPanelURL ) ) - { - 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 ( @@ -251,7 +217,7 @@ Reference<XResource> SAL_CALL TaskPanelFactory::createResource ( if ( sResourceURL.match( FrameworkHelper::msTaskPanelURLPrefix ) ) { - toolpanel::PanelId ePanelId( lcl_getPanelId( sResourceURL ) ); + toolpanel::PanelId ePanelId( toolpanel::GetStandardPanelId( sResourceURL ) ); if ( ( ePanelId != toolpanel::PID_UNKNOWN ) && ( mpViewShellBase != NULL ) ) { @@ -297,7 +263,7 @@ void SAL_CALL TaskPanelFactory::releaseResource ( const ::boost::shared_ptr< ViewShell > pPaneViewShell( pFrameworkHelper->GetViewShell( sPaneURL ) ); if ( pPaneViewShell != NULL ) { - toolpanel::PanelId ePanelId( lcl_getPanelId( xResourceId->getResourceURL() ) ); + toolpanel::PanelId ePanelId( toolpanel::GetStandardPanelId( xResourceId->getResourceURL() ) ); toolpanel::ToolPanelViewShell* pToolPanel = dynamic_cast< toolpanel::ToolPanelViewShell* >( pPaneViewShell.get() ); if ( ( ePanelId != toolpanel::PID_UNKNOWN ) diff --git a/sd/source/ui/inc/taskpane/PanelId.hxx b/sd/source/ui/inc/taskpane/PanelId.hxx index 6ce1c4693267..7e26c4e66e68 100644 --- a/sd/source/ui/inc/taskpane/PanelId.hxx +++ b/sd/source/ui/inc/taskpane/PanelId.hxx @@ -49,6 +49,8 @@ namespace sd { namespace toolpanel PID_FIRST_CUSTOM_PANEL = 6 }; + PanelId GetStandardPanelId( const ::rtl::OUString& i_rTaskPanelResourceURL ); + //...................................................................................................................... } } // namespace sd::toolpanel //...................................................................................................................... diff --git a/sd/source/ui/toolpanel/ToolPanelViewShell.cxx b/sd/source/ui/toolpanel/ToolPanelViewShell.cxx index 8a068cad1dd4..6217924c5c71 100644 --- a/sd/source/ui/toolpanel/ToolPanelViewShell.cxx +++ b/sd/source/ui/toolpanel/ToolPanelViewShell.cxx @@ -55,6 +55,7 @@ /** === begin UNO includes === **/ #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/XDrawSubController.hpp> /** === end UNO includes === **/ @@ -110,6 +111,9 @@ using ::com::sun::star::drawing::framework::ConfigurationChangeEvent; using ::com::sun::star::lang::EventObject; using ::com::sun::star::lang::DisposedException; 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; /** === end UNO using === **/ using ::sd::framework::FrameworkHelper; @@ -268,9 +272,20 @@ 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 activate initially + /** creates the built-in panels, returns the position of the panel to initially activate */ - size_t SetupDefaultPanels(); + struct PanelActivation + { + size_t nPanelPos; + bool bActivateAsResource; + + PanelActivation() + :nPanelPos( size_t( -1 ) ) + ,bActivateAsResource( true ) + { + } + }; + PanelActivation SetupDefaultPanels(); /** creates the custom panels */ @@ -391,7 +406,7 @@ SFX_IMPL_INTERFACE(ToolPanelViewShell, SfxShell, SdResId(STR_TASKPANEVIEWSHELL)) TYPEINIT1(ToolPanelViewShell, ViewShell); // --------------------------------------------------------------------------------------------------------------------- -size_t ToolPanelViewShell_Impl::SetupDefaultPanels() +ToolPanelViewShell_Impl::PanelActivation ToolPanelViewShell_Impl::SetupDefaultPanels() { typedef std::auto_ptr<ControlFactory> (*ControlFactoryFactory)( ToolPanelViewShell& i_rToolPanelShell ); @@ -453,9 +468,35 @@ size_t ToolPanelViewShell_Impl::SetupDefaultPanels() ::boost::shared_ptr< FrameworkHelper > pFrameworkHelper( FrameworkHelper::Instance( m_rPanelViewShell.GetViewShellBase() ) ); const Reference< XResourceId > xToolPanelId( pFrameworkHelper->CreateResourceId( FrameworkHelper::msTaskPaneURL, FrameworkHelper::msRightPaneURL ) ); - // 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 ); + // 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, + // use that one. + PanelId nPanelToActivate = PID_LAYOUT; + PanelActivation aPanelToActivate; + try + { + ::boost::shared_ptr< FrameworkHelper > pFrameworkHelper( FrameworkHelper::Instance( m_rPanelViewShell.GetViewShellBase() ) ); + Reference< XConfigurationController > xCC( pFrameworkHelper->GetConfigurationController(), UNO_QUERY_THROW ); + Reference< XConfiguration > xConfiguration( xCC->getRequestedConfiguration(), UNO_QUERY_THROW ); + Sequence< Reference< XResourceId > > aViewIds( xConfiguration->getResources( + FrameworkHelper::CreateResourceId( FrameworkHelper::msTaskPaneURL, FrameworkHelper::msRightPaneURL ), + FrameworkHelper::msTaskPanelURLPrefix, AnchorBindingMode_DIRECT ) ); + + if ( aViewIds.getLength() > 0 ) + { + const ::rtl::OUString sResourceURL( aViewIds[0]->getResourceURL() ); + PanelId nRequestedPanel = GetStandardPanelId( sResourceURL ); + if ( nRequestedPanel != PID_UNKNOWN ) + { + nPanelToActivate = nRequestedPanel; + aPanelToActivate.bActivateAsResource = false; + } + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } // create the panels Reference< XFrame > xFrame( m_rPanelViewShell.GetViewShellBase().GetViewFrame()->GetFrame()->GetFrameInterface() ); @@ -486,11 +527,11 @@ size_t ToolPanelViewShell_Impl::SetupDefaultPanels() // remember it RegisterPanel( nPanelPos, aPanels[i].nPanelID, pNewPanel ); - if ( nPanelIdToActivate == aPanels[i].nPanelID ) - nPanelPosToActivate = nPanelPos; + if ( nPanelToActivate == aPanels[i].nPanelID ) + aPanelToActivate.nPanelPos = nPanelPos; } - return nPanelPosToActivate; + return aPanelToActivate; } // --------------------------------------------------------------------------------------------------------------------- @@ -532,13 +573,16 @@ void ToolPanelViewShell_Impl::Setup() m_bInitialized = true; // standard (built-in) panels - const size_t nPanelPosToActivate = SetupDefaultPanels(); + const PanelActivation aPanelToActivate = SetupDefaultPanels(); // custom panels SetupCustomPanels(); // activate default panel - m_pPanelDeck->ActivatePanelResource( nPanelPosToActivate ); + 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 ); @@ -1187,4 +1231,37 @@ void ToolPanelViewShell_Impl::Dying() { } +// --------------------------------------------------------------------------------------------------------------------- +PanelId GetStandardPanelId( const ::rtl::OUString& i_rTaskPanelResourceURL ) +{ + PanelId ePanelId( PID_UNKNOWN ); + + 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 ) ) + { + 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!" ); + } + + return ePanelId; +} + } } // end of namespace ::sd::toolpanel |