summaryrefslogtreecommitdiff
path: root/sw/qa/core/layout/layout.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/qa/core/layout/layout.cxx')
-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: */