summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-01-17 10:48:20 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-01-17 16:18:37 +0100
commitec855fe33351d482b6d60fd92cf531757fccee83 (patch)
treeaaf19e6543886579a0262148a9ba966bd50aef74
parentec17da9c7867e0e0667c6479f16021abb3008f24 (diff)
sw reqif-xhtml export: fix not needed font name/size
The only reason commit 4cd3c436923bfba281b1bf16d9785208a2119cea (sw reqif-xhtml export: limit values of the style attribute, 2018-04-11) missed these is because they write their css properties directly, not going via SwHTMLWriter::OutCSS1_Property(). Also adapt testReqIfWellFormed: its intention was to make sure that in case these properties are written, then inline CSS is used: that is true for XHTML, but not for ReqIF-XHTML. (cherry picked from commit 1655819c8914efad28f218f56d8d89d4e4bd9488) Change-Id: I4ceb2bb09187101baa6f4a74d65aaa4dc955511f
-rw-r--r--sw/qa/extras/htmlexport/data/xhtml-css.odt (renamed from sw/qa/extras/htmlexport/data/reqif.odt)bin8559 -> 8559 bytes
-rw-r--r--sw/qa/extras/htmlexport/htmlexport.cxx39
-rw-r--r--sw/source/filter/html/css1atr.cxx2
-rw-r--r--sw/source/filter/html/htmlatr.cxx10
-rw-r--r--sw/source/filter/html/wrthtml.hxx1
5 files changed, 48 insertions, 4 deletions
diff --git a/sw/qa/extras/htmlexport/data/reqif.odt b/sw/qa/extras/htmlexport/data/xhtml-css.odt
index a094202e9775..a094202e9775 100644
--- a/sw/qa/extras/htmlexport/data/reqif.odt
+++ b/sw/qa/extras/htmlexport/data/xhtml-css.odt
Binary files differ
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index faf86c966159..7d707888dea5 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -535,7 +535,7 @@ DECLARE_HTMLEXPORT_TEST(testReqIfTable2, "reqif-table2.odt")
CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:td>") != -1);
}
-DECLARE_HTMLEXPORT_TEST(testReqIfWellFormed, "reqif.odt")
+DECLARE_HTMLEXPORT_TEST(testXHTMLUseCSS, "xhtml-css.odt")
{
SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
CPPUNIT_ASSERT(pStream);
@@ -544,9 +544,9 @@ DECLARE_HTMLEXPORT_TEST(testReqIfWellFormed, "reqif.odt")
pStream->Seek(0);
OString aStream(read_uInt8s_ToOString(*pStream, nLength));
// This failed, <font face="..."> was written.
- CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:span style=\"font-family:") != -1);
+ CPPUNIT_ASSERT(aStream.indexOf("<span style=\"font-family:") != -1);
// This failed, <font size="..."> was written.
- CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:span style=\"font-size:") != -1);
+ CPPUNIT_ASSERT(aStream.indexOf("<span style=\"font-size:") != -1);
}
DECLARE_HTMLEXPORT_TEST(testReqIfList, "reqif-list.xhtml")
@@ -847,6 +847,39 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifComment)
CPPUNIT_ASSERT(pDoc);
}
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifFontNameSize)
+{
+ // Create a document with a custom font name and size in it.
+ loadURL("private:factory/swriter", nullptr);
+ uno::Reference<beans::XPropertySet> xParagraph(getParagraph(1), uno::UNO_QUERY);
+ xParagraph->setPropertyValue("CharFontName", uno::makeAny(OUString("Liberation Serif")));
+ float fCharHeight = 14.0;
+ xParagraph->setPropertyValue("CharHeight", uno::makeAny(fCharHeight));
+ sal_Int32 nCharColor = 0xff0000;
+ xParagraph->setPropertyValue("CharColor", uno::makeAny(nCharColor));
+ uno::Reference<text::XTextRange> xTextRange(xParagraph, uno::UNO_QUERY);
+ xTextRange->setString("x");
+
+ // Export it.
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aStoreProperties = {
+ comphelper::makePropertyValue("FilterName", OUString("HTML (StarWriter)")),
+ comphelper::makePropertyValue("FilterOptions", OUString("xhtmlns=reqif-xhtml")),
+ };
+ xStorable->storeToURL(maTempFile.GetURL(), aStoreProperties);
+ SvMemoryStream aStream;
+ HtmlExportTest::wrapFragment(maTempFile, aStream);
+ xmlDocPtr pDoc = parseXmlStream(&aStream);
+
+ // Make sure the output is well-formed.
+ CPPUNIT_ASSERT(pDoc);
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 1
+ // - Actual : 3
+ // i.e. font name and size was written, even if that's not relevant for ReqIF.
+ assertXPath(pDoc, "//reqif-xhtml:span", 1);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
index 94dd953bd221..e98134fdc5ce 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -185,6 +185,7 @@ OString lclConvToHex(sal_uInt16 nHex)
return OString(aNToABuf, 2);
}
+}
/// Determines if rProperty has to be suppressed due to ReqIF mode.
bool IgnorePropertyForReqIF(bool bReqIF, const OString& rProperty)
@@ -201,7 +202,6 @@ bool IgnorePropertyForReqIF(bool bReqIF, const OString& rProperty)
return true;
}
-}
OString GetCSS1_Color(const Color& rColor)
{
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index 807396ace498..f34d978e9806 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -2696,6 +2696,11 @@ static Writer& OutHTML_SvxFont( Writer& rWrt, const SfxPoolItem& rHt )
if( rHTMLWrt.m_bOutOpts )
return rWrt;
+ if (IgnorePropertyForReqIF(rHTMLWrt.mbReqIF, "font-family"))
+ {
+ return rWrt;
+ }
+
if( rHTMLWrt.m_bTagOn )
{
OUString aNames;
@@ -2737,6 +2742,11 @@ static Writer& OutHTML_SvxFontHeight( Writer& rWrt, const SfxPoolItem& rHt )
if( rHTMLWrt.m_bOutOpts )
return rWrt;
+ if (IgnorePropertyForReqIF(rHTMLWrt.mbReqIF, "font-size"))
+ {
+ return rWrt;
+ }
+
if( rHTMLWrt.m_bTagOn )
{
if (rHTMLWrt.mbXHTML)
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index a3fc7a115b34..3617bcdeed27 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -697,6 +697,7 @@ Writer& OutHTML_NumBulListEnd( SwHTMLWriter& rWrt,
Writer& OutCSS1_SvxBox( Writer& rWrt, const SfxPoolItem& rHt );
OString GetCSS1_Color(const Color& rColor);
+bool IgnorePropertyForReqIF(bool bReqIF, const OString& rProperty);
#endif // INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX