[Libreoffice-commits] core.git: include/sfx2 include/svtools include/vcl sc/source sfx2/inc sfx2/source solenv/clang-format solenv/sanitizers svtools/source svx/source sw/inc sw/Library_sw.mk sw/source sw/uiconfig sw/UIConfig_swriter.mk uitest/writer_tests5

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 24 10:01:27 UTC 2020


 include/sfx2/weldutils.hxx                           |    4 
 include/svtools/toolboxcontroller.hxx                |    2 
 include/vcl/weldutils.hxx                            |   12 
 sc/source/ui/sidebar/AlignmentPropertyPanel.cxx      |    8 
 sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx |    4 
 sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx   |    2 
 sfx2/inc/sidebar/ControllerFactory.hxx               |    6 
 sfx2/source/dialog/recfloat.cxx                      |    2 
 sfx2/source/sidebar/ControllerFactory.cxx            |    6 
 sfx2/source/toolbox/weldutils.cxx                    |    7 
 solenv/clang-format/blacklist                        |    2 
 solenv/sanitizers/ui/modules/swriter.suppr           |    3 
 svtools/source/uno/toolboxcontroller.cxx             |    3 
 svx/source/dialog/dlgctrl.cxx                        |    2 
 svx/source/sidebar/area/AreaPropertyPanelBase.cxx    |    2 
 svx/source/sidebar/line/LinePropertyPanelBase.cxx    |    4 
 svx/source/sidebar/lists/ListsPropertyPanel.cxx      |    4 
 svx/source/sidebar/paragraph/ParaPropertyPanel.cxx   |   16 
 svx/source/sidebar/possize/PosSizePropertyPanel.cxx  |    4 
 svx/source/tbxctrls/fillctrl.cxx                     |    2 
 sw/Library_sw.mk                                     |    1 
 sw/UIConfig_swriter.mk                               |    3 
 sw/inc/pch/precompiled_msword.hxx                    |   10 
 sw/inc/pch/precompiled_sw.hxx                        |   10 
 sw/inc/pch/precompiled_swui.hxx                      |   13 
 sw/inc/pch/precompiled_vbaswobj.hxx                  |   10 
 sw/inc/strings.hrc                                   |   16 
 sw/source/uibase/cctrl/actctrl.cxx                   |   49 
 sw/source/uibase/inc/actctrl.hxx                     |   82 
 sw/source/uibase/inc/conttree.hxx                    |  289 +-
 sw/source/uibase/inc/navipi.hxx                      |   43 
 sw/source/uibase/ribbar/workctrl.cxx                 |  151 -
 sw/source/uibase/sidebar/TableEditPanel.cxx          |   14 
 sw/source/uibase/sidebar/WrapPropertyPanel.cxx       |    2 
 sw/source/uibase/uitest/uiobject.cxx                 |    6 
 sw/source/uibase/utlui/content.cxx                   | 2385 +++++++++----------
 sw/source/uibase/utlui/glbltree.cxx                  | 1055 +++-----
 sw/source/uibase/utlui/navipi.cxx                    |  552 ++--
 sw/uiconfig/swriter/ui/mastercontextmenu.ui          |  131 +
 sw/uiconfig/swriter/ui/navigatorcontextmenu.ui       |  242 +
 sw/uiconfig/swriter/ui/navigatorpanel.ui             |  933 +++++--
 sw/uiconfig/swriter/ui/spinbox.ui                    |   32 
 uitest/writer_tests5/tdf114724.py                    |    2 
 43 files changed, 3222 insertions(+), 2904 deletions(-)

New commits:
commit 5a2c0ab29719ac914d30d8789c0e386541702cbf
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Feb 28 11:13:12 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Mar 24 11:00:50 2020 +0100

    weld writer navigator
    
    GtkToggleToolButton are much wider than vcl equivalents.  Split the bottom
    toolbar into two toolbars. Rearrange their contents so the layout of each level
    visually match.
    
    Notes:
    
    Master documents have two modes, master content tree and the normal content
    tree.
    
    You can drag entries from the content tree into the document, drag mode drop
    down controls whether its a link or a copy etc that's dropped in.
    
    Documents can be dropped into the content and global trees.
    
    If outline tracking isn't active, then when content changes the tree is cleared
    and refilled, typically an effort is made to reselect the same entry that was
    previously selected. Additionally, if the amount of content didn't change an
    effort is made to scroll back to the location the scrollbar was at before the
    clear.
    
    Change-Id: I00c015145eac5b1acc3398d3c40861d830e4264a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89725
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/sfx2/weldutils.hxx b/include/sfx2/weldutils.hxx
index 8c577f9a1651..c2e05d54924a 100644
--- a/include/sfx2/weldutils.hxx
+++ b/include/sfx2/weldutils.hxx
@@ -24,6 +24,7 @@
 
 namespace weld
 {
+class Builder;
 class Toolbar;
 }
 
@@ -33,6 +34,7 @@ private:
     css::uno::Reference<css::frame::XFrame> m_xFrame;
     SvtMiscOptions m_aToolbarOptions;
     weld::Toolbar* m_pToolbar;
+    weld::Builder* m_pBuilder;
 
     DECL_LINK(SelectHdl, const OString&, void);
     DECL_LINK(ToggleMenuHdl, const OString&, void);
@@ -47,7 +49,7 @@ private:
 
 public:
     // fill in the label and icons for actions and dispatch the action on item click
-    ToolbarUnoDispatcher(weld::Toolbar& rToolbar,
+    ToolbarUnoDispatcher(weld::Toolbar& rToolbar, weld::Builder& rBuilder,
                          const css::uno::Reference<css::frame::XFrame>& rFrame);
 
     css::uno::Reference<css::frame::XToolbarController>
diff --git a/include/svtools/toolboxcontroller.hxx b/include/svtools/toolboxcontroller.hxx
index b97c0e15b11a..bcf688ded0c6 100644
--- a/include/svtools/toolboxcontroller.hxx
+++ b/include/svtools/toolboxcontroller.hxx
@@ -47,6 +47,7 @@ class ToolBox;
 
 namespace weld
 {
+    class Builder;
     class Toolbar;
 }
 
@@ -184,6 +185,7 @@ class SVT_DLLPUBLIC ToolboxController :
         css::uno::Reference< css::util::XURLTransformer >         m_xUrlTransformer;
         OUString                                                  m_sModuleName;
         weld::Toolbar*                                            m_pToolbar;
+        weld::Builder*                                            m_pBuilder;
 };
 
 }
diff --git a/include/vcl/weldutils.hxx b/include/vcl/weldutils.hxx
index dc2ca29150ac..fdc9e8cf30d6 100644
--- a/include/vcl/weldutils.hxx
+++ b/include/vcl/weldutils.hxx
@@ -27,6 +27,7 @@ class VCL_DLLPUBLIC TransportAsXWindow : public TransportAsXWindow_Base
 private:
     osl::Mutex m_aHelperMtx;
     weld::Widget* m_pWeldWidget;
+    weld::Builder* m_pWeldWidgetBuilder;
 
     comphelper::OInterfaceContainerHelper2 m_aWindowListeners;
     comphelper::OInterfaceContainerHelper2 m_aKeyListeners;
@@ -36,9 +37,10 @@ private:
     comphelper::OInterfaceContainerHelper2 m_aPaintListeners;
 
 public:
-    TransportAsXWindow(weld::Widget* pWeldWidget)
+    TransportAsXWindow(weld::Widget* pWeldWidget, weld::Builder* pWeldWidgetBuilder = nullptr)
         : TransportAsXWindow_Base(m_aHelperMtx)
         , m_pWeldWidget(pWeldWidget)
+        , m_pWeldWidgetBuilder(pWeldWidgetBuilder)
         , m_aWindowListeners(m_aHelperMtx)
         , m_aKeyListeners(m_aHelperMtx)
         , m_aFocusListeners(m_aHelperMtx)
@@ -50,7 +52,13 @@ public:
 
     weld::Widget* getWidget() const { return m_pWeldWidget; }
 
-    virtual void clear() { m_pWeldWidget = nullptr; }
+    weld::Builder* getBuilder() const { return m_pWeldWidgetBuilder; }
+
+    virtual void clear()
+    {
+        m_pWeldWidget = nullptr;
+        m_pWeldWidgetBuilder = nullptr;
+    }
 
     // css::awt::XWindow
     void SAL_CALL setPosSize(sal_Int32, sal_Int32, sal_Int32, sal_Int32, sal_Int16) override
