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 <jluth@mail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.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 0000000..5c39c06
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf148956_directEndFormatting.docx
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 1833b12..9b40b34 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -85,6 +85,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 d0da99a..528afab 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);