sw/inc/fmtautofmt.hxx | 2 - sw/qa/extras/ww8export/data/tdf117994_CRnumformatting.doc |binary sw/qa/extras/ww8export/ww8export4.cxx | 7 ++++ sw/source/core/text/txtfld.cxx | 5 +-- sw/source/filter/ww8/ww8par.cxx | 23 ++++++++++++++ 5 files changed, 34 insertions(+), 3 deletions(-)
New commits: commit 6e1c8bcec511444d2d51c5c5143be56d1900e5e6 Author: Justin Luth <jl...@mail.com> AuthorDate: Sat Sep 3 08:37:19 2022 -0400 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Tue Sep 20 10:53:01 2022 +0200 tdf#150613 sw: better DOC import of paragraph marker formatting Following the lead of LO 6.4 commit 5ba30f588d6e41a13d68b1461345fca7a7ca61ac. This fixes a LO 7.2 regression from tdf#108518. This patch depends on tdf#117994 being fixed in order for ww8export3's testTdf108518_CRnumformatting to round-trip. The problem here is that Word allows formatting the paragraph end marker, and applies the same formatting to the generated numbering string; Writer has no such marker thing. On m_xCtrlStck, the rPos is pointing to the end of the paragraph. GetStackAttr looks for char properties that are still m_bOpen or else where the Point (Mark is the Start, Point is the End) is greater than aPos. Well, at the end of the paragraph I don't think there can be any empty (point==mark) hints in .DOC, so this should only pick up properties that are spilling over onto the CR - just like we want. Change-Id: I06cab075f102d40f93d33fedf5ae0ce8e165e9fa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139329 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/inc/fmtautofmt.hxx b/sw/inc/fmtautofmt.hxx index 5773bffd5329..f4ac2fae7035 100644 --- a/sw/inc/fmtautofmt.hxx +++ b/sw/inc/fmtautofmt.hxx @@ -23,7 +23,7 @@ #include <svl/poolitem.hxx> #include <memory> -class SAL_DLLPUBLIC_RTTI SwFormatAutoFormat final : public SfxPoolItem +class SW_DLLPUBLIC SwFormatAutoFormat final : public SfxPoolItem { std::shared_ptr<SfxItemSet> mpHandle; diff --git a/sw/qa/extras/ww8export/data/tdf117994_CRnumformatting.doc b/sw/qa/extras/ww8export/data/tdf117994_CRnumformatting.doc new file mode 100644 index 000000000000..99744382a82b Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf117994_CRnumformatting.doc differ diff --git a/sw/qa/extras/ww8export/ww8export4.cxx b/sw/qa/extras/ww8export/ww8export4.cxx index e6d1d27f53a4..22ed17e6f849 100644 --- a/sw/qa/extras/ww8export/ww8export4.cxx +++ b/sw/qa/extras/ww8export/ww8export4.cxx @@ -64,6 +64,13 @@ DECLARE_WW8EXPORT_TEST(testTdf150197_anlv2ListFormat, "tdf150197_anlv2ListFormat getProperty<OUString>(getParagraph(4), "ListLabelString")); } +DECLARE_WW8EXPORT_TEST(testTdf117994_CRnumformatting, "tdf117994_CRnumformatting.doc") +{ + CPPUNIT_ASSERT_EQUAL(OUString("1."), parseDump("//body/txt[1]/Special[@nType='PortionType::Number']", "rText")); + //Without this fix in place, it would become 200 (and non-bold). + CPPUNIT_ASSERT_EQUAL(OUString("160"), parseDump("//body/txt[1]/Special[@nType='PortionType::Number']", "nHeight")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx index 22875f247210..22127dd30e21 100644 --- a/sw/source/core/text/txtfld.cxx +++ b/sw/source/core/text/txtfld.cxx @@ -432,9 +432,10 @@ static void checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm SwFormatAutoFormat const& rListAutoFormat(rInf.GetTextFrame()->GetTextNodeForParaProps()->GetAttr(RES_PARATR_LIST_AUTOFMT)); std::shared_ptr<SfxItemSet> pSet(rListAutoFormat.GetStyleHandle()); - // TODO remove this fallback (for WW8/RTF) + // TODO remove this fallback for RTF + bool isDOC = pIDSA->get(DocumentSettingId::ADD_FLY_OFFSETS); bool isDOCX = pIDSA->get(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS); - if (!isDOCX && !pSet) + if (!isDOC && !isDOCX && !pSet) { TextFrameIndex const nTextLen(rInf.GetTextFrame()->GetText().getLength()); SwTextNode const* pNode(nullptr); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 77805814fc46..82dec7f3105d 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -103,6 +103,7 @@ #include <swtable.hxx> #include <fchrfmt.hxx> #include <charfmt.hxx> +#include <fmtautofmt.hxx> #include <IDocumentSettingAccess.hxx> #include "sprmids.hxx" @@ -121,6 +122,7 @@ #include <svl/lngmisc.hxx> #include <svl/itemiter.hxx> +#include <svl/whiter.hxx> #include <comphelper/indexedpropertyvalues.hxx> #include <comphelper/processfactory.hxx> @@ -2423,6 +2425,27 @@ void SwWW8ImplReader::AppendTextNode(SwPosition& rPos) if (pText != nullptr) pRule = sw::util::GetNumRuleFromTextNode(*pText); + // tdf#64222 / tdf#150613 filter out the "paragraph marker" formatting and + // set it as a separate paragraph property, just like we do for DOCX. + // This is only being used for numbering currently, so limiting to that context. + if (pRule) + { + SfxItemSetFixed<RES_CHRATR_BEGIN, RES_CHRATR_END - 1, RES_TXTATR_CHARFMT, + RES_TXTATR_CHARFMT, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END - 1> + items(m_pPaM->GetDoc().GetAttrPool()); + + SfxWhichIter aIter(items); + for (sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich()) + { + const SfxPoolItem* pItem = m_xCtrlStck->GetStackAttr(rPos, nWhich); + if (pItem) + items.Put(*pItem); + } + SwFormatAutoFormat item(RES_PARATR_LIST_AUTOFMT); + item.SetStyleHandle(std::make_shared<SfxItemSet>(items)); + pText->SetAttr(item); + } + if ( pRule && !m_xWDop->fDontUseHTMLAutoSpacing && (m_bParaAutoBefore || m_bParaAutoAfter)