officecfg/registry/schema/org/openoffice/Office/Writer.xcs |    7 +
 sw/CppunitTest_sw_core_layout.mk                           |    1 
 sw/CppunitTest_sw_core_layout_flycnt.mk                    |   82 -------------
 sw/Module_sw.mk                                            |    1 
 sw/inc/formatflysplit.hxx                                  |    4 
 sw/qa/core/layout/flycnt.cxx                               |   28 +++-
 sw/source/core/attr/formatflysplit.cxx                     |   28 +---
 sw/source/core/unocore/unoframe.cxx                        |   10 +
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx   |   11 +
 9 files changed, 59 insertions(+), 113 deletions(-)

New commits:
commit 3282508f8deeafd50f5af45ca0adf760efb114a3
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Fri Feb 17 08:49:59 2023 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Feb 17 09:12:28 2023 +0000

    sw floattable: add ImportFloatingTableAsSplitFly expert setting
    
    Mapping DOCX floating tables to Writer split flys is still disabled by
    default, but now the environment variable affects the DOCX import
    instead of affecting the Writer item pool's default.
    
    This allows mixing ImportFloatingTableAsSplitFly=true and =false tests
    in the same suite, so the sw/CppunitTest_sw_core_layout_flycnt.mk
    boilerplate can be dropped.
    
    It also allows overwriting this default from an xcu file (expert config,
    or the XCU file in online.git) for testing / demo purposes.
    
    Also extend the layout representation comment / doc a bit.
    
    Change-Id: I239e9c6e9d9c8748ed0846ae336c9c818d59f180
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147191
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
index 99c3e8e0f606..07fcc54d10d4 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
@@ -5670,6 +5670,13 @@
             </info>
             <value>true</value>
           </prop>
+          <prop oor:name="ImportFloatingTableAsSplitFly" oor:type="xs:boolean" 
oor:nillable="false">
+            <info>
+              <desc>Specifies whether a floating table should be imported as a 
split text frame.</desc>
+              <label>Import floating table as split frame.</label>
+            </info>
+            <value>false</value>
+          </prop>
         </group>
       </group>
     </group>
diff --git a/sw/CppunitTest_sw_core_layout.mk b/sw/CppunitTest_sw_core_layout.mk
index 9a7a4710dfb7..1a7aeb649887 100644
--- a/sw/CppunitTest_sw_core_layout.mk
+++ b/sw/CppunitTest_sw_core_layout.mk
@@ -14,6 +14,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,sw_core_layout))
 $(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_core_layout))
 
 $(eval $(call gb_CppunitTest_add_exception_objects,sw_core_layout, \
+    sw/qa/core/layout/flycnt \
     sw/qa/core/layout/layout \
 ))
 
diff --git a/sw/CppunitTest_sw_core_layout_flycnt.mk 
b/sw/CppunitTest_sw_core_layout_flycnt.mk
deleted file mode 100644
index c9668afbc9b8..000000000000
--- a/sw/CppunitTest_sw_core_layout_flycnt.mk
+++ /dev/null
@@ -1,82 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#*************************************************************************
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-#*************************************************************************
-
-$(eval $(call gb_CppunitTest_CppunitTest,sw_core_layout_flycnt))
-
-$(eval $(call 
gb_CppunitTest_use_common_precompiled_header,sw_core_layout_flycnt))
-
-# TODO merge this with sw_core_layout once SwFormatFlySplit::SetForce() is 
gone.
-$(eval $(call gb_CppunitTest_add_exception_objects,sw_core_layout_flycnt, \
-    sw/qa/core/layout/flycnt \
-))
-
-$(eval $(call gb_CppunitTest_use_libraries,sw_core_layout_flycnt, \
-    editeng \
-    comphelper \
-    cppu \
-    cppuhelper \
-    sal \
-    sfx \
-    subsequenttest \
-    sw \
-       swqahelper \
-    test \
-    unotest \
-    utl \
-    vcl \
-    svt \
-    tl \
-    svl \
-    svxcore \
-))
-
-$(eval $(call gb_CppunitTest_use_externals,sw_core_layout_flycnt,\
-    boost_headers \
-    libxml2 \
-))
-
-$(eval $(call gb_CppunitTest_set_include,sw_core_layout_flycnt,\
-    -I$(SRCDIR)/sw/inc \
-    -I$(SRCDIR)/sw/source/core/inc \
-    -I$(SRCDIR)/sw/source/uibase/inc \
-    -I$(SRCDIR)/sw/qa/inc \
-    $$(INCLUDE) \
-))
-
-$(eval $(call gb_CppunitTest_use_api,sw_core_layout_flycnt,\
-       udkapi \
-       offapi \
-       oovbaapi \
-))
-
-$(eval $(call gb_CppunitTest_use_ure,sw_core_layout_flycnt))
-$(eval $(call gb_CppunitTest_use_vcl,sw_core_layout_flycnt))
-
-$(eval $(call gb_CppunitTest_use_rdb,sw_core_layout_flycnt,services))
-
-$(eval $(call gb_CppunitTest_use_custom_headers,sw_core_layout_flycnt,\
-    officecfg/registry \
-))
-
-$(eval $(call gb_CppunitTest_use_configuration,sw_core_layout_flycnt))
-
-$(eval $(call gb_CppunitTest_use_uiconfigs,sw_core_layout_flycnt, \
-    modules/swriter \
-    svt \
-    svx \
-))
-
-# assert if font/glyph fallback occurs
-$(eval $(call 
gb_CppunitTest_set_non_application_font_use,sw_core_layout_flycnt,abort))
-
-$(eval $(call gb_CppunitTest_use_more_fonts,sw_core_layout_flycnt))
-
-# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 45325bf3ea9a..2b99d0bff22a 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -138,7 +138,6 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
     CppunitTest_sw_uibase_wrtsh \
     CppunitTest_sw_core_accessibilitycheck \
     CppunitTest_sw_core_layout \
