summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-03-31 08:03:43 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-03-31 09:53:16 +0200
commitc088d26578d1be352efa49bd164a8217627648de (patch)
tree636da07fe60a990968a94f7ad0c69936a0e260d7
parenta182e9ce5e0da3cc98603ed27819405812d7fab1 (diff)
tdf#140343 sw page rtl gutter margin: add layout
We used to get the gutter margin on the left side and the right gutter margin on the right side, which works for normal and mirrored layout. Swap these two in RTL mode. Change-Id: Ibe866c2d971ce72e94fab5d5c71040ab62ffbe93 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113395 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
-rw-r--r--sw/qa/core/layout/layout.cxx25
-rw-r--r--sw/source/core/layout/frmtool.cxx8
2 files changed, 31 insertions, 2 deletions
diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx
index 7c37eec7fc7a..794752206035 100644
--- a/sw/qa/core/layout/layout.cxx
+++ b/sw/qa/core/layout/layout.cxx
@@ -357,6 +357,31 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testGutterMirrorMargin)
CPPUNIT_ASSERT_EQUAL(nGutterTwips, nOldRight - nNewRight);
}
+CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testRtlGutterMargin)
+{
+ // Given a document with a right margin:
+ SwDoc* pDoc = createSwDoc();
+ uno::Reference<beans::XPropertySet> xStandard(getStyles("PageStyles")->getByName("Standard"),
+ uno::UNO_QUERY);
+ SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+ SwFrame* pPage = pLayout->GetLower();
+ tools::Long nOldRight = pPage->getFramePrintArea().Right();
+
+ // When setting enable RTL gutter mode and setting a gutter margin:
+ xStandard->setPropertyValue("RtlGutter", uno::makeAny(true));
+ sal_Int32 nGutterMm100 = 2000;
+ xStandard->setPropertyValue("GutterMargin", uno::makeAny(nGutterMm100));
+
+ // Then make sure the new right edge of the print area is decreased:
+ tools::Long nNewRight = pPage->getFramePrintArea().Right();
+ tools::Long nGutterTwips = convertMm100ToTwip(nGutterMm100);
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 1134
+ // - Actual : 0
+ // i.e. the gutter was missing on the right side.
+ CPPUNIT_ASSERT_EQUAL(nGutterTwips, nOldRight - nNewRight);
+}
+
CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testGutterMarginPageBorder)
{
// FIXME this is 3369 on macOS -- calculate this number dynamically?
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index e1c7eee5148e..7abc46270bfa 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -2271,9 +2271,11 @@ tools::Long SwBorderAttrs::CalcRight( const SwFrame* pCaller ) const
DocumentSettingId::GUTTER_AT_TOP);
if (!bGutterAtTop)
{
+ bool bRtlGutter = pPageFrame->GetAttrSet()->GetItem<SfxBoolItem>(RES_RTL_GUTTER)->GetValue();
+ tools::Long nGutterMargin = bRtlGutter ? m_rLR->GetGutterMargin() : m_rLR->GetRightGutterMargin();
// Decrease the print area: the right space is the sum of right and right gutter
// margins.
- nRight += m_rLR->GetRightGutterMargin();
+ nRight += nGutterMargin;
}
}
@@ -2349,8 +2351,10 @@ tools::Long SwBorderAttrs::CalcLeft( const SwFrame *pCaller ) const
DocumentSettingId::GUTTER_AT_TOP);
if (!bGutterAtTop)
{
+ bool bRtlGutter = pPageFrame->GetAttrSet()->GetItem<SfxBoolItem>(RES_RTL_GUTTER)->GetValue();
+ tools::Long nGutterMargin = bRtlGutter ? m_rLR->GetRightGutterMargin() : m_rLR->GetGutterMargin();
// Decrease the print area: the left space is the sum of left and gutter margins.
- nLeft += m_rLR->GetGutterMargin();
+ nLeft += nGutterMargin;
}
}