1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 from uitest
.framework
import UITestCase
10 from uitest
.uihelper
.calc
import enter_text_to_cell
11 from uitest
.uihelper
.common
import select_by_text
13 from libreoffice
.calc
.document
import get_cell_by_position
14 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
17 # Bug 39917 - EDITING Find/Replace modifies formula in R1C1 syntax to invalid lowercase
18 class tdf39917(UITestCase
):
19 def test_tdf39917_find_replace_R1C1(self
):
20 with self
.ui_test
.create_doc_in_start_center("calc") as document
:
21 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
22 gridwin
= xCalcDoc
.getChild("grid_window")
23 #* Tools --> Options --> Calc --> Formula --> Syntax = Excel R1C1
24 with self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt
:
26 xPages
= xDialogOpt
.getChild("pages")
27 xCalcEntry
= xPages
.getChild('3') # Calc
28 xCalcEntry
.executeAction("EXPAND", tuple())
29 xCalcFormulaEntry
= xCalcEntry
.getChild('4')
30 xCalcFormulaEntry
.executeAction("SELECT", tuple()) #Formula
32 formulasyntax
= xDialogOpt
.getChild("formulasyntax")
34 select_by_text(formulasyntax
, "Excel R1C1")
37 #1. Create a workbook with 3 sheets: Page1, Page2, Page3.
38 # 2. Tools -> Options -> LibreOffice Calc -> Formula: Set syntax to Excel A1
41 with self
.ui_test
.execute_dialog_through_command(".uno:Insert") as xDialog
:
42 after
= xDialog
.getChild("after")
43 after
.executeAction("CLICK", tuple())
44 nameed
= xDialog
.getChild("nameed")
45 nameed
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
46 nameed
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
47 nameed
.executeAction("TYPE", mkPropertyValues({"TEXT":"Page2"}))
48 with self
.ui_test
.execute_dialog_through_command(".uno:Insert") as xDialog
:
49 after
= xDialog
.getChild("after")
50 after
.executeAction("CLICK", tuple())
51 nameed
= xDialog
.getChild("nameed")
52 nameed
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
53 nameed
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
54 nameed
.executeAction("TYPE", mkPropertyValues({"TEXT":"Page3"}))
55 gridwin
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RIGHT"}))
56 # 3. Type in (for example) B4: =Page2!B4
57 enter_text_to_cell(gridwin
, "B4", "=Page2!RC")
58 # 4. Edit -> Find and Replace
61 # 6. Press Replace all
62 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button
="close") as xDialog
:
63 searchterm
= xDialog
.getChild("searchterm")
64 searchterm
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
65 searchterm
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
66 searchterm
.executeAction("TYPE", mkPropertyValues({"TEXT":"Page2"}))
67 replaceterm
= xDialog
.getChild("replaceterm")
68 replaceterm
.executeAction("TYPE", mkPropertyValues({"TEXT":"Page3"})) #replace textbox
69 replace
= xDialog
.getChild("replace")
70 replace
.executeAction("CLICK", tuple())
71 replace
.executeAction("CLICK", tuple())
74 enter_text_to_cell(gridwin
, "A1", "=FORMULA(R[3]C[1])")
75 self
.assertEqual(get_cell_by_position(document
, 0, 0, 0).getString(), "=Page3!RC")
76 #Give it back Tools --> Options --> Calc --> Formula --> Syntax = Calc A1
77 with self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt
:
79 xPages
= xDialogOpt
.getChild("pages")
80 xCalcEntry
= xPages
.getChild('3') # Calc
81 xCalcEntry
.executeAction("EXPAND", tuple())
82 xCalcFormulaEntry
= xCalcEntry
.getChild('4')
83 xCalcFormulaEntry
.executeAction("SELECT", tuple()) #Formula
85 formulasyntax
= xDialogOpt
.getChild("formulasyntax")
87 select_by_text(formulasyntax
, "Calc A1")
90 # vim: set shiftwidth=4 softtabstop=4 expandtab: