summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-06-10 09:12:33 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-07-01 10:08:46 +0200
commit31850ef3505bc15a75c9a9a50ed04f970670b244 (patch)
tree1ca3c215569e77b88563c2b727faca17bdc38f6a /sw
parentefe41847428e61a8456706861ddf880a36b816a0 (diff)
sw XHTML export: avoid writing default transparent background for ReqIF
We started writing properties of tables and rows since commit c3c3303516c3da9372dce3f05f38f15a104e961c (sw XHTML export: output table / table row background format using CSS, 2022-05-10). In case the SwTableLine has an explicit SvxBrushItem with its color set to COL_TRANSPARENT, we turn that into a "background: transparent" CSS by default. This is a 1:1 mapping from the doc model, but HTML defaults to this already, so this is considered as noise. Extend IgnorePropertyForReqIF() to filter out these unwanted defaults, and fix SwHTMLWriter::OutCSS1_Property(), because it used to not pass the CSS value for the filter function. The behavior for table cells is unchanged, we continue to not export cell properties (in the ReqIF case) at all. (cherry picked from commit 04cc6e079e3122c183054fde046c054ed6c7b737) Conflicts: sw/source/filter/html/css1atr.cxx (cherry picked from commit bd1d738e78e5287b35e2d17f84971d44b384425b) Change-Id: Idbcd07809e159def694f4de017eebc7ad4104575
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/htmlexport/htmlexport.cxx8
-rw-r--r--sw/source/filter/html/css1atr.cxx21
2 files changed, 26 insertions, 3 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 535a484dd0e2..cb2d697d7664 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -1641,10 +1641,14 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testTableBackground)
pWrtShell->SetTabBackground(aBrush);
pWrtShell->Down(/*bSelect=*/false);
pWrtShell->SplitNode();
- pWrtShell->InsertTable(aInsertTableOptions, /*nRows=*/1, /*nCols=*/1);
+ pWrtShell->InsertTable(aInsertTableOptions, /*nRows=*/2, /*nCols=*/1);
pWrtShell->MoveTable(GotoPrevTable, fnTableStart);
aBrush.SetColor(0x00ff00);
pWrtShell->SetRowBackground(aBrush);
+ pWrtShell->Down(/*bSelect=*/false);
+ // Second row has an explicit transparent background.
+ aBrush.SetColor(COL_TRANSPARENT);
+ pWrtShell->SetRowBackground(aBrush);
// When exporting to reqif-xhtml:
ExportToReqif();
@@ -1661,6 +1665,8 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testTableBackground)
assertXPath(pXmlDoc, "//reqif-xhtml:table[2]/reqif-xhtml:tr[1]", "style",
"background: #00ff00");
assertXPathNoAttribute(pXmlDoc, "//reqif-xhtml:table[2]/reqif-xhtml:tr[1]", "bgcolor");
+ // Second row has no explicit style, the default is not written.
+ assertXPathNoAttribute(pXmlDoc, "//reqif-xhtml:table[2]/reqif-xhtml:tr[2]", "style");
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
index eccbbdae4f3d..18ee264324f6 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -180,9 +180,21 @@ OString lclConvToHex(sal_uInt16 nHex)
bool IgnorePropertyForReqIF(bool bReqIF, const OString& rProperty, const OString& rValue,
std::optional<sw::Css1Background> oMode)
{
- if (!bReqIF || (oMode.has_value() && *oMode != sw::Css1Background::TableCell))
+ if (!bReqIF)
return false;
+ if (oMode.has_value() && *oMode != sw::Css1Background::TableCell)
+ {
+ // Table or row.
+ if (rProperty == sCSS1_P_background && rValue == "transparent")
+ {
+ // This is the default already.
+ return true;
+ }
+
+ return false;
+ }
+
// Only allow these two keys, nothing else in ReqIF mode.
if (rProperty == sCSS1_P_text_decoration)
{
@@ -239,7 +251,12 @@ void SwHTMLWriter::OutCSS1_Property( const char *pProp,
const OUString *pSVal,
std::optional<sw::Css1Background> oMode )
{
- if (IgnorePropertyForReqIF(mbReqIF, pProp, pVal, oMode))
+ OString aPropertyValue(pVal);
+ if (aPropertyValue.isEmpty() && pSVal)
+ {
+ aPropertyValue = pSVal->toUtf8();
+ }
+ if (IgnorePropertyForReqIF(mbReqIF, pProp, aPropertyValue, oMode))
return;
OStringBuffer sOut;