diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-07-29 10:23:06 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-07-29 11:17:49 +0200 |
commit | d19a21a81bea24cdcfc8618ed3d37b825e638f65 (patch) | |
tree | b7563d91ded7051fcd140d44b913a090e30c0515 /sw | |
parent | 27613259990d39d34b036b3d717d3ceaf5c15e65 (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".
Change-Id: Ide64344f58bde4569fe499d8514dab36a055bda9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99662
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/htmlexport/htmlexport.cxx | 28 | ||||
-rw-r--r-- | sw/source/filter/html/css1atr.cxx | 15 | ||||
-rw-r--r-- | sw/source/filter/html/htmlatr.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/html/wrthtml.hxx | 4 |
4 files changed, 44 insertions, 7 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index aa92fd90ddd6..ec08d491e64f 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -17,6 +17,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 <svtools/htmlcfg.hxx> #include <swmodule.hxx> @@ -1106,6 +1107,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); + xmlDocUniquePtr 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 a4a11df97ac6..3bf645b5ddcf 100644 --- a/sw/source/filter/html/css1atr.cxx +++ b/sw/source/filter/html/css1atr.cxx @@ -184,15 +184,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; @@ -237,7 +244,7 @@ void SwHTMLWriter::OutCSS1_Property( const char *pProp, const 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 83a02160b6ef..e7997b56f5e5 100644 --- a/sw/source/filter/html/htmlatr.cxx +++ b/sw/source/filter/html/htmlatr.cxx @@ -2687,7 +2687,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; } @@ -2733,7 +2733,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 fe50f51498d3..ffc416f22662 100644 --- a/sw/source/filter/html/wrthtml.hxx +++ b/sw/source/filter/html/wrthtml.hxx @@ -696,7 +696,9 @@ Writer& OutHTML_NumberBulletListEnd( 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 |