cui/source/dialogs/hltpbase.cxx      |   30 +++++++++++++++++++++++++++---
 cui/source/inc/hltpbase.hxx          |    6 ++++++
 include/svx/hlnkitem.hxx             |   10 ++++++++++
 sc/source/ui/drawfunc/drawsh5.cxx    |    2 ++
 sc/source/ui/drawfunc/drtxtob.cxx    |    1 +
 sc/source/ui/view/cellsh.cxx         |    1 +
 sc/source/ui/view/editsh.cxx         |    1 +
 sd/source/ui/view/drviewsf.cxx       |    6 ++++++
 svx/source/items/hlnkitem.cxx        |   30 ++++++++++++++++++------------
 sw/source/uibase/shells/annotsh.cxx  |    2 ++
 sw/source/uibase/shells/drwbassh.cxx |    2 ++
 sw/source/uibase/shells/drwtxtex.cxx |    2 ++
 sw/source/uibase/shells/frmsh.cxx    |    3 +++
 sw/source/uibase/shells/textsh.cxx   |    2 ++
 14 files changed, 83 insertions(+), 15 deletions(-)

New commits:
commit 7522c665dbe0da689598ae484654c9ced19367fb
Author:     Maya Stephens <[email protected]>
AuthorDate: Tue Aug 19 08:49:26 2025 +0000
Commit:     Michael Stahl <[email protected]>
CommitDate: Tue Sep 9 15:52:25 2025 +0200

    Use member initlializer in SvxHyperlinkItem::SvxHyperlinkItem
    
    Change-Id: Ib58545f8038f0ed1d5975d7d080edc7a42fca2f7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189903
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190679
    Tested-by: Jenkins

diff --git a/svx/source/items/hlnkitem.cxx b/svx/source/items/hlnkitem.cxx
index 41f857f55c37..267a83743632 100644
--- a/svx/source/items/hlnkitem.cxx
+++ b/svx/source/items/hlnkitem.cxx
@@ -25,20 +25,18 @@
 
 SfxPoolItem* SvxHyperlinkItem::CreateDefault() { return new  
SvxHyperlinkItem(TypedWhichId<SvxHyperlinkItem>(0));}
 
