[Libreoffice-commits] core.git: sw/qa sw/source
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jul 3 15:33:50 UTC 2019
sw/qa/extras/uiwriter/data2/tdf126206.docx |binary
sw/qa/extras/uiwriter/uiwriter2.cxx | 30 ++++++++++++++++++++++++++
sw/source/core/doc/DocumentRedlineManager.cxx | 12 +++++-----
sw/source/core/doc/docredln.cxx | 14 ++++++++++--
4 files changed, 48 insertions(+), 8 deletions(-)
New commits:
commit 5322663f8234836a6a4aaaed025c158fd7e8b67a
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Tue Jul 2 18:36:32 2019 +0200
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Wed Jul 3 17:32:40 2019 +0200
tdf#126206 DOCX: add rejection of character formatting changes
using imported change tracking data, instead of
clearing only direct formatting in the modified text range.
See commit 9c4eef7d809ad7d283860c7b47b0f561aa240906
"tdf#52391 reject/clear formatting of format-only changes".
Change-Id: Ie27d5c5bca6d9f30681e8f542f95417e9bb4c266
Reviewed-on: https://gerrit.libreoffice.org/75011
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth at numbertext.org>
diff --git a/sw/qa/extras/uiwriter/data2/tdf126206.docx b/sw/qa/extras/uiwriter/data2/tdf126206.docx
new file mode 100644
index 000000000000..166125e7a738
Binary files /dev/null and b/sw/qa/extras/uiwriter/data2/tdf126206.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 04b2c4df88ba..24e3f3ddec38 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -8,6 +8,7 @@
*/
#include <swmodeltestbase.hxx>
+#include <com/sun/star/awt/FontWeight.hpp>
#include <com/sun/star/frame/DispatchHelper.hpp>
#include <com/sun/star/style/LineSpacing.hpp>
#include <comphelper/propertysequence.hxx>
@@ -1139,6 +1140,35 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf52391)
CPPUNIT_ASSERT_EQUAL(OUString("Portion1Portion2"), xRun->getString());
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf126206)
+{
+ load(DATA_DIRECTORY, "tdf126206.docx");
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ // normal text (it was bold)
+ auto xText = getParagraph(1)->getText();
+ CPPUNIT_ASSERT(xText.is());
+ {
+ auto xCursor(xText->createTextCursorByRange(getRun(getParagraph(1), 2)));
+ CPPUNIT_ASSERT(xCursor.is());
+ CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(xCursor, "CharWeight"));
+ }
+
+ // reject tracked changes
+ lcl_dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {});
+
+ // bold text again
+ xText = getParagraph(1)->getText();
+ CPPUNIT_ASSERT(xText.is());
+ {
+ auto xCursor(xText->createTextCursorByRange(getRun(getParagraph(1), 2)));
+ CPPUNIT_ASSERT(xCursor.is());
+ CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(xCursor, "CharWeight"));
+ }
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf101873)
{
SwDoc* pDoc = createDoc();
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index 30b6b09300b2..e46de6b0b648 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -649,9 +649,6 @@ namespace
case RedlineType::Format:
case RedlineType::FmtColl:
{
- if( pRedl->GetExtraData() )
- pRedl->GetExtraData()->Reject( *pRedl );
-
// tdf#52391 instead of hidden acception at the requested
// rejection, remove direct text formatting to get the potential
// original state of the text (FIXME if the original text
@@ -660,10 +657,13 @@ namespace
if ( pRedl->GetType() == RedlineType::Format )
{
SwPaM aPam( *(pRedl->Start()), *(pRedl->End()) );
- rArr.DeleteAndDestroy( rPos-- );
rDoc.ResetAttrs(aPam);
- } else
- rArr.DeleteAndDestroy( rPos-- );
+ }
+
+ if( pRedl->GetExtraData() )
+ pRedl->GetExtraData()->Reject( *pRedl );
+
+ rArr.DeleteAndDestroy( rPos-- );
}
break;
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 36734eaa0c61..94c903bbc56f 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -913,9 +913,19 @@ SwRedlineExtraData* SwRedlineExtraData_FormattingChanges::CreateNew() const
return new SwRedlineExtraData_FormattingChanges( *this );
}
-void SwRedlineExtraData_FormattingChanges::Reject(SwPaM&) const
+void SwRedlineExtraData_FormattingChanges::Reject(SwPaM& rPam) const
{
- // ToDo: Add 'Reject' logic
+ SwDoc* pDoc = rPam.GetDoc();
+
+ if( m_pSet )
+ {
+ RedlineFlags eOld = pDoc->getIDocumentRedlineAccess().GetRedlineFlags();
+ pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern(eOld & ~RedlineFlags(RedlineFlags::On | RedlineFlags::Ignore));
+
+ pDoc->getIDocumentContentOperations().InsertItemSet(rPam, *GetItemSet());
+
+ pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
+ }
}
bool SwRedlineExtraData_FormattingChanges::operator == ( const SwRedlineExtraData& rExtraData ) const
More information about the Libreoffice-commits
mailing list