summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-05-20 08:41:46 +0200
committerGabor Kelemen <kelemen.gabor2@nisz.hu>2020-09-13 10:40:17 +0200
commit956e9ea5020896bf6137e77740d14bedcca592a6 (patch)
tree374336f8c0ca8c8b20882054cf7fdb4760dfafcc
parent0e37f38af0fb5a6005a394009183fe4d5ec7ef39 (diff)
tdf#128195 Keep spacing below last paragraph in header (docx)
Add a layout compat option to keep the spacing below the last paragraph in the header in doc/docx files Change-Id: I259511183a8252e04d9951357dbdd4f4832523ec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94577 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> (cherry picked from commit 9b5805d1ef2b9e9c4e8f389c069807bf4489ea95) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96337 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> (cherry picked from commit 21e319ffba1e9357914e343bda793f65b4129155) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102555 Tested-by: Gabor Kelemen <kelemen.gabor2@nisz.hu> Reviewed-by: Gabor Kelemen <kelemen.gabor2@nisz.hu>
-rw-r--r--sw/CppunitTest_sw_core_layout.mk73
-rw-r--r--sw/Module_sw.mk1
-rw-r--r--sw/inc/IDocumentSettingAccess.hxx1
-rw-r--r--sw/qa/core/layout/data/tdf128195.docxbin0 -> 14883 bytes
-rw-r--r--sw/qa/core/layout/layout.cxx34
-rw-r--r--sw/source/core/doc/DocumentSettingManager.cxx10
-rw-r--r--sw/source/core/inc/DocumentSettingManager.hxx1
-rw-r--r--sw/source/core/layout/flowfrm.cxx4
-rw-r--r--sw/source/filter/ww8/ww8par.cxx3
-rw-r--r--sw/source/uibase/uno/SwXDocumentSettings.cxx19
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx2
11 files changed, 147 insertions, 1 deletions
diff --git a/sw/CppunitTest_sw_core_layout.mk b/sw/CppunitTest_sw_core_layout.mk
new file mode 100644
index 000000000000..19ebdc10df9b
--- /dev/null
+++ b/sw/CppunitTest_sw_core_layout.mk
@@ -0,0 +1,73 @@
+# -*- 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_core_layout))
+
+$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_core_layout))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_core_layout, \
+ sw/qa/core/layout/layout \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sw_core_layout, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ sal \
+ sfx \
+ sw \
+ test \
+ unotest \
+ utl \
+ vcl \
+ svt \
+ tl \
+ svl \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sw_core_layout,\
+ boost_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_core_layout,\
+ -I$(SRCDIR)/sw/inc \
+ -I$(SRCDIR)/sw/source/core/inc \
+ -I$(SRCDIR)/sw/source/uibase/inc \
+ -I$(SRCDIR)/sw/qa/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sw_core_layout,\
+ udkapi \
+ offapi \
+ oovbaapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sw_core_layout))
+$(eval $(call gb_CppunitTest_use_vcl,sw_core_layout))
+
+$(eval $(call gb_CppunitTest_use_rdb,sw_core_layout,services))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,sw_core_layout,\
+ officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sw_core_layout))
+
+$(eval $(call gb_CppunitTest_use_uiconfigs,sw_core_layout, \
+ modules/swriter \
+))
+
+$(eval $(call gb_CppunitTest_use_more_fonts,sw_core_layout))
+
+# vim: set noet sw=4 ts=4:
+
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index dc4f303d7a3b..ae5459d8bf89 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -110,6 +110,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
CppunitTest_sw_core_frmedt \
CppunitTest_sw_core_txtnode \
CppunitTest_sw_core_objectpositioning \
+ CppunitTest_sw_core_layout \
))
ifneq ($(DISABLE_GUI),TRUE)
diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
index 56ff3ab04234..f182027ded95 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -103,6 +103,7 @@ enum class DocumentSettingId
EMBED_SYSTEM_FONTS,
APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING,
CONTINUOUS_ENDNOTES,
+ HEADER_SPACING_BELOW_LAST_PARA,
};
/** Provides access to settings of a document
diff --git a/sw/qa/core/layout/data/tdf128195.docx b/sw/qa/core/layout/data/tdf128195.docx
new file mode 100644
index 000000000000..16180654ce8d
--- /dev/null
+++ b/sw/qa/core/layout/data/tdf128195.docx
Binary files differ
diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx
new file mode 100644
index 000000000000..02a1a70ac04c
--- /dev/null
+++ b/sw/qa/core/layout/layout.cxx
@@ -0,0 +1,34 @@
+/* -*- 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 <vcl/gdimtf.hxx>
+
+#include <wrtsh.hxx>
+
+static char const DATA_DIRECTORY[] = "/sw/qa/core/layout/data/";
+
+/// Covers sw/source/core/layout/ fixes.
+class SwCoreLayoutTest : public SwModelTestBase
+{
+};
+
+CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTdf128195)
+{
+ // Load a document that has two paragraphs in the header.
+ // The second paragraph should have its bottom spacing applied.
+ load(DATA_DIRECTORY, "tdf128195.docx");
+ sal_Int32 nTxtHeight = parseDump("//header/txt[2]/infos/bounds", "height").toInt32();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2269), nTxtHeight);
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx
index fe13a6b569f6..c6293837d1f3 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -91,7 +91,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc)
mbSubtractFlys(false),
mApplyParagraphMarkFormatToNumbering(false),
mbLastBrowseMode( false ),
- mbDisableOffPagePositioning ( false )
+ mbDisableOffPagePositioning ( false ),
+ mbHeaderSpacingBelowLastPara(false)
// COMPATIBILITY FLAGS END
{
@@ -217,6 +218,8 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const
case DocumentSettingId::EMPTY_DB_FIELD_HIDES_PARA: return mbEmptyDbFieldHidesPara;
case DocumentSettingId::CONTINUOUS_ENDNOTES:
return mbContinuousEndnotes;
+ case DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA:
+ return mbHeaderSpacingBelowLastPara;
default:
OSL_FAIL("Invalid setting id");
}
@@ -452,6 +455,9 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo
case DocumentSettingId::CONTINUOUS_ENDNOTES:
mbContinuousEndnotes = value;
break;
+ case DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA:
+ mbHeaderSpacingBelowLastPara = value;
+ break;
default:
OSL_FAIL("Invalid setting id");
}
@@ -594,6 +600,7 @@ void sw::DocumentSettingManager::ReplaceCompatibilityOptions(const DocumentSetti
mbTabAtLeftIndentForParagraphsInList = rSource.mbTabAtLeftIndentForParagraphsInList;
mbMsWordCompTrailingBlanks = rSource.mbMsWordCompTrailingBlanks;
mbEmptyDbFieldHidesPara = rSource.mbEmptyDbFieldHidesPara;
+ mbHeaderSpacingBelowLastPara = rSource.mbHeaderSpacingBelowLastPara;
}
sal_uInt32 sw::DocumentSettingManager::Getn32DummyCompatibilityOptions1() const
@@ -615,4 +622,5 @@ void sw::DocumentSettingManager::Setn32DummyCompatibilityOptions2( const sal_uIn
{
mn32DummyCompatibilityOptions2 = CompatibilityOptions2;
}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx
index 1cfe2978ab3b..fe87b339307c 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -161,6 +161,7 @@ class DocumentSettingManager :
bool mbDisableOffPagePositioning; // tdf#112443
bool mbEmptyDbFieldHidesPara;
bool mbContinuousEndnotes = false;
+ bool mbHeaderSpacingBelowLastPara;
public:
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index 1b8997cd6c2b..466e0e1855bc 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -1696,6 +1696,10 @@ SwTwips SwFlowFrame::CalcLowerSpace( const SwBorderAttrs* _pAttrs ) const
nLowerSpace += CalcAddLowerSpaceAsLastInTableCell( _pAttrs );
}
+ // tdf#128195 Consider para spacing below last paragraph in header
+ if (!m_rThis.IsInFly() && m_rThis.FindFooterOrHeader() && !GetFollow() && !m_rThis.GetIndNext())
+ nLowerSpace += _pAttrs->GetULSpace().GetLower() + _pAttrs->CalcLineSpacing();
+
return nLowerSpace;
}
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 5839bf219039..f476d156a323 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1837,6 +1837,9 @@ void SwWW8ImplReader::ImportDop()
// tdf#117923
m_rDoc.getIDocumentSettingAccess().set(
DocumentSettingId::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, true);
+ // tdf#128195
+ m_rDoc.getIDocumentSettingAccess().set(
+ DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA, true);
// Import Default Tabs
long nDefTabSiz = m_xWDop->dxaTab;
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index 93dc022cd9be..9887cdc11dc8 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -144,6 +144,7 @@ enum SwDocumentSettingsPropertyHandles
HANDLE_DISABLE_OFF_PAGE_POSITIONING,
HANDLE_EMPTY_DB_FIELD_HIDES_PARA,
HANDLE_CONTINUOUS_ENDNOTES,
+ HANDLE_HEADER_SPACING_BELOW_LAST_PARA,
};
static MasterPropertySetInfo * lcl_createSettingsInfo()
@@ -229,6 +230,8 @@ static MasterPropertySetInfo * lcl_createSettingsInfo()
{ OUString("DisableOffPagePositioning"), HANDLE_DISABLE_OFF_PAGE_POSITIONING, cppu::UnoType<bool>::get(), 0},
{ OUString("EmptyDbFieldHidesPara"), HANDLE_EMPTY_DB_FIELD_HIDES_PARA, cppu::UnoType<bool>::get(), 0 },
{ OUString("ContinuousEndnotes"), HANDLE_CONTINUOUS_ENDNOTES, cppu::UnoType<bool>::get(), 0 },
+ { OUString("HeaderSpacingBelowLastPara"), HANDLE_HEADER_SPACING_BELOW_LAST_PARA, cppu::UnoType<bool>::get(), 0 },
+
/*
* As OS said, we don't have a view when we need to set this, so I have to
* find another solution before adding them to this property set - MTG
@@ -937,6 +940,16 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
}
}
break;
+ case HANDLE_HEADER_SPACING_BELOW_LAST_PARA:
+ {
+ bool bTmp;
+ if (rValue >>= bTmp)
+ {
+ mpDoc->getIDocumentSettingAccess().set(
+ DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA, bTmp);
+ }
+ }
+ break;
default:
throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
}
@@ -1399,6 +1412,12 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf
<<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::CONTINUOUS_ENDNOTES);
}
break;
+ case HANDLE_HEADER_SPACING_BELOW_LAST_PARA:
+ {
+ rValue <<= mpDoc->getIDocumentSettingAccess().get(
+ DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA);
+ }
+ break;
default:
throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
}
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 50c5704a032a..91d69d40cc33 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -125,6 +125,8 @@ DomainMapper::DomainMapper( const uno::Reference< uno::XComponentContext >& xCon
// Don't load the default style definitions to avoid weird mix
m_pImpl->SetDocumentSettingsProperty("StylesNoDefault", uno::makeAny(true));
+ m_pImpl->SetDocumentSettingsProperty("HeaderSpacingBelowLastPara",
+ uno::makeAny(true));
// Initialize RDF metadata, to be able to add statements during the import.
try