sw/source/core/layout/flycnt.cxx                                  |    7 +-
 writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx |   27 
++++++++++
 writerfilter/qa/cppunittests/dmapper/data/floattable-nested.docx  |binary
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx          |    8 --
 4 files changed, 33 insertions(+), 9 deletions(-)

New commits:
commit 3b96641c556dc240d5118825e3f0277ed870bf64
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Wed Sep 13 08:14:19 2023 +0200
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Thu Sep 14 10:19:36 2023 +0200

    sw floattable, nesting: add DOCX import
    
    There were two problems here:
    
    1) writerfilter/ didn't even try allowing split floating tables for the
       inner case, because layout didn't support that previously.
    
    2) CppunitTest_writerfilter_dmapper's test3NestedFloatingTables crashed
       because we expected that in case a fly+table is not toplevel, then
       the parent is also a fly+table frame, but in this case the parent was
       just a table frame.
    
       Fix this by checking for a table parent instead of a fly parent when
       deciding if we handle the split as a nested case or a toplevel one.
    
    (cherry picked from commit 5127b1961b762643d47a26704556fd9b8664c6fc)
    
    Change-Id: I4c58636ef80371b8ec51a96fe436fa6379c795d9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156905
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 310526d39944..13388e378867 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -1611,10 +1611,11 @@ SwLayoutFrame *SwFrame::GetNextFlyLeaf( MakePageType 
eMakePage )
                 }
             }
 
-            if (bLeftFly && pFlyAnchor && pFlyAnchor->IsInFly()
-                && FindFlyFrame() == pLayLeaf->FindFlyFrame())
+            if (bLeftFly && pFlyAnchor && pFlyAnchor->IsInTab()
+                && FindTabFrame() == pLayLeaf->FindTabFrame())
             {
-                // This is an inner fly, then the follow anchor will be just 
next to us.
+                // This is an inner fly (parent is an inline or a floating 
table), then the follow
+                // anchor will be just next to us.
                 SwLayoutFrame* pFlyAnchorUpper = pFlyAnchor->GetUpper();
                 pOldLayLeaf = pLayLeaf;
                 pLayLeaf = pFlyAnchorUpper;
diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx 
b/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx
index 8c11e3db22c7..fa1567c5a577 100644
--- a/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx
@@ -133,6 +133,33 @@ CPPUNIT_TEST_FIXTURE(Test, 
testDOCXFloatingTableHiddenAnchor)
     // hidden.
     CPPUNIT_ASSERT(!bCharHidden);
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testDOCXFloatingTableNested)
+{
+    // Given a document with nested, multi-page floating tables:
+    // When loading that document:
+    loadFromURL(u"floattable-nested.docx");
+
+    // Then make sure that both floating tables are allowed to split:
+    uno::Reference<text::XTextFramesSupplier> xFramesSupplier(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> 
xFrames(xFramesSupplier->getTextFrames(),
+                                                    uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xFrames->getCount());
+    // Outer frame:
+    uno::Reference<beans::XPropertySet> xFrame1;
+    xFrames->getByIndex(0) >>= xFrame1;
+    bool bIsSplitAllowed = false;
+    xFrame1->getPropertyValue("IsSplitAllowed") >>= bIsSplitAllowed;
+    CPPUNIT_ASSERT(bIsSplitAllowed);
+    // Inner frame:
+    uno::Reference<beans::XPropertySet> xFrame2;
+    xFrames->getByIndex(1) >>= xFrame2;
+    bIsSplitAllowed = false;
+    xFrame2->getPropertyValue("IsSplitAllowed") >>= bIsSplitAllowed;
+    // Without the accompanying fix in place, this test would have failed, the 
inner frame could not
+    // split.
+    CPPUNIT_ASSERT(bIsSplitAllowed);
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/qa/cppunittests/dmapper/data/floattable-nested.docx 
b/writerfilter/qa/cppunittests/dmapper/data/floattable-nested.docx
new file mode 100644
index 000000000000..655e6c0e0bad
Binary files /dev/null and 
b/writerfilter/qa/cppunittests/dmapper/data/floattable-nested.docx differ
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx 
b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 44749e7b124f..fdad7aba4011 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -1590,12 +1590,8 @@ void DomainMapperTableHandler::endTable(unsigned int 
nestedTableLevel, bool bTab
                     comphelper::makePropertyValue("IsFollowingTextFlow", 
true));
             }
 
-            if (nestedTableLevel <= 1)
-            {
-                // A text frame created for floating tables is allowed to 
split if it's a toplevel
-                // table.
-                
aFrameProperties.push_back(comphelper::makePropertyValue("IsSplitAllowed", 
true));
-            }
+            // A text frame created for floating tables is always allowed to 
split.
+            
aFrameProperties.push_back(comphelper::makePropertyValue("IsSplitAllowed", 
true));
 
             sal_Int32 nTableWidth = 0;
             m_aTableProperties->getValue(TablePropertyMap::TABLE_WIDTH, 
nTableWidth);

Reply via email to