weld SvxHlinkDlgMarkWnd

Change-Id: I8aacfc54592074c976530fa9d1dbf860c1fb0ad4
Reviewed-on: https://gerrit.libreoffice.org/74152
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/cui/source/dialogs/cuihyperdlg.cxx b/cui/source/dialogs/cuihyperdlg.cxx
index 26a6e4f..4e455c0 100644
--- a/cui/source/dialogs/cuihyperdlg.cxx
+++ b/cui/source/dialogs/cuihyperdlg.cxx
@@ -228,30 +228,26 @@ void SvxHpLinkDlg::Move()
        // Size of Extrawindow
        Size aExtraWndSize( pCurrentPage->GetSizeExtraWnd() );

        bool bDoInvalid ;
        if( aDlgPos.X()+(1.02*aDlgSize.Width())+aExtraWndSize.Width() > aWindowSize.Width() )
        {
            if( aDlgPos.X() - ( 0.02*aDlgSize.Width() ) - aExtraWndSize.Width() < 0 )
            {
                // Pos Extrawindow anywhere
                bDoInvalid = pCurrentPage->MoveToExtraWnd( Point( 1, long(1.1*aDlgPos.Y()) ), true );
                pCurrentPage->MoveToExtraWnd( Point( 1, long(1.1*aDlgPos.Y()) ) );
            }
            else
            {
                // Pos Extrawindow on the left side of Dialog
                bDoInvalid = pCurrentPage->MoveToExtraWnd( aDlgPos -
                                                           Point( long(0.02*aDlgSize.Width()), 0 ) -
                                                           Point( aExtraWndSize.Width(), 0 ) );
                pCurrentPage->MoveToExtraWnd( aDlgPos -
                                              Point( long(0.02*aDlgSize.Width()), 0 ) -
                                              Point( aExtraWndSize.Width(), 0 ) );
            }
        }
        else
        {
            // Pos Extrawindow on the right side of Dialog
            bDoInvalid = pCurrentPage->MoveToExtraWnd ( aDlgPos + Point( long(1.02*aDlgSize.Width()), 0 ) );
            pCurrentPage->MoveToExtraWnd ( aDlgPos + Point( long(1.02*aDlgSize.Width()), 0 ) );
        }

        if ( bDoInvalid )
            Invalidate(InvalidateFlags::Transparent);
    }

    Window::Move();
diff --git a/cui/source/dialogs/hldoctp.cxx b/cui/source/dialogs/hldoctp.cxx
index e492703..282e5ee 100644
--- a/cui/source/dialogs/hldoctp.cxx
+++ b/cui/source/dialogs/hldoctp.cxx
@@ -229,26 +229,26 @@ IMPL_LINK_NOARG(SvxHyperlinkDocTp, ClickFileopenHdl_Impl, Button*, void)

IMPL_LINK_NOARG(SvxHyperlinkDocTp, ClickTargetHdl_Impl, Button*, void)
{
    ShowMarkWnd();

    if ( GetPathType ( maStrURL ) == EPathType::ExistsFile  ||
         maStrURL.isEmpty() ||
         maStrURL.equalsIgnoreAsciiCase( sFileScheme ) ||
         maStrURL.startsWith( sHash ) )
    {
        mpMarkWnd->SetError( LERR_NOERROR );
        mxMarkWnd->SetError( LERR_NOERROR );

        EnterWait();

        if ( maStrURL.equalsIgnoreAsciiCase( sFileScheme ) )
            mpMarkWnd->RefreshTree ( "" );
            mxMarkWnd->RefreshTree ( "" );
        else
            mpMarkWnd->RefreshTree ( maStrURL );
            mxMarkWnd->RefreshTree ( maStrURL );

        LeaveWait();
    }
    else
        mpMarkWnd->SetError( LERR_DOCNOTOPEN );

    ShowMarkWnd ();
        mxMarkWnd->SetError( LERR_DOCNOTOPEN );
}