-    CppunitTest_sw_core_layout_flycnt \
     CppunitTest_sw_core_fields \
     CppunitTest_sw_core_tox \
     CppunitTest_sw_core_frmedt \
diff --git a/sw/inc/formatflysplit.hxx b/sw/inc/formatflysplit.hxx
index 1db9587752b6..5f7dda675ed2 100644
--- a/sw/inc/formatflysplit.hxx
+++ b/sw/inc/formatflysplit.hxx
@@ -34,10 +34,6 @@ public:
     SwFormatFlySplit* Clone(SfxItemPool* pPool = nullptr) const override;
 
     void dumpAsXml(xmlTextWriterPtr pWriter) const override;
-
-    // Force-enable for test purposes.
-    static void SetForce(bool bForce);
-    static bool GetForce();
 };
 
 inline const SwFormatFlySplit& SwAttrSet::GetFlySplit(bool bInP) const
diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index f305c19ec5c1..a41fb17ef54d 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -9,7 +9,9 @@
 
 #include <swmodeltestbase.hxx>
 
+#include <comphelper/configuration.hxx>
 #include <comphelper/scopeguard.hxx>
+#include <officecfg/Office/Writer.hxx>
 
 #include <IDocumentLayoutAccess.hxx>
 #include <anchoredobject.hxx>
@@ -36,8 +38,16 @@ public:
 CPPUNIT_TEST_FIXTURE(Test, testSplitFlyWithTable)
 {
     // Given a document with a multi-page floating table:
-    SwFormatFlySplit::SetForce(true);
-    comphelper::ScopeGuard g([] { SwFormatFlySplit::SetForce(false); });
+    std::shared_ptr<comphelper::ConfigurationChanges> pChanges(
+        comphelper::ConfigurationChanges::create());
+    
officecfg::Office::Writer::Filter::Import::DOCX::ImportFloatingTableAsSplitFly::set(true,
+                                                                               
         pChanges);
+    pChanges->commit();
+    comphelper::ScopeGuard g([pChanges] {
+        
officecfg::Office::Writer::Filter::Import::DOCX::ImportFloatingTableAsSplitFly::set(
+            false, pChanges);
+        pChanges->commit();
+    });
     createSwDoc("floattable.docx");
 
     // When laying out that document:
@@ -86,8 +96,16 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyWithTable)
 CPPUNIT_TEST_FIXTURE(Test, testSplitFlyVertoffset)
 {
     // Given a document with a floattable, split on 2 pages and a positive 
vertical offset:
-    SwFormatFlySplit::SetForce(true);
-    comphelper::ScopeGuard g([] { SwFormatFlySplit::SetForce(false); });
+    std::shared_ptr<comphelper::ConfigurationChanges> pChanges(
+        comphelper::ConfigurationChanges::create());
+    
officecfg::Office::Writer::Filter::Import::DOCX::ImportFloatingTableAsSplitFly::set(true,
+                                                                               
         pChanges);
+    pChanges->commit();
+    comphelper::ScopeGuard g([pChanges] {
+        
officecfg::Office::Writer::Filter::Import::DOCX::ImportFloatingTableAsSplitFly::set(
+            false, pChanges);
+        pChanges->commit();
+    });
     createSwDoc("floattable-vertoffset.docx");
 
     // When laying out that document:
@@ -129,6 +147,4 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyVertoffset)
 }
 }
 
