diff options
-rwxr-xr-x | sw/qa/extras/layout/data/table-extrusion1.odt | bin | 0 -> 9234 bytes | |||
-rwxr-xr-x | sw/qa/extras/layout/data/table-extrusion2.odt | bin | 0 -> 9259 bytes | |||
-rwxr-xr-x[-rw-r--r--] | sw/qa/extras/layout/layout.cxx | 43 | ||||
-rw-r--r-- | sw/source/core/layout/paintfrm.cxx | 28 |
4 files changed, 53 insertions, 18 deletions
diff --git a/sw/qa/extras/layout/data/table-extrusion1.odt b/sw/qa/extras/layout/data/table-extrusion1.odt Binary files differnew file mode 100755 index 000000000000..10600fa54c86 --- /dev/null +++ b/sw/qa/extras/layout/data/table-extrusion1.odt diff --git a/sw/qa/extras/layout/data/table-extrusion2.odt b/sw/qa/extras/layout/data/table-extrusion2.odt Binary files differnew file mode 100755 index 000000000000..63fc74f46db8 --- /dev/null +++ b/sw/qa/extras/layout/data/table-extrusion2.odt diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index a7eb24e89208..2356832cc4ba 100644..100755 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -20,6 +20,8 @@ public: void testTdf116925(); void testTdf117028(); void testTdf106390(); + void testTableExtrusion1(); + void testTableExtrusion2(); void testTdf116848(); void testTdf117245(); @@ -28,6 +30,8 @@ public: CPPUNIT_TEST(testTdf116925); CPPUNIT_TEST(testTdf117028); CPPUNIT_TEST(testTdf106390); + CPPUNIT_TEST(testTableExtrusion1); + CPPUNIT_TEST(testTableExtrusion2); CPPUNIT_TEST(testTdf116848); CPPUNIT_TEST(testTdf117245); CPPUNIT_TEST_SUITE_END(); @@ -132,6 +136,45 @@ void SwLayoutWriter::testTdf106390() assertXPath(pXmlDoc, sXPath, 0); } +void SwLayoutWriter::testTableExtrusion1() +{ + SwDoc* pDoc = createDoc("table-extrusion1.odt"); + SwDocShell* pShell = pDoc->GetDocShell(); + + // Dump the rendering of the first page as an XML file. + std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); + MetafileXmlDump dumper; + xmlDocPtr pXmlDoc = dumper.dumpAndParse(*xMetaFile); + CPPUNIT_ASSERT(pXmlDoc); + sal_Int32 nRight = getXPath(pXmlDoc, "//sectrectclipregion", "right").toInt32(); + sal_Int32 nLeft = (nRight + getXPath(pXmlDoc, "(//rect)[1]", "right").toInt32()) / 2; + + // Expect table borders in right page margin. + const OString sXPath = "//polyline/point[@x>" + OString::number(nLeft) + " and @x<" + + OString::number(nRight) + "]"; + + assertXPath(pXmlDoc, sXPath, 4); +} + +void SwLayoutWriter::testTableExtrusion2() +{ + SwDoc* pDoc = createDoc("table-extrusion2.odt"); + SwDocShell* pShell = pDoc->GetDocShell(); + + // Dump the rendering of the first page as an XML file. + std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); + MetafileXmlDump dumper; + xmlDocPtr pXmlDoc = dumper.dumpAndParse(*xMetaFile); + CPPUNIT_ASSERT(pXmlDoc); + // End point position of the outer table. + sal_Int32 nX = getXPath(pXmlDoc, "(//polyline[1]/point)[2]", "x").toInt32(); + + // Do not allow inner table extrude outer table. + const OString sXPath = "//polyline/point[@x>" + OString::number(nX) + "]"; + + assertXPath(pXmlDoc, sXPath, 0); +} + void SwLayoutWriter::testTdf116848() { SwDoc* pDoc = createDoc("tdf116848.odt"); diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index cd76c222b040..b684c5ac1b2c 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -2308,8 +2308,8 @@ class SwTabFramePainter const SwTabFrame& mrTabFrame; void Insert( SwLineEntry&, bool bHori ); - void Insert( const SwFrame& rFrame, const SvxBoxItem& rBoxItem ); - void HandleFrame( const SwLayoutFrame& rFrame ); + void Insert(const SwFrame& rFrame, const SvxBoxItem& rBoxItem, const SwRect &rPaintArea); + void HandleFrame(const SwLayoutFrame& rFrame, const SwRect& rPaintArea); void FindStylesForLine( const Point&, const Point&, svx::frame::Style*, @@ -2324,10 +2324,11 @@ public: SwTabFramePainter::SwTabFramePainter( const SwTabFrame& rTabFrame ) : mrTabFrame( rTabFrame ) { - HandleFrame( rTabFrame ); + SwRect aPaintArea = rTabFrame.GetUpper()->GetPaintArea(); + HandleFrame(rTabFrame, aPaintArea); } -void SwTabFramePainter::HandleFrame( const SwLayoutFrame& rLayoutFrame ) +void SwTabFramePainter::HandleFrame(const SwLayoutFrame& rLayoutFrame, const SwRect& rPaintArea) { // Add border lines of cell frames. Skip covered cells. Skip cells // in special row span row, which do not have a negative row span: @@ -2341,7 +2342,7 @@ void SwTabFramePainter::HandleFrame( const SwLayoutFrame& rLayoutFrame ) SwBorderAttrAccess aAccess( SwFrame::GetCache(), &rLayoutFrame ); const SwBorderAttrs& rAttrs = *aAccess.Get(); const SvxBoxItem& rBox = rAttrs.GetBox(); - Insert( rLayoutFrame, rBox ); + Insert(rLayoutFrame, rBox, rPaintArea); } } @@ -2351,7 +2352,7 @@ void SwTabFramePainter::HandleFrame( const SwLayoutFrame& rLayoutFrame ) { const SwLayoutFrame* pLowerLayFrame = dynamic_cast<const SwLayoutFrame*>(pLower); if ( pLowerLayFrame && !pLowerLayFrame->IsTabFrame() ) - HandleFrame( *pLowerLayFrame ); + HandleFrame(*pLowerLayFrame, rPaintArea); pLower = pLower->GetNext(); } @@ -2725,21 +2726,12 @@ static bool lcl_IsFirstRowInFollowTableWithoutRepeatedHeadlines( && rBoxItem.GetBottom()); } -void SwTabFramePainter::Insert( const SwFrame& rFrame, const SvxBoxItem& rBoxItem ) +void SwTabFramePainter::Insert(const SwFrame& rFrame, const SvxBoxItem& rBoxItem, const SwRect& rPaintArea) { // build 4 line entries for the 4 borders: SwRect aBorderRect = rFrame.getFrameArea(); - // Frame area of a table might be larger than the containing frame - // so we have to intersect the border rect with upper frames til - // the first frame that is not part of a table. - const SwLayoutFrame *pUpper = rFrame.GetUpper(); - while(pUpper) - { - aBorderRect.Intersection(pUpper->getFrameArea()); - if (!pUpper->IsInTab()) - break; - pUpper = pUpper->GetUpper(); - } + + aBorderRect.Intersection(rPaintArea); bool const bBottomAsTop(lcl_IsFirstRowInFollowTableWithoutRepeatedHeadlines( mrTabFrame, rFrame, rBoxItem)); |