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 fa3f04bdd4)
Change-Id: Ic21bbe8ead9f85dfbe0827b0051ecb68aeff0beb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182597
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user