WIP tdf#160817

WIP commit

Change-Id: I9fe93eec6b60f15cfe86aa7953208677a838030e
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index bd394dc..66222aa 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -96,6 +96,8 @@ protected:
    Link<const MouseEvent&, bool> m_aMouseReleaseHdl;

public:
    virtual vcl::Window* GetVclWindow() { return nullptr; }

    virtual void set_sensitive(bool sensitive) = 0;
    virtual bool get_sensitive() const = 0;

diff --git a/include/vcl/wintypes.hxx b/include/vcl/wintypes.hxx
index d0d6208..ede1d0f 100644
--- a/include/vcl/wintypes.hxx
+++ b/include/vcl/wintypes.hxx
@@ -33,7 +33,7 @@ enum class WindowType : sal_uInt16
    ERRORBOX             ,
    QUERYBOX             ,
    WINDOW               ,
    WORKWINDOW           ,
    WORKWINDOW           , //310
    CONTAINER            ,
    FLOATINGWINDOW       ,
    DIALOG               ,
@@ -43,7 +43,7 @@ enum class WindowType : sal_uInt16
    OKBUTTON             ,
    CANCELBUTTON         ,
    HELPBUTTON           ,
    IMAGEBUTTON          ,
    IMAGEBUTTON          , //320
    MENUBUTTON           ,
    MOREBUTTON           ,
    SPINBUTTON           ,
@@ -53,7 +53,7 @@ enum class WindowType : sal_uInt16
    EDIT                 ,
    MULTILINEEDIT        ,
    COMBOBOX             ,
    LISTBOX              ,
    LISTBOX              , //330
    MULTILISTBOX         ,
    FIXEDTEXT            ,
    FIXEDLINE            ,
@@ -63,7 +63,7 @@ enum class WindowType : sal_uInt16
    SCROLLBAR            ,
    SCROLLBARBOX         ,
    SPLITTER             ,
    SPLITWINDOW          ,
    SPLITWINDOW          , //340
    SPINFIELD            ,
    PATTERNFIELD         ,
    METRICFIELD          ,
@@ -73,7 +73,7 @@ enum class WindowType : sal_uInt16
    TIMEFIELD            ,
    PATTERNBOX           ,
    NUMERICBOX           ,
    METRICBOX            ,
    METRICBOX            , //350
    CURRENCYBOX          ,
    DATEBOX              ,
    TIMEBOX              ,
@@ -83,7 +83,7 @@ enum class WindowType : sal_uInt16
    DOCKINGWINDOW        ,
    STATUSBAR            ,
    TABPAGE              ,
    TABCONTROL           ,
    TABCONTROL           , //360
    TABDIALOG            ,
    BORDERWINDOW         ,
    BUTTONDIALOG         ,
@@ -93,7 +93,7 @@ enum class WindowType : sal_uInt16
    TREELISTBOX          ,
    HELPTEXTWINDOW       ,
    INTROWINDOW          ,
    LISTBOXWINDOW        ,
    LISTBOXWINDOW        , //370
    DOCKINGAREA          ,
    RULER                ,
    HEADERBAR            ,
