diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2023-05-24 11:00:11 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2023-05-31 13:47:58 +0200 |
commit | 53b99e785cf5506fdbdd3d896154a2b1ad6e9aac (patch) | |
tree | 9aad72189f9122de250843f8bfd15aeab56563b0 /sw/source | |
parent | 9449d50a885b91bcf4f75b6569d5f3b28e868076 (diff) |
sw floattable: add a DoNotBreakWrappedTables compat flag
RTF doesn't break floating table across pages, and there is a matching
DOCX compat flag to handle such documents.
We can ignore floating table info on the model as a workaround, but that
would mean the info is lost on save, so that's not ideal.
Instead add a new compat flag that disables fly split at a layout level,
which allows both not splitting tables & retaining the model-level info.
This commit does the doc model, UNO API, layout & ODT filter, the Word
filters are not yet updated.
This compat flag is probably quite rare, so introduce a mechanism to
only write the compat flag when it's true: this way the majority of the
documents don't need to say anything about it and we can assume "false"
for them. Also fix two missing xmlTextWriterEndElement() calls in the
xml dumper.
(cherry picked from commit 08fa2903df1a7cf9a1647fcf967e4c8b57dad793)
Change-Id: I32321ec204d7bfe011fcf024b97c906da0db8aae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152260
Tested-by: Miklos Vajna <vmiklos@collabora.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/doc/DocumentSettingManager.cxx | 13 | ||||
-rw-r--r-- | sw/source/core/inc/DocumentSettingManager.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/layout/fly.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlexp.cxx | 5 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlimp.cxx | 10 | ||||
-rw-r--r-- | sw/source/uibase/uno/SwXDocumentSettings.cxx | 18 |
6 files changed, 52 insertions, 1 deletions
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx index da04446c1271..8a75b9f31eff 100644 --- a/sw/source/core/doc/DocumentSettingManager.cxx +++ b/sw/source/core/doc/DocumentSettingManager.cxx @@ -248,6 +248,8 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const case DocumentSettingId::AUTO_FIRST_LINE_INDENT_DISREGARD_LINE_SPACE: return mbAutoFirstLineIndentDisregardLineSpace; case DocumentSettingId::HYPHENATE_URLS: return mbHyphenateURLs; + case DocumentSettingId::DO_NOT_BREAK_WRAPPED_TABLES: + return mbDoNotBreakWrappedTables; case DocumentSettingId::WRAP_AS_CHAR_FLYS_LIKE_IN_OOXML: return mbWrapAsCharFlysLikeInOOXML; case DocumentSettingId::NO_NUMBERING_SHOW_FOLLOWBY: return mbNoNumberingShowFollowBy; case DocumentSettingId::DROP_CAP_PUNCTUATION: return mbDropCapPunctuation; @@ -433,6 +435,10 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo mbHyphenateURLs = value; break; + case DocumentSettingId::DO_NOT_BREAK_WRAPPED_TABLES: + mbDoNotBreakWrappedTables = value; + break; + case DocumentSettingId::WRAP_AS_CHAR_FLYS_LIKE_IN_OOXML: mbWrapAsCharFlysLikeInOOXML = value; break; @@ -1039,10 +1045,17 @@ void sw::DocumentSettingManager::dumpAsXml(xmlTextWriterPtr pWriter) const (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mbFootnoteInColumnToPageEnd")); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::boolean(mbFootnoteInColumnToPageEnd).getStr())); + (void)xmlTextWriterEndElement(pWriter); (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mbHyphenateURLs")); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::boolean(mbHyphenateURLs).getStr())); + (void)xmlTextWriterEndElement(pWriter); + + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mbDoNotBreakWrappedTables")); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), + BAD_CAST(OString::boolean(mbDoNotBreakWrappedTables).getStr())); + (void)xmlTextWriterEndElement(pWriter); (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mnImagePreferredDPI")); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx index 07a12e3f1a6b..31dcf2f20360 100644 --- a/sw/source/core/inc/DocumentSettingManager.hxx +++ b/sw/source/core/inc/DocumentSettingManager.hxx @@ -175,6 +175,7 @@ class DocumentSettingManager final : sal_Int32 mnImagePreferredDPI; bool mbAutoFirstLineIndentDisregardLineSpace; bool mbHyphenateURLs = false; + bool mbDoNotBreakWrappedTables = false; // If this is on as_char flys wrapping will be handled the same like in Word bool mbWrapAsCharFlysLikeInOOXML; bool mbNoNumberingShowFollowBy; diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 054e86525180..20b02ed05e86 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -661,6 +661,12 @@ bool SwFlyFrame::IsFlySplitAllowed() const return false; } + const IDocumentSettingAccess& rIDSA = GetFormat()->getIDocumentSettingAccess(); + if (rIDSA.get(DocumentSettingId::DO_NOT_BREAK_WRAPPED_TABLES)) + { + return false; + } + if (FindFooterOrHeader()) { // Adding a new page would not increase the header/footer area. diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx index 65df1c99e243..6d9f16f35218 100644 --- a/sw/source/filter/xml/xmlexp.cxx +++ b/sw/source/filter/xml/xmlexp.cxx @@ -394,7 +394,10 @@ void SwXMLExport::GetConfigurationSettings( Sequence < PropertyValue >& rProps) if (!xProps.is()) return; - SvXMLUnitConverter::convertPropertySet( rProps, xProps ); + static const std::initializer_list<std::u16string_view> vOmitFalseValues = { + u"DoNotBreakWrappedTables", + }; + SvXMLUnitConverter::convertPropertySet( rProps, xProps, &vOmitFalseValues ); // tdf#144532 if NoEmbDataSet was set, to indicate not to write an embedded // database for the case of a temporary mail merge preview document, then diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 5ef66a1bf36f..58916ccd3b08 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -1308,6 +1308,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC bool bCollapseEmptyCellPara = false; bool bAutoFirstLineIndentDisregardLineSpace = false; bool bHyphenateURLs = false; + bool bDoNotBreakWrappedTables = false; bool bDropCapPunctuation = false; const PropertyValue* currentDatabaseDataSource = nullptr; @@ -1406,6 +1407,10 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC { bHyphenateURLs = true; } + else if (rValue.Name == "DoNotBreakWrappedTables") + { + rValue.Value >>= bDoNotBreakWrappedTables; + } else if ( rValue.Name == "DropCapPunctuation" ) bDropCapPunctuation = true; } @@ -1575,6 +1580,11 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC xProps->setPropertyValue("HyphenateURLs", Any(true)); } + if (bDoNotBreakWrappedTables) + { + xProps->setPropertyValue("DoNotBreakWrappedTables", 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 9ce8dda4d5fd..316914d4cf14 100644 --- a/sw/source/uibase/uno/SwXDocumentSettings.cxx +++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx @@ -153,6 +153,7 @@ enum SwDocumentSettingsPropertyHandles HANDLE_IMAGE_PREFERRED_DPI, HANDLE_AUTO_FIRST_LINE_INDENT_DISREGARD_LINE_SPACE, HANDLE_HYPHENATE_URLS, + HANDLE_DO_NOT_BREAK_WRAPPED_TABLES, HANDLE_WORD_LIKE_WRAP_FOR_AS_CHAR_FLYS, HANDLE_NO_NUMBERING_SHOW_FOLLOWBY, HANDLE_DROP_CAP_PUNCTUATION @@ -255,6 +256,7 @@ static rtl::Reference<MasterPropertySetInfo> lcl_createSettingsInfo() { OUString("ImagePreferredDPI"), HANDLE_IMAGE_PREFERRED_DPI, cppu::UnoType<sal_Int32>::get(), 0 }, { 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("WordLikeWrapForAsCharFlys"), HANDLE_WORD_LIKE_WRAP_FOR_AS_CHAR_FLYS, 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 }, @@ -1068,6 +1070,16 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf } } break; + case HANDLE_DO_NOT_BREAK_WRAPPED_TABLES: + { + bool bTmp; + if (rValue >>= bTmp) + { + mpDoc->getIDocumentSettingAccess().set( + DocumentSettingId::DO_NOT_BREAK_WRAPPED_TABLES, bTmp); + } + } + break; case HANDLE_WORD_LIKE_WRAP_FOR_AS_CHAR_FLYS: { bool bTmp; @@ -1620,6 +1632,12 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf DocumentSettingId::HYPHENATE_URLS); } break; + case HANDLE_DO_NOT_BREAK_WRAPPED_TABLES: + { + rValue <<= mpDoc->getIDocumentSettingAccess().get( + DocumentSettingId::DO_NOT_BREAK_WRAPPED_TABLES); + } + break; case HANDLE_WORD_LIKE_WRAP_FOR_AS_CHAR_FLYS: { rValue <<= mpDoc->getIDocumentSettingAccess().get( |