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/.
10 from uitest
.framework
import UITestCase
11 from uitest
.uihelper
.common
import get_state_as_dict
, get_url_for_data_file
12 from libreoffice
.calc
.document
import get_sheet_from_doc
13 from libreoffice
.calc
.conditional_format
import get_conditional_format_from_sheet
14 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
16 #Bug 100793 - FORMATTING - conditional formatting gets corrupted upon copy/paste/insert
17 class tdf100793(UITestCase
):
18 def test_tdf100793(self
):
20 with self
.ui_test
.load_file(get_url_for_data_file("tdf100793.ods")) as calc_doc
:
21 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
22 gridwin
= xCalcDoc
.getChild("grid_window")
24 sheet
= get_sheet_from_doc(calc_doc
, 2)
25 conditional_format_list
= get_conditional_format_from_sheet(sheet
)
26 self
.assertEqual(conditional_format_list
.getLength(), 1)
27 #2) Go to sheet "plan"
28 gridwin
.executeAction("SELECT", mkPropertyValues({"TABLE": "2"}))
29 #3) Open the conditional formatting management dialog-> The indicated range should be G18:K29,F18,F20:F29
30 with self
.ui_test
.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog", close_button
="") as xCondFormatMgr
:
32 # check that we have exactly one conditional formats in the beginning
33 xList
= xCondFormatMgr
.getChild("CONTAINER")
34 list_state
= get_state_as_dict(xList
)
35 self
.assertEqual(list_state
['Children'], '1')
37 #3) Click Edit & try to change to intended one, F18:K33
38 xEditBtn
= xCondFormatMgr
.getChild("edit")
39 with self
.ui_test
.execute_dialog_through_action(xEditBtn
, "CLICK", event_name
= "ModelessDialogVisible") as xCondFormatDlg
:
42 xedassign
= xCondFormatDlg
.getChild("edassign")
44 xedassign
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "END"}))
45 xedassign
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "HOME"}))
47 xedassign
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"}))
48 xedassign
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"}))
49 xedassign
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"}))
50 xedassign
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"}))
51 xedassign
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"}))
52 xedassign
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"}))
53 xedassign
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"}))
54 xedassign
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"}))
55 xedassign
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"}))
56 xedassign
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"}))
57 xedassign
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"}))
58 #now I'm at F18 - write :K33
59 xedassign
.executeAction("TYPE", mkPropertyValues({"TEXT":":K33"}))
61 # we need to get a pointer again as the old window has been deleted
62 xCondFormatMgr
= self
.xUITest
.getTopFocusWindow()
64 # check again that we still have 1 entry in the list
65 # and still only 1 conditional format in the document
66 xList
= xCondFormatMgr
.getChild("CONTAINER")
67 list_state
= get_state_as_dict(xList
)
68 self
.assertEqual(list_state
['Children'], '1')
70 self
.assertEqual(conditional_format_list
.getLength(), 1)
72 # close the conditional format manager
73 xOKBtn
= xCondFormatMgr
.getChild("ok")
74 self
.ui_test
.close_dialog_through_button(xOKBtn
)
76 #verify - reopen, check range
77 with self
.ui_test
.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog", close_button
="") as xCondFormatMgr
:
78 xEditBtn
= xCondFormatMgr
.getChild("edit")
79 with self
.ui_test
.execute_dialog_through_action(xEditBtn
, "CLICK", event_name
= "ModelessDialogVisible") as xCondFormatDlg
:
80 xedassign
= xCondFormatDlg
.getChild("edassign")
81 self
.assertEqual(get_state_as_dict(xedassign
)["Text"], "G18:K29,F18:K33,F20:F29")
83 xCondFormatMgr
= self
.xUITest
.getTopFocusWindow()
84 xCancelBtn
= xCondFormatMgr
.getChild("cancel")
85 self
.ui_test
.close_dialog_through_button(xCancelBtn
)
87 # vim: set shiftwidth=4 softtabstop=4 expandtab: