summaryrefslogtreecommitdiff
path: root/sw/qa/uitest
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2021-06-14 20:46:17 +0200
committerLászló Németh <nemeth@numbertext.org>2021-06-17 10:43:08 +0200
commit12da70f88517bf3c053afe1c504bb70bd27573f2 (patch)
tree27097e4bb9cc343ece830f77991b5d5220ea2ff3 /sw/qa/uitest
parent68eb62b9bf8a64d892b3cfa58447e7c890ed3ec4 (diff)
tdf#90401 xmloff: remove personal info of comments and changes
If Options → LibreOffice → Security → Security Options and Warnings → Options... → Security Options → Remove personal information on saving" is enabled. Use the same time (1970-01-01T00:00:00) for mandatory time stamps, and replace authors and creator-initials with "1", "2", "3" etc., also to avoid of joining adjacent redline ranges. Note: to see the work of the unit test in Linux command line: (cd sw && make UITest_writer_tests7 UITEST_TEST_NAME="tdf90401.tdf90401.test_tdf90401_remove_personal_info" SAL_USE_VCLPLUGIN=gen) Change-Id: I3b4d710dbeeee12177aff378597cd2b683ca6c25 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117319 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa/uitest')
-rw-r--r--sw/qa/uitest/data/redline-autocorrect.fodt24
-rw-r--r--sw/qa/uitest/writer_tests7/tdf90401.py103
2 files changed, 127 insertions, 0 deletions
diff --git a/sw/qa/uitest/data/redline-autocorrect.fodt b/sw/qa/uitest/data/redline-autocorrect.fodt
new file mode 100644
index 000000000000..ce874d299a8f
--- /dev/null
+++ b/sw/qa/uitest/data/redline-autocorrect.fodt
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:officeooo="http://openoffice.org/2009/office" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text" xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <office:styles>
+ <style:style style:name="Standard" style:family="paragraph" style:class="text"/>
+ <style:default-style style:family="paragraph">
+ <style:text-properties fo:language="en" fo:country="US"/>
+ </style:default-style>
+ </office:styles>
+ <office:body>
+ <office:text>
+ <text:tracked-changes text:track-changes="false">
+ <text:changed-region xml:id="ct94099223789984" text:id="ct94099223789984">
+ <text:deletion>
+ <office:change-info>
+ <dc:creator>NL</dc:creator>
+ <dc:date>2020-11-03T19:19:05</dc:date>
+ </office:change-info>
+ </text:deletion>
+ </text:changed-region>
+ </text:tracked-changes>
+ <text:p text:style-name="P1"><text:change-start text:change-id="ct94099223789984"/>t<text:change-end text:change-id="ct94099223789984"/>s</text:p>
+ </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/uitest/writer_tests7/tdf90401.py b/sw/qa/uitest/writer_tests7/tdf90401.py
new file mode 100644
index 000000000000..7260ae914268
--- /dev/null
+++ b/sw/qa/uitest/writer_tests7/tdf90401.py
@@ -0,0 +1,103 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from uitest.framework import UITestCase
+#from uitest.uihelper.common import type_text
+from uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.common import get_url_for_data_file
+from uitest.uihelper.common import select_pos
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from org.libreoffice.unotest import systemPathToFileUrl
+from tempfile import TemporaryDirectory
+import os.path
+#Bug 90401 - remove personal info on redlines and annotations
+
+class tdf90401(UITestCase):
+
+ def test_tdf90401_remove_personal_info(self):
+
+ # load a test document with a tracked change, and add a comment
+
+ writer_doc = self.ui_test.load_file(get_url_for_data_file('redline-autocorrect.fodt'))
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild('writer_edit')
+
+ document = self.ui_test.get_component()
+ selection = self.xUITest.executeCommand('.uno:SelectAll')
+ self.xUITest.executeCommand('.uno:InsertAnnotation')
+
+ # enable remove personal info security option
+
+ self.ui_test.execute_dialog_through_command('.uno:OptionsTreeDialog') #optionsdialog
+ xDialog = self.xUITest.getTopFocusWindow()
+
+ xPages = xDialog.getChild('pages')
+ xGenEntry = xPages.getChild('0')
+ xSecurityPage = xGenEntry.getChild('6')
+ xSecurityPage.executeAction('SELECT', tuple())
+ # Click Button Options...
+ xOptions = xDialog.getChild('options')
+ def handle_options_dlg(dialog):
+ xRemovePersonal = dialog.getChild('removepersonal')
+ xRemovePersonal.executeAction('CLICK', tuple())
+ #Click on its button Close
+ xOkBtn = dialog.getChild('ok')
+ xOkBtn.executeAction('CLICK', tuple())
+
+ self.ui_test.execute_blocking_action(xOptions.executeAction, args=('CLICK', ()),
+ dialog_handler=handle_options_dlg)
+
+ xOKBtn = xDialog.getChild('ok')
+ self.ui_test.close_dialog_through_button(xOKBtn)
+
+ # save and reload the document to remove personal info
+
+ with TemporaryDirectory() as tempdir:
+ xFilePath = os.path.join(tempdir, 'tdf90401-tmp.fodt')
+
+ # Save Copy as
+ self.ui_test.execute_dialog_through_command('.uno:SaveAs')
+ xDialog = self.xUITest.getTopFocusWindow()
+
+ xFileName = xDialog.getChild('file_name')
+ xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'CTRL+A'}))
+ xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'BACKSPACE'}))
+ xFileName.executeAction('TYPE', mkPropertyValues({'TEXT': xFilePath}))
+
+ xOpenBtn = xDialog.getChild('open')
+ self.ui_test.close_dialog_through_button(xOpenBtn)
+
+ # Close the Writer document
+ self.ui_test.close_doc()
+
+ self.ui_test.load_file(systemPathToFileUrl(xFilePath))
+ document = self.ui_test.get_component()
+
+ # check removed personal info on comments
+
+ textfields = document.getTextFields()
+ author = ""
+ year = -1
+ for textfield in textfields:
+ if textfield.supportsService("com.sun.star.text.TextField.Annotation"):
+ author = textfield.Author
+ year = textfield.Date.Year
+ # This was 'Unknown Author'
+ self.assertEqual(author, 'Author2')
+ # This was 2021
+ self.assertEqual(year, 0)
+
+ # check removed personal info on tracked changes
+
+ self.ui_test.execute_modeless_dialog_through_command('.uno:AcceptTrackedChanges')
+ xTrackDlg = self.xUITest.getTopFocusWindow()
+ xTreeList = xTrackDlg.getChild('writerchanges')
+ state = get_state_as_dict(xTreeList)
+ # This was 'NL\t11/03/2020 19:19:05\t', containing personal info
+ self.assertEqual(state['SelectEntryText'], 'Author1\t01/01/1970 00:00:00\t')
+
+ self.ui_test.close_doc()
+# vim: set shiftwidth=4 softtabstop=4 expandtab: