drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx | 4 +-- editeng/source/editeng/impedit3.cxx | 2 - include/editeng/flditem.hxx | 14 ++++++++----- sd/source/ui/func/fuinsert.cxx | 2 - sd/source/ui/inc/DrawViewShell.hxx | 2 - sd/source/ui/view/drviews2.cxx | 4 +-- sd/source/ui/view/drviews4.cxx | 2 - sd/source/ui/view/drviewse.cxx | 12 ++++++----- sd/source/ui/view/drviewsf.cxx | 1 sd/source/ui/view/sdview2.cxx | 2 - svx/source/svdraw/svdotextdecomposition.cxx | 1 11 files changed, 27 insertions(+), 19 deletions(-)
New commits: commit 8bf8873f3091f131f6b4067d5a5f868882949114 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu Mar 6 17:39:58 2025 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Mar 6 19:16:28 2025 +0100 tdf#161583 drawinglayer,editeng,svx,sd: add "Name" to SvxURLField ... ... and use for PDF export, instead of the representation, which appears to be wrong. Strangely the Hyperlink dialog already allowed to insert a Name, but it was not actually set in the document. (regression from commit fa3f04bdd4f73a1b3be70dfb709c44638ef7e3d9) Change-Id: Ic21bbe8ead9f85dfbe0827b0051ecb68aeff0beb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182597 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index b39341f72612..de51c5ba6d61 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -1310,8 +1310,8 @@ void VclMetafileProcessor2D::processTextHierarchyFieldPrimitive2D( static_cast<sal_Int32>(ceil(aViewRange.getMaxX())), static_cast<sal_Int32>(ceil(aViewRange.getMaxY()))); vcl::PDFExtOutDevBookmarkEntry aBookmark; - OUString const content(rFieldPrimitive.getValue(u"Representation"_ustr)); - aBookmark.nLinkId = mpPDFExtOutDevData->CreateLink(aRectLogic, content); + OUString const altText(rFieldPrimitive.getValue(u"AltText"_ustr)); + aBookmark.nLinkId = mpPDFExtOutDevData->CreateLink(aRectLogic, altText); aBookmark.aBookmark = aURL; std::vector<vcl::PDFExtOutDevBookmarkEntry>& rBookmarks = mpPDFExtOutDevData->GetBookmarks(); rBookmarks.push_back(aBookmark); diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 699389cebbaa..6b86cbd0962b 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -3931,7 +3931,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po tools::Rectangle aRect(aTopLeft, rTextPortion.GetSize()); vcl::PDFExtOutDevBookmarkEntry aBookmark; - aBookmark.nLinkId = pPDFExtOutDevData->CreateLink(aRect, pUrlField->GetRepresentation()); + aBookmark.nLinkId = pPDFExtOutDevData->CreateLink(aRect, pUrlField->GetName()); aBookmark.aBookmark = pUrlField->GetURL(); std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFExtOutDevData->GetBookmarks(); rBookmarks.push_back(aBookmark); diff --git a/include/editeng/flditem.hxx b/include/editeng/flditem.hxx index a20692982752..397e9bd516d5 100644 --- a/include/editeng/flditem.hxx +++ b/include/editeng/flditem.hxx @@ -137,9 +137,9 @@ public: enum class SvxURLFormat { - AppDefault = 0, // Set as in App - Url, // Represent URL - Repr // Constitute representation + AppDefault = 0, // App setting + Url, // Show URL + Repr // Show representation }; class EDITENG_DLLPUBLIC SvxURLField final : public SvxFieldData @@ -147,8 +147,9 @@ class EDITENG_DLLPUBLIC SvxURLField final : public SvxFieldData private: SvxURLFormat eFormat; OUString aURL; // URL-Address - OUString aRepresentation; // What is shown - OUString aTargetFrame; // In what Frame + OUString aRepresentation; // Text shown in document + OUString aTargetFrame; // Frame to open in + OUString m_Name; // Alt-text public: static constexpr auto CLASS_ID = css::text::textfield::Type::URL; @@ -163,6 +164,9 @@ public: const OUString& GetRepresentation() const { return aRepresentation; } void SetRepresentation( const OUString& rRep ) { aRepresentation= rRep; } + OUString const& GetName() const { return m_Name; } + void SetName(OUString const& rName) { m_Name = rName; } + const OUString& GetTargetFrame() const { return aTargetFrame; } void SetTargetFrame( const OUString& rFrm ) { aTargetFrame = rFrm; } diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx index c2f9d7ea1022..a6e3a1cc04dd 100644 --- a/sd/source/ui/func/fuinsert.cxx +++ b/sd/source/ui/func/fuinsert.cxx @@ -271,7 +271,7 @@ void FuInsertClipboard::DoExecute( SfxRequest& ) ( aDataHelper.HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) && aDataHelper.GetINetBookmark( SotClipboardFormatId::UNIFORMRESOURCELOCATOR, aINetBookmark ) ) ) { - pDrViewSh->InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), u""_ustr ); + pDrViewSh->InsertURLField(aINetBookmark.GetURL(), aINetBookmark.GetDescription(), u""_ustr, u""_ustr); } } diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx index 7883b29c12da..7d2f275753c1 100644 --- a/sd/source/ui/inc/DrawViewShell.hxx +++ b/sd/source/ui/inc/DrawViewShell.hxx @@ -133,7 +133,7 @@ public: virtual void SetZoom( ::tools::Long nZoom ) override; virtual void SetZoomRect( const ::tools::Rectangle& rZoomRect ) override; - void InsertURLField(const OUString& rURL, const OUString& rText, const OUString& rTarget); + void InsertURLField(const OUString& rURL, const OUString& rText, const OUString& rTarget, OUString const& rAltText); void InsertURLButton(const OUString& rURL, const OUString& rText, const OUString& rTarget, const Point* pPos); diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 1e6b14682cd9..3f9d2655b0da 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -2917,7 +2917,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if (pHLItem->GetInsertMode() == HLINK_FIELD) { InsertURLField(pHLItem->GetURL(), pHLItem->GetName(), - pHLItem->GetTargetFrame()); + pHLItem->GetTargetFrame(), pHLItem->GetIntName()); } else if (pHLItem->GetInsertMode() == HLINK_BUTTON) { @@ -2931,7 +2931,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if (pOlView || comphelper::LibreOfficeKit::isActive()) { InsertURLField(pHLItem->GetURL(), pHLItem->GetName(), - pHLItem->GetTargetFrame()); + pHLItem->GetTargetFrame(), pHLItem->GetIntName()); } else { diff --git a/sd/source/ui/view/drviews4.cxx b/sd/source/ui/view/drviews4.cxx index 55204c760178..764eef122571 100644 --- a/sd/source/ui/view/drviews4.cxx +++ b/sd/source/ui/view/drviews4.cxx @@ -552,7 +552,7 @@ void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin) ( aDataHelper.HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) && aDataHelper.GetINetBookmark( SotClipboardFormatId::UNIFORMRESOURCELOCATOR, aINetBookmark ) ) ) { - InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), u""_ustr ); + InsertURLField(aINetBookmark.GetURL(), aINetBookmark.GetDescription(), u""_ustr, u""_ustr); } } } diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx index b815cf0818f3..cb8b10cd1b53 100644 --- a/sd/source/ui/view/drviewse.cxx +++ b/sd/source/ui/view/drviewse.cxx @@ -1045,7 +1045,7 @@ void DrawViewShell::FuSupport(SfxRequest& rReq) ( aDataHelper.HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) && aDataHelper.GetINetBookmark( SotClipboardFormatId::UNIFORMRESOURCELOCATOR, aINetBookmark ) ) ) { - InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), u""_ustr ); + InsertURLField(aINetBookmark.GetURL(), aINetBookmark.GetDescription(), u""_ustr, u""_ustr); } } } @@ -1547,14 +1547,18 @@ void DrawViewShell::FuSupportRotate(SfxRequest const &rReq) } void DrawViewShell::InsertURLField(const OUString& rURL, const OUString& rText, - const OUString& rTarget) + const OUString& rTarget, OUString const& rAltText) { OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView(); + SvxURLField aURLField(rURL, rText, SvxURLFormat::Repr); + aURLField.SetTargetFrame(rTarget); + aURLField.SetName(rAltText); + if (pOLV) { ESelection aSel( pOLV->GetSelection() ); - SvxFieldItem aURLItem( SvxURLField( rURL, rText, SvxURLFormat::Repr ), EE_FEATURE_FIELD ); + SvxFieldItem const aURLItem(aURLField, EE_FEATURE_FIELD); pOLV->InsertField( aURLItem ); if (aSel.start.nIndex <= aSel.end.nIndex) aSel.end.nIndex = aSel.start.nIndex + 1; @@ -1568,8 +1572,6 @@ void DrawViewShell::InsertURLField(const OUString& rURL, const OUString& rText, pOutl->Init( OutlinerMode::TextObject ); OutlinerMode nOutlMode = pOutl->GetOutlinerMode(); - SvxURLField aURLField(rURL, rText, SvxURLFormat::Repr); - aURLField.SetTargetFrame(rTarget); SvxFieldItem aURLItem(aURLField, EE_FEATURE_FIELD); pOutl->QuickInsertField( aURLItem, ESelection() ); std::optional<OutlinerParaObject> pOutlParaObject = pOutl->CreateParaObject(); diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx index d864a3c1ecd0..917a21e14ece 100644 --- a/sd/source/ui/view/drviewsf.cxx +++ b/sd/source/ui/view/drviewsf.cxx @@ -95,6 +95,7 @@ void DrawViewShell::GetCtrlState(SfxItemSet &rSet) aHLinkItem.SetName(pUrlField->GetRepresentation()); aHLinkItem.SetURL(pUrlField->GetURL()); aHLinkItem.SetTargetFrame(pUrlField->GetTargetFrame()); + aHLinkItem.SetIntName(pUrlField->GetName()); } else { diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx index 8f5937172c0c..b571625484f0 100644 --- a/sd/source/ui/view/sdview2.cxx +++ b/sd/source/ui/view/sdview2.cxx @@ -337,7 +337,7 @@ void View::DoPaste (::sd::Window* pWindow) ( aDataHelper.HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) && aDataHelper.GetINetBookmark( SotClipboardFormatId::UNIFORMRESOURCELOCATOR, aINetBookmark ) ) ) { - pDrViewSh->InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), u""_ustr ); + pDrViewSh->InsertURLField(aINetBookmark.GetURL(), aINetBookmark.GetDescription(), u""_ustr, u""_ustr); } } } diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index 10975edd9c0f..a05db720cdb1 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -625,6 +625,7 @@ namespace meValues.emplace_back("URL", pURLField->GetURL()); meValues.emplace_back("Representation", pURLField->GetRepresentation()); meValues.emplace_back("TargetFrame", pURLField->GetTargetFrame()); + meValues.emplace_back("AltText", pURLField->GetName()); meValues.emplace_back("SvxURLFormat", OUString::number(static_cast<sal_uInt16>(pURLField->GetFormat()))); xRet = new drawinglayer::primitive2d::TextHierarchyFieldPrimitive2D(std::move(aSequence), drawinglayer::primitive2d::FIELD_TYPE_URL, &meValues); }