summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-05-20 08:41:46 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-06-15 16:57:12 +0200
commitfbd62e247fd588a595e44cec787fc8944f158777 (patch)
tree7279b1dccbb5a59d126da088f25e8a79660da452
parent7f314586cdaea97636699b05f94fbefcc05cc71f (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/+/96336
-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.cxx11
-rw-r--r--sw/source/core/doc/DocumentSettingManager.cxx13
-rw-r--r--sw/source/core/inc/DocumentSettingManager.hxx1
-rw-r--r--sw/source/core/layout/flowfrm.cxx5
-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
9 files changed, 53 insertions, 2 deletions
diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
index 5c7d3fe54253..00176843b32f 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -105,6 +105,7 @@ enum class DocumentSettingId
CONTINUOUS_ENDNOTES,
PROTECT_BOOKMARKS,
PROTECT_FIELDS,
+ 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
index 8a3a3b5369e6..cfc13640c471 100644
--- a/sw/qa/core/layout/layout.cxx
+++ b/sw/qa/core/layout/layout.cxx
@@ -39,6 +39,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 82b958a64d5a..f8d2af02f521 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -95,7 +95,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc)
mbLastBrowseMode( false ),
mbDisableOffPagePositioning ( false ),
mbProtectBookmarks(false),
- mbProtectFields(false)
+ mbProtectFields(false),
+ mbHeaderSpacingBelowLastPara(false)
// COMPATIBILITY FLAGS END
{
@@ -222,6 +223,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const
case DocumentSettingId::CONTINUOUS_ENDNOTES: return mbContinuousEndnotes;
case DocumentSettingId::PROTECT_BOOKMARKS: return mbProtectBookmarks;
case DocumentSettingId::PROTECT_FIELDS: return mbProtectFields;
+ case DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA: return mbHeaderSpacingBelowLastPara;
default:
OSL_FAIL("Invalid setting id");
}
@@ -463,6 +465,9 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo
case DocumentSettingId::PROTECT_FIELDS:
mbProtectFields = value;
break;
+ case DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA:
+ mbHeaderSpacingBelowLastPara = value;
+ break;
default:
OSL_FAIL("Invalid setting id");
}
@@ -634,6 +639,7 @@ void sw::DocumentSettingManager::ReplaceCompatibilityOptions(const DocumentSetti
mbContinuousEndnotes = rSource.mbContinuousEndnotes;
// No mbProtectBookmarks
// No mbProtectFields
+ mbHeaderSpacingBelowLastPara = rSource.mbHeaderSpacingBelowLastPara;
}
sal_uInt32 sw::DocumentSettingManager::Getn32DummyCompatibilityOptions1() const
@@ -924,6 +930,11 @@ void sw::DocumentSettingManager::dumpAsXml(xmlTextWriterPtr pWriter) const
BAD_CAST(OString::boolean(mbContinuousEndnotes).getStr()));
xmlTextWriterEndElement(pWriter);
+ xmlTextWriterStartElement(pWriter, BAD_CAST("mbHeaderSpacingBelowLastPara"));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
+ BAD_CAST(OString::boolean(mbHeaderSpacingBelowLastPara).getStr()));
+ xmlTextWriterEndElement(pWriter);
+
xmlTextWriterEndElement(pWriter);
}
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx
index 2ea1a2583e54..f2d8f34c8c50 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -164,6 +164,7 @@ class DocumentSettingManager :
bool mbContinuousEndnotes = false;
bool mbProtectBookmarks;
bool mbProtectFields;
+ bool mbHeaderSpacingBelowLastPara;
public:
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index e33cb736ce19..480d60571764 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -1388,7 +1388,6 @@ SwTwips SwFlowFrame::CalcUpperSpace( const SwBorderAttrs *pAttrs,
const SwFrame* pPr,
const bool _bConsiderGrid ) const
{
-
const SwFrame* pPrevFrame = GetPrevFrameForUpperSpaceCalc_( pPr );
std::unique_ptr<SwBorderAttrAccess> pAccess;
@@ -1692,6 +1691,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 e2e75a4d78ab..f58506ec5268 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1845,6 +1845,9 @@ void SwWW8ImplReader::ImportDop()
DocumentSettingId::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, true);
m_rDoc.getIDocumentSettingAccess().set(
DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS, 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 0cb9eaaa1d16..1e6de063f472 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -142,6 +142,7 @@ enum SwDocumentSettingsPropertyHandles
HANDLE_CONTINUOUS_ENDNOTES,
HANDLE_PROTECT_BOOKMARKS,
HANDLE_PROTECT_FIELDS,
+ HANDLE_HEADER_SPACING_BELOW_LAST_PARA,
};
}
@@ -231,6 +232,8 @@ static MasterPropertySetInfo * lcl_createSettingsInfo()
{ OUString("ContinuousEndnotes"), HANDLE_CONTINUOUS_ENDNOTES, cppu::UnoType<bool>::get(), 0 },
{ OUString("ProtectBookmarks"), HANDLE_PROTECT_BOOKMARKS, cppu::UnoType<bool>::get(), 0 },
{ OUString("ProtectFields"), HANDLE_PROTECT_FIELDS, 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
@@ -959,6 +962,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));
}
@@ -1433,6 +1446,12 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf
DocumentSettingId::PROTECT_FIELDS);
}
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 60e32fd8aa05..beccdfdafc76 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("MsWordCompTrailingBlanks", uno::makeAny(true));
+ m_pImpl->SetDocumentSettingsProperty("HeaderSpacingBelowLastPara",
+ uno::makeAny(true));
m_pImpl->SetDocumentSettingsProperty("TabAtLeftIndentForParagraphsInList", uno::makeAny(true));