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 e36e5a7dd05f150372a3b2bea5d5d0c785b54520 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu Mar 6 17:39:58 2025 +0100 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Mon Mar 10 01:42:16 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> (cherry picked from commit 8bf8873f3091f131f6b4067d5a5f868882949114) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182625 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index f12be451b03a..54f6f3c028b5 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -1306,8 +1306,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 db3b63d6c99b..6553527e009d 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -4050,7 +4050,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 7dec33e9e891..0044c654a8b2 100644 --- a/include/editeng/flditem.hxx +++ b/include/editeng/flditem.hxx @@ -136,9 +136,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 @@ -146,8 +146,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; @@ -162,6 +163,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 693ae65f14c4..86701f2f77d0 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 80543adebac2..19165bc6d1d9 100644 --- a/sd/source/ui/inc/DrawViewShell.hxx +++ b/sd/source/ui/inc/DrawViewShell.hxx @@ -132,7 +132,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 92e18c868ad4..e00382d4b80a 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -2308,7 +2308,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) { @@ -2322,7 +2322,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 83ffcc9be39b..ecc5f5accb63 100644 --- a/sd/source/ui/view/drviews4.cxx +++ b/sd/source/ui/view/drviews4.cxx @@ -549,7 +549,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 f594fb1f7fcf..621f23ab5a90 100644 --- a/sd/source/ui/view/drviewse.cxx +++ b/sd/source/ui/view/drviewse.cxx @@ -985,7 +985,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); } } } @@ -1496,14 +1496,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.nStartPos <= aSel.nEndPos ) aSel.nEndPos = aSel.nStartPos + 1; @@ -1517,8 +1521,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 1c1577b7ab91..c97169de054c 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 b2f58cfcfffd..efa963fc3831 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 c7cc6998cbb8..7aae5ee0a768 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); }