diff options
author | László Németh <nemeth@numbertext.org> | 2023-04-20 20:56:10 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2023-04-21 10:54:01 +0200 |
commit | 77ce7aaa30d20abc1e6221a60ce5e69a52bfaf19 (patch) | |
tree | f70839ea3890289259c2dadda936d635a8067175 /sw | |
parent | e6a08aa351815b7be3bd094320c589026582454b (diff) |
tdf#153016 sw DOC: don't export automatic redline comments
DOC format doesn't support comments of change tracking, so DOC
export converts them to annotations. But skip this conversion
in case of automatic redline comments of tracked annotations
("Commend added" and "Comment deleted") to avoid of double
annotations (the original tracked annotation and the newly
added annotation of the comment of the change tracking).
Regression from commit 3a14b2040ecd95a23acbc3e8d0f8087505135f11
"tdf#148032 sw: add redline comment for tracked comments"
Change-Id: I563859d203886a7f81f6a9e1f164ea5524d80d1f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150735
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/uitest/writer_tests/trackedChanges.py | 42 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 5 |
2 files changed, 46 insertions, 1 deletions
diff --git a/sw/qa/uitest/writer_tests/trackedChanges.py b/sw/qa/uitest/writer_tests/trackedChanges.py index 0599f8bc6f11..a76cfe5dbe36 100644 --- a/sw/qa/uitest/writer_tests/trackedChanges.py +++ b/sw/qa/uitest/writer_tests/trackedChanges.py @@ -347,6 +347,48 @@ class trackedchanges(UITestCase): # This was False (missing comment) self.assertEqual(True, get_state_as_dict(xChild)["Text"].endswith('\tComment added')) + + def get_annotation_count(self, document): + n = 0 + textfields = document.getTextFields() + for textfield in textfields: + if textfield.supportsService("com.sun.star.text.TextField.Annotation"): + n = n + 1 + return n + + def test_tdf153016_annotation_in_DOC(self): + # load a test document, and add a tracked comment + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, 'temp_drop_down_form_field.doc') + + with self.ui_test.load_file(get_url_for_data_file('drop_down_form_field.doc')) as document: + + self.xUITest.executeCommand(".uno:TrackChanges") + self.xUITest.executeCommand('.uno:SelectAll') + + self.assertEqual(0, self.get_annotation_count(document)) + + self.xUITest.executeCommand('.uno:InsertAnnotation') + + self.assertEqual(1, self.get_annotation_count(document)) + + # Save Copy as + with self.ui_test.execute_dialog_through_command('.uno:SaveAs', close_button="") as xDialog: + xFileName = xDialog.getChild('file_name') + xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'CTRL+A'})) + xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'BACKSPACE'})) + xFileName.executeAction('TYPE', mkPropertyValues({'TEXT': xFilePath})) + + xOpen = xDialog.getChild("open") + # DOC confirmation dialog is displayed + with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="save"): + pass + + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document: + # This was 2 + self.assertEqual(1, self.get_annotation_count(document)) + + def test_tdf147179(self): with self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as document: xWriterDoc = self.xUITest.getTopFocusWindow() diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 54c4c4a52f8c..4ba85a21bbee 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -1106,7 +1106,10 @@ void WW8AttributeOutput::StartRun( const SwRedlineData* pRedlineData, sal_Int32 { const OUString &rComment = pRedlineData->GetComment(); //Only possible to export to main text - if (!rComment.isEmpty() && (m_rWW8Export.m_nTextTyp == TXT_MAINTEXT)) + if (!rComment.isEmpty() && (m_rWW8Export.m_nTextTyp == TXT_MAINTEXT) && + // tdf#153016 don't export the new automatic comments added by tdf#148032 + rComment != SwResId(STR_REDLINE_COMMENT_DELETED) && + rComment != SwResId(STR_REDLINE_COMMENT_ADDED)) { if (m_rWW8Export.m_pAtn->IsNewRedlineComment(pRedlineData)) { |