summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-10-12 08:34:33 +0200
committerMiklos Vajna <vmiklos@collabora.com>2023-10-12 18:50:00 +0200
commit5b9249e950165015ba57cc2c0503381df9751bf6 (patch)
treec59548687a673b58d87545c3264eb3e97620f0a4 /sw
parentdcea29c283680c8e75e4890f46b1624d0a55846f (diff)
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). Change-Id: Ibc431f7dc11710926c115d8e03f760b7f0784304 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157855 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/IDocumentSettingAccess.hxx1
-rw-r--r--sw/qa/uibase/uno/uno.cxx26
-rw-r--r--sw/source/core/doc/DocumentSettingManager.cxx11
-rw-r--r--sw/source/core/inc/DocumentSettingManager.hxx1
-rw-r--r--sw/source/filter/xml/xmlexp.cxx1
-rw-r--r--sw/source/filter/xml/xmlimp.cxx10
-rw-r--r--sw/source/uibase/uno/SwXDocumentSettings.cxx18
7 files changed, 68 insertions, 0 deletions
diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
index f14ffb543b30..8e5e3a587997 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -93,6 +93,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 dd74cd716ea3..3d7a473d7660 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 5610f2a1f801..53bd26fa9d08 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -253,6 +253,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;
case DocumentSettingId::USE_VARIABLE_WIDTH_NBSP: return mbUseVariableWidthNBSP;
@@ -442,6 +444,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;
@@ -1066,6 +1072,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 1a6fdf6f4bf6..d03706f70d9a 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 d0148ac4ace3..ae131a26f792 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 8e5362451052..3b37d1cf76a0 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -1303,6 +1303,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;
@@ -1405,6 +1406,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;
}
@@ -1579,6 +1584,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 d544848ca597..3071f0cf6ee4 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,
HANDLE_USE_VARIABLE_WIDTH_NBSP,
@@ -257,6 +258,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 },
{ OUString("UseVariableWidthNBSP"), HANDLE_USE_VARIABLE_WIDTH_NBSP, cppu::UnoType<bool>::get(), 0 },
@@ -1080,6 +1082,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;
@@ -1638,6 +1650,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(