diff --git a/solenv/sanitizers/ui/modules/swriter.suppr b/solenv/sanitizers/ui/modules/swriter.suppr
index 4dd174b..fed392e 100644
--- a/solenv/sanitizers/ui/modules/swriter.suppr
+++ b/solenv/sanitizers/ui/modules/swriter.suppr
@@ -22,6 +22,17 @@ sw/uiconfig/swriter/ui/columnpage.ui://GtkSpinButton[@id='width3mf'] labelled-by
sw/uiconfig/swriter/ui/columnpage.ui://GtkSpinButton[@id='width2mf'] labelled-by-and-mnemonic
sw/uiconfig/swriter/ui/columnpage.ui://GtkSpinButton[@id='width1mf'] labelled-by-and-mnemonic
sw/uiconfig/swriter/ui/conditionpage.ui://GtkComboBoxText[@id='filter'] no-labelled-by
sw/uiconfig/swriter/ui/contenttreefunctionbuttons.ui://GtkToolButton[@id='tabledialog'] button-no-label
sw/uiconfig/swriter/ui/contenttreefunctionbuttons.ui://GtkToolButton[@id='autoformat'] button-no-label
sw/uiconfig/swriter/ui/contenttreefunctionbuttons.ui://GtkToolButton[@id='framedialog'] button-no-label
sw/uiconfig/swriter/ui/contenttreefunctionbuttons.ui://GtkToolButton[@id='graphicdialog'] button-no-label
sw/uiconfig/swriter/ui/contenttreefunctionbuttons.ui://GtkToolButton[@id='insertbookmark'] button-no-label
sw/uiconfig/swriter/ui/contenttreefunctionbuttons.ui://GtkToolButton[@id='hyperlinkdialog'] button-no-label
sw/uiconfig/swriter/ui/contenttreefunctionbuttons.ui://GtkToolButton[@id='edithyperlink'] button-no-label
sw/uiconfig/swriter/ui/contenttreefunctionbuttons.ui://GtkToolButton[@id='removehyperlink'] button-no-label
sw/uiconfig/swriter/ui/contenttreefunctionbuttons.ui://GtkToolButton[@id='updatefields'] button-no-label
sw/uiconfig/swriter/ui/contenttreefunctionbuttons.ui://GtkToolButton[@id='editfielddialog'] button-no-label
sw/uiconfig/swriter/ui/contenttreefunctionbuttons.ui://GtkToolButton[@id='drawingobjectinsertcaptiondialog'] button-no-label
sw/uiconfig/swriter/ui/converttexttable.ui://GtkLabel[@id='label4'] orphan-label
sw/uiconfig/swriter/ui/customizeaddrlistdialog.ui://GtkButton[@id='down'] button-no-label
sw/uiconfig/swriter/ui/customizeaddrlistdialog.ui://GtkButton[@id='up'] button-no-label
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index 27b7248..bcdaf5f 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -137,6 +137,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
	sw/uiconfig/swriter/ui/contentcontroldlg \
	sw/uiconfig/swriter/ui/contentcontroldropdown \
	sw/uiconfig/swriter/ui/contentcontrollistitemdlg \
	sw/uiconfig/swriter/ui/contenttreefunctionbuttons \
	sw/uiconfig/swriter/ui/converttexttable \
	sw/uiconfig/swriter/ui/createaddresslist \
	sw/uiconfig/swriter/ui/createauthorentry \
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index c758b97..c3a8737 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -1799,7 +1799,7 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,

            if ( !bRet
                 && IsAttrAtPos::InetAttr & rContentAtPos.eContentAtPos
                 && !aTmpState.m_bFootnoteNoInfo )
                 && !aTmpState.m_bFootnoteNoInfo ) // reminder comment
            {
                sal_Int32 index = aPos.GetContentIndex();
                pTextAttr = pTextNd->GetTextAttrAt(index, RES_TXTATR_INETFMT);
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 34619f0..6cbee70 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -1732,6 +1732,8 @@ bool SwTextNode::DontExpandFormat( sal_Int32 nIdx, bool bFlag,
    return bRet;
}


// seems off for InetAttr
static bool lcl_GetTextAttrDefault(sal_Int32 nIndex, sal_Int32 nHintStart, sal_Int32 nHintEnd)
{
    return ((nHintStart <= nIndex) && (nIndex <  nHintEnd));
diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx
index 9a67d98..7bb4093 100644
--- a/sw/source/uibase/inc/conttree.hxx
+++ b/sw/source/uibase/inc/conttree.hxx
@@ -36,6 +36,9 @@
#include <editsh.hxx>
#include <edglbldc.hxx>

#include <vcl/InterimItemWindow.hxx>
#include <sfx2/weldutils.hxx>

class SwWrtShell;
class SwContentType;
class SwNavigationPI;
@@ -74,6 +77,50 @@ namespace o3tl {

class SwContentTree;

class SwContentTreeFunctionButtonsWindow final : public InterimItemWindow
{
    SwContentTree* m_pContentTree;
    std::unique_ptr<weld::Toolbar> m_xHeadingsContentFunctionButtonsToolbar;

    std::unique_ptr<weld::Toolbar> m_xTablesContentFunctionButtonsToolbar;
    std::unique_ptr<ToolbarUnoDispatcher> m_xTablesContentFunctionButtonsDispatch;

    std::unique_ptr<weld::Toolbar> m_xFramesContentFunctionButtonsToolbar;
    std::unique_ptr<ToolbarUnoDispatcher> m_xFramesContentFunctionButtonsDispatch;

    std::unique_ptr<weld::Toolbar> m_xImagesContentFunctionButtonsToolbar;
    std::unique_ptr<ToolbarUnoDispatcher> m_xImagesContentFunctionButtonsDispatch;

    std::unique_ptr<weld::Toolbar> m_xBookmarksContentTypeFunctionButtonsToolbar;
    std::unique_ptr<ToolbarUnoDispatcher> m_xBookmarksContentTypeFunctionButtonsDispatch;

    std::unique_ptr<weld::Toolbar> m_xHyperlinksContentTypeFunctionButtonsToolbar;
    std::unique_ptr<weld::Toolbar> m_xHyperlinksContentFunctionButtonsToolbar;
    std::unique_ptr<ToolbarUnoDispatcher> m_xHyperlinksContentTypeFunctionButtonsDispatch;
    std::unique_ptr<ToolbarUnoDispatcher> m_xHyperlinksContentFunctionButtonsDispatch;

    std::unique_ptr<weld::Toolbar> m_xFieldsContentTypeFunctionButtonsToolbar;
    std::unique_ptr<weld::Toolbar> m_xFieldsContentFunctionButtonsToolbar;
    std::unique_ptr<ToolbarUnoDispatcher> m_xFieldsContentTypeFunctionButtonsDispatch;
    std::unique_ptr<ToolbarUnoDispatcher> m_xFieldsContentFunctionButtonsDispatch;

    std::unique_ptr<weld::Toolbar> m_xDrawingobjectsContentFunctionButtonsToolbar;
    std::unique_ptr<ToolbarUnoDispatcher> m_xDrawingobjectsContentFunctionButtonsDispatch;

    std::unique_ptr<weld::Toolbar> m_xDeleteFunctionButtonToolbar;

    DECL_LINK(ToolbarSelectHdl, const OUString&, void );

public:
    SwContentTreeFunctionButtonsWindow(SwContentTree* pContentTree, vcl::Window* pVclWindow,
                                       const css::uno::Reference<css::frame::XFrame>& rxFrame);

    ~SwContentTreeFunctionButtonsWindow() override { disposeOnce(); }
    void dispose() override;

    void ShowForEntry(const weld::TreeIter &rEntry);
};

class SwContentTreeDropTarget final : public DropTargetHelper
{
private:
@@ -89,6 +136,8 @@ public:
/** TreeListBox for content indicator */
class SwContentTree final : public SfxListener
{
    friend class SwContentTreeFunctionButtonsWindow;

    std::unique_ptr<weld::TreeView> m_xTreeView;
    SwContentTreeDropTarget m_aDropTargetHelper;
    SwNavigationPI*     m_pDialog;
@@ -143,6 +192,10 @@ class SwContentTree final : public SfxListener
    std::unique_ptr<weld::TreeIter> m_xOverlayCompareEntry;
    std::unique_ptr<sdr::overlay::OverlayObject> m_xOverlayObject;

    VclPtr<SwContentTreeFunctionButtonsWindow> m_xFunctionButtonsWindow;

    std::unique_ptr<weld::TreeIter> m_xOldSelectedEntry;

    void OverlayObject(std::vector<basegfx::B2DRange>&& aRanges = {});

    void BringEntryToAttention(const weld::TreeIter& rEntry);
@@ -200,6 +253,9 @@ class SwContentTree final : public SfxListener

    void UpdateLastSelType();

    void DeleteAllEntriesOfContentType(const weld::TreeIter& rEntry);


    /** Expand - Remember the state for content types */
    DECL_LINK(ExpandHdl, const weld::TreeIter&, bool);
    /** Collapse - Remember the state for content types. */
@@ -216,6 +272,7 @@ class SwContentTree final : public SfxListener
    DECL_LINK(OverlayObjectDelayTimerHdl, Timer *, void);
    DECL_LINK(MouseMoveHdl, const MouseEvent&, bool);
    DECL_LINK(MousePressHdl, const MouseEvent&, bool);
    DECL_LINK(VisibleRangeChangedHdl, weld::TreeView&, void);

public:
    SwContentTree(std::unique_ptr<weld::TreeView> xTreeView, SwNavigationPI* pDialog);
diff --git a/sw/source/uibase/inc/navipi.hxx b/sw/source/uibase/inc/navipi.hxx
index ff07316..a6ab9a9 100644
--- a/sw/source/uibase/inc/navipi.hxx
+++ b/sw/source/uibase/inc/navipi.hxx
@@ -46,11 +46,16 @@ class SwNavigationPI final : public PanelLayout
    friend class SwNavigatorWin;
    friend class SwContentTree;
    friend class SwGlobalTree;
    friend class SwContentTreeFunctionButtonsWindow;

    ::sfx2::sidebar::ControllerItem m_aDocFullName;
    ::sfx2::sidebar::ControllerItem m_aPageStats;
    ::sfx2::sidebar::ControllerItem m_aNavElement;

    css::uno::Reference<css::frame::XFrame> m_xFrame;

    VclPtr<SfxNavigator> m_xNavigatorDlg;

    std::unique_ptr<weld::Toolbar> m_xContent1ToolBox;
    std::unique_ptr<weld::Toolbar> m_xContent2ToolBox;
    std::unique_ptr<weld::Toolbar> m_xContent3ToolBox;
@@ -71,8 +76,6 @@ class SwNavigationPI final : public PanelLayout
    std::unique_ptr<weld::ComboBox> m_xDocListBox;
    OUString            m_sContentFileName;

    VclPtr<SfxNavigator> m_xNavigatorDlg;

    std::optional<SfxObjectShellLock>  m_oObjectShell;
    SwView              *m_pContentView;
    SwWrtShell          *m_pContentWrtShell;
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index fb7833e..c725211 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -125,6 +125,9 @@

#include <expfld.hxx>

#include <toolkit/helper/vclunohelper.hxx>
#include <iostream>

#define CTYPE_CNT   0
#define CTYPE_CTT   1

@@ -1101,6 +1104,24 @@ const TranslateId STR_CONTEXT_ARY[] =
    STR_OUTLINE_TRACKING_OFF
};

// static void lcl_get_vclwins(VclPtr<vcl::Window> xVclWin, std::vector<VclPtr<vcl::Window>>& rVclWindowsVector)
// {
//     if (xVclWin == nullptr)
//         return;
//     rVclWindowsVector.push_back(xVclWin);
//     auto nChildCount = xVclWin->GetChildCount();
//     //std::cout << "nChildCount = " << nChildCount << " type = " << (sal_uInt16)xVclWin->GetType() << " xVclWin->get_id() = " << xVclWin->get_id() << std::endl;
//     for (auto nChild = 0; nChild < nChildCount; nChild++)
//     {
//         VclPtr<vcl::Window> xVclWinChild = xVclWin->GetChild(nChild);
//         if (xVclWinChild)
//         {
//             //std::cout << "nChild = " << nChild << " type = " << (sal_uInt16)xVclWinChild->GetType() << " xVclWinChild->get_id = " << xVclWinChild->get_id() << std::endl;
//             lcl_get_vclwins(xVclWinChild, rVclWindowsVector);
//         }
//     }
// }

SwContentTree::SwContentTree(std::unique_ptr<weld::TreeView> xTreeView, SwNavigationPI* pDialog)
    : m_xTreeView(std::move(xTreeView))
    , m_aDropTargetHelper(*this)
@@ -1141,6 +1162,49 @@ SwContentTree::SwContentTree(std::unique_ptr<weld::TreeView> xTreeView, SwNaviga
    m_xTreeView->connect_drag_begin(LINK(this, SwContentTree, DragBeginHdl));
    m_xTreeView->connect_mouse_move(LINK(this, SwContentTree, MouseMoveHdl));
    m_xTreeView->connect_mouse_press(LINK(this, SwContentTree, MousePressHdl));
    m_xTreeView->connect_visible_range_changed(LINK(this, SwContentTree, VisibleRangeChangedHdl));

    {
        VclPtr<vcl::Window> xVclWin;
        // {
        //     // hacky way to get the content treeview vcl::Window as opposed to upseting the
        //     // weld::widget class
        //     weld::Window* pWeldWin;
        //     pWeldWin = GetParentWindow()->GetFrameWeld();
        //     //std::cout << "pWeldWin = " << pWeldWin << std::endl;

        //     if (pWeldWin)
        //     {
        //         uno::Reference< awt::XWindow > xWindow = pDialog->m_xFrame->getComponentWindow(); // pWeldWin->GetXWindow();
        //         //std::cout << "xWindow = " << xWindow.get() << std::endl;

        //         xVclWin = VCLUnoHelper::GetWindow(xWindow);
        //         //std::cout << "xVclWin = " << xVclWin.get() << std::endl;

        //         std::vector<VclPtr<vcl::Window>> rVclWindowsVector;
        //         lcl_get_vclwins(xVclWin, rVclWindowsVector);

        //         for (const VclPtr<vcl::Window>& rVclWindowPtr : rVclWindowsVector)
        //         {
        //             //std::cout << "GetType = " << (sal_uInt16) rVclWindowPtr->GetType() << " get_id = " << rVclWindowPtr->get_id() << std::endl;
        //             if (rVclWindowPtr->get_id() == "contenttree")
        //             {
        //                 std::cout << "rVclWindowPtr->get_id() == \"contenttree\"" << std::endl;
        //                 xVclWin = rVclWindowPtr;
        //                 break;
        //             }
        //         }
        //     }
        // }

        if (xVclWin == nullptr)
             xVclWin = m_xTreeView->GetVclWindow();
        if (xVclWin)
        {
            m_xFunctionButtonsWindow.reset(VclPtr<SwContentTreeFunctionButtonsWindow>::Create(this,
                xVclWin, pDialog->m_xFrame));
        }
    }

    for (ContentTypeId i : o3tl::enumrange<ContentTypeId>())
    {
@@ -1190,8 +1254,24 @@ SwContentTree::~SwContentTree()
    SetActiveShell(nullptr);
}

IMPL_LINK_NOARG(SwContentTree, VisibleRangeChangedHdl, weld::TreeView&, void)
{
    if (m_xFunctionButtonsWindow)
        m_xFunctionButtonsWindow->Hide();
}

IMPL_LINK(SwContentTree, MousePressHdl, const MouseEvent&, rMEvt, bool)
{
    if (m_eState == State::HIDDEN)
        return false;
    if (m_xFunctionButtonsWindow)
    {
        std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
        bool bRet = m_xTreeView->get_dest_row_at_pos(rMEvt.GetPosPixel(), xEntry.get(), false,
                                                     false);
        if (bRet && m_xTreeView->get_sensitive(*xEntry, 0))
            m_xFunctionButtonsWindow->ShowForEntry(*xEntry);
    }
    m_bSelectTo = rMEvt.IsShift() && (m_pConfig->IsNavigateOnSelect() || rMEvt.GetClicks() == 2);
    return false;
}
@@ -1205,9 +1285,23 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, rMEvt, bool)
        return false;
    if (m_eState == State::HIDDEN)
        return false;
    if (std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
            m_xTreeView->get_dest_row_at_pos(rMEvt.GetPosPixel(), xEntry.get(), false, false) &&
            !rMEvt.IsLeaveWindow())

    std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
    bool bRet = m_xTreeView->get_dest_row_at_pos(rMEvt.GetPosPixel(), xEntry.get(), false, false);

    if (bRet && m_xFunctionButtonsWindow)
    {
        if (m_xTreeView->is_selected(*xEntry) && m_xTreeView->get_sensitive(*xEntry, 0))
        {
            m_xFunctionButtonsWindow->ShowForEntry(*xEntry);
        }
        else if (m_xFunctionButtonsWindow->IsVisible())
        {
            m_xFunctionButtonsWindow->Hide();
        }
    }

    if (bRet && !rMEvt.IsLeaveWindow())
    {
        if (!m_xOverlayCompareEntry)
            m_xOverlayCompareEntry.reset(m_xTreeView->make_iterator().release());
@@ -1218,6 +1312,9 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, rMEvt, bool)
    }
    else
    {
        if (m_xFunctionButtonsWindow)
            m_xFunctionButtonsWindow->Hide();

        if (m_xOverlayCompareEntry)
            m_xOverlayCompareEntry.reset();
        m_aOverlayObjectDelayTimer.Stop();
@@ -4155,7 +4252,8 @@ static void lcl_SelectByContentTypeAndName(SwContentTree* pThis, weld::TreeView&
    }
}

static void lcl_SelectDrawObjectByName(weld::TreeView& rContentTree, std::u16string_view rName)
static void lcl_SelectDrawObjectByName(SwContentTree* pThis, weld::TreeView& rContentTree,
                                       std::u16string_view rName)
{
    if (rName.empty())
        return;
@@ -4177,6 +4275,7 @@ static void lcl_SelectDrawObjectByName(weld::TreeView& rContentTree, std::u16str
                {
                    rContentTree.select(*xIter);
                    rContentTree.scroll_to_row(*xIter);
                    pThis->Select(); // maybe make this only happen once for the loop?
                }
                break;
            }
@@ -4317,15 +4416,15 @@ void SwContentTree::UpdateTracking()
                        SdrObject* pSelected = pSdrView->GetMarkedObjectByIndex(nIdx);
                        OUString aName(pSelected->GetName());
                        if (!aName.isEmpty())
                            lcl_SelectDrawObjectByName(*m_xTreeView, aName);
                            lcl_SelectDrawObjectByName(this, *m_xTreeView, aName);
                    }
                }
                else
                {
                    // clear treeview selections
                    m_xTreeView->unselect_all();
                    Select();
                }
                Select();
            }
            return;
        }
