1458e3
From 5c705fbd9e4d231fed87b7e8ac06d8b7d4c6891f Mon Sep 17 00:00:00 2001
1458e3
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
1458e3
Date: Thu, 12 Aug 2021 12:55:30 +0100
1458e3
Subject: [PATCH] Resolves: tdf#132739 two style tags where there should be
1458e3
 just one
1458e3
1458e3
Change-Id: Id9c8c8cc8c5ffdd21ba79ff39a6279cf2ddc8025
1458e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120360
1458e3
Tested-by: Jenkins
1458e3
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
1458e3
---
1458e3
 sw/source/filter/html/css1atr.cxx  | 4 +++-
1458e3
 sw/source/filter/html/htmltabw.cxx | 9 ++++++---
1458e3
 sw/source/filter/html/wrthtml.hxx  | 2 +-
1458e3
 3 files changed, 10 insertions(+), 5 deletions(-)
1458e3
1458e3
diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
1458e3
index 7b1a5cc19be3..c401d95a788f 100644
1458e3
--- a/sw/source/filter/html/css1atr.cxx
1458e3
+++ b/sw/source/filter/html/css1atr.cxx
1458e3
@@ -2113,10 +2113,12 @@ void SwHTMLWriter::OutCSS1_TableFrameFormatOptions( const SwFrameFormat& rFrameF
1458e3
         Strm().WriteChar( '\"' );
1458e3
 }
1458e3
 
1458e3
-void SwHTMLWriter::OutCSS1_TableCellBorderHack(SwFrameFormat const& rFrameFormat)
1458e3
+void SwHTMLWriter::OutCSS1_TableCellBordersAndBG(SwFrameFormat const& rFrameFormat, const SvxBrushItem *pBrushItem)
1458e3
 {
1458e3
     SwCSS1OutMode const aMode( *this,
1458e3
         CSS1_OUTMODE_STYLE_OPT_ON|CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_TABLEBOX, nullptr );
1458e3
+    if (pBrushItem)
1458e3
+        OutCSS1_SvxBrush(*this, *pBrushItem, Css1Background::Table, nullptr);
1458e3
     OutCSS1_SvxBox(*this, rFrameFormat.GetBox());
1458e3
     if (!m_bFirstCSS1Property)
1458e3
     {
1458e3
diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx
1458e3
index 4c83319747b7..63812a9b3ef6 100644
1458e3
--- a/sw/source/filter/html/htmltabw.cxx
1458e3
+++ b/sw/source/filter/html/htmltabw.cxx
1458e3
@@ -424,11 +424,14 @@ void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt,
1458e3
             // Avoid non-CSS version in the ReqIF case.
1458e3
             rWrt.OutBackground( pBrushItem, false );
1458e3
 
1458e3
-        if( rWrt.m_bCfgOutStyles )
1458e3
-            OutCSS1_TableBGStyleOpt( rWrt, *pBrushItem );
1458e3
+        if (!rWrt.m_bCfgOutStyles)
1458e3
+            pBrushItem = nullptr;
1458e3
     }
1458e3
 
1458e3
-    rWrt.OutCSS1_TableCellBorderHack(*pBox->GetFrameFormat());
1458e3
+    // tdf#132739 with rWrt.m_bCfgOutStyles of true bundle the brush item css
1458e3
+    // properties into the same "style" tag as the borders so there is only one
1458e3
+    // style tag
1458e3
+    rWrt.OutCSS1_TableCellBordersAndBG(*pBox->GetFrameFormat(), pBrushItem);
1458e3
 
1458e3
     sal_uInt32 nNumFormat = 0;
1458e3
     double nValue = 0.0;
1458e3
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
1458e3
index ab282ba652ff..f82325ee50ae 100644
1458e3
--- a/sw/source/filter/html/wrthtml.hxx
1458e3
+++ b/sw/source/filter/html/wrthtml.hxx
1458e3
@@ -484,7 +484,7 @@ public:
1458e3
     void writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameFormat& rFrameFormat, const OUString& rAltText, HtmlFrmOpts nFrameOpts);
1458e3
 
1458e3
     void OutCSS1_TableFrameFormatOptions( const SwFrameFormat& rFrameFormat );
1458e3
-    void OutCSS1_TableCellBorderHack(const SwFrameFormat& rFrameFormat);
1458e3
+    void OutCSS1_TableCellBordersAndBG(const SwFrameFormat& rFrameFormat, const SvxBrushItem *pBrushItem);
1458e3
     void OutCSS1_SectionFormatOptions( const SwFrameFormat& rFrameFormat, const SwFormatCol *pCol );
1458e3
     void OutCSS1_FrameFormatOptions( const SwFrameFormat& rFrameFormat, HtmlFrmOpts nFrameOpts,
1458e3
                                      const SdrObject *pSdrObj=nullptr,
1458e3
-- 
1458e3
2.31.1
1458e3