summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-08-05 14:14:01 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-08-06 09:52:17 +0200
commite41e309693060c85e194ecd2267ad7e06f35ed53 (patch)
tree60dd6b18c03051b9d26f10e9dc0b180a93a6d8f4
parentdb175f7b0114fce67b2ae403b572e53fd8aa9f25 (diff)
sw XHTML export: <sdfield> and shading is not relevant for ReqIF
See commit 4cd3c436923bfba281b1bf16d9785208a2119cea (sw reqif-xhtml export: limit values of the style attribute, 2018-04-11) for motivation. Reviewed-on: https://gerrit.libreoffice.org/76986 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins (cherry picked from commit 3166209cca8c8c76d4605eead12431fed2f1e306) Change-Id: I28aa239a1b02c8021879159e5591880804aa0825
-rw-r--r--sw/qa/extras/htmlexport/data/field-shade-reqif.odtbin0 -> 8903 bytes
-rw-r--r--sw/qa/extras/htmlexport/htmlexport.cxx14
-rw-r--r--sw/source/filter/html/htmlfldw.cxx14
3 files changed, 25 insertions, 3 deletions
diff --git a/sw/qa/extras/htmlexport/data/field-shade-reqif.odt b/sw/qa/extras/htmlexport/data/field-shade-reqif.odt
new file mode 100644
index 000000000000..be7ec90f5a7f
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/field-shade-reqif.odt
Binary files differ
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 6944a8991c07..f91fa5ceb2a9 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -702,6 +702,20 @@ DECLARE_HTMLEXPORT_TEST(testFieldShade, "field-shade.odt")
assertXPath(pDoc, "/html/body/p[2]/span/span", 0);
}
+DECLARE_HTMLEXPORT_TEST(testFieldShadeReqIf, "field-shade-reqif.odt")
+{
+ htmlDocPtr pDoc = parseHtml(maTempFile);
+ CPPUNIT_ASSERT(pDoc);
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 0
+ // - Actual : 2
+ // i.e. the ReqIF subset of xhtml had a background color and a page number field, resulting in
+ // an invalid ReqIF-XHTML.
+ assertXPath(pDoc, "/html/body/div/p[1]/span", 0);
+ assertXPath(pDoc, "/html/body/div/p[1]/sdfield", 0);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/htmlfldw.cxx b/sw/source/filter/html/htmlfldw.cxx
index e2ac83f39df9..dfa4ae71bb3a 100644
--- a/sw/source/filter/html/htmlfldw.cxx
+++ b/sw/source/filter/html/htmlfldw.cxx
@@ -257,11 +257,18 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pField,
default: break;
}
- // <SDFIELD>-Tag ausgeben
+ // ReqIF-XHTML doesn't allow <sdfield>.
+ if (rHTMLWrt.mbReqIF && pTypeStr)
+ {
+ pTypeStr = nullptr;
+ }
+
+ // Output the <sdfield> tag.
if( pTypeStr )
{
OStringBuffer sOut;
sOut.append('<');
+ sOut.append(rHTMLWrt.GetNamespace());
sOut.append(OOO_STRING_SVTOOLS_HTML_sdfield).append(' ').
append(OOO_STRING_SVTOOLS_HTML_O_type).append('=').
append(pTypeStr);
@@ -427,7 +434,7 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pField,
rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
}
- // Off-Tag ausgeben
+ // Output the closing tag.
if( pTypeStr )
HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_sdfield, false );
@@ -538,7 +545,8 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
if( pTextField )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
- bool bFieldShadings = SwViewOption::IsFieldShadings();
+ // ReqIF-XHTML doesn't allow specifying a background color.
+ bool bFieldShadings = SwViewOption::IsFieldShadings() && !rHTMLWrt.mbReqIF;
if (bFieldShadings)
{
// If there is a text portion background started already, that should have priority.