@@ -5077,46 +5176,7 @@ void SwContentTree::ExecuteContextMenuAction(const OUString& rSelectedPopupEntry

    if (rSelectedPopupEntry == "deleteallfootnotes" || rSelectedPopupEntry == "deleteallendnotes")
    {
        if (!lcl_IsContentType(*xFirst, *m_xTreeView))
            return;

        //MakeAllOutlineContentTemporarilyVisible a(m_pActiveShell->GetDoc());

        m_pActiveShell->AssureStdMode();

        SwCursor* pCursor = m_pActiveShell->getShellCursor(true);

        SwContentType* pCntType = weld::fromId<SwContentType*>(m_xTreeView->get_id(*xFirst));
        const auto nCount = pCntType->GetMemberCount();

        m_pActiveShell->StartAction();
        m_pActiveShell->EnterAddMode();
        for (size_t i = 0; i < nCount; i++)
        {
            const SwTextFootnoteContent* pTextFootnoteCnt =
                    static_cast<const SwTextFootnoteContent*>(pCntType->GetMember(i));
            if (pTextFootnoteCnt && !pTextFootnoteCnt->IsInvisible())
            {
                if (const SwTextAttr* pTextAttr = pTextFootnoteCnt->GetTextFootnote())
                {
                    const SwTextFootnote* pTextFootnote = pTextAttr->GetFootnote().GetTextFootnote();
                    if (!pTextFootnote)
                        continue;
                    const SwTextNode& rTextNode = pTextFootnote->GetTextNode();
                    auto nStart = pTextAttr->GetStart();
                    pCursor->GetPoint()->Assign(rTextNode, nStart + 1);
                    m_pActiveShell->SetMark();
                    m_pActiveShell->SttSelect();
                    pCursor->GetPoint()->Assign(rTextNode, nStart);
                    m_pActiveShell->EndSelect();
                }
            }
        }
        m_pActiveShell->LeaveAddMode();
        m_pActiveShell->EndAction();

        m_pActiveShell->DelRight();

        DeleteAllEntriesOfContentType(*xFirst);
        return;
    }

@@ -5500,6 +5560,9 @@ void SwContentTree::ShowActualView()

IMPL_LINK_NOARG(SwContentTree, SelectHdl, weld::TreeView&, void)
{
    std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
    if (!m_xTreeView->get_selected(xEntry.get()))
        return;
    if (m_pConfig->IsNavigateOnSelect())
    {
        ContentDoubleClickHdl(*m_xTreeView);
@@ -5509,9 +5572,6 @@ IMPL_LINK_NOARG(SwContentTree, SelectHdl, weld::TreeView&, void)
    if (m_bIsRoot)
        return;
    // Select the content type in the Navigate By control
    std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
    if (!m_xTreeView->get_selected(xEntry.get()))
        return;
    while (m_xTreeView->get_iter_depth(*xEntry))
        m_xTreeView->iter_parent(*xEntry);
    m_pDialog->SelectNavigateByContentType(m_xTreeView->get_text(*xEntry));
@@ -5523,14 +5583,29 @@ IMPL_LINK_NOARG(SwContentTree, SelectHdl, weld::TreeView&, void)
// sorted or when the selected entry is not outline content.
void SwContentTree::Select()
{
    if (m_xFunctionButtonsWindow)
        m_xFunctionButtonsWindow->Hide();

    std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
    if (!m_xTreeView->get_selected(xEntry.get()))
    {
        m_xOldSelectedEntry.reset();
        return;
    }

    if (!m_xOldSelectedEntry)
        m_xOldSelectedEntry = m_xTreeView->make_iterator();
    else if (m_xTreeView->iter_compare(*xEntry, *m_xOldSelectedEntry) == 0)
        return;
    m_xTreeView->copy_iterator(*xEntry, *m_xOldSelectedEntry);

    SwNavigationPI* pNavi = GetParentWindow();

    bool bEnable = false;

    if (!pNavi->IsZoomedIn() && !m_bIsLastReadOnly)
    {
        std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
        if (m_xTreeView->get_selected(xEntry.get()) && lcl_IsContent(*xEntry, *m_xTreeView))
        if (lcl_IsContent(*xEntry, *m_xTreeView))
        {
            const SwContentType* pCntType =
                    weld::fromId<SwContent*>(m_xTreeView->get_id(*xEntry))->GetParent();
@@ -5565,6 +5640,177 @@ OUString SwContentType::RemoveNewline(const OUString& rEntry)
    return aEntry.makeStringAndClear();
}

void SwContentTree::DeleteAllEntriesOfContentType(const weld::TreeIter& rEntry)
{
    if (!lcl_IsContentType(rEntry, *m_xTreeView))
        return;

    SwContentType* pContentType = weld::fromId<SwContentType*>(m_xTreeView->get_id(rEntry));
    const ContentTypeId eContentTypeId = pContentType->GetType();
    if (eContentTypeId == ContentTypeId::TABLE)
    {
        m_pActiveShell->AssureStdMode();

        const auto nCount = pContentType->GetMemberCount();

        m_pActiveShell->StartAction();
        SwRewriter aRewriter;
        aRewriter.AddRule(UndoArg1, pContentType->GetName());
        m_pActiveShell->StartUndo(SwUndoId::DELETE, &aRewriter);
        for (size_t i = 0; i < nCount; i++)
        {
            const OUString& rName(pContentType->GetMember(i)->GetName());
            m_pActiveShell->GotoTable(rName);
            m_pActiveShell->SelAll();
            m_pActiveShell->DeleteTable();
        }
        m_pActiveShell->EndUndo();
        m_pActiveShell->EndAction();
    }
    else if (eContentTypeId == ContentTypeId::FRAME
             || eContentTypeId == ContentTypeId::GRAPHIC
             || eContentTypeId == ContentTypeId::OLE)
    {
        m_pActiveShell->AssureStdMode();

        const auto nCount = pContentType->GetMemberCount();

        m_pActiveShell->LockView(true);
        SwRewriter aRewriter;
        aRewriter.AddRule(UndoArg1, pContentType->GetName());
        m_pActiveShell->StartUndo(SwUndoId::DELETE, &aRewriter);
        for (size_t i = 0; i < nCount; i++)
        {
            const OUString& rName(pContentType->GetMember(i)->GetName());
            m_pActiveShell->GotoFly(rName);
            m_pActiveShell->DelRight();
        }
        m_pActiveShell->EndUndo();
        m_pActiveShell->LockView(false);
    }
    else if (eContentTypeId == ContentTypeId::BOOKMARK)
    {
        m_pActiveShell->AssureStdMode();

        const auto nCount = pContentType->GetMemberCount();

        IDocumentMarkAccess* const pMarkAccess = m_pActiveShell->getIDocumentMarkAccess();

        m_pActiveShell->StartAction();
        SwRewriter aRewriter;
        aRewriter.AddRule(UndoArg1, pContentType->GetName());
        m_pActiveShell->StartUndo(SwUndoId::DELETE, &aRewriter);
        for (size_t i = 0; i < nCount; i++)
        {
            const OUString& rName(pContentType->GetMember(i)->GetName());
            pMarkAccess->deleteMark(pMarkAccess->findMark(rName), false);
        }
        m_pActiveShell->EndUndo();
        m_pActiveShell->EndAction();
    }
    else if (eContentTypeId == ContentTypeId::URLFIELD) // hyperlinks
    {
        m_pActiveShell->AssureStdMode();

        const auto nCount = pContentType->GetMemberCount();

        m_pActiveShell->LockView(true);
        SwRewriter aRewriter;
        aRewriter.AddRule(UndoArg1, pContentType->GetName());
        m_pActiveShell->StartUndo(SwUndoId::DELETE, &aRewriter);
        for (size_t i = 0; i < nCount; i++)
        {
            if (m_pActiveShell->GotoINetAttr(*static_cast<const SwURLFieldContent*>(
                                                pContentType->GetMember(i))->GetINetAttr() ))
            {
                m_pActiveShell->Right(SwCursorSkipMode::Chars, false, 1, false);
                m_pActiveShell->SwCursorShell::SelectTextAttr(RES_TXTATR_INETFMT, true);
                m_pActiveShell->DelRight();
            }
        }
        m_pActiveShell->EndUndo();
        m_pActiveShell->LockView(false);
    }
    if (eContentTypeId == ContentTypeId::DRAWOBJECT)
    {
        m_pActiveShell->AssureStdMode();

        const auto nCount = pContentType->GetMemberCount();

        m_pActiveShell->StartAction();
        SwRewriter aRewriter;
        aRewriter.AddRule(UndoArg1, pContentType->GetName());
        m_pActiveShell->StartUndo(SwUndoId::DELETE, &aRewriter);
        for (size_t i = 0; i < nCount; i++)
        {
            const OUString& rName(pContentType->GetMember(i)->GetName());
            m_pActiveShell->GotoDrawingObject(rName);
            m_pActiveShell->DelRight();
            //m_pActiveShell->DelSelectedObj();
        }
        m_pActiveShell->EndUndo();
        m_pActiveShell->EndAction();
    }
    else if (eContentTypeId == ContentTypeId::TEXTFIELD)
    {
        m_pActiveShell->AssureStdMode();

        const auto nCount = pContentType->GetMemberCount();

        m_pActiveShell->StartAction();
        SwRewriter aRewriter;
        aRewriter.AddRule(UndoArg1, pContentType->GetName());
        m_pActiveShell->StartUndo(SwUndoId::DELETE, &aRewriter);
        for (size_t i = 0; i < nCount; i++)
        {
            const SwTextFieldContent* pTextFieldContent =
                    static_cast<const SwTextFieldContent*>(pContentType->GetMember(i));
            const SwTextField* pTextField = pTextFieldContent->GetFormatField()->GetTextField();
            SwTextField::DeleteTextField(*pTextField);
        }
        m_pActiveShell->EndUndo();
        m_pActiveShell->EndAction();
    }
    else if (eContentTypeId == ContentTypeId::FOOTNOTE || eContentTypeId == ContentTypeId::ENDNOTE)
    {
        //MakeAllOutlineContentTemporarilyVisible a(m_pActiveShell->GetDoc());

        m_pActiveShell->AssureStdMode();

        SwCursor* pCursor = m_pActiveShell->getShellCursor(true);

        const auto nCount = pContentType->GetMemberCount();

        m_pActiveShell->StartAction();
        m_pActiveShell->EnterAddMode();
        for (size_t i = 0; i < nCount; i++)
        {
            const SwTextFootnoteContent* pTextFootnoteCnt =
                    static_cast<const SwTextFootnoteContent*>(pContentType->GetMember(i));
            if (pTextFootnoteCnt && !pTextFootnoteCnt->IsInvisible())
            {
                if (const SwTextAttr* pTextAttr = pTextFootnoteCnt->GetTextFootnote())
                {
                    const SwTextFootnote* pTextFootnote = pTextAttr->GetFootnote().GetTextFootnote();
                    if (!pTextFootnote)
                        continue;
                    const SwTextNode& rTextNode = pTextFootnote->GetTextNode();
                    auto nStart = pTextAttr->GetStart();
                    pCursor->GetPoint()->Assign(rTextNode, nStart + 1);
                    m_pActiveShell->SetMark();
                    m_pActiveShell->SttSelect();
                    pCursor->GetPoint()->Assign(rTextNode, nStart);
                    m_pActiveShell->EndSelect();
                }
            }
        }
        m_pActiveShell->LeaveAddMode();
        m_pActiveShell->EndAction();

        m_pActiveShell->DelRight();
    }
}

void SwContentTree::EditEntry(const weld::TreeIter& rEntry, EditEntryMode nMode)
{
    SwContent* pCnt = weld::fromId<SwContent*>(m_xTreeView->get_id(rEntry));
@@ -5593,21 +5839,9 @@ void SwContentTree::EditEntry(const weld::TreeIter& rEntry, EditEntryMode nMode)
            }
            else if(nMode == EditEntryMode::DELETE)
            {
                m_pActiveShell->StartAction();
                OUString sTable = SwResId(STR_TABLE_NAME);
                SwRewriter aRewriterTableName;
                aRewriterTableName.AddRule(UndoArg1, SwResId(STR_START_QUOTE));
                aRewriterTableName.AddRule(UndoArg2, pCnt->GetName());
                aRewriterTableName.AddRule(UndoArg3, SwResId(STR_END_QUOTE));
                sTable = aRewriterTableName.Apply(sTable);

                SwRewriter aRewriter;
                aRewriter.AddRule(UndoArg1, sTable);
                m_pActiveShell->StartUndo(SwUndoId::DELETE, &aRewriter);
                m_pActiveShell->GetView().GetViewFrame().GetDispatcher()->Execute(FN_TABLE_SELECT_ALL);
                m_pActiveShell->DeleteRow();
                m_pActiveShell->EndUndo();
                m_pActiveShell->EndAction();
                //m_pActiveShell->GotoTable(pCnt->GetName());
                m_pActiveShell->SelAll();
                m_pActiveShell->DeleteTable();
            }
            else if(nMode == EditEntryMode::RENAME)
            {
@@ -6015,8 +6249,27 @@ void SwContentTree::GotoContent(const SwContent* pCnt)
            if(m_pActiveShell->GotoINetAttr(
                            *static_cast<const SwURLFieldContent*>(pCnt)->GetINetAttr() ))
            {
                m_pActiveShell->Right( SwCursorSkipMode::Chars, true, 1, false);
                m_pActiveShell->SwCursorShell::SelectTextAttr( RES_TXTATR_INETFMT, true );
                m_pActiveShell->Right( SwCursorSkipMode::Chars, false, 1, false);
                // m_pActiveShell->SwCursorShell::SelectTextAttr( RES_TXTATR_INETFMT, true );

                // if (!m_bSelectTo)
                // {
                //     // After the edit dialog is opened this hack doesn't work anymore

                //     // Going to a hyperlink results in the document cursor set to a position that
                //     // content tracking doesn't detect as a hyperlink. It seems the above
                //     // SwCursorShell::SelectTextAttr(RES_TXTATR_INETFMT, true) sets the document
                //     // cursor to a position that SwCursorShell::GetContentAtPos doesn't recognize
                //     // as an IsAttrAtPos::InetAttr. Swapping the point and mark seems to work
                //     // around this problem but causes a slight funk with arrow key cursor movement
                //     // which is probably not noticable enough to be of concern.
                //     // See: UpdateTracking()
                //     //    // hyperlinks
                //     //    if (SwContentAtPos aContentAtPos(IsAttrAtPos::InetAttr);
                //     //        m_pActiveShell->GetContentAtPos(m_pActiveShell->GetCursorDocPos(), aContentAtPos)
                //     m_pActiveShell->SwapPam();
                //     m_pActiveShell->UpdateCursor(); // cause probelem for hyperlinks in footnotes when '&& !aTmpState.m_bFootnoteNoInfo' isn't commented out in GetContentAtPos
                // }
            }
        }
        break;
@@ -6825,4 +7078,252 @@ void SwContentTree::BringTextFieldsToAttention(std::vector<const SwTextAttr*>& r
    OverlayObject(std::move(aRanges));
}

SwContentTreeFunctionButtonsWindow::SwContentTreeFunctionButtonsWindow(SwContentTree* pContentTree,
                                                                       vcl::Window *pVclWindow,
                                                                       const css::uno::Reference<css::frame::XFrame>& rxFrame)
    : InterimItemWindow(pVclWindow,
                        "modules/swriter/ui/contenttreefunctionbuttons.ui",
                        "ContentTreeFunctionButtons")
    , m_pContentTree(pContentTree)
    , m_xHeadingsContentFunctionButtonsToolbar(m_xBuilder->weld_toolbar("HeadingsContentFunctionButtonsToolbar"))
    , m_xTablesContentFunctionButtonsToolbar(m_xBuilder->weld_toolbar("TablesContentFunctionButtonsToolbar"))
    , m_xTablesContentFunctionButtonsDispatch(new ToolbarUnoDispatcher(*m_xTablesContentFunctionButtonsToolbar,
                                                                       *m_xBuilder, rxFrame))
    , m_xFramesContentFunctionButtonsToolbar(m_xBuilder->weld_toolbar("FramesContentFunctionButtonsToolbar"))
    , m_xFramesContentFunctionButtonsDispatch(new ToolbarUnoDispatcher(*m_xFramesContentFunctionButtonsToolbar,
                                                                       *m_xBuilder, rxFrame))
    , m_xImagesContentFunctionButtonsToolbar(m_xBuilder->weld_toolbar("ImagesContentFunctionButtonsToolbar"))
    , m_xImagesContentFunctionButtonsDispatch(new ToolbarUnoDispatcher(*m_xImagesContentFunctionButtonsToolbar,
                                                                       *m_xBuilder, rxFrame))
    , m_xBookmarksContentTypeFunctionButtonsToolbar(m_xBuilder->weld_toolbar("BookmarksContentTypeFunctionButtonsToolbar"))
    , m_xBookmarksContentTypeFunctionButtonsDispatch(new ToolbarUnoDispatcher(*m_xBookmarksContentTypeFunctionButtonsToolbar,
                                                                              *m_xBuilder, rxFrame))
    , m_xHyperlinksContentTypeFunctionButtonsToolbar(m_xBuilder->weld_toolbar("HyperlinksContentTypeFunctionButtonsToolbar"))
    , m_xHyperlinksContentFunctionButtonsToolbar(m_xBuilder->weld_toolbar("HyperlinksContentFunctionButtonsToolbar"))
    , m_xHyperlinksContentTypeFunctionButtonsDispatch(new ToolbarUnoDispatcher(*m_xHyperlinksContentTypeFunctionButtonsToolbar,
                                                                               *m_xBuilder, rxFrame))
    , m_xHyperlinksContentFunctionButtonsDispatch(new ToolbarUnoDispatcher(*m_xHyperlinksContentFunctionButtonsToolbar,
                                                                           *m_xBuilder, rxFrame))
    , m_xFieldsContentTypeFunctionButtonsToolbar(m_xBuilder->weld_toolbar("FieldsContentTypeFunctionButtonsToolbar"))
    , m_xFieldsContentFunctionButtonsToolbar(m_xBuilder->weld_toolbar("FieldsContentFunctionButtonsToolbar"))
    , m_xFieldsContentTypeFunctionButtonsDispatch(new ToolbarUnoDispatcher(*m_xFieldsContentTypeFunctionButtonsToolbar,
                                                                           *m_xBuilder, rxFrame))
    , m_xFieldsContentFunctionButtonsDispatch(new ToolbarUnoDispatcher(*m_xFieldsContentFunctionButtonsToolbar,
                                                                       *m_xBuilder, rxFrame))
    , m_xDrawingobjectsContentFunctionButtonsToolbar(m_xBuilder->weld_toolbar("DrawingobjectsContentFunctionButtonsToolbar"))
    , m_xDrawingobjectsContentFunctionButtonsDispatch(new ToolbarUnoDispatcher(*m_xDrawingobjectsContentFunctionButtonsToolbar,
                                                                               *m_xBuilder, rxFrame))
    , m_xDeleteFunctionButtonToolbar(m_xBuilder->weld_toolbar("DeleteFunctionButtonToolbar"))
{
    //InitControlBase(&pContentTree->get_widget());

    //const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
    //Color aColor = rStyleSettings.GetActiveColor();
    Color aColor = COL_YELLOW;
    SetBackground(aColor);

    Link<const OUString&, void> aLk = LINK(this, SwContentTreeFunctionButtonsWindow,
                                           ToolbarSelectHdl);
    m_xHeadingsContentFunctionButtonsToolbar->connect_clicked(aLk);
    m_xDeleteFunctionButtonToolbar->connect_clicked(aLk);
}

void SwContentTreeFunctionButtonsWindow::dispose()
{
    m_xHeadingsContentFunctionButtonsToolbar.reset();
    m_xTablesContentFunctionButtonsToolbar.reset();
    m_xTablesContentFunctionButtonsDispatch.reset();
    m_xBookmarksContentTypeFunctionButtonsToolbar.reset();
    m_xBookmarksContentTypeFunctionButtonsDispatch.reset();
    m_xHyperlinksContentTypeFunctionButtonsToolbar.reset();
    m_xHyperlinksContentFunctionButtonsToolbar.reset();
    m_xHyperlinksContentTypeFunctionButtonsDispatch.reset();
    m_xHyperlinksContentFunctionButtonsDispatch.reset();
    m_xFieldsContentTypeFunctionButtonsToolbar.reset();
    m_xFieldsContentFunctionButtonsToolbar.reset();
    m_xFieldsContentTypeFunctionButtonsDispatch.reset();
    m_xFieldsContentFunctionButtonsDispatch.reset();
    m_xDrawingobjectsContentFunctionButtonsToolbar.reset();
    m_xDrawingobjectsContentFunctionButtonsDispatch.reset();
    m_xDeleteFunctionButtonToolbar.reset();

    InterimItemWindow::dispose();
}

IMPL_LINK(SwContentTreeFunctionButtonsWindow, ToolbarSelectHdl, const OUString&, rCommand, void)
{
    Hide();
    if (rCommand == "promote")
    {
        m_pContentTree->ExecCommand(u"promote", true);
    }
    else if (rCommand == "demote")
    {
        m_pContentTree->ExecCommand(u"demote", true);
    }
    else if (rCommand == "chaptermoveup")
    {
        m_pContentTree->ExecCommand(u"chapterup", true);
    }
    else if (rCommand == "chaptermovedown")
    {
        m_pContentTree->ExecCommand(u"chapterdown", true);
    }
    else if (rCommand == "delete")
    {
        std::unique_ptr<weld::TreeIter> xEntry(m_pContentTree->m_xTreeView->make_iterator());
        if (m_pContentTree->m_xTreeView->get_selected(xEntry.get()))
        {
            if (lcl_IsContentType(*xEntry, *m_pContentTree->m_xTreeView))
            {
                SwContentType* pContentType
                        = weld::fromId<SwContentType*>(m_pContentTree->m_xTreeView->get_id(*xEntry));
                const ContentTypeId eContentTypeId = pContentType->GetType();
                if (eContentTypeId == ContentTypeId::TABLE
                        || eContentTypeId == ContentTypeId::FRAME
                        || eContentTypeId == ContentTypeId::GRAPHIC
                        || eContentTypeId == ContentTypeId::OLE
                        || eContentTypeId == ContentTypeId::BOOKMARK
                        || eContentTypeId == ContentTypeId::URLFIELD
                        || eContentTypeId == ContentTypeId::DRAWOBJECT
                        || eContentTypeId == ContentTypeId::TEXTFIELD
                        || eContentTypeId == ContentTypeId::FOOTNOTE
                        || eContentTypeId == ContentTypeId::ENDNOTE)
                {
                    m_pContentTree->DeleteAllEntriesOfContentType(*xEntry);
                }
            }
            else
            {
                SwContent* pContent =
                        weld::fromId<SwContent*>(m_pContentTree->m_xTreeView->get_id(*xEntry));
                if (pContent->GetParent()->IsDeletable())
                {
                    m_pContentTree->EditEntry(*xEntry, EditEntryMode::DELETE);
                }
            }
        }
    }
}

void SwContentTreeFunctionButtonsWindow::ShowForEntry(const weld::TreeIter &rEntry)
{
    m_xHeadingsContentFunctionButtonsToolbar->hide();
    m_xTablesContentFunctionButtonsToolbar->hide();
    m_xFramesContentFunctionButtonsToolbar->hide();
    m_xImagesContentFunctionButtonsToolbar->hide();
    m_xBookmarksContentTypeFunctionButtonsToolbar->hide();
    m_xHyperlinksContentFunctionButtonsToolbar->hide();
    m_xHyperlinksContentTypeFunctionButtonsToolbar->hide();
    m_xDrawingobjectsContentFunctionButtonsToolbar->hide();
    m_xFieldsContentTypeFunctionButtonsToolbar->hide();
    m_xFieldsContentFunctionButtonsToolbar->hide();

    const auto nButtonWidth = 25;

    auto nWindowWidth = 0;

    const SwContentType* pContentType;
    ContentTypeId eContentTypeId;

    weld::TreeView& rTreeView = m_pContentTree->get_widget();
    if (lcl_IsContentType(rEntry, rTreeView))
    {
        pContentType = weld::fromId<SwContentType*>(rTreeView.get_id(rEntry));
        eContentTypeId = pContentType->GetType();
        if (eContentTypeId == ContentTypeId::BOOKMARK)
        {
            m_xBookmarksContentTypeFunctionButtonsToolbar->show();
            nWindowWidth += nButtonWidth * m_xBookmarksContentTypeFunctionButtonsToolbar->get_n_items();
        }
        else if (eContentTypeId == ContentTypeId::URLFIELD)
        {
            m_xHyperlinksContentTypeFunctionButtonsToolbar->show();
            nWindowWidth += nButtonWidth * m_xHyperlinksContentTypeFunctionButtonsToolbar->get_n_items();
        }
        else if (eContentTypeId == ContentTypeId::TEXTFIELD)
        {
            m_xFieldsContentTypeFunctionButtonsToolbar->show();
            nWindowWidth += nButtonWidth * m_xFieldsContentTypeFunctionButtonsToolbar->get_n_items();
        }
        else if (eContentTypeId != ContentTypeId::TABLE
                 && eContentTypeId != ContentTypeId::FRAME
                 && eContentTypeId != ContentTypeId::GRAPHIC
                 && eContentTypeId != ContentTypeId::OLE
                 && eContentTypeId != ContentTypeId::BOOKMARK
                 && eContentTypeId != ContentTypeId::URLFIELD
                 && eContentTypeId != ContentTypeId::DRAWOBJECT
                 && eContentTypeId != ContentTypeId::TEXTFIELD
                 && eContentTypeId != ContentTypeId::FOOTNOTE
                 && eContentTypeId != ContentTypeId::ENDNOTE)
        {
            Hide();
            return;
        }
    }
    else
    {
        pContentType = weld::fromId<SwContent*>(rTreeView.get_id(rEntry))->GetParent();
        eContentTypeId = pContentType->GetType();
        if (eContentTypeId == ContentTypeId::OUTLINE)
        {
            m_xHeadingsContentFunctionButtonsToolbar->show();
            nWindowWidth += nButtonWidth * m_xHeadingsContentFunctionButtonsToolbar->get_n_items();
        }
        else if (eContentTypeId == ContentTypeId::TABLE
                 && m_pContentTree->m_pConfig->IsNavigateOnSelect())
        {
            m_xTablesContentFunctionButtonsToolbar->show();
            nWindowWidth += nButtonWidth * m_xTablesContentFunctionButtonsToolbar->get_n_items();
        }
        else if ((eContentTypeId == ContentTypeId::FRAME || eContentTypeId == ContentTypeId::OLE)
                 && m_pContentTree->m_pConfig->IsNavigateOnSelect())
        {
            m_xFramesContentFunctionButtonsToolbar->show();
            nWindowWidth += nButtonWidth * m_xFramesContentFunctionButtonsToolbar->get_n_items();
        }
        else if (eContentTypeId == ContentTypeId::GRAPHIC
                 && m_pContentTree->m_pConfig->IsNavigateOnSelect())
        {
            m_xImagesContentFunctionButtonsToolbar->show();
            nWindowWidth += nButtonWidth * m_xImagesContentFunctionButtonsToolbar->get_n_items();
        }
        else if (eContentTypeId == ContentTypeId::URLFIELD
                 && m_pContentTree->m_pConfig->IsNavigateOnSelect())
        {
            m_xHyperlinksContentFunctionButtonsToolbar->show();
            nWindowWidth += nButtonWidth * m_xHyperlinksContentFunctionButtonsToolbar->get_n_items();
        }
        else if (eContentTypeId == ContentTypeId::DRAWOBJECT
                 && m_pContentTree->m_pConfig->IsNavigateOnSelect())
        {
           m_xDrawingobjectsContentFunctionButtonsToolbar->show();
           nWindowWidth += nButtonWidth * m_xDrawingobjectsContentFunctionButtonsToolbar->get_n_items();
        }
        else if (eContentTypeId == ContentTypeId::TEXTFIELD
                 && m_pContentTree->m_pConfig->IsNavigateOnSelect())
        {
            m_xFieldsContentFunctionButtonsToolbar->show();
            nWindowWidth += nButtonWidth * m_xFieldsContentFunctionButtonsToolbar->get_n_items();
        }
    }

    // plus the width of the delete toolbar
    nWindowWidth += nButtonWidth;

    int x, y, width, height;
    rTreeView.get_extents_relative_to(rTreeView/**m_pWidget*/, x, y, width, height);

    tools::Rectangle rRowAreaRect = rTreeView.get_row_area(rEntry);

    SetSizePixel(Size(nWindowWidth, rRowAreaRect.GetHeight() + 9));

    Point aPosPixelPoint;
    aPosPixelPoint.setX(width - nWindowWidth - 40);
    aPosPixelPoint.setY(rRowAreaRect.getY() - 4);

    SetPosPixel(aPosPixelPoint);

    Show(true);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx
index e86e51c..54415b6 100644
--- a/sw/source/uibase/utlui/navipi.cxx
+++ b/sw/source/uibase/utlui/navipi.cxx
@@ -426,6 +426,8 @@ SwNavigationPI::SwNavigationPI(weld::Widget* pParent,
    , m_aDocFullName(SID_DOCFULLNAME, *_pBindings, *this)
    , m_aPageStats(FN_STAT_PAGE, *_pBindings, *this)
    , m_aNavElement(FN_NAV_ELEMENT, *_pBindings, *this)
    , m_xFrame(rxFrame)
    , m_xNavigatorDlg(pNavigatorDlg)
    , m_xContent1ToolBox(m_xBuilder->weld_toolbar("content1"))
    , m_xContent2ToolBox(m_xBuilder->weld_toolbar("content2"))
    , m_xContent3ToolBox(m_xBuilder->weld_toolbar("content3"))
@@ -444,7 +446,6 @@ SwNavigationPI::SwNavigationPI(weld::Widget* pParent,
    , m_xGlobalBox(m_xBuilder->weld_widget("globalbox"))
    , m_xGlobalTree(new SwGlobalTree(m_xBuilder->weld_tree_view("globaltree"), this))
    , m_xDocListBox(m_xBuilder->weld_combo_box("documents"))
    , m_xNavigatorDlg(pNavigatorDlg)
    , m_pContentView(nullptr)
    , m_pContentWrtShell(nullptr)
    , m_pActContView(nullptr)
diff --git a/sw/uiconfig/swriter/ui/contenttreefunctionbuttons.ui b/sw/uiconfig/swriter/ui/contenttreefunctionbuttons.ui
new file mode 100644
index 0000000..31afe06
--- /dev/null
+++ b/sw/uiconfig/swriter/ui/contenttreefunctionbuttons.ui
@@ -0,0 +1,458 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<interface domain="sw">
  <requires lib="gtk+" version="3.20"/>
  <object class="GtkBox" id="ContentTreeFunctionButtons">
    <property name="visible">True</property>
    <property name="can-focus">False</property>
    <property name="valign">center</property>
    <property name="hexpand">True</property>
    <property name="vexpand">True</property>
    <property name="orientation">vertical</property>
    <property name="baseline-position">top</property>
    <child>
      <object class="GtkBox">
        <property name="visible">True</property>
        <property name="can-focus">False</property>
        <child>
          <object class="GtkBox" id="headings">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
            <property name="valign">center</property>
            <property name="hexpand">True</property>
            <property name="vexpand">True</property>
            <child>
              <object class="GtkToolbar" id="HeadingsContentFunctionButtonsToolbar">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
                <property name="valign">center</property>
                <property name="hexpand">True</property>
                <property name="vexpand">True</property>
                <property name="toolbar-style">icons</property>
                <property name="show-arrow">False</property>
                <child>
                  <object class="GtkToolButton" id="promote">
                    <property name="visible">True</property>
                    <property name="can-focus">False</property>
                    <property name="tooltip-text" translatable="yes" context="contenttreefunctionbuttons|promote|tooltip_text">Promote Outline Level</property>
                    <property name="hexpand">True</property>
                    <property name="vexpand">True</property>
                    <property name="icon-name">sw/res/sc20172.png</property>
                  </object>
                  <packing>
                    <property name="expand">True</property>
                    <property name="homogeneous">True</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkToolButton" id="demote">
                    <property name="visible">True</property>
                    <property name="can-focus">False</property>
                    <property name="tooltip-text" translatable="yes" context="contenttreefunctionbuttons|demote|tooltip_text">Demote Outline Level</property>
                    <property name="hexpand">True</property>
                    <property name="vexpand">True</property>
                    <property name="icon-name">sw/res/sc20173.png</property>
                  </object>
                  <packing>
                    <property name="expand">True</property>
                    <property name="homogeneous">True</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkToolButton" id="chaptermoveup">
                    <property name="visible">True</property>
                    <property name="can-focus">False</property>
                    <property name="tooltip-text" translatable="yes" context="contenttreefunctionbuttons|chaptermoveup|tooltip_text">Move Heading Up</property>
                    <property name="hexpand">True</property>
                    <property name="vexpand">True</property>
                    <property name="icon-name">sw/res/sc20174.png</property>
                  </object>
                  <packing>
                    <property name="expand">True</property>
                    <property name="homogeneous">True</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkToolButton" id="chaptermovedown">
                    <property name="visible">True</property>
                    <property name="can-focus">False</property>
                    <property name="tooltip-text" translatable="yes" context="contenttreefunctionbuttons|chaptermovedown|tooltip_text">Move Heading Down</property>
                    <property name="hexpand">True</property>
                    <property name="vexpand">True</property>
                    <property name="icon-name">sw/res/sc20171.png</property>
                  </object>
                  <packing>
                    <property name="expand">True</property>
                    <property name="homogeneous">True</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkBox" id="tables">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
            <child>
              <object class="GtkToolbar" id="TablesContentFunctionButtonsToolbar">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
                <property name="toolbar-style">icons</property>
                <property name="show-arrow">False</property>
                <child>
                  <object class="GtkToolButton" id="tabledialog">
                    <property name="visible">True</property>
                    <property name="can-focus">False</property>
                    <property name="action-name">.uno:TableDialog</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="homogeneous">True</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkToolButton" id="autoformat">
                    <property name="visible">True</property>
                    <property name="can-focus">False</property>
                    <property name="action-name">.uno:AutoFormat</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="homogeneous">True</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkBox" id="frames">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
            <child>
              <object class="GtkToolbar" id="FramesContentFunctionButtonsToolbar">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
                <property name="toolbar-style">icons</property>
                <property name="show-arrow">False</property>
                <child>
                  <object class="GtkToolButton" id="framedialog">
                    <property name="visible">True</property>
                    <property name="can-focus">False</property>
                    <property name="action-name">.uno:FrameDialog</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="homogeneous">True</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">2</property>
          </packing>
        </child>
        <child>
          <object class="GtkBox" id="images">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
            <child>
              <object class="GtkToolbar" id="ImagesContentFunctionButtonsToolbar">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
                <property name="toolbar-style">icons</property>
                <property name="show-arrow">False</property>
                <child>
                  <object class="GtkToolButton" id="graphicdialog">
                    <property name="visible">True</property>
                    <property name="can-focus">False</property>
                    <property name="action-name">.uno:GraphicDialog</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="homogeneous">True</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">3</property>
          </packing>
        </child>
        <child>
          <object class="GtkBox" id="bookmarks">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
            <child>
              <object class="GtkToolbar" id="BookmarksContentTypeFunctionButtonsToolbar">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
                <property name="toolbar-style">icons</property>
                <property name="show-arrow">False</property>
                <child>
                  <object class="GtkToolButton" id="insertbookmark">
                    <property name="visible">True</property>
                    <property name="can-focus">False</property>
                    <property name="action-name">.uno:InsertBookmark</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="homogeneous">True</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">4</property>
          </packing>
        </child>
        <child>
          <object class="GtkBox" id="hyperlinks">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
            <property name="orientation">vertical</property>
            <child>
              <object class="GtkToolbar" id="HyperlinksContentTypeFunctionButtonsToolbar">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
                <property name="toolbar-style">icons</property>
                <property name="show-arrow">False</property>
                <child>
                  <object class="GtkToolButton" id="hyperlinkdialog">
                    <property name="visible">True</property>
                    <property name="can-focus">False</property>
                    <property name="action-name">.uno:HyperlinkDialog</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="homogeneous">True</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkToolbar" id="HyperlinksContentFunctionButtonsToolbar">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
                <property name="toolbar-style">icons</property>
                <property name="show-arrow">False</property>
                <child>
                  <object class="GtkToolButton" id="edithyperlink">
                    <property name="visible">True</property>
                    <property name="can-focus">False</property>
                    <property name="action-name">.uno:EditHyperlink</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="homogeneous">True</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkToolButton" id="removehyperlink">
                    <property name="visible">True</property>
                    <property name="can-focus">False</property>
                    <property name="action-name">.uno:RemoveHyperlink</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="homogeneous">True</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">1</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">5</property>
          </packing>
        </child>
        <child>
          <object class="GtkBox" id="fields">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
            <property name="orientation">vertical</property>
            <child>
              <object class="GtkToolbar" id="FieldsContentTypeFunctionButtonsToolbar">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
                <property name="toolbar-style">icons</property>
                <property name="show-arrow">False</property>
                <child>
                  <object class="GtkToolButton" id="updatefields">
                    <property name="visible">True</property>
                    <property name="can-focus">False</property>
                    <property name="action-name">.uno:UpdateFields</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="homogeneous">True</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkToolbar" id="FieldsContentFunctionButtonsToolbar">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
                <property name="toolbar-style">icons</property>
                <property name="show-arrow">False</property>
                <child>
                  <object class="GtkToolButton" id="editfielddialog">
                    <property name="visible">True</property>
                    <property name="can-focus">False</property>
                    <property name="action-name">.uno:FieldDialog</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="homogeneous">True</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">1</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">6</property>
          </packing>
        </child>
        <child>
          <object class="GtkBox" id="drawingobjects">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
            <child>
              <object class="GtkToolbar" id="DrawingobjectsContentFunctionButtonsToolbar">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
                <property name="toolbar-style">icons</property>
                <property name="show-arrow">False</property>
                <child>
                  <object class="GtkToolButton" id="drawingobjectinsertcaptiondialog">
                    <property name="visible">True</property>
                    <property name="can-focus">False</property>
                    <property name="action-name">.uno:InsertCaptionDialog</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="homogeneous">True</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">7</property>
          </packing>
        </child>
        <child>
          <object class="GtkToolbar" id="DeleteFunctionButtonToolbar">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
            <property name="valign">center</property>
            <property name="hexpand">True</property>
            <property name="vexpand">True</property>
            <property name="toolbar-style">icons</property>
            <property name="show-arrow">False</property>
            <child>
              <object class="GtkToolButton" id="delete">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
                <property name="tooltip-text" translatable="yes" context="contenttreefunctionbuttons|delete|tooltip_text">Delete</property>
                <property name="hexpand">True</property>
                <property name="vexpand">True</property>
                <property name="icon-name">cmd/sc_delete.png</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="homogeneous">True</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">True</property>
            <property name="fill">True</property>
            <property name="position">8</property>
          </packing>
        </child>
      </object>
      <packing>
        <property name="expand">True</property>
        <property name="fill">True</property>
        <property name="position">0</property>
      </packing>
    </child>
  </object>
</interface>
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 54abb89..553c12d 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -228,6 +228,8 @@ protected:
public:
    SalInstanceWidget(vcl::Window* pWidget, SalInstanceBuilder* pBuilder, bool bTakeOwnership);

    vcl::Window* GetVclWindow() override { return m_xWidget; }

    virtual void set_sensitive(bool sensitive) override;

    virtual bool get_sensitive() const override;
diff --git a/vcl/source/control/InterimItemWindow.cxx b/vcl/source/control/InterimItemWindow.cxx
index 0769245..bc3b5d2 100644
--- a/vcl/source/control/InterimItemWindow.cxx
+++ b/vcl/source/control/InterimItemWindow.cxx
@@ -138,9 +138,11 @@ void InterimItemWindow::GetFocus()
       to this toolitem in case tab means to move to another toolitem within
       the toolbox
    */
    vcl::Window* pToolBox = GetParent();
    NotifyEvent aNEvt(NotifyEventType::GETFOCUS, this);
    pToolBox->EventNotify(aNEvt);
    if (vcl::Window* pToolBox = GetParent())
    {
        NotifyEvent aNEvt(NotifyEventType::GETFOCUS, this);
        pToolBox->EventNotify(aNEvt);
    }
}

bool InterimItemWindow::ChildKeyInput(const KeyEvent& rKEvt)