-SvxHyperlinkItem::SvxHyperlinkItem( const SvxHyperlinkItem& rHyperlinkItem ):
-            SfxPoolItem(rHyperlinkItem)
+SvxHyperlinkItem::SvxHyperlinkItem( const SvxHyperlinkItem& rHyperlinkItem )
+    : SfxPoolItem(rHyperlinkItem),
+    sName(rHyperlinkItem.sName),
+    sURL(rHyperlinkItem.sURL),
+    sTarget(rHyperlinkItem.sTarget),
+    eType(rHyperlinkItem.eType),
+    sReplacementText(rHyperlinkItem.sReplacementText),
+    m_showName(rHyperlinkItem.m_showName),
+    m_showText(rHyperlinkItem.m_showText),
+    sIntName(rHyperlinkItem.sIntName),
+    nMacroEvents(rHyperlinkItem.nMacroEvents)
 {
-    sName   = rHyperlinkItem.sName;
-    sURL    = rHyperlinkItem.sURL;
-    sTarget = rHyperlinkItem.sTarget;
-    eType   = rHyperlinkItem.eType;
-    sIntName = rHyperlinkItem.sIntName;
-    nMacroEvents = rHyperlinkItem.nMacroEvents;
-    sReplacementText = rHyperlinkItem.sReplacementText;
-
-    m_showName = rHyperlinkItem.m_showName;
-    m_showText = rHyperlinkItem.m_showText;
-
     if( rHyperlinkItem.GetMacroTable() )
         pMacroTable.reset( new SvxMacroTableDtor( 
*rHyperlinkItem.GetMacroTable() ) );
 
commit 07fd215222539c396b042a2ef4fcb44412d1b64b
Author:     Maya Stephens <[email protected]>
AuthorDate: Mon Aug 18 14:39:15 2025 +0000
Commit:     Michael Stahl <[email protected]>
CommitDate: Tue Sep 9 15:52:12 2025 +0200

    Hide hyperlink dialog fields based on selection
    
    Hides the name field in all cases except writer text or draw text, as these 
seem to be the only types of text that can store link names.
    Hides text field for non-text links, such as shapes or images.
    If a shell does not set the properties m_showText or m_showName, deafult 
values to true, to avoid regressions for unimplemented shells.
    
    Change-Id: I228dc7f9d65c5cb17717afb79feb515376cd4d31
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189885
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190678
    Tested-by: Jenkins

diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx
index b4cf9c4bdf16..2ce3163037af 100644
--- a/cui/source/dialogs/hltpbase.cxx
+++ b/cui/source/dialogs/hltpbase.cxx
@@ -107,6 +107,9 @@ 
SvxHyperlinkTabPageBase::SvxHyperlinkTabPageBase(weld::Container* pParent,
   , mxEdText(xBuilder->weld_entry(u"name"_ustr))
   , mxBtScript(xBuilder->weld_button(u"script"_ustr))
   , mxFormLabel(xBuilder->weld_label(u"form_label"_ustr))
+  , mxNameLabel(xBuilder->weld_label(u"name_label"_ustr))
+  , mxIndicationLabel(xBuilder->weld_label(u"indication_label"_ustr))
+  , mxFurtherSettings(xBuilder->weld_label(u"label1"_ustr))
   , mbIsCloseDisabled( false )
   , mpDialog( pDlg )
   , mbStdControlsInit( false )
@@ -205,6 +208,9 @@ void SvxHyperlinkTabPageBase::HideMarkWnd()
 // 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 );
@@ -235,9 +241,27 @@ void SvxHyperlinkTabPageBase::FillStandardDlgFields ( 
const SvxHyperlinkItem* pH
         mxLbForm->append_text( aStrFormText );
         mxLbForm->append_text( aStrFormButton );
         mxLbForm->set_active( pHyperlinkItem->GetInsertMode() == HLINK_BUTTON 
? 1 : 0 );
+
+        if (pHyperlinkItem->GetShowName()) {
+            mxNameLabel->show();
+            mxEdText->show();
+            mxFurtherSettings->show();
+        } else {
+            mxNameLabel->hide();
+            mxEdText->hide();
+            mxFurtherSettings->hide();
+        }
+
+        if (pHyperlinkItem->GetShowText()) {
+            mxEdIndication->show();
+            mxIndicationLabel->show();
+        } else {
+            mxEdIndication->hide();
+            mxIndicationLabel->hide();
+        }
     }
 
-    // URL
+    // Text
     mxEdIndication->set_text( pHyperlinkItem->GetName() );
 
     // Name
@@ -445,7 +469,7 @@ bool SvxHyperlinkTabPageBase::FillItemSet( SfxItemSet* rOut)
     SvxMacroTableDtor* pTable = GetMacroTable();
 
     SvxHyperlinkItem aItem( SID_HYPERLINK_SETLINK, aStrName, aStrURL, 
OUString(),
-                            aStrIntName, eMode, nEvents, pTable );
+                            aStrIntName, eMode, nEvents, pTable, m_showName, 
m_showText );
     rOut->Put (aItem);
 
     return true;
@@ -488,7 +512,7 @@ DeactivateRC SvxHyperlinkTabPageBase::DeactivatePage( 
SfxItemSet* _pSet)
     if( _pSet )
     {
         SvxHyperlinkItem aItem( SID_HYPERLINK_GETLINK, aStrName, aStrURL, 
OUString(),
-                                aStrIntName, eMode, nEvents, pTable );
+                                aStrIntName, eMode, nEvents, pTable, 
m_showName, m_showText );
         _pSet->Put( aItem );
     }
 
diff --git a/cui/source/inc/hltpbase.hxx b/cui/source/inc/hltpbase.hxx
index 7e74e1ec0202..ed204d384264 100644
--- a/cui/source/inc/hltpbase.hxx
+++ b/cui/source/inc/hltpbase.hxx
@@ -50,9 +50,15 @@ private:
     std::unique_ptr<weld::Entry> mxEdText;
     std::unique_ptr<weld::Button> mxBtScript;
     std::unique_ptr<weld::Label> mxFormLabel;
