diff options
author | Justin Luth <justin.luth@collabora.com> | 2018-09-04 09:38:42 +0300 |
---|---|---|
committer | Justin Luth <justin_luth@sil.org> | 2018-09-04 21:30:19 +0200 |
commit | efd316b6171b9e1827c5e34ddb12658f48268e24 (patch) | |
tree | 9acf9c2638fe01cb2c9ae3508b252d4a90b6365f | |
parent | aa978430637448effd2b94dbedd561c1c7a52f42 (diff) |
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 <justin_luth@sil.org>
-rw-r--r-- | sw/CppunitTest_sw_ww8export3.mk | 58 | ||||
-rw-r--r-- | sw/Module_sw.mk | 1 | ||||
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf94009_zeroPgMargin.odt | bin | 0 -> 11939 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export3.cxx | 43 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 2 |
5 files changed, 104 insertions, 0 deletions
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 Binary files differnew file mode 100644 index 000000000000..e3143ec049f5 --- /dev/null +++ b/sw/qa/extras/ww8export/data/tdf94009_zeroPgMargin.odt 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 <swmodeltestbase.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/text/XTextFramesSupplier.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XTextTablesSupplier.hpp> + +#include <drawdoc.hxx> + +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<beans::XPropertySet> defaultStyle(getStyles("PageStyles")->getByName("Standard"), + uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(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 ) ) ) ) { |