cui/Library_cui.mk                              |   13 
 cui/UIConfig_cui.mk                             |    5 
 cui/source/dialogs/cuihyperdlg.cxx              |  290 -------------
 cui/source/dialogs/hldocntp.cxx                 |  449 --------------------
 cui/source/dialogs/hldoctp.cxx                  |  336 ---------------
 cui/source/dialogs/hlinettp.cxx                 |  284 ------------
 cui/source/dialogs/hlmailtp.cxx                 |  220 ----------
 cui/source/dialogs/hlmarkwn.cxx                 |   30 -
 cui/source/dialogs/hltpbase.cxx                 |  526 ------------------------
 cui/source/dialogs/hyperlinkdlg.cxx             |  182 ++++++++
 cui/source/dialogs/hyperlinkdoctabpage.cxx      |  273 ++++++++++++
 cui/source/dialogs/hyperlinkinternettabpage.cxx |  196 ++++++++
 cui/source/dialogs/hyperlinkmailtabpage.cxx     |  155 +++++++
 cui/source/dialogs/hyperlinknewdoctabpage.cxx   |  372 ++++++++++++++++
 cui/source/dialogs/hyperlinktabpagebase.cxx     |  297 +++++++++++++
 cui/source/dialogs/iconcdlg.cxx                 |  307 --------------
 cui/source/factory/dlgfact.cxx                  |   28 -
 cui/source/factory/dlgfact.hxx                  |    3 
 cui/source/inc/cuihyperdlg.hxx                  |  139 ------
 cui/source/inc/hldocntp.hxx                     |   60 --
 cui/source/inc/hldoctp.hxx                      |   75 ---
 cui/source/inc/hlinettp.hxx                     |   76 ---
 cui/source/inc/hlmailtp.hxx                     |   63 --
 cui/source/inc/hlmarkwn.hxx                     |   11 
 cui/source/inc/hltpbase.hxx                     |  140 ------
 cui/source/inc/hyperlinkdlg.hxx                 |   42 +
 cui/source/inc/hyperlinkdoctabpage.hxx          |   64 ++
 cui/source/inc/hyperlinkinternettabpage.hxx     |   53 ++
 cui/source/inc/hyperlinkmailtabpage.hxx         |   45 ++
 cui/source/inc/hyperlinknewdoctabpage.hxx       |   52 ++
 cui/source/inc/hyperlinktabpagebase.hxx         |   97 ++++
 cui/source/inc/iconcdlg.hxx                     |   80 ---
 cui/uiconfig/ui/hyperlinkdlg.ui                 |  109 ++++
 include/sfx2/sfxdlg.hxx                         |    3 
 include/svx/hyperdlg.hxx                        |    6 
 include/svx/svxdlg.hxx                          |    1 
 include/vcl/tabs.hrc                            |    4 
 svx/source/dialog/hyperdlg.cxx                  |   75 +--
 38 files changed, 2021 insertions(+), 3140 deletions(-)

New commits:
commit 1c6eb5324d97dbd9df539a06f9b5128052bbd2a9
Author:     siddhisalunkhe1998 <[email protected]>
AuthorDate: Sun Dec 7 18:46:28 2025 +0000
Commit:     Heiko Tietze <[email protected]>
CommitDate: Mon Feb 2 17:35:21 2026 +0100

    tdf#147630 Transform Hyperlink dialog into a standard SfxTabDialog
    
    Adds new hyperlinkdialog ( class HyperlinkDialog : public 
SfxTabDialogController )
    and tab pages - internet, mail, document, new document
    
    Change-Id: I1d8c27d4da340f22f76df9046ab781d94477121f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195201
    Tested-by: Jenkins
    Reviewed-by: Heiko Tietze <[email protected]>

diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index b9e1fe20dd7c..7972a211b085 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -120,20 +120,19 @@ $(eval $(call gb_Library_add_exception_objects,cui,\
     cui/source/dialogs/cuifmsearch \
     cui/source/dialogs/cuigaldlg \
     cui/source/dialogs/cuigrfflt \
-    cui/source/dialogs/cuihyperdlg \
     cui/source/dialogs/cuiimapwnd \
     cui/source/dialogs/cuitbxform \
     cui/source/dialogs/dlgname \
     cui/source/dialogs/DiagramDialog \
     cui/source/dialogs/FontFeaturesDialog \
     cui/source/dialogs/hangulhanjadlg \
-    cui/source/dialogs/hldocntp \
-    cui/source/dialogs/hldoctp \
-    cui/source/dialogs/hlinettp \
-    cui/source/dialogs/hlmailtp \
     cui/source/dialogs/hlmarkwn \
-    cui/source/dialogs/hltpbase \
-    cui/source/dialogs/iconcdlg \
+    cui/source/dialogs/hyperlinktabpagebase\
+    cui/source/dialogs/hyperlinkdlg \
+    cui/source/dialogs/hyperlinkinternettabpage\
+    cui/source/dialogs/hyperlinkmailtabpage\
+    cui/source/dialogs/hyperlinkdoctabpage\
+    cui/source/dialogs/hyperlinknewdoctabpage\
     cui/source/dialogs/insdlg \
     cui/source/dialogs/insrc \
     cui/source/dialogs/linkdlg \
diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk
index 5d1db7a5ad79..0f985aeff71f 100644
--- a/cui/UIConfig_cui.mk
+++ b/cui/UIConfig_cui.mk
@@ -96,10 +96,11 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\
        cui/uiconfig/ui/hatchpage \
        cui/uiconfig/ui/hyperlinkdialog \
        cui/uiconfig/ui/hyperlinkdocpage \
-       cui/uiconfig/ui/hyperlinkinternetpage \
        cui/uiconfig/ui/hyperlinkmarkdialog \
-       cui/uiconfig/ui/hyperlinkmailpage \
        cui/uiconfig/ui/hyperlinknewdocpage \
+       cui/uiconfig/ui/hyperlinkdlg \
+       cui/uiconfig/ui/hyperlinkinternetpage \
+       cui/uiconfig/ui/hyperlinkmailpage \
        cui/uiconfig/ui/hyphenate \
        cui/uiconfig/ui/iconchangedialog \
        cui/uiconfig/ui/iconselectordialog \
diff --git a/cui/source/dialogs/cuihyperdlg.cxx 
b/cui/source/dialogs/cuihyperdlg.cxx
deleted file mode 100644
index 526ca5f698ca..000000000000
--- a/cui/source/dialogs/cuihyperdlg.cxx
+++ /dev/null
@@ -1,290 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <sal/config.h>
-
-#include <osl/diagnose.h>
-#include <comphelper/lok.hxx>
-#include <unotools/viewoptions.hxx>
-#include <cuihyperdlg.hxx>
-#include <hlinettp.hxx>
-#include <hlmailtp.hxx>
-#include <hldoctp.hxx>
-#include <hldocntp.hxx>
-#include <sfx2/app.hxx>
-#include <sfx2/viewfrm.hxx>
-#include <svl/eitem.hxx>
-#include <svx/svxids.hrc>
-#include <vcl/weld/Builder.hxx>
-#include <dialmgr.hxx>
-#include <strings.hrc>
-#include <vector>
-
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::frame::XFrame;
-
-
-//#                                                                      #
-//# Childwindow-Wrapper-Class                                            #
-//#                                                                      #
-
-
-SvxHlinkCtrl::SvxHlinkCtrl( sal_uInt16 _nId, SfxBindings & rBindings, 
SvxHpLinkDlg* pDlg )
-    : SfxControllerItem ( _nId, rBindings )
-    , aRdOnlyForwarder  ( SID_READONLY_MODE, *this )
-{
-    pParent = pDlg;
-}
-
-void SvxHlinkCtrl::dispose()
-{
-    pParent = nullptr;
-    aRdOnlyForwarder.dispose();
-    ::SfxControllerItem::dispose();
-}
-
-void SvxHlinkCtrl::StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState 
eState,
-                                 const SfxPoolItem* pState )
-{
-    if (!(eState == SfxItemState::DEFAULT && pParent))
-        return;
-
-    switch ( nSID )
-    {
-        case SID_HYPERLINK_GETLINK :
-        {
-            pParent->SetPage( static_cast<const SvxHyperlinkItem*>(pState) );
-        }
-        break;
-        case SID_READONLY_MODE :
-        {
-            pParent->SetReadOnlyMode( static_cast<const 
SfxBoolItem*>(pState)->GetValue() );
-        }
-        break;
-    }
-}
-
-// tdf#90496 - remember last used view in hyperlink dialog
-OUString SvxHpLinkDlg::msRememberedPageId(u"internet"_ustr);
-
-//#                                                                      #
-//# Hyperlink - Dialog                                                   #
-//#                                                                      #
-SvxHpLinkDlg::SvxHpLinkDlg(SfxBindings* pBindings, SfxChildWindow* pChild, 
weld::Window* pParent)
-    : SfxModelessDialogController(pBindings, pChild, pParent, 
u"cui/ui/hyperlinkdialog.ui"_ustr, u"HyperlinkDialog"_ustr)
-    , pSet            ( nullptr )
-    , maCtrl          ( SID_HYPERLINK_GETLINK, *pBindings, this )
-    , mbIsHTMLDoc     ( false )
-    , m_xIconCtrl(m_xBuilder->weld_notebook(u"tabcontrol"_ustr))
-    , m_xOKBtn(m_xBuilder->weld_button(u"ok"_ustr))
-    , m_xApplyBtn(m_xBuilder->weld_button(u"apply"_ustr))
-    , m_xCancelBtn(m_xBuilder->weld_button(u"cancel"_ustr))
-    , m_xHelpBtn(m_xBuilder->weld_button(u"help"_ustr))
-    , m_xResetBtn(m_xBuilder->weld_button(u"reset"_ustr))
-{
-    m_xIconCtrl->connect_enter_page( LINK ( this, SvxHpLinkDlg, 
ChosePageHdl_Impl ) );
-    m_xIconCtrl->show();
-
-    // ItemSet
-    if ( pSet )
-    {
-        pExampleSet.reset(new SfxItemSet( *pSet ));
-        pOutSet.reset(new SfxItemSet( *pSet->GetPool(), pSet->GetRanges() ));
-    }
-
-    // Buttons
-    m_xOKBtn->show();
-    m_xCancelBtn->show();
-
-    m_xApplyBtn->set_visible(!comphelper::LibreOfficeKit::isActive());
-    m_xHelpBtn->set_visible(!comphelper::LibreOfficeKit::isActive());
-    m_xResetBtn->set_visible(!comphelper::LibreOfficeKit::isActive());
-
-    mbGrabFocus = true;
-
-    // set OK/Cancel - button
-    m_xCancelBtn->set_label(CuiResId(RID_CUISTR_HYPDLG_CLOSEBUT));
-
-    // create itemset for tabpages
-    mpItemSet = std::make_unique<SfxItemSetFixed<SID_HYPERLINK_GETLINK,
-                               SID_HYPERLINK_SETLINK>>( 
SfxGetpApp()->GetPool());
-
-    SvxHyperlinkItem aItem(SID_HYPERLINK_GETLINK);
-    mpItemSet->Put(aItem);
-
-    SetInputSet (mpItemSet.get());
-
-    AddTabPage(u"internet"_ustr, SvxHyperlinkInternetTp::Create);
-    AddTabPage(u"mail"_ustr, SvxHyperlinkMailTp::Create);
-    AddTabPage(u"document"_ustr, SvxHyperlinkDocTp::Create);
-
-    if (!comphelper::LibreOfficeKit::isActive())
-        AddTabPage(u"newdocument"_ustr, SvxHyperlinkNewDocTp::Create);
-
-    GetBindings().Update(SID_HYPERLINK_GETLINK);
-    GetBindings().Update(SID_READONLY_MODE);
-
-    m_xResetBtn->connect_clicked( LINK( this, SvxHpLinkDlg, ResetHdl ) );
-    m_xOKBtn->connect_clicked( LINK ( this, SvxHpLinkDlg, ClickOkHdl_Impl ) );
-    m_xApplyBtn->connect_clicked ( LINK ( this, SvxHpLinkDlg, 
ClickApplyHdl_Impl ) );
-}
-
-SvxHpLinkDlg::~SvxHpLinkDlg()
-{
-    mbGrabFocus = false; // don't do any grab if tear-down moves focus around 
during destruction
-
-    // delete config item, so the base class (SfxModelessDialogController) can 
not load it on the next start
-    SvtViewOptions aViewOpt( EViewType::TabDialog, 
OUString::number(SID_HYPERLINK_DIALOG) );
-    aViewOpt.Delete();
-
-    mpItemSet.reset();
-
-    maCtrl.dispose();
-
-    maPageList.clear();
-
-    pRanges.reset();
-    pOutSet.reset();
-}
-
-IconChoicePage* SvxHpLinkDlg::GetTabPage( std::u16string_view rPageId )
-{
-    const IconChoicePageData* p = GetPageData(rPageId);
-    return (p == nullptr) ? nullptr : p->xPage.get();
-}
-
-void SvxHpLinkDlg::Activate()
-{
-    if (mbGrabFocus) {
-        static_cast<SvxHyperlinkTabPageBase 
*>(GetTabPage(GetCurPageId()))->SetInitFocus();
-        mbGrabFocus = false;
-    }
-    SfxModelessDialogController::Activate();
-}
-
-void SvxHpLinkDlg::Close()
-{
-    if (IsClosing())
-        return;
-    if (SfxViewFrame* pViewFrame = SfxViewFrame::Current())
-        pViewFrame->ToggleChildWindow(SID_HYPERLINK_DIALOG);
-}
-
-void SvxHpLinkDlg::Apply()
-{
-    auto aItemSet = SfxItemSet::makeFixedSfxItemSet<SID_HYPERLINK_GETLINK, 
SID_HYPERLINK_SETLINK>( SfxGetpApp()->GetPool() );
-
-    SvxHyperlinkTabPageBase* pCurrentPage = 
static_cast<SvxHyperlinkTabPageBase*>(
-                                                GetTabPage( GetCurPageId() ) );
-
-    pCurrentPage->FillItemSet( &aItemSet );
-
-    const SvxHyperlinkItem *aItem = aItemSet.GetItem(SID_HYPERLINK_SETLINK);
-    if ( !aItem->GetURL().isEmpty() )
-        GetDispatcher()->ExecuteList(SID_HYPERLINK_SETLINK,
-                SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { aItem });
-
-    static_cast<SvxHyperlinkTabPageBase*>( GetTabPage( GetCurPageId() ) 
)->DoApply();
-}
-
-/// Click on OK button
-IMPL_LINK_NOARG(SvxHpLinkDlg, ClickOkHdl_Impl, weld::Button&, void)
-{
-    Apply();
-    m_xDialog->response(RET_OK);
-}
-
-/*************************************************************************
-|*
-|* Click on Apply-button
-|*
-|************************************************************************/
-IMPL_LINK_NOARG(SvxHpLinkDlg, ClickApplyHdl_Impl, weld::Button&, void)
-{
-    Apply();
-}
-
-/*************************************************************************
-|*
-|* Set Page
-|*
-|************************************************************************/
-void SvxHpLinkDlg::SetPage ( SvxHyperlinkItem const * pItem )
-{
-    mpItemSet->Put(*pItem);
-
-    const OUString& aStrURL(pItem->GetURL());
-    INetURLObject aURL(aStrURL);
-    INetProtocol eProtocolTyp = aURL.GetProtocol();
-
-    OUString sPageId(msRememberedPageId);
-
-    if (comphelper::LibreOfficeKit::isActive()) {
-        sPageId = "internet";
-    }
-
-    if (eProtocolTyp == INetProtocol::Http || eProtocolTyp == 
INetProtocol::Https || eProtocolTyp == INetProtocol::Ftp) {
-        sPageId = "internet";
-    } else if (eProtocolTyp == INetProtocol::Mailto) {
-        sPageId = "mail";
-    } else if (!comphelper::LibreOfficeKit::isActive() &&
-        (eProtocolTyp == INetProtocol::File || aStrURL.startsWith("#"))) {
-        sPageId = "document";
-    }
-
-    IconChoicePage* pPage = GetTabPage(sPageId);
-
-    // Switching to tab that doesn't exist should not crash
-    if (pPage == nullptr) { return; }
-
-    ShowPage (sPageId);
-    mbIsHTMLDoc = (pItem->GetInsertMode() & HLINK_HTMLMODE) != 0;
-
-    SfxItemSet& aPageSet = const_cast<SfxItemSet&>(pPage->GetItemSet ());
-    aPageSet.Put ( *pItem );
-
-    for (std::unique_ptr<IconChoicePageData>& page: maPageList) {
-        page->xPage->Reset(*pSet);
-    }
-}
-
-/*************************************************************************
-|*
-|* Enable/Disable ReadOnly mode
-|*
-|************************************************************************/
-void SvxHpLinkDlg::SetReadOnlyMode( bool bRdOnly )
-{
-    m_xOKBtn->set_sensitive(!bRdOnly);
-}
-
-/*************************************************************************
-|*
-|* late-initialization of newly created pages
-|*
-|************************************************************************/
-void SvxHpLinkDlg::PageCreated(IconChoicePage& rPage)
-{
-    SvxHyperlinkTabPageBase& rHyperlinkPage = dynamic_cast< 
SvxHyperlinkTabPageBase& >( rPage );
-    Reference< XFrame > xDocumentFrame = GetBindings().GetActiveFrame();
-    OSL_ENSURE( xDocumentFrame.is(), "SvxHpLinkDlg::PageCreated: macro 
assignment functionality won't work with a proper frame!" );
-    rHyperlinkPage.SetDocumentFrame( xDocumentFrame );
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/dialogs/hldocntp.cxx b/cui/source/dialogs/hldocntp.cxx
deleted file mode 100644
index 5a3ffeefe6a2..000000000000
--- a/cui/source/dialogs/hldocntp.cxx
+++ /dev/null
@@ -1,449 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <hldocntp.hxx>
-#include <osl/file.hxx>
-#include <sfx2/filedlghelper.hxx>
-#include <sfx2/viewfrm.hxx>
-#include <sfx2/docfilt.hxx>
-#include <svl/stritem.hxx>
-#include <com/sun/star/awt/XTopWindow.hpp>
-#include <com/sun/star/uno/Reference.h>
-#include <com/sun/star/uno/Exception.hpp>
-#include <utility>
-#include <vcl/svapp.hxx>
-#include <vcl/weld/Builder.hxx>
-#include <vcl/weld/weld.hxx>
-#include <tools/urlobj.hxx>
-#include <unotools/pathoptions.hxx>
-#include <unotools/dynamicmenuoptions.hxx>
-#include <unotools/ucbstreamhelper.hxx>
-#include <unotools/ucbhelper.hxx>
-
-#include <comphelper/processfactory.hxx>
-#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
-#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
-
-#include <cuihyperdlg.hxx>
-#include <dialmgr.hxx>
-#include <strings.hrc>
-
-using namespace ::com::sun::star::ui::dialogs;
-using namespace ::com::sun::star::uno;
-
-using namespace ::com::sun::star;
-
-/*************************************************************************
-|*
-|* Data-struct for documenttypes in listbox
-|*
-|************************************************************************/
-
-namespace {
-
-struct DocumentTypeData
-{
-    OUString aStrURL;
-    OUString aStrExt;
-    DocumentTypeData (OUString aURL, OUString aExt) : 
aStrURL(std::move(aURL)), aStrExt(std::move(aExt))
-    {}
-};
-
-}
-
-bool SvxHyperlinkNewDocTp::ImplGetURLObject( const OUString& rPath, 
std::u16string_view rBase, INetURLObject& aURLObject ) const
-{
-    bool bIsValidURL = !rPath.isEmpty();
-    if ( bIsValidURL )
-    {
-        aURLObject.SetURL( rPath );
-        if ( aURLObject.GetProtocol() == INetProtocol::NotValid )      // test 
if the source is already a valid url
-        {                                                           // if not 
we have to create a url from a physical file name
-            bool wasAbs;
-            INetURLObject base(rBase);
-            base.setFinalSlash();
-            aURLObject = base.smartRel2Abs(
-                rPath, wasAbs, true, INetURLObject::EncodeMechanism::All,
-                RTL_TEXTENCODING_UTF8, true);
-        }
-        bIsValidURL = aURLObject.GetProtocol() != INetProtocol::NotValid;
-        if ( bIsValidURL )
-        {
-            OUString aBase( aURLObject.getName( INetURLObject::LAST_SEGMENT, 
false ) );
-            if ( aBase.isEmpty() || ( aBase[0] == '.' ) )
-                bIsValidURL = false;
-        }
-        if ( bIsValidURL )
-        {
-            sal_Int32 nPos = m_xLbDocTypes->get_selected_index();
-            if (nPos != -1)
-                
aURLObject.SetExtension(weld::fromId<DocumentTypeData*>(m_xLbDocTypes->get_id(nPos))->aStrExt);
-        }
-
-    }
-    return bIsValidURL;
-}
-
-/*************************************************************************
-|*
-|* Constructor / Destructor
-|*
-|************************************************************************/
-
-SvxHyperlinkNewDocTp::SvxHyperlinkNewDocTp(weld::Container* pParent, 
SvxHpLinkDlg* pDlg, const SfxItemSet* pItemSet)
-    : SvxHyperlinkTabPageBase(pParent, pDlg, 
u"cui/ui/hyperlinknewdocpage.ui"_ustr, u"HyperlinkNewDocPage"_ustr, pItemSet)
-    , m_xRbtEditNow(xBuilder->weld_radio_button(u"editnow"_ustr))
-    , m_xRbtEditLater(xBuilder->weld_radio_button(u"editlater"_ustr))
-    , m_xCbbPath(new SvxHyperURLBox(xBuilder->weld_combo_box(u"path"_ustr)))
-    , m_xBtCreate(xBuilder->weld_button(u"create"_ustr))
-    , m_xLbDocTypes(xBuilder->weld_tree_view(u"types"_ustr))
-{
-    m_xCbbPath->SetSmartProtocol(INetProtocol::File);
-    m_xLbDocTypes->set_size_request(-1, m_xLbDocTypes->get_height_rows(5));
-
-    InitStdControls();
-
-    SetExchangeSupport ();
-
-    m_xCbbPath->show();
-    m_xCbbPath->SetBaseURL(SvtPathOptions().GetWorkPath());
-
-    // set defaults
-    m_xRbtEditNow->set_active(true);
-
-    m_xBtCreate->connect_clicked(LINK(this, SvxHyperlinkNewDocTp, 
ClickNewHdl_Impl));
-
-    FillDocumentList ();
-}
-
-SvxHyperlinkNewDocTp::~SvxHyperlinkNewDocTp ()
-{
-    if (m_xLbDocTypes)
-    {
-        for (sal_Int32 n = 0, nEntryCount = m_xLbDocTypes->n_children(); n < 
nEntryCount; ++n)
-            delete weld::fromId<DocumentTypeData*>(m_xLbDocTypes->get_id(n));
-        m_xLbDocTypes = nullptr;
-    }
-}
-
-/*************************************************************************
-|*
-|* Fill the all dialog-controls except controls in groupbox "more..."
-|*
-|************************************************************************/
-
-
-void SvxHyperlinkNewDocTp::FillDlgFields(const OUString& /*rStrURL*/)
-{
-}
-
-void SvxHyperlinkNewDocTp::FillDocumentList()
-{
-    weld::WaitObject aWaitObj(mpDialog->getDialog());
-
-    std::vector<SvtDynMenuEntry> aDynamicMenuEntries( 
SvtDynamicMenuOptions::GetMenu( EDynamicMenuType::NewMenu ) );
-
-    for ( const SvtDynMenuEntry & rDynamicMenuEntry : aDynamicMenuEntries )
-    {
-        OUString aDocumentUrl = rDynamicMenuEntry.sURL;
-        OUString aTitle = rDynamicMenuEntry.sTitle;
-
-        //#i96822# business cards, labels and database should not be inserted 
here
-        if( aDocumentUrl == "private:factory/swriter?slot=21051" ||
-            aDocumentUrl == "private:factory/swriter?slot=21052" ||
-            aDocumentUrl == "private:factory/sdatabase?Interactive" )
-            continue;
-
-        // Insert into listbox
-        if ( !aDocumentUrl.isEmpty() )
-        {
-            if ( aDocumentUrl == "private:factory/simpress?slot=6686" )        
      // SJ: #106216# do not start
-                aDocumentUrl = "private:factory/simpress"; // the AutoPilot 
for impress
-
-            // insert private-url and default-extension as user-data
-            std::shared_ptr<const SfxFilter> pFilter = 
SfxFilter::GetDefaultFilterFromFactory( aDocumentUrl );
-            if ( pFilter )
-            {
-                // insert doc-name and image
-                OUString aTitleName = aTitle.replaceFirst( "~", "" );
-
-                OUString aStrDefExt(pFilter->GetDefaultExtension());
-                DocumentTypeData *pTypeData = new 
DocumentTypeData(aDocumentUrl, aStrDefExt.copy(2));
-                OUString sId(weld::toId(pTypeData));
-                m_xLbDocTypes->append(sId, aTitleName);
-            }
-        }
-    }
-    m_xLbDocTypes->select(0);
-}
-
-/*************************************************************************
-|*
-|* retrieve and prepare data from dialog-fields
-|*
-|************************************************************************/
-
-void SvxHyperlinkNewDocTp::GetCurrentItemData ( OUString& rStrURL, OUString& 
aStrName,
-                                               OUString& aStrIntName, 
OUString& aStrFrame,
-                                               SvxLinkInsertMode& eMode )
-{
-    // get data from dialog-controls
-    rStrURL = m_xCbbPath->get_active_text();
-    INetURLObject aURL;
-    if ( ImplGetURLObject( rStrURL, m_xCbbPath->GetBaseURL(), aURL ) )
-    {
-        rStrURL = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
-    }
-
-    GetDataFromCommonFields( aStrName, aStrIntName, aStrFrame, eMode );
-}
-
-/*************************************************************************
-|*
-|* static method to create Tabpage
-|*
-|************************************************************************/
-
-std::unique_ptr<IconChoicePage> SvxHyperlinkNewDocTp::Create(weld::Container* 
pWindow, SvxHpLinkDlg* pDlg, const SfxItemSet* pItemSet)
-{
-    return std::make_unique<SvxHyperlinkNewDocTp>(pWindow, pDlg, pItemSet);
-}
-
-/*************************************************************************
-|*
-|* Set initial focus
-|*
-|************************************************************************/
-void SvxHyperlinkNewDocTp::SetInitFocus()
-{
-    m_xCbbPath->grab_focus();
-}
-
-namespace
-{
-    struct ExecuteInfo
-    {
-        bool bRbtEditLater;
-        bool bRbtEditNow;
-        INetURLObject aURL;
-        OUString aStrDocName;
-        // current document
-        css::uno::Reference<css::frame::XFrame> xFrame;
-        SfxDispatcher* pDispatcher;
-    };
-}
-
-IMPL_STATIC_LINK(SvxHyperlinkNewDocTp, DispatchDocument, void*, p, void)
-{
-    std::unique_ptr<ExecuteInfo> xExecuteInfo(static_cast<ExecuteInfo*>(p));
-    if (!xExecuteInfo->xFrame.is())
-        return;
-    try
-    {
-        //if it throws dispatcher is invalid
-        
css::uno::Reference<css::awt::XTopWindow>(xExecuteInfo->xFrame->getContainerWindow(),
 css::uno::UNO_QUERY_THROW);
-
-        SfxViewFrame *pViewFrame = nullptr;
-
-        // create items
-        SfxStringItem aName( SID_FILE_NAME, xExecuteInfo->aStrDocName );
-        SfxStringItem aReferer( SID_REFERER, u"private:user"_ustr );
-        SfxStringItem aFrame( SID_TARGETNAME, u"_blank"_ustr);
-
-        OUString aStrFlags('S');
-        if (xExecuteInfo->bRbtEditLater)
-        {
-            aStrFlags += "H";
-        }
-        SfxStringItem aFlags (SID_OPTIONS, aStrFlags);
-
-        // open url
-        const SfxPoolItemHolder aResult(xExecuteInfo->pDispatcher->ExecuteList(
-            SID_OPENDOC, SfxCallMode::SYNCHRON,
-            { &aName, &aFlags, &aFrame, &aReferer }));
-
-        // save new doc
-        const SfxViewFrameItem *pItem = dynamic_cast<const 
SfxViewFrameItem*>(aResult.getItem());  // aResult is NULL if the Hyperlink
-        if ( pItem )                                                           
 // creation is cancelled #106216#
-        {
-            pViewFrame = pItem->GetFrame();
-            if (pViewFrame)
-            {
-                SfxStringItem aNewName( SID_FILE_NAME, 
xExecuteInfo->aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
-                SfxUnoFrameItem aDocFrame( SID_FILLFRAME, 
pViewFrame->GetFrame().GetFrameInterface() );
-                pViewFrame->GetDispatcher()->ExecuteList(
-                    SID_SAVEASDOC, SfxCallMode::SYNCHRON,
-                    { &aNewName }, { &aDocFrame });
-            }
-        }
-
-        if (xExecuteInfo->bRbtEditNow)
-        {
-            css::uno::Reference<css::awt::XTopWindow> 
xWindow(xExecuteInfo->xFrame->getContainerWindow(), css::uno::UNO_QUERY);
-            if (xWindow.is()) //will be false if the frame was exited while 
the document was loading (e.g. we waited for warning dialogs)
-                xWindow->toFront();
-        }
-
-        if (pViewFrame && xExecuteInfo->bRbtEditLater)
-        {
-            SfxObjectShell* pObjShell = pViewFrame->GetObjectShell();
-            pObjShell->DoClose();
-        }
-    }
-    catch (...)
-    {
-    }
-}
-
-/*************************************************************************
-|*
-|* Any action to do after apply-button is pressed
-|*
-\************************************************************************/
-void SvxHyperlinkNewDocTp::DoApply()
-{
-    weld::WaitObject aWait(mpDialog->getDialog());
-
-    // get data from dialog-controls
-    OUString aStrNewName = m_xCbbPath->get_active_text();
-
-    if ( aStrNewName.isEmpty() )
-        aStrNewName = maStrInitURL;
-
-    // create a real URL-String
-    INetURLObject aURL;
-    if ( !ImplGetURLObject( aStrNewName, m_xCbbPath->GetBaseURL(), aURL ) )
-        return;
-
-    // create Document
-    aStrNewName = aURL.GetURLPath( INetURLObject::DecodeMechanism::NONE );
-    bool bCreate = true;
-    try
-    {
-        // check if file exists, warn before we overwrite it
-        std::unique_ptr<SvStream> pIStm = 
::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ), StreamMode::READ );
-
-        bool bOk = pIStm && ( pIStm->GetError() == ERRCODE_NONE);
-
-        pIStm.reset();
-
-        if( bOk )
-        {
-            std::unique_ptr<weld::MessageDialog> 
xWarn(Application::CreateMessageDialog(mpDialog->getDialog(),
-                                                       
VclMessageType::Warning, VclButtonsType::YesNo,
-                                                       
CuiResId(RID_CUISTR_HYPERDLG_QUERYOVERWRITE)));
-            bCreate = xWarn->run() == RET_YES;
-        }
-    }
-    catch (const uno::Exception&)
-    {
-    }
-
-    if (!bCreate || aStrNewName.isEmpty())
-        return;
-
-    ExecuteInfo* pExecuteInfo = new ExecuteInfo;
-
-    pExecuteInfo->bRbtEditLater = m_xRbtEditLater->get_active();
-    pExecuteInfo->bRbtEditNow = m_xRbtEditNow->get_active();
-    // get private-url
-    sal_Int32 nPos = m_xLbDocTypes->get_selected_index();
-    if (nPos == -1)
-        nPos = 0;
-    pExecuteInfo->aURL = std::move(aURL);
-    pExecuteInfo->aStrDocName = 
weld::fromId<DocumentTypeData*>(m_xLbDocTypes->get_id(nPos))->aStrURL;
-
-    // current document
-    pExecuteInfo->xFrame = 
GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface();
-    pExecuteInfo->pDispatcher = GetDispatcher();
-
-    Application::PostUserEvent(LINK(nullptr, SvxHyperlinkNewDocTp, 
DispatchDocument), pExecuteInfo);
-}
-
-/*************************************************************************
-|*
-|* Click on imagebutton : new
-|*
-|************************************************************************/
-IMPL_LINK_NOARG(SvxHyperlinkNewDocTp, ClickNewHdl_Impl, weld::Button&, void)
-{
-    DisableClose( true );
-    const uno::Reference < XComponentContext >& xContext( 
::comphelper::getProcessComponentContext() );
-    uno::Reference < XFolderPicker2 >  xFolderPicker = 
sfx2::createFolderPicker(xContext, mpDialog->getDialog());
-
-    OUString            aStrURL;
-    OUString            aTempStrURL( m_xCbbPath->get_active_text() );
-    osl::FileBase::getFileURLFromSystemPath( aTempStrURL, aStrURL );
-
-    OUString            aStrPath = aStrURL;
-    bool            bZeroPath = aStrPath.isEmpty();
-    bool            bHandleFileName = bZeroPath;    // when path has length of 
0, then the rest should always be handled
-                                                        //  as file name, 
otherwise we do not yet know
-
-    if( bZeroPath )
-        aStrPath = SvtPathOptions().GetWorkPath();
-    else if( !::utl::UCBContentHelper::IsFolder( aStrURL ) )
-        bHandleFileName = true;
-
-    xFolderPicker->setDisplayDirectory( aStrPath );
-    sal_Int16 nResult = xFolderPicker->execute();
-    DisableClose( false );
-    if( ExecutableDialogResults::OK != nResult )
-        return;
-
-    char const  sSlash[] = "/";
-
-    INetURLObject   aURL( aStrURL, INetProtocol::File );
-    OUString        aStrName;
-    if( bHandleFileName )
-        aStrName = bZeroPath? aTempStrURL : aURL.getName();
-
-    m_xCbbPath->SetBaseURL( xFolderPicker->getDirectory() );
-    OUString          aStrTmp( xFolderPicker->getDirectory() );
-
-    if( aStrTmp[ aStrTmp.getLength() - 1 ] != sSlash[0] )
-        aStrTmp += sSlash;
-
-    // append old file name
-    if( bHandleFileName )
-        aStrTmp += aStrName;
-
-    INetURLObject   aNewURL( aStrTmp );
-
-    if (!aStrName.isEmpty() && !aNewURL.getExtension().isEmpty() &&
-       m_xLbDocTypes->get_selected_index() != -1)
-    {
-        // get private-url
-        const sal_Int32 nPos = m_xLbDocTypes->get_selected_index();
-        
aNewURL.setExtension(weld::fromId<DocumentTypeData*>(m_xLbDocTypes->get_id(nPos))->aStrExt);
-    }
-
-    if( aNewURL.GetProtocol() == INetProtocol::File )
-    {
-        osl::FileBase::getSystemPathFromFileURL(aNewURL.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ), aStrTmp);
-    }
-    else
-    {
-        aStrTmp = aNewURL.GetMainURL( 
INetURLObject::DecodeMechanism::Unambiguous );
-    }
-
-    m_xCbbPath->set_entry_text( aStrTmp );
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/dialogs/hldoctp.cxx b/cui/source/dialogs/hldoctp.cxx
deleted file mode 100644
index 1916283f527a..000000000000
--- a/cui/source/dialogs/hldoctp.cxx
+++ /dev/null
@@ -1,336 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <cuihyperdlg.hxx>
-#include <osl/file.hxx>
-#include <sfx2/filedlghelper.hxx>
-#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
-#include <vcl/weld/Builder.hxx>
-
-#include <hldoctp.hxx>
-#include <hlmarkwn_def.hxx>
-
-char const sHash[]          = "#";
-
-/*************************************************************************
-|*
-|* Constructor / Destructor
-|*
-|************************************************************************/
-
-SvxHyperlinkDocTp::SvxHyperlinkDocTp(weld::Container* pParent, SvxHpLinkDlg* 
pDlg, const SfxItemSet* pItemSet)
-    : SvxHyperlinkTabPageBase(pParent, pDlg, 
u"cui/ui/hyperlinkdocpage.ui"_ustr, u"HyperlinkDocPage"_ustr, pItemSet)
-    , m_xCbbPath(new SvxHyperURLBox(xBuilder->weld_combo_box(u"path"_ustr)))
-    , m_xBtFileopen(xBuilder->weld_button(u"fileopen"_ustr))
-    , m_xEdTarget(xBuilder->weld_entry(u"target"_ustr))
-    , m_xFtFullURL(xBuilder->weld_label(u"url"_ustr))
-    , m_xBtBrowse(xBuilder->weld_button(u"browse"_ustr))
-    , m_bMarkWndOpen(false)
-{
-    m_xCbbPath->SetSmartProtocol(INetProtocol::File);
-
-    InitStdControls();
-
-    if (comphelper::LibreOfficeKit::isActive()) {
-        xBuilder->weld_label(u"label3"_ustr)->hide();
-
-        m_xBtFileopen->hide();
-        xBuilder->weld_label(u"path_label"_ustr)->hide();
-        m_xCbbPath->hide();
-
-        xBuilder->weld_label(u"url_label"_ustr)->hide();
-        m_xFtFullURL->hide();
-    } else {
-        m_xCbbPath->show();
-    }
-
-    m_xCbbPath->SetBaseURL(INET_FILE_SCHEME);
-
-    SetExchangeSupport();
-
-    // set handlers
-    m_xBtFileopen->connect_clicked( LINK ( this, SvxHyperlinkDocTp, 
ClickFileopenHdl_Impl ) );
-    m_xBtBrowse->connect_clicked( LINK ( this, SvxHyperlinkDocTp, 
ClickTargetHdl_Impl ) );
-    m_xCbbPath->connect_changed( LINK ( this, SvxHyperlinkDocTp, 
ModifiedPathHdl_Impl ) );
-    m_xEdTarget->connect_changed( LINK ( this, SvxHyperlinkDocTp, 
ModifiedTargetHdl_Impl ) );
-
-    m_xCbbPath->connect_focus_out( LINK ( this, SvxHyperlinkDocTp, 
LostFocusPathHdl_Impl ) );
-
-    maTimer.SetInvokeHandler ( LINK ( this, SvxHyperlinkDocTp, TimeoutHdl_Impl 
) );
-}
-
-SvxHyperlinkDocTp::~SvxHyperlinkDocTp()
-{
-}
-
-/*************************************************************************
-|*
-|* Fill all dialog-controls except controls in groupbox "more..."
-|*
-|************************************************************************/
-void SvxHyperlinkDocTp::FillDlgFields(const OUString& rStrURL)
-{
-    sal_Int32 nPos = rStrURL.indexOf(sHash);
-    // path
-    m_xCbbPath->set_entry_text( rStrURL.copy( 0, ( nPos == -1 ? 
rStrURL.getLength() : nPos ) ) );
-
-    // set target in document at editfield
-    OUString aStrMark;
-    if ( nPos != -1 && nPos < rStrURL.getLength()-1 )
-        aStrMark = rStrURL.copy( nPos+1 );
-    m_xEdTarget->set_text( aStrMark );
-
-    ModifiedPathHdl_Impl(*m_xCbbPath->getWidget());
-}
-
-/*************************************************************************
-|*
-|* retrieve current url-string
-|*
-|************************************************************************/
-OUString SvxHyperlinkDocTp::GetCurrentURL () const
-{
-    // get data from dialog-controls
-    OUString aStrURL;
-    OUString aStrPath( m_xCbbPath->get_active_text() );
-    OUString aStrMark( m_xEdTarget->get_text() );
-
-    if ( !aStrPath.isEmpty() )
-    {
-        INetURLObject aURL( aStrPath );
-        if ( aURL.GetProtocol() != INetProtocol::NotValid )    // maybe the 
path is already a valid
-            aStrURL = aStrPath;                             // hyperlink, then 
we can use this path directly
-        else
-        {
-            osl::FileBase::getFileURLFromSystemPath( aStrPath, aStrURL );
-            aStrURL = INetURLObject::decode(aStrURL, 
INetURLObject::DecodeMechanism::ToIUri, RTL_TEXTENCODING_UTF8);
-        }
-
-        //#105788# always create a URL even if it is not valid
-        if( aStrURL.isEmpty() )
-            aStrURL = aStrPath;
-    }
-
-    if( !aStrMark.isEmpty() )
-    {
-        aStrURL += sHash + aStrMark;
-    }
-
-    return aStrURL;
-}
-
-/*************************************************************************
-|*
-|* retrieve and prepare data from dialog-fields
-|*
-|************************************************************************/
-void SvxHyperlinkDocTp::GetCurrentItemData ( OUString& rStrURL, OUString& 
aStrName,
-                                            OUString& aStrIntName, OUString& 
aStrFrame,
-                                            SvxLinkInsertMode& eMode )
-{
-    // get data from standard-fields
-    rStrURL = GetCurrentURL();
-
-    if( rStrURL.equalsIgnoreAsciiCase( INET_FILE_SCHEME ) )
-         rStrURL.clear();
-
-    GetDataFromCommonFields( aStrName, aStrIntName, aStrFrame, eMode );
-}
-
-/*************************************************************************
-|*
-|* static method to create Tabpage
-|*
-|************************************************************************/
-std::unique_ptr<IconChoicePage> SvxHyperlinkDocTp::Create(weld::Container* 
pWindow, SvxHpLinkDlg* pDlg, const SfxItemSet* pItemSet)
-{
-    return std::make_unique<SvxHyperlinkDocTp>(pWindow, pDlg, pItemSet);
-}
-
-/*************************************************************************
-|*
-|* Set initial focus
-|*
-|************************************************************************/
-void SvxHyperlinkDocTp::SetInitFocus()
-{
-    m_xCbbPath->grab_focus();
-}
-
-/*************************************************************************
-|*
-|* Click on imagebutton : fileopen
-|*
-|************************************************************************/
-IMPL_LINK_NOARG(SvxHyperlinkDocTp, ClickFileopenHdl_Impl, weld::Button&, void)
-{
-    DisableClose( true );
-    // Open Fileopen-Dialog
-    sfx2::FileDialogHelper aDlg(
-        css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 
FileDialogFlags::NONE,
-        mpDialog->getDialog() );
-    OUString aOldURL( GetCurrentURL() );
-    if( aOldURL.startsWithIgnoreAsciiCase( INET_FILE_SCHEME ) )
-    {
-        OUString aPath;
-        osl::FileBase::getSystemPathFromFileURL(aOldURL, aPath);
-        aDlg.SetDisplayFolder( aPath );
-    }
-
-    ErrCode nError = aDlg.Execute();
-    DisableClose( false );
-
-    if ( ERRCODE_NONE != nError )
-        return;
-
-    OUString aURL( aDlg.GetPath() );
-    OUString aPath;
-
-    osl::FileBase::getSystemPathFromFileURL(aURL, aPath);
-
-    m_xCbbPath->SetBaseURL( aURL );
-    m_xCbbPath->set_entry_text(aPath);
-
-    if ( aOldURL != GetCurrentURL() )
-        ModifiedPathHdl_Impl(*m_xCbbPath->getWidget());
-}
-
-/*************************************************************************
-|*
-|* Click on imagebutton : target
-|*
-|************************************************************************/
-IMPL_LINK_NOARG(SvxHyperlinkDocTp, ClickTargetHdl_Impl, weld::Button&, void)
-{
-    ShowMarkWnd();
-
-    if (!mxMarkWnd)
-        return;
-
-    if ( GetPathType ( maStrURL ) == EPathType::ExistsFile  ||
-         maStrURL.isEmpty() ||
-         maStrURL.equalsIgnoreAsciiCase( INET_FILE_SCHEME ) ||
-         maStrURL.startsWith( sHash ) )
-    {
-        mxMarkWnd->SetError( LERR_NOERROR );
-
-        weld::WaitObject aWait(mpDialog->getDialog());
-
-        if ( maStrURL.equalsIgnoreAsciiCase( INET_FILE_SCHEME ) )
-            mxMarkWnd->RefreshTree ( u""_ustr );
-        else
-            mxMarkWnd->RefreshTree ( maStrURL );
-    }
-    else
-        mxMarkWnd->SetError( LERR_DOCNOTOPEN );
-}
-
-/*************************************************************************
-|*
-|* Contents of combobox "Path" modified
-|*
-|************************************************************************/
-IMPL_LINK_NOARG(SvxHyperlinkDocTp, ModifiedPathHdl_Impl, weld::ComboBox&, void)
-{
-    maStrURL = GetCurrentURL();
-
-    maTimer.SetTimeout( 2500 );
-    maTimer.Start();
-
-    m_xFtFullURL->set_label( maStrURL );
-}
-
-/*************************************************************************
-|*
-|* If path-field was modify, to browse the new doc after timeout
-|*
-|************************************************************************/
-IMPL_LINK_NOARG(SvxHyperlinkDocTp, TimeoutHdl_Impl, Timer *, void)
-{
-    if ( IsMarkWndVisible() && ( GetPathType( maStrURL )== 
EPathType::ExistsFile ||
-                                  maStrURL.isEmpty() ||
-                                  maStrURL.equalsIgnoreAsciiCase( 
INET_FILE_SCHEME ) ) )
-    {
-        weld::WaitObject aWait(mpDialog->getDialog());
-
-        if (mxMarkWnd)
-        {
-            if ( maStrURL.equalsIgnoreAsciiCase( INET_FILE_SCHEME ) )
-                mxMarkWnd->RefreshTree ( u""_ustr );
-            else
-                mxMarkWnd->RefreshTree ( maStrURL );
-        }
-    }
-}
-
-/*************************************************************************
-|*
-|* Contents of editfield "Target" modified
-|*
-|************************************************************************/
-IMPL_LINK_NOARG(SvxHyperlinkDocTp, ModifiedTargetHdl_Impl, weld::Entry&, void)
-{
-    maStrURL = GetCurrentURL();
-
-    if (IsMarkWndVisible())
-        mxMarkWnd->SelectEntry(m_xEdTarget->get_text());
-
-    m_xFtFullURL->set_label( maStrURL );
-}
-
-/*************************************************************************
-|*
-|* editfield "Target" lost focus
-|*
-|************************************************************************/
-IMPL_LINK_NOARG(SvxHyperlinkDocTp, LostFocusPathHdl_Impl, weld::Widget&, void)
-{
-    maStrURL = GetCurrentURL();
-
-    m_xFtFullURL->set_label( maStrURL );
-}
-
-/*************************************************************************
-|*
-|* Get String from Bookmark-Wnd
-|*
-|************************************************************************/
-void SvxHyperlinkDocTp::SetMarkStr ( const OUString& aStrMark )
-{
-    m_xEdTarget->set_text(aStrMark);
-
-    ModifiedTargetHdl_Impl ( *m_xEdTarget );
-}
-
-/*************************************************************************
-|*
-|* retrieve kind of pathstr
-|*
-|************************************************************************/
-SvxHyperlinkDocTp::EPathType SvxHyperlinkDocTp::GetPathType ( 
std::u16string_view rStrPath )
-{
-    INetURLObject aURL( rStrPath, INetProtocol::File );
-
-    if( aURL.HasError() )
-        return EPathType::Invalid;
-    else
-        return EPathType::ExistsFile;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/dialogs/hlinettp.cxx b/cui/source/dialogs/hlinettp.cxx
deleted file mode 100644
index c64b8bdfd758..000000000000
--- a/cui/source/dialogs/hlinettp.cxx
+++ /dev/null
@@ -1,284 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <o3tl/string_view.hxx>
-#include <vcl/weld/Builder.hxx>
-
-#include <hlinettp.hxx>
-#include <hlmarkwn_def.hxx>
-#include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp>
-
-
-/*************************************************************************
-|*
-|* Constructor / Destructor
-|*
-|************************************************************************/
-SvxHyperlinkInternetTp::SvxHyperlinkInternetTp(weld::Container* pParent,
-                                               SvxHpLinkDlg* pDlg,
-                                               const SfxItemSet* pItemSet)
-    : SvxHyperlinkTabPageBase(pParent, pDlg, 
u"cui/ui/hyperlinkinternetpage.ui"_ustr, u"HyperlinkInternetPage"_ustr,
-                              pItemSet)
-    , m_bMarkWndOpen(false)
-    , m_xCbbTarget(new 
SvxHyperURLBox(xBuilder->weld_combo_box(u"target"_ustr)))
-    , m_xFtTarget(xBuilder->weld_label(u"target_label"_ustr))
-{
-    // gtk_size_group_set_ignore_hidden, "Measuring the size of hidden widgets
-    // ...  they will report a size of 0 nowadays, and thus, their size will
-    // not affect the other size group members", which is unfortunate. So here
-    // before we hide the labels, take the size group width and set it as
-    // explicit preferred size on a label that won't be hidden
-    auto nLabelWidth = m_xFtTarget->get_preferred_size().Width();
-    m_xFtTarget->set_size_request(nLabelWidth, -1);
-
-    m_xCbbTarget->SetSmartProtocol(INetProtocol::Http);
-
-    InitStdControls();
-
-    m_xCbbTarget->show();
-
-    SetExchangeSupport ();
-
-    // set handlers
-    m_xCbbTarget->connect_focus_out( LINK ( this, SvxHyperlinkInternetTp, 
LostFocusTargetHdl_Impl ) );
-    m_xCbbTarget->connect_changed( LINK ( this, SvxHyperlinkInternetTp, 
ModifiedTargetHdl_Impl ) );
-    maTimer.SetInvokeHandler ( LINK ( this, SvxHyperlinkInternetTp, 
TimeoutHdl_Impl ) );
-}
-
-SvxHyperlinkInternetTp::~SvxHyperlinkInternetTp()
-{
-}
-
-/*************************************************************************
-|*
-|* Fill the all dialog-controls except controls in groupbox "more..."
-|*
-|************************************************************************/
-void SvxHyperlinkInternetTp::FillDlgFields(const OUString& rStrURL)
-{
-    // tdf#146576 - propose clipboard content when inserting a hyperlink
-    OUString aStrURL(rStrURL);
-    if (aStrURL.isEmpty())
-    {
-        if (auto xClipboard = GetSystemClipboard())
-        {
-            if (auto xTransferable = xClipboard->getContents())
-            {
-                css::datatransfer::DataFlavor aFlavor;
-                SotExchange::GetFormatDataFlavor(SotClipboardFormatId::STRING, 
aFlavor);
-                if (xTransferable->isDataFlavorSupported(aFlavor))
-                {
-                    OUString aClipBoardContent;
-                    try
-                    {
-                        if (xTransferable->getTransferData(aFlavor) >>= 
aClipBoardContent)
-                        {
-                            // tdf#162753 - allow only syntactically valid 
hyperlink targets
-                            INetURLObject aURL(o3tl::trim(aClipBoardContent));
-                            if (!aURL.HasError())
-                                aStrURL
-                                    = 
aURL.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous);
-                        }
-                    }
-                    // tdf#158345: Opening Hyperlink dialog leads to crash
-                    // MimeType = "text/plain;charset=utf-16"
-                    catch (const 
css::datatransfer::UnsupportedFlavorException&)
-                    {
-                    }
-                }
-            }
-        }
-    }
-
-    INetURLObject aURL(aStrURL);
-    OUString aStrScheme(GetSchemeFromURL(aStrURL));
-
-    // set URL-field
-    // Show the scheme, #72740
-    if ( aURL.GetProtocol() != INetProtocol::NotValid )
-        m_xCbbTarget->set_entry_text( aURL.GetMainURL( 
INetURLObject::DecodeMechanism::Unambiguous ) );
-    else
-        m_xCbbTarget->set_entry_text(rStrURL);
-
-    SetScheme(aStrScheme);
-}
-
-/*************************************************************************
-|*
-|* retrieve and prepare data from dialog-fields
-|*
-|************************************************************************/
-
-void SvxHyperlinkInternetTp::GetCurrentItemData ( OUString& rStrURL, OUString& 
aStrName,
-                                                 OUString& aStrIntName, 
OUString& aStrFrame,
-                                                 SvxLinkInsertMode& eMode )
-{
-    rStrURL = CreateAbsoluteURL();
-    GetDataFromCommonFields( aStrName, aStrIntName, aStrFrame, eMode );
-}
-
-OUString SvxHyperlinkInternetTp::CreateAbsoluteURL() const
-{
-    // erase leading and trailing whitespaces
-    OUString aStrURL(m_xCbbTarget->get_active_text().trim());
-
-    INetURLObject aURL(aStrURL, GetSmartProtocolFromButtons());
-
-    if ( aURL.GetProtocol() != INetProtocol::NotValid )
-        return aURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri );
-    else //#105788# always create a URL even if it is not valid
-        return aStrURL;
-}
-
-/*************************************************************************
-|*
-|* static method to create Tabpage
-|*
-|************************************************************************/
-
-std::unique_ptr<IconChoicePage> 
SvxHyperlinkInternetTp::Create(weld::Container* pWindow, SvxHpLinkDlg* pDlg, 
const SfxItemSet* pItemSet)
-{
-    return std::make_unique<SvxHyperlinkInternetTp>(pWindow, pDlg, pItemSet);
-}
-
-/*************************************************************************
-|*
-|* Set initial focus
-|*
-|************************************************************************/
-void SvxHyperlinkInternetTp::SetInitFocus()
-{
-    m_xCbbTarget->grab_focus();
-}
-
-/*************************************************************************
-|*
-|* Contents of editfield "Target" modified
-|*
-|************************************************************************/
-IMPL_LINK_NOARG(SvxHyperlinkInternetTp, ModifiedTargetHdl_Impl, 
weld::ComboBox&, void)
-{
-    OUString aScheme = GetSchemeFromURL( m_xCbbTarget->get_active_text() );
-    if( !aScheme.isEmpty() )
-        SetScheme( aScheme );
-
-    // start timer
-    maTimer.SetTimeout( 2500 );
-    maTimer.Start();
-}
-
-/*************************************************************************
-|*
-|* If target-field was modify, to browse the new doc after timeout
-|*
-|************************************************************************/
-IMPL_LINK_NOARG(SvxHyperlinkInternetTp, TimeoutHdl_Impl, Timer *, void)
-{
-    RefreshMarkWindow();
-}
-
-void SvxHyperlinkInternetTp::SetScheme(std::u16string_view rScheme)
-{
-    //update target:
-    RemoveImproperProtocol(rScheme);
-    m_xCbbTarget->SetSmartProtocol( GetSmartProtocolFromButtons() );
-
-    //update 'link target in document'-window and opening-button
-    if (o3tl::starts_with(rScheme, INET_HTTP_SCHEME) || rScheme.empty())
-    {
-        if ( m_bMarkWndOpen )
-            ShowMarkWnd ();
-    }
-    else
-    {
-        //disable for https and ftp
-        if ( m_bMarkWndOpen )
-            HideMarkWnd ();
-    }
-}
-
-/*************************************************************************
-|*
-|* Remove protocol if it does not fit to the current button selection
-|*
-|************************************************************************/
-
-void SvxHyperlinkInternetTp::RemoveImproperProtocol(std::u16string_view 
aProperScheme)
-{
-    OUString aStrURL ( m_xCbbTarget->get_active_text() );
-    if ( !aStrURL.isEmpty() )
-    {
-        OUString aStrScheme(GetSchemeFromURL(aStrURL));
-        if ( !aStrScheme.isEmpty() && aStrScheme != aProperScheme )
-        {
-            aStrURL = aStrURL.copy( aStrScheme.getLength() );
-            m_xCbbTarget->set_entry_text( aStrURL );
-        }
-    }
-}
-
-INetProtocol SvxHyperlinkInternetTp::GetSmartProtocolFromButtons()
-{
-    return INetProtocol::Http;
-}
-
-/*************************************************************************
-|*
-|* Combobox Target lost the focus
-|*
-|************************************************************************/
-IMPL_LINK_NOARG(SvxHyperlinkInternetTp, LostFocusTargetHdl_Impl, 
weld::Widget&, void)
-{
-    RefreshMarkWindow();
-}
-
-void SvxHyperlinkInternetTp::RefreshMarkWindow()
-{
-    if (IsMarkWndVisible())
-    {
-        weld::WaitObject aWait(mpDialog->getDialog());
-        OUString aStrURL( CreateAbsoluteURL() );
-        if ( !aStrURL.isEmpty() )
-            mxMarkWnd->RefreshTree ( aStrURL );
-        else
-            mxMarkWnd->SetError( LERR_DOCNOTOPEN );
-    }
-}
-
-/*************************************************************************
-|*
-|* Get String from Bookmark-Wnd
-|*
-|************************************************************************/
-void SvxHyperlinkInternetTp::SetMarkStr ( const OUString& aStrMark )
-{
-    OUString aStrURL(m_xCbbTarget->get_active_text());
-
-    const sal_Unicode sUHash = '#';
-    sal_Int32 nPos = aStrURL.lastIndexOf( sUHash );
-
-    if( nPos != -1 )
-        aStrURL = aStrURL.copy(0, nPos);
-
-    aStrURL += OUStringChar(sUHash) + aStrMark;
-
-    m_xCbbTarget->set_entry_text(aStrURL);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/dialogs/hlmailtp.cxx b/cui/source/dialogs/hlmailtp.cxx
deleted file mode 100644
index e4af0cb8cae1..000000000000
--- a/cui/source/dialogs/hlmailtp.cxx
+++ /dev/null
@@ -1,220 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <sfx2/request.hxx>
-
-#include <sfx2/viewfrm.hxx>
-#include <unotools/moduleoptions.hxx>
-#include <vcl/weld/Builder.hxx>
-
-#include <hlmailtp.hxx>
-
-#include <comphelper/lok.hxx>
-
-using namespace ::com::sun::star;
-
-/*************************************************************************
-|*
-|* Constructor / Destructor
-|*
-|************************************************************************/
-SvxHyperlinkMailTp::SvxHyperlinkMailTp(weld::Container* pParent, SvxHpLinkDlg* 
pDlg, const SfxItemSet* pItemSet)
-    : SvxHyperlinkTabPageBase(pParent, pDlg, 
u"cui/ui/hyperlinkmailpage.ui"_ustr, u"HyperlinkMailPage"_ustr, pItemSet)
-    , m_xCbbReceiver(new 
SvxHyperURLBox(xBuilder->weld_combo_box(u"receiver"_ustr)))
-    , m_xBtAdrBook(xBuilder->weld_button(u"addressbook"_ustr))
-    , m_xEdSubject(xBuilder->weld_entry(u"subject"_ustr))
-{
-    m_xCbbReceiver->SetSmartProtocol(INetProtocol::Mailto);
-
-    InitStdControls();
-
-    m_xCbbReceiver->show();
-
-    SetExchangeSupport ();
-
-    // set handlers
-    m_xBtAdrBook->connect_clicked( LINK ( this, SvxHyperlinkMailTp, 
ClickAdrBookHdl_Impl ) );
-    m_xCbbReceiver->connect_changed( LINK ( this, SvxHyperlinkMailTp, 
ModifiedReceiverHdl_Impl) );
-
-    if (!SvtModuleOptions().IsDataBaseInstalled() || 
comphelper::LibreOfficeKit::isActive())
-        m_xBtAdrBook->hide();
-}
-
-SvxHyperlinkMailTp::~SvxHyperlinkMailTp()
-{
-}
-
-/*************************************************************************
-|*
-|* Fill the all dialog-controls except controls in groupbox "more..."
-|*
-|************************************************************************/
-
-void SvxHyperlinkMailTp::FillDlgFields(const OUString& rStrURL)
-{
-    OUString aStrScheme = GetSchemeFromURL(rStrURL);
-
-    // set URL-field and additional controls
-    OUString aStrURLc (rStrURL);
-    // set additional controls for EMail:
-    if ( aStrScheme.startsWith( INET_MAILTO_SCHEME ) )
-    {
-        // Find mail-subject
-        OUString aStrSubject, aStrTmp( aStrURLc );
-
-        sal_Int32 nPos = aStrTmp.toAsciiLowerCase().indexOf( "subject" );
-
-        if ( nPos != -1 )
-            nPos = aStrTmp.indexOf( '=', nPos );
-
-        if ( nPos != -1 )
-            aStrSubject = aStrURLc.copy( nPos+1 );
-
-        nPos = aStrURLc.indexOf( '?' );
-
-        if ( nPos != -1 )
-            aStrURLc = aStrURLc.copy( 0, nPos );
-
-        m_xEdSubject->set_text( aStrSubject );
-    }
-    else
-    {
-        m_xEdSubject->set_text(u""_ustr);
-    }
-
-    m_xCbbReceiver->set_entry_text(aStrURLc);
-
-    SetScheme( aStrScheme );
-}
-
-/*************************************************************************
-|*
-|* retrieve and prepare data from dialog-fields
-|*
-|************************************************************************/
-void SvxHyperlinkMailTp::GetCurrentItemData ( OUString& rStrURL, OUString& 
aStrName,
-                                             OUString& aStrIntName, OUString& 
aStrFrame,
-                                             SvxLinkInsertMode& eMode )
-{
-    rStrURL = CreateAbsoluteURL();
-    GetDataFromCommonFields( aStrName, aStrIntName, aStrFrame, eMode );
-}
-
-OUString SvxHyperlinkMailTp::CreateAbsoluteURL() const
-{
-    OUString aStrURL = m_xCbbReceiver->get_active_text();
-    INetURLObject aURL(aStrURL, INetProtocol::Mailto);
-
-    // subject for EMail-url
-    if( aURL.GetProtocol() == INetProtocol::Mailto )
-    {
-        if (!m_xEdSubject->get_text().isEmpty())
-        {
-            OUString aQuery = "subject=" + m_xEdSubject->get_text();
-            aURL.SetParam(aQuery);
-        }
-    }
-
-    if ( aURL.GetProtocol() != INetProtocol::NotValid )
-        return aURL.GetMainURL( INetURLObject::DecodeMechanism::WithCharset );
-    else //#105788# always create a URL even if it is not valid
-        return aStrURL;
-}
-
-/*************************************************************************
-|*
-|* static method to create Tabpage
-|*
-|************************************************************************/
-
-std::unique_ptr<IconChoicePage> SvxHyperlinkMailTp::Create(weld::Container* 
pWindow, SvxHpLinkDlg* pDlg, const SfxItemSet* pItemSet)
-{
-    return std::make_unique<SvxHyperlinkMailTp>(pWindow, pDlg, pItemSet);
-}
-
-/*************************************************************************
-|*
-|* Set initial focus
-|*
-|************************************************************************/
-void SvxHyperlinkMailTp::SetInitFocus()
-{
-    m_xCbbReceiver->grab_focus();
-}
-
-/*************************************************************************
-|************************************************************************/
-void SvxHyperlinkMailTp::SetScheme(std::u16string_view rScheme)
-{
-    //update target:
-    RemoveImproperProtocol(rScheme);
-    m_xCbbReceiver->SetSmartProtocol( INetProtocol::Mailto );
-
-    //show/hide  special fields for MAIL:
-    m_xBtAdrBook->set_sensitive(true);
-    m_xEdSubject->set_sensitive(true);
-}
-
-/*************************************************************************
-|*
-|* Remove protocol if it does not fit to the current button selection
-|*
-|************************************************************************/
-void SvxHyperlinkMailTp::RemoveImproperProtocol(std::u16string_view 
aProperScheme)
-{
-    OUString aStrURL(m_xCbbReceiver->get_active_text());
-    if ( !aStrURL.isEmpty() )
-    {
-        OUString aStrScheme = GetSchemeFromURL( aStrURL );
-        if ( !aStrScheme.isEmpty() && aStrScheme != aProperScheme )
-        {
-            aStrURL = aStrURL.copy( aStrScheme.getLength() );
-            m_xCbbReceiver->set_entry_text(aStrURL);
-        }
-    }
-}
-
-/*************************************************************************
-|*
-|* Contents of editfield "receiver" modified
-|*
-|************************************************************************/
-IMPL_LINK_NOARG(SvxHyperlinkMailTp, ModifiedReceiverHdl_Impl, weld::ComboBox&, 
void)
-{
-    OUString aScheme = GetSchemeFromURL( m_xCbbReceiver->get_active_text() );
-    if(!aScheme.isEmpty())
-        SetScheme( aScheme );
-}
-
-/*************************************************************************
-|*
-|* Click on imagebutton : addressbook
-|*
-|************************************************************************/
-IMPL_STATIC_LINK_NOARG(SvxHyperlinkMailTp, ClickAdrBookHdl_Impl, 
weld::Button&, void)
-{
-    if (SfxViewFrame* pViewFrame = SfxViewFrame::Current())
-    {
-        SfxItemPool &rPool = pViewFrame->GetPool();
-        SfxRequest aReq(SID_VIEW_DATA_SOURCE_BROWSER, SfxCallMode::SLOT, 
rPool);
-        pViewFrame->ExecuteSlot( aReq, true );
-    }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/dialogs/hlmarkwn.cxx b/cui/source/dialogs/hlmarkwn.cxx
index 7712d06bffd8..5c1cdc2c96d3 100644
--- a/cui/source/dialogs/hlmarkwn.cxx
+++ b/cui/source/dialogs/hlmarkwn.cxx
@@ -41,7 +41,7 @@
 
 #include <strings.hrc>
 #include <hlmarkwn.hxx>
-#include <hltpbase.hxx>
+#include <hyperlinktabpagebase.hxx>
 #include <hlmarkwn_def.hxx>
 
 #include <stack>
@@ -66,17 +66,18 @@ struct TargetData
 
 }
 
-//*** Window-Class ***
-// Constructor / Destructor
-SvxHlinkDlgMarkWnd::SvxHlinkDlgMarkWnd(weld::Window* pParentDialog, 
SvxHyperlinkTabPageBase *pParentPage)
+
+// Constructor for new HyperlinkDialog
+SvxHlinkDlgMarkWnd::SvxHlinkDlgMarkWnd(weld::Window* pParentDialog)
     : GenericDialogController(pParentDialog, 
u"cui/ui/hyperlinkmarkdialog.ui"_ustr, u"HyperlinkMark"_ustr)
-    , mpParent(pParentPage)
+    , mpParent(nullptr)
     , mnError(LERR_NOERROR)
-    , mxBtApply(m_xBuilder->weld_button(u"ok"_ustr))
-    , mxBtClose(m_xBuilder->weld_button(u"close"_ustr))
-    , mxLbTree(m_xBuilder->weld_tree_view(u"TreeListBox"_ustr))
-    , mxError(m_xBuilder->weld_label(u"error"_ustr))
 {
+    mxBtApply = m_xBuilder->weld_button(u"ok"_ustr);
+    mxBtClose = m_xBuilder->weld_button(u"close"_ustr);
+    mxLbTree = m_xBuilder->weld_tree_view(u"TreeListBox"_ustr);
+    mxError = m_xBuilder->weld_label(u"error"_ustr);
+
     mxLbTree->set_size_request(mxLbTree->get_approximate_digit_width() * 25,
                                mxLbTree->get_height_rows(12));
     mxBtApply->connect_clicked( LINK ( this, SvxHlinkDlgMarkWnd, 
ClickApplyHdl_Impl ) );
@@ -481,7 +482,16 @@ IMPL_LINK_NOARG(SvxHlinkDlgMarkWnd, ClickApplyHdl_Impl, 
weld::Button&, void)
         TargetData* pData = 
weld::fromId<TargetData*>(mxLbTree->get_id(*xEntry));
         if (pData->bIsTarget)
         {
-            mpParent->SetMarkStr(pData->aUStrLinkname);
+            maSelectedMark = pData->aUStrLinkname;
+
+            if (mpParent)
+            {
+                mpParent->SetMarkStr(pData->aUStrLinkname);
+            }
+            else
+            {
+                m_xDialog->response(RET_OK);
+            }
         }
     }
 }
diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx
deleted file mode 100644
index f6cd7ab3cabe..000000000000
--- a/cui/source/dialogs/hltpbase.cxx
+++ /dev/null
@@ -1,526 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <memory>
-#include <sal/config.h>
-
-#include <comphelper/lok.hxx>
-#include <osl/file.hxx>
-#include <sfx2/app.hxx>
-#include <sfx2/event.hxx>
-#include <sfx2/frame.hxx>
-#include <sfx2/viewfrm.hxx>
-#include <sot/formats.hxx>
-#include <sfx2/sfxsids.hrc>
-#include <svl/macitem.hxx>
-#include <vcl/weld/Builder.hxx>
-#include <cuihyperdlg.hxx>
-#include <hltpbase.hxx>
-#include <macroass.hxx>
-#include <strings.hrc>
-#include <dialmgr.hxx>
-#include <bitmaps.hlst>
-
-namespace {
-
-OUString CreateUiNameFromURL( const OUString& aStrURL )
-{
-    OUString          aStrUiURL;
-    INetURLObject   aURLObj( aStrURL );
-
-    switch(aURLObj.GetProtocol())
-    {
-        case INetProtocol::File:
-            
osl::FileBase::getSystemPathFromFileURL(aURLObj.GetMainURL(INetURLObject::DecodeMechanism::NONE),
 aStrUiURL);
-            break;
-        case INetProtocol::Ftp :
-            {
-                //remove password from name
-                INetURLObject   aTmpURL(aURLObj);
-                aTmpURL.SetPass(u"");
-                aStrUiURL = aTmpURL.GetMainURL( 
INetURLObject::DecodeMechanism::Unambiguous );
-            }
-            break;
-        default :
-            {
-                aStrUiURL = 
aURLObj.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous);
-            }
-    }
-    if(aStrUiURL.isEmpty())
-        return aStrURL;
-    return aStrUiURL;
-}
-
-}
-
-// ComboBox-Control for URL's with History and Autocompletion
-SvxHyperURLBox::SvxHyperURLBox(std::unique_ptr<weld::ComboBox> xControl)
-    : SvtURLBox(std::move(xControl))
-    , DropTargetHelper(getWidget()->get_drop_target())
-{
-    SetSmartProtocol(INetProtocol::Http);
-}
-
-sal_Int8 SvxHyperURLBox::AcceptDrop( const AcceptDropEvent& /* rEvt */ )
-{
-    return IsDropFormatSupported( SotClipboardFormatId::STRING ) ? 
DND_ACTION_COPY : DND_ACTION_NONE;
-}
-
-sal_Int8 SvxHyperURLBox::ExecuteDrop( const ExecuteDropEvent& rEvt )
-{
-    TransferableDataHelper  aDataHelper( rEvt.maDropEvent.Transferable );
-    OUString                aString;
-    sal_Int8                nRet = DND_ACTION_NONE;
-
-    if( aDataHelper.GetString( SotClipboardFormatId::STRING, aString ) )
-    {
-        set_entry_text(aString);
-        nRet = DND_ACTION_COPY;
-    }
-
-    return nRet;
-}
-
-//# Hyperlink-Dialog: Tabpages-Baseclass                                 #
-
-SvxHyperlinkTabPageBase::SvxHyperlinkTabPageBase(weld::Container* pParent,
-                                                 SvxHpLinkDlg* pDlg,
-                                                 const OUString& 
rUIXMLDescription,
-                                                 const OUString& rID,
-                                                 const SfxItemSet* pItemSet)
-  : IconChoicePage(pParent, rUIXMLDescription, rID, pItemSet)
-  , mxCbbFrame(xBuilder->weld_combo_box(u"frame"_ustr))
-  , mxLbForm(xBuilder->weld_combo_box(u"form"_ustr))
-  , mxEdIndication(xBuilder->weld_entry(u"indication"_ustr))
-  , mxEdText(xBuilder->weld_entry(u"name"_ustr))
-  , mxBtScript(xBuilder->weld_button(u"script"_ustr))
-  , mxFormLabel(xBuilder->weld_label(u"form_label"_ustr))
-  , mxFrameLabel(xBuilder->weld_label(u"frame_label"_ustr))
-  , mxNameLabel(xBuilder->weld_label(u"name_label"_ustr))
-  , mxIndicationLabel(xBuilder->weld_label(u"indication_label"_ustr))
-  , mxTabLabel(xBuilder->weld_label(u"label2"_ustr))
-  , mxFurtherSettings(xBuilder->weld_label(u"label1"_ustr))
-  , mbIsCloseDisabled( false )
-  , mpDialog( pDlg )
-  , mbStdControlsInit( false )
-  , maTimer("cui SvxHyperlinkTabPageBase maTimer")
-{
-    // create bookmark-window
-}
-
-SvxHyperlinkTabPageBase::~SvxHyperlinkTabPageBase()
-{
-    maTimer.Stop();
-
-    HideMarkWnd();
-}
-
-bool SvxHyperlinkTabPageBase::QueryClose()
-{
-    return !mbIsCloseDisabled;
-}
-
-void SvxHyperlinkTabPageBase::InitStdControls ()
-{
-    if ( !mbStdControlsInit )
-    {
-        SfxDispatcher* pDispatch = GetDispatcher();
-        SfxViewFrame* pViewFrame = pDispatch ? pDispatch->GetFrame() : nullptr;
-        SfxFrame* pFrame = pViewFrame ? &pViewFrame->GetFrame() : nullptr;
-        if ( pFrame )
-        {
-            TargetList aList;
-            SfxFrame::GetDefaultTargetList(aList);
-            if( !aList.empty() )
-            {
-                size_t nCount = aList.size();
-                size_t i;
-                for ( i = 0; i < nCount; i++ )
-                {
-                    mxCbbFrame->append_text( aList.at( i ) );
-                }
-            }
-        }
-
-        mxBtScript->set_from_icon_name(RID_SVXBMP_SCRIPT);
-
-        mxBtScript->connect_clicked ( LINK ( this, SvxHyperlinkTabPageBase, 
ClickScriptHdl_Impl ) );
-    }
-
-    mbStdControlsInit = true;
-}
-
-// Show Extra-Window
-void SvxHyperlinkTabPageBase::ShowMarkWnd()
-{
-    if (mxMarkWnd)
-    {
-        mxMarkWnd->getDialog()->present();
-        return;
-    }
-
-    weld::Dialog* pDialog = mpDialog->getDialog();
-
-    mxMarkWnd = std::make_shared<SvxHlinkDlgMarkWnd>(pDialog, this);
-
-    // Size of dialog-window in screen pixels
-    Size aDlgSize(pDialog->get_size());
-
-    // Size of Extrawindow
-    Size aExtraWndSize(mxMarkWnd->getDialog()->get_preferred_size());
-
-    mxMarkWnd->RestorePosSize();
-
-    // Set size of Extra-Window
-    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
-void SvxHyperlinkTabPageBase::FillStandardDlgFields ( const SvxHyperlinkItem* 
pHyperlinkItem )
-{
-    m_showName = pHyperlinkItem->GetShowName();
-    m_showText = pHyperlinkItem->GetShowText();
-
-    // Form
-    OUString aStrFormText = CuiResId( RID_CUISTR_HYPERDLG_FROM_TEXT );
-    OUString aStrFormButton = CuiResId( RID_CUISTR_HYPERDLG_FORM_BUTTON );
-
-    if (!comphelper::LibreOfficeKit::isActive())
-    {
-        // Frame
-        sal_Int32 nPos = 
mxCbbFrame->find_text(pHyperlinkItem->GetTargetFrame());
-        if (nPos != -1)
-            mxCbbFrame->set_active(nPos);
-
-        if( pHyperlinkItem->GetInsertMode() & HLINK_HTMLMODE )
-        {
-            mxLbForm->clear();
-            mxLbForm->append_text( aStrFormText );
-            mxLbForm->set_active( 0 );
-        }
-        else
-        {
-            mxLbForm->clear();
-            mxLbForm->append_text( aStrFormText );
-            mxLbForm->append_text( aStrFormButton );
-            mxLbForm->set_active( pHyperlinkItem->GetInsertMode() == 
HLINK_BUTTON ? 1 : 0 );
-        }
-    }
-    else
-    {
-        mxCbbFrame->hide();
-        mxLbForm->hide();
-        mxFormLabel->hide();
-        mxFrameLabel->hide();
-        mxTabLabel->hide();
-        mxFurtherSettings->hide();
-
-        // Although not visible, give fields so that default value can be used
-        mxLbForm->clear();
-        mxLbForm->append_text( aStrFormText );
-        mxLbForm->append_text( aStrFormButton );
-        mxLbForm->set_active( pHyperlinkItem->GetInsertMode() == HLINK_BUTTON 
? 1 : 0 );
-
-        mxNameLabel->set_visible(m_showName);
-        mxEdText->set_visible(m_showName);
-
-        mxEdIndication->set_visible(m_showText);
-        mxIndicationLabel->set_visible(m_showText);
-    }
-
-    // Text
-    mxEdIndication->set_text( pHyperlinkItem->GetName() );
-
-    // Name
-    mxEdText->set_text( pHyperlinkItem->GetIntName() );
-
-    // Script-button
-    if (!comphelper::LibreOfficeKit::isActive())
-    {
-        if ( pHyperlinkItem->GetMacroEvents() == HyperDialogEvent::NONE )
-            mxBtScript->set_sensitive(false);
-        else
-            mxBtScript->set_sensitive(true);
-    }
-    else
-    {
-        mxBtScript->hide();
-    }
-}
-
-// Any action to do after apply-button is pressed
-void SvxHyperlinkTabPageBase::DoApply ()
-{
-    // default-implementation : do nothing
-}
-
-// This method would be called from bookmark-window to set new mark-string
-void SvxHyperlinkTabPageBase::SetMarkStr ( const OUString& /*aStrMark*/ )
-{
-    // default-implementation : do nothing
-}
-
-// Set initial focus
-void SvxHyperlinkTabPageBase::SetInitFocus()
-{
-    xContainer->grab_focus();
-}
-
-// retrieve dispatcher
-SfxDispatcher* SvxHyperlinkTabPageBase::GetDispatcher() const
-{
-    return mpDialog->GetDispatcher();
-}
-
-void SvxHyperlinkTabPageBase::DisableClose(bool _bDisable)
-{
-    mbIsCloseDisabled = _bDisable;
-    if (mbIsCloseDisabled)
-        maBusy.incBusy(mpDialog->getDialog());
-    else
-        maBusy.decBusy();
-}
-
-// Click on imagebutton : Script
-IMPL_LINK_NOARG(SvxHyperlinkTabPageBase, ClickScriptHdl_Impl, weld::Button&, 
void)
-{
-    SvxHyperlinkItem *pHyperlinkItem = const_cast<SvxHyperlinkItem*>(
-                                       GetItemSet().GetItem 
(SID_HYPERLINK_GETLINK));
-
-    if (!pHyperlinkItem || pHyperlinkItem->GetMacroEvents() == 
HyperDialogEvent::NONE)
-        return;
-
-    // get macros from itemset
-    const SvxMacroTableDtor* pMacroTbl = pHyperlinkItem->GetMacroTable();
-    SvxMacroItem aItem ( SID_ATTR_MACROITEM );
-    if( pMacroTbl )
-        aItem.SetMacroTable( *pMacroTbl );
-
-    // create empty itemset for macro-dlg
-    auto xItemSet = std::make_unique<SfxItemSetFixed<SID_ATTR_MACROITEM, 
SID_ATTR_MACROITEM>>( SfxGetpApp()->GetPool() );
-    xItemSet->Put( aItem );
-
-    DisableClose( true );
-
-    SfxMacroAssignDlg aDlg(mpDialog->getDialog(), mxDocumentFrame, 
std::move(xItemSet));
-
-    // add events
-    SfxMacroTabPage *pMacroPage = aDlg.GetTabPage();
-
-    if ( pHyperlinkItem->GetMacroEvents() & HyperDialogEvent::MouseOverObject )
-        pMacroPage->AddEvent( CuiResId(RID_CUISTR_HYPDLG_MACROACT1),
-                              SvMacroItemId::OnMouseOver );
-    if ( pHyperlinkItem->GetMacroEvents() & HyperDialogEvent::MouseClickObject 
)
-        pMacroPage->AddEvent( CuiResId(RID_CUISTR_HYPDLG_MACROACT2),
-                              SvMacroItemId::OnClick);
-    if ( pHyperlinkItem->GetMacroEvents() & HyperDialogEvent::MouseOutObject )
-        pMacroPage->AddEvent( CuiResId(RID_CUISTR_HYPDLG_MACROACT3),
-                              SvMacroItemId::OnMouseOut);
-    // execute dlg
-    short nRet = aDlg.run();
-    DisableClose( false );
-    if ( RET_OK == nRet )
-    {
-        const SfxItemSet* pOutSet = aDlg.GetOutputItemSet();
-        const SfxPoolItem* pItem;
-        if( SfxItemState::SET == pOutSet->GetItemState( SID_ATTR_MACROITEM, 
false, &pItem ))
-        {
-            pHyperlinkItem->SetMacroTable( static_cast<const 
SvxMacroItem*>(pItem)->GetMacroTable() );
-        }
-    }
-}
-
-// Get Macro-Infos
-HyperDialogEvent SvxHyperlinkTabPageBase::GetMacroEvents() const
-{
-    const SvxHyperlinkItem *pHyperlinkItem =
-                                       GetItemSet().GetItem 
(SID_HYPERLINK_GETLINK);
-
-    return pHyperlinkItem ? pHyperlinkItem->GetMacroEvents() : 
HyperDialogEvent();
-}
-
-SvxMacroTableDtor* SvxHyperlinkTabPageBase::GetMacroTable()
-{
-    const SvxHyperlinkItem *pHyperlinkItem =
-                                       GetItemSet().GetItem 
(SID_HYPERLINK_GETLINK);
-
-    return const_cast<SvxMacroTableDtor*>(pHyperlinkItem->GetMacroTable());
-}
-
-// try to detect the current protocol that is used in rStrURL
-OUString SvxHyperlinkTabPageBase::GetSchemeFromURL( const OUString& rStrURL )
-{
-    OUString aStrScheme;
-
-    INetURLObject aURL( rStrURL );
-    INetProtocol aProtocol = aURL.GetProtocol();
-
-    // our new INetUrlObject now has the ability
-    // to detect if a Url is valid or not :-(
-    if ( aProtocol == INetProtocol::NotValid )
-    {
-        if ( rStrURL.startsWithIgnoreAsciiCase( INET_HTTP_SCHEME ) )
-        {
-            aStrScheme = INET_HTTP_SCHEME;
-        }
-        else if ( rStrURL.startsWithIgnoreAsciiCase( INET_HTTPS_SCHEME ) )
-        {
-            aStrScheme = INET_HTTPS_SCHEME;
-        }
-        else if ( rStrURL.startsWithIgnoreAsciiCase( INET_FTP_SCHEME ) )
-        {
-            aStrScheme = INET_FTP_SCHEME;
-        }
-        else if ( rStrURL.startsWithIgnoreAsciiCase( INET_MAILTO_SCHEME ) )
-        {
-            aStrScheme = INET_MAILTO_SCHEME;
-        }
-    }
-    else
-        aStrScheme = INetURLObject::GetScheme( aProtocol );
-    return aStrScheme;
-}
-
-void SvxHyperlinkTabPageBase::GetDataFromCommonFields( OUString& aStrName,
-                                             OUString& aStrIntName, OUString& 
aStrFrame,
-                                             SvxLinkInsertMode& eMode )
-{
-    aStrIntName = mxEdText->get_text();
-    aStrName    = mxEdIndication->get_text();
-    aStrFrame   = mxCbbFrame->get_active_text();
-
-    sal_Int32 nPos = mxLbForm->get_active();
-    if (nPos == -1)
-        // This happens when FillStandardDlgFields() hides mpLbForm.
-        nPos = 0;
-    eMode = static_cast<SvxLinkInsertMode>(nPos + 1);
-
-    // Ask dialog whether the current doc is a HTML-doc
-    if (mpDialog->IsHTMLDoc())
-        eMode = static_cast<SvxLinkInsertMode>( sal_uInt16(eMode) | 
HLINK_HTMLMODE );
-}
-
-// reset dialog-fields
-void SvxHyperlinkTabPageBase::Reset( const SfxItemSet& rItemSet )
-{
-
-    // Set dialog-fields from create-itemset
-    maStrInitURL.clear();
-
-    const SvxHyperlinkItem *pHyperlinkItem =
-                                       rItemSet.GetItem 
(SID_HYPERLINK_GETLINK);
-
-    if ( pHyperlinkItem )
-    {
-        // set dialog-fields
-        FillStandardDlgFields (pHyperlinkItem);
-
-        // set all other fields
-        FillDlgFields(pHyperlinkItem->GetURL());
-
-        // Store initial URL
-        maStrInitURL = pHyperlinkItem->GetURL();
-    }
-}
-
-// Fill output-ItemSet
-bool SvxHyperlinkTabPageBase::FillItemSet( SfxItemSet* rOut)
-{
-    OUString aStrURL, aStrName, aStrIntName, aStrFrame;
-    SvxLinkInsertMode eMode;
-
-    GetCurrentItemData ( aStrURL, aStrName, aStrIntName, aStrFrame, eMode);
-    if ( aStrName.isEmpty() ) //automatically create a visible name if the 
link is created without name
-        aStrName = CreateUiNameFromURL(aStrURL);
-
-    HyperDialogEvent nEvents = GetMacroEvents();
-    SvxMacroTableDtor* pTable = GetMacroTable();
-
-    SvxHyperlinkItem aItem( SID_HYPERLINK_SETLINK, aStrName, aStrURL, 
aStrFrame,
-                            aStrIntName, eMode, nEvents, pTable, m_showName, 
m_showText );
-    rOut->Put (aItem);
-
-    return true;
-}
-
-// Activate / Deactivate Tabpage
-void SvxHyperlinkTabPageBase::ActivatePage( const SfxItemSet& rItemSet )
-{
-
-    // Set dialog-fields from input-itemset
-    const SvxHyperlinkItem *pHyperlinkItem =
-                                       rItemSet.GetItem 
(SID_HYPERLINK_GETLINK);
-
-    if ( pHyperlinkItem )
-    {
-        // standard-fields
-        FillStandardDlgFields (pHyperlinkItem);
-    }
-
-    // show mark-window if it was open before
-    if ( ShouldOpenMarkWnd () )
-        ShowMarkWnd ();
-}
-
-DeactivateRC SvxHyperlinkTabPageBase::DeactivatePage( SfxItemSet* _pSet)
-{
-    // hide mark-wnd
-    SetMarkWndShouldOpen( IsMarkWndVisible () );
-    HideMarkWnd ();
-
-    // retrieve data of dialog
-    OUString aStrURL, aStrName, aStrIntName, aStrFrame;
-    SvxLinkInsertMode eMode;
-
-    GetCurrentItemData ( aStrURL, aStrName, aStrIntName, aStrFrame, eMode);
-
-    HyperDialogEvent nEvents = GetMacroEvents();
-    SvxMacroTableDtor* pTable = GetMacroTable();
-
-    if( _pSet )
-    {
-        SvxHyperlinkItem aItem( SID_HYPERLINK_GETLINK, aStrName, aStrURL, 
aStrFrame,
-                                aStrIntName, eMode, nEvents, pTable, 
m_showName, m_showText );
-        _pSet->Put( aItem );
-    }
-
-    return DeactivateRC::LeavePage;
-}
-
-bool SvxHyperlinkTabPageBase::ShouldOpenMarkWnd()
-{
-    return false;
-}
-
-void SvxHyperlinkTabPageBase::SetMarkWndShouldOpen(bool)
-{
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/dialogs/hyperlinkdlg.cxx 
b/cui/source/dialogs/hyperlinkdlg.cxx
new file mode 100644
index 000000000000..69d6ecee775c
--- /dev/null
+++ b/cui/source/dialogs/hyperlinkdlg.cxx
@@ -0,0 +1,182 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <hyperlinkdlg.hxx>
+#include <hyperlinkinternettabpage.hxx>
+#include <hyperlinkmailtabpage.hxx>
+#include <hyperlinkdoctabpage.hxx>
+#include <hyperlinknewdoctabpage.hxx>
+#include <hyperlinktabpagebase.hxx>
+#include <comphelper/lok.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <svl/urihelper.hxx>
+#include <svx/hlnkitem.hxx>
+#include <vcl/tabs.hrc>
+
+HyperlinkDialog::HyperlinkDialog(weld::Window* pParent, SfxChildWindow* 
/*pChildWindow*/)
+    : SfxTabDialogController(pParent, u"cui/ui/hyperlinkdlg.ui"_ustr, 
u"HyperlinkDialog"_ustr)
+{
+    AddTabPage("Internet", TabResId(RID_TAB_HLINTERNET.aLabel), 
HyperlinkInternetTP::Create,
+               RID_TAB_HLINTERNET.sIconName);
+
+    AddTabPage("Mail", TabResId(RID_TAB_HLMAIL.aLabel), 
HyperlinkMailTabPage::Create,
+               RID_TAB_HLMAIL.sIconName);
+
+    AddTabPage("Document", TabResId(RID_TAB_HLDOC.aLabel), 
HyperlinkDocTabPage::Create,
+               RID_TAB_HLDOC.sIconName);
+
+    AddTabPage("New Document", TabResId(RID_TAB_HLDOCN.aLabel), 
HyperlinkDocNewTabPage::Create,
+               RID_TAB_HLDOCN.sIconName);
+
+    SetApplyHandler(LINK(this, HyperlinkDialog, ClickApplyHdl));
+}
+
+SfxItemSet* HyperlinkDialog::CreateInputItemSet(const OUString&)
+{
+    m_pInputSet = std::make_unique<SfxItemSetFixed<SID_HYPERLINK_GETLINK, 
SID_HYPERLINK_SETLINK>>(
+        SfxGetpApp()->GetPool());
+    return m_pInputSet.get();
+}
+
+OUString HyperlinkDialog::DetermineTabPageId(const SvxHyperlinkItem* 
pHyperItem)
+{
+    if (comphelper::LibreOfficeKit::isActive())
+        return "Internet";
+
+    const OUString& aStrURL = pHyperItem->GetURL();
+    INetURLObject aURL(aStrURL);
+    INetProtocol eProtocolTyp = aURL.GetProtocol();
+
+    if (eProtocolTyp == INetProtocol::Http || eProtocolTyp == 
INetProtocol::Https
+        || eProtocolTyp == INetProtocol::Ftp)
+        return "Internet";
+
+    if (eProtocolTyp == INetProtocol::Mailto)
+        return "Mail";
+
+    if (eProtocolTyp == INetProtocol::File || aStrURL.startsWith("#"))
+        return "Document";
+
+    return "Internet";
+}
+
+void HyperlinkDialog::Apply()
+{
+    auto aSet = SfxItemSet::makeFixedSfxItemSet<SID_HYPERLINK_GETLINK, 
SID_HYPERLINK_SETLINK>(
+        SfxGetpApp()->GetPool());
+
+    SfxTabPage* pCurrentTabPage = GetTabPage(GetCurPageId());
+    if (!pCurrentTabPage)
+        return;
+
+    if (!pCurrentTabPage->FillItemSet(&aSet))
+        return;
+
+    const SvxHyperlinkItem* pItem = aSet.GetItem(SID_HYPERLINK_SETLINK);
+
+    if (!pItem || pItem->GetURL().isEmpty())
+        return;
+
+    // create the document first
+    HyperlinkDocNewTabPage* pNewDocTab = 
dynamic_cast<HyperlinkDocNewTabPage*>(pCurrentTabPage);
+    if (pNewDocTab)
+    {
+        pNewDocTab->DoApply();
+    }
+
+    SfxViewFrame* pFrame = SfxViewFrame::Current();
+    if (!pFrame)
+        return;
+
+    SfxDispatcher* pDisp = pFrame->GetDispatcher();
+    if (!pDisp)
+        return;
+
+    pDisp->ExecuteList(SID_HYPERLINK_SETLINK, SfxCallMode::RECORD, { pItem });
+}
+
+void HyperlinkDialog::CheckAndInitializeHyperlinkData()
+{
+    SfxViewFrame* pViewFrame = SfxViewFrame::Current();
+    if (!pViewFrame)
+        return;
+
+    std::unique_ptr<SfxPoolItem> pItem;
+    SfxItemState eState = 
pViewFrame->GetBindings().QueryState(SID_HYPERLINK_GETLINK, pItem);
+
+    if (eState >= SfxItemState::DEFAULT && pItem)
+    {
+        const SvxHyperlinkItem* pHyperItem = 
dynamic_cast<SvxHyperlinkItem*>(pItem.get());
+        if (!pHyperItem)
+            return;
+
+        if (m_pInputSet)
+        {
+            m_pInputSet->Put(*pHyperItem);
+        }
+
+        // Only override the page if there's a valid URL to determine the 
appropriate tab
+        // holds the last page when dialog is opened without hyperlink data 
(tdf#90496)
+        const OUString& aStrURL = pHyperItem->GetURL();
+        if (!aStrURL.isEmpty())
+        {
+            OUString sPageId = DetermineTabPageId(pHyperItem);
+            SetCurPageId(sPageId);
+        }
+
+        SfxTabPage* pCurrentTabPage = GetTabPage(GetCurPageId());
+        if (pCurrentTabPage)
+        {
+            pCurrentTabPage->Reset(m_pInputSet.get());
+        }
+    }
+}
+
+void HyperlinkDialog::Activate()
+{
+    SfxTabDialogController::Activate();
+
+    // Set initial focus to the current tab page
+    SfxTabPage* pCurrentTabPage = GetTabPage(GetCurPageId());
+    if (pCurrentTabPage)
+    {
+        static_cast<HyperlinkTabPageBase*>(pCurrentTabPage)->SetInitFocus();
+    }
+
+    // Check for existing hyperlink data only once when dialog is first 
activated
+    if (!m_bInitialized)
+    {
+        CheckAndInitializeHyperlinkData();
+        m_bInitialized = true;
+    }
+}
+
+IMPL_LINK_NOARG(HyperlinkDialog, ClickApplyHdl, weld::Button&, void) { 
Apply(); }
+
+short HyperlinkDialog::Ok()
+{
+    Apply();
+    return SfxTabDialogController::Ok();
+}
+
+void HyperlinkDialog::PageCreated(const OUString&, SfxTabPage& rTabPage)
+{
+    SfxViewFrame* pFrame = SfxViewFrame::Current();
+    if (pFrame)
+    {
+        css::uno::Reference<css::frame::XFrame> xFrame = 
pFrame->GetFrame().GetFrameInterface();
+        rTabPage.SetFrame(xFrame);
+    }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/cui/source/dialogs/hyperlinkdoctabpage.cxx 
b/cui/source/dialogs/hyperlinkdoctabpage.cxx
new file mode 100644
index 000000000000..fa76cbd2432a
--- /dev/null
+++ b/cui/source/dialogs/hyperlinkdoctabpage.cxx
@@ -0,0 +1,273 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <hyperlinkdoctabpage.hxx>
+#include <tools/urlobj.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <osl/file.hxx>
+#include <comphelper/lok.hxx>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include <hlmarkwn_def.hxx>
+
+using namespace ::com::sun::star;
+
+namespace
+{
+char const sHash[] = "#";
+}
+
+HyperlinkDocTabPage::HyperlinkDocTabPage(weld::Container* pParent,
+                                         weld::DialogController* pController,
+                                         const SfxItemSet* pSet)
+    : HyperlinkTabPageBase(pParent, pController, 
u"cui/ui/hyperlinkdocpage.ui"_ustr,
+                           u"HyperlinkDocPage"_ustr, pSet)
+    , 
m_xCbbPath(std::make_unique<SvxHyperURLBox>(m_xBuilder->weld_combo_box(u"path"_ustr)))
+    , m_xBtFileopen(m_xBuilder->weld_button(u"fileopen"_ustr))
+    , m_xEdTarget(m_xBuilder->weld_entry(u"target"_ustr))
+    , m_xFtFullURL(m_xBuilder->weld_label(u"url"_ustr))
+    , m_xBtBrowse(m_xBuilder->weld_button(u"browse"_ustr))
+{
+    m_xCbbPath->SetSmartProtocol(INetProtocol::File);
+
+    InitStdControls();
+
+    // Clear any default text from UI file
+    m_xIndication->set_text(OUString());
+
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        m_xBuilder->weld_label(u"label3"_ustr)->hide();
+        m_xBtFileopen->hide();
+        m_xBuilder->weld_label(u"path_label"_ustr)->hide();
+        m_xCbbPath->hide();
+        m_xBuilder->weld_label(u"url_label"_ustr)->hide();
+        m_xFtFullURL->hide();
+    }
+
+    m_xCbbPath->SetBaseURL(INET_FILE_SCHEME);
+
+    m_xBtFileopen->connect_clicked(LINK(this, HyperlinkDocTabPage, 
ClickFileopenHdl_Impl));
+    m_xBtBrowse->connect_clicked(LINK(this, HyperlinkDocTabPage, 
ClickTargetHdl_Impl));
+    m_xCbbPath->connect_changed(LINK(this, HyperlinkDocTabPage, 
ModifiedPathHdl_Impl));
+    m_xEdTarget->connect_changed(LINK(this, HyperlinkDocTabPage, 
ModifiedTargetHdl_Impl));
+    m_xCbbPath->connect_focus_out(LINK(this, HyperlinkDocTabPage, 
LostFocusPathHdl_Impl));
+    maTimer.SetInvokeHandler(LINK(this, HyperlinkDocTabPage, TimeoutHdl_Impl));
+}
+
+HyperlinkDocTabPage::~HyperlinkDocTabPage()
+{
+    if (mxMarkWnd)
+    {
+        mxMarkWnd->response(RET_CANCEL);
+        mxMarkWnd.reset();
+    }
+}
+
+std::unique_ptr<SfxTabPage> HyperlinkDocTabPage::Create(weld::Container* 
pParent,
+                                                        
weld::DialogController* pController,
+                                                        const SfxItemSet* pSet)
+{
+    return std::make_unique<HyperlinkDocTabPage>(pParent, pController, pSet);
+}
+
+void HyperlinkDocTabPage::FillDlgFields(const OUString& rStrURL)
+{
+    sal_Int32 nPos = rStrURL.indexOf(sHash);
+
+    m_xCbbPath->set_entry_text(rStrURL.copy(0, (nPos == -1 ? 
rStrURL.getLength() : nPos)));
+
+    OUString aStrMark;
+    if (nPos != -1 && nPos < rStrURL.getLength() - 1)
+        aStrMark = rStrURL.copy(nPos + 1);
+    m_xEdTarget->set_text(aStrMark);
+
+    ModifiedPathHdl_Impl(*m_xCbbPath->getWidget());
+}
+
+void HyperlinkDocTabPage::GetCurrentItemData(OUString& rStrURL, OUString& 
aStrName,
+                                             OUString& aStrIntName, OUString& 
aStrFrame,
+                                             SvxLinkInsertMode& eMode)
+{
+    rStrURL = GetCurrentURL();
+
+    if (rStrURL.equalsIgnoreAsciiCase(INET_FILE_SCHEME))
+        rStrURL.clear();
+
+    GetDataFromCommonFields(aStrName, aStrIntName, aStrFrame, eMode);
+}
+
+HyperlinkDocTabPage::EPathType 
HyperlinkDocTabPage::GetPathType(std::u16string_view rStrPath)
+{
+    INetURLObject aURL(rStrPath, INetProtocol::File);
+
+    if (aURL.HasError())
+        return EPathType::Invalid;
+    else
+        return EPathType::ExistsFile;
+}
+
+OUString HyperlinkDocTabPage::GetCurrentURL() const
+{
+    OUString aStrURL;
+    OUString aStrPath(m_xCbbPath->get_active_text());
+    OUString aStrMark(m_xEdTarget->get_text());
+
+    if (!aStrPath.isEmpty())
+    {
+        INetURLObject aURL(aStrPath);
+        if (aURL.GetProtocol() != INetProtocol::NotValid)
+            aStrURL = aStrPath;
+        else
+        {
+            osl::FileBase::getFileURLFromSystemPath(aStrPath, aStrURL);
+            aStrURL = INetURLObject::decode(aStrURL, 
INetURLObject::DecodeMechanism::ToIUri,
+                                            RTL_TEXTENCODING_UTF8);
+        }
+
+        if (aStrURL.isEmpty())
+            aStrURL = aStrPath;
+    }
+
+    if (!aStrMark.isEmpty())
+    {
+        aStrURL += sHash + aStrMark;
+    }
+
+    return aStrURL;
+}
+
+void HyperlinkDocTabPage::SetInitFocus() { m_xCbbPath->grab_focus(); }
+
+void HyperlinkDocTabPage::SetMarkStr(const OUString& aStrMark)
+{
+    m_xEdTarget->set_text(aStrMark);
+    ModifiedTargetHdl_Impl(*m_xEdTarget);
+}
+
+bool HyperlinkDocTabPage::ShouldOpenMarkWnd() { return m_bMarkWndOpen; }
+
+void HyperlinkDocTabPage::SetMarkWndShouldOpen(bool bOpen) { m_bMarkWndOpen = 
bOpen; }
+
+void HyperlinkDocTabPage::ClearPageSpecificControls()
+{
+    m_xCbbPath->set_entry_text(OUString());
+    m_xEdTarget->set_text(OUString());
+    maStrURL.clear();
+    m_xFtFullURL->set_label(maStrURL);
+}
+
+IMPL_LINK_NOARG(HyperlinkDocTabPage, ClickFileopenHdl_Impl, weld::Button&, 
void)
+{
+    sfx2::FileDialogHelper 
aDlg(css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
+                                FileDialogFlags::NONE, GetFrameWeld());
+
+    OUString aOldURL(GetCurrentURL());
+    if (aOldURL.startsWithIgnoreAsciiCase(INET_FILE_SCHEME))
+    {
+        OUString aPath;
+        osl::FileBase::getSystemPathFromFileURL(aOldURL, aPath);
+        aDlg.SetDisplayFolder(aPath);
+    }
+
+    ErrCode nError = aDlg.Execute();
+
+    if (ERRCODE_NONE != nError)
+        return;
+
+    OUString aURL(aDlg.GetPath());
+    OUString aPath;
+
+    osl::FileBase::getSystemPathFromFileURL(aURL, aPath);
+
+    m_xCbbPath->SetBaseURL(aURL);
+    m_xCbbPath->set_entry_text(aPath);
+
+    if (aOldURL != GetCurrentURL())
+        ModifiedPathHdl_Impl(*m_xCbbPath->getWidget());
+}
+
+IMPL_LINK_NOARG(HyperlinkDocTabPage, ClickTargetHdl_Impl, weld::Button&, void)
+{
+    mxMarkWnd = std::make_shared<SvxHlinkDlgMarkWnd>(GetFrameWeld());
+
+    if (GetPathType(maStrURL) == EPathType::ExistsFile || maStrURL.isEmpty()
+        || maStrURL.equalsIgnoreAsciiCase(INET_FILE_SCHEME) || 
maStrURL.startsWith(sHash))
+    {
+        mxMarkWnd->SetError(LERR_NOERROR);
+
+        weld::WaitObject aWait(GetFrameWeld());
+
+        if (maStrURL.equalsIgnoreAsciiCase(INET_FILE_SCHEME))
+            mxMarkWnd->RefreshTree(u""_ustr);
+        else
+            mxMarkWnd->RefreshTree(maStrURL);
+    }
+    else
+        mxMarkWnd->SetError(LERR_DOCNOTOPEN);
+
+    weld::DialogController::runAsync(mxMarkWnd, [this](sal_Int32 nResult) {
+        if (nResult == RET_OK && mxMarkWnd)
+        {
+            OUString aSelectedMark = mxMarkWnd->GetSelectedMark();
+            if (!aSelectedMark.isEmpty())
+            {
+                m_xEdTarget->set_text(aSelectedMark);
+                ModifiedTargetHdl_Impl(*m_xEdTarget);
+            }
+        }
+        mxMarkWnd.reset();
+    });
+}
+
+IMPL_LINK_NOARG(HyperlinkDocTabPage, ModifiedPathHdl_Impl, weld::ComboBox&, 
void)
+{
+    maStrURL = GetCurrentURL();
+
+    maTimer.SetTimeout(2500);
+    maTimer.Start();
+
+    m_xFtFullURL->set_label(maStrURL);
+}
+
+IMPL_LINK_NOARG(HyperlinkDocTabPage, ModifiedTargetHdl_Impl, weld::Entry&, 
void)
+{
+    maStrURL = GetCurrentURL();
+
+    if (IsMarkWndVisible())
+        mxMarkWnd->SelectEntry(m_xEdTarget->get_text());
+
+    m_xFtFullURL->set_label(maStrURL);
+}
+
+IMPL_LINK_NOARG(HyperlinkDocTabPage, LostFocusPathHdl_Impl, weld::Widget&, 
void)
+{
+    maStrURL = GetCurrentURL();
+    m_xFtFullURL->set_label(maStrURL);
+}
+
+IMPL_LINK_NOARG(HyperlinkDocTabPage, TimeoutHdl_Impl, Timer*, void)
+{
+    if (IsMarkWndVisible()
+        && (GetPathType(maStrURL) == EPathType::ExistsFile || 
maStrURL.isEmpty()
+            || maStrURL.equalsIgnoreAsciiCase(INET_FILE_SCHEME)))
+    {
+        weld::WaitObject aWait(GetFrameWeld());
+
+        if (mxMarkWnd)
+        {
+            if (maStrURL.equalsIgnoreAsciiCase(INET_FILE_SCHEME))
+                mxMarkWnd->RefreshTree(u""_ustr);
+            else
+                mxMarkWnd->RefreshTree(maStrURL);
+        }
+    }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/cui/source/dialogs/hyperlinkinternettabpage.cxx 
b/cui/source/dialogs/hyperlinkinternettabpage.cxx
new file mode 100644
index 000000000000..a712a5e66f42
--- /dev/null
+++ b/cui/source/dialogs/hyperlinkinternettabpage.cxx
@@ -0,0 +1,196 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <hyperlinkinternettabpage.hxx>
+#include <tools/urlobj.hxx>
+#include <o3tl/string_view.hxx>
+#include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp>
+#include <sot/exchange.hxx>
+#include <hlmarkwn_def.hxx>
+
+OUString HyperlinkInternetTP::CreateAbsoluteURL() const
+{
+    // erase leading and trailing whitespaces
+    OUString aStrURL(o3tl::trim(m_xCbbTarget->get_active_text()));
+
+    INetURLObject aURL(aStrURL, GetSmartProtocolFromButtons());
+
+    if (aURL.GetProtocol() != INetProtocol::NotValid)
+        return aURL.GetMainURL(INetURLObject::DecodeMechanism::ToIUri);
+    else
+        return aStrURL;
+}
+
+HyperlinkInternetTP::HyperlinkInternetTP(weld::Container* pParent,
+                                         weld::DialogController* pController,
+                                         const SfxItemSet* pSet)
+    : HyperlinkTabPageBase(pParent, pController, 
u"cui/ui/hyperlinkinternetpage.ui"_ustr,
+                           u"HyperlinkInternetPage"_ustr, pSet)
+    , 
m_xCbbTarget(std::make_unique<SvxHyperURLBox>(m_xBuilder->weld_combo_box(u"target"_ustr)))
+{
+    m_xCbbTarget->SetSmartProtocol(GetSmartProtocolFromButtons());
+
+    InitStdControls();
+
+    // set handlers
+    m_xCbbTarget->connect_focus_out(LINK(this, HyperlinkInternetTP, 
LostFocusTargetHdl_Impl));
+    m_xCbbTarget->connect_changed(LINK(this, HyperlinkInternetTP, 
ModifiedTargetHdl_Impl));
+    maTimer.SetInvokeHandler(LINK(this, HyperlinkInternetTP, TimeoutHdl_Impl));
+}
+
+std::unique_ptr<SfxTabPage> HyperlinkInternetTP::Create(weld::Container* 
pParent,
+                                                        
weld::DialogController* pController,
+                                                        const SfxItemSet* pSet)
+{
+    return std::make_unique<HyperlinkInternetTP>(pParent, pController, pSet);
+}
+
+void HyperlinkInternetTP::FillDlgFields(const OUString& rStrURL)
+{
+    // tdf#146576 - propose clipboard content when inserting a hyperlink
+    OUString aStrURL(rStrURL);
+    if (aStrURL.isEmpty())
+    {
+        if (auto xClipboard = GetSystemClipboard())
+        {
+            if (auto xTransferable = xClipboard->getContents())
+            {
+                css::datatransfer::DataFlavor aFlavor;
+                SotExchange::GetFormatDataFlavor(SotClipboardFormatId::STRING, 
aFlavor);
+                if (xTransferable->isDataFlavorSupported(aFlavor))
+                {
+                    OUString aClipBoardContent;
+                    try
+                    {
+                        if (xTransferable->getTransferData(aFlavor) >>= 
aClipBoardContent)
+                        {
+                            // tdf#162753 - allow only syntactically valid 
hyperlink targets
+                            INetURLObject aURL(o3tl::trim(aClipBoardContent));
+                            if (!aURL.HasError())
+                                aStrURL
+                                    = 
aURL.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous);
+                        }
+                    }
+                    // tdf#158345: Opening Hyperlink dialog leads to crash
+                    catch (const 
css::datatransfer::UnsupportedFlavorException&)
+                    {
+                    }
+                }
+            }
+        }
+    }
+
+    INetURLObject aURL(aStrURL);
+    OUString aStrScheme(GetSchemeFromURL(aStrURL));
+
+    // set URL-field
+    // Show the scheme, #72740
+    if (aURL.GetProtocol() != INetProtocol::NotValid)
+        
m_xCbbTarget->set_entry_text(aURL.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous));
+    else
+        m_xCbbTarget->set_entry_text(rStrURL);
+
+    SetScheme(aStrScheme);
+}
+
+void HyperlinkInternetTP::GetCurrentItemData(OUString& rStrURL, OUString& 
aStrName,
+                                             OUString& aStrIntName, OUString& 
aStrFrame,
+                                             SvxLinkInsertMode& eMode)
+{
+    rStrURL = CreateAbsoluteURL();
+    GetDataFromCommonFields(aStrName, aStrIntName, aStrFrame, eMode);
+}
+
+void HyperlinkInternetTP::ClearPageSpecificControls() { 
m_xCbbTarget->set_entry_text(OUString()); }
+
+IMPL_LINK_NOARG(HyperlinkInternetTP, ModifiedTargetHdl_Impl, weld::ComboBox&, 
void)
+{
+    OUString aScheme = GetSchemeFromURL(m_xCbbTarget->get_active_text());
+    if (!aScheme.isEmpty())
+        SetScheme(aScheme);
+
+    // start timer
+    maTimer.SetTimeout(2500);
+    maTimer.Start();
+}
+
+IMPL_LINK_NOARG(HyperlinkInternetTP, TimeoutHdl_Impl, Timer*, void) { 
RefreshMarkWindow(); }
+
+void HyperlinkInternetTP::SetScheme(std::u16string_view rScheme)
+{
+    // update target
+    RemoveImproperProtocol(rScheme);
+    m_xCbbTarget->SetSmartProtocol(GetSmartProtocolFromButtons());
+
+    // update mark window visibility
+    if (o3tl::starts_with(rScheme, INET_HTTP_SCHEME) || rScheme.empty())
+    {
+        if (m_bMarkWndOpen)
+            ShowMarkWnd();
+    }
+    else
+    {
+        // disable for https and ftp
+        if (m_bMarkWndOpen)
+            HideMarkWnd();
+    }
+}
+
+void HyperlinkInternetTP::RemoveImproperProtocol(std::u16string_view 
aProperScheme)
+{
+    OUString aStrURL(m_xCbbTarget->get_active_text());
+    if (!aStrURL.isEmpty())
-e 
... etc. - the rest is truncated

Reply via email to