sw/inc/IDocumentSettingAccess.hxx             |    1 +
 sw/qa/uibase/uno/uno.cxx                      |   26 ++++++++++++++++++++++++++
 sw/source/core/doc/DocumentSettingManager.cxx |   11 +++++++++++
 sw/source/core/inc/DocumentSettingManager.hxx |    1 +
 sw/source/filter/xml/xmlexp.cxx               |    1 +
 sw/source/filter/xml/xmlimp.cxx               |   10 ++++++++++
 sw/source/uibase/uno/SwXDocumentSettings.cxx  |   18 ++++++++++++++++++
 7 files changed, 68 insertions(+)

New commits:
commit ba2b66996146fcdaeb58ed044b0e0b5a60dafaa8
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Thu Oct 12 08:34:33 2023 +0200
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Oct 13 16:12:55 2023 +0200

    sw floattable: add an AllowTextAfterFloatingTableBreak compat flag
    
    Word and Writer normally only wrap the anchor text around the split fly
    frame on the last page, but as
    <https://bugs.documentfoundation.org/show_bug.cgi?id=61594#c33> points
    out, Word has an allowTextAfterFloatingTableBreak compat flag that
    allows wrapping on all pages.
    
    Map this to a Writer compat flag for now, which affects all floating
    tables in the document. The mailing list thread at
    
<https://lists.freedesktop.org/archives/libreoffice/2023-July/thread.html#90670>
    suggests that possibly there will be demand to control this on a
    per-frame level: that's not something Word supports, but we could do an
    OR of the two settings in the future if wanted.
    
    This is just the compat flag itself, layout still has to actually handle
    it.
    
    This compat flag is probably quite rare, so only write it to documents
    if it's true (the default is false).
    
    (cherry picked from commit 5b9249e950165015ba57cc2c0503381df9751bf6)
    
    Change-Id: Ibc431f7dc11710926c115d8e03f760b7f0784304
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157903
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sw/inc/IDocumentSettingAccess.hxx 
b/sw/inc/IDocumentSettingAccess.hxx
index 6d4409464386..8904424faa6a 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -94,6 +94,7 @@ enum class DocumentSettingId
     AUTO_FIRST_LINE_INDENT_DISREGARD_LINE_SPACE,
     HYPHENATE_URLS, ///< tdf#152952
     DO_NOT_BREAK_WRAPPED_TABLES,
+    ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK,
     // COMPATIBILITY FLAGS END
     BROWSE_MODE,
     HTML_MODE,
diff --git a/sw/qa/uibase/uno/uno.cxx b/sw/qa/uibase/uno/uno.cxx
index 50d1582133b9..04d25ee3a40a 100644
--- a/sw/qa/uibase/uno/uno.cxx
+++ b/sw/qa/uibase/uno/uno.cxx
@@ -534,6 +534,32 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUnoTest, 
testDoNotBreakWrappedTables)
     CPPUNIT_ASSERT(bDoNotBreakWrappedTables);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUibaseUnoTest, testAllowTextAfterFloatingTableBreak)
