sw/qa/uitest/writer_tests/trackedChanges.py |   42 ++++++++++++++++++++++++++++
 sw/source/filter/ww8/ww8atr.cxx             |    5 ++-
 2 files changed, 46 insertions(+), 1 deletion(-)

New commits:
commit 17e0439119695faf9b23526e47d58cd41d1cb996
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Thu Apr 20 20:56:10 2023 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Apr 21 12:10:03 2023 +0200

    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 <nem...@numbertext.org>
    (cherry picked from commit ac668aadcc35755dd84933c409362123c0c996d2)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150723
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/qa/uitest/writer_tests/trackedChanges.py 
b/sw/qa/uitest/writer_tests/trackedChanges.py
index 592c839fcd18..761f6d810722 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 b1e4b8a9e750..4a9779591d87 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -1080,7 +1080,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))
             {

Reply via email to