summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2024-12-10 16:03:40 +0500
committerXisco Fauli <xiscofauli@libreoffice.org>2024-12-19 11:32:33 +0100
commit300f70ec4b56b64f7b23aac0bdbe9cca978189b2 (patch)
tree13001018f104562c74055d57fd361853058957b4
parent5cba5e59da2102607048025a54a34aa6145dd30c (diff)
ReqIF: avoid 'target' attribute in 'a' elements
Change-Id: Iab34a18e2da766d30a2d6b5f5d8ed3855f3c8b8e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178207 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> (cherry picked from commit 46ce77dfffaa6445ed05e1400284f4f9491b9faf) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178556 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sw/qa/extras/htmlexport/data/link_with_target.fodt9
-rw-r--r--sw/qa/extras/htmlexport/data/tdf160867_image_with_link.fodt4
-rw-r--r--sw/qa/extras/htmlexport/htmlexport2.cxx16
-rw-r--r--sw/source/filter/html/htmlatr.cxx15
-rw-r--r--sw/source/filter/html/htmlflywriter.cxx7
5 files changed, 40 insertions, 11 deletions
diff --git a/sw/qa/extras/htmlexport/data/link_with_target.fodt b/sw/qa/extras/htmlexport/data/link_with_target.fodt
new file mode 100644
index 000000000000..3be1cc31f120
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/link_with_target.fodt
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:body>
+ <office:text>
+ <text:p><text:a xlink:type="simple" xlink:href="http://www.example.org/" office:target-frame-name="_blank">link</text:a></text:p>
+ </office:text>
+ </office:body>
+</office:document> \ No newline at end of file
diff --git a/sw/qa/extras/htmlexport/data/tdf160867_image_with_link.fodt b/sw/qa/extras/htmlexport/data/tdf160867_image_with_link.fodt
index 43c35cdff13e..7bf886ab94ce 100644
--- a/sw/qa/extras/htmlexport/data/tdf160867_image_with_link.fodt
+++ b/sw/qa/extras/htmlexport/data/tdf160867_image_with_link.fodt
@@ -8,13 +8,13 @@
</office:styles>
<office:body>
<office:text>
- <text:p><draw:a xlink:type="simple" xlink:href="foo/bar"><draw:frame draw:style-name="Frame" draw:name="image1" svg:width="17cm" svg:height="25mm" style:rel-height="scale"><draw:image draw:mime-type="image/png">
+ <text:p><draw:a xlink:type="simple" xlink:href="foo/bar" office:target-frame-name="_blank"><draw:frame draw:style-name="Frame" draw:name="image1" svg:width="17cm" svg:height="25mm" style:rel-height="scale"><draw:image draw:mime-type="image/png">
<office:binary-data>iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAAMSURBVBhXY/jPwAAAAwEBAGMkVdMAAAAASUVORK5C</office:binary-data>
</draw:image>
</draw:frame></draw:a>image1 with a hyperlink, and this text with <text:a xlink:type="simple" xlink:href="baz" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">another hyperlink</text:a></text:p>
<text:p><draw:frame draw:style-name="Frame" draw:name="frame" svg:width="17cm">
<draw:text-box fo:min-height="1pt">
- <text:p><draw:a xlink:type="simple" xlink:href="foo/bar"><draw:frame draw:style-name="Frame" draw:name="image2" svg:width="17cm" svg:height="25mm"><draw:image draw:mime-type="image/png">
+ <text:p><draw:a xlink:type="simple" xlink:href="foo/bar" office:target-frame-name="_blank"><draw:frame draw:style-name="Frame" draw:name="image2" svg:width="17cm" svg:height="25mm"><draw:image draw:mime-type="image/png">
<office:binary-data>iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAAMSURBVBhXY/jPwAAAAwEBAGMkVdMAAAAASUVORK5C</office:binary-data>
</draw:image>
</draw:frame></draw:a>image2 with a hyperlink, and this text with <text:a xlink:type="simple" xlink:href="baz" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">another hyperlink</text:a>, in a frame</text:p>
diff --git a/sw/qa/extras/htmlexport/htmlexport2.cxx b/sw/qa/extras/htmlexport/htmlexport2.cxx
index 99e9d5347b15..550c9644af97 100644
--- a/sw/qa/extras/htmlexport/htmlexport2.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport2.cxx
@@ -1270,6 +1270,8 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_160867)
assertXPath(pXmlDoc, "//reqif-xhtml:p[2]/reqif-xhtml:a/reqif-xhtml:object");
CPPUNIT_ASSERT(
getXPath(pXmlDoc, "//reqif-xhtml:p[2]/reqif-xhtml:a", "href").endsWith("foo/bar"));
+ // There must be no 'target' attribute
+ assertXPathNoAttribute(pXmlDoc, "//reqif-xhtml:p[2]/reqif-xhtml:a", "target");
}
CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testHTML_161979)
@@ -1606,6 +1608,20 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testHTML_163873)
assertXPath(pDoc, "/html/body/p[14]/span/h2", "style", u"display:inline;");
}
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifNoTargetInA)
+{
+ // Given a document with a link with target:
+ createSwDoc("link_with_target.fodt");
+
+ // When exporting to XHTML:
+ ExportToReqif();
+
+ // Check that 'a' element has no 'target' attribute
+ xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile();
+ // Without the accompanying fix in place, this test would have failed
+ assertXPathNoAttribute(pXmlDoc, "//reqif-xhtml:a", "target");
+}
+
} // end of anonymous namespace
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index 7e2009263cd6..d71b97fb281a 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -3105,13 +3105,16 @@ SwHTMLWriter& OutHTML_INetFormat( SwHTMLWriter& rWrt, const SwFormatINetFormat&
sOut = "\""_ostr;
}
- const OUString& rTarget = rINetFormat.GetTargetFrame();
- if( !rTarget.isEmpty() )
+ if (!rWrt.mbReqIF) // no target attribute for ReqIF
{
- sOut += " " OOO_STRING_SVTOOLS_HTML_O_target "=\"";
- rWrt.Strm().WriteOString( sOut );
- HTMLOutFuncs::Out_String( rWrt.Strm(), rTarget );
- sOut = "\""_ostr;
+ const OUString& rTarget = rINetFormat.GetTargetFrame();
+ if (!rTarget.isEmpty())
+ {
+ sOut += " " OOO_STRING_SVTOOLS_HTML_O_target "=\"";
+ rWrt.Strm().WriteOString(sOut);
+ HTMLOutFuncs::Out_String(rWrt.Strm(), rTarget);
+ sOut = "\""_ostr;
+ }
}
if( !sRel.isEmpty() )
diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx
index 45d1893e4232..0ff0183248e9 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -1301,7 +1301,8 @@ SwHTMLWriter& OutHTML_ImageStart( HtmlWriter& rHtml, SwHTMLWriter& rWrt, const S
{
aMapURL = pURLItem->GetURL();
aName = pURLItem->GetName();
- aTarget = pURLItem->GetTargetFrameName();
+ if (!rWrt.mbReqIF) // no target attribute for ReqIF
+ aTarget = pURLItem->GetTargetFrameName();
}
else if (rWrt.mbReqIF && pAltImgMap)
{
@@ -1312,8 +1313,8 @@ SwHTMLWriter& OutHTML_ImageStart( HtmlWriter& rHtml, SwHTMLWriter& rWrt, const S
{
aMapURL = pIMapObject->GetURL();
aName = pIMapObject->GetName();
- aTarget = pIMapObject->GetTarget();
- if (!aMapURL.isEmpty() || !aName.isEmpty() || !aTarget.isEmpty())
+ // Don't read target for ReqIF
+ if (!aMapURL.isEmpty() || !aName.isEmpty())
break;
}
}