summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-07-29 10:23:06 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-07-29 17:21:57 +0200
commitf0365d85149f6fd2cde4548f2242222a97ffc637 (patch)
tree9b54395d89258c2e68ed6a66a3f32f930de89920
parenta16d6e2130f5a4915fd1aca629805f2682e86803 (diff)
sw reqif-xhtml export: avoid writing text-decoration:none
This CSS key is allowed, but only the underline and line-through values are allowed in reqif mode, according to the top of page 66 of "01_OMG_Requirements Interchange Format (ReqIF)_Version 1.2_formal-16-07-01.pdf". (cherry picked from commit d19a21a81bea24cdcfc8618ed3d37b825e638f65) Change-Id: Ide64344f58bde4569fe499d8514dab36a055bda9
-rw-r--r--sw/qa/extras/htmlexport/htmlexport.cxx28
-rw-r--r--sw/source/filter/html/css1atr.cxx15
-rw-r--r--sw/source/filter/html/htmlatr.cxx4
-rw-r--r--sw/source/filter/html/wrthtml.hxx4
4 files changed, 44 insertions, 7 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index bddee029ec77..8119e509b8b0 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -20,6 +20,7 @@
#include <com/sun/star/frame/XDispatchHelper.hpp>
#include <com/sun/star/frame/DispatchHelper.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
#include <swmodule.hxx>
#include <swdll.hxx>
@@ -1131,6 +1132,33 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testMultiParaListItem)
assertXPathContent(pXmlDoc, "//reqif-xhtml:ol/reqif-xhtml:li[3]/reqif-xhtml:p", "D");
}
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testUnderlineNone)
+{
+ // Create a document with a single paragraph: its underlying is set to an explicit 'none' value.
+ loadURL("private:factory/swriter", nullptr);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XText> xText = xTextDocument->getText();
+ xText->insertString(xText->getEnd(), "x", /*bAbsorb=*/false);
+ uno::Reference<beans::XPropertySet> xParagraph(getParagraph(1), uno::UNO_QUERY);
+ xParagraph->setPropertyValue("CharUnderline", uno::makeAny(sal_Int16(awt::FontUnderline::NONE)));
+
+ // Export to reqif-xhtml.
+ 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);
+
+ // Make sure that the paragraph has no explicit style, because "text-decoration: none" is
+ // filtered out.
+ SvMemoryStream aStream;
+ HtmlExportTest::wrapFragment(maTempFile, aStream);
+ xmlDocPtr pXmlDoc = parseXmlStream(&aStream);
+ CPPUNIT_ASSERT(pXmlDoc);
+ assertXPathNoAttribute(pXmlDoc, "//reqif-xhtml:div/reqif-xhtml:p", "style");
+}
+
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 e98134fdc5ce..0d4813c8e15b 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -187,15 +187,22 @@ OString lclConvToHex(sal_uInt16 nHex)
}
}
-/// Determines if rProperty has to be suppressed due to ReqIF mode.
-bool IgnorePropertyForReqIF(bool bReqIF, const OString& rProperty)
+bool IgnorePropertyForReqIF(bool bReqIF, const OString& rProperty, const OString& rValue)
{
if (!bReqIF)
return false;
// Only allow these two keys, nothing else in ReqIF mode.
if (rProperty == sCSS1_P_text_decoration)
- return false;
+ {
+ // Deny other text-decoration values (e.g. "none").
+ if (rValue == "underline" || rValue == "line-through")
+ {
+ return false;
+ }
+
+ return true;
+ }
if (rProperty == sCSS1_P_color)
return false;
@@ -236,7 +243,7 @@ void SwHTMLWriter::OutCSS1_Property( const sal_Char *pProp,
const sal_Char *pVal,
const OUString *pSVal )
{
- if (IgnorePropertyForReqIF(mbReqIF, pProp))
+ if (IgnorePropertyForReqIF(mbReqIF, pProp, pVal))
return;
OStringBuffer sOut;
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index dda69d7c7f6a..82f0a8e473ee 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -2691,7 +2691,7 @@ static Writer& OutHTML_SvxFont( Writer& rWrt, const SfxPoolItem& rHt )
if( rHTMLWrt.m_bOutOpts )
return rWrt;
- if (IgnorePropertyForReqIF(rHTMLWrt.mbReqIF, "font-family"))
+ if (IgnorePropertyForReqIF(rHTMLWrt.mbReqIF, "font-family", OString()))
{
return rWrt;
}
@@ -2737,7 +2737,7 @@ static Writer& OutHTML_SvxFontHeight( Writer& rWrt, const SfxPoolItem& rHt )
if( rHTMLWrt.m_bOutOpts )
return rWrt;
- if (IgnorePropertyForReqIF(rHTMLWrt.mbReqIF, "font-size"))
+ if (IgnorePropertyForReqIF(rHTMLWrt.mbReqIF, "font-size", OString()))
{
return rWrt;
}
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index 3617bcdeed27..920f5c582e42 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -697,7 +697,9 @@ 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);
+
+/// Determines if rProperty with a given rValue has to be suppressed due to ReqIF mode.
+bool IgnorePropertyForReqIF(bool bReqIF, const OString& rProperty, const OString& rValue);
#endif // INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX