From 530ef7394a5441793135e69c1c7a74266f3660ec Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Tue, 09 Nov 2021 11:24:23 +0200 Subject: [PATCH] tdf#104254 docx compat15: add compat wrap on headers/endnotes MSWord for some bizarre reason ignored wrapping while in headers/footers and footnotes/endnotes. That changed in 2013's compatiblityMode 15. The worst part is that we altered LO itself so that it would do the same thing in order to make compatible documents. Now we have to undo that to again author compatible layouts (which is tdf#143793). This patch only worries about correct layout of DOCX c15. (I do pre-set DOC to also not wrap even though that matches the default for now.) A follow-up patch (with ESC blessing) will change LO itself to once again honour wrap settings in headings / endnotes. Change-Id: If1042d40b5b092af326d7c2b13024f7c18b7c02f --- diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx index 310f6a7..861ed0c 100644 --- a/sw/inc/IDocumentSettingAccess.hxx +++ b/sw/inc/IDocumentSettingAccess.hxx @@ -53,6 +53,7 @@ ADD_PARA_LINE_SPACING_TO_TABLE_CELLS, USE_FORMER_OBJECT_POS, USE_FORMER_TEXT_WRAPPING, + USE_TEXT_WRAPPING_ON_HEADERS_ENDNOTES, CONSIDER_WRAP_ON_OBJECT_POSITION, IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx index 883ab47..823f595 100644 --- a/sw/source/core/doc/DocumentSettingManager.cxx +++ b/sw/source/core/doc/DocumentSettingManager.cxx @@ -60,6 +60,7 @@ mbAddFlyOffsets(false), mbAddVerticalFlyOffsets(false), mbUseHiResolutionVirtualDevice(true), + mbUseTextWrappingOnHeadersEndnotes(false), // tdf#104254 mbMathBaselineAlignment(false), // default for *old* documents is 'off' mbStylesNoDefault(false), mbFloattableNomargins(false), @@ -181,6 +182,7 @@ case DocumentSettingId::ADD_PARA_LINE_SPACING_TO_TABLE_CELLS: return mbAddParaLineSpacingToTableCells; case DocumentSettingId::USE_FORMER_OBJECT_POS: return mbUseFormerObjectPos; case DocumentSettingId::USE_FORMER_TEXT_WRAPPING: return mbUseFormerTextWrapping; + case DocumentSettingId::USE_TEXT_WRAPPING_ON_HEADERS_ENDNOTES: return mbUseTextWrappingOnHeadersEndnotes; case DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION: return mbConsiderWrapOnObjPos; case DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK: return mbDoNotJustifyLinesWithManualBreak; case DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING: return mbIgnoreFirstLineIndentInNumbering; @@ -308,6 +310,9 @@ case DocumentSettingId::USE_FORMER_TEXT_WRAPPING: mbUseFormerTextWrapping = value; break; + case DocumentSettingId::USE_TEXT_WRAPPING_ON_HEADERS_ENDNOTES: + mbUseTextWrappingOnHeadersEndnotes = value; + break; case DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION: mbConsiderWrapOnObjPos = value; break; @@ -640,6 +645,7 @@ mbAddParaLineSpacingToTableCells = rSource.mbAddParaLineSpacingToTableCells; mbUseFormerObjectPos = rSource.mbUseFormerObjectPos; mbUseFormerTextWrapping = rSource.mbUseFormerTextWrapping; + mbUseTextWrappingOnHeadersEndnotes = rSource.mbUseTextWrappingOnHeadersEndnotes; mbConsiderWrapOnObjPos = rSource.mbConsiderWrapOnObjPos; mbMathBaselineAlignment = rSource.mbMathBaselineAlignment; mbStylesNoDefault = rSource.mbStylesNoDefault; @@ -800,6 +806,11 @@ BAD_CAST(OString::boolean(mbUseFormerTextWrapping).getStr())); (void)xmlTextWriterEndElement(pWriter); + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mbUseTextWrappingOnHeadersEndnotes")); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), + BAD_CAST(OString::boolean(mbUseTextWrappingOnHeadersEndnotes).getStr())); + (void)xmlTextWriterEndElement(pWriter); + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mbConsiderWrapOnObjPos")); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::boolean(mbConsiderWrapOnObjPos).getStr())); diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx index 19e55d5..0fb3800 100644 --- a/sw/source/core/inc/DocumentSettingManager.hxx +++ b/sw/source/core/inc/DocumentSettingManager.hxx @@ -116,6 +116,7 @@ bool mbAddParaSpacingToTableCells : 1; bool mbUseFormerObjectPos : 1; // #i11860# bool mbUseFormerTextWrapping : 1; + bool mbUseTextWrappingOnHeadersEndnotes : 1; // tdf#104254 bool mbConsiderWrapOnObjPos : 1; // #i28701# // true: object positioning algorithm has consider the wrapping style of // the floating screen objects as given by its attribute 'WrapInfluenceOnObjPos' // floating screen objects as given by its diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 95388db..4f40fd7 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -2760,6 +2760,7 @@ const IDocumentSettingAccess& rIDSA = GetFormat()->getIDocumentSettingAccess(); const bool bWrapAllowed = rIDSA.get(DocumentSettingId::USE_FORMER_TEXT_WRAPPING) || + rIDSA.get(DocumentSettingId::USE_TEXT_WRAPPING_ON_HEADERS_ENDNOTES) || ( !IsInFootnote() && nullptr == FindFooterOrHeader() ); if ( pPage->GetSortedObjs() && bWrapAllowed ) diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx index db792e4..46ba4a4 100644 --- a/sw/source/core/text/txtfly.cxx +++ b/sw/source/core/text/txtfly.cxx @@ -840,6 +840,7 @@ // #i40155# - check, if frame is marked not to wrap const bool bAllowCompatWrap = m_pCurrFrame->IsInTab() && (bFooterHeader || m_pCurrFrame->IsInFootnote()); const bool bWrapAllowed = ( pIDSA->get(DocumentSettingId::USE_FORMER_TEXT_WRAPPING) || + pIDSA->get(DocumentSettingId::USE_TEXT_WRAPPING_ON_HEADERS_ENDNOTES) || bAllowCompatWrap || (!m_pCurrFrame->IsInFootnote() && !bFooterHeader)); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 818e3b0..d295aa5 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1883,6 +1883,7 @@ m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION, true); m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::USE_FORMER_TEXT_WRAPPING, false); // #i13832#, #i24135# + m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::USE_TEXT_WRAPPING_ON_HEADERS_ENDNOTES, false); m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::TABLE_ROW_KEEP, true); //SetTableRowKeep( true ); diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx index 8a8caaa..01a7c00 100644 --- a/sw/source/uibase/uno/SwXDocumentSettings.cxx +++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx @@ -98,6 +98,7 @@ HANDLE_ADD_PARA_LINE_SPACING_TO_TABLE_CELLS, HANDLE_USE_FORMER_OBJECT_POSITIONING, HANDLE_USE_FORMER_TEXT_WRAPPING, + HANDLE_USE_TEXT_WRAPPING_ON_HEADERS_ENDNOTES, HANDLE_CHANGES_PASSWORD, HANDLE_CONSIDER_WRAP_ON_OBJPOS, HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, @@ -193,6 +194,7 @@ { OUString("AddParaLineSpacingToTableCells"), HANDLE_ADD_PARA_LINE_SPACING_TO_TABLE_CELLS, cppu::UnoType::get(), 0}, { OUString("UseFormerObjectPositioning"), HANDLE_USE_FORMER_OBJECT_POSITIONING, cppu::UnoType::get(), 0}, { OUString("UseFormerTextWrapping"), HANDLE_USE_FORMER_TEXT_WRAPPING, cppu::UnoType::get(), 0}, + { OUString("UseTextWrappingOnHeadersEndnotes"), HANDLE_USE_TEXT_WRAPPING_ON_HEADERS_ENDNOTES, cppu::UnoType::get(), 0}, { OUString("RedlineProtectionKey"), HANDLE_CHANGES_PASSWORD, cppu::UnoType< cppu::UnoSequenceType >::get(), 0}, { OUString("ConsiderTextWrapOnObjPos"), HANDLE_CONSIDER_WRAP_ON_OBJPOS, cppu::UnoType::get(), 0}, { OUString("IgnoreFirstLineIndentInNumbering"), HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, cppu::UnoType::get(), 0}, @@ -655,6 +657,12 @@ mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::USE_FORMER_TEXT_WRAPPING, bTmp); } break; + case HANDLE_USE_TEXT_WRAPPING_ON_HEADERS_ENDNOTES: + { + bool bTmp = *o3tl::doAccess(rValue); + mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::USE_TEXT_WRAPPING_ON_HEADERS_ENDNOTES, bTmp); + } + break; case HANDLE_CHANGES_PASSWORD: { Sequence aNew; @@ -1261,6 +1269,11 @@ rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::USE_FORMER_TEXT_WRAPPING); } break; + case HANDLE_USE_TEXT_WRAPPING_ON_HEADERS_ENDNOTES: + { + rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::USE_TEXT_WRAPPING_ON_HEADERS_ENDNOTES); + } + break; case HANDLE_CHANGES_PASSWORD: { rValue <<= mpDoc->getIDocumentRedlineAccess().GetRedlinePassword(); diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx index 732b96f..155c536 100644 --- a/writerfilter/source/dmapper/SettingsTable.cxx +++ b/writerfilter/source/dmapper/SettingsTable.cxx @@ -542,10 +542,12 @@ if (GetWordCompatibilityMode() <= 14) { + //RTF and DOCX <= 2010 uno::Reference xTextFactory(xDoc, uno::UNO_QUERY_THROW); uno::Reference xDocumentSettings(xTextFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY_THROW); xDocumentSettings->setPropertyValue("MsWordCompMinLineHeightByFly", uno::makeAny(true)); xDocumentSettings->setPropertyValue("TabOverMargin", uno::makeAny(true)); + xDocumentSettings->setPropertyValue("UseTextWrappingOnHeadersEndnotes", uno::makeAny(false)); } // Show changes value diff --git a/writerfilter/source/filter/WriterFilter.cxx b/writerfilter/source/filter/WriterFilter.cxx index f546446..c05810c 100644 --- a/writerfilter/source/filter/WriterFilter.cxx +++ b/writerfilter/source/filter/WriterFilter.cxx @@ -314,6 +314,7 @@ xSettings->setPropertyValue("UseFormerObjectPositioning", uno::makeAny(false)); xSettings->setPropertyValue("ConsiderTextWrapOnObjPos", uno::makeAny(true)); xSettings->setPropertyValue("UseFormerTextWrapping", uno::makeAny(false)); + xSettings->setPropertyValue("UseTextWrappingOnHeadersEndnotes", uno::makeAny(true)); xSettings->setPropertyValue("TableRowKeep", uno::makeAny(true)); xSettings->setPropertyValue("IgnoreTabsAndBlanksForLineCalculation", uno::makeAny(true)); xSettings->setPropertyValue("InvertBorderSpacing", uno::makeAny(true));