sw/qa/extras/ww8export/ww8export2.cxx |   36 +++++++++++++++++++++++++++++++++-
 sw/source/filter/ww8/ww8par6.cxx      |    3 +-
 2 files changed, 37 insertions(+), 2 deletions(-)

New commits:
commit c6dc8e4003722db07936e3e4be8d3f1613c69f58
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Fri Apr 14 14:10:03 2023 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Apr 20 08:27:48 2023 +0200

    sw floattable: unconditionally map DOC table pos props to SwFormatFlySplit
    
    Previously we only mapped DOC floating tables to split fly frames when
    the heuristics asked for a fly frame, this goes further.
    
    Also add a testcase that shows that the import now works, but the export
    needs more work.
    
    In other words, this disables heuristics when the feature flag is on.
    
    (cherry picked from commit 69fe424e426957545a30e1b912c933e1e7693100)
    
    Change-Id: I65018fef7994b283a60b0c38b22c16e2277cb80f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150471
    Tested-by: Miklos Vajna <vmik...@collabora.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/ww8export/ww8export2.cxx 
b/sw/qa/extras/ww8export/ww8export2.cxx
index 9f33c596c83f..863c2c1ccbad 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -26,13 +26,21 @@
 #include <com/sun/star/text/XEndnotesSupplier.hpp>
 
 #include <svx/svdpage.hxx>
+#include <o3tl/string_view.hxx>
 
 #include <ftninfo.hxx>
 #include <drawdoc.hxx>
 #include <IDocumentDrawModelAccess.hxx>
 #include <docsh.hxx>
 #include <unotxdoc.hxx>
-#include <o3tl/string_view.hxx>
+#include <IDocumentLayoutAccess.hxx>
+#include <rootfrm.hxx>
+#include <pagefrm.hxx>
+#include <sortedobjs.hxx>
+#include <cntfrm.hxx>
+#include <anchoredobject.hxx>
+#include <tabfrm.hxx>
+#include <flyfrms.hxx>
 
 class Test : public SwModelTestBase
 {
@@ -336,6 +344,32 @@ DECLARE_WW8EXPORT_TEST(testTdf107773, "tdf107773.doc")
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Horizontal Orientation", 
text::HoriOrientation::CENTER, getProperty<sal_Int16>(xTable, "HoriOrient"));
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf107773SplitFly)
+{
+    SwModelTestBase::FlySplitGuard aGuard;
+
+    createSwDoc("tdf107773.doc");
+
+    // This failed, multi-page table was imported as a non-split frame.
+    SwDoc* pDoc = getSwDoc();
+    SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+    auto pPage1 = dynamic_cast<SwPageFrame*>(pLayout->Lower());
+    CPPUNIT_ASSERT(pPage1);
+    // pPage1 has no sorted (floating) objections.
+    CPPUNIT_ASSERT(pPage1->GetSortedObjs());
+    const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs();
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rPage1Objs.size());
+    auto pPage1Fly = dynamic_cast<SwFlyAtContentFrame*>(rPage1Objs[0]);
+    CPPUNIT_ASSERT(pPage1Fly);
+    auto pTab1 = dynamic_cast<SwTabFrame*>(pPage1Fly->GetLower());
+    CPPUNIT_ASSERT(pTab1);
+    CPPUNIT_ASSERT(pTab1->HasFollow());
+
+    // tdf#80635 - assert the horizontal orientation.
+    const SwFormatHoriOrient& rFormatHoriOrient = 
pPage1Fly->GetFormat()->GetHoriOrient();
+    CPPUNIT_ASSERT_EQUAL(css::text::HoriOrientation::CENTER, 
rFormatHoriOrient.GetHoriOrient());
+}
+
 DECLARE_WW8EXPORT_TEST(testTdf112074_RTLtableJustification, 
"tdf112074_RTLtableJustification.doc")
 {
     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, 
uno::UNO_QUERY);
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index d36702847e30..7825602f7cc9 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2507,7 +2507,8 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults 
&rApo, const WW8_TablePos *p
 
         WW8FlySet aFlySet(*this, m_xWFlyPara.get(), m_xSFlyPara.get(), false);
 
-        if (pTabPos && pTabPos->bNoFly)
+        // Always map floating tables to split flys when fly split is allowed.
+        if (pTabPos && pTabPos->bNoFly && !IsFlySplitAllowed())
         {
             m_xSFlyPara->SetFlyFormat(nullptr);
         }

Reply via email to