diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-04-05 18:04:25 +0200 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2018-05-02 16:46:20 +0200 |
commit | 9b893304850077d98be0b1ed7a9b280a06632e05 (patch) | |
tree | 4f40660b097a668e4d06447850dda01e57391627 | |
parent | 2a76476eed36dcdbfc0d4811eb43a685da99fe67 (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/52982
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
(cherry picked from commit 05ed69af14af8f138f69941c7c6186b39c742eb4)
Reviewed-on: https://gerrit.libreoffice.org/53653
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r-- | sw/CppunitTest_sw_layoutwriter.mk | 72 | ||||
-rw-r--r-- | sw/Module_sw.mk | 1 | ||||
-rw-r--r-- | sw/qa/extras/layout/data/tdf116830.odt | bin | 0 -> 8963 bytes | |||
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 68 | ||||
-rw-r--r-- | sw/source/core/layout/paintfrm.cxx | 4 |
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 0ab442fb3c7b..03d46c2799fa 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -76,6 +76,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 Binary files differnew file mode 100644 index 000000000000..8faacc3ddaec --- /dev/null +++ b/sw/qa/extras/layout/data/tdf116830.odt 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 61a818d415e1..4b8d38cdecdb 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -6557,7 +6557,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 ) { |