[Libreoffice-commits] core.git: sd/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Feb 21 19:00:18 UTC 2019


 sd/source/ui/animations/CustomAnimationList.cxx |   67 ++++++++++++++++++++++++
 sd/source/ui/animations/CustomAnimationList.hxx |    3 +
 2 files changed, 70 insertions(+)

New commits:
commit d3fdd9f12ba698008515bfdc47c5f96318406d7f
Author:     Brian Fraser <andthebrain at softfrog.ca>
AuthorDate: Sun Feb 17 22:55:57 2019 -0800
Commit:     Jim Raykowski <raykowj at gmail.com>
CommitDate: Thu Feb 21 19:59:46 2019 +0100

    tdf#123534 Impress collapse/expand animation maintains selection
    
    - Expandened a selected bulleted list's animations now
      selects children (maintaining the selection behaviour).
    - Collapsing a bulleted list's animation no longer
      clears the current selections
    - Deselecting animations now refreshed the UI correctly
    
    Change-Id: I3a3ca0eb0efe841784d96d5dc8e1b760dea4f777
    Reviewed-on: https://gerrit.libreoffice.org/67947
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <raykowj at gmail.com>

diff --git a/sd/source/ui/animations/CustomAnimationList.cxx b/sd/source/ui/animations/CustomAnimationList.cxx
index 7e3107b80baa..d3f88d483f1d 100644
--- a/sd/source/ui/animations/CustomAnimationList.cxx
+++ b/sd/source/ui/animations/CustomAnimationList.cxx
@@ -1108,6 +1108,7 @@ void CustomAnimationList::onSelectionChanged(const Any& rSelection)
     }
 }
 
+// Notify controller to refresh UI when we are notified of selection change from base class
 void CustomAnimationList::SelectHdl()
 {
     if( mbIgnorePaint )
@@ -1116,6 +1117,72 @@ void CustomAnimationList::SelectHdl()
     mpController->onSelect();
 }
 
+// Notify controller to refresh UI when we are notified of selection change from base class
+void CustomAnimationList::DeselectHdl()
+{
+    if( mbIgnorePaint )
+        return;
+    SvTreeListBox::DeselectHdl();
+    mpController->onSelect();
+}
+
+
+bool CustomAnimationList::Expand( SvTreeListEntry* pParent )
+{
+    bool result = SvTreeListBox::Expand( pParent );
+
+    // If expanded entry is selected, then select its children too.
+    if( IsSelected( pParent )) {
+        for( auto pChild = FirstChild( pParent ); pChild; pChild = pChild->NextSibling() )
+        {
+            if( !IsSelected( pChild ) )
+            {
+                SelectListEntry( pChild, true );
+            }
+        }
+    }
+
+    // Notify controller that selection has changed (it should update the UI)
+    mpController->onSelect();
+
+    return result;
+}
+
+bool CustomAnimationList::Collapse( SvTreeListEntry* pParent )
+{
+    // SvTreeListBox::Collapse(..) discards multi-selection state
+    // of list entries, so first save current selection state
+    std::vector< SvTreeListEntry* > selectedEntries;
+    for( auto pEntry = FirstSelected(); pEntry; pEntry = NextSelected( pEntry ))
+    {
+        selectedEntries.push_back( pEntry );
+    }
+
+    // Execute collapse on base class
+    bool result = SvTreeListBox::Collapse( pParent );
+
+    // Deselect all entries as SvTreeListBox::Collapse selects the last
+    // entry to have focus (or its parent), which is not desired
+    for( auto pEntry = FirstSelected(); pEntry; pEntry = NextSelected( pEntry ))
+    {
+        SelectListEntry( pEntry, false );
+    }
+
+    // Restore selection state for entries which are still visible
+    for( auto &pEntry : selectedEntries )
+    {
+        if( IsEntryVisible( pEntry ))
+        {
+            SelectListEntry( pEntry, true );
+        }
+    }
+
+    // Notify controller that selection has changed (it should update the UI)
+    mpController->onSelect();
+
+    return result;
+}
+
 bool CustomAnimationList::isExpanded( const CustomAnimationEffectPtr& pEffect ) const
 {
     CustomAnimationListEntry* pEntry = static_cast<CustomAnimationListEntry*>(First());
diff --git a/sd/source/ui/animations/CustomAnimationList.hxx b/sd/source/ui/animations/CustomAnimationList.hxx
index 8e322f885db1..25976bc0e437 100644
--- a/sd/source/ui/animations/CustomAnimationList.hxx
+++ b/sd/source/ui/animations/CustomAnimationList.hxx
@@ -72,6 +72,7 @@ public:
 
     // overrides
     virtual void    SelectHdl() override;
+    virtual void    DeselectHdl() override;
     virtual bool    DoubleClickHdl() override;
 
     virtual void    Paint( vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect ) override;
@@ -83,6 +84,8 @@ public:
 
     virtual void notify_change() override;
 
+    virtual bool Expand( SvTreeListEntry* pParent ) override;
+    virtual bool Collapse( SvTreeListEntry* pParent ) override;
     bool isExpanded( const CustomAnimationEffectPtr& pEffect ) const;
     bool isVisible( const CustomAnimationEffectPtr& pEffect ) const;
 


More information about the Libreoffice-commits mailing list