diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/core/layout/layout.cxx | 27 | ||||
-rw-r--r-- | sw/source/core/inc/frmtool.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/layout/frmtool.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/layout/paintfrm.cxx | 10 |
4 files changed, 44 insertions, 0 deletions
diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx index 04b6cd0be900..63fa7336d263 100644 --- a/sw/qa/core/layout/layout.cxx +++ b/sw/qa/core/layout/layout.cxx @@ -74,6 +74,33 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testBorderCollapseCompat) assertXPath(pXmlDoc, "//polyline[@style='solid']", "width", "20"); } +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testGutterMargin) +{ + // Create a document, remember the old left edge of the page print area (the rectangle that is + // inside margins). + loadURL("private:factory/swriter", nullptr); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + uno::Reference<beans::XPropertySet> xStandard(getStyles("PageStyles")->getByName("Standard"), + uno::UNO_QUERY); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + SwFrame* pPage = pLayout->GetLower(); + long nOldLeft = pPage->getFramePrintArea().Left(); + + // Set the gutter margin to 2cm. + sal_Int32 nGutterMm100 = 2000; + xStandard->setPropertyValue("GutterMargin", uno::makeAny(nGutterMm100)); + + // Verify that the new left edge is larger. + long nNewLeft = pPage->getFramePrintArea().Left(); + 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 not added to the left margin. + CPPUNIT_ASSERT_EQUAL(nGutterTwips, nNewLeft - nOldLeft); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index c8447d8dd0f1..23f905f611b3 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -373,6 +373,7 @@ public: const SwAttrSet &GetAttrSet() const { return m_rAttrSet; } const SvxULSpaceItem &GetULSpace() const { return m_rUL; } + const std::shared_ptr<SvxLRSpaceItem>& GetLRSpace() const { return m_rLR; } const SvxBoxItem &GetBox() const { return m_rBox; } const SvxShadowItem &GetShadow() const { return m_rShadow; } diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index a861dd60013b..0d106946cd2b 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -2306,6 +2306,12 @@ long SwBorderAttrs::CalcLeft( const SwFrame *pCaller ) const nLeft += static_cast<const SwTextFrame*>(pCaller)->GetTextNodeForParaProps()->GetLeftMarginWithNum(); } + if (pCaller->IsPageFrame() && m_rLR) + { + // Decrease the print area: the left space is the sum of left and gutter margins. + nLeft += m_rLR->GetGutterMargin(); + } + return nLeft; } diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index a53e7b249dba..da8731a400d1 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -1266,6 +1266,16 @@ static void lcl_CalcBorderRect( SwRect &rRect, const SwFrame *pFrame, SwRectFn fnRect = pFrame->IsVertical() ? ( pFrame->IsVertLR() ? (pFrame->IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori; + if (pFrame->IsPageFrame() && rAttrs.GetLRSpace()) + { + long nGutterMargin = rAttrs.GetLRSpace()->GetGutterMargin(); + if (nGutterMargin) + { + // Paint the left border based on the left margin, ignoring the gutter margin. + (rRect.*fnRect->fnSubLeft)(nGutterMargin); + } + } + const SvxBoxItem &rBox = rAttrs.GetBox(); const bool bTop = 0 != (pFrame->*fnRect->fnGetTopMargin)(); if ( bTop ) |