From ebceee31d92f04b58e795d02a26f62b717c47737 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 1 Mar 2021 10:37:49 +0100 Subject: tdf#140342 sw layout: remove explicit gutter handling when positioning borders Word has two modes the specify border positions: the distance can be measured from the edge of the page or from text. Similar to how documents that have page borders but no gutter, page page border + gutter documents should be always measured "from text" by the layout. "From page" should be a concern for Word filters. "From page" was already working -- fix "from text" by changing the layout to do "from text" and then extending DOCX import/export to handle gutter while handling the "from page" page borders. This also requires allowing nominally negative top margins, because we want to have the gutter unchanged, but the border might want to be on the gutter area, which is only possible with a negative top margin. Change-Id: I7f2c9943357359e76cb554cb2a65b93a492e694b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111735 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- sw/source/filter/ww8/docxattributeoutput.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sw/source/filter/ww8/docxattributeoutput.cxx') diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index b5a793ec196f..67d6aa748df4 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -6743,6 +6743,15 @@ void DocxAttributeOutput::SectionPageBorders( const SwFrameFormat* pFormat, cons if (aGlue.HasFooter()) aMargins.nBottom = aGlue.dyaHdrBottom; + if (pFormat->GetDoc()->getIDocumentSettingAccess().get(DocumentSettingId::GUTTER_AT_TOP)) + { + aMargins.nTop += pFormat->GetLRSpace().GetGutterMargin(); + } + else + { + aMargins.nLeft += pFormat->GetLRSpace().GetGutterMargin(); + } + aOutputBorderOptions.pDistances = std::make_shared(); editeng::BorderDistancesToWord(rBox, aMargins, *aOutputBorderOptions.pDistances); -- cgit