[Libreoffice-commits] core.git: sw/qa sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Mar 12 21:37:03 UTC 2019
sw/qa/extras/htmlexport/data/field-shade.odt |binary
sw/qa/extras/htmlexport/htmlexport.cxx | 6 ++++++
sw/source/filter/html/htmlatr.cxx | 2 ++
sw/source/filter/html/htmlfldw.cxx | 13 +++++++++++--
sw/source/filter/html/wrthtml.hxx | 4 ++++
5 files changed, 23 insertions(+), 2 deletions(-)
New commits:
commit ce01727e4d6779ea128aa1be09f4af8cad4e1854
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Mar 12 18:43:43 2019 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Mar 12 22:36:34 2019 +0100
sw HTML export, field shadings: give text portion background priority
If the user explicitly gives a background color to the field portion,
then respect that, don't overwrite with the field shading (the UI does
the same).
Change-Id: I7c35618f82a37ef1dd16c03b82651268767813af
Reviewed-on: https://gerrit.libreoffice.org/69127
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
diff --git a/sw/qa/extras/htmlexport/data/field-shade.odt b/sw/qa/extras/htmlexport/data/field-shade.odt
index 38debcb48d0b..2533be68c49e 100644
Binary files a/sw/qa/extras/htmlexport/data/field-shade.odt and b/sw/qa/extras/htmlexport/data/field-shade.odt differ
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 170213e16699..1f016f52409a 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -678,6 +678,12 @@ DECLARE_HTMLEXPORT_TEST(testFieldShade, "field-shade.odt")
// Without the accompanying fix in place, this test would have failed with 'Expected: 1; Actual:
// 0', i.e. shading for the field was lost.
assertXPath(pDoc, "/html/body/p[1]/span", "style", "background: #c0c0c0");
+
+ // Check that field shading is written only in case there is no user-defined span background.
+ assertXPath(pDoc, "/html/body/p[2]/span", "style", "background: #ff0000");
+ // Without the accompanying fix in place, this test would have failed with 'Expected: 0; Actual:
+ // 1', i.e there was an inner span hiding the wanted background color.
+ assertXPath(pDoc, "/html/body/p[2]/span/span", 0);
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index 50a7562cb858..d73f91572513 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -1931,6 +1931,7 @@ void HTMLEndPosLst::OutStartAttrs( SwHTMLWriter& rHWrt, sal_Int32 nPos,
pContext = nullptr; // one time only
}
Out( aHTMLAttrFnTab, *pPos->GetItem(), rHWrt );
+ rHWrt.maStartedAttributes[pPos->GetItem()->Which()]++;
rHWrt.m_nCSS1Script = nCSS1Script;
}
}
@@ -1981,6 +1982,7 @@ void HTMLEndPosLst::OutEndAttrs( SwHTMLWriter& rHWrt, sal_Int32 nPos,
if( !bSkipOut )
{
Out( aHTMLAttrFnTab, *pPos->GetItem(), rHWrt );
+ rHWrt.maStartedAttributes[pPos->GetItem()->Which()]--;
}
RemoveItem_( i );
}
diff --git a/sw/source/filter/html/htmlfldw.cxx b/sw/source/filter/html/htmlfldw.cxx
index e70e856bae81..0ad1b55d5db7 100644
--- a/sw/source/filter/html/htmlfldw.cxx
+++ b/sw/source/filter/html/htmlfldw.cxx
@@ -539,7 +539,16 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
if( pTextField )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
- if (SwViewOption::IsFieldShadings())
+ bool bFieldShadings = SwViewOption::IsFieldShadings();
+ if (bFieldShadings)
+ {
+ // If there is a text portion background started already, that should have priority.
+ auto it = rHTMLWrt.maStartedAttributes.find(RES_CHRATR_BACKGROUND);
+ if (it != rHTMLWrt.maStartedAttributes.end())
+ bFieldShadings = it->second <= 0;
+ }
+
+ if (bFieldShadings)
{
OStringBuffer sOut;
sOut.append("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span);
@@ -556,7 +565,7 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
OutHTML_SwField( rWrt, pField, pTextField->GetTextNode(),
pTextField->GetStart() );
- if (SwViewOption::IsFieldShadings())
+ if (bFieldShadings)
HTMLOutFuncs::Out_AsciiTag(
rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span, false);
}
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index 9c96d8680232..b92b95f70e27 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -22,6 +22,7 @@
#include <memory>
#include <vector>
#include <set>
+#include <map>
#include <com/sun/star/container/XIndexContainer.hpp>
#include <com/sun/star/form/XForm.hpp>
@@ -398,6 +399,9 @@ public:
bool m_bParaDotLeaders : 1; // for TOC dot leaders
// 25
+ /// Tracks which text portion attributes are currently open: a which id -> open count map.
+ std::map<sal_uInt16, int> maStartedAttributes;
+
explicit SwHTMLWriter( const OUString& rBaseURL );
virtual ~SwHTMLWriter() override;
More information about the Libreoffice-commits
mailing list