summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-02-08 16:49:45 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-02-10 12:12:17 +0100
commit3010ee15889a52b23aef278300e29f06739882d6 (patch)
tree466e2b315afa1b8938a02328f16d2ace770074c4 /sw/qa
parent9dc25ec68f3342f257ac0b0a6ed2f7165473ed3d (diff)
tdf#91920 sw page gutter margin: handle mirrored margins
- SwPageDesc::Mirror: generate "right gutter margin" from gutter margin for mirrored pages, we just lost the gutter margin here previously - SwBorderAttrs::CalcRight: handle right gutter margin, so gutter increases the right margin, not the left margin on mirrored pages - lcl_CalcBorderRect: similar to left and top margins, compensate for right margin gutter as well, so borders are independent from the gutter margin (Word compat) (cherry picked from commit ffe7fd5c3f3de474b201fbb1e25b8251cb13574d) Conflicts: editeng/source/items/frmitems.cxx include/editeng/lrspitem.hxx sw/source/core/layout/paintfrm.cxx Change-Id: Ie4d3459ab6edcc60b20c2fed08dbf45060ca9828 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110692 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/core/layout/layout.cxx33
1 files changed, 33 insertions, 0 deletions
diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx
index 33642b84776d..b98360353dc5 100644
--- a/sw/qa/core/layout/layout.cxx
+++ b/sw/qa/core/layout/layout.cxx
@@ -9,6 +9,8 @@
#include <swmodeltestbase.hxx>
+#include <com/sun/star/style/PageStyleLayout.hpp>
+
#include <vcl/gdimtf.hxx>
#include <comphelper/classids.hxx>
#include <tools/globname.hxx>
@@ -132,6 +134,37 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testGutterTopMargin)
CPPUNIT_ASSERT_EQUAL(nGutterTwips, nNewTop - nOldTop);
}
+CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testGutterMirrorMargin)
+{
+ loadURL("private:factory/swriter", nullptr);
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+ SwDocShell* pDocShell = pDoc->GetDocShell();
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+ pWrtShell->InsertPageBreak();
+ SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+ SwFrame* pPage = pLayout->GetLower();
+ long nOldLeft = pPage->getFramePrintArea().Left();
+ SwFrame* pPage2 = pPage->GetNext();
+ long nOldRight = pPage2->getFramePrintArea().Right();
+
+ uno::Reference<beans::XPropertySet> xStandard(getStyles("PageStyles")->getByName("Standard"),
+ uno::UNO_QUERY);
+ xStandard->setPropertyValue("PageStyleLayout", uno::makeAny(style::PageStyleLayout_MIRRORED));
+ sal_Int32 nGutterMm100 = 2000;
+ xStandard->setPropertyValue("GutterMargin", uno::makeAny(nGutterMm100));
+
+ long nNewLeft = pPage->getFramePrintArea().Left();
+ long nGutterTwips = convertMm100ToTwip(nGutterMm100);
+ CPPUNIT_ASSERT_EQUAL(nGutterTwips, nNewLeft - nOldLeft);
+ long nNewRight = pPage2->getFramePrintArea().Right();
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 1134
+ // - Actual : 0
+ // i.e. the gutter was missing on the second, mirrored page.
+ CPPUNIT_ASSERT_EQUAL(nGutterTwips, nOldRight - nNewRight);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */