diff options
author | Andre Fischer <af@apache.org> | 2013-05-29 15:57:18 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-05-29 20:58:47 +0100 |
commit | 10480649244213a6346bdb52192580f0b4ad6804 (patch) | |
tree | 5867da455e9472e212a5aa49ab2fffa7009cc12a /sfx2 | |
parent | c723428d61c7a5a5ee5796e2ed8d891db384c52a (diff) |
Resolves: #i122394# Force creation of new sidebar panels on DATACHANGED events
(cherry picked from commit c726a12e1833af2f06858e5a797bcbd03bf9e996)
Conflicts:
sfx2/source/sidebar/SidebarController.cxx
Change-Id: Ie28ff4371e42fd57534eeca75dab1a4bfda2ead6
Diffstat (limited to 'sfx2')
-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 a2efa70fb15f..bce2f6f1b610 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -106,6 +106,7 @@ SidebarController::SidebarController ( mxFrame(rxFrame), maCurrentContext(OUString(), OUString()), maRequestedContext(), + mnRequestedForceFlags(SwitchFlag_NoForce), msCurrentDeckId(gsDefaultDeckId), msCurrentDeckTitle(), maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)), @@ -260,7 +261,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(); } } @@ -381,7 +382,8 @@ void SidebarController::ProcessNewWidth (const sal_Int32 nNewWidth) void SidebarController::UpdateConfigurations (void) { - if (maCurrentContext != maRequestedContext) + if (maCurrentContext != maRequestedContext + || mnRequestedForceFlags!=SwitchFlag_NoForce) { maCurrentContext = maRequestedContext; @@ -461,7 +463,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) @@ -478,7 +482,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. @@ -552,10 +561,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. @@ -564,7 +583,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(), @@ -615,30 +635,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] == 0) - 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, @@ -753,6 +749,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 7eeab7fb06b5..5f2c82b5bb66 100644 --- a/sfx2/source/sidebar/SidebarController.hxx +++ b/sfx2/source/sidebar/SidebarController.hxx @@ -98,6 +98,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 ( @@ -120,6 +131,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; @@ -160,9 +173,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, |