sw/qa/extras/uiwriter/data/tdf148956_directEndFormatting.docx |binary sw/qa/extras/uiwriter/uiwriter2.cxx | 21 ++++++++++ sw/source/core/txtnode/txtedt.cxx | 3 - 3 files changed, 23 insertions(+), 1 deletion(-)
New commits: commit aa46c5e153791b891300557e4928a642438b3fc7 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Tue May 2 20:05:41 2023 -0400 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri May 5 10:54:16 2023 +0200 tdf#148956 sw: clear nAttrStart == paraEnd hints in DOCX I don't think that native Writer will create a character property at the end of a paragraph. (I couldn't do it manually or by round-tripping a problematic DOCX file.) However, DOCX does need to do this. However, a Ctrl-M to clear direct formatting was not clearing out those attributes (that don't span any text, but just sit at the end of the node). This patch fixes that problem. Change-Id: I6bd93fc145d226f785287e6991b7ea6e3fcd1c9b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151306 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151390 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/sw/qa/extras/uiwriter/data/tdf148956_directEndFormatting.docx b/sw/qa/extras/uiwriter/data/tdf148956_directEndFormatting.docx new file mode 100644 index 000000000000..5c39c067231e Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf148956_directEndFormatting.docx differ diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 151a910a0bb0..9d8e7e082338 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -100,6 +100,27 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf47471_paraStyleBackground) getProperty<OUString>(getParagraph(3), "ParaStyleName")); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf148956_directEndFormatting) +{ + createSwDoc("tdf148956_directEndFormatting.docx"); + SwDoc* pDoc = getSwDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + + pWrtShell->EndPara(/*bSelect=*/true); + CPPUNIT_ASSERT_MESSAGE( + "Has direct formatting", + pWrtShell->GetCursor()->GetMark()->GetNode().GetTextNode()->GetpSwpHints()); + + dispatchCommand(mxComponent, ".uno:ResetAttributes", {}); + + dispatchCommand(mxComponent, ".uno:GotoStartOfPara", {}); + dispatchCommand(mxComponent, ".uno:GotoEndOfPara", {}); + + CPPUNIT_ASSERT_MESSAGE( + "Direct formatting cleared", + !pWrtShell->GetCursor()->GetMark()->GetNode().GetTextNode()->GetpSwpHints()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdfChangeNumberingListAutoFormat) { createSwDoc("tdf117923.docx"); diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index 51c8528e2e19..91fdcfdc0a20 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -436,7 +436,8 @@ void SwTextNode::RstTextAttr( SwTextAttr *pHt = nullptr; while ( (i < m_pSwpHints->Count()) && ( ( ( nAttrStart = m_pSwpHints->GetWithoutResorting(i)->GetStart()) < nEnd ) - || nLen==0 ) && !bExactRange) + || nLen==0 || (nEnd == nAttrStart && nAttrStart == m_Text.getLength())) + && !bExactRange) { pHt = m_pSwpHints->GetWithoutResorting(i);