summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/uiwriter/data/tdf148956_directEndFormatting.docxbin0 -> 6143 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx21
-rw-r--r--sw/source/core/txtnode/txtedt.cxx3
3 files changed, 23 insertions, 1 deletions
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
--- /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 1833b1220dbd..9b40b3420c9e 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 d0da99a7986c..528afabed561 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);