diff --git a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
index f5c8f7e4955b..25ad4f1a131b 100644
--- a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
+++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
@@ -58,13 +58,13 @@ AlignmentPropertyPanel::AlignmentPropertyPanel(
     , mxCBStacked(m_xBuilder->weld_check_button("stacked"))
     , mxTextOrientBox(m_xBuilder->weld_widget("textorientbox"))
     , mxHorizontalAlign(m_xBuilder->weld_toolbar("horizontalalignment"))
-    , mxHorizontalAlignDispatch(new ToolbarUnoDispatcher(*mxHorizontalAlign, rxFrame))
+    , mxHorizontalAlignDispatch(new ToolbarUnoDispatcher(*mxHorizontalAlign, *m_xBuilder, rxFrame))
     , mxVertAlign(m_xBuilder->weld_toolbar("verticalalignment"))
-    , mxVertAlignDispatch(new ToolbarUnoDispatcher(*mxVertAlign, rxFrame))
+    , mxVertAlignDispatch(new ToolbarUnoDispatcher(*mxVertAlign, *m_xBuilder, rxFrame))
     , mxWriteDirection(m_xBuilder->weld_toolbar("writedirection"))
-    , mxWriteDirectionDispatch(new ToolbarUnoDispatcher(*mxWriteDirection, rxFrame))
+    , mxWriteDirectionDispatch(new ToolbarUnoDispatcher(*mxWriteDirection, *m_xBuilder, rxFrame))
     , mxIndentButtons(m_xBuilder->weld_toolbar("indentbuttons"))
-    , mxIndentButtonsDispatch(new ToolbarUnoDispatcher(*mxIndentButtons, rxFrame))
+    , mxIndentButtonsDispatch(new ToolbarUnoDispatcher(*mxIndentButtons, *m_xBuilder, rxFrame))
     , maAlignHorControl(SID_H_ALIGNCELL, *pBindings, *this)
     , maLeftIndentControl(SID_ATTR_ALIGN_INDENT, *pBindings, *this)
     , maMergeCellControl(FID_MERGE_TOGGLE, *pBindings, *this)
diff --git a/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx b/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx
index b7e04177dc1a..b3669f5ce786 100644
--- a/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx
+++ b/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx
@@ -51,10 +51,10 @@ CellAppearancePropertyPanel::CellAppearancePropertyPanel(
 
     mxTBCellBorder(m_xBuilder->weld_toolbar("cellbordertype")),
     mxTBCellBackground(m_xBuilder->weld_toolbar("cellbackgroundcolor")),
-    mxBackColorDispatch(new ToolbarUnoDispatcher(*mxTBCellBackground, rxFrame)),
+    mxBackColorDispatch(new ToolbarUnoDispatcher(*mxTBCellBackground, *m_xBuilder, rxFrame)),
     mxTBLineStyle(m_xBuilder->weld_toolbar("borderlinestyle")),
     mxTBLineColor(m_xBuilder->weld_toolbar("borderlinecolor")),
-    mxLineColorDispatch(new ToolbarUnoDispatcher(*mxTBLineColor, rxFrame)),
+    mxLineColorDispatch(new ToolbarUnoDispatcher(*mxTBLineColor, *m_xBuilder, rxFrame)),
 
     mbCellBorderPopoverCreated(false),
     mbLinePopoverCreated(false),
diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
index 653a6494c2b5..ec9e665287b2 100644
--- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
+++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
@@ -37,7 +37,7 @@ NumberFormatPropertyPanel::NumberFormatPropertyPanel(
     : PanelLayout(pParent,"NumberFormatPropertyPanel", "modules/scalc/ui/sidebarnumberformat.ui", rxFrame, true)
     , mxLbCategory(m_xBuilder->weld_combo_box("category"))
     , mxTBCategory(m_xBuilder->weld_toolbar("numberformat"))
-    , mxCatagoryDispatch(new ToolbarUnoDispatcher(*mxTBCategory, rxFrame))
+    , mxCatagoryDispatch(new ToolbarUnoDispatcher(*mxTBCategory, *m_xBuilder, rxFrame))
     , mxFtDecimals(m_xBuilder->weld_label("decimalplaceslabel"))
     , mxEdDecimals(m_xBuilder->weld_spin_button("decimalplaces"))
     , mxFtDenominator(m_xBuilder->weld_label("denominatorplaceslabel"))
diff --git a/sfx2/inc/sidebar/ControllerFactory.hxx b/sfx2/inc/sidebar/ControllerFactory.hxx
index 66c3e432aebc..5bfc138c8e70 100644
--- a/sfx2/inc/sidebar/ControllerFactory.hxx
+++ b/sfx2/inc/sidebar/ControllerFactory.hxx
@@ -28,7 +28,10 @@ namespace com::sun::star::frame { class XToolbarController; }
 
 class ToolBox;
 
-namespace weld { class Toolbar; }
+namespace weld {
+    class Builder;
+    class Toolbar;
+}
 
 namespace sfx2 { namespace sidebar {
 
@@ -48,6 +51,7 @@ public:
 
     static css::uno::Reference<css::frame::XToolbarController> CreateToolBoxController(
         weld::Toolbar& rToolbar,
+        weld::Builder& rBuilder,
         const OUString& rsCommandName,
         const css::uno::Reference<css::frame::XFrame>& rxFrame);
 
diff --git a/sfx2/source/dialog/recfloat.cxx b/sfx2/source/dialog/recfloat.cxx
index 28073a3130b9..18833ea5edfa 100644
--- a/sfx2/source/dialog/recfloat.cxx
+++ b/sfx2/source/dialog/recfloat.cxx
@@ -100,7 +100,7 @@ SfxRecordingFloat_Impl::SfxRecordingFloat_Impl(SfxBindings* pBind, SfxChildWindo
     : SfxModelessDialogController(pBind, pChildWin, pParent, "sfx/ui/floatingrecord.ui",
                                   "FloatingRecord")
     , m_xToolbar(m_xBuilder->weld_toolbar("toolbar"))
-    , m_xDispatcher(new ToolbarUnoDispatcher(*m_xToolbar, pBind->GetActiveFrame()))
+    , m_xDispatcher(new ToolbarUnoDispatcher(*m_xToolbar, *m_xBuilder, pBind->GetActiveFrame()))
 {
     // start recording
     SfxBoolItem aItem( SID_RECORDMACRO, true );
diff --git a/sfx2/source/sidebar/ControllerFactory.cxx b/sfx2/source/sidebar/ControllerFactory.cxx
index ef07c0827f7b..71d5a3649007 100644
--- a/sfx2/source/sidebar/ControllerFactory.cxx
+++ b/sfx2/source/sidebar/ControllerFactory.cxx
@@ -139,11 +139,11 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController(
 }
 
 Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController(
-    weld::Toolbar& rToolbar,
+    weld::Toolbar& rToolbar, weld::Builder& rBuilder,
     const OUString& rsCommandName,
     const Reference<frame::XFrame>& rxFrame)
 {
-    css::uno::Reference<css::awt::XWindow> xWidget(new weld::TransportAsXWindow(&rToolbar));
+    css::uno::Reference<css::awt::XWindow> xWidget(new weld::TransportAsXWindow(&rToolbar, &rBuilder));
 
     Reference<frame::XToolbarController> xController(
         CreateToolBarController(
@@ -188,6 +188,8 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController(
 
     if (xController.is())
     {
+        xController->createItemWindow(xWidget);
+
         Reference<util::XUpdatable> xUpdatable(xController, UNO_QUERY);
         if (xUpdatable.is())
             xUpdatable->update();
diff --git a/sfx2/source/toolbox/weldutils.cxx b/sfx2/source/toolbox/weldutils.cxx
index 1be8559d4d87..c35f9047cf20 100644
--- a/sfx2/source/toolbox/weldutils.cxx
+++ b/sfx2/source/toolbox/weldutils.cxx
@@ -71,10 +71,11 @@ vcl::ImageType ToolbarUnoDispatcher::GetIconSize() const
     return eType;
 }
 
-ToolbarUnoDispatcher::ToolbarUnoDispatcher(weld::Toolbar& rToolbar,
+ToolbarUnoDispatcher::ToolbarUnoDispatcher(weld::Toolbar& rToolbar, weld::Builder& rBuilder,
                                            const css::uno::Reference<css::frame::XFrame>& rFrame)
     : m_xFrame(rFrame)
     , m_pToolbar(&rToolbar)
+    , m_pBuilder(&rBuilder)
 {
     rToolbar.connect_clicked(LINK(this, ToolbarUnoDispatcher, SelectHdl));
     rToolbar.connect_menu_toggled(LINK(this, ToolbarUnoDispatcher, ToggleMenuHdl));
@@ -112,7 +113,8 @@ ToolbarUnoDispatcher::ToolbarUnoDispatcher(weld::Toolbar& rToolbar,
 void ToolbarUnoDispatcher::CreateController(const OUString& rCommand)
 {
     css::uno::Reference<css::frame::XToolbarController> xController(
-        sfx2::sidebar::ControllerFactory::CreateToolBoxController(*m_pToolbar, rCommand, m_xFrame));
+        sfx2::sidebar::ControllerFactory::CreateToolBoxController(*m_pToolbar, *m_pBuilder,
+                                                                  rCommand, m_xFrame));
 
     if (xController.is())
         maControllers.insert(std::make_pair(rCommand, xController));
@@ -190,6 +192,7 @@ void ToolbarUnoDispatcher::dispose()
 
     m_pToolbar->connect_clicked(Link<const OString&, void>());
     m_pToolbar = nullptr;
+    m_pBuilder = nullptr;
 }
 
 ToolbarUnoDispatcher::~ToolbarUnoDispatcher() { dispose(); }
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 3de9010b05b0..1d5f5913fdcc 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -15343,7 +15343,6 @@ sw/source/uibase/app/swdllimpl.hxx
 sw/source/uibase/app/swmodul1.cxx
 sw/source/uibase/app/swmodule.cxx
 sw/source/uibase/app/swwait.cxx
-sw/source/uibase/cctrl/actctrl.cxx
 sw/source/uibase/chrdlg/ccoll.cxx
 sw/source/uibase/config/StoredChapterNumbering.cxx
 sw/source/uibase/config/barcfg.cxx
@@ -15424,7 +15423,6 @@ sw/source/uibase/inc/SidebarWindowsConsts.hxx
 sw/source/uibase/inc/SwSpellDialogChildWindow.hxx
 sw/source/uibase/inc/SwXFilterOptions.hxx
 sw/source/uibase/inc/abstract.hxx
-sw/source/uibase/inc/actctrl.hxx
 sw/source/uibase/inc/annotsh.hxx
 sw/source/uibase/inc/ascfldlg.hxx
 sw/source/uibase/inc/barcfg.hxx
diff --git a/solenv/sanitizers/ui/modules/swriter.suppr b/solenv/sanitizers/ui/modules/swriter.suppr
index b9ebbdae2f9d..004fce187e42 100644
--- a/solenv/sanitizers/ui/modules/swriter.suppr
+++ b/solenv/sanitizers/ui/modules/swriter.suppr
@@ -161,6 +161,8 @@ sw/uiconfig/swriter/ui/mmsendmails.ui://GtkProgressBar[@id='progress'] no-labell
 sw/uiconfig/swriter/ui/mmsendmails.ui://GtkLabel[@id='errorstatus'] orphan-label
 sw/uiconfig/swriter/ui/mmsalutationpage.ui://GtkLabel[@id='documentindex'] orphan-label
 sw/uiconfig/swriter/ui/mmsalutationpage.ui://GtkLabel[@id='femalefi'] orphan-label
+sw/uiconfig/swriter/ui/navigatorcontextmenu.ui://GtkMenuItem[@id='800'] button-no-label
+sw/uiconfig/swriter/ui/navigatorpanel.ui://GtkSpinButton[@id='spinbutton'] no-labelled-by
 sw/uiconfig/swriter/ui/notebookbar_groups.ui://GtkLabel[@id='filegrouplabel'] orphan-label
 sw/uiconfig/swriter/ui/notebookbar_groups.ui://GtkLabel[@id='clipboardgrouplabel'] orphan-label
 sw/uiconfig/swriter/ui/notebookbar_groups.ui://GtkLabel[@id='formatgrouplabel'] orphan-label
@@ -195,7 +197,6 @@ sw/uiconfig/swriter/ui/selectaddressdialog.ui://GtkLabel[@id='connecting'] orpha
 sw/uiconfig/swriter/ui/selecttabledialog.ui://GtkLabel[@id='select'] orphan-label
 sw/uiconfig/swriter/ui/spellmenu.ui://GtkMenuItem[@id='spelldialog'] button-no-label
 sw/uiconfig/swriter/ui/spellmenu.ui://GtkMenuItem[@id='correctdialog'] button-no-label
-sw/uiconfig/swriter/ui/spinbox.ui://GtkSpinButton[@id='spin'] no-labelled-by
 sw/uiconfig/swriter/ui/statisticsinfopage.ui://GtkLabel[@id='nopages'] orphan-label
 sw/uiconfig/swriter/ui/statisticsinfopage.ui://GtkLabel[@id='notables'] orphan-label
 sw/uiconfig/swriter/ui/statisticsinfopage.ui://GtkLabel[@id='nogrfs'] orphan-label
diff --git a/svtools/source/uno/toolboxcontroller.cxx b/svtools/source/uno/toolboxcontroller.cxx
index 3ff118f31bb5..2c0292b26565 100644
--- a/svtools/source/uno/toolboxcontroller.cxx
+++ b/svtools/source/uno/toolboxcontroller.cxx
@@ -62,6 +62,7 @@ ToolboxController::ToolboxController(
     ,   m_aCommandURL( aCommandURL )
     ,   m_aListenerContainer( m_aMutex )
     ,   m_pToolbar(nullptr)
+    ,   m_pBuilder(nullptr)
 {
     OSL_ASSERT( m_xContext.is() );
     registerProperty( TOOLBARCONTROLLER_PROPNAME_SUPPORTSVISIBLE,
@@ -87,6 +88,7 @@ ToolboxController::ToolboxController() :
     ,   m_nToolBoxId( SAL_MAX_UINT16 )
     ,   m_aListenerContainer( m_aMutex )
     ,   m_pToolbar(nullptr)
+    ,   m_pBuilder(nullptr)
 {
     registerProperty( TOOLBARCONTROLLER_PROPNAME_SUPPORTSVISIBLE,
         TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIBLE,
@@ -217,6 +219,7 @@ void SAL_CALL ToolboxController::initialize( const Sequence< Any >& aArguments )
     {
         m_pToolbar = dynamic_cast<weld::Toolbar*>(pTunnel->getWidget());
         assert(m_pToolbar && "must be a toolbar");
+        m_pBuilder = pTunnel->getBuilder();
     }
 }
 
diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx
index c061aa742452..f63196c37e2a 100644
--- a/svx/source/dialog/dlgctrl.cxx
+++ b/svx/source/dialog/dlgctrl.cxx
@@ -1447,7 +1447,7 @@ void padWidthForSidebar(weld::Toolbar& rToolbar, const css::uno::Reference<css::
         // of a "standard" column in a two column panel
         std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(&rToolbar, "svx/ui/measurewidthbar.ui"));
         std::unique_ptr<weld::Toolbar> xToolbar(xBuilder->weld_toolbar("measurewidth"));
-        std::unique_ptr<ToolbarUnoDispatcher> xDispatcher(new ToolbarUnoDispatcher(*xToolbar, rFrame));
+        std::unique_ptr<ToolbarUnoDispatcher> xDispatcher(new ToolbarUnoDispatcher(*xToolbar, *xBuilder, rFrame));
         nColumnWidth = xToolbar->get_preferred_size().Width();
         eSize = rToolbar.get_icon_size();
     }
diff --git a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
index a08ea54e78fc..270b29be96a2 100644
--- a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
+++ b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
@@ -79,7 +79,7 @@ AreaPropertyPanelBase::AreaPropertyPanelBase(
       mxLbFillGradFrom(new ColorListBox(m_xBuilder->weld_menu_button("fillgrad1"), GetFrameWeld())),
       mxLbFillGradTo(new ColorListBox(m_xBuilder->weld_menu_button("fillgrad2"), GetFrameWeld())),
       mxToolBoxColor(m_xBuilder->weld_toolbar("selectcolor")),
-      mxColorDispatch(new ToolbarUnoDispatcher(*mxToolBoxColor, rxFrame)),
+      mxColorDispatch(new ToolbarUnoDispatcher(*mxToolBoxColor, *m_xBuilder, rxFrame)),
       mxTrspTextFT(m_xBuilder->weld_label("transparencylabel")),
       mxLBTransType(m_xBuilder->weld_combo_box("transtype")),
       mxMTRTransparent(m_xBuilder->weld_metric_spin_button("settransparency", FieldUnit::PERCENT)),
diff --git a/svx/source/sidebar/line/LinePropertyPanelBase.cxx b/svx/source/sidebar/line/LinePropertyPanelBase.cxx
index fe7ff32ea3f4..bdb776decf61 100644
--- a/svx/source/sidebar/line/LinePropertyPanelBase.cxx
+++ b/svx/source/sidebar/line/LinePropertyPanelBase.cxx
@@ -75,9 +75,9 @@ LinePropertyPanelBase::LinePropertyPanelBase(
     const uno::Reference<css::frame::XFrame>& rxFrame)
 :   PanelLayout(pParent, "LinePropertyPanel", "svx/ui/sidebarline.ui", rxFrame, true),
     mxTBColor(m_xBuilder->weld_toolbar("color")),
-    mxColorDispatch(new ToolbarUnoDispatcher(*mxTBColor, rxFrame)),
+    mxColorDispatch(new ToolbarUnoDispatcher(*mxTBColor, *m_xBuilder, rxFrame)),
     mxLineStyleTB(m_xBuilder->weld_toolbar("linestyle")),
-    mxLineStyleDispatch(new ToolbarUnoDispatcher(*mxLineStyleTB, rxFrame)),
+    mxLineStyleDispatch(new ToolbarUnoDispatcher(*mxLineStyleTB, *m_xBuilder, rxFrame)),
     mxFTWidth(m_xBuilder->weld_label("widthlabel")),
     mxTBWidth(m_xBuilder->weld_toolbar("width")),
     mxFTTransparency(m_xBuilder->weld_label("translabel")),
diff --git a/svx/source/sidebar/lists/ListsPropertyPanel.cxx b/svx/source/sidebar/lists/ListsPropertyPanel.cxx
index e82c3adfa274..cf9d94cc42bd 100644
--- a/svx/source/sidebar/lists/ListsPropertyPanel.cxx
+++ b/svx/source/sidebar/lists/ListsPropertyPanel.cxx
@@ -42,9 +42,9 @@ ListsPropertyPanel::ListsPropertyPanel(vcl::Window* pParent,
                                        const css::uno::Reference<css::frame::XFrame>& rxFrame)
     : PanelLayout(pParent, "ListsPropertyPanel", "svx/ui/sidebarlists.ui", rxFrame, true)
     , mxTBxNumBullet(m_xBuilder->weld_toolbar("numberbullet"))
-    , mxNumBulletDispatcher(new ToolbarUnoDispatcher(*mxTBxNumBullet, rxFrame))
+    , mxNumBulletDispatcher(new ToolbarUnoDispatcher(*mxTBxNumBullet, *m_xBuilder, rxFrame))
     , mxTBxOutline(m_xBuilder->weld_toolbar("outline"))
-    , mxOutlineDispatcher(new ToolbarUnoDispatcher(*mxTBxOutline, rxFrame))
+    , mxOutlineDispatcher(new ToolbarUnoDispatcher(*mxTBxOutline, *m_xBuilder, rxFrame))
 {
 }
 
diff --git a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
index 75d376eb2dd6..dd39f050d4bd 100644
--- a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
+++ b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
@@ -406,22 +406,22 @@ ParaPropertyPanel::ParaPropertyPanel(vcl::Window* pParent,
     : PanelLayout(pParent, "ParaPropertyPanel", "svx/ui/sidebarparagraph.ui", rxFrame, true),
       //Alignment
       mxTBxHorzAlign(m_xBuilder->weld_toolbar("horizontalalignment")),
-      mxHorzAlignDispatch(new ToolbarUnoDispatcher(*mxTBxHorzAlign, rxFrame)),
+      mxHorzAlignDispatch(new ToolbarUnoDispatcher(*mxTBxHorzAlign, *m_xBuilder, rxFrame)),
       mxTBxVertAlign(m_xBuilder->weld_toolbar("verticalalignment")),
-      mxVertAlignDispatch(new ToolbarUnoDispatcher(*mxTBxVertAlign, rxFrame)),
+      mxVertAlignDispatch(new ToolbarUnoDispatcher(*mxTBxVertAlign, *m_xBuilder, rxFrame)),
       //NumBullet&Backcolor
       mxTBxNumBullet(m_xBuilder->weld_toolbar("numberbullet")),
-      mxNumBulletDispatch(new ToolbarUnoDispatcher(*mxTBxNumBullet, rxFrame)),
+      mxNumBulletDispatch(new ToolbarUnoDispatcher(*mxTBxNumBullet, *m_xBuilder, rxFrame)),
       mxTBxBackColor(m_xBuilder->weld_toolbar("backgroundcolor")),
-      mxBackColorDispatch(new ToolbarUnoDispatcher(*mxTBxBackColor, rxFrame)),
+      mxBackColorDispatch(new ToolbarUnoDispatcher(*mxTBxBackColor, *m_xBuilder, rxFrame)),
       mxTBxWriteDirection(m_xBuilder->weld_toolbar("writedirection")),
-      mxWriteDirectionDispatch(new ToolbarUnoDispatcher(*mxTBxWriteDirection, rxFrame)),
+      mxWriteDirectionDispatch(new ToolbarUnoDispatcher(*mxTBxWriteDirection, *m_xBuilder, rxFrame)),
       mxTBxParaSpacing(m_xBuilder->weld_toolbar("paraspacing")),
-      mxParaSpacingDispatch(new ToolbarUnoDispatcher(*mxTBxParaSpacing, rxFrame)),
+      mxParaSpacingDispatch(new ToolbarUnoDispatcher(*mxTBxParaSpacing, *m_xBuilder, rxFrame)),
       mxTBxLineSpacing(m_xBuilder->weld_toolbar("linespacing")),
-      mxLineSpacingDispatch(new ToolbarUnoDispatcher(*mxTBxLineSpacing, rxFrame)),
+      mxLineSpacingDispatch(new ToolbarUnoDispatcher(*mxTBxLineSpacing, *m_xBuilder, rxFrame)),
       mxTBxIndent(m_xBuilder->weld_toolbar("indent")),
-      mxIndentDispatch(new ToolbarUnoDispatcher(*mxTBxIndent, rxFrame)),
+      mxIndentDispatch(new ToolbarUnoDispatcher(*mxTBxIndent, *m_xBuilder, rxFrame)),
       //Paragraph spacing
       mxTopDist(new SvxRelativeField(m_xBuilder->weld_metric_spin_button("aboveparaspacing", FieldUnit::CM))),
       mxBottomDist(new SvxRelativeField(m_xBuilder->weld_metric_spin_button("belowparaspacing", FieldUnit::CM))),
diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
index 18be1aa4d2c5..0f0697a40452 100644
--- a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
+++ b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
@@ -70,9 +70,9 @@ PosSizePropertyPanel::PosSizePropertyPanel(
     mxDial(new weld::CustomWeld(*m_xBuilder, "orientationcontrol", *mxCtrlDial)),
     mxFtFlip(m_xBuilder->weld_label("fliplabel")),
     mxFlipTbx(m_xBuilder->weld_toolbar("selectrotationtype")),
-    mxFlipDispatch(new ToolbarUnoDispatcher(*mxFlipTbx, rxFrame)),
+    mxFlipDispatch(new ToolbarUnoDispatcher(*mxFlipTbx, *m_xBuilder, rxFrame)),
     mxArrangeTbx(m_xBuilder->weld_toolbar("arrangetoolbar")),
-    mxArrangeDispatch(new ToolbarUnoDispatcher(*mxArrangeTbx, rxFrame)),
+    mxArrangeDispatch(new ToolbarUnoDispatcher(*mxArrangeTbx, *m_xBuilder, rxFrame)),
     mxBtnEditChart(m_xBuilder->weld_button("btnEditChart")),
     maRect(),
     mpView(nullptr),
diff --git a/svx/source/tbxctrls/fillctrl.cxx b/svx/source/tbxctrls/fillctrl.cxx
index 8ae4bf58acb5..8b1339ad3e7b 100644
--- a/svx/source/tbxctrls/fillctrl.cxx
+++ b/svx/source/tbxctrls/fillctrl.cxx
@@ -560,7 +560,7 @@ FillControl::FillControl(vcl::Window* pParent, const css::uno::Reference<css::fr
     : InterimItemWindow(pParent, "svx/ui/fillctrlbox.ui", "FillCtrlBox")
     , mxLbFillType(m_xBuilder->weld_combo_box("type"))
     , mxToolBoxColor(m_xBuilder->weld_toolbar("color"))
-    , mxColorDispatch(new ToolbarUnoDispatcher(*mxToolBoxColor, rFrame))
+    , mxColorDispatch(new ToolbarUnoDispatcher(*mxToolBoxColor, *m_xBuilder, rFrame))
     , mxLbFillAttr(m_xBuilder->weld_combo_box("attr"))
     , mnTypeCurPos(0)
     , mnAttrCurPos(0)
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index ec4c3ebc146e..b6d75fd890bf 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -588,7 +588,6 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/uibase/dbui/maildispatcher \
     sw/source/uibase/dbui/mailmergehelper \
     sw/source/uibase/dbui/mmconfigitem \
-    sw/source/uibase/cctrl/actctrl \
     sw/source/uibase/chrdlg/ccoll \
     sw/source/uibase/config/StoredChapterNumbering \
     sw/source/uibase/config/barcfg \
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index 872de3c9912e..ea417c9bfb65 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -209,6 +209,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
 	sw/uiconfig/swriter/ui/querysavelabeldialog \
 	sw/uiconfig/swriter/ui/mailmerge \
 	sw/uiconfig/swriter/ui/managechangessidebar \
+	sw/uiconfig/swriter/ui/mastercontextmenu \
 	sw/uiconfig/swriter/ui/mmaddressblockpage \
 	sw/uiconfig/swriter/ui/mmcreatingdialog \
 	sw/uiconfig/swriter/ui/mmlayoutpage \
@@ -220,6 +221,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
 	sw/uiconfig/swriter/ui/mmselectpage \
 	sw/uiconfig/swriter/ui/mmsendmails \
 	sw/uiconfig/swriter/ui/mmsalutationpage \
+	sw/uiconfig/swriter/ui/navigatorcontextmenu \
 	sw/uiconfig/swriter/ui/navigatorpanel \
 	sw/uiconfig/swriter/ui/notebookbar \
 	sw/uiconfig/swriter/ui/notebookbar_compact \
@@ -266,7 +268,6 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
 	sw/uiconfig/swriter/ui/sidebartableedit \
 	sw/uiconfig/swriter/ui/sidebartheme \
 	sw/uiconfig/swriter/ui/sortdialog \
-	sw/uiconfig/swriter/ui/spinbox \
 	sw/uiconfig/swriter/ui/spellmenu \
 	sw/uiconfig/swriter/ui/splittable \
 	sw/uiconfig/swriter/ui/statisticsinfopage \
diff --git a/sw/inc/pch/precompiled_msword.hxx b/sw/inc/pch/precompiled_msword.hxx
index 3e8c55bf5942..7271e76cc75c 100644
--- a/sw/inc/pch/precompiled_msword.hxx
+++ b/sw/inc/pch/precompiled_msword.hxx
@@ -13,7 +13,7 @@
  manual changes will be rewritten by the next run of update_pch.sh (which presumably
  also fixes all possible problems, so it's usually better to use it).
 
- Generated on 2020-02-17 14:43:22 using:
+ Generated on 2020-03-04 21:21:56 using:
  ./bin/update_pch sw msword --cutoff=4 --exclude:system --include:module --include:local
 
  If after updating build fails, use the following command to locate conflicting headers:
@@ -43,6 +43,7 @@
 #include <math.h>
 #include <memory>
 #include <new>
+#include <optional>
 #include <ostream>
 #include <set>
 #include <stddef.h>
@@ -55,6 +56,12 @@
 #include <unordered_set>
 #include <utility>
 #include <vector>
+#include <boost/multi_index/composite_key.hpp>
+#include <boost/multi_index/identity.hpp>
+#include <boost/multi_index/mem_fun.hpp>
+#include <boost/multi_index/ordered_index.hpp>
+#include <boost/multi_index/random_access_index.hpp>
+#include <boost/multi_index_container.hpp>
 #include <boost/property_tree/ptree_fwd.hpp>
 #endif // PCH_LEVEL >= 1
 #if PCH_LEVEL >= 2
@@ -340,7 +347,6 @@
 #include <i18nutil/transliteration.hxx>
 #include <o3tl/cow_wrapper.hxx>
 #include <o3tl/enumarray.hxx>
-#include <optional>
 #include <o3tl/safeint.hxx>
 #include <o3tl/sorted_vector.hxx>
 #include <o3tl/strong_int.hxx>
diff --git a/sw/inc/pch/precompiled_sw.hxx b/sw/inc/pch/precompiled_sw.hxx
index bfd07f24abad..90cb78ee1fa4 100644
--- a/sw/inc/pch/precompiled_sw.hxx
+++ b/sw/inc/pch/precompiled_sw.hxx
@@ -13,7 +13,7 @@
  manual changes will be rewritten by the next run of update_pch.sh (which presumably
  also fixes all possible problems, so it's usually better to use it).
 
- Generated on 2020-02-17 14:43:31 using:
+ Generated on 2020-03-04 21:22:05 using:
  ./bin/update_pch sw sw --cutoff=7 --exclude:system --exclude:module --include:local
 
  If after updating build fails, use the following command to locate conflicting headers:
@@ -35,6 +35,7 @@
 #include <map>
 #include <memory>
 #include <new>
+#include <optional>
 #include <ostream>
 #include <set>
 #include <stddef.h>
@@ -68,6 +69,9 @@
 #include <rtl/math.hxx>
 #include <rtl/ref.hxx>
 #include <rtl/strbuf.hxx>
+#include <rtl/string.h>
+#include <rtl/stringconcat.hxx>
+#include <rtl/stringutils.hxx>
 #include <rtl/tencinfo.h>
 #include <rtl/textenc.h>
 #include <rtl/unload.h>
@@ -103,7 +107,6 @@
 #include <vcl/imap.hxx>
 #include <vcl/imapobj.hxx>
 #include <vcl/keycod.hxx>
-#include <vcl/lstbox.hxx>
 #include <vcl/metric.hxx>
 #include <vcl/outdev.hxx>
 #include <vcl/settings.hxx>
@@ -274,7 +277,6 @@
 #include <o3tl/any.hxx>
 #include <o3tl/cow_wrapper.hxx>
 #include <o3tl/deleter.hxx>
-#include <optional>
 #include <o3tl/safeint.hxx>
 #include <o3tl/sorted_vector.hxx>
 #include <o3tl/strong_int.hxx>
@@ -365,6 +367,7 @@
 #include <svx/svdoutl.hxx>
 #include <svx/svdpage.hxx>
 #include <svx/svdpagv.hxx>
+#include <svx/svdtypes.hxx>
 #include <svx/svdview.hxx>
 #include <svx/svxdlg.hxx>
 #include <svx/svxdllapi.h>
@@ -532,6 +535,7 @@
 #include <fmtwrapinfluenceonobjpos.hxx>
 #include <fntcache.hxx>
 #include <frame.hxx>
+#include <frameformats.hxx>
 #include <frmatr.hxx>
 #include <frmfmt.hxx>
 #include <frmmgr.hxx>
diff --git a/sw/inc/pch/precompiled_swui.hxx b/sw/inc/pch/precompiled_swui.hxx
index 39909eb342bc..cc71c3c666e1 100644
--- a/sw/inc/pch/precompiled_swui.hxx
+++ b/sw/inc/pch/precompiled_swui.hxx
@@ -13,7 +13,7 @@
  manual changes will be rewritten by the next run of update_pch.sh (which presumably
  also fixes all possible problems, so it's usually better to use it).
 
- Generated on 2020-02-19 12:45:34 using:
+ Generated on 2020-03-04 21:22:13 using:
  ./bin/update_pch sw swui --cutoff=3 --exclude:system --include:module --include:local
 
  If after updating build fails, use the following command to locate conflicting headers:
@@ -40,6 +40,7 @@
 #include <math.h>
 #include <memory>
 #include <new>
+#include <optional>
 #include <ostream>
 #include <set>
 #include <stack>
@@ -52,12 +53,6 @@
 #include <unordered_map>
 #include <utility>
 #include <vector>
-#include <boost/multi_index/composite_key.hpp>
-#include <boost/multi_index/identity.hpp>
-#include <boost/multi_index/mem_fun.hpp>
-#include <boost/multi_index/ordered_index.hpp>
-#include <boost/multi_index/random_access_index.hpp>
-#include <boost/multi_index_container.hpp>
 #include <boost/property_tree/ptree_fwd.hpp>
 #endif // PCH_LEVEL >= 1
 #if PCH_LEVEL >= 2
@@ -100,6 +95,7 @@
 #include <vcl/GraphicExternalLink.hxx>
 #include <vcl/GraphicObject.hxx>
 #include <vcl/IDialogRenderable.hxx>
+#include <vcl/ITiledRenderable.hxx>
 #include <vcl/NotebookBarAddonsMerger.hxx>
 #include <vcl/Scanline.hxx>
 #include <vcl/accessibletableprovider.hxx>
@@ -312,6 +308,7 @@
 #include <com/sun/star/view/XPrintJobBroadcaster.hpp>
 #include <com/sun/star/view/XPrintable.hpp>
 #include <comphelper/comphelperdllapi.h>
+#include <comphelper/lok.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/servicehelper.hxx>
 #include <comphelper/string.hxx>
@@ -367,7 +364,6 @@
 #include <i18nutil/transliteration.hxx>
 #include <o3tl/cow_wrapper.hxx>
 #include <o3tl/deleter.hxx>
-#include <optional>
 #include <o3tl/safeint.hxx>
 #include <o3tl/sorted_vector.hxx>
 #include <o3tl/strong_int.hxx>
@@ -398,6 +394,7 @@
 #include <sfx2/shell.hxx>
 #include <sfx2/tabdlg.hxx>
 #include <sfx2/viewfrm.hxx>
+#include <sfx2/viewsh.hxx>
 #include <sot/exchange.hxx>
 #include <sot/formats.hxx>
 #include <sot/sotdllapi.h>
diff --git a/sw/inc/pch/precompiled_vbaswobj.hxx b/sw/inc/pch/precompiled_vbaswobj.hxx
index 26ed24e28f76..c32c83ecc235 100644
--- a/sw/inc/pch/precompiled_vbaswobj.hxx
+++ b/sw/inc/pch/precompiled_vbaswobj.hxx
@@ -13,7 +13,7 @@
  manual changes will be rewritten by the next run of update_pch.sh (which presumably
  also fixes all possible problems, so it's usually better to use it).
 
- Generated on 2020-02-14 09:24:51 using:
+ Generated on 2020-03-04 21:22:17 using:
  ./bin/update_pch sw vbaswobj --cutoff=4 --exclude:system --include:module --include:local
 
  If after updating build fails, use the following command to locate conflicting headers:
@@ -43,6 +43,7 @@
 #include <math.h>
 #include <memory>
 #include <new>
+#include <optional>
 #include <ostream>
 #include <set>
 #include <stack>
@@ -55,12 +56,6 @@
 #include <unordered_map>
 #include <utility>
 #include <vector>
-#include <boost/multi_index/composite_key.hpp>
-#include <boost/multi_index/identity.hpp>
-#include <boost/multi_index/mem_fun.hpp>
-#include <boost/multi_index/ordered_index.hpp>
-#include <boost/multi_index/random_access_index.hpp>
-#include <boost/multi_index_container.hpp>
 #include <boost/property_tree/ptree_fwd.hpp>
 #endif // PCH_LEVEL >= 1
 #if PCH_LEVEL >= 2
@@ -247,7 +242,6 @@
 #include <editeng/svxenum.hxx>
 #include <i18nlangtag/lang.h>
 #include <o3tl/cow_wrapper.hxx>
-#include <optional>
 #include <o3tl/sorted_vector.hxx>
 #include <o3tl/strong_int.hxx>
 #include <o3tl/typed_flags_set.hxx>
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 4b5c0d7c17c4..dfb17c43a782 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -647,12 +647,7 @@
 #define STR_OUTLINE_TRACKING_DEFAULT            NC_("STR_OUTLINE_TRACKING_DEFAULT", "Default")
 #define STR_OUTLINE_TRACKING_FOCUS              NC_("STR_OUTLINE_TRACKING_FOCUS", "Focus")
 #define STR_OUTLINE_TRACKING_OFF                NC_("STR_OUTLINE_TRACKING_OFF", "Off")
-#define STR_GOTO                                NC_("STR_GOTO", "Go to")
-#define STR_SELECT                              NC_("STR_SELECT", "Select")
-#define STR_DEMOTE_CHAPTER                      NC_("STR_DEMOTE_CHAPTER", "Demote Chapter")
-#define STR_PROMOTE_CHAPTER                     NC_("STR_PROMOTE_CHAPTER", "Promote Chapter")
-#define STR_DEMOTE_LEVEL                        NC_("STR_DEMOTE_LEVEL", "Demote Level")
-#define STR_PROMOTE_LEVEL                       NC_("STR_PROMOTE_LEVEL", "Promote Level")
+
 #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")
@@ -678,15 +673,10 @@
 #define STR_UPDATE_INDEX                        NC_("STR_UPDATE_INDEX", "Indexes")
 #define STR_UPDATE_LINK                         NC_("STR_UPDATE_LINK", "Links")
 #define STR_UPDATE_ALL                          NC_("STR_UPDATE_ALL", "All")
-#define STR_REMOVE_INDEX                        NC_("STR_REMOVE_INDEX", "~Remove Index")
-#define STR_REMOVE_TBL_PROTECTION               NC_("STR_REMOVE_TBL_PROTECTION", "~Unprotect")
+
 #define STR_INVISIBLE                           NC_("STR_INVISIBLE", "hidden")
 #define STR_BROKEN_LINK                         NC_("STR_BROKEN_LINK", "File not found: ")
-#define STR_RENAME                              NC_("STR_RENAME", "~Rename...")
-#define STR_READONLY_IDX                        NC_("STR_READONLY_IDX", "Read-~only")
-#define STR_POSTIT_SHOW                         NC_("STR_POSTIT_SHOW", "Show All")
-#define STR_POSTIT_HIDE                         NC_("STR_POSTIT_HIDE", "Hide All")
-#define STR_POSTIT_DELETE                       NC_("STR_POSTIT_DELETE", "Delete All")
+
 #define STR_RESOLVED                            NC_("STR_RESOLVED", "RESOLVED")
 #define STR_PROTECTED                           NC_("STR_PROTECTED", "Protected")
 
diff --git a/sw/source/uibase/cctrl/actctrl.cxx b/sw/source/uibase/cctrl/actctrl.cxx
deleted file mode 100644
index 62bfe65e7d66..000000000000
--- a/sw/source/uibase/cctrl/actctrl.cxx
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <actctrl.hxx>
-#include <vcl/event.hxx>
-#include <vcl/toolbox.hxx>
-
-NumEditAction::NumEditAction(vcl::Window* pParent)
-    : InterimItemWindow(pParent, "modules/swriter/ui/spinbox.ui", "SpinBox")
-    , m_xWidget(m_xBuilder->weld_spin_button("spin"))
-{
-    m_xWidget->connect_key_press(LINK(this, NumEditAction, KeyInputHdl));
-    limitWidth();
-    SetSizePixel(m_xContainer->get_preferred_size());
-}
-
-void NumEditAction::limitWidth()
-{
-    m_xWidget->set_width_chars(3);
-}
-
-void NumEditAction::set_max(int nMax)
-{
-    m_xWidget->set_max(nMax);
-    limitWidth();
-}
-
-IMPL_LINK(NumEditAction, KeyInputHdl, const KeyEvent&, rKEvt, bool)
-{
-    return ChildKeyInput(rKEvt);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/actctrl.hxx b/sw/source/uibase/inc/actctrl.hxx
deleted file mode 100644
index fdb2feb7109b..000000000000
--- a/sw/source/uibase/inc/actctrl.hxx
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_ACTCTRL_HXX
-#define INCLUDED_SW_SOURCE_UIBASE_INC_ACTCTRL_HXX
-
-#include <sfx2/InterimItemWindow.hxx>
-#include <vcl/weld.hxx>
-#include <swdllapi.h>
-
-// numerical input
-class NumEditAction final : public InterimItemWindow
-{
-private:
-    std::unique_ptr<weld::SpinButton> m_xWidget;
-
-    DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
-
-public:
-    NumEditAction(vcl::Window* pParent);
-
-    virtual void dispose() override
-    {
-        m_xWidget.reset();
-        InterimItemWindow::dispose();
-    }
-
-    virtual ~NumEditAction() override
-    {
-        disposeOnce();
-    }
-
-    virtual void GetFocus() override
-    {
-        if (m_xWidget)
-            m_xWidget->grab_focus();
-        InterimItemWindow::GetFocus();
-    }
-
-    void connect_value_changed(const Link<weld::SpinButton&, void>& rLink)
-    {
-        m_xWidget->connect_value_changed(rLink);
-    }
-
-    int get_value() const
-    {
-        return m_xWidget->get_value();
-    }
-
-    void set_value(int nValue)
-    {
-        m_xWidget->set_value(nValue);
-    }
-
-    void set_accessible_name(const OUString& rName)
-    {
-        m_xWidget->set_accessible_name(rName);
-    }
-
-    void set_max(int nMax);
-
-    void limitWidth();
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx
index 3cb48bc804d2..8df62857115f 100644
--- a/sw/source/uibase/inc/conttree.hxx
+++ b/sw/source/uibase/inc/conttree.hxx
@@ -20,8 +20,7 @@
 #define INCLUDED_SW_SOURCE_UIBASE_INC_CONTTREE_HXX
 
 #include <svl/lstner.hxx>
-#include <vcl/treelistbox.hxx>
-#include <vcl/svlbitm.hxx>
+#include <ndarr.hxx>
 #include "swcont.hxx"
 
 #include <map>
@@ -67,11 +66,25 @@ namespace o3tl {
     template<> struct typed_flags<MenuEnableFlags> : is_typed_flags<MenuEnableFlags, 0x00ff> {};
 }
 
+class SwContentTree;
+
+class SwContentTreeDropTarget : public DropTargetHelper
+{
+private:
+    SwContentTree& m_rTreeView;
+
+    virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
+    virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
+
+public:
+    SwContentTreeDropTarget(SwContentTree& rTreeView);
+};
+
 /** TreeListBox for content indicator */
-class SwContentTree final
-    : public SvTreeListBox
-    , public SfxListener
+class SwContentTree final : public SfxListener
 {
+    std::unique_ptr<weld::TreeView> m_xTreeView;
+    SwContentTreeDropTarget m_aDropTargetHelper;
     VclPtr<SwNavigationPI> m_xDialog;
     OUString            m_sSpace;
     AutoTimer           m_aUpdTimer;
@@ -79,16 +92,7 @@ class SwContentTree final
     o3tl::enumarray<ContentTypeId,std::unique_ptr<SwContentType>>  m_aActiveContentArr;
     o3tl::enumarray<ContentTypeId,std::unique_ptr<SwContentType>>  m_aHiddenContentArr;
     OUString            m_aContextStrings[CONTEXT_COUNT + 1];
-    OUString            m_sRemoveIdx;
-    OUString            m_sUpdateIdx;
-    OUString            m_sUnprotTable;
-    OUString            m_sRename;
-    OUString            m_sReadonlyIdx;
     OUString            m_sInvisible;
-    OUString            m_sPostItShow;
-    OUString            m_sPostItHide;
-    OUString            m_sPostItDelete;
-    OUString            m_sProtected;
 
     SwWrtShell*         m_pHiddenShell;   // dropped Doc
     SwWrtShell*         m_pActiveShell;   // the active or a const. open view
@@ -98,6 +102,7 @@ class SwContentTree final
 
     sal_Int32           m_nActiveBlock;
     sal_Int32           m_nHiddenBlock;
+    size_t              m_nEntryCount;
     ContentTypeId       m_nRootType;
     ContentTypeId       m_nLastSelType;
     sal_uInt8           m_nOutlineLevel;
@@ -107,20 +112,14 @@ class SwContentTree final
     enum class State { ACTIVE, CONSTANT, HIDDEN } m_eState;
 
     bool                m_bDocChgdInDragging  :1;
-    bool                m_bIsInternalDrag     :1;
     bool                m_bIsRoot             :1;
     bool                m_bIsIdleClear        :1;
     bool                m_bIsLastReadOnly     :1;
     bool                m_bIsOutlineMoveable  :1;
     bool                m_bViewHasChanged     :1;
 
-    static bool         bIsInDrag;
-
-    bool                m_bIsKeySpace;
-    tools::Rectangle           m_aOldRectangle;
-
     // outline root mode drag & drop
-    std::vector< SvTreeListEntry* > m_aDndOutlinesSelected;
+    std::vector<std::unique_ptr<weld::TreeIter>> m_aDndOutlinesSelected;
 
     bool m_bIsInPromoteDemote = false;
 
@@ -130,60 +129,57 @@ class SwContentTree final
      */
     void                FindActiveTypeAndRemoveUserData();
 
-    using SvTreeListBox::ExecuteDrop;
-    using SvTreeListBox::EditEntry;
+    void insert(const weld::TreeIter* pParent, const OUString& rStr, const OUString& rId,
+                const OUString* pExpanderName, bool bChildrenOnDemand, weld::TreeIter* pRet);
 
-    virtual void    RequestHelp( const HelpEvent& rHEvt ) override;
-    virtual void    InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&) override;
-    virtual void    DataChanged( const DataChangedEvent& rDCEvt ) override;
+    void remove(const weld::TreeIter& rIter);
 
     SwNavigationPI* GetParentWindow();
 
-    virtual void    StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override;
-    virtual void    DragFinished( sal_Int8 ) override;
-    virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
-
-    virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
-
     bool        FillTransferData( TransferDataContainer& rTransfer,
                                             sal_Int8& rDragMode );
 
     /** Check if the displayed content is valid. */
     bool            HasContentChanged();
 
-    virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
-                                        SvTreeListEntry* ) override;
-    virtual bool    NotifyAcceptDrop( SvTreeListEntry* ) override;
-
-    virtual TriState NotifyMoving(   SvTreeListEntry*  pTarget,
-                                    SvTreeListEntry*  pEntry,
-                                    SvTreeListEntry*& rpNewParent,
-                                    sal_uLong&        rNewChildPos
-                                ) override;
-    virtual TriState NotifyCopying(  SvTreeListEntry*  pTarget,
-                                    SvTreeListEntry*  pEntry,
-                                    SvTreeListEntry*& rpNewParent,
-                                    sal_uLong&        rNewChildPos
-                                ) override;
-    virtual void    Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
-    virtual void    MouseButtonDown( const MouseEvent& rMEvt ) override;
-
-    void            EditEntry( SvTreeListEntry const * pEntry, EditEntryMode nMode );
+    size_t          GetAbsPos(const weld::TreeIter& rIter);
+
+    void            EditEntry(const weld::TreeIter& rEntry, EditEntryMode nMode);
 
     void            GotoContent(const SwContent* pCnt);
-    static void     SetInDrag(bool bSet) {bIsInDrag = bSet;}
 
-    virtual VclPtr<PopupMenu> CreateContextMenu() override;
-    virtual void    ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) override;
+    void            ExecuteContextMenuAction(const OString& rSelectedPopupEntry);
 
     void DeleteOutlineSelections();
 
+    size_t GetEntryCount() const;
+
+    size_t GetChildCount(const weld::TreeIter& rParent) const;
+
+    std::unique_ptr<weld::TreeIter> GetEntryAtAbsPos(size_t nAbsPos) const;
+
+    void Expand(const weld::TreeIter& rParent, std::vector<std::unique_ptr<weld::TreeIter>>* pNodesToExpand);
+
+    void MoveOutline(SwOutlineNodes::size_type nTargetPos);
+
+    void UpdateLastSelType();
+
+    /** Expand - Remember the state for content types */
+    DECL_LINK(ExpandHdl, const weld::TreeIter&, bool);
+    /** Collapse - Remember the state for content types. */
+    DECL_LINK(CollapseHdl, const weld::TreeIter&, bool);
+    DECL_LINK(ContentDoubleClickHdl, weld::TreeView&, bool);
+    DECL_LINK(SelectHdl, weld::TreeView&, void);
+    DECL_LINK(FocusHdl, weld::Widget&, void);
+    DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
+    DECL_LINK(CommandHdl, const CommandEvent&, bool);
+    DECL_LINK(QueryTooltipHdl, const weld::TreeIter&, OUString);
+    DECL_LINK(DragBeginHdl, bool&, bool);
+    DECL_LINK(TimerUpdate, Timer *, void);
+
 public:
-    SwContentTree(vcl::Window* pParent, SwNavigationPI* pDialog);
-    virtual ~SwContentTree() override;
-    virtual void dispose() override;
-    OUString        GetEntryAltText( SvTreeListEntry* pEntry ) const override;
-    OUString        GetEntryLongDescription( SvTreeListEntry* pEntry ) const override;
+    SwContentTree(std::unique_ptr<weld::TreeView> xTreeView, SwNavigationPI* pDialog);
+    ~SwContentTree();
     SdrObject*      GetDrawingObjectsByContent(const SwContent *pCnt);
 
     /** Switch the display to Root */
@@ -192,8 +188,8 @@ public:
 
     /** Show the file */
     void            Display( bool bActiveView );
-    /** In the Clear the content types have to be deleted, also. */
-    void            Clear();
+    /** In the clear the content types have to be deleted, also. */
+    void            clear();
 
     /** After a file is dropped on the Navigator, the new shell will be set */
     void            SetHiddenShell(SwWrtShell* pSh);
@@ -209,18 +205,13 @@ public:
     SwWrtShell*     GetWrtShell()
         { return State::HIDDEN == m_eState ? m_pHiddenShell : m_pActiveShell; }
 
-    static bool     IsInDrag() {return bIsInDrag;}
+    bool            IsInDrag() const;
 
     sal_uInt8       GetOutlineLevel()const {return m_nOutlineLevel;}
     void            SetOutlineLevel(sal_uInt8 nSet);
 
-    /** Expand - Remember the state for content types */
-    virtual bool    Expand( SvTreeListEntry* pParent ) override;
-    /** Collapse - Remember the state for content types. */
-    virtual bool    Collapse( SvTreeListEntry* pParent ) override;
-
     /** Execute commands of the Navigator */
-    void            ExecCommand(const OUString& rCmd, bool bModifier);
+    void            ExecCommand(const OString& rCmd, bool bModifier);
 
     void            ShowTree();
     void            HideTree();
@@ -232,56 +223,79 @@ public:
     const SwWrtShell*   GetActiveWrtShell() const {return m_pActiveShell;}
     SwWrtShell*         GetHiddenWrtShell() {return m_pHiddenShell;}
 
-    DECL_LINK( ContentDoubleClickHdl, SvTreeListBox*, bool );
-    DECL_LINK( TimerUpdate, Timer *, void );
+    void Select();
 
-    virtual sal_IntPtr GetTabPos( SvTreeListEntry*, SvLBoxTab* ) override;
-    virtual void    RequestingChildren( SvTreeListEntry* pParent ) override;
-    virtual void    GetFocus() override;
-    virtual void    KeyInput(const KeyEvent& rKEvt) override;
-
-    virtual bool    Select( SvTreeListEntry* pEntry, bool bSelect=true ) override;
-    virtual Size    GetOptimalSize() const override;
+    // return true if it has any children
+    bool RequestingChildren(const weld::TreeIter& rParent);
 
     virtual void Notify(SfxBroadcaster& rBC, SfxHint const& rHint) override;
 
-};
+    sal_Int8 AcceptDrop(const AcceptDropEvent& rEvt);
+    sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt);
 
-// TreeListBox for global documents
+    bool IsDropFormatSupported(SotClipboardFormatId nFormat)
+    {
+        return m_aDropTargetHelper.IsDropFormatSupported(nFormat);
+    }
 
-class SwLBoxString : public SvLBoxString
-{
-public:
+    void set_accessible_name(const OUString& rName)
+    {
+        m_xTreeView->set_accessible_name(rName);
+    }
 
-    SwLBoxString( const OUString& rStr ) : SvLBoxString(rStr)
+    void grab_focus()
     {
+        m_xTreeView->grab_focus();
     }
 
-    virtual void Paint(const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext,
-                       const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) override;
+    int count_selected_rows() const
+    {
+        return m_xTreeView->count_selected_rows();
+    }
+
+    void set_selection_mode(SelectionMode eMode)
+    {
+        m_xTreeView->set_selection_mode(eMode);
+    }
+
+    weld::TreeView& get_widget()
+    {
+        return *m_xTreeView;
+    }
 };
 
 namespace sfx2 { class DocumentInserter; }
 namespace sfx2 { class FileDialogHelper; }
 
-class SwGlobalTree final : public SvTreeListBox
+class SwGlobalTree;
+
+class SwGlobalTreeDropTarget : public DropTargetHelper
+{
+private:
+    SwGlobalTree& m_rTreeView;
+
+    virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
+    virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
+
+public:
+    SwGlobalTreeDropTarget(SwGlobalTree& rTreeView);
+};
+
+class SwGlobalTree final
 {
 private:
+    std::unique_ptr<weld::TreeView> m_xTreeView;
+    SwGlobalTreeDropTarget  m_aDropTargetHelper;
     VclPtr<SwNavigationPI>  m_xDialog;
     AutoTimer               m_aUpdateTimer;
     OUString                m_aContextStrings[GLOBAL_CONTEXT_COUNT];
 
     SwWrtShell*             m_pActiveShell;
-    SvTreeListEntry*        m_pEmphasisEntry; // Drag'n Drop emphasis
-    SvTreeListEntry*        m_pDDSource;      // source for Drag'n Drop
     std::unique_ptr<SwGlblDocContents> m_pSwGlblDocContents; // array with sorted content
 
     std::unique_ptr<SwGlblDocContent>       m_pDocContent;
     std::unique_ptr<sfx2::DocumentInserter> m_pDocInserter;
 
-    bool                m_bIsInternalDrag     :1;
-    bool                m_bLastEntryEmphasis  :1; // Drag'n Drop
-
     static const SfxObjectShell* pShowShell;
 
     void        InsertRegion( const SwGlblDocContent* _pContent,
@@ -289,48 +303,15 @@ private:
 
     DECL_LINK(  DialogClosedHdl, sfx2::FileDialogHelper*, void );
 
-    using SvTreeListBox::DoubleClickHdl;
-    using SvTreeListBox::ExecuteDrop;
-    using Window::Update;
+    void Select();
 
-    virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
-
-    virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
-
-    virtual void    DataChanged( const DataChangedEvent& rDCEvt ) override;
-
-    virtual void    RequestHelp( const HelpEvent& rHEvt ) override;
-
-    virtual sal_IntPtr GetTabPos( SvTreeListEntry*, SvLBoxTab* ) override;
-    virtual TriState NotifyMoving(   SvTreeListEntry*  pTarget,
-                                    SvTreeListEntry*  pEntry,
-                                    SvTreeListEntry*& rpNewParent,
-                                    sal_uLong&        rNewChildPos
-                                ) override;
-    virtual TriState NotifyCopying(  SvTreeListEntry*  pTarget,
-                                    SvTreeListEntry*  pEntry,
-                                    SvTreeListEntry*& rpNewParent,
-                                    sal_uLong&        rNewChildPos
-                                ) override;
-
-    virtual void    StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override;
-    virtual void    DragFinished( sal_Int8 ) override;
-    virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
-                                        SvTreeListEntry* ) override;
-    virtual bool    NotifyAcceptDrop( SvTreeListEntry* ) override;
-
-    virtual void    MouseButtonDown( const MouseEvent& rMEvt ) override;
-    virtual void    KeyInput(const KeyEvent& rKEvt) override;
-    virtual void    GetFocus() override;
-    virtual void    SelectHdl() override;
-    virtual void    DeselectHdl() override;
-    virtual void    InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&) override;
-
-    void            Clear();
-
-    DECL_LINK( PopupHdl, Menu*, bool );
-    DECL_LINK( Timeout, Timer*, void );
-    DECL_LINK( DoubleClickHdl, SvTreeListBox*, bool );
+    DECL_LINK(Timeout, Timer*, void);
+    DECL_LINK(DoubleClickHdl, weld::TreeView&, bool);
+    DECL_LINK(SelectHdl, weld::TreeView&, void);
+    DECL_LINK(FocusInHdl, weld::Widget&, void);
+    DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
+    DECL_LINK(CommandHdl, const CommandEvent&, bool);
+    DECL_LINK(QueryTooltipHdl, const weld::TreeIter&, OUString);
 
     SwNavigationPI* GetParentWindow();
 
@@ -341,16 +322,40 @@ private:
     static void     SetShowShell(const SfxObjectShell*pSet) {pShowShell = pSet;}
     DECL_STATIC_LINK(SwGlobalTree, ShowFrameHdl, void*, void);
 
-    virtual VclPtr<PopupMenu> CreateContextMenu() override;
-    virtual void    ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) override;
-
 public:
-    SwGlobalTree(vcl::Window* pParent, SwNavigationPI* pDialog);
-    virtual ~SwGlobalTree() override;
-    virtual void        dispose() override;
-    virtual Size        GetOptimalSize() const override;
+    SwGlobalTree(std::unique_ptr<weld::TreeView> xTreeView, SwNavigationPI* pDialog);
+    ~SwGlobalTree();
 
-    void                TbxMenuHdl(sal_uInt16 nTbxId, ToolBox* pBox);
+    bool get_visible() const { return m_xTreeView->get_visible(); }
+
+    void set_accessible_name(const OUString& rName)
+    {
+        m_xTreeView->set_accessible_name(rName);
+    }
+
+    void grab_focus()
+    {
+        m_xTreeView->grab_focus();
+    }
+
+    int count_selected_rows() const
+    {
+        return m_xTreeView->count_selected_rows();
+    }
+
+    void set_selection_mode(SelectionMode eMode)
+    {
+        m_xTreeView->set_selection_mode(eMode);
+    }
+
+    weld::TreeView& get_widget()
+    {
+        return *m_xTreeView;
+    }
+
+    void MoveSelectionTo(weld::TreeIter* pDropTarget);
+
+    void                TbxMenuHdl(const OString& rCommand, weld::Menu& rMenu);
     void                InsertRegion( const SwGlblDocContent* pCont,
                                         const OUString* pFileName = nullptr );
     void                EditContent(const SwGlblDocContent* pCont );
@@ -358,11 +363,15 @@ public:
     void                ShowTree();
     void                HideTree();
 
-    void                ExecCommand(const OUString& rCmd);
+    void                ExecCommand(const OString& rCmd);
 
     void                Display(bool bOnlyUpdateUserData = false);
 
     bool                Update(bool bHard);
+
+    void                ExecuteContextMenuAction(const OString& rSelectedPopupEntry);
+
+    const SwWrtShell*   GetActiveWrtShell() const {return m_pActiveShell;}
 };
 
 #endif
diff --git a/sw/source/uibase/inc/navipi.hxx b/sw/source/uibase/inc/navipi.hxx
index 1404d826da83..1ae6542fb51b 100644
--- a/sw/source/uibase/inc/navipi.hxx
+++ b/sw/source/uibase/inc/navipi.hxx
@@ -19,9 +19,6 @@
 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_NAVIPI_HXX
 #define INCLUDED_SW_SOURCE_UIBASE_INC_NAVIPI_HXX
 
-#include <vcl/lstbox.hxx>
-#include <vcl/layout.hxx>
-#include <vcl/toolbox.hxx>
 #include <vcl/idle.hxx>
 #include <svl/lstner.hxx>
 #include <vcl/transfer.hxx>
@@ -30,6 +27,7 @@
 #include <sfx2/tbxctrl.hxx>
 #include <sfx2/sidebar/ControllerItem.hxx>
 #include <sfx2/sidebar/SidebarToolBox.hxx>
+#include <sfx2/weldutils.hxx>
 #include <svx/sidebar/PanelLayout.hxx>
 #include "conttree.hxx"
 #include <ndarr.hxx>
@@ -39,7 +37,6 @@ class SwWrtShell;
 class SwNavigationPI;
 class SwNavigationChild;
 class SfxBindings;
-class NumEditAction;
 class SwNavigationConfig;
 class SwView;
 class SfxObjectShellLock;
@@ -59,17 +56,23 @@ class SwNavigationPI : public PanelLayout
     ::sfx2::sidebar::ControllerItem m_aDocFullName;
     ::sfx2::sidebar::ControllerItem m_aPageStats;
 
-    VclPtr<sfx2::sidebar::SidebarToolBox> m_aContentToolBox;
-    VclPtr<ToolBox>             m_aGlobalToolBox;
-    VclPtr<NumEditAction>       m_xEdit;
-    VclPtr<VclContainer>        m_aContentBox;
-    VclPtr<SwContentTree>       m_aContentTree;
-    VclPtr<VclContainer>        m_aGlobalBox;
-    VclPtr<SwGlobalTree>        m_aGlobalTree;
-    VclPtr<ListBox>             m_aDocListBox;
+    std::unique_ptr<weld::Toolbar> m_xContent1ToolBox;
+    std::unique_ptr<weld::Toolbar> m_xContent2ToolBox;
+    std::unique_ptr<weld::Toolbar> m_xContent3ToolBox;
+    std::unique_ptr<ToolbarUnoDispatcher> m_xContent1Dispatch;
+    std::unique_ptr<weld::Menu> m_xHeadingsMenu;
+    std::unique_ptr<weld::Menu> m_xDragModeMenu;
+    std::unique_ptr<weld::Menu> m_xUpdateMenu;
+    std::unique_ptr<weld::Menu> m_xInsertMenu;
+    std::unique_ptr<weld::Toolbar> m_xGlobalToolBox;
+    std::unique_ptr<weld::SpinButton> m_xEdit;
+    std::unique_ptr<weld::Widget> m_xContentBox;
+    std::unique_ptr<SwContentTree> m_xContentTree;
+    std::unique_ptr<weld::Widget> m_xGlobalBox;
+    std::unique_ptr<SwGlobalTree> m_xGlobalTree;
+    std::unique_ptr<weld::ComboBox> m_xDocListBox;
     Idle                m_aPageChgIdle;
     OUString            m_sContentFileName;
-    OUString            m_aContextArr[3];
     OUString            m_aStatusArr[4];
 
     std::unique_ptr<SfxObjectShellLock>  m_pxObjectShell;
@@ -93,12 +96,15 @@ class SwNavigationPI : public PanelLayout
 
     void FillBox();
 
-    DECL_LINK( DocListBoxSelectHdl, ListBox&, void );
-    DECL_LINK( ToolBoxSelectHdl, ToolBox *, void );
-    DECL_LINK( ToolBoxClickHdl, ToolBox *, void );
-    DECL_LINK( ToolBoxDropdownClickHdl, ToolBox*, void );
+    DECL_LINK( DocListBoxSelectHdl, weld::ComboBox&, void );
+    DECL_LINK( ToolBoxSelectHdl, const OString&, void );
+    DECL_LINK( ToolBoxClickHdl, const OString&, void );
+    DECL_LINK( ToolBox2DropdownClickHdl, const OString&, void );
+    DECL_LINK( ToolBox3DropdownClickHdl, const OString&, void );
     DECL_LINK( DoneLink, SfxPoolItem const *, void );
-    DECL_LINK( MenuSelectHdl, Menu *, bool );
+    DECL_LINK( DropModeMenuSelectHdl, const OString&, void );
+    DECL_LINK( HeadingsMenuSelectHdl, const OString&, void );
+    DECL_LINK( GlobalMenuSelectHdl, const OString&, void );
     DECL_LINK( ChangePageHdl, Timer*, void );
     DECL_LINK( PageEditModifyHdl, weld::SpinButton&, void );
     bool EditAction();
@@ -109,7 +115,6 @@ protected:
     // release ObjectShellLock early enough for app end
     virtual void    Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
 
-    NumEditAction&  GetPageEdit();
     void            ToggleTree();
     void            SetGlobalMode(bool bSet) {m_bGlobalMode = bSet;}
 
diff --git a/sw/source/uibase/ribbar/workctrl.cxx b/sw/source/uibase/ribbar/workctrl.cxx
index 90ed663b5952..feb999de7fc4 100644
--- a/sw/source/uibase/ribbar/workctrl.cxx
+++ b/sw/source/uibase/ribbar/workctrl.cxx
@@ -41,6 +41,7 @@
 #include <swabstdlg.hxx>
 #include <sfx2/zoomitem.hxx>
 #include <vcl/svapp.hxx>
+#include <vcl/weldutils.hxx>
 #include <svx/dialmgr.hxx>
 #include <svx/strings.hrc>
 #include <bitmaps.hlst>
@@ -566,7 +567,9 @@ VclPtr<vcl::Window> SwJumpToSpecificPageControl::CreateItemWindow( vcl::Window *
 
 namespace {
 
+class NavElementBox_Base;
 class NavElementBox_Impl;
+
 class NavElementToolBoxControl : public svt::ToolboxController,
                                  public lang::XServiceInfo
 {
@@ -601,10 +604,46 @@ class NavElementToolBoxControl : public svt::ToolboxController,
         using svt::ToolboxController::dispatchCommand;
 
     private:
-        VclPtr<NavElementBox_Impl>           m_pBox;
+        VclPtr<NavElementBox_Impl> m_xVclBox;
+        std::unique_ptr<NavElementBox_Base> m_xWeldBox;
+        NavElementBox_Base* m_pBox;
+};
+
+class NavElementBox_Base
+{
+public:
+    NavElementBox_Base(std::unique_ptr<weld::ComboBox> xWidget,
+                       const uno::Reference<frame::XFrame>& _xFrame,
+                       NavElementToolBoxControl& rCtrl);
+
+    virtual ~NavElementBox_Base()
+    {
+    }
+
+    void set_sensitive(bool bSensitive)
+    {
+        m_xWidget->set_sensitive(bSensitive);
+    }
+
+    void                UpdateBox();
+
+protected:
+    std::unique_ptr<weld::ComboBox>            m_xWidget;
+    NavElementToolBoxControl*                  m_pCtrl;
+    bool                                       m_bRelease;
+    uno::Reference< frame::XFrame >            m_xFrame;
+
+    virtual bool DoKeyInput(const KeyEvent& rKEvt);
+
+    DECL_LINK(SelectHdl, weld::ComboBox&, void);
+    DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
+
+    void                ReleaseFocus_Impl();
 };
 
+
 class NavElementBox_Impl final : public InterimItemWindow
+                               , public NavElementBox_Base
 {
 public:
     NavElementBox_Impl(vcl::Window* pParent,
@@ -624,52 +663,48 @@ public:
         InterimItemWindow::GetFocus();
     }
 
+    virtual bool DoKeyInput(const KeyEvent& rKEvt) override;
+
     virtual ~NavElementBox_Impl() override
     {
         disposeOnce();
     }
-
-    void                Update();
-
-private:
-    std::unique_ptr<weld::ComboBox>            m_xWidget;
-    NavElementToolBoxControl*                  m_pCtrl;
-    bool                                       m_bRelease;
-    uno::Reference< frame::XFrame >            m_xFrame;
-
-    DECL_LINK(SelectHdl, weld::ComboBox&, void);
-    DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
-
-    void                ReleaseFocus_Impl();
 };
 
 }
 
-NavElementBox_Impl::NavElementBox_Impl(
-    vcl::Window*                                      _pParent,
+NavElementBox_Base::NavElementBox_Base(
+    std::unique_ptr<weld::ComboBox> xWidget,
     const uno::Reference< frame::XFrame >&            _xFrame,
     NavElementToolBoxControl&                         _rCtrl )
-    : InterimItemWindow(_pParent, "modules/swriter/ui/combobox.ui", "ComboBox")
-    , m_xWidget(m_xBuilder->weld_combo_box("combobox"))
+    : m_xWidget(std::move(xWidget))
     , m_pCtrl(&_rCtrl)
     , m_bRelease(true)
     , m_xFrame(_xFrame)
 {
-    m_xWidget->set_size_request(42, -1); // set to something small so the size set at the .ui takes precedence
+    m_xWidget->set_size_request(150, -1);
 
     std::map<OUString, std::pair<sal_uInt16, rtl::OUString> > aStoreSortedNavigationIds;
-    for(sal_uInt16 i = 0; i < NID_COUNT; i++)
+    for (sal_uInt16 i = 0; i < NID_COUNT; i++)
         aStoreSortedNavigationIds[SwResId(aNavigationStrIds[i])] = std::make_pair(aNavigationInsertIds[i], aNavigationImgIds[i]);// for ordering of Navigation Pane
 
     for (auto const &itr : aStoreSortedNavigationIds)
         m_xWidget->append(OUString::number(itr.second.first), itr.first, itr.second.second);
-    m_xWidget->connect_changed(LINK(this, NavElementBox_Impl, SelectHdl));
-    m_xWidget->connect_key_press(LINK(this, NavElementBox_Impl, KeyInputHdl));
+    m_xWidget->connect_changed(LINK(this, NavElementBox_Base, SelectHdl));
+    m_xWidget->connect_key_press(LINK(this, NavElementBox_Base, KeyInputHdl));
+}
 
+NavElementBox_Impl::NavElementBox_Impl(
+    vcl::Window*                                      _pParent,
+    const uno::Reference< frame::XFrame >&            _xFrame,
+    NavElementToolBoxControl&                         _rCtrl )
+    : InterimItemWindow(_pParent, "modules/swriter/ui/combobox.ui", "ComboBox")
+    , NavElementBox_Base(m_xBuilder->weld_combo_box("combobox"), _xFrame, _rCtrl)
+{
     SetSizePixel(m_xContainer->get_preferred_size());
 }
 
-void NavElementBox_Impl::ReleaseFocus_Impl()
+void NavElementBox_Base::ReleaseFocus_Impl()
 {
     if ( !m_bRelease )
     {
@@ -681,7 +716,7 @@ void NavElementBox_Impl::ReleaseFocus_Impl()
         m_xFrame->getContainerWindow()->setFocus();
 }
 
-IMPL_LINK(NavElementBox_Impl, SelectHdl, weld::ComboBox&, rComboBox, void)
+IMPL_LINK(NavElementBox_Base, SelectHdl, weld::ComboBox&, rComboBox, void)
 {
     if (rComboBox.changed_by_direct_pick())  // only when picked from the list
     {
@@ -701,7 +736,7 @@ IMPL_LINK(NavElementBox_Impl, SelectHdl, weld::ComboBox&, rComboBox, void)
     }
 }
 
-void NavElementBox_Impl::Update()
+void NavElementBox_Base::UpdateBox()
 {
     sal_uInt16 nMoveType = SwView::GetMoveType();
     for ( size_t i = 0; i < SAL_N_ELEMENTS( aNavigationInsertIds ); ++i )
@@ -716,7 +751,12 @@ void NavElementBox_Impl::Update()
     }
 }
 
-IMPL_LINK(NavElementBox_Impl, KeyInputHdl, const KeyEvent&, rKEvt, bool)
+IMPL_LINK(NavElementBox_Base, KeyInputHdl, const KeyEvent&, rKEvt, bool)
+{
+    return DoKeyInput(rKEvt);
+}
+
+bool NavElementBox_Base::DoKeyInput(const KeyEvent& rKEvt)
 {
     bool bHandled = false;
 
@@ -743,9 +783,15 @@ IMPL_LINK(NavElementBox_Impl, KeyInputHdl, const KeyEvent&, rKEvt, bool)
             break;
     }
 
-    return bHandled || ChildKeyInput(rKEvt);
+    return bHandled;
+}
+
+bool NavElementBox_Impl::DoKeyInput(const KeyEvent& rKEvt)
+{
+    return NavElementBox_Base::DoKeyInput(rKEvt) || ChildKeyInput(rKEvt);
 }
 
+
 NavElementToolBoxControl::NavElementToolBoxControl( const uno::Reference< uno::XComponentContext >& rxContext )
  : svt::ToolboxController( rxContext,
                            uno::Reference< frame::XFrame >(),
@@ -796,24 +842,26 @@ void SAL_CALL NavElementToolBoxControl::dispose()
     svt::ToolboxController::dispose();
 
     SolarMutexGuard aSolarMutexGuard;
-    m_pBox.disposeAndClear();
+    m_xVclBox.disposeAndClear();
+    m_xWeldBox.reset();
+    m_pBox = nullptr;
 }
 
 // XStatusListener
 void SAL_CALL NavElementToolBoxControl::statusChanged( const frame::FeatureStateEvent& rEvent )
 {
-    if ( m_pBox )
+    if (m_pBox)
     {
         SolarMutexGuard aSolarMutexGuard;
         if ( rEvent.FeatureURL.Path == "NavElement" )
         {
             if ( rEvent.IsEnabled )
             {
-                m_pBox->Enable();
-                m_pBox->Update();
+                m_pBox->set_sensitive(true);
+                m_pBox->UpdateBox();
             }
             else
-                m_pBox->Disable();
+                m_pBox->set_sensitive(true);
         }
     }
 }
@@ -841,12 +889,27 @@ uno::Reference< awt::XWindow > SAL_CALL NavElementToolBoxControl::createItemWind
 {
     uno::Reference< awt::XWindow > xItemWindow;
 
-    VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow( xParent );
-    if ( pParent )
+    if (m_pBuilder)
     {
         SolarMutexGuard aSolarMutexGuard;
-        m_pBox = VclPtr<NavElementBox_Impl>::Create( pParent, m_xFrame, *this );
-        xItemWindow = VCLUnoHelper::GetInterface( m_pBox );
+
+        std::unique_ptr<weld::ComboBox> xWidget(m_pBuilder->weld_combo_box("NavElementWidget"));
+
+        xItemWindow = css::uno::Reference<css::awt::XWindow>(new weld::TransportAsXWindow(xWidget.get()));
+
+        m_xWeldBox.reset(new NavElementBox_Base(std::move(xWidget), m_xFrame, *this));
+        m_pBox = m_xWeldBox.get();
+    }
+    else
+    {
+        VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow( xParent );
+        if ( pParent )
+        {
+            SolarMutexGuard aSolarMutexGuard;
+            m_xVclBox = VclPtr<NavElementBox_Impl>::Create( pParent, m_xFrame, *this );
+            m_pBox = m_xVclBox.get();
+            xItemWindow = VCLUnoHelper::GetInterface(m_xVclBox);
+        }
     }
 
     uno::Reference< util::XURLTransformer > xURLTransformer = getURLTransformer();
@@ -970,13 +1033,17 @@ void SAL_CALL PrevNextScrollToolboxController::dispose()
 // XStatusListener
 void SAL_CALL PrevNextScrollToolboxController::statusChanged( const css::frame::FeatureStateEvent& rEvent )
 {
-    if ( rEvent.FeatureURL.Path == "NavElement" )
+    if (rEvent.FeatureURL.Path == "NavElement")
     {
-        ToolBox* pToolBox = nullptr;
-        sal_uInt16 nId = 0;
-        if ( getToolboxId( nId, &pToolBox ) )
-            pToolBox->SetQuickHelpText( nId, ( meType == PrevNextScrollToolboxController::PREVIOUS?lcl_GetScrollToolTip( false ):
-                                                                                                   lcl_GetScrollToolTip( true ) ) );
+        if (m_pToolbar)
+            m_pToolbar->set_item_tooltip_text(m_aCommandURL.toUtf8(), lcl_GetScrollToolTip(meType != PrevNextScrollToolboxController::PREVIOUS));
+        else
+        {
+            ToolBox* pToolBox = nullptr;
+            sal_uInt16 nId = 0;
+            if (getToolboxId(nId, &pToolBox))
+                pToolBox->SetQuickHelpText(nId, lcl_GetScrollToolTip(meType != PrevNextScrollToolboxController::PREVIOUS));
+        }
     }
 }
 
diff --git a/sw/source/uibase/sidebar/TableEditPanel.cxx b/sw/source/uibase/sidebar/TableEditPanel.cxx
index 0dec00ec1613..7f4dadbd308f 100644
--- a/sw/source/uibase/sidebar/TableEditPanel.cxx
+++ b/sw/source/uibase/sidebar/TableEditPanel.cxx
@@ -101,19 +101,19 @@ TableEditPanel::TableEditPanel(vcl::Window* pParent,
     , m_xColumnWidthEdit(
           new SvxRelativeField(m_xBuilder->weld_metric_spin_button("columnwidth", FieldUnit::CM)))
     , m_xInsert(m_xBuilder->weld_toolbar("insert"))
-    , m_xInsertDispatch(new ToolbarUnoDispatcher(*m_xInsert, rxFrame))
+    , m_xInsertDispatch(new ToolbarUnoDispatcher(*m_xInsert, *m_xBuilder, rxFrame))
     , m_xSelect(m_xBuilder->weld_toolbar("select"))
-    , m_xSelectDispatch(new ToolbarUnoDispatcher(*m_xSelect, rxFrame))
+    , m_xSelectDispatch(new ToolbarUnoDispatcher(*m_xSelect, *m_xBuilder, rxFrame))
     , m_xRowSizing(m_xBuilder->weld_toolbar("rowsizing"))
-    , m_xRowSizingDispatch(new ToolbarUnoDispatcher(*m_xRowSizing, rxFrame))
+    , m_xRowSizingDispatch(new ToolbarUnoDispatcher(*m_xRowSizing, *m_xBuilder, rxFrame))
     , m_xColumnSizing(m_xBuilder->weld_toolbar("columnsizing"))
-    , m_xColumnSizingDispatch(new ToolbarUnoDispatcher(*m_xColumnSizing, rxFrame))
+    , m_xColumnSizingDispatch(new ToolbarUnoDispatcher(*m_xColumnSizing, *m_xBuilder, rxFrame))
     , m_xDelete(m_xBuilder->weld_toolbar("delete"))
-    , m_xDeleteDispatch(new ToolbarUnoDispatcher(*m_xDelete, rxFrame))
+    , m_xDeleteDispatch(new ToolbarUnoDispatcher(*m_xDelete, *m_xBuilder, rxFrame))
     , m_xSplitMerge(m_xBuilder->weld_toolbar("split_merge"))
-    , m_xSplitMergeDispatch(new ToolbarUnoDispatcher(*m_xSplitMerge, rxFrame))
+    , m_xSplitMergeDispatch(new ToolbarUnoDispatcher(*m_xSplitMerge, *m_xBuilder, rxFrame))
     , m_xMisc(m_xBuilder->weld_toolbar("misc"))
-    , m_xMiscDispatch(new ToolbarUnoDispatcher(*m_xMisc, rxFrame))
+    , m_xMiscDispatch(new ToolbarUnoDispatcher(*m_xMisc, *m_xBuilder, rxFrame))
     , m_aRowHeightController(SID_ATTR_TABLE_ROW_HEIGHT, *pBindings, *this)
     , m_aColumnWidthController(SID_ATTR_TABLE_COLUMN_WIDTH, *pBindings, *this)
     , m_aInsertRowsBeforeController(FN_TABLE_INSERT_ROW_BEFORE, *pBindings, *this)
diff --git a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
index e0770cba03d4..feb7abf9fc2d 100644
--- a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
+++ b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
@@ -72,7 +72,7 @@ WrapPropertyPanel::WrapPropertyPanel(
     , maSwLRSpacingControl(SID_ATTR_LRSPACE, *pBindings, *this)
     , maSwULSpacingControl(SID_ATTR_ULSPACE, *pBindings, *this)
     , mxWrapOptions(m_xBuilder->weld_toolbar("wrapoptions"))
-    , mxWrapOptionsDispatch(new ToolbarUnoDispatcher(*mxWrapOptions, rxFrame))
+    , mxWrapOptionsDispatch(new ToolbarUnoDispatcher(*mxWrapOptions, *m_xBuilder, rxFrame))
     , mxSpacingLB(m_xBuilder->weld_combo_box("spacingLB"))
 {
     FieldUnit eMetric = ::GetDfltMetric(false);
diff --git a/sw/source/uibase/uitest/uiobject.cxx b/sw/source/uibase/uitest/uiobject.cxx
index ecdfd68ad6a8..a0b8da9e9d97 100644
--- a/sw/source/uibase/uitest/uiobject.cxx
+++ b/sw/source/uibase/uitest/uiobject.cxx
@@ -138,7 +138,7 @@ StringMap SwNavigationPIUIObject::get_state()
 {
     StringMap aMap = WindowUIObject::get_state();
 
-    aMap["selectioncount"] = OUString::number(mxSwNavigationPI->m_aContentTree->GetSelectionCount());
+    aMap["selectioncount"] = OUString::number(mxSwNavigationPI->m_xContentTree->count_selected_rows());
 
     return aMap;
 }
@@ -147,9 +147,7 @@ void SwNavigationPIUIObject::execute(const OUString& rAction,
         const StringMap& rParameters)
 {
     if (rAction == "ROOT")
-    {
-        mxSwNavigationPI->m_aContentToolBox->TriggerItem(mxSwNavigationPI->m_aContentToolBox->GetItemId("root"));
-    }
+        mxSwNavigationPI->ToolBoxSelectHdl("root");
     else
         WindowUIObject::execute(rAction, rParameters);
 }
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index b7f85297087a..51aeea0d77a5 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -28,6 +28,7 @@
 #include <sfx2/viewfrm.hxx>
 #include <o3tl/enumrange.hxx>
 #include <o3tl/sorted_vector.hxx>
+#include <vcl/commandevent.hxx>
 #include <vcl/help.hxx>
 #include <vcl/settings.hxx>
 #include <sot/formats.hxx>
@@ -69,7 +70,6 @@
 #include <dcontact.hxx>
 #include <svx/svdpage.hxx>
 #include <svx/svdview.hxx>
-#include <vcl/scrbar.hxx>
 #include <SwRewriter.hxx>
 #include <hints.hxx>
 #include <numrule.hxx>
@@ -77,7 +77,6 @@
 #include <ndtxt.hxx>
 #include <PostItMgr.hxx>
 #include <postithelper.hxx>
-#include <vcl/treelistentry.hxx>
 
 #include <swabstdlg.hxx>
 #include <bitmaps.hlst>
@@ -107,18 +106,16 @@ class SwContentArr
 {
 };
 
-bool SwContentTree::bIsInDrag = false;
-
 namespace
 {
-    bool lcl_IsContent(const SvTreeListEntry* pEntry)
+    bool lcl_IsContent(const weld::TreeIter& rEntry, const weld::TreeView& rTreeView)
     {
-        return static_cast<const SwTypeNumber*>(pEntry->GetUserData())->GetTypeId() == CTYPE_CNT;
+        return reinterpret_cast<const SwTypeNumber*>(rTreeView.get_id(rEntry).toInt64())->GetTypeId() == CTYPE_CNT;
     }
 
-    bool lcl_IsContentType(const SvTreeListEntry* pEntry)
+    bool lcl_IsContentType(const weld::TreeIter& rEntry, const weld::TreeView& rTreeView)
     {
-        return static_cast<const SwTypeNumber*>(pEntry->GetUserData())->GetTypeId() == CTYPE_CTT;
+        return reinterpret_cast<const SwTypeNumber*>(rTreeView.get_id(rEntry).toInt64())->GetTypeId() == CTYPE_CTT;
     }
 
     bool lcl_FindShell(SwWrtShell const * pShell)
@@ -860,47 +857,48 @@ static const char* STR_CONTEXT_ARY[] =
     STR_OUTLINE_TRACKING_OFF
 };
 
-SwContentTree::SwContentTree(vcl::Window* pParent, SwNavigationPI* pDialog)
-    : SvTreeListBox(pParent)
+SwContentTree::SwContentTree(std::unique_ptr<weld::TreeView> xTreeView, SwNavigationPI* pDialog)
+    : m_xTreeView(std::move(xTreeView))
+    , m_aDropTargetHelper(*this)
     , m_xDialog(pDialog)
     , m_sSpace(OUString("                    "))
-    , m_sRemoveIdx(SwResId(STR_REMOVE_INDEX))
-    , m_sUpdateIdx(SwResId(STR_UPDATE))
-    , m_sUnprotTable(SwResId(STR_REMOVE_TBL_PROTECTION))
-    , m_sRename(SwResId(STR_RENAME))
-    , m_sReadonlyIdx(SwResId(STR_READONLY_IDX))
     , m_sInvisible(SwResId(STR_INVISIBLE))
-    , m_sPostItShow(SwResId(STR_POSTIT_SHOW))
-    , m_sPostItHide(SwResId(STR_POSTIT_HIDE))
-    , m_sPostItDelete(SwResId(STR_POSTIT_DELETE))
-    , m_sProtected(SwResId(STR_PROTECTED))
     , m_pHiddenShell(nullptr)
     , m_pActiveShell(nullptr)
     , m_pConfig(SW_MOD()->GetNavigationConfig())
     , m_nActiveBlock(0)
     , m_nHiddenBlock(0)
+    , m_nEntryCount(0)
     , m_nRootType(ContentTypeId::UNKNOWN)
     , m_nLastSelType(ContentTypeId::UNKNOWN)
     , m_nOutlineLevel(MAXLEVEL)
     , m_eState(State::ACTIVE)
     , m_bDocChgdInDragging(false)
-    , m_bIsInternalDrag(false)
     , m_bIsRoot(false)
     , m_bIsIdleClear(false)
     , m_bIsLastReadOnly(false)
     , m_bIsOutlineMoveable(true)
     , m_bViewHasChanged(false)
-    , m_bIsKeySpace(false)
 {
-    SetHelpId(HID_NAVIGATOR_TREELIST);
+    Size aSize(m_xDialog->LogicToPixel(Size(110, 112), MapMode(MapUnit::MapAppFont)));
+    m_xTreeView->set_size_request(aSize.Width(), aSize.Height());
+
+    m_xTreeView->set_help_id(HID_NAVIGATOR_TREELIST);
+
+    m_xTreeView->connect_expanding(LINK(this, SwContentTree, ExpandHdl));
+    m_xTreeView->connect_collapsing(LINK(this, SwContentTree, CollapseHdl));
+    m_xTreeView->connect_row_activated(LINK(this, SwContentTree, ContentDoubleClickHdl));
+    m_xTreeView->connect_changed(LINK(this, SwContentTree, SelectHdl));
+    m_xTreeView->connect_focus_in(LINK(this, SwContentTree, FocusHdl));
+    m_xTreeView->connect_key_press(LINK(this, SwContentTree, KeyInputHdl));
+    m_xTreeView->connect_popup_menu(LINK(this, SwContentTree, CommandHdl));
+    m_xTreeView->connect_query_tooltip(LINK(this, SwContentTree, QueryTooltipHdl));
+    m_xTreeView->connect_drag_begin(LINK(this, SwContentTree, DragBeginHdl));
 
-    SetNodeDefaultImages();
-    SetDoubleClickHdl(LINK(this, SwContentTree, ContentDoubleClickHdl));
-    SetDragDropMode(DragDropMode::APP_COPY);
     for (ContentTypeId i : o3tl::enumrange<ContentTypeId>())
     {
-        m_aActiveContentArr[i]    = nullptr;
-        m_aHiddenContentArr[i]    = nullptr;
+        m_aActiveContentArr[i] = nullptr;
+        m_aHiddenContentArr[i] = nullptr;
     }
     for (int i = 0; i < CONTEXT_COUNT; ++i)
     {
@@ -909,275 +907,110 @@ SwContentTree::SwContentTree(vcl::Window* pParent, SwNavigationPI* pDialog)
     m_nActiveBlock = m_pConfig->GetActiveBlock();
     m_aUpdTimer.SetInvokeHandler(LINK(this, SwContentTree, TimerUpdate));
     m_aUpdTimer.SetTimeout(1000);
-    Clear();
-    EnableContextMenuHandling();
-    SetQuickSearch(true);
 }
 
 SwContentTree::~SwContentTree()
 {
-    disposeOnce();
-}
-
-void SwContentTree::dispose()
-{
-    Clear(); // If applicable erase content types previously.
-    bIsInDrag = false;
+    clear(); // If applicable erase content types previously.
     m_aUpdTimer.Stop();
     SetActiveShell(nullptr);
     m_xDialog.clear();
-    SvTreeListBox::dispose();
-}
-
-Size SwContentTree::GetOptimalSize() const
-{
-    return LogicToPixel(Size(110, 112), MapMode(MapUnit::MapAppFont));
-}
-
-OUString SwContentTree::GetEntryAltText( SvTreeListEntry* pEntry ) const
-{
-    if (pEntry == nullptr || !lcl_IsContent(pEntry))
-        return OUString();
-
-    assert(pEntry->GetUserData() == nullptr || dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
-    SwContent* pCnt = static_cast<SwContent*>(pEntry->GetUserData());
-    if( pCnt == nullptr || pCnt->GetParent() == nullptr)
-        return OUString();
-
-    ContentTypeId nJumpType = pCnt->GetParent()->GetType();
-    SdrObject* pTemp;
-
-    switch(nJumpType)
-    {
-        case ContentTypeId::DRAWOBJECT:
-            {
-                SdrView* pDrawView = m_pActiveShell->GetDrawView();
-                if (pDrawView)
-                {
-                    SwDrawModel* pDrawModel = m_pActiveShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
-                    SdrPage* pPage = pDrawModel->GetPage(0);
-                    const size_t nCount = pPage->GetObjCount();
-                    for( size_t i=0; i<nCount; ++i )
-                    {
-                        pTemp = pPage->GetObj(i);
-                        sal_uInt16 nCmpId;
-                        switch( pTemp->GetObjIdentifier() )
-                        {
-                        case OBJ_GRUP:
-                        case OBJ_TEXT:
-                        case OBJ_LINE:
-                        case OBJ_RECT:
-                        case OBJ_CUSTOMSHAPE:
-                        case OBJ_CIRC:
-                        case OBJ_SECT:
-                        case OBJ_CARC:
-                        case OBJ_CCUT:
-                        case OBJ_POLY:
-                        case OBJ_PLIN:
-                        case OBJ_PATHLINE:
-                        case OBJ_PATHFILL:
-                        case OBJ_FREELINE:
-                        case OBJ_FREEFILL:
-                        case OBJ_PATHPOLY:
-                        case OBJ_PATHPLIN:
-                        case OBJ_CAPTION:
-                            nCmpId = OBJ_GRUP;
-                            break;
-                        default:
-                            nCmpId = pTemp->GetObjIdentifier();
-                        }
-                        if(nCmpId == OBJ_GRUP && pTemp->GetName() == pCnt->GetName())
-                        {
-                            return pTemp->GetTitle();
-                        }
-                    }
-                }
-            }
-            break;
-        case ContentTypeId::GRAPHIC   :
-            {
-                if( m_pActiveShell && m_pActiveShell->GetDoc() )
-                {
-                    const SwFlyFrameFormat* pFrameFormat = m_pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName());
-                    if( pFrameFormat )
-                        return pFrameFormat->GetObjTitle();
-                }
-            }
-            break;
-        case ContentTypeId::OLE       :
-        case ContentTypeId::FRAME     :
-            {
-                //Can't find the GetAlternateText function. Need to verify again.
-                const SwFlyFrameFormat* pFlyFormat = m_pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName());
-                if( pFlyFormat )
-                    return pFlyFormat->/*GetAlternateText*/GetName();
-            }
-            break;
-        default: break;
-    }
-    return OUString();
 }
 
-OUString SwContentTree::GetEntryLongDescription( SvTreeListEntry* pEntry ) const
+// Drag&Drop methods
+IMPL_LINK(SwContentTree, DragBeginHdl, bool&, rUnsetDragIcon, bool)
 {
-    if( pEntry == nullptr)
-        return OUString();
+    rUnsetDragIcon = true;
 
-    assert(pEntry->GetUserData() == nullptr || dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
-    SwContent* pCnt = static_cast<SwContent*>(pEntry->GetUserData());
-    if( pCnt == nullptr || pCnt->GetParent() == nullptr)
-        return OUString();
+    bool bDisallow = true;
 
-    SdrObject* pTemp;
-
-    switch(pCnt->GetParent()->GetType())
-    {
-        case ContentTypeId::DRAWOBJECT:
-            {
-                SdrView* pDrawView = m_pActiveShell->GetDrawView();
-                if (pDrawView)
-                {
-                    SwDrawModel* pDrawModel = m_pActiveShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
-                    SdrPage* pPage = pDrawModel->GetPage(0);
-                    const size_t nCount = pPage->GetObjCount();
-                    for( size_t i=0; i<nCount; ++i )
-                    {
-                        pTemp = pPage->GetObj(i);
-                        sal_uInt16 nCmpId;
-                        switch( pTemp->GetObjIdentifier() )
-                        {
-                        case OBJ_GRUP:
-                        case OBJ_TEXT:
-                        case OBJ_LINE:
-                        case OBJ_RECT:
-                        case OBJ_CUSTOMSHAPE:
-                        case OBJ_CIRC:
-                        case OBJ_SECT:
-                        case OBJ_CARC:
-                        case OBJ_CCUT:
-                        case OBJ_POLY:
-                        case OBJ_PLIN:
-                        case OBJ_PATHLINE:
-                        case OBJ_PATHFILL:
-                        case OBJ_FREELINE:
-                        case OBJ_FREEFILL:
-                        case OBJ_PATHPOLY:
-                        case OBJ_PATHPLIN:
-                        case OBJ_CAPTION:
-                            nCmpId = OBJ_GRUP;
-                            break;
-                        default:
-                            nCmpId = pTemp->GetObjIdentifier();
-                        }
-                        if(nCmpId == OBJ_GRUP /*dynamic_cast< const SdrObjGroup *>( pTemp ) !=  nullptr*/ && pTemp->GetName() == pCnt->GetName())
-                        {
-                            return pTemp->GetDescription();
-                        }
-                    }
-                }
-            }
-            break;
-        case ContentTypeId::GRAPHIC   :
-        case ContentTypeId::OLE       :
-        case ContentTypeId::FRAME     :
-            {
-                //Can't find the function "GetLongDescription". Need to verify again.
-                const SwFlyFrameFormat* pFlyFormat = m_pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName());
-                if( pFlyFormat )
-                    return pFlyFormat->GetDescription();
-            }
-            break;
-        default: break;
-    }
-    return OUString();
-}
-
-// Drag&Drop methods
-
-void SwContentTree::StartDrag( sal_Int8 nAction, const Point& rPosPixel )
-{
-    if( !m_bIsRoot || m_nRootType != ContentTypeId::OUTLINE )
-    {
-        ReleaseMouse();
+    rtl::Reference<TransferDataContainer> xContainer = new TransferDataContainer;
+    sal_Int8 nDragMode = DND_ACTION_COPYMOVE | DND_ACTION_LINK;
 
-        rtl::Reference<TransferDataContainer> pContainer = new TransferDataContainer;
+    if (FillTransferData(*xContainer, nDragMode))
+        bDisallow = false;
 
-        sal_Int8 nDragMode = DND_ACTION_COPYMOVE | DND_ACTION_LINK;
-        if( FillTransferData( *pContainer, nDragMode ))
-        {
-            SwContentTree::SetInDrag(true);
-            pContainer->StartDrag( this, nDragMode, GetDragFinishedHdl() );
-        }
-    }
-    else
+    if (m_bIsRoot && m_nRootType == ContentTypeId::OUTLINE)
     {
-        SwWrtShell *const pShell = GetWrtShell();
-        pShell->StartAllAction();
-        pShell->StartUndo(SwUndoId::OUTLINE_UD);
         // Only move drag entry and continuous selected siblings:
         m_aDndOutlinesSelected.clear();
-        SvTreeListEntry* pEntry = GetEntry(rPosPixel);
+
+        std::unique_ptr<weld::TreeIter> xScratch(m_xTreeView->make_iterator());
+
+        std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
+        bool bEntry = m_xTreeView->get_selected(xEntry.get());
+        if (!bEntry)
+            return true; // disallow
         // Find first selected of continuous siblings
-        while (pEntry && IsSelected(pEntry->PrevSibling()))
+        while (true)
         {
-            pEntry = pEntry->PrevSibling();
+            m_xTreeView->copy_iterator(*xEntry, *xScratch);
+            if (!m_xTreeView->iter_previous_sibling(*xScratch))
+                break;
+            if (!m_xTreeView->is_selected(*xScratch))
+                break;
+            m_xTreeView->copy_iterator(*xScratch, *xEntry);
         }
         // Record continuous selected siblings
-        if (pEntry)
+        do
         {
-            m_aDndOutlinesSelected.push_back(pEntry);
-            while (pEntry && IsSelected(pEntry->NextSibling()))
-            {
-                pEntry = pEntry->NextSibling();
-                m_aDndOutlinesSelected.push_back(pEntry);
-            }
+            m_aDndOutlinesSelected.push_back(m_xTreeView->make_iterator(xEntry.get()));
         }
-        SvTreeListBox::StartDrag( nAction, rPosPixel );
+        while (m_xTreeView->iter_next_sibling(*xEntry) && m_xTreeView->is_selected(*xEntry));
+        bDisallow = false;
     }
+
+    if (!bDisallow)
+        m_xTreeView->enable_drag_source(xContainer, nDragMode);
+    return bDisallow;
 }
 
-void SwContentTree::DragFinished( sal_Int8 nAction )
+SwContentTreeDropTarget::SwContentTreeDropTarget(SwContentTree& rTreeView)
+    : DropTargetHelper(rTreeView.get_widget().get_drop_target())
+    , m_rTreeView(rTreeView)
 {
-    if (m_bIsRoot && m_nRootType == ContentTypeId::OUTLINE)
+}
+
+sal_Int8 SwContentTreeDropTarget::AcceptDrop(const AcceptDropEvent& rEvt)
+{
+    sal_Int8 nAccept = m_rTreeView.AcceptDrop(rEvt);
+
+    if (nAccept != DND_ACTION_NONE)
     {
-        SwWrtShell *const pShell = GetWrtShell();
-        pShell->EndUndo();
-        pShell->EndAllAction();
-        m_aActiveContentArr[ContentTypeId::OUTLINE]->Invalidate();
-        Display(true);
-        m_aDndOutlinesSelected.clear();
+        // to enable the autoscroll when we're close to the edges
+        weld::TreeView& rWidget = m_rTreeView.get_widget();
+        rWidget.get_dest_row_at_pos(rEvt.maPosPixel, nullptr);
     }
 
-    // To prevent the removing of the selected entry in external drag and drop
-    // the drag action mustn't be MOVE.
-    SvTreeListBox::DragFinished( m_bIsInternalDrag ? nAction : DND_ACTION_COPY );
-    SwContentTree::SetInDrag(false);
-    m_bIsInternalDrag = false;
+    return nAccept;
 }
 
-// QueryDrop will be executed in the navigator
+bool SwContentTree::IsInDrag() const
+{
+    return m_xTreeView->get_drag_source() == m_xTreeView.get();
+}
 
-sal_Int8 SwContentTree::AcceptDrop( const AcceptDropEvent& rEvt )
+// QueryDrop will be executed in the navigator
+sal_Int8 SwContentTree::AcceptDrop(const AcceptDropEvent& rEvt)
 {
     sal_Int8 nRet = DND_ACTION_NONE;
     if( m_bIsRoot )
     {
         if( m_bIsOutlineMoveable )
-            nRet = SvTreeListBox::AcceptDrop( rEvt );
+            nRet = rEvt.mnAction;
     }
-    else if( !bIsInDrag )
+    else if (!IsInDrag())
         nRet = GetParentWindow()->AcceptDrop();
     return nRet;
 }
 
 // Drop will be executed in the navigator
-
-static void* lcl_GetOutlineKey( SwContentTree* pTree, SwOutlineContent const * pContent)
+static void* lcl_GetOutlineKey(SwContentTree& rTree, SwOutlineContent const * pContent)
 {
     void* key = nullptr;
-    if( pTree && pContent )
+    if (pContent)
     {
-        SwWrtShell* pShell = pTree->GetWrtShell();
+        SwWrtShell* pShell = rTree.GetWrtShell();
         auto const nPos = pContent->GetOutlinePos();
 
         key = static_cast<void*>(pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos ));
@@ -1185,74 +1018,142 @@ static void* lcl_GetOutlineKey( SwContentTree* pTree, SwOutlineContent const * p
     return key;
 }
 
-sal_Int8 SwContentTree::ExecuteDrop( const ExecuteDropEvent& rEvt )
+sal_Int8 SwContentTreeDropTarget::ExecuteDrop(const ExecuteDropEvent& rEvt)
 {
-    SvTreeListEntry* pEntry = pTargetEntry;
-    if( pEntry && ( m_nRootType == ContentTypeId::OUTLINE ) && lcl_IsContent( pEntry ) )
+    return m_rTreeView.ExecuteDrop(rEvt);
+}
+
+sal_Int8 SwContentTree::ExecuteDrop(const ExecuteDropEvent& rEvt)
+{
+    std::unique_ptr<weld::TreeIter> xDropEntry(m_xTreeView->make_iterator());
+    if (!m_xTreeView->get_dest_row_at_pos(rEvt.maPosPixel, xDropEntry.get()))
+        xDropEntry.reset();
+
+    if (m_nRootType == ContentTypeId::OUTLINE)
     {
-        assert(pEntry->GetUserData() == nullptr || dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
-        SwOutlineContent* pOutlineContent = static_cast<SwOutlineContent*>(pEntry->GetUserData());
-        if( pOutlineContent )
+        if (xDropEntry && lcl_IsContent(*xDropEntry, *m_xTreeView))
         {
-            void* key = lcl_GetOutlineKey(this, pOutlineContent);
-            if( !mOutLineNodeMap[key] )
+            assert(dynamic_cast<SwContent*>(reinterpret_cast<SwTypeNumber*>(m_xTreeView->get_id(*xDropEntry).toInt64())));
+            SwOutlineContent* pOutlineContent = reinterpret_cast<SwOutlineContent*>(m_xTreeView->get_id(*xDropEntry).toInt64());
+            assert(pOutlineContent);
+
+            void* key = lcl_GetOutlineKey(*this, pOutlineContent);
+            assert(key);
+            if (!mOutLineNodeMap[key])
             {
-                while( pEntry->HasChildren() )
+                while (m_xTreeView->iter_has_child(*xDropEntry))
                 {
-                    SvTreeListEntry* pChildEntry = FirstChild( pEntry );
-                    while( pChildEntry )
+                    std::unique_ptr<weld::TreeIter> xChildEntry(m_xTreeView->make_iterator(xDropEntry.get()));
+                    bool bChildEntry = m_xTreeView->iter_children(*xChildEntry);
+                    while (bChildEntry)
                     {
-                        pEntry = pChildEntry;
-                        pChildEntry = pChildEntry->NextSibling();
+                        m_xTreeView->copy_iterator(*xChildEntry, *xDropEntry);
+                        bChildEntry = m_xTreeView->iter_next_sibling(*xChildEntry);
                     }
                 }
-                pTargetEntry = pEntry;
             }
         }
+
+        SwOutlineNodes::size_type nTargetPos = 0;
+        if (!xDropEntry)
+        {
+            // dropped in blank space -> move to bottom
+            nTargetPos = GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount() - 1;
+        }
+        else if (!lcl_IsContent(*xDropEntry, *m_xTreeView))
+        {
+            // dropped on "heading" parent -> move to start
+            nTargetPos = SwOutlineNodes::npos;
+        }
+        else
+        {
+            assert(dynamic_cast<SwOutlineContent*>(reinterpret_cast<SwTypeNumber*>(m_xTreeView->get_id(*xDropEntry).toInt64())));
+            nTargetPos = reinterpret_cast<SwOutlineContent*>(m_xTreeView->get_id(*xDropEntry).toInt64())->GetOutlinePos();
+        }
+
+        if( MAXLEVEL > m_nOutlineLevel && // Not all layers are displayed.
+                        nTargetPos != SwOutlineNodes::npos)
+        {
+            std::unique_ptr<weld::TreeIter> xNext(m_xTreeView->make_iterator(xDropEntry.get()));
+            bool bNext = m_xTreeView->iter_next(*xNext);
+            if (bNext)
+            {
+                assert(dynamic_cast<SwOutlineContent*>(reinterpret_cast<SwTypeNumber*>(m_xTreeView->get_id(*xNext).toInt64())));
+                nTargetPos = reinterpret_cast<SwOutlineContent*>(m_xTreeView->get_id(*xNext).toInt64())->GetOutlinePos() - 1;
+            }
+            else
+                nTargetPos = GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount() - 1;
+        }
+
+        MoveOutline(nTargetPos);
+
     }
-    if( m_bIsRoot )
-        return SvTreeListBox::ExecuteDrop( rEvt );
-    return bIsInDrag ? DND_ACTION_NONE : GetParentWindow()->ExecuteDrop(rEvt);
+    return IsInDrag() ? DND_ACTION_NONE : GetParentWindow()->ExecuteDrop(rEvt);
 }
 
-// Handler for Dragging and ContextMenu
+namespace
+{
+    bool IsAllExpanded(const weld::TreeView& rContentTree, const weld::TreeIter& rEntry)
+    {
+        if (!rContentTree.get_row_expanded(rEntry))
+            return false;
 
-static void lcl_InsertExpandCollapseAllItem(SwContentTree* pContentTree, SvTreeListEntry* pEntry, PopupMenu* pPop)
+        if (!rContentTree.iter_has_child(rEntry))
+            return false;
+
+        std::unique_ptr<weld::TreeIter> xChild(rContentTree.make_iterator(&rEntry));
+        rContentTree.iter_children(*xChild);
+
+        do
+        {
+            if (rContentTree.iter_has_child(*xChild) || rContentTree.get_children_on_demand(*xChild))
+            {
+                if (!IsAllExpanded(rContentTree, *xChild))
+                    return false;
+            }
+        }
+        while (rContentTree.iter_next_sibling(*xChild));
+        return true;
+    }
+}
+
+// Handler for Dragging and ContextMenu
+static bool lcl_InsertExpandCollapseAllItem(weld::TreeView& rContentTree, weld::TreeIter& rEntry, weld::Menu& rPop)
 {
-    if(pEntry->HasChildren() || pEntry->HasChildrenOnDemand())
+    if (rContentTree.iter_has_child(rEntry) || rContentTree.get_children_on_demand(rEntry))
     {
-        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));
+        rPop.set_label(OString::number(800), IsAllExpanded(rContentTree, rEntry) ? SwResId(STR_COLLAPSEALL) : SwResId(STR_EXPANDALL));
+        return false;
     }
+    return true;
 }
 
-VclPtr<PopupMenu> SwContentTree::CreateContextMenu()
+IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool)
 {
-    bool bOutline(false);
+    if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
+        return false;
+
+    std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(m_xTreeView.get(), "modules/swriter/ui/navigatorcontextmenu.ui"));
+    std::unique_ptr<weld::Menu> xPop = xBuilder->weld_menu("navmenu");
 
-    auto pPop = VclPtr<PopupMenu>::Create();
-    VclPtrInstance<PopupMenu> pSubPop1;
-    VclPtrInstance<PopupMenu> pSubPop2;
-    VclPtrInstance<PopupMenu> pSubPop3;
-    VclPtrInstance<PopupMenu> pSubPopOutlineTracking;
+    bool bOutline(false);
+    std::unique_ptr<weld::Menu> xSubPop1 = xBuilder->weld_menu("outlinelevel");
+    std::unique_ptr<weld::Menu> xSubPop2 = xBuilder->weld_menu("dragmodemenu");
+    std::unique_ptr<weld::Menu> xSubPop3 = xBuilder->weld_menu("displaymenu");
+    std::unique_ptr<weld::Menu> xSubPopOutlineTracking = xBuilder->weld_menu("outlinetracking");
 
     for(int i = 1; i <= 3; ++i)
-    {
-        pSubPopOutlineTracking->InsertItem(i + 10, m_aContextStrings[i + IDX_STR_OUTLINE_TRACKING], MenuItemBits::AUTOCHECK | MenuItemBits::RADIOCHECK);
-    }
-    pSubPopOutlineTracking->CheckItem(10 + m_nOutlineTracking);
-    for(int i = 1; i <= MAXLEVEL; ++i)
-    {
-        pSubPop1->InsertItem(i + 100, OUString::number(i), MenuItemBits::AUTOCHECK | MenuItemBits::RADIOCHECK);
-    }
-    pSubPop1->CheckItem(100 + m_nOutlineLevel);

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list