From efd316b6171b9e1827c5e34ddb12658f48268e24 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Tue, 4 Sep 2018 09:38:42 +0300 Subject: tdf#94009 ww8export: always export section margins Since the internal SW defaults (0) don't match the import defaults, always write the top/bottom, left/right margins into the document definition. It is very rare indeed to have a zero margin anyway, since the page margin being zero is highly discouraged because of printing. The bug report is for DOCX, but it also affects DOC. I don't have an example where LRSpace is skipped, but it only makes sense to treat these two the same just in case. Change-Id: Ie9a08ad0dd4f73bc976756fe244fc33e2dc804f3 Reviewed-on: https://gerrit.libreoffice.org/59967 Tested-by: Jenkins Reviewed-by: Justin Luth --- sw/CppunitTest_sw_ww8export3.mk | 58 +++++++++++++++++++++ sw/Module_sw.mk | 1 + .../ww8export/data/tdf94009_zeroPgMargin.odt | Bin 0 -> 11939 bytes sw/qa/extras/ww8export/ww8export3.cxx | 43 +++++++++++++++ sw/source/filter/ww8/ww8atr.cxx | 2 + 5 files changed, 104 insertions(+) create mode 100644 sw/CppunitTest_sw_ww8export3.mk create mode 100644 sw/qa/extras/ww8export/data/tdf94009_zeroPgMargin.odt create mode 100644 sw/qa/extras/ww8export/ww8export3.cxx diff --git a/sw/CppunitTest_sw_ww8export3.mk b/sw/CppunitTest_sw_ww8export3.mk new file mode 100644 index 000000000000..564f344d7297 --- /dev/null +++ b/sw/CppunitTest_sw_ww8export3.mk @@ -0,0 +1,58 @@ +# -*- 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_ww8export3)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sw_ww8export3, \ + sw/qa/extras/ww8export/ww8export3 \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sw_ww8export3, \ + comphelper \ + cppu \ + cppuhelper \ + editeng \ + $(if $(filter WNT-TRUE,$(OS)-$(DISABLE_ATL)),,emboleobj) \ + sal \ + sfx \ + test \ + unotest \ + utl \ + sw \ + tl \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sw_ww8export3,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sw_ww8export3,\ + -I$(SRCDIR)/sw/inc \ + -I$(SRCDIR)/sw/source/core/inc \ + -I$(SRCDIR)/sw/qa/extras/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sw_ww8export3,\ + udkapi \ + offapi \ + oovbaapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sw_ww8export3)) +$(eval $(call gb_CppunitTest_use_vcl,sw_ww8export3)) + +$(eval $(call gb_CppunitTest_use_rdb,sw_ww8export3,services)) + +$(eval $(call gb_CppunitTest_use_configuration,sw_ww8export3)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index c3feaa8feb5b..cafeb93af03b 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -81,6 +81,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_ooxmlimport2 \ CppunitTest_sw_ww8export \ CppunitTest_sw_ww8export2 \ + CppunitTest_sw_ww8export3 \ CppunitTest_sw_ww8import \ CppunitTest_sw_rtfexport \ CppunitTest_sw_rtfexport2 \ diff --git a/sw/qa/extras/ww8export/data/tdf94009_zeroPgMargin.odt b/sw/qa/extras/ww8export/data/tdf94009_zeroPgMargin.odt new file mode 100644 index 000000000000..e3143ec049f5 Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf94009_zeroPgMargin.odt differ diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx new file mode 100644 index 000000000000..8adc21445a6d --- /dev/null +++ b/sw/qa/extras/ww8export/ww8export3.cxx @@ -0,0 +1,43 @@ +/* -*- 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 + +#include +#include +#include +#include +#include + +#include + +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase("/sw/qa/extras/ww8export/data/", "MS Word 97") + { + } + + bool mustTestImportOf(const char* filename) const override + { + // If the testcase is stored in some other format, it's pointless to test. + return OString(filename).endsWith(".doc"); + } +}; +DECLARE_WW8EXPORT_TEST(testTdf94009_zeroPgMargin, "tdf94009_zeroPgMargin.odt") +{ + uno::Reference defaultStyle(getStyles("PageStyles")->getByName("Standard"), + uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(defaultStyle, "TopMargin")); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 15ef3cae7c54..a86094fda676 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -5412,6 +5412,8 @@ void AttributeOutputBase::OutputStyleItemSet( const SfxItemSet& rSet, bool bTest { if ( SfxItemState::SET == pSet->GetItemState( nWhich, true/*bDeep*/, &pItem ) && ( !bTestForDefault || + nWhich == RES_UL_SPACE || + nWhich == RES_LR_SPACE || *pItem != rPool.GetDefaultItem( nWhich ) || ( pSet->GetParent() && *pItem != pSet->GetParent()->Get( nWhich ) ) ) ) { -- cgit v1.2.3