[Libreoffice-commits] core.git: sw/qa sw/source
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jul 5 08:09:56 UTC 2019
sw/qa/extras/uiwriter/data2/tdf120338.docx |binary
sw/qa/extras/uiwriter/uiwriter2.cxx | 29 ++++++++++++++++++++++++
sw/source/core/doc/DocumentRedlineManager.cxx | 31 ++++++++++++++++++++++++++
3 files changed, 60 insertions(+)
New commits:
commit 05526a206cc8a273771b2e6aae1fd3c4092cbf03
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Thu Jul 4 15:23:26 2019 +0200
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Fri Jul 5 10:09:05 2019 +0200
tdf#120338 DOCX: add rejection of paragraph formatting changes
using imported change tracking data, instead of doing nothing
for the user request.
Change-Id: I37775ae2d9b78fe3a31541a331f686af9ca9094f
Reviewed-on: https://gerrit.libreoffice.org/75089
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth at numbertext.org>
diff --git a/sw/qa/extras/uiwriter/data2/tdf120338.docx b/sw/qa/extras/uiwriter/data2/tdf120338.docx
new file mode 100644
index 000000000000..94e0023cea7f
Binary files /dev/null and b/sw/qa/extras/uiwriter/data2/tdf120338.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index dfa98003007b..64352b08f5fd 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -1649,4 +1649,33 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testImageCommentAtChar)
pDoc->getIDocumentMarkAccess()->getAnnotationMarksCount());
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf120338)
+{
+ load(DATA_DIRECTORY, "tdf120338.docx");
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1),
+ getProperty<sal_Int32>(getParagraph(2), "ParaAdjust")); // right
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1),
+ getProperty<sal_Int32>(getParagraph(3), "ParaAdjust")); // right
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
+ getProperty<sal_Int32>(getParagraph(4), "ParaAdjust")); // left
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1),
+ getProperty<sal_Int32>(getParagraph(5), "ParaAdjust")); // right
+
+ // reject tracked paragraph adjustments
+ lcl_dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {});
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
+ getProperty<sal_Int32>(getParagraph(2), "ParaAdjust")); // left
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3),
+ getProperty<sal_Int32>(getParagraph(3), "ParaAdjust")); // center
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3),
+ getProperty<sal_Int32>(getParagraph(4), "ParaAdjust")); // center
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
+ getProperty<sal_Int32>(getParagraph(5), "ParaAdjust")); // left
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index e46de6b0b648..d2d0adde11d4 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -648,6 +648,7 @@ namespace
case RedlineType::Format:
case RedlineType::FmtColl:
+ case RedlineType::ParagraphFormat:
{
// tdf#52391 instead of hidden acception at the requested
// rejection, remove direct text formatting to get the potential
@@ -659,6 +660,36 @@ namespace
SwPaM aPam( *(pRedl->Start()), *(pRedl->End()) );
rDoc.ResetAttrs(aPam);
}
+ else if ( pRedl->GetType() == RedlineType::ParagraphFormat )
+ {
+ // handle paragraph formatting changes
+ // (range is only a full paragraph or a part of it)
+ const SwPosition* pStt = pRedl->Start();
+ SwTextNode* pTNd = pStt->nNode.GetNode().GetTextNode();
+ if( pTNd )
+ {
+ // expand range to the whole paragraph
+ // and reset only the paragraph attributes
+ SwPaM aPam( *pTNd, pTNd->GetText().getLength() );
+ std::set<sal_uInt16> aResetAttrsArray;
+
+ sal_uInt16 aResetableSetRange[] = {
+ RES_PARATR_LINESPACING, RES_PARATR_OUTLINELEVEL,
+ RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1,
+ 0
+ };
+
+ const sal_uInt16 *pUShorts = aResetableSetRange;
+ while (*pUShorts)
+ {
+ for (sal_uInt16 i = pUShorts[0]; i <= pUShorts[1]; ++i)
+ aResetAttrsArray.insert( aResetAttrsArray.end(), i );
+ pUShorts += 2;
+ }
+
+ rDoc.ResetAttrs(aPam, false, aResetAttrsArray);
+ }
+ }
if( pRedl->GetExtraData() )
pRedl->GetExtraData()->Reject( *pRedl );
More information about the Libreoffice-commits
mailing list