[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - sw/CppunitTest_sw_layoutwriter.mk sw/Module_sw.mk sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Apr 11 16:48:44 UTC 2018


 sw/CppunitTest_sw_layoutwriter.mk      |   72 +++++++++++++++++++++++++++++++++
 sw/Module_sw.mk                        |    1 
 sw/qa/extras/layout/data/tdf116830.odt |binary
 sw/qa/extras/layout/layout.cxx         |   68 +++++++++++++++++++++++++++++++
 sw/source/core/layout/paintfrm.cxx     |    4 +
 5 files changed, 144 insertions(+), 1 deletion(-)

New commits:
commit c8357e261be6715dd6c23219778362126d4a9844
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Apr 5 18:04:25 2018 +0200

    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 at libreoffice.org>
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>

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
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf116830.odt 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 )
         {


More information about the Libreoffice-commits mailing list