include/vcl/treelist.hxx           |    1 +
 sw/inc/strings.hrc                 |    2 ++
 sw/source/uibase/utlui/content.cxx |   16 ++++++++++++++++
 vcl/source/treelist/svimpbox.cxx   |    2 +-
 vcl/source/treelist/treelist.cxx   |   17 +++++++++++++++++
 5 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit 3ed56f407235feb97ee2565a613e5f1d2bb2d925
Author:     Jim Raykowski <rayk...@gmail..com>
AuthorDate: Thu Oct 17 19:09:18 2019 -0800
Commit:     Jim Raykowski <rayk...@gmail.com>
CommitDate: Wed Oct 23 04:38:36 2019 +0200

    tdf#128058 Add Expand Collapse All to Navigator context menu
    
    Change-Id: I8c68865c8bc95a9ef6d1bea565e635e288f728e6
    Reviewed-on: https://gerrit.libreoffice.org/81003
    Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org>
    Tested-by: Heiko Tietze <heiko.tie...@documentfoundation.org>
    Tested-by: Jenkins

diff --git a/include/vcl/treelist.hxx b/include/vcl/treelist.hxx
index 2d8fc7b4379d..15931d79f9d6 100644
--- a/include/vcl/treelist.hxx
+++ b/include/vcl/treelist.hxx
@@ -288,6 +288,7 @@ public:
     { return pModel->IsEntryVisible(this,pEntry); }
 
     bool                IsExpanded( SvTreeListEntry* pEntry ) const;
+    bool                IsAllExpanded( SvTreeListEntry* pEntry) const;
     bool                IsSelected( SvTreeListEntry* pEntry ) const;
     void                SetEntryFocus( SvTreeListEntry* pEntry, bool bFocus );
     const SvViewDataEntry*         GetViewData( const SvTreeListEntry* pEntry 
) const;
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index e6355c4cbb3d..b77225641089 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -631,6 +631,8 @@
 #define STR_OUTLINE_LEVEL                       NC_("STR_OUTLINE_LEVEL", 
"Outline Level")
 #define STR_DRAGMODE                            NC_("STR_DRAGMODE", "Drag 
Mode")
 #define STR_SEND_OUTLINE_TO_CLIPBOARD_ENTRY     
NC_("STR_SEND_OUTLINE_TO_CLIPBOARD_ENTRY", "Send Outline to Clipboard")
+#define STR_EXPANDALL                           NC_("STR_EXPANDALL", "Expand 
All")
+#define STR_COLLAPSEALL                         NC_("STR_COLLAPSEALL", 
"Collapse All")
 #define STR_HYPERLINK                           NC_("STR_HYPERLINK", "Insert 
as Hyperlink")
 #define STR_LINK_REGION                         NC_("STR_LINK_REGION", "Insert 
as Link")
 #define STR_COPY_REGION                         NC_("STR_COPY_REGION", "Insert 
as Copy")
diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index 7ee2789a4f9f..0381b2101281 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -1207,6 +1207,16 @@ sal_Int8 SwContentTree::ExecuteDrop( const 
ExecuteDropEvent& rEvt )
 
 // Handler for Dragging and ContextMenu
 
+static void lcl_InsertExpandCollapseAllItem(SwContentTree* pContentTree, 
SvTreeListEntry* pEntry, PopupMenu* pPop)
+{
+    if(pEntry->HasChildren() || pEntry->HasChildrenOnDemand())
+    {
+        pPop->InsertSeparator();
+        pPop->InsertItem(800, pContentTree->IsAllExpanded(pEntry) ? 
SwResId(STR_COLLAPSEALL) : SwResId(STR_EXPANDALL));
+        pPop->SetAccelKey(800, vcl::KeyCode(KEY_MULTIPLY, false, true, false, 
false));
+    }
+}
+
 VclPtr<PopupMenu> SwContentTree::CreateContextMenu()
 {
     auto pPop = VclPtr<PopupMenu>::Create();
@@ -1348,6 +1358,8 @@ VclPtr<PopupMenu> SwContentTree::CreateContextMenu()
                 pPop->SetPopupMenu(4, pSubPop4);
             }
         }
+        else if(ContentTypeId::OUTLINE == nContentType)
+            lcl_InsertExpandCollapseAllItem(this, pEntry, pPop);
     }
     else if( pEntry )
     {
@@ -1355,6 +1367,7 @@ VclPtr<PopupMenu> SwContentTree::CreateContextMenu()
         SwContentType* pType = 
static_cast<SwContentType*>(pEntry->GetUserData());
         if(ContentTypeId::OUTLINE == pType->GetType())
         {
+            lcl_InsertExpandCollapseAllItem(this, pEntry, pPop);
             pPop->InsertSeparator();
             pPop->InsertItem(700, 
m_aContextStrings[IDX_STR_SEND_OUTLINE_TO_CLIPBOARD_ENTRY]);
         }
@@ -3291,6 +3304,9 @@ void SwContentTree::ExecuteContextMenuAction( sal_uInt16 
nSelectedPopupEntry )
                 
m_pActiveShell->GetView().GetViewFrame()->GetDispatcher()->Execute(FN_OUTLINE_TO_CLIPBOARD);
                 break;
             }
+        case 800:
+            KeyInput(KeyEvent(0, KEY_MOD1|KEY_MULTIPLY));
+            break;
         //Display
         default:
         if(nSelectedPopupEntry > 300 && nSelectedPopupEntry < 400)
diff --git a/vcl/source/treelist/svimpbox.cxx b/vcl/source/treelist/svimpbox.cxx
index a936c4a3f9e4..5a7308b8a3a3 100644
--- a/vcl/source/treelist/svimpbox.cxx
+++ b/vcl/source/treelist/svimpbox.cxx
@@ -2473,7 +2473,7 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
                 // otherwise ignore the key press
                 if( IsExpandable() )
                 {
-                    if (!m_pView->IsExpanded(m_pCursor))
+                    if (!m_pView->IsAllExpanded(m_pCursor))
                     {
                         m_pView->Expand(m_pCursor);
                         ExpandAll();
diff --git a/vcl/source/treelist/treelist.cxx b/vcl/source/treelist/treelist.cxx
index 11a4221e5305..03c1d9d4e831 100644
--- a/vcl/source/treelist/treelist.cxx
+++ b/vcl/source/treelist/treelist.cxx
@@ -1352,6 +1352,23 @@ bool SvListView::IsExpanded( SvTreeListEntry* pEntry ) 
const
     return itr->second->IsExpanded();
 }
 
+bool SvListView::IsAllExpanded( SvTreeListEntry* pEntry ) const
+{
+    DBG_ASSERT(pEntry,"IsAllExpanded:No Entry");
+    if (!IsExpanded(pEntry))
+        return false;
+    const SvTreeListEntries& rChildren = pEntry->GetChildEntries();
+    for (auto& rChild : rChildren)
+    {
+        if (rChild->HasChildren() || rChild->HasChildrenOnDemand())
+        {
+            if (!IsAllExpanded(rChild.get()))
+                return false;
+        }
+    }
+    return true;
+}
+
 bool SvListView::IsSelected( SvTreeListEntry* pEntry ) const
 {
     DBG_ASSERT(pEntry,"IsExpanded:No Entry");
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to