[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sw/qa sw/source

Mark Hung marklh9 at gmail.com
Tue Jun 12 14:59:49 UTC 2018


 sw/qa/extras/layout/data/table-extrusion1.odt |binary
 sw/qa/extras/layout/data/table-extrusion2.odt |binary
 sw/qa/extras/layout/layout.cxx                |   43 ++++++++++++++++++++++++++
 sw/source/core/layout/paintfrm.cxx            |   28 ++++++----------
 4 files changed, 53 insertions(+), 18 deletions(-)

New commits:
commit 5f42787232a5a2ece35d4c018df8a9b7c856919f
Author: Mark Hung <marklh9 at gmail.com>
Date:   Sat May 26 22:34:49 2018 +0800

    tdf#117884: intersect border with paint area of upper frame.
    
    This patch fix regression caused by e87cc12eaf53 and allow
    table borders rendered in the left or right page margin.
    
    Also add another test case (testTableExtrusion2) to assure
    inner table can't have wider border than outer table.
    
    Change-Id: I7a86b379dee08fb2f23385183a42d0ebde007370
    Reviewed-on: https://gerrit.libreoffice.org/54862
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mark Hung <marklh9 at gmail.com>
    (cherry picked from commit 1e21902106cbe57658bed03ed24d4d0863685cfd)
    Reviewed-on: https://gerrit.libreoffice.org/55663

diff --git a/sw/qa/extras/layout/data/table-extrusion1.odt b/sw/qa/extras/layout/data/table-extrusion1.odt
new file mode 100755
index 000000000000..10600fa54c86
Binary files /dev/null and b/sw/qa/extras/layout/data/table-extrusion1.odt differ
diff --git a/sw/qa/extras/layout/data/table-extrusion2.odt b/sw/qa/extras/layout/data/table-extrusion2.odt
new file mode 100755
index 000000000000..63fc74f46db8
Binary files /dev/null and b/sw/qa/extras/layout/data/table-extrusion2.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
old mode 100644
new mode 100755
index a7eb24e89208..2356832cc4ba
--- 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));


More information about the Libreoffice-commits mailing list