summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 91e04e86f3a1..cdc0b315b050 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -87,6 +87,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 )
{