+    std::unique_ptr<weld::Label> mxNameLabel;
+    std::unique_ptr<weld::Label> mxIndicationLabel;
+    std::unique_ptr<weld::Label> mxFurtherSettings;
 
     bool                        mbIsCloseDisabled;
 
+    bool m_showName = true;
+    bool m_showText = true;
+
     css::uno::Reference< css::frame::XFrame >
                                 mxDocumentFrame;
 
diff --git a/include/svx/hlnkitem.hxx b/include/svx/hlnkitem.hxx
index a17385f165fc..6859d1a04902 100644
--- a/include/svx/hlnkitem.hxx
+++ b/include/svx/hlnkitem.hxx
@@ -53,6 +53,9 @@ class SVX_DLLPUBLIC SvxHyperlinkItem final : public 
SfxPoolItem
     SvxLinkInsertMode eType;
     OUString sReplacementText;
 
+    bool m_showName = true;
+    bool m_showText = true;
+
     OUString sIntName;
     std::unique_ptr<SvxMacroTableDtor>  pMacroTable;
 
@@ -71,6 +74,7 @@ public:
                                     SvxLinkInsertMode eTyp,
                                     HyperDialogEvent nEvents,
                                     SvxMacroTableDtor const *pMacroTbl,
+                                    bool showName = true, bool showText = true,
                                     OUString aReplacementText = OUString());
 
     virtual bool             operator==( const SfxPoolItem& ) const override;
@@ -90,6 +94,12 @@ public:
     const   OUString& GetTargetFrame() const { return sTarget; }
     void    SetTargetFrame(const OUString& rTarget) { sTarget = rTarget; }
 
+    bool GetShowName() const { return m_showName; }
+    void    SetShowName(const bool show) { m_showName = show; }
+
+    bool GetShowText() const { return m_showText; }
+    void    SetShowText(const bool show) { m_showText = show; }
+
     SvxLinkInsertMode GetInsertMode() const { return eType; }
     void    SetInsertMode( SvxLinkInsertMode eNew ) { eType = eNew; }
 
diff --git a/sc/source/ui/drawfunc/drawsh5.cxx 
b/sc/source/ui/drawfunc/drawsh5.cxx
index 1cdb33ee05fe..1031db8dbbbb 100644
--- a/sc/source/ui/drawfunc/drawsh5.cxx
+++ b/sc/source/ui/drawfunc/drawsh5.cxx
@@ -61,6 +61,8 @@ void ScDrawShell::GetHLinkState( SfxItemSet& rSet )           
  //  Hyperlink
         //  Hyperlink
 
     SvxHyperlinkItem aHLinkItem;
