[Libreoffice-commits] core.git: 2 commits - sfx2/source

Andre Fischer af at apache.org
Wed May 29 13:00:51 PDT 2013


 sfx2/source/sidebar/Panel.cxx             |    7 ---
 sfx2/source/sidebar/SidebarController.cxx |   60 ++++++++++++++----------------
 sfx2/source/sidebar/SidebarController.hxx |   16 ++++++--
 3 files changed, 42 insertions(+), 41 deletions(-)

New commits:
commit 7e1c66163287eef13253d20639b9b2c78abf2580
Author: Andre Fischer <af at apache.org>
Date:   Wed May 29 13:19:17 2013 +0000

    Resolves: #i122405# Sidebar panels no longer dispose...
    
    XUIElement's inner objects
    
    (cherry picked from commit 3464c3499e708370359a9c0864bd4edc76d3a4c0)
    
    Change-Id: I860e09fe2436bb8a08458e4f49fb88f05d34dbd8

diff --git a/sfx2/source/sidebar/Panel.cxx b/sfx2/source/sidebar/Panel.cxx
index 3b81121..309dc04 100644
--- a/sfx2/source/sidebar/Panel.cxx
+++ b/sfx2/source/sidebar/Panel.cxx
@@ -86,13 +86,6 @@ void Panel::Dispose (void)
 {
     mxPanelComponent = NULL;
 
-    if (mxElement.is())
-    {
-        Reference<lang::XComponent> xComponent (mxElement->getRealInterface(), UNO_QUERY);
-        if (xComponent.is())
-            xComponent->dispose();
-    }
-
     {
         Reference<lang::XComponent> xComponent (mxElement, UNO_QUERY);
         mxElement = NULL;
commit 10480649244213a6346bdb52192580f0b4ad6804
Author: Andre Fischer <af at apache.org>
Date:   Wed May 29 15:57:18 2013 +0000

    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

diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index a2efa70..bce2f6f 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 7eeab7f..5f2c82b 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,


More information about the Libreoffice-commits mailing list