-CPPUNIT_PLUGIN_IMPLEMENT();
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/attr/formatflysplit.cxx 
b/sw/source/core/attr/formatflysplit.cxx
index 7bc8a75594d7..6bcfd74390e1 100644
--- a/sw/source/core/attr/formatflysplit.cxx
+++ b/sw/source/core/attr/formatflysplit.cxx
@@ -21,8 +21,6 @@
 
 #include <libxml/xmlwriter.h>
 
-static std::optional<bool> g_oForce;
-
 SwFormatFlySplit::SwFormatFlySplit(bool bSplit)
     : SfxBoolItem(RES_FLY_SPLIT, bSplit)
 {
@@ -31,17 +29,19 @@ SwFormatFlySplit::SwFormatFlySplit(bool bSplit)
     //
     // The layout representation is the following:
     //
-    // - We assume that the anchor type is at-para for such fly frames, and 
SwFlyAtContentFrame
-    // derives from SwFlowFrame to be able to split in general.
+    // - We assume that the anchor type is at-para for such fly frames.
+    //
+    // - We also assume that AutoSize is true for such fly frames.
+    //
+    // - SwFlyAtContentFrame derives from SwFlowFrame to be able to split in 
general.
     //
     // - Both the master fly and the follow flys need an anchor. At the same 
time, we want all text
     // of the anchor frame to be wrapped around the last follow fly frame, for 
Word compatibility.
     // These are solved by splitting the anchor frame as many times as needed, 
always at
     // TextFrameIndex 0.
-    if (SwFormatFlySplit::GetForce())
-    {
-        SetValue(true);
-    }
+    //
+    // - The vertical offset is only considered on the master fly, all the 
follow flys ignore it, so
+    // they start at the top of a next page.
 }
 
 SwFormatFlySplit* SwFormatFlySplit::Clone(SfxItemPool*) const
@@ -59,16 +59,4 @@ void SwFormatFlySplit::dumpAsXml(xmlTextWriterPtr pWriter) 
const
     (void)xmlTextWriterEndElement(pWriter);
 }
 
-void SwFormatFlySplit::SetForce(bool bForce) { g_oForce = bForce; }
-
-bool SwFormatFlySplit::GetForce()
-{
-    if (g_oForce.has_value())
-    {
-        return *g_oForce;
-    }
-
-    return getenv("SW_FORCE_FLY_SPLIT") != nullptr;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/unocore/unoframe.cxx 
b/sw/source/core/unocore/unoframe.cxx
index f7c825040bd8..15701a50a114 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -134,6 +134,7 @@
 #include <svx/xfltrit.hxx>
 #include <swunohelper.hxx>
 #include <fefly.hxx>
+#include <formatflysplit.hxx>
 
 using namespace ::com::sun::star;
 
@@ -959,6 +960,15 @@ bool 
BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet& rToSet, const SfxI
         rToSet.Put(item);
     }
 
+    const ::uno::Any* pFlySplit = nullptr;
+    GetProperty(RES_FLY_SPLIT, 0, pFlySplit);
+    if (pFlySplit)
+    {
+        SwFormatFlySplit aSplit(true);
+        bRet &= aSplit.PutValue(*pFlySplit, 0);
+        rToSet.Put(aSplit);
+    }
+
     return bRet;
 }
 
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx 
b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index ef210f57bcfe..9ecf646af705 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -51,6 +51,7 @@
 #include <comphelper/propertyvalue.hxx>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
 #include <boost/lexical_cast.hpp>
+#include <officecfg/Office/Writer.hxx>
 
 #ifdef DBG_UTIL
 #include "PropertyMapHelper.hxx"
@@ -1564,6 +1565,16 @@ void DomainMapperTableHandler::endTable(unsigned int 
nestedTableLevel, bool bTab
                     comphelper::makePropertyValue("IsFollowingTextFlow", 
true));
             }
 
+            bool bSplitAllowed = 
officecfg::Office::Writer::Filter::Import::DOCX::ImportFloatingTableAsSplitFly::get();
+            if (!bSplitAllowed)
+            {
+                bSplitAllowed = getenv("SW_FORCE_FLY_SPLIT") != nullptr;
+            }
+            if (bSplitAllowed)
+            {
+                
aFrameProperties.push_back(comphelper::makePropertyValue("IsSplitAllowed", 
true));
+            }
+
             // In case the document ends with a table, we're called after
             // SectionPropertyMap::CloseSectionGroup(), so we'll have no idea
             // about the text area width, nor can fix this by delaying the text

Reply via email to