/*************************************************************************
@@ -282,9 +282,9 @@ IMPL_LINK_NOARG(SvxHyperlinkDocTp, TimeoutHdl_Impl, Timer *, void)
        EnterWait();

        if ( maStrURL.equalsIgnoreAsciiCase( sFileScheme ) )
            mpMarkWnd->RefreshTree ( "" );
            mxMarkWnd->RefreshTree ( "" );
        else
            mpMarkWnd->RefreshTree ( maStrURL );
            mxMarkWnd->RefreshTree ( maStrURL );

        LeaveWait();
    }
@@ -301,7 +301,7 @@ IMPL_LINK_NOARG(SvxHyperlinkDocTp, ModifiedTargetHdl_Impl, Edit&, void)
    maStrURL = GetCurrentURL();

    if ( IsMarkWndVisible() )
        mpMarkWnd->SelectEntry ( m_pEdTarget->GetText() );
        mxMarkWnd->SelectEntry ( m_pEdTarget->GetText() );

    m_pFtFullURL->SetText( maStrURL );
}
diff --git a/cui/source/dialogs/hlinettp.cxx b/cui/source/dialogs/hlinettp.cxx
index 9dd2672..29360b1 100644
--- a/cui/source/dialogs/hlinettp.cxx
+++ b/cui/source/dialogs/hlinettp.cxx
@@ -381,9 +381,9 @@ void SvxHyperlinkInternetTp::RefreshMarkWindow()
        EnterWait();
        OUString aStrURL( CreateAbsoluteURL() );
        if ( !aStrURL.isEmpty() )
            mpMarkWnd->RefreshTree ( aStrURL );
            mxMarkWnd->RefreshTree ( aStrURL );
        else
            mpMarkWnd->SetError( LERR_DOCNOTOPEN );
            mxMarkWnd->SetError( LERR_DOCNOTOPEN );
        LeaveWait();
    }

diff --git a/cui/source/dialogs/hlmarkwn.cxx b/cui/source/dialogs/hlmarkwn.cxx
index cada8bd..1f09736 100644
--- a/cui/source/dialogs/hlmarkwn.cxx
+++ b/cui/source/dialogs/hlmarkwn.cxx
@@ -20,6 +20,7 @@
#include <dialmgr.hxx>
#include <sfx2/docfile.hxx>
#include <unotools/viewoptions.hxx>
#include <vcl/graph.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <vcl/wrkwin.hxx>
@@ -38,7 +39,6 @@
#include <com/sun/star/io/IOException.hpp>

#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/treelistentry.hxx>

#include <strings.hrc>
#include <hlmarkwn.hxx>
@@ -60,98 +60,50 @@ struct TargetData
    }
};

// Tree-Window
SvxHlmarkTreeLBox::SvxHlmarkTreeLBox(vcl::Window* pParent, WinBits nStyle)
    : SvTreeListBox(pParent, nStyle)
    , mpParentWnd(nullptr)
{
    SetNodeDefaultImages();
}

SvxHlmarkTreeLBox::~SvxHlmarkTreeLBox()
{
    disposeOnce();
}

void SvxHlmarkTreeLBox::dispose()
{
    mpParentWnd.clear();
    SvTreeListBox::dispose();
}

VCL_BUILDER_FACTORY_CONSTRUCTOR(SvxHlmarkTreeLBox, WB_TABSTOP)

Size SvxHlmarkTreeLBox::GetOptimalSize() const
{
    return LogicToPixel(Size(103, 162), MapMode(MapUnit::MapAppFont));
}

void SvxHlmarkTreeLBox::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect)
{
    if (!mpParentWnd || mpParentWnd->mnError == LERR_NOERROR)
    {
        SvTreeListBox::Paint(rRenderContext, rRect);
    }
    else
    {
        Erase(rRenderContext);

        ::tools::Rectangle aDrawRect(Point( 0, 0 ), GetSizePixel());

        OUString aStrMessage;

        switch (mpParentWnd->mnError)
        {
        case LERR_NOENTRIES :
            aStrMessage = CuiResId( RID_SVXSTR_HYPDLG_ERR_LERR_NOENTRIES );
            break;
        case LERR_DOCNOTOPEN :
            aStrMessage = CuiResId( RID_SVXSTR_HYPDLG_ERR_LERR_DOCNOTOPEN );
            break;
        }

        rRenderContext.DrawText(aDrawRect, aStrMessage, DrawTextFlags::Left
                | DrawTextFlags::MultiLine | DrawTextFlags::WordBreak);
    }
}


//*** Window-Class ***
// Constructor / Destructor
SvxHlinkDlgMarkWnd::SvxHlinkDlgMarkWnd( SvxHyperlinkTabPageBase *pParent )
    : FloatingWindow(pParent, "HyperlinkMark", "cui/ui/hyperlinkmarkdialog.ui")
    , mbUserMoved(false)
    , mpParent(pParent)
SvxHlinkDlgMarkWnd::SvxHlinkDlgMarkWnd(weld::Window* pParentDialog, SvxHyperlinkTabPageBase *pParentPage)
    : GenericDialogController(pParentDialog, "cui/ui/hyperlinkmarkdialog.ui", "HyperlinkMark")
    , mpParent(pParentPage)
    , mnError(LERR_NOERROR)
    , mxBtApply(m_xBuilder->weld_button("ok"))
    , mxBtClose(m_xBuilder->weld_button("close"))
    , mxLbTree(m_xBuilder->weld_tree_view("TreeListBox"))
    , mxError(m_xBuilder->weld_label("error"))
{
    get(mpBtApply, "apply");
    get(mpBtClose, "close");
    get(mpLbTree, "TreeListBox");
    mpLbTree->SetParentWnd(this);

    mpBtApply->SetClickHdl          ( LINK ( this, SvxHlinkDlgMarkWnd, ClickApplyHdl_Impl ) );
    mpBtClose->SetClickHdl       ( LINK ( this, SvxHlinkDlgMarkWnd, ClickCloseHdl_Impl ) );
    mpLbTree->SetDoubleClickHdl  ( LINK ( this, SvxHlinkDlgMarkWnd, DoubleClickApplyHdl_Impl ) );

    // add lines to the Tree-ListBox
    mpLbTree->SetStyle( mpLbTree->GetStyle() | WB_TABSTOP | WB_BORDER | WB_HASLINES |
                            WB_HASBUTTONS |  //WB_HASLINESATROOT |
                            WB_HSCROLL | WB_HASBUTTONSATROOT );
    mxLbTree->set_size_request(mxLbTree->get_approximate_digit_width() * 25,
                               mxLbTree->get_height_rows(12));
    mxBtApply->connect_clicked( LINK ( this, SvxHlinkDlgMarkWnd, ClickApplyHdl_Impl ) );
    mxBtClose->connect_clicked( LINK ( this, SvxHlinkDlgMarkWnd, ClickCloseHdl_Impl ) );
    mxLbTree->connect_row_activated( LINK ( this, SvxHlinkDlgMarkWnd, DoubleClickApplyHdl_Impl ) );
}

SvxHlinkDlgMarkWnd::~SvxHlinkDlgMarkWnd()
{
    disposeOnce();
    ClearTree();
}

void SvxHlinkDlgMarkWnd::dispose()
void SvxHlinkDlgMarkWnd::ErrorChanged()
{
    ClearTree();
    mpBtApply.clear();
    mpBtClose.clear();
    mpLbTree.clear();
    mpParent.clear();
    FloatingWindow::dispose();
    if (mnError == LERR_NOENTRIES)
    {
        OUString aStrMessage = CuiResId( RID_SVXSTR_HYPDLG_ERR_LERR_NOENTRIES );
        mxError->set_label(aStrMessage);
        mxError->show();
        mxLbTree->hide();
    }
    else if (mnError == LERR_DOCNOTOPEN)
    {
        OUString aStrMessage = CuiResId( RID_SVXSTR_HYPDLG_ERR_LERR_DOCNOTOPEN );
        mxError->set_label(aStrMessage);
        mxError->show();
        mxLbTree->hide();
    }
    else
    {
        mxLbTree->show();
        mxError->hide();
    }
}

// Set an errorstatus
@@ -163,44 +115,20 @@ sal_uInt16 SvxHlinkDlgMarkWnd::SetError( sal_uInt16 nError)
    if( mnError != LERR_NOERROR )
        ClearTree();

    mpLbTree->Invalidate();
    ErrorChanged();

    return nOldError;
}

// Move window
bool SvxHlinkDlgMarkWnd::MoveTo ( Point aNewPos )
void SvxHlinkDlgMarkWnd::MoveTo(const Point& rNewPos)
{
    if ( !mbUserMoved )
    {
        bool bOldStatus = mbUserMoved;
        SetPosPixel ( aNewPos );
        mbUserMoved = bOldStatus;
    }

    return mbUserMoved;
}

void SvxHlinkDlgMarkWnd::Move ()
{
    Window::Move();

    if ( IsReallyVisible() )
        mbUserMoved = true;
}

bool SvxHlinkDlgMarkWnd::ConnectToDialog()
{
    bool bOldStatus = mbUserMoved;

    mbUserMoved = true;

    return bOldStatus;
    m_xDialog->window_move(rNewPos.X(), rNewPos.Y());
}

namespace
{
    void SelectPath(SvTreeListEntry *pEntry, SvxHlmarkTreeLBox &rLbTree,
    void SelectPath(weld::TreeIter* pEntry, weld::TreeView& rLbTree,
        std::deque<OUString> &rLastSelectedPath)
    {
        OUString sTitle(rLastSelectedPath.front());
@@ -209,18 +137,21 @@ namespace
            return;
        while (pEntry)
        {
            if (sTitle == rLbTree.GetEntryText(pEntry))
            if (sTitle == rLbTree.get_text(*pEntry))
            {
                rLbTree.Select(pEntry);
                rLbTree.MakeVisible(pEntry);
                rLbTree.select(*pEntry);
                rLbTree.scroll_to_row(*pEntry);
                if (!rLastSelectedPath.empty())
                {
                    rLbTree.Expand(pEntry);
                    SelectPath(rLbTree.FirstChild(pEntry), rLbTree, rLastSelectedPath);
                    rLbTree.expand_row(*pEntry);
                    if (!rLbTree.iter_children(*pEntry))
                        pEntry = nullptr;
                    SelectPath(pEntry, rLbTree, rLastSelectedPath);
                }
                break;
            }
            pEntry = pEntry->NextSibling();
            if (!rLbTree.iter_next_sibling(*pEntry))
                pEntry = nullptr;
        }
    }
}
@@ -255,7 +186,10 @@ void SvxHlinkDlgMarkWnd::RestoreLastSelection()
    if (!bSelectedEntry && !aLastSelectedPath.empty())
    {
        std::deque<OUString> aTmpSelectedPath(aLastSelectedPath);
        SelectPath(mpLbTree->First(), *mpLbTree, aTmpSelectedPath);
        std::unique_ptr<weld::TreeIter> xEntry(mxLbTree->make_iterator());
        if (!mxLbTree->get_iter_first(*xEntry))
            xEntry.reset();
        SelectPath(xEntry.get(), *mxLbTree, aTmpSelectedPath);
    }
}

@@ -264,7 +198,7 @@ void SvxHlinkDlgMarkWnd::RefreshTree (const OUString& aStrURL)
{
    OUString aUStrURL;

    EnterWait();
    weld::WaitObject aWait(m_xDialog.get());

    ClearTree();

@@ -274,7 +208,7 @@ void SvxHlinkDlgMarkWnd::RefreshTree (const OUString& aStrURL)
        aUStrURL = aStrURL;

    if (!RefreshFromDoc(aUStrURL))
        mpLbTree->Invalidate();
        ErrorChanged();

    bool bSelectedEntry = false;

@@ -286,8 +220,6 @@ void SvxHlinkDlgMarkWnd::RefreshTree (const OUString& aStrURL)

    if (!bSelectedEntry)
        RestoreLastSelection();

    LeaveWait();
}

// get links from document
@@ -351,7 +283,7 @@ bool SvxHlinkDlgMarkWnd::RefreshFromDoc(const OUString& aURL)
}

// Fill Tree-Control
int SvxHlinkDlgMarkWnd::FillTree( const uno::Reference< container::XNameAccess >& xLinks, SvTreeListEntry* pParentEntry )
int SvxHlinkDlgMarkWnd::FillTree( const uno::Reference< container::XNameAccess >& xLinks, weld::TreeIter* pParentEntry )
{
    int nEntries=0;
    const uno::Sequence< OUString > aNames( xLinks->getElementNames() );
@@ -398,48 +330,32 @@ int SvxHlinkDlgMarkWnd::FillTree( const uno::Reference< container::XNameAccess >

                // create userdata
                TargetData *pData = new TargetData ( aLink, bIsTarget );
                OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pData)));

                SvTreeListEntry* pEntry;
                std::unique_ptr<weld::TreeIter> xEntry(mxLbTree->make_iterator());
                mxLbTree->insert(pParentEntry, -1, &aStrDisplayname, &sId, nullptr, nullptr, nullptr, false, xEntry.get());

                try
                {
                    // get bitmap for the tree-entry
                    uno::Reference< awt::XBitmap >
                        aXBitmap( xTarget->getPropertyValue( aProp_LinkDisplayBitmap ), uno::UNO_QUERY );
                    if( aXBitmap.is() )
                    if (aXBitmap.is())
                    {
                        Image aBmp(BitmapEx(VCLUnoHelper::GetBitmap(aXBitmap).GetBitmap(), /*mask*/COL_LIGHTMAGENTA));
                        Graphic aBmp(Graphic(VCLUnoHelper::GetBitmap(aXBitmap)));
                        // insert Displayname into treelist with bitmaps
                        pEntry = mpLbTree->InsertEntry ( aStrDisplayname,
                                                        aBmp, aBmp,
                                                        pParentEntry,
                                                        false, TREELIST_APPEND,
                                                        static_cast<void*>(pData) );
                        nEntries++;
                    }
                    else
                    {
                        // insert Displayname into treelist without bitmaps
                        pEntry = mpLbTree->InsertEntry ( aStrDisplayname,
                                                        pParentEntry,
                                                        false, TREELIST_APPEND,
                                                        static_cast<void*>(pData) );
                        nEntries++;
                        mxLbTree->set_image(*xEntry, aBmp.GetXGraphic(), -1);
                    }
                }
                catch(const css::uno::Exception&)
                {
                    // insert Displayname into treelist without bitmaps
                    pEntry = mpLbTree->InsertEntry ( aStrDisplayname,
                                                    pParentEntry,
                                                    false, TREELIST_APPEND,
                                                    static_cast<void*>(pData) );
                    nEntries++;
                }

                nEntries++;

                uno::Reference< document::XLinkTargetSupplier > xLTS( xTarget, uno::UNO_QUERY );
                if( xLTS.is() )
                    nEntries += FillTree( xLTS->getLinks(), pEntry );
                    nEntries += FillTree( xLTS->getLinks(), xEntry.get() );
            }
            catch(const css::uno::Exception&)
            {
@@ -453,64 +369,67 @@ int SvxHlinkDlgMarkWnd::FillTree( const uno::Reference< container::XNameAccess >
// Clear Tree
void SvxHlinkDlgMarkWnd::ClearTree()
{
    SvTreeListEntry* pEntry = mpLbTree->First();
    std::unique_ptr<weld::TreeIter> xEntry = mxLbTree->make_iterator();
    bool bEntry = mxLbTree->get_iter_first(*xEntry);

    while ( pEntry )
    while (bEntry)
    {
        TargetData* pUserData = static_cast<TargetData *>(pEntry->GetUserData());
        TargetData* pUserData = reinterpret_cast<TargetData*>(mxLbTree->get_id(*xEntry).toInt64());
        delete pUserData;

        pEntry = mpLbTree->Next( pEntry );
        bEntry = mxLbTree->iter_next(*xEntry);
    }

    mpLbTree->Clear();
    mxLbTree->clear();
}

// Find Entry for String
SvTreeListEntry* SvxHlinkDlgMarkWnd::FindEntry (const OUString& aStrName)
std::unique_ptr<weld::TreeIter> SvxHlinkDlgMarkWnd::FindEntry (const OUString& aStrName)
{
    bool bFound=false;
    SvTreeListEntry* pEntry = mpLbTree->First();
    std::unique_ptr<weld::TreeIter> xEntry = mxLbTree->make_iterator();
    bool bEntry = mxLbTree->get_iter_first(*xEntry);

    while ( pEntry && !bFound )
    while (bEntry && !bFound)
    {
        TargetData* pUserData = static_cast<TargetData *>(pEntry->GetUserData ());
        TargetData* pUserData = reinterpret_cast<TargetData*>(mxLbTree->get_id(*xEntry).toInt64());
        if (aStrName == pUserData->aUStrLinkname)
            bFound = true;
        else
            pEntry = mpLbTree->Next( pEntry );
            bEntry = mxLbTree->iter_next(*xEntry);
    }

    return pEntry;
    if (!bFound)
        xEntry.reset();

    return xEntry;
}

// Select Entry
bool SvxHlinkDlgMarkWnd::SelectEntry(const OUString& aStrMark)
{
    SvTreeListEntry* pEntry = FindEntry(aStrMark);
    if (!pEntry)
    std::unique_ptr<weld::TreeIter> xEntry = FindEntry(aStrMark);
    if (!xEntry)
        return false;
    mpLbTree->Select(pEntry);
    mpLbTree->MakeVisible (pEntry);
    mxLbTree->select(*xEntry);
    mxLbTree->scroll_to_row(*xEntry);
    return true;
}

// Click on Apply-Button / Double-click on item in tree
IMPL_LINK_NOARG(SvxHlinkDlgMarkWnd, DoubleClickApplyHdl_Impl, SvTreeListBox*, bool)
IMPL_LINK_NOARG(SvxHlinkDlgMarkWnd, DoubleClickApplyHdl_Impl, weld::TreeView&, void)
{
    ClickApplyHdl_Impl(nullptr);
    return false;
    ClickApplyHdl_Impl(*mxBtApply);
}

IMPL_LINK_NOARG(SvxHlinkDlgMarkWnd, ClickApplyHdl_Impl, Button*, void)
IMPL_LINK_NOARG(SvxHlinkDlgMarkWnd, ClickApplyHdl_Impl, weld::Button&, void)
{
    SvTreeListEntry* pEntry = mpLbTree->GetCurEntry();

    if ( pEntry )
    std::unique_ptr<weld::TreeIter> xEntry(mxLbTree->make_iterator());
    bool bEntry = mxLbTree->get_cursor(xEntry.get());
    if (bEntry)
    {
        TargetData *pData = static_cast<TargetData *>(pEntry->GetUserData());

        if ( pData->bIsTarget )
        TargetData* pData = reinterpret_cast<TargetData*>(mxLbTree->get_id(*xEntry).toInt64());
        if (pData->bIsTarget)
        {
            mpParent->SetMarkStr(pData->aUStrLinkname);
        }
@@ -518,26 +437,24 @@ IMPL_LINK_NOARG(SvxHlinkDlgMarkWnd, ClickApplyHdl_Impl, Button*, void)
}

// Click on Close-Button
IMPL_LINK_NOARG(SvxHlinkDlgMarkWnd, ClickCloseHdl_Impl, Button*, void)
IMPL_LINK_NOARG(SvxHlinkDlgMarkWnd, ClickCloseHdl_Impl, weld::Button&, void)
{
    SvTreeListEntry* pEntry = mpLbTree->GetCurEntry();
    if ( pEntry )
    std::unique_ptr<weld::TreeIter> xEntry(mxLbTree->make_iterator());
    bool bEntry = mxLbTree->get_cursor(xEntry.get());
    if (bEntry)
    {
        TargetData* pUserData = static_cast<TargetData *>(pEntry->GetUserData());
        TargetData* pUserData = reinterpret_cast<TargetData*>(mxLbTree->get_id(*xEntry).toInt64());
        OUString sLastSelectedMark = pUserData->aUStrLinkname;

        std::deque<OUString> aLastSelectedPath;
        if (pEntry)
        //If the bottommost entry is expanded but nothing
        //underneath it is selected leave a dummy entry
        if (mxLbTree->get_row_expanded(*xEntry))
            aLastSelectedPath.push_front(OUString());
        while (bEntry)
        {
            //If the bottommost entry is expanded but nothing
            //underneath it is selected leave a dummy entry
            if (mpLbTree->IsExpanded(pEntry))
                aLastSelectedPath.push_front(OUString());
            while (pEntry)
            {
                aLastSelectedPath.push_front(mpLbTree->GetEntryText(pEntry));
                pEntry = mpLbTree->GetParent(pEntry);
            }
            aLastSelectedPath.push_front(mxLbTree->get_text(*xEntry));
            bEntry = mxLbTree->iter_parent(*xEntry);
        }

        uno::Sequence< beans::NamedValue > aSettings
@@ -551,7 +468,7 @@ IMPL_LINK_NOARG(SvxHlinkDlgMarkWnd, ClickCloseHdl_Impl, Button*, void)
        aViewSettings.SetUserData( aSettings );
    }

    Close();
    m_xDialog->response(RET_CANCEL);
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx
index d47e379..a6db4f1 100644
--- a/cui/source/dialogs/hltpbase.cxx
+++ b/cui/source/dialogs/hltpbase.cxx
@@ -109,18 +109,17 @@ SvxHyperlinkTabPageBase::SvxHyperlinkTabPageBase ( vcl::Window *pParent,
                                                   const OString& rID,
                                                   const OUString& rUIXMLDescription,
                                                   const SfxItemSet* pItemSet )
:   IconChoicePage          ( pParent, rID, rUIXMLDescription, pItemSet ),
    mpCbbFrame              ( nullptr ),
    mpLbForm                ( nullptr ),
    mpEdIndication          ( nullptr ),
    mpEdText                ( nullptr ),
    mpBtScript              ( nullptr ),
    mbIsCloseDisabled       ( false ),
    mpDialog                ( pDlg ),
    mbStdControlsInit       ( false )
  : IconChoicePage( pParent, rID, rUIXMLDescription, pItemSet )
  , mpCbbFrame( nullptr )
  , mpLbForm( nullptr )
  , mpEdIndication( nullptr )
  , mpEdText( nullptr )
  , mpBtScript( nullptr )
  , mbIsCloseDisabled( false )
  , mpDialog( pDlg )
  , mbStdControlsInit( false )
{
    // create bookmark-window
    mpMarkWnd = VclPtr<SvxHlinkDlgMarkWnd>::Create( this );
}

SvxHyperlinkTabPageBase::~SvxHyperlinkTabPageBase()
@@ -132,7 +131,7 @@ void SvxHyperlinkTabPageBase::dispose()
{
    maTimer.Stop();

    mpMarkWnd.disposeAndClear();
    HideMarkWnd();

    mpCbbFrame.clear();
    mpLbForm.clear();
@@ -187,20 +186,21 @@ void SvxHyperlinkTabPageBase::InitStdControls ()
}

// Move Extra-Window
bool SvxHyperlinkTabPageBase::MoveToExtraWnd( Point aNewPos, bool bDisConnectDlg )
void SvxHyperlinkTabPageBase::MoveToExtraWnd( Point aNewPos )
{
    bool bReturn =  mpMarkWnd->MoveTo ( aNewPos );

    if( bDisConnectDlg )
        mpMarkWnd->ConnectToDialog();

    return ( !bReturn && IsMarkWndVisible() );
    mxMarkWnd->MoveTo(aNewPos);
}

// Show Extra-Window
void SvxHyperlinkTabPageBase::ShowMarkWnd ()
void SvxHyperlinkTabPageBase::ShowMarkWnd()
{
    static_cast<vcl::Window*>(mpMarkWnd)->Show();
    if (mxMarkWnd)
    {
        mxMarkWnd->getDialog()->present();
        return;
    }

    mxMarkWnd = std::make_unique<SvxHlinkDlgMarkWnd>(GetFrameWeld(), this);

    // Size of dialog-window in screen pixels
    ::tools::Rectangle aDlgRect( mpDialog->GetWindowExtentsRelative( nullptr ) );
@@ -211,16 +211,15 @@ void SvxHyperlinkTabPageBase::ShowMarkWnd ()
    ::tools::Rectangle aScreen( mpDialog->GetDesktopRectPixel() );

    // Size of Extrawindow
    Size aExtraWndSize( mpMarkWnd->GetSizePixel () );
    Size aExtraWndSize(mxMarkWnd->getDialog()->get_preferred_size());

    // mpMarkWnd is a child of mpDialog, so coordinates for positioning must be relative to mpDialog
    // mxMarkWnd is a child of mpDialog, so coordinates for positioning must be relative to mpDialog
    if( aDlgPos.X()+(1.05*aDlgSize.Width())+aExtraWndSize.Width() > aScreen.Right() )
    {
        if( aDlgPos.X() - ( 0.05*aDlgSize.Width() ) - aExtraWndSize.Width() < 0 )
        {
            // Pos Extrawindow anywhere
            MoveToExtraWnd( Point(10,10) );  // very unlikely
            mpMarkWnd->ConnectToDialog();
        }
        else
        {
@@ -235,7 +234,18 @@ void SvxHyperlinkTabPageBase::ShowMarkWnd ()
    }

    // Set size of Extra-Window
    mpMarkWnd->SetSizePixel( Size( aExtraWndSize.Width(), aDlgSize.Height() ) );
    mxMarkWnd->getDialog()->set_size_request(aExtraWndSize.Width(), aDlgSize.Height());

    weld::DialogController::runAsync(mxMarkWnd, [this](sal_Int32 /*nResult*/) { mxMarkWnd.reset(); } );
}

void SvxHyperlinkTabPageBase::HideMarkWnd()
{
    if (mxMarkWnd)
    {
        mxMarkWnd->response(RET_CANCEL);
        mxMarkWnd.reset();
    }
}

// Fill Dialogfields
diff --git a/cui/source/inc/hlmarkwn.hxx b/cui/source/inc/hlmarkwn.hxx
index f1c79e7..c24c093 100644
--- a/cui/source/inc/hlmarkwn.hxx
+++ b/cui/source/inc/hlmarkwn.hxx
@@ -21,88 +21,53 @@
#define INCLUDED_CUI_SOURCE_INC_HLMARKWN_HXX

#include <com/sun/star/container/XNameAccess.hpp>
#include <vcl/button.hxx>
#include <vcl/floatwin.hxx>
#include <vcl/treelistbox.hxx>
#include <vcl/weld.hxx>

#include "hlmarkwn_def.hxx"
class SvxHyperlinkTabPageBase;


//#                                                                      #
//# Tree-Window                                                          #
//#                                                                      #


class SvxHlinkDlgMarkWnd;

class SvxHlmarkTreeLBox : public SvTreeListBox
{
private:
    VclPtr<SvxHlinkDlgMarkWnd> mpParentWnd;

public:
    SvxHlmarkTreeLBox(vcl::Window* pParent, WinBits nStyle);
    virtual ~SvxHlmarkTreeLBox() override;
    virtual void dispose() override;

    void SetParentWnd(SvxHlinkDlgMarkWnd* pParent)
    {
        mpParentWnd = pParent;
    }

    virtual void Paint( vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect ) override;
    virtual Size GetOptimalSize() const override;
};


//#                                                                      #
//# Window-Class                                                         #
//#                                                                      #
class SvxHlinkDlgMarkWnd : public FloatingWindow //FloatingWindow
class SvxHlinkDlgMarkWnd : public weld::GenericDialogController
{
private:
    friend class SvxHlmarkTreeLBox;

    VclPtr<PushButton>       mpBtApply;
    VclPtr<PushButton>       mpBtClose;
    VclPtr<SvxHlmarkTreeLBox>  mpLbTree;

    bool            mbUserMoved;

    VclPtr<SvxHyperlinkTabPageBase> mpParent;

    sal_uInt16          mnError;

    std::unique_ptr<weld::Button> mxBtApply;
    std::unique_ptr<weld::Button> mxBtClose;
    std::unique_ptr<weld::TreeView> mxLbTree;
    std::unique_ptr<weld::Label> mxError;

    void ErrorChanged();

protected:
    bool RefreshFromDoc( const OUString& aURL );
    void RestoreLastSelection();

    SvTreeListEntry* FindEntry(const OUString& aStrName);
    std::unique_ptr<weld::TreeIter> FindEntry(const OUString& aStrName);
    void ClearTree();
    int FillTree( const css::uno::Reference< css::container::XNameAccess >& xLinks, SvTreeListEntry* pParentEntry =nullptr );
    int FillTree( const css::uno::Reference< css::container::XNameAccess >& xLinks, weld::TreeIter* pParentEntry =nullptr );

    virtual void Move () override;

    DECL_LINK( ClickApplyHdl_Impl, Button*, void );
    DECL_LINK( DoubleClickApplyHdl_Impl, SvTreeListBox*, bool );
    DECL_LINK( ClickCloseHdl_Impl, Button*, void );
    DECL_LINK( ClickApplyHdl_Impl, weld::Button&, void );
    DECL_LINK( DoubleClickApplyHdl_Impl, weld::TreeView&, void );
    DECL_LINK( ClickCloseHdl_Impl, weld::Button&, void );

public:
    SvxHlinkDlgMarkWnd (SvxHyperlinkTabPageBase *pParent);
    SvxHlinkDlgMarkWnd(weld::Window* pParentDialog, SvxHyperlinkTabPageBase *pParentPage);
    virtual ~SvxHlinkDlgMarkWnd() override;
    virtual void dispose() override;

    bool MoveTo ( Point aNewPos );
    void MoveTo(const Point& rNewPos);
    void RefreshTree(const OUString& aStrURL);
    bool SelectEntry(const OUString& aStrMark);

    bool ConnectToDialog();

    sal_uInt16 SetError( sal_uInt16 nError);
};


#endif // INCLUDED_CUI_SOURCE_INC_HLMARKWN_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/inc/hltpbase.hxx b/cui/source/inc/hltpbase.hxx
index 5ced4c6..61cdbb8 100644
--- a/cui/source/inc/hltpbase.hxx
+++ b/cui/source/inc/hltpbase.hxx
@@ -77,7 +77,7 @@ protected:

    Timer               maTimer;

    VclPtr<SvxHlinkDlgMarkWnd> mpMarkWnd;
    std::shared_ptr<SvxHlinkDlgMarkWnd> mxMarkWnd;

    void InitStdControls ();
    void FillStandardDlgFields ( const SvxHyperlinkItem* pHyperlinkItem );
@@ -122,9 +122,9 @@ public:
    virtual void ActivatePage( const SfxItemSet& rItemSet ) override;
    virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override;

    bool IsMarkWndVisible ()      { return static_cast<vcl::Window*>(mpMarkWnd)->IsVisible(); }
    Size GetSizeExtraWnd ()       { return mpMarkWnd->GetSizePixel(); }
    bool MoveToExtraWnd ( Point aNewPos, bool bDisConnectDlg = false );
    bool IsMarkWndVisible() const { return static_cast<bool>(mxMarkWnd); }
    Size GetSizeExtraWnd()       { return mxMarkWnd->getDialog()->get_size(); }
    void MoveToExtraWnd ( Point aNewPos );

    using TabPage::ActivatePage;
    using TabPage::DeactivatePage;
@@ -134,8 +134,8 @@ protected:
    virtual bool ShouldOpenMarkWnd();
    virtual void SetMarkWndShouldOpen(bool bOpen);

    void ShowMarkWnd ();
    void HideMarkWnd ()           { static_cast<vcl::Window*>(mpMarkWnd)->Hide(); }
    void ShowMarkWnd();
    void HideMarkWnd();

    SfxDispatcher* GetDispatcher() const;

diff --git a/cui/source/inc/labdlg.hxx b/cui/source/inc/labdlg.hxx
index 98f9a63f..07d802a7 100644
--- a/cui/source/inc/labdlg.hxx
+++ b/cui/source/inc/labdlg.hxx
@@ -24,6 +24,7 @@
#include <svx/sxctitm.hxx>
#include <svx/sxcecitm.hxx>
#include <svx/anchorid.hxx>
#include <vcl/image.hxx>

class SdrView;

diff --git a/cui/uiconfig/ui/hyperlinkmarkdialog.ui b/cui/uiconfig/ui/hyperlinkmarkdialog.ui
index f6917ae..439cd92 100644
--- a/cui/uiconfig/ui/hyperlinkmarkdialog.ui
+++ b/cui/uiconfig/ui/hyperlinkmarkdialog.ui
@@ -1,13 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.1 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="cui">
  <requires lib="gtk+" version="3.18"/>
  <requires lib="LibreOffice" version="1.0"/>
  <object class="GtkTreeStore" id="liststore1">
    <columns>
      <!-- column-name expander -->
      <column type="GdkPixbuf"/>
      <!-- column-name text -->
      <column type="gchararray"/>
      <!-- column-name id -->
      <column type="gchararray"/>
    </columns>
  </object>
  <object class="GtkDialog" id="HyperlinkMark">
    <property name="can_focus">False</property>
    <property name="border_width">6</property>
    <property name="title" translatable="yes" context="hyperlinkmarkdialog|HyperlinkMark">Target in Document</property>
    <property name="default_width">0</property>
    <property name="default_height">0</property>
    <property name="type_hint">dialog</property>
    <child>
      <placeholder/>
    </child>
    <child internal-child="vbox">
      <object class="GtkBox" id="dialog-vbox1">
        <property name="can_focus">False</property>
@@ -18,7 +32,7 @@
            <property name="can_focus">False</property>
            <property name="layout_style">end</property>
            <child>
              <object class="GtkButton" id="apply">
              <object class="GtkButton" id="ok">
                <property name="label" translatable="yes" context="hyperlinkmarkdialog|apply">_Apply</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
@@ -56,19 +70,77 @@
          </packing>
        </child>
        <child>
          <object class="cuilo-SvxHlmarkTreeLBox" id="TreeListBox:border">
          <object class="GtkBox">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <property name="can_focus">False</property>
            <property name="hexpand">True</property>
            <property name="vexpand">True</property>
            <child internal-child="selection">
              <object class="GtkTreeSelection" id="Tree List-selection1"/>
            </child>
            <child internal-child="accessible">
              <object class="AtkObject" id="TreeListBox:border-atkobject">
                <property name="AtkObject::accessible-name" translatable="yes" context="hyperlinkmarkdialog|TreeListBox-atkobject">Mark Tree</property>
            <property name="orientation">vertical</property>
            <child>
              <object class="GtkScrolledWindow">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="hexpand">True</property>
                <property name="vexpand">True</property>
                <property name="shadow_type">in</property>
                <child>
                  <object class="GtkTreeView" id="TreeListBox">
                    <property name="width_request">-1</property>
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="receives_default">True</property>
                    <property name="hexpand">True</property>
                    <property name="vexpand">True</property>
                    <property name="model">liststore1</property>
                    <property name="headers_visible">False</property>
                    <property name="search_column">1</property>
                    <property name="enable_tree_lines">True</property>
                    <child internal-child="selection">
                      <object class="GtkTreeSelection" id="Macro Library List-selection1"/>
                    </child>
                    <child>
                      <object class="GtkTreeViewColumn" id="treeviewcolumn2">
                        <property name="spacing">6</property>
                        <child>
                          <object class="GtkCellRendererPixbuf" id="cellrenderertext4"/>
                          <attributes>
                            <attribute name="pixbuf">0</attribute>
                          </attributes>
                        </child>
                        <child>
                          <object class="GtkCellRendererText" id="cellrenderertext2"/>
                          <attributes>
                            <attribute name="text">1</attribute>
                          </attributes>
                        </child>
                      </object>
                    </child>
                    <child internal-child="accessible">
                      <object class="AtkObject">
                        <property name="AtkObject::accessible-name" translatable="yes" context="hyperlinkmarkdialog|TreeListBox-atkobject">Mark Tree</property>
                      </object>
                    </child>
                  </object>
                </child>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkLabel" id="error">
                <property name="can_focus">False</property>
                <property name="no_show_all">True</property>
                <property name="xalign">0.5</property>
                <property name="yalign">0.5</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">1</property>
              </packing>
            </child>
          </object>
          <packing>
@@ -80,8 +152,8 @@
      </object>
    </child>
    <action-widgets>
      <action-widget response="101">apply</action-widget>
      <action-widget response="-7">close</action-widget>
      <action-widget response="101">ok</action-widget>
      <action-widget response="-6">close</action-widget>
    </action-widgets>
  </object>
</interface>
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index 7d52623..bdfd89c 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -199,9 +199,6 @@
      </properties>
    </glade-widget-class>

    <glade-widget-class title="Hyperlink Tree Box" name="cuilo-SvxHlmarkTreeLBox"
                        generic-name="Hyperlink Tree Box" parent="vcllo-SvTreeListBox"
                        icon-name="widget-gtk-treeview"/>
    <glade-widget-class title="Content List Box" name="sfxlo-ContentListBox"
                        generic-name="Content List Box" parent="vcllo-SvTreeListBox"
                        icon-name="widget-gtk-treeview"/>
diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py
index b514ca3..3be0581 100755
--- a/solenv/bin/native-code.py
+++ b/solenv/bin/native-code.py
@@ -497,7 +497,6 @@ custom_widgets = [
    'SvxFillAttrBox',
    'SvxFillTypeBox',
    'SvxFontPrevWindow',
    'SvxHlmarkTreeLBox',
    'SvxHyperURLBox',
    'SvxLanguageBox',
    'SvxLanguageComboBox',