summaryrefslogtreecommitdiff
path: root/sw/source/core/layout/flowfrm.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2024-05-07 08:13:37 +0200
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-05-08 15:12:18 +0200
commit4fe480d314ceb100f4679626fee3d60dd82a6bc6 (patch)
tree247df7c1df10d78643d7115ac03ed7076fb91b9e /sw/source/core/layout/flowfrm.cxx
parent470f00694ac42fd07a55d6fbea5a56a28791fcc0 (diff)
tdf#160952 sw: ignore top margin of para on non-first pages with newer DOCX cp-24.04.2-1
The 2nd page of the bugdoc has a single paragraph, with a non-zero top margin. This is ignored in Word, but wasn't ignored in Writer. Experimenting with the document, it looks like old Word files also don't ignore this top margin: it started when the compat mode is upgraded (from binary DOC or Word 2010) to Word 2013 or newer. Also the top margin is only ignored for the first paragraph on the page, and only in case it's not on the first page. Fix the problem by introducing a new SwFrame::IsCollapseUpper() function to decide if the upper margin should be collapsed or not, and then by using it in SwFlowFrame::CalcUpperSpace() at one place where we read the top margin from the doc model. Take advantage of the fact that we have related, existing compat flags that tell us if we're in "Word >= 2013" compat mode: see e.g. GetFlyAnchorBottom(), which explains DocumentSettingId::TAB_OVER_MARGIN is a good indicator that this is a "Word <= 2010" document. Also, DocumentSettingId::TAB_OVER_SPACING is an indicator that this is a Word document, so we want the "TabOverSpacing && !TabOverMargin" case. This doesn't change all reads of the upper spacing of a text node, but is enough to avoid the unwanted top spacing, as demonstrated by the bugdoc. (cherry picked from commit 6200d89b905d51776ff4f3c8a84f338655ffaa7f) Change-Id: Ibdebdf5f0555256a0b6ed85d07079f14ef69a576 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167306 Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'sw/source/core/layout/flowfrm.cxx')
-rw-r--r--sw/source/core/layout/flowfrm.cxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index 88158161c530..37fd20b323d7 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -1658,6 +1658,11 @@ SwTwips SwFlowFrame::CalcUpperSpace( const SwBorderAttrs *pAttrs,
CastFlowFrame( pOwn )->HasParaSpaceAtPages( m_rThis.IsSctFrame() ) )
{
nUpper = pAttrs->GetULSpace().GetUpper();
+
+ if (m_rThis.IsCollapseUpper())
+ {
+ nUpper = 0;
+ }
}
}