sw/inc/IDocumentSettingAccess.hxx | 1 + sw/qa/core/layout/data/tdf128195.docx |binary sw/qa/core/layout/layout.cxx | 11 +++++++++++ sw/source/core/doc/DocumentSettingManager.cxx | 8 +++++++- sw/source/core/inc/DocumentSettingManager.hxx | 1 + sw/source/core/layout/flowfrm.cxx | 4 ++++ sw/source/filter/ww8/ww8par.cxx | 3 +++ sw/source/uibase/uno/SwXDocumentSettings.cxx | 19 +++++++++++++++++++ writerfilter/source/dmapper/DomainMapper.cxx | 2 ++ 9 files changed, 48 insertions(+), 1 deletion(-)
New commits: commit d0f8e4693120f9c7e7d4ec83cd6ad5d9af349587 Author: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> AuthorDate: Wed May 20 08:41:46 2020 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Jun 15 17:26:50 2020 +0200 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 (cherry picked from commit 9b5805d1ef2b9e9c4e8f389c069807bf4489ea95) Conflicts: sw/inc/IDocumentSettingAccess.hxx sw/source/core/doc/DocumentSettingManager.cxx sw/source/core/inc/DocumentSettingManager.hxx sw/source/core/layout/flowfrm.cxx sw/source/filter/ww8/ww8par.cxx sw/source/uibase/uno/SwXDocumentSettings.cxx writerfilter/source/dmapper/DomainMapper.cxx Change-Id: I259511183a8252e04d9951357dbdd4f4832523ec 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 Binary files /dev/null and b/sw/qa/core/layout/data/tdf128195.docx differ diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx index 4c16a3bbcd97..04b6cd0be900 100644 --- a/sw/qa/core/layout/layout.cxx +++ b/sw/qa/core/layout/layout.cxx @@ -43,6 +43,17 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTableFlyOverlap) CPPUNIT_ASSERT_GREATEREQUAL(nFlyBottom, nTableTop); } +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(); + sal_Int32 nTxtBottom = parseDump("//header/txt[2]/infos/bounds", "bottom").toInt32(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2269), nTxtHeight); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3529), nTxtBottom); +} + CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testBorderCollapseCompat) { // Load a document with a border conflict: top cell has a dotted bottom border, bottom cell has diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx index 0d2a8fb99808..3d31102f602d 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,7 @@ 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 +454,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"); } @@ -595,6 +600,7 @@ void sw::DocumentSettingManager::ReplaceCompatibilityOptions(const DocumentSetti mbSubtractFlys = rSource.mbSubtractFlys; mbMsWordCompTrailingBlanks = rSource.mbMsWordCompTrailingBlanks; mbEmptyDbFieldHidesPara = rSource.mbEmptyDbFieldHidesPara; + mbHeaderSpacingBelowLastPara = rSource.mbHeaderSpacingBelowLastPara; } sal_uInt32 sw::DocumentSettingManager::Getn32DummyCompatibilityOptions1() const 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 b0ea96fc7f51..89b45849fe69 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 8ef88ab320bb..f142ba7aa361 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)); m_pImpl->SetDocumentSettingsProperty("TabAtLeftIndentForParagraphsInList", uno::makeAny(true)); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits