diff options
author | Andre Fischer <af@apache.org> | 2013-05-29 15:57:18 +0000 |
---|---|---|
committer | Andre Fischer <af@apache.org> | 2013-05-29 15:57:18 +0000 |
commit | c726a12e1833af2f06858e5a797bcbd03bf9e996 (patch) | |
tree | 51000cfb0c387076ae15fd95d6d849d379a31a56 | |
parent | 924bd9b9227bcd1fb820fb922b3a2e84bcc73f20 (diff) |
122394: Force creation of new sidebar panels on DATACHANGED events.
Notes
Notes:
merged as: 10480649244213a6346bdb52192580f0b4ad6804
-rw-r--r-- | sfx2/source/sidebar/SidebarController.cxx | 60 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarController.hxx | 16 |
2 files changed, 42 insertions, 34 deletions
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index e49ba248fb5c..067349a65a3f 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -114,6 +114,7 @@ SidebarController::SidebarController ( mxFrame(rxFrame), maCurrentContext(OUString(), OUString()), maRequestedContext(), + mnRequestedForceFlags(SwitchFlag_NoForce), msCurrentDeckId(gsDefaultDeckId), msCurrentDeckTitle(), maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)), @@ -268,7 +269,7 @@ void SAL_CALL SidebarController::statusChanged (const css::frame::FeatureStateEv // Force the current deck to update its panel list. if ( ! mbIsDocumentReadOnly) msCurrentDeckId = gsDefaultDeckId; - maCurrentContext = Context(); + mnRequestedForceFlags |= SwitchFlag_ForceSwitch; maContextChangeUpdate.RequestCall(); } } @@ -389,7 +390,8 @@ void SidebarController::ProcessNewWidth (const sal_Int32 nNewWidth) void SidebarController::UpdateConfigurations (void) { - if (maCurrentContext != maRequestedContext) + if (maCurrentContext != maRequestedContext + || mnRequestedForceFlags!=SwitchFlag_NoForce) { maCurrentContext = maRequestedContext; @@ -469,7 +471,9 @@ void SidebarController::OpenThenSwitchToDeck ( void SidebarController::SwitchToDeck ( const ::rtl::OUString& rsDeckId) { - if ( ! msCurrentDeckId.equals(rsDeckId) || ! mbIsDeckOpen) + if ( ! msCurrentDeckId.equals(rsDeckId) + || ! mbIsDeckOpen + || mnRequestedForceFlags!=SwitchFlag_NoForce) { const DeckDescriptor* pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(rsDeckId); if (pDeckDescriptor != NULL) @@ -486,7 +490,12 @@ void SidebarController::SwitchToDeck ( { maFocusManager.Clear(); - if ( ! msCurrentDeckId.equals(rDeckDescriptor.msId)) + const bool bForceNewDeck ((mnRequestedForceFlags&SwitchFlag_ForceNewDeck)!=0); + const bool bForceNewPanels ((mnRequestedForceFlags&SwitchFlag_ForceNewPanels)!=0); + mnRequestedForceFlags = SwitchFlag_NoForce; + + if ( ! msCurrentDeckId.equals(rDeckDescriptor.msId) + || bForceNewDeck) { // When the deck changes then destroy the deck and all panels // and create everything new. @@ -560,10 +569,20 @@ void SidebarController::SwitchToDeck ( // Find the corresponding panel among the currently active // panels. - SharedPanelContainer::const_iterator iPanel (::std::find_if( + SharedPanelContainer::const_iterator iPanel; + if (bForceNewPanels) + { + // All panels have to be created in any case. There is no + // point in searching already existing panels. + iPanel = rCurrentPanels.end(); + } + else + { + iPanel = ::std::find_if( rCurrentPanels.begin(), rCurrentPanels.end(), - ::boost::bind(&Panel::HasIdPredicate, _1, ::boost::cref(rPanelContexDescriptor.msId)))); + ::boost::bind(&Panel::HasIdPredicate, _1, ::boost::cref(rPanelContexDescriptor.msId))); + } if (iPanel != rCurrentPanels.end()) { // Panel already exists in current deck. Reuse it. @@ -572,7 +591,8 @@ void SidebarController::SwitchToDeck ( } else { - // Panel does not yet exist. Create it. + // Panel does not yet exist or creation of new panels is forced. + // Create it. aNewPanels[nWriteIndex] = CreatePanel( rPanelContexDescriptor.msId, mpCurrentDeck->GetPanelParentWindow(), @@ -623,30 +643,6 @@ void SidebarController::SwitchToDeck ( -bool SidebarController::ArePanelSetsEqual ( - const SharedPanelContainer& rCurrentPanels, - const ResourceManager::PanelContextDescriptorContainer& rRequestedPanels) -{ - if (rCurrentPanels.size() != rRequestedPanels.size()) - return false; - for (sal_Int32 nIndex=0,nCount=rCurrentPanels.size(); nIndex<nCount; ++nIndex) - { - if (rCurrentPanels[nIndex] == NULL) - return false; - if ( ! rCurrentPanels[nIndex]->GetId().equals(rRequestedPanels[nIndex].msId)) - return false; - - // Check if the panels still can be displayed. This may not be the case when - // the document just become rea-only. - if (mbIsDocumentReadOnly && ! rRequestedPanels[nIndex].mbShowForReadOnlyDocuments) - return false; - } - return true; -} - - - - SharedPanel SidebarController::CreatePanel ( const OUString& rsPanelId, ::Window* pParentWindow, @@ -761,6 +757,8 @@ IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent*, pEvent) Theme::HandleDataChange(); UpdateTitleBarIcons(); mpParentWindow->Invalidate(); + mnRequestedForceFlags |= SwitchFlag_ForceNewDeck | SwitchFlag_ForceNewPanels; + maContextChangeUpdate.RequestCall(); break; case SFX_HINT_DYING: diff --git a/sfx2/source/sidebar/SidebarController.hxx b/sfx2/source/sidebar/SidebarController.hxx index 6f02b5779fdf..36389b6027c2 100644 --- a/sfx2/source/sidebar/SidebarController.hxx +++ b/sfx2/source/sidebar/SidebarController.hxx @@ -102,6 +102,17 @@ public: void NotifyResize (void); + /** In some situations it is necessary to force an update of the + current deck and its panels. One reason is a change of the + view scale. Some panels can handle this only when + constructed. In this case we have to a context change and + also force that all panels are destroyed and created new. + */ + const static sal_Int32 SwitchFlag_NoForce = 0x00; + const static sal_Int32 SwitchFlag_ForceSwitch = 0x01; + const static sal_Int32 SwitchFlag_ForceNewDeck = 0x02; + const static sal_Int32 SwitchFlag_ForceNewPanels = 0x02; + void SwitchToDeck ( const ::rtl::OUString& rsDeckId); void OpenThenSwitchToDeck ( @@ -124,6 +135,8 @@ private: cssu::Reference<css::frame::XFrame> mxFrame; Context maCurrentContext; Context maRequestedContext; + /// Use a combination of SwitchFlag_* as value. + sal_Int32 mnRequestedForceFlags; ::rtl::OUString msCurrentDeckId; ::rtl::OUString msCurrentDeckTitle; AsynchronousCall maPropertyChangeForwarder; @@ -164,9 +177,6 @@ private: */ void UpdateConfigurations (void); - bool ArePanelSetsEqual ( - const SharedPanelContainer& rCurrentPanels, - const ResourceManager::PanelContextDescriptorContainer& rRequestedPanels); cssu::Reference<css::ui::XUIElement> CreateUIElement ( const cssu::Reference<css::awt::XWindowPeer>& rxWindow, const ::rtl::OUString& rsImplementationURL, |