+    aHLinkItem.SetShowName(false);
+    aHLinkItem.SetShowText(false);
 
     if ( rMarkList.GetMarkCount() == 1 )              // URL-Button marked ?
     {
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx 
b/sc/source/ui/drawfunc/drtxtob.cxx
index 8ef747b95a25..c3bfca0aa71a 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -379,6 +379,7 @@ void ScDrawTextObjectBar::GetState( SfxItemSet& rSet )
     if ( rSet.GetItemState( SID_HYPERLINK_GETLINK ) != SfxItemState::UNKNOWN )
     {
         SvxHyperlinkItem aHLinkItem;
+        aHLinkItem.SetShowName(false);
         SdrView* pView = mrViewData.GetScDrawView();
         OutlinerView* pOutView = pView->GetTextEditOutlinerView();
         if ( pOutView )
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index 1318a71aab95..fa646cc67896 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -679,6 +679,7 @@ void ScCellShell::GetHLinkState( SfxItemSet& rSet )
     //  if the cell at the cursor contains only a link, return that link
 
     SvxHyperlinkItem aHLinkItem;
+    aHLinkItem.SetShowName(false);
     if ( !GetViewData().GetView()->HasBookmarkAtCursor( &aHLinkItem ) )
     {
         // tdf#80043 - put selected text into item
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 3762298a4c7d..024cb8cd1ac0 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -784,6 +784,7 @@ void ScEditShell::GetState( SfxItemSet& rSet )
             case SID_HYPERLINK_GETLINK:
                 {
                     SvxHyperlinkItem aHLinkItem;
+                    aHLinkItem.SetShowName(false);
                     bool bCellLinksOnly
                         = 
(ScModule::get()->GetAppOptions().GetLinksInsertedLikeMSExcel()
                           && 
rViewData.GetSfxDocShell().GetMedium()->GetFilter()->IsMSOFormat())
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index 54893d0fdcc2..d5ae57361155 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -88,6 +88,9 @@ void DrawViewShell::GetCtrlState(SfxItemSet &rSet)
 
         if (pOLV)
         {
+            aHLinkItem.SetShowText(true);
+            aHLinkItem.SetShowName(true);
+
             const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
             const SvxFieldData* pField = pFieldItem ? pFieldItem->GetField() : 
nullptr;
             if( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) )
@@ -111,6 +114,9 @@ void DrawViewShell::GetCtrlState(SfxItemSet &rSet)
             const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
             if (rMarkList.GetMarkCount() > 0)
             {
+                aHLinkItem.SetShowText(false);
+                aHLinkItem.SetShowName(false);
+
                 bool bFound = false;
 
                 SdrObject* pMarkedObj = 
rMarkList.GetMark(0)->GetMarkedSdrObj();
diff --git a/svx/source/items/hlnkitem.cxx b/svx/source/items/hlnkitem.cxx
index b56c9bc5c955..41f857f55c37 100644
--- a/svx/source/items/hlnkitem.cxx
+++ b/svx/source/items/hlnkitem.cxx
@@ -36,6 +36,9 @@ SvxHyperlinkItem::SvxHyperlinkItem( const SvxHyperlinkItem& 
rHyperlinkItem ):
     nMacroEvents = rHyperlinkItem.nMacroEvents;
     sReplacementText = rHyperlinkItem.sReplacementText;
 
+    m_showName = rHyperlinkItem.m_showName;
+    m_showText = rHyperlinkItem.m_showText;
+
     if( rHyperlinkItem.GetMacroTable() )
         pMacroTable.reset( new SvxMacroTableDtor( 
*rHyperlinkItem.GetMacroTable() ) );
 
@@ -43,13 +46,15 @@ SvxHyperlinkItem::SvxHyperlinkItem( const SvxHyperlinkItem& 
rHyperlinkItem ):
 
 SvxHyperlinkItem::SvxHyperlinkItem( TypedWhichId<SvxHyperlinkItem> _nWhich, 
OUString aName, OUString aURL,
                                     OUString aTarget, OUString aIntName, 
SvxLinkInsertMode eTyp,
-                                    HyperDialogEvent nEvents, 
SvxMacroTableDtor const *pMacroTbl, OUString aReplacementText):
+                                    HyperDialogEvent nEvents, 
SvxMacroTableDtor const *pMacroTbl, bool showName, bool showText, OUString 
aReplacementText):
     SfxPoolItem (_nWhich ),
     sName       (std::move(aName)),
     sURL        (std::move(aURL)),
     sTarget     (std::move(aTarget)),
     eType       (eTyp),
     sReplacementText (std::move(aReplacementText)),
+    m_showName    (showName),
+    m_showText    (showText),
     sIntName (std::move(aIntName)),
     nMacroEvents (nEvents)
 {
@@ -74,7 +79,9 @@ bool SvxHyperlinkItem::operator==( const SfxPoolItem& rAttr ) 
const
                   eType   == rItem.eType   &&
                   sIntName == rItem.sIntName &&
                   nMacroEvents == rItem.nMacroEvents &&
-                  sReplacementText == rItem.sReplacementText);
+                  sReplacementText == rItem.sReplacementText &&
+                  m_showText == rItem.m_showText &&
+                  m_showName == rItem.m_showName);
     if (!bRet)
         return false;
 
@@ -186,6 +193,7 @@ bool SvxHyperlinkItem::PutValue( const css::uno::Any& rVal, 
sal_uInt8 nMemberId
                 return false;
             sReplacementText = aStr;
         break;
+        // Currently no way to put showName or showValue; these are set by the 
shell
         default:
             return false;
     }
diff --git a/sw/source/uibase/shells/annotsh.cxx 
b/sw/source/uibase/shells/annotsh.cxx
index c9fc94ce4c9c..4fe1f29f8d8c 100644
--- a/sw/source/uibase/shells/annotsh.cxx
+++ b/sw/source/uibase/shells/annotsh.cxx
@@ -1110,6 +1110,8 @@ void SwAnnotationShell::StateInsert(SfxItemSet &rSet)
             case SID_HYPERLINK_GETLINK:
                 {
                     SvxHyperlinkItem aHLinkItem;
+                    aHLinkItem.SetShowName(false);
+                    aHLinkItem.SetShowText(true);
                     aHLinkItem.SetInsertMode(HLINK_FIELD);
 
                     const SvxFieldItem* pFieldItem = 
pOLV->GetFieldAtSelection();
diff --git a/sw/source/uibase/shells/drwbassh.cxx 
b/sw/source/uibase/shells/drwbassh.cxx
index cf5b8241b78d..85eeb0c70072 100644
--- a/sw/source/uibase/shells/drwbassh.cxx
+++ b/sw/source/uibase/shells/drwbassh.cxx
@@ -988,6 +988,8 @@ void SwDrawBaseShell::GetState(SfxItemSet& rSet)
                     SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
                     OUString sHyperLink = pObj->getHyperlink();
                     SvxHyperlinkItem aHLinkItem;
+                    aHLinkItem.SetShowName(false);
+                    aHLinkItem.SetShowText(false);
                     aHLinkItem.SetURL(sHyperLink);
                     rSet.Put(aHLinkItem);
                 }
diff --git a/sw/source/uibase/shells/drwtxtex.cxx 
b/sw/source/uibase/shells/drwtxtex.cxx
index bbf3ecba17d4..cf9b5a1203d5 100644
--- a/sw/source/uibase/shells/drwtxtex.cxx
+++ b/sw/source/uibase/shells/drwtxtex.cxx
@@ -1270,6 +1270,8 @@ void SwDrawTextShell::StateInsert(SfxItemSet &rSet)
             case SID_HYPERLINK_GETLINK:
                 {
                     SvxHyperlinkItem aHLinkItem;
+                    aHLinkItem.SetShowName(false);
+                    aHLinkItem.SetShowText(false);
                     aHLinkItem.SetInsertMode(HLINK_FIELD);
 
                     const SvxFieldItem* pFieldItem = 
pOLV->GetFieldAtSelection();
diff --git a/sw/source/uibase/shells/frmsh.cxx 
b/sw/source/uibase/shells/frmsh.cxx
index 5d46cdaf22c8..b7c016ed3f5b 100644
--- a/sw/source/uibase/shells/frmsh.cxx
+++ b/sw/source/uibase/shells/frmsh.cxx
@@ -920,6 +920,9 @@ void SwFrameShell::GetState(SfxItemSet& rSet)
             {
                 SvxHyperlinkItem aHLinkItem;
 
+                aHLinkItem.SetShowName(false);
+                aHLinkItem.SetShowText(false);
+
                 SfxItemSetFixed<RES_URL, RES_URL> aURLSet(GetPool());
                 rSh.GetFlyFrameAttr( aURLSet );
 
diff --git a/sw/source/uibase/shells/textsh.cxx 
b/sw/source/uibase/shells/textsh.cxx
index 9e26a068285f..45eea7dd21f6 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -702,6 +702,8 @@ void SwTextShell::StateInsert( SfxItemSet &rSet )
                     rSh.GetCurAttr( aSet );
 
                     SvxHyperlinkItem aHLinkItem;
+                    aHLinkItem.SetShowName(true);
+                    aHLinkItem.SetShowText(true);
                     if(const SwFormatINetFormat* pINetFormat = 
aSet.GetItemIfSet(RES_TXTATR_INETFMT, false))
                     {
                         aHLinkItem.SetURL(pINetFormat->GetValue());

Reply via email to