summaryrefslogtreecommitdiffstats
path: root/sc/qa/uitest/search_replace
diff options
context:
space:
mode:
Diffstat (limited to 'sc/qa/uitest/search_replace')
-rw-r--r--sc/qa/uitest/search_replace/data/tdf106194.odsbin0 -> 7588 bytes
-rw-r--r--sc/qa/uitest/search_replace/data/tdf35020.odsbin0 -> 8270 bytes
-rw-r--r--sc/qa/uitest/search_replace/data/tdf39959.odsbin0 -> 8211 bytes
-rw-r--r--sc/qa/uitest/search_replace/data/tdf44861.odsbin0 -> 12408 bytes
-rw-r--r--sc/qa/uitest/search_replace/replace.py68
-rw-r--r--sc/qa/uitest/search_replace/tdf132097.py39
-rw-r--r--sc/qa/uitest/search_replace/tdf132783.py39
-rw-r--r--sc/qa/uitest/search_replace/tdf35020.py57
-rw-r--r--sc/qa/uitest/search_replace/tdf39917.py111
-rw-r--r--sc/qa/uitest/search_replace/tdf39959.py59
-rw-r--r--sc/qa/uitest/search_replace/tdf44398.py93
-rw-r--r--sc/qa/uitest/search_replace/tdf44861.py59
12 files changed, 525 insertions, 0 deletions
diff --git a/sc/qa/uitest/search_replace/data/tdf106194.ods b/sc/qa/uitest/search_replace/data/tdf106194.ods
new file mode 100644
index 000000000..acc4199f3
--- /dev/null
+++ b/sc/qa/uitest/search_replace/data/tdf106194.ods
Binary files differ
diff --git a/sc/qa/uitest/search_replace/data/tdf35020.ods b/sc/qa/uitest/search_replace/data/tdf35020.ods
new file mode 100644
index 000000000..ef9a5455d
--- /dev/null
+++ b/sc/qa/uitest/search_replace/data/tdf35020.ods
Binary files differ
diff --git a/sc/qa/uitest/search_replace/data/tdf39959.ods b/sc/qa/uitest/search_replace/data/tdf39959.ods
new file mode 100644
index 000000000..971bf877c
--- /dev/null
+++ b/sc/qa/uitest/search_replace/data/tdf39959.ods
Binary files differ
diff --git a/sc/qa/uitest/search_replace/data/tdf44861.ods b/sc/qa/uitest/search_replace/data/tdf44861.ods
new file mode 100644
index 000000000..d4dd9efb4
--- /dev/null
+++ b/sc/qa/uitest/search_replace/data/tdf44861.ods
Binary files differ
diff --git a/sc/qa/uitest/search_replace/replace.py b/sc/qa/uitest/search_replace/replace.py
new file mode 100644
index 000000000..ae28348be
--- /dev/null
+++ b/sc/qa/uitest/search_replace/replace.py
@@ -0,0 +1,68 @@
+# -*- 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.path import get_srcdir_url
+
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from libreoffice.calc.document import get_row
+
+from uitest.uihelper.common import get_state_as_dict
+
+import time
+
+def get_url_for_data_file(file_name):
+ return get_srcdir_url() + "/sc/qa/uitest/search_replace/data/" + file_name
+
+class ReplaceTest(UITestCase):
+
+ def test_tdf106194(self):
+ doc = self.ui_test.load_file(get_url_for_data_file("tdf106194.ods"))
+
+ xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window")
+
+ self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+
+ xSearchDlg = self.xUITest.getTopFocusWindow()
+
+ xSearchTerm = xSearchDlg.getChild("searchterm")
+ xSearchTerm.executeAction("TYPE", mkPropertyValues({"TEXT": "1"}))
+ xReplaceTerm = xSearchDlg.getChild("replaceterm")
+ xReplaceTerm.executeAction("TYPE", mkPropertyValues({"TEXT": "2"}))
+
+ xSearchBtn = xSearchDlg.getChild("search")
+ xSearchBtn.executeAction("CLICK", tuple())
+
+ self.assertEqual(get_state_as_dict(xGridWin)["CurrentRow"], "1")
+ lastTopVisibleRow = int(get_state_as_dict(xGridWin)["TopVisibleRow"])
+
+ # start replacing
+ xReplaceBtn = xSearchDlg.getChild("replace")
+ xReplaceBtn.executeAction("CLICK", tuple())
+
+ # check position and visible range
+ self.assertEqual(get_state_as_dict(xGridWin)["CurrentRow"], "199")
+ currentTopVisibleRow = int(get_state_as_dict(xGridWin)["TopVisibleRow"])
+ self.assertGreater(currentTopVisibleRow, lastTopVisibleRow)
+
+ lastTopVisibleRow = currentTopVisibleRow
+
+ # replace again
+ xReplaceBtn.executeAction("CLICK", tuple())
+
+ # check position and visible range
+ self.assertEqual(get_state_as_dict(xGridWin)["CurrentRow"], "499")
+ currentTopVisibleRow = int(get_state_as_dict(xGridWin)["TopVisibleRow"])
+ self.assertGreater(currentTopVisibleRow, lastTopVisibleRow)
+
+ xReplaceBtn.executeAction("CLICK", tuple())
+
+ xCloseBtn = xSearchDlg.getChild("close")
+
+ self.ui_test.close_dialog_through_button(xCloseBtn)
+
+ self.ui_test.close_doc()
diff --git a/sc/qa/uitest/search_replace/tdf132097.py b/sc/qa/uitest/search_replace/tdf132097.py
new file mode 100644
index 000000000..5585befb6
--- /dev/null
+++ b/sc/qa/uitest/search_replace/tdf132097.py
@@ -0,0 +1,39 @@
+# -*- 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 get_state_as_dict
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+class tdf132097(UITestCase):
+
+ def test_tdf132097(self):
+ calc_doc = self.ui_test.create_doc_in_start_center("calc")
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+
+ self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+ xDialog = self.xUITest.getTopFocusWindow()
+ xCols = xDialog.getChild('cols')
+ xSearchTerm = xDialog.getChild("searchterm")
+ xBackSearch = xDialog.getChild("backsearch")
+ xSeachLabel = xDialog.getChild("searchlabel")
+
+ xCols.executeAction("CLICK", tuple())
+ xSearchTerm.executeAction("TYPE", mkPropertyValues({"TEXT":"TEST"}))
+
+ for i in range(10):
+ # without the fix in place it would crash here.
+ # Sometimes it doesn't crash at first so try a few times to be sure
+ xBackSearch.executeAction("CLICK", tuple())
+
+ self.assertEqual(get_state_as_dict(xSeachLabel)["Text"], "Search key not found")
+
+ xcloseBtn = xDialog.getChild("close")
+ self.ui_test.close_dialog_through_button(xcloseBtn)
+
+ self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/search_replace/tdf132783.py b/sc/qa/uitest/search_replace/tdf132783.py
new file mode 100644
index 000000000..097eaa8c2
--- /dev/null
+++ b/sc/qa/uitest/search_replace/tdf132783.py
@@ -0,0 +1,39 @@
+# -*- 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 get_state_as_dict
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.path import get_srcdir_url
+
+def get_url_for_data_file(file_name):
+ return get_srcdir_url() + "/sc/qa/uitest/calc_tests/data/" + file_name
+
+class tdf132783(UITestCase):
+
+ def test_tdf132783(self):
+ calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf132783.ods"))
+
+ for i in range(5):
+ self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+ xDialog = self.xUITest.getTopFocusWindow()
+ xSearchTerm = xDialog.getChild("searchterm")
+
+ xSearchTerm.executeAction("TYPE", mkPropertyValues({"TEXT":"1"}))
+
+ xSearch = xDialog.getChild("search")
+ xSearch.executeAction("CLICK", tuple())
+
+ xcloseBtn = xDialog.getChild("close")
+ self.ui_test.close_dialog_through_button(xcloseBtn)
+
+ xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window")
+ self.assertEqual(get_state_as_dict(xGridWin)["CurrentRow"], "1")
+ self.assertEqual(get_state_as_dict(xGridWin)["CurrentColumn"], str( 96 + i))
+
+ self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/search_replace/tdf35020.py b/sc/qa/uitest/search_replace/tdf35020.py
new file mode 100644
index 000000000..a0412697e
--- /dev/null
+++ b/sc/qa/uitest/search_replace/tdf35020.py
@@ -0,0 +1,57 @@
+# -*- 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 get_state_as_dict
+from uitest.uihelper.common import select_pos
+from uitest.uihelper.calc import enter_text_to_cell
+from libreoffice.calc.document import get_cell_by_position
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import get_state_as_dict, type_text
+from uitest.debug import sleep
+import org.libreoffice.unotest
+import pathlib
+
+def get_url_for_data_file(file_name):
+ return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
+
+#Bug 35020 - Find and Replace changes case of sheet name in formulas
+
+class tdf35020(UITestCase):
+ def test_tdf39959_find_replace_all_sheets(self):
+ calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf35020.ods"))
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ gridwin = xCalcDoc.getChild("grid_window")
+ document = self.ui_test.get_component()
+
+ self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+ xDialog = self.xUITest.getTopFocusWindow()
+ searchterm = xDialog.getChild("searchterm")
+ searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+ searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+ searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"X6"}))
+ replaceterm = xDialog.getChild("replaceterm")
+ replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"A6"})) #replace textbox
+ allsheets = xDialog.getChild("allsheets")
+ allsheets.executeAction("CLICK", tuple())
+ calcsearchin = xDialog.getChild("calcsearchin")
+ props = {"TEXT": "Formulas"}
+ actionProps = mkPropertyValues(props)
+ calcsearchin.executeAction("SELECT", actionProps)
+ replaceall = xDialog.getChild("replaceall")
+ replaceall.executeAction("CLICK", tuple())
+ xcloseBtn = xDialog.getChild("close")
+ self.ui_test.close_dialog_through_button(xcloseBtn)
+
+ #verify Sheet1.A13 A14 = 2
+ self.assertEqual(get_cell_by_position(document, 0, 0, 12).getValue(), 2)
+ self.assertEqual(get_cell_by_position(document, 0, 0, 13).getValue(), 2)
+ #Undo
+ self.xUITest.executeCommand(".uno:Undo")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 12).getValue(), 1)
+ self.assertEqual(get_cell_by_position(document, 0, 0, 13).getValue(), 1)
+ self.ui_test.close_doc()
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/search_replace/tdf39917.py b/sc/qa/uitest/search_replace/tdf39917.py
new file mode 100644
index 000000000..1af5b9c39
--- /dev/null
+++ b/sc/qa/uitest/search_replace/tdf39917.py
@@ -0,0 +1,111 @@
+# -*- 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 get_state_as_dict
+from uitest.uihelper.common import select_pos
+from uitest.uihelper.calc import enter_text_to_cell
+from libreoffice.calc.document import get_cell_by_position
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import get_state_as_dict, type_text
+from uitest.debug import sleep
+
+#Bug 39917 - EDITING Find/Replace modifies formula in R1C1 syntax to invalid lowercase
+
+class tdf39917(UITestCase):
+ def test_tdf39917_find_replace_R1C1(self):
+ calc_doc = self.ui_test.create_doc_in_start_center("calc")
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ gridwin = xCalcDoc.getChild("grid_window")
+ document = self.ui_test.get_component()
+ #* Tools --> Options --> Calc --> Formula --> Syntax = Excel R1C1
+ self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
+ xDialogOpt = self.xUITest.getTopFocusWindow()
+
+ xPages = xDialogOpt.getChild("pages")
+ xCalcEntry = xPages.getChild('3') # Calc
+ xCalcEntry.executeAction("EXPAND", tuple())
+ xCalcFormulaEntry = xCalcEntry.getChild('4')
+ xCalcFormulaEntry.executeAction("SELECT", tuple()) #Formula
+
+ formulasyntax = xDialogOpt.getChild("formulasyntax")
+ #Excel R1C1
+ props = {"TEXT": "Excel R1C1"}
+ actionProps = mkPropertyValues(props)
+ formulasyntax.executeAction("SELECT", actionProps)
+
+ xOKBtn = xDialogOpt.getChild("ok")
+ self.ui_test.close_dialog_through_button(xOKBtn)
+
+ #1. Create a workbook with 3 sheets: Page1, Page2, Page3.
+ # 2. Tools -> Options -> LibreOffice Calc -> Formula: Set syntax to Excel A1
+ # 5. Fill fields:
+
+ self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet
+ xDialog = self.xUITest.getTopFocusWindow()
+ after = xDialog.getChild("after")
+ after.executeAction("CLICK", tuple())
+ nameed = xDialog.getChild("nameed")
+ nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+ nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+ nameed.executeAction("TYPE", mkPropertyValues({"TEXT":"Page2"}))
+ xOKButton = xDialog.getChild("ok")
+ xOKButton.executeAction("CLICK", tuple())
+ self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet
+ xDialog = self.xUITest.getTopFocusWindow()
+ after = xDialog.getChild("after")
+ after.executeAction("CLICK", tuple())
+ nameed = xDialog.getChild("nameed")
+ nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+ nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+ nameed.executeAction("TYPE", mkPropertyValues({"TEXT":"Page3"}))
+ xOKButton = xDialog.getChild("ok")
+ xOKButton.executeAction("CLICK", tuple())
+ gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RIGHT"}))
+ # 3. Type in (for example) B4: =Page2!B4
+ enter_text_to_cell(gridwin, "B4", "=Page2!RC")
+ # 4. Edit -> Find and Replace
+ # Find: Page2
+ # Replace: Page3
+ # 6. Press Replace all
+ self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+ xDialog = self.xUITest.getTopFocusWindow()
+ searchterm = xDialog.getChild("searchterm")
+ searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+ searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+ searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"Page2"}))
+ replaceterm = xDialog.getChild("replaceterm")
+ replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"Page3"})) #replace textbox
+ replace = xDialog.getChild("replace")
+ replace.executeAction("CLICK", tuple())
+ replace.executeAction("CLICK", tuple())
+ xcloseBtn = xDialog.getChild("close")
+ self.ui_test.close_dialog_through_button(xcloseBtn)
+
+ #verify
+ enter_text_to_cell(gridwin, "A1", "=FORMULA(R[3]C[1])")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "=Page3!RC")
+ #Give it back Tools --> Options --> Calc --> Formula --> Syntax = Calc A1
+ self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
+ xDialogOpt = self.xUITest.getTopFocusWindow()
+
+ xPages = xDialogOpt.getChild("pages")
+ xCalcEntry = xPages.getChild('3') # Calc
+ xCalcEntry.executeAction("EXPAND", tuple())
+ xCalcFormulaEntry = xCalcEntry.getChild('4')
+ xCalcFormulaEntry.executeAction("SELECT", tuple()) #Formula
+
+ formulasyntax = xDialogOpt.getChild("formulasyntax")
+ #Excel R1C1
+ props = {"TEXT": "Calc A1"}
+ actionProps = mkPropertyValues(props)
+ formulasyntax.executeAction("SELECT", actionProps)
+
+ xOKBtn = xDialogOpt.getChild("ok")
+ self.ui_test.close_dialog_through_button(xOKBtn)
+
+ self.ui_test.close_doc()
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/search_replace/tdf39959.py b/sc/qa/uitest/search_replace/tdf39959.py
new file mode 100644
index 000000000..1f7c6a7a7
--- /dev/null
+++ b/sc/qa/uitest/search_replace/tdf39959.py
@@ -0,0 +1,59 @@
+# -*- 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 get_state_as_dict
+from uitest.uihelper.common import select_pos
+from uitest.uihelper.calc import enter_text_to_cell
+from libreoffice.calc.document import get_cell_by_position
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import get_state_as_dict, type_text
+from uitest.debug import sleep
+import org.libreoffice.unotest
+import pathlib
+
+def get_url_for_data_file(file_name):
+ return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
+
+#Bug 39959 - Find-and-replace doesn't search all tables anymore
+
+class tdf39959(UITestCase):
+ def test_tdf39959_find_replace_all_sheets(self):
+ calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf39959.ods"))
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ gridwin = xCalcDoc.getChild("grid_window")
+ document = self.ui_test.get_component()
+
+ # 1. Open a new document
+ # 2. Enter "asdf" in A1
+ # 3. Activate Sheet2
+ # 4. Try Find-and-replace (Ctrl+Alt+F) to search for "asdf"
+ # Whether the checkbox "in allen Tabellen suchen" is activated or not: LibO Calc never seems to find the text
+
+ self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+ xDialog = self.xUITest.getTopFocusWindow()
+ searchterm = xDialog.getChild("searchterm")
+ searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+ searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+ searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"asdf"}))
+ replaceterm = xDialog.getChild("replaceterm")
+ replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"bbb"})) #replace textbox
+ allsheets = xDialog.getChild("allsheets")
+ allsheets.executeAction("CLICK", tuple())
+ replaceall = xDialog.getChild("replaceall")
+ replaceall.executeAction("CLICK", tuple())
+ # print(xDialog.getChildren())
+ xcloseBtn = xDialog.getChild("close")
+ self.ui_test.close_dialog_through_button(xcloseBtn)
+
+ #verify Sheet2.A1 = "bbb"
+ self.assertEqual(get_cell_by_position(document, 1, 0, 0).getString(), "bbb ")
+ self.assertEqual(get_cell_by_position(document, 1, 0, 2).getString(), "abc")
+ #Undo
+ self.xUITest.executeCommand(".uno:Undo")
+ self.assertEqual(get_cell_by_position(document, 1, 0, 0).getString(), "asdf ")
+ self.ui_test.close_doc()
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/search_replace/tdf44398.py b/sc/qa/uitest/search_replace/tdf44398.py
new file mode 100644
index 000000000..c44305cb0
--- /dev/null
+++ b/sc/qa/uitest/search_replace/tdf44398.py
@@ -0,0 +1,93 @@
+# -*- 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 get_state_as_dict
+from uitest.uihelper.common import select_pos
+from uitest.uihelper.calc import enter_text_to_cell
+from libreoffice.calc.document import get_cell_by_position
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import get_state_as_dict, type_text
+from uitest.debug import sleep
+
+#Bug 44398 - : Find, replace, regular expression bug
+
+class tdf44398(UITestCase):
+ def test_tdf44398_find_replace_regexp(self):
+ calc_doc = self.ui_test.create_doc_in_start_center("calc")
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ gridwin = xCalcDoc.getChild("grid_window")
+ document = self.ui_test.get_component()
+
+ # 1. A1 => 123456
+ enter_text_to_cell(gridwin, "A1", "123456")
+ # 2. ctrl-h, in dialog
+ # Search: ([0-9])
+ # Replace: $1
+ # check regular expression
+ # hit replace all
+
+ self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+ xDialog = self.xUITest.getTopFocusWindow()
+ searchterm = xDialog.getChild("searchterm")
+ searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+ searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+ searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"([0-9])"}))
+ replaceterm = xDialog.getChild("replaceterm")
+ replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"$1"})) #replace textbox
+ regexp = xDialog.getChild("regexp")
+ regexp.executeAction("CLICK", tuple()) #regular expressions
+ replaceall = xDialog.getChild("replaceall")
+ replaceall.executeAction("CLICK", tuple())
+ xcloseBtn = xDialog.getChild("close")
+ self.ui_test.close_dialog_through_button(xcloseBtn)
+
+ #verify 3. A1 => 123456
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "123456")
+
+ self.ui_test.close_doc()
+
+ def test_tdf44398_find_replace_regexp_string(self):
+ calc_doc = self.ui_test.create_doc_in_start_center("calc")
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ gridwin = xCalcDoc.getChild("grid_window")
+ document = self.ui_test.get_component()
+
+ # 1. A1 => VarNumberA
+ enter_text_to_cell(gridwin, "A1", "VarNumberA")
+ gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RIGHT"}))
+ # 2. ctrl-h, in dialog
+ # Search: ([A-Z])
+ # Replace: <space>$1
+ # check regular expression
+ # check case
+ # hit replace all
+
+ self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+ xDialog = self.xUITest.getTopFocusWindow()
+ searchterm = xDialog.getChild("searchterm")
+ searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+ searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+ searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"([A-Z])"}))
+ replaceterm = xDialog.getChild("replaceterm")
+ replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":" $1"})) #replace textbox
+ regexp = xDialog.getChild("regexp")
+ if (get_state_as_dict(regexp)["Selected"]) == "false":
+ regexp.executeAction("CLICK", tuple()) #regular expressions
+ matchcase = xDialog.getChild("matchcase")
+ matchcase.executeAction("CLICK", tuple()) #case
+
+ replaceall = xDialog.getChild("replaceall")
+ replaceall.executeAction("CLICK", tuple())
+
+ xcloseBtn = xDialog.getChild("close")
+ self.ui_test.close_dialog_through_button(xcloseBtn)
+
+ #verify A1 => ' Var Number A'
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), " Var Number A")
+
+ self.ui_test.close_doc()
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/search_replace/tdf44861.py b/sc/qa/uitest/search_replace/tdf44861.py
new file mode 100644
index 000000000..de60cab07
--- /dev/null
+++ b/sc/qa/uitest/search_replace/tdf44861.py
@@ -0,0 +1,59 @@
+# -*- 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 get_state_as_dict
+from uitest.uihelper.common import select_pos
+from uitest.uihelper.calc import enter_text_to_cell
+from libreoffice.calc.document import get_cell_by_position
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import get_state_as_dict, type_text
+from uitest.debug import sleep
+import org.libreoffice.unotest
+import pathlib
+
+#Bug 44861 - EDITING: result 'Find&Replace All' wrong for particular Regular Expression
+def get_url_for_data_file(file_name):
+ return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
+
+class tdf44861(UITestCase):
+ def test_tdf44861_find_replaceAll_regexp(self):
+ calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf44861.ods"))
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ gridwin = xCalcDoc.getChild("grid_window")
+ document = self.ui_test.get_component()
+ # 2. ctrl-h, in dialog
+ # Search: ([0-9]{2})([0-9]{2})
+ # Replace: $1.$2
+ # check option "Enable regular expressions"
+ # Press "Replace all"
+
+ self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+ xDialog = self.xUITest.getTopFocusWindow()
+ searchterm = xDialog.getChild("searchterm")
+ searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+ searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+ searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"([0-9]{2})([0-9]{2})"}))
+ replaceterm = xDialog.getChild("replaceterm")
+ replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"$1.$2"})) #replace textbox
+ regexp = xDialog.getChild("regexp")
+ if (get_state_as_dict(regexp)["Selected"]) == "false":
+ regexp.executeAction("CLICK", tuple()) #regular expressions
+ replaceall = xDialog.getChild("replaceall")
+ replaceall.executeAction("CLICK", tuple())
+ xcloseBtn = xDialog.getChild("close")
+ self.ui_test.close_dialog_through_button(xcloseBtn)
+
+ #Expected: instead of 1345-1430 appears 13.45-14.30
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "13.45-14.30")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "13.45-14.30")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "14.50-15.30")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "12.55-13.35")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "12.30-13.40")
+
+ self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab: