diff options
-rw-r--r-- | sw/qa/core/layout/data/para-border-in-cell-clip.docx | bin | 0 -> 12524 bytes | |||
-rw-r--r-- | sw/qa/core/layout/layout.cxx | 20 | ||||
-rw-r--r-- | sw/source/core/layout/paintfrm.cxx | 40 |
3 files changed, 57 insertions, 3 deletions
diff --git a/sw/qa/core/layout/data/para-border-in-cell-clip.docx b/sw/qa/core/layout/data/para-border-in-cell-clip.docx Binary files differnew file mode 100644 index 000000000000..7c516853648c --- /dev/null +++ b/sw/qa/core/layout/data/para-border-in-cell-clip.docx diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx index 4ed97597ffcc..a02e17fb8bde 100644 --- a/sw/qa/core/layout/layout.cxx +++ b/sw/qa/core/layout/layout.cxx @@ -674,6 +674,26 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testDoubleBorderHorizontal) CPPUNIT_ASSERT_GREATER(aBorderWidthVec[3], aBorderWidthVec[2]); } +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testParaBorderInCellClip) +{ + // Given a document which has outside-cell borders defined, which should not be visible: + SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "para-border-in-cell-clip.docx"); + SwDocShell* pShell = pDoc->GetDocShell(); + + // When rendering those borders: + std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); + + // Then make sure that we have clipping setup for both paragraphs inside the table cell: + MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 2 + // - Actual : 0 + // - XPath '//clipregion/polygon' number of nodes is incorrect + // i.e. there was no clipping applied, leading to unexpected left/right borders. + assertXPath(pXmlDoc, "//clipregion/polygon", 2); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 656646420dc5..1b2a7379b17f 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -118,6 +118,7 @@ #include <comphelper/lok.hxx> #include <svtools/optionsdrawinglayer.hxx> #include <vcl/GraphicLoader.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> using namespace ::editeng; using namespace ::com::sun::star; @@ -5357,6 +5358,25 @@ void SwFrame::PaintSwFrameShadowAndBorder( pBottomBorder = aAccess.Get()->GetBox().GetBottom(); } + bool bWordTableCell = false; + SwViewShell* pShell = getRootFrame()->GetCurrShell(); + if (pShell) + { + const IDocumentSettingAccess& rIDSA = pShell->GetDoc()->getIDocumentSettingAccess(); + bWordTableCell = rIDSA.get(DocumentSettingId::TABLE_ROW_KEEP); + } + bool bInWordTableCell = IsContentFrame() && GetUpper()->IsCellFrame() && bWordTableCell; + if (bInWordTableCell) + { + // Compat mode: don't paint bottom border if we know the bottom of the content was cut + // off. + auto pContentFrame = static_cast<const SwContentFrame*>(this); + if (pContentFrame->IsUndersized()) + { + pBottomBorder = nullptr; + } + } + if(nullptr != pLeftBorder || nullptr != pRightBorder || nullptr != pTopBorder || nullptr != pBottomBorder) { // now we have all SvxBorderLine(s) sorted out, create geometry @@ -5370,14 +5390,28 @@ void SwFrame::PaintSwFrameShadowAndBorder( const svx::frame::Style aStyleLeft(pLeftBorder, 1.0); drawinglayer::primitive2d::Primitive2DContainer aBorderLineTarget; - aBorderLineTarget.append( - drawinglayer::primitive2d::Primitive2DReference( + drawinglayer::primitive2d::Primitive2DReference aRetval( new drawinglayer::primitive2d::SwBorderRectanglePrimitive2D( aBorderTransform, aStyleTop, aStyleRight, aStyleBottom, - aStyleLeft))); + aStyleLeft)); + + if (bInWordTableCell) + { + // Compat mode: cut off the borders which are outside of our own area. + const SwRect& rClip = getFrameArea(); + basegfx::B2DRectangle aClip(rClip.Left(), rClip.Top(), rClip.Right(), + rClip.Bottom()); + const basegfx::B2DPolyPolygon aPolyPolygon( + basegfx::utils::createPolygonFromRect(aClip)); + const drawinglayer::primitive2d::Primitive2DReference xClipped( + new drawinglayer::primitive2d::MaskPrimitive2D(aPolyPolygon, { aRetval })); + aRetval = xClipped; + } + + aBorderLineTarget.append(aRetval); gProp.pBLines->AddBorderLines(std::move(aBorderLineTarget)); } } |