diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-04-30 22:16:12 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-06-18 03:09:59 +0500 |
commit | 958efa1943e3a5f303cd9a85d7af3e8dabaff3da (patch) | |
tree | 0a53ad70560d28b633810adc83e5e2243a1a3f25 | |
parent | 473a9e3e0b124beb11fdd07099ac221513ce1b64 (diff) |
tdf#160867: export as-char frames' hyperlinks to image map
Change-Id: Idc8d41a27c8ee9cdd12fb5e17a328ec6aa104a16
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166935
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | sw/qa/extras/htmlexport/htmlexport.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/text/inftxt.cxx | 16 | ||||
-rw-r--r-- | sw/source/core/text/itrpaint.cxx | 17 | ||||
-rw-r--r-- | sw/source/core/text/porfly.hxx | 1 |
4 files changed, 40 insertions, 2 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index acad980505e3..f54ad6e7fce2 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -3071,13 +3071,17 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testHTML_160867) CPPUNIT_ASSERT(pDoc); assertXPath(pDoc, "/html/body/p"_ostr, 2); - // Test export of text hyperlink in the image map. TODO: implement export of image hyperlink. + // Test export of image and text hyperlinks in the image map. // Without the fix, the test would fail with // - Expected: 1 // - Actual : 0 // - In <>, XPath '/html/body/p[2]/map' number of nodes is incorrect const OUString mapName = getXPath(pDoc, "/html/body/p[2]/map"_ostr, "name"_ostr); - assertXPath(pDoc, "/html/body/p[2]/map/area"_ostr, "shape"_ostr, u"rect"_ustr); + assertXPath(pDoc, "/html/body/p[2]/map/area[1]"_ostr, "shape"_ostr, u"rect"_ustr); + CPPUNIT_ASSERT( + getXPath(pDoc, "/html/body/p[2]/map/area[1]"_ostr, "href"_ostr).endsWith("foo/bar")); + assertXPath(pDoc, "/html/body/p[2]/map/area[2]"_ostr, "shape"_ostr, u"rect"_ustr); + CPPUNIT_ASSERT(getXPath(pDoc, "/html/body/p[2]/map/area[2]"_ostr, "href"_ostr).endsWith("baz")); assertXPath(pDoc, "/html/body/p[2]/img"_ostr, "usemap"_ostr, "#" + mapName); } diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 73295ffae113..18cd23ebef61 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -44,6 +44,7 @@ #include <viewsh.hxx> #include <viewopt.hxx> #include <frmtool.hxx> +#include <fmturl.hxx> #include <IDocumentSettingAccess.hxx> #include <IDocumentDeviceAccess.hxx> #include <IDocumentMarkAccess.hxx> @@ -51,6 +52,7 @@ #include <rootfrm.hxx> #include "inftxt.hxx" #include <noteurl.hxx> +#include "porfly.hxx" #include "porftn.hxx" #include "porrst.hxx" #include "itratr.hxx" @@ -1477,6 +1479,20 @@ void SwTextPaintInfo::NotifyURL_(const SwLinePortion& rPor) const const SwFormatINetFormat& rFormat = pAttr->GetINetFormat(); pNoteURL->InsertURLNote(rFormat.GetValue(), rFormat.GetTargetFrame(), aIntersect); } + else if (rPor.IsFlyCntPortion()) + { + if (auto* pFlyContentPortion = dynamic_cast<const sw::FlyContentPortion*>(&rPor)) + { + if (auto* pFlyFtame = pFlyContentPortion->GetFlyFrame()) + { + if (auto* pFormat = pFlyFtame->GetFormat()) + { + auto& url = pFormat->GetURL(); // TODO: url.GetMap() ? + pNoteURL->InsertURLNote(url.GetURL(), url.GetTargetFrameName(), aIntersect); + } + } + } + } } } diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx index 8fa9ca45f5fd..f02beed8ce5b 100644 --- a/sw/source/core/text/itrpaint.cxx +++ b/sw/source/core/text/itrpaint.cxx @@ -33,6 +33,7 @@ #include <swfont.hxx> #include "txtpaint.hxx" #include "porfld.hxx" +#include "porfly.hxx" #include "portab.hxx" #include <txatbase.hxx> #include <charfmt.hxx> @@ -40,6 +41,7 @@ #include "porrst.hxx" #include "pormulti.hxx" #include <doc.hxx> +#include <fmturl.hxx> // Returns, if we have an underline breaking situation // Adding some more conditions here means you also have to change them @@ -461,6 +463,21 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip, if (GetFnt()->IsURL() && pPor->InTextGrp()) GetInfo().NotifyURL(*pPor); + else if (pPor->IsFlyCntPortion()) + { + if (auto* pFlyContentPortion = dynamic_cast<sw::FlyContentPortion*>(pPor)) + { + if (auto* pFlyFrame = pFlyContentPortion->GetFlyFrame()) + { + if (auto* pFormat = pFlyFrame->GetFormat()) + { + auto& url = pFormat->GetURL(); + if (!url.GetURL().isEmpty()) // TODO: url.GetMap() ? + GetInfo().NotifyURL(*pPor); + } + } + } + } bFirst &= !pPor->GetLen(); if( pNext || !pPor->IsMarginPortion() ) diff --git a/sw/source/core/text/porfly.hxx b/sw/source/core/text/porfly.hxx index a519c1109c87..2c56563a4436 100644 --- a/sw/source/core/text/porfly.hxx +++ b/sw/source/core/text/porfly.hxx @@ -76,6 +76,7 @@ namespace sw FlyContentPortion(SwFlyInContentFrame* pFly); static FlyContentPortion* Create(const SwTextFrame& rFrame, SwFlyInContentFrame* pFly, const Point& rBase, tools::Long nAscent, tools::Long nDescent, tools::Long nFlyAsc, tools::Long nFlyDesc, AsCharFlags nFlags); SwFlyInContentFrame* GetFlyFrame() { return m_pFly; } + const SwFlyInContentFrame* GetFlyFrame() const { return m_pFly; } void GetFlyCursorOfst(Point& rPoint, SwPosition& rPos, SwCursorMoveState* pCMS) const { m_pFly->GetModelPositionForViewPoint(&rPos, rPoint, pCMS); }; virtual void Paint(const SwTextPaintInfo& rInf) const override; virtual ~FlyContentPortion() override; |