+{
+    // Given an empty document:
+    createSwDoc();
+
+    // When checking the state of the AllowTextAfterFloatingTableBreak compat 
flag:
+    uno::Reference<lang::XMultiServiceFactory> xDocument(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xSettings(
+        xDocument->createInstance("com.sun.star.document.Settings"), 
uno::UNO_QUERY);
+    bool bAllowTextAfterFloatingTableBreak{};
+    // Without the accompanying fix in place, this test would have failed with:
+    // An uncaught exception of type 
com.sun.star.beans.UnknownPropertyException
+    // i.e. the compat flag was not recognized.
+    xSettings->getPropertyValue("AllowTextAfterFloatingTableBreak")
+        >>= bAllowTextAfterFloatingTableBreak;
+    // Then make sure it's false by default:
+    CPPUNIT_ASSERT(!bAllowTextAfterFloatingTableBreak);
+
+    // And when setting AllowTextAfterFloatingTableBreak=true:
+    xSettings->setPropertyValue("AllowTextAfterFloatingTableBreak", 
uno::Any(true));
+    // Then make sure it gets enabled:
+    xSettings->getPropertyValue("AllowTextAfterFloatingTableBreak")
+        >>= bAllowTextAfterFloatingTableBreak;
+    CPPUNIT_ASSERT(bAllowTextAfterFloatingTableBreak);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx 
b/sw/source/core/doc/DocumentSettingManager.cxx
index 159b11292fe9..4342fb419e80 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -249,6 +249,8 @@ bool sw::DocumentSettingManager::get(/*[in]*/ 
DocumentSettingId id) const
         case DocumentSettingId::HYPHENATE_URLS: return mbHyphenateURLs;
         case DocumentSettingId::DO_NOT_BREAK_WRAPPED_TABLES:
             return mbDoNotBreakWrappedTables;
+        case DocumentSettingId::ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK:
+            return mbAllowTextAfterFloatingTableBreak;
         case DocumentSettingId::NO_NUMBERING_SHOW_FOLLOWBY: return 
mbNoNumberingShowFollowBy;
         case DocumentSettingId::DROP_CAP_PUNCTUATION: return 
mbDropCapPunctuation;
         default:
@@ -437,6 +439,10 @@ void sw::DocumentSettingManager::set(/*[in]*/ 
DocumentSettingId id, /*[in]*/ boo
             mbDoNotBreakWrappedTables = value;
             break;
 
+        case DocumentSettingId::ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK:
+            mbAllowTextAfterFloatingTableBreak = value;
+            break;
+
         case DocumentSettingId::NO_NUMBERING_SHOW_FOLLOWBY:
             mbNoNumberingShowFollowBy = value;
             break;
@@ -1051,6 +1057,11 @@ void 
sw::DocumentSettingManager::dumpAsXml(xmlTextWriterPtr pWriter) const
                                 
BAD_CAST(OString::boolean(mbDoNotBreakWrappedTables).getStr()));
     (void)xmlTextWriterEndElement(pWriter);
 
+    (void)xmlTextWriterStartElement(pWriter, 
BAD_CAST("mbAllowTextAfterFloatingTableBreak"));
+    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
+                                
BAD_CAST(OString::boolean(mbAllowTextAfterFloatingTableBreak).getStr()));
+    (void)xmlTextWriterEndElement(pWriter);
+
     (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mnImagePreferredDPI"));
     (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
                                 
BAD_CAST(OString::number(mnImagePreferredDPI).getStr()));
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx 
b/sw/source/core/inc/DocumentSettingManager.hxx
index 49c6234eb082..a84607de42ca 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -176,6 +176,7 @@ class DocumentSettingManager final :
     bool mbAutoFirstLineIndentDisregardLineSpace;
     bool mbHyphenateURLs = false;
     bool mbDoNotBreakWrappedTables = false;
+    bool mbAllowTextAfterFloatingTableBreak = false;
     // If this is on as_char flys wrapping will be handled the same like in 
Word
     bool mbNoNumberingShowFollowBy;
     bool mbDropCapPunctuation; // tdf#150200, tdf#150438
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
index 6d9f16f35218..1dad70965e22 100644
--- a/sw/source/filter/xml/xmlexp.cxx
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -396,6 +396,7 @@ void SwXMLExport::GetConfigurationSettings( Sequence < 
PropertyValue >& rProps)
 
     static const std::initializer_list<std::u16string_view> vOmitFalseValues = 
{
         u"DoNotBreakWrappedTables",
+        u"AllowTextAfterFloatingTableBreak",
     };
     SvXMLUnitConverter::convertPropertySet( rProps, xProps, &vOmitFalseValues 
);
 
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index 58916ccd3b08..4dfe7b23e52b 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -1309,6 +1309,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence 
< PropertyValue > & aC
     bool bAutoFirstLineIndentDisregardLineSpace = false;
     bool bHyphenateURLs = false;
     bool bDoNotBreakWrappedTables = false;
+    bool bAllowTextAfterFloatingTableBreak = false;
     bool bDropCapPunctuation = false;
 
     const PropertyValue* currentDatabaseDataSource = nullptr;
@@ -1411,6 +1412,10 @@ void SwXMLImport::SetConfigurationSettings(const 
Sequence < PropertyValue > & aC
                 {
                     rValue.Value >>= bDoNotBreakWrappedTables;
                 }
+                else if (rValue.Name == "AllowTextAfterFloatingTableBreak")
+                {
+                    rValue.Value >>= bAllowTextAfterFloatingTableBreak;
+                }
                 else if ( rValue.Name == "DropCapPunctuation" )
                     bDropCapPunctuation = true;
             }
@@ -1585,6 +1590,11 @@ void SwXMLImport::SetConfigurationSettings(const 
Sequence < PropertyValue > & aC
         xProps->setPropertyValue("DoNotBreakWrappedTables", Any(true));
     }
 
+    if (bAllowTextAfterFloatingTableBreak)
+    {
+        xProps->setPropertyValue("AllowTextAfterFloatingTableBreak", 
Any(true));
+    }
+
     // LO 7.4 and previous versions had different drop cap punctuation: very 
long dashes.
     // In order to keep backwards compatibility, DropCapPunctuation option is 
written to .odt
     // files, and the default for new documents is 'true'. Files without this 
option
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx 
b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index c84bff0ceab2..21ae55b900f7 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -154,6 +154,7 @@ enum SwDocumentSettingsPropertyHandles
     HANDLE_AUTO_FIRST_LINE_INDENT_DISREGARD_LINE_SPACE,
     HANDLE_HYPHENATE_URLS,
     HANDLE_DO_NOT_BREAK_WRAPPED_TABLES,
+    HANDLE_ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK,
     HANDLE_NO_NUMBERING_SHOW_FOLLOWBY,
     HANDLE_DROP_CAP_PUNCTUATION
 };
@@ -256,6 +257,7 @@ static rtl::Reference<MasterPropertySetInfo> 
lcl_createSettingsInfo()
         { OUString("AutoFirstLineIndentDisregardLineSpace"), 
HANDLE_AUTO_FIRST_LINE_INDENT_DISREGARD_LINE_SPACE, cppu::UnoType<bool>::get(), 
0 },
         { OUString("HyphenateURLs"), HANDLE_HYPHENATE_URLS, 
cppu::UnoType<bool>::get(), 0 },
         { OUString("DoNotBreakWrappedTables"), 
HANDLE_DO_NOT_BREAK_WRAPPED_TABLES, cppu::UnoType<bool>::get(), 0 },
+        { OUString("AllowTextAfterFloatingTableBreak"), 
HANDLE_ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK, cppu::UnoType<bool>::get(), 0 },
         { OUString("NoNumberingShowFollowBy"), 
HANDLE_NO_NUMBERING_SHOW_FOLLOWBY, cppu::UnoType<bool>::get(), 0 },
         { OUString("DropCapPunctuation"), HANDLE_DROP_CAP_PUNCTUATION, 
cppu::UnoType<bool>::get(), 0 },
 
@@ -1078,6 +1080,16 @@ void SwXDocumentSettings::_setSingleValue( const 
comphelper::PropertyInfo & rInf
             }
         }
         break;
+        case HANDLE_ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK:
+        {
+            bool bTmp;
+            if (rValue >>= bTmp)
+            {
+                mpDoc->getIDocumentSettingAccess().set(
+                    DocumentSettingId::ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK, 
bTmp);
+            }
+        }
+        break;
         case HANDLE_NO_NUMBERING_SHOW_FOLLOWBY:
         {
             bool bTmp;
@@ -1628,6 +1640,12 @@ void SwXDocumentSettings::_getSingleValue( const 
comphelper::PropertyInfo & rInf
                 DocumentSettingId::DO_NOT_BREAK_WRAPPED_TABLES);
         }
         break;
+        case HANDLE_ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK:
+        {
+            rValue <<= mpDoc->getIDocumentSettingAccess().get(
+                DocumentSettingId::ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK);
+        }
+        break;
         case HANDLE_NO_NUMBERING_SHOW_FOLLOWBY:
         {
             rValue <<= mpDoc->getIDocumentSettingAccess().get(

Reply via email to