summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2024-04-30 22:16:12 +0500
committerMike Kaganski <mike.kaganski@collabora.com>2024-05-01 13:52:47 +0500
commitff0c1b51e35a552094438c3dec16053ebf4df1ed (patch)
tree79ca8994eb2d291743576f78a3f851ec6d8e8ce8
parentbe55b84165dcad78eb72619e0737acd85602aee3 (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.cxx7
-rw-r--r--sw/source/core/text/inftxt.cxx16
-rw-r--r--sw/source/core/text/itrpaint.cxx17
-rw-r--r--sw/source/core/text/porfly.hxx1
4 files changed, 39 insertions, 2 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 5edae5a45085..148285680043 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -3065,13 +3065,16 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testHTML_160867)
CPPUNIT_ASSERT(pDoc);
assertXPath(pDoc, "/html/body/p", 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", "name");
- assertXPath(pDoc, "/html/body/p[2]/map/area", "shape", "rect");
+ assertXPath(pDoc, "/html/body/p[2]/map/area[1]", "shape", "rect");
+ CPPUNIT_ASSERT(getXPath(pDoc, "/html/body/p[2]/map/area[1]", "href").endsWith("foo/bar"));
+ assertXPath(pDoc, "/html/body/p[2]/map/area[2]", "shape", "rect");
+ CPPUNIT_ASSERT(getXPath(pDoc, "/html/body/p[2]/map/area[2]", "href").endsWith("baz"));
assertXPath(pDoc, "/html/body/p[2]/img", "usemap", "#" + mapName);
}
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index 54d0506c4db0..2cc1b0329f62 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"
@@ -1381,6 +1383,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 382c56f4cf01..1f1959b06c66 100644
--- a/sw/source/core/text/itrpaint.cxx
+++ b/sw/source/core/text/itrpaint.cxx
@@ -32,6 +32,7 @@
#include <txtfrm.hxx>
#include <swfont.hxx>
#include "txtpaint.hxx"
+#include "porfly.hxx"
#include "portab.hxx"
#include <txatbase.hxx>
#include <charfmt.hxx>
@@ -39,6 +40,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
@@ -406,6 +408,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;