svgio/qa/cppunit/SvgImportTest.cxx                    |   24 +++++++++
 svgio/qa/cppunit/data/tdf97710.svg                    |    8 +++
 svgio/source/svgreader/svgstyleattributes.cxx         |    3 -
 sw/qa/core/layout/data/floattable-in-inlinetable.docx |binary
 sw/qa/core/layout/tabfrm.cxx                          |   37 +++++++++++++++
 sw/source/core/layout/tabfrm.cxx                      |   44 ++++++++++++++++++
 6 files changed, 114 insertions(+), 2 deletions(-)

New commits:
commit 35f19e5cb93ce218787904e99c2bedfd40e725cc
Author:     Xisco Fauli <[email protected]>
AuthorDate: Tue Sep 26 16:51:17 2023 +0200
Commit:     Xisco Fauli <[email protected]>
CommitDate: Fri Sep 29 10:40:14 2023 +0200

    tdf#97710: do not create nonzero conform for polyline
    
    Change-Id: Ib9d4e957b83ad84b79ae4ade5c6be3ab3d9d8028
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157286
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>
    (cherry picked from commit 661f2425602f39e4b1e426edf3b13fc8c4fe1f75)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157310

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index e59a92cffb97..a3a554cbaf27 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -1446,6 +1446,30 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf101237)
     assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", 
"width", "5");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf97710)
+{
+    Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf97710.svg");
+    CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
+
+    drawinglayer::Primitive2dXmlDump dumper;
+    xmlDocUniquePtr pDocument = 
dumper.dumpAndParse(Primitive2DContainer(aSequence));
+
+    CPPUNIT_ASSERT (pDocument);
+
+    assertXPath(pDocument, "/primitive2D/transform/mask/polypolygoncolor[1]", 
"color", "#000000");
+
+    // Without the fix in place, this test would have failed with
+    // - Expected: 100
+    // - Actual  : 0
+    assertXPath(pDocument, 
"/primitive2D/transform/mask/polypolygoncolor[1]/polypolygon", "width", "100");
+    assertXPath(pDocument, 
"/primitive2D/transform/mask/polypolygoncolor[1]/polypolygon", "height", "100");
+    assertXPath(pDocument, "/primitive2D/transform/mask/polypolygoncolor[2]", 
"color", "#008000");
+    assertXPath(pDocument, 
"/primitive2D/transform/mask/polypolygoncolor[2]/polypolygon", "width", "100");
+    assertXPath(pDocument, 
"/primitive2D/transform/mask/polypolygoncolor[2]/polypolygon", "height", "100");
+    assertXPath(pDocument, 
"/primitive2D/transform/mask/polypolygonstroke/line", "color", "#000000");
+    assertXPath(pDocument, 
"/primitive2D/transform/mask/polypolygonstroke/line", "width", "1");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf94765)
 {
     Primitive2DSequence aSequenceTdf94765 = 
parseSvg(u"/svgio/qa/cppunit/data/tdf94765.svg");
diff --git a/svgio/qa/cppunit/data/tdf97710.svg 
b/svgio/qa/cppunit/data/tdf97710.svg
new file mode 100644
index 000000000000..bbd9a91a9b8e
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf97710.svg
@@ -0,0 +1,8 @@
+<svg viewBox="0 0 200 100" xmlns="http://www.w3.org/2000/svg";>
+  <!-- Example of a polyline with the default fill -->
+  <polyline points="0,100 50,25 50,75 100,0" />
+
+  <!-- Example of the same polyline shape with stroke and no fill -->
+  <polyline points="100,100 150,25 150,75 200,0" fill="green" stroke="black" />
+</svg>
+
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index 94209c32ac25..2953f42b5efc 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1127,8 +1127,7 @@ namespace svgio::svgreader
                 // create fill
                 basegfx::B2DPolyPolygon aPath(rPath);
 
-                if(SVGToken::Path == mrOwner.getType() || SVGToken::Polygon == 
mrOwner.getType()
-                        || SVGToken::Polyline == mrOwner.getType())
+                if(SVGToken::Path == mrOwner.getType() || SVGToken::Polygon == 
mrOwner.getType())
                 {
                     if(FillRule::evenodd != getClipRule() && FillRule::evenodd 
!= getFillRule())
                     {
commit 99c627a511cfe86a2d6b0bc945bd9f957cb4866b
Author:     Miklos Vajna <[email protected]>
AuthorDate: Wed Sep 27 08:36:12 2023 +0200
Commit:     Xisco Fauli <[email protected]>
CommitDate: Fri Sep 29 10:40:06 2023 +0200

    Related: tdf#126449 sw floattable: fix bad join of inline tbl with inner fly
    
    The problem is that the bugdoc has 3 pages with an inline outer table,
    where pages 2 & 3 have an inner floating table. The outer table is only
    on pages 1 -> 2, while it should be on pages 1 -> 2 -> 3.
    
    The trouble is similar to point 4) of commit
    cfe9c68a7a19dd77d1fcbde3a7dd75730634becc (tdf#157119 sw floattable: fix
    moving master of split fly to next page, 2023-09-21), i.e. our normal
    behavior would move up the follow table to page 2 from page 3 and simply
    shift up the floating table, which is fine for images, but not for
    floating tables.
    
    Fix the problem by checking for flys on the old page when determining if
    it's OK to move or not. Checking for flys on the new page is already
    done in SwTabFrame::ShouldBwdMoved(), when it calls the precede's
    CalcFlyOffsets().
    
    This just fixes a simplified DOCX bugdoc (inline outer table, floating
    inner table), the full document still needs more fixes.
    
    Change-Id: I7946c0f3cb9995a497fdfff3bfac28b6f16ff844
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157306
    Reviewed-by: Miklos Vajna <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit c86d6111525f09e895483c7c4919a4b9a5dbd9b9)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157315
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sw/qa/core/layout/data/floattable-in-inlinetable.docx 
b/sw/qa/core/layout/data/floattable-in-inlinetable.docx
new file mode 100644
index 000000000000..56505316cd8e
Binary files /dev/null and 
b/sw/qa/core/layout/data/floattable-in-inlinetable.docx differ
diff --git a/sw/qa/core/layout/tabfrm.cxx b/sw/qa/core/layout/tabfrm.cxx
index 705bf47af4bc..a5e448081b0f 100644
--- a/sw/qa/core/layout/tabfrm.cxx
+++ b/sw/qa/core/layout/tabfrm.cxx
@@ -61,6 +61,43 @@ CPPUNIT_TEST_FIXTURE(Test, testTableMissingJoin)
     // page 3.
     CPPUNIT_ASSERT(!pTab->HasFollow());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyInInlineTable)
