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
.common
import get_state_as_dict
11 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
13 class printRange(UITestCase
):
14 def test_printRange(self
):
15 with self
.ui_test
.create_doc_in_start_center("calc"):
16 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
17 gridwin
= xCalcDoc
.getChild("grid_window")
19 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F20"}))
21 self
.xUITest
.executeCommand(".uno:DefinePrintArea")
23 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:EditPrintArea") as xDialog
:
24 xlbprintarea
= xDialog
.getChild("lbprintarea")
25 xedprintarea
= xDialog
.getChild("edprintarea")
27 self
.assertEqual(get_state_as_dict(xlbprintarea
)["SelectEntryText"], "- selection -")
28 self
.assertEqual(get_state_as_dict(xedprintarea
)["Text"], "$A$1:$F$20")
30 xedrepeatrow
= xDialog
.getChild("edrepeatrow")
31 xedrepeatrow
.executeAction("TYPE", mkPropertyValues({"TEXT":"$1"}))
33 xedrepeatcol
= xDialog
.getChild("edrepeatcol")
34 xedrepeatcol
.executeAction("TYPE", mkPropertyValues({"TEXT":"$A"}))
37 #Verify Print Range dialog
38 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:EditPrintArea", close_button
="cancel") as xDialog
:
39 xedprintarea
= xDialog
.getChild("edprintarea")
40 xedrepeatrow
= xDialog
.getChild("edrepeatrow")
41 xedrepeatcol
= xDialog
.getChild("edrepeatcol")
42 self
.assertEqual(get_state_as_dict(xedprintarea
)["Text"], "$A$1:$F$20")
43 self
.assertEqual(get_state_as_dict(xedrepeatrow
)["Text"], "$1")
44 self
.assertEqual(get_state_as_dict(xedrepeatcol
)["Text"], "$A")
47 self
.xUITest
.executeCommand(".uno:DeletePrintArea")
48 #Verify Print Range dialog
49 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:EditPrintArea") as xDialog
:
50 xedprintarea
= xDialog
.getChild("edprintarea")
51 xlbprintarea
= xDialog
.getChild("lbprintarea")
52 xedrepeatrow
= xDialog
.getChild("edrepeatrow")
53 xedrepeatcol
= xDialog
.getChild("edrepeatcol")
54 self
.assertEqual(get_state_as_dict(xedprintarea
)["Text"], "")
55 self
.assertEqual(get_state_as_dict(xlbprintarea
)["SelectEntryText"], "- entire sheet -")
56 self
.assertEqual(get_state_as_dict(xedrepeatrow
)["Text"], "$1")
57 self
.assertEqual(get_state_as_dict(xedrepeatcol
)["Text"], "$A")
59 def test_tdf33341_copy_sheet_with_print_range(self
):
60 with self
.ui_test
.create_doc_in_start_center("calc"):
61 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
62 gridwin
= xCalcDoc
.getChild("grid_window")
64 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F20"}))
66 self
.xUITest
.executeCommand(".uno:DefinePrintArea")
68 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:EditPrintArea") as xDialog
:
69 xlbprintarea
= xDialog
.getChild("lbprintarea")
70 xedprintarea
= xDialog
.getChild("edprintarea")
72 self
.assertEqual(get_state_as_dict(xlbprintarea
)["SelectEntryText"], "- selection -")
73 self
.assertEqual(get_state_as_dict(xedprintarea
)["Text"], "$A$1:$F$20")
75 xedrepeatrow
= xDialog
.getChild("edrepeatrow")
76 xedrepeatrow
.executeAction("TYPE", mkPropertyValues({"TEXT":"$1"}))
78 xedrepeatcol
= xDialog
.getChild("edrepeatcol")
79 xedrepeatcol
.executeAction("TYPE", mkPropertyValues({"TEXT":"$A"}))
83 with self
.ui_test
.execute_dialog_through_command(".uno:Move"):
85 #Verify Print Range dialog on new sheet
86 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:EditPrintArea") as xDialog
:
87 xedprintarea
= xDialog
.getChild("edprintarea")
88 xedrepeatrow
= xDialog
.getChild("edrepeatrow")
89 xedrepeatcol
= xDialog
.getChild("edrepeatcol")
90 self
.assertEqual(get_state_as_dict(xedprintarea
)["Text"], "$A$1:$F$20")
91 self
.assertEqual(get_state_as_dict(xedrepeatrow
)["Text"], "$1")
92 self
.assertEqual(get_state_as_dict(xedrepeatcol
)["Text"], "$A")
95 # vim: set shiftwidth=4 softtabstop=4 expandtab: