summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-04-05 18:04:25 +0200
committerMichael Stahl <Michael.Stahl@cib.de>2018-04-11 18:48:09 +0200
commitc8357e261be6715dd6c23219778362126d4a9844 (patch)
tree5ccc3a95b9236e86cf0b549bae1fdb62137e50b4
parenta3925ee114d551567a106161d9e747318ab60c6f (diff)
tdf#116830 sw: handle cell background for BACKGROUND_PARA_OVER_DRAWINGS
Commit 18b3feb8bef06bf7b126fd0bc743e19479cb8026 (n#778133 sw: add BackgroundParaOverDrawings compat flag, 2012-09-12) added a layout compat flag that is meant to make Writer behave the same as Word when it comes to the order of various backgrounds. The original fix was that in case there are background shapes and also paragraph backgrounds, then this flag can opt in to have the paragraph backgrounds on top of background shapes. Cell backgrounds behave the same way in Word, so extend the behavior of the compat flag to cover not only the background of text frames but also of cell frames. (The test could be hacked into CppunitTest_sw_uiwriter, but 1) this is layout, not UI and 2) that one started to get rather large.) (cherry picked from commit 09954c381895f340c9b73af64b0833d8b4689c06) Change-Id: Ifca1851217000f6daac50e6c9562c042aca6ff7d Reviewed-on: https://gerrit.libreoffice.org/52668 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
-rw-r--r--sw/CppunitTest_sw_layoutwriter.mk72
-rw-r--r--sw/Module_sw.mk1
-rw-r--r--sw/qa/extras/layout/data/tdf116830.odtbin0 -> 8963 bytes
-rw-r--r--sw/qa/extras/layout/layout.cxx68
-rw-r--r--sw/source/core/layout/paintfrm.cxx4
5 files changed, 144 insertions, 1 deletions
diff --git a/sw/CppunitTest_sw_layoutwriter.mk b/sw/CppunitTest_sw_layoutwriter.mk
new file mode 100644
index 000000000000..675299180e44
--- /dev/null
+++ b/sw/CppunitTest_sw_layoutwriter.mk
@@ -0,0 +1,72 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sw_layoutwriter))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_layoutwriter, \
+ sw/qa/extras/layout/layout \
+))
+
+# note: this links msword only for the reason to have a order dependency,
+# because "make sw.check" will not see the dependency through services.rdb
+$(eval $(call gb_CppunitTest_use_libraries,sw_layoutwriter, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ editeng \
+ msword \
+ sal \
+ sfx \
+ svl \
+ svt \
+ svxcore \
+ sw \
+ test \
+ unotest \
+ vcl \
+ tl \
+ utl \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sw_layoutwriter,\
+ boost_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_layoutwriter,\
+ -I$(SRCDIR)/sw/inc \
+ -I$(SRCDIR)/sw/source/core/inc \
+ -I$(SRCDIR)/sw/qa/extras/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sw_layoutwriter))
+
+$(eval $(call gb_CppunitTest_use_ure,sw_layoutwriter))
+$(eval $(call gb_CppunitTest_use_vcl,sw_layoutwriter))
+
+$(eval $(call gb_CppunitTest_use_rdb,sw_layoutwriter,services))
+
+$(eval $(call gb_CppunitTest_use_configuration,sw_layoutwriter))
+
+$(eval $(call gb_CppunitTest_use_uiconfigs,sw_layoutwriter, \
+ modules/swriter \
+))
+
+$(call gb_CppunitTest_get_target,sw_layoutwriter): \
+ $(call gb_Library_get_target,textconv_dict)
+
+ifneq ($(filter MORE_FONTS,$(BUILD_TYPE)),)
+$(call gb_CppunitTest_get_target,sw_layoutwriter): \
+ $(call gb_ExternalPackage_get_target,fonts_liberation)
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 966c71d097fd..6574a70ae1b8 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -83,6 +83,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
CppunitTest_sw_odfimport \
CppunitTest_sw_txtexport \
CppunitTest_sw_uiwriter \
+ CppunitTest_sw_layoutwriter \
CppunitTest_sw_mailmerge \
CppunitTest_sw_globalfilter \
))
diff --git a/sw/qa/extras/layout/data/tdf116830.odt b/sw/qa/extras/layout/data/tdf116830.odt
new file mode 100644
index 000000000000..8faacc3ddaec
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf116830.odt
Binary files differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
new file mode 100644
index 000000000000..16efa14c5875
--- /dev/null
+++ b/sw/qa/extras/layout/layout.cxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <swmodeltestbase.hxx>
+#include <test/mtfxmldump.hxx>
+
+static char const DATA_DIRECTORY[] = "/sw/qa/extras/layout/data/";
+
+/// Test to assert layout / rendering result of Writer.
+class SwLayoutWriter : public SwModelTestBase
+{
+public:
+ void testTdf116830();
+
+ CPPUNIT_TEST_SUITE(SwLayoutWriter);
+ CPPUNIT_TEST(testTdf116830);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ SwDoc* createDoc(const char* pName = nullptr);
+};
+
+SwDoc* SwLayoutWriter::createDoc(const char* pName)
+{
+ load(DATA_DIRECTORY, pName);
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ return pTextDoc->GetDocShell()->GetDoc();
+}
+
+void SwLayoutWriter::testTdf116830()
+{
+ SwDoc* pDoc = createDoc("tdf116830.odt");
+ SwDocShell* pShell = pDoc->GetDocShell();
+
+ // Dump the rendering of the first page as an XML file.
+ std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
+ MetafileXmlDump dumper;
+ xmlDocPtr pXmlDoc = dumper.dumpAndParse(*xMetaFile);
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ // Assert that the yellow rectangle (cell background) is painted after the
+ // polypolygon (background shape).
+ // Background shape: 1.1.1.2
+ // Cell background: 1.1.1.3
+ assertXPath(
+ pXmlDoc,
+ "/metafile/push[1]/push[1]/push[1]/push[2]/push[1]/push[1]/fillcolor[@color='#729fcf']", 1);
+ assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[2]/push[1]/push[1]/polypolygon",
+ 1);
+
+ // This failed: cell background was painted before the background shape.
+ assertXPath(pXmlDoc,
+ "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/fillcolor[@color='#ffff00']", 1);
+ assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/rect", 1);
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutWriter);
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 9ace67161ffc..80d12a53f873 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -6412,7 +6412,9 @@ void SwFrame::PaintBackground( const SwRect &rRect, const SwPageFrame *pPage,
if( IsTextFrame() || IsSctFrame() )
aPaintRect = UnionFrame( true );
- if ( (!bOnlyTextBackground || IsTextFrame()) && aPaintRect.IsOver( rRect ) )
+ // bOnlyTextBackground means background that's on top of background shapes,
+ // this includes both text and cell frames.
+ if ( (!bOnlyTextBackground || IsTextFrame() || IsCellFrame()) && aPaintRect.IsOver( rRect ) )
{
if ( bBack || bPageFrame || !bLowerMode )
{