+{
+    // Outer inline table on pages 1 -> 2 -> 3, inner floating table on pages 
2 -> 3:
+    // When laying out that document:
+    createSwDoc("floattable-in-inlinetable.docx");
+
+    // Then make sure that the outer table is not missing on page 3:
+    SwDoc* pDoc = getSwDoc();
+    SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+    auto pPage1 = pLayout->Lower()->DynCastPageFrame();
+    CPPUNIT_ASSERT(pPage1);
+    {
+        SwFrame* pBody = pPage1->FindBodyCont();
+        auto pTab = pBody->GetLower()->DynCastTabFrame();
+        CPPUNIT_ASSERT(!pTab->GetPrecede());
+        CPPUNIT_ASSERT(pTab->GetFollow());
+    }
+    auto pPage2 = pPage1->GetNext()->DynCastPageFrame();
+    CPPUNIT_ASSERT(pPage2);
+    {
+        SwFrame* pBody = pPage2->FindBodyCont();
+        auto pTab = pBody->GetLower()->DynCastTabFrame();
+        CPPUNIT_ASSERT(pTab->GetPrecede());
+        // Without the accompanying fix in place, this test would have failed, 
the outer table was
+        // missing on page 3.
+        CPPUNIT_ASSERT(pTab->GetFollow());
+    }
+    auto pPage3 = pPage2->GetNext()->DynCastPageFrame();
+    CPPUNIT_ASSERT(pPage3);
+    {
+        SwFrame* pBody = pPage3->FindBodyCont();
+        auto pTab = pBody->GetLower()->DynCastTabFrame();
+        CPPUNIT_ASSERT(pTab->GetPrecede());
+        CPPUNIT_ASSERT(!pTab->GetFollow());
+    }
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 009a05159970..51c29f899b77 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -2357,6 +2357,50 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
                         // when the upper has no space, but the follow is
                         // empty.
                         bFits = aRectFnSet.BottomDist(getFrameArea(), 
nDeadLine) >= 0;
+
+                    if (bFits)
+                    {
+                        // The follow table's wants to move backwards, see if 
the first row has a
+                        // split fly anchored in it that would have more space 
than what we have:
+                        SwRowFrame* pRow = 
GetFollow()->GetFirstNonHeadlineRow();
+                        if (pRow)
+                        {
+                            SwPageFrame* pPage = GetFollow()->FindPageFrame();
+                            SwSortedObjs* pPageObjs = pPage->GetSortedObjs();
+                            if (pPageObjs)
+                            {
+                                bool bSplitFly = false;
+                                for (size_t i = 0; i < pPageObjs->size(); ++i)
+                                {
+                                    SwAnchoredObject* pAnchoredObj = 
(*pPage->GetSortedObjs())[i];
+                                    auto pFly = 
pAnchoredObj->DynCastFlyFrame();
+                                    if (!pFly || !pFly->IsFlySplitAllowed())
+                                    {
+                                        continue;
+                                    }
+
+                                    SwFrame* pFlyAnchor = 
pFly->FindAnchorCharFrame();
+                                    if (!pFlyAnchor || 
!pRow->IsAnLower(pFlyAnchor))
+                                    {
+                                        continue;
+                                    }
+
+                                    bSplitFly = true;
+                                    break;
+                                }
+                                SwTwips nFollowFirstRowHeight = 
aRectFnSet.GetHeight(pRow->getFrameArea());
+                                SwTwips nSpace = 
aRectFnSet.BottomDist(getFrameArea(), nDeadLine);
+                                if (bSplitFly && nFollowFirstRowHeight > 0 && 
nSpace < nFollowFirstRowHeight)
+                                {
+                                    // The row has at least one split fly and 
the row would not fit
+                                    // to our remaining space, when also 
taking flys into account,
+                                    // so that's not a fit.
+                                    bFits = false;
+                                }
+                            }
+                        }
+                    }
+
                     if (bFits)
                     {
                         // First, we remove an existing follow flow line.

Reply via email to