1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 from uitest
.framework
import UITestCase
8 from uitest
.uihelper
.common
import get_state_as_dict
9 from uitest
.uihelper
.common
import select_pos
10 from uitest
.uihelper
.calc
import enter_text_to_cell
11 from libreoffice
.calc
.document
import get_sheet_from_doc
12 from libreoffice
.calc
.conditional_format
import get_conditional_format_from_sheet
13 from uitest
.debug
import sleep
14 from libreoffice
.calc
.document
import get_cell_by_position
15 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
16 import org
.libreoffice
.unotest
18 #text to column testcase
20 def get_url_for_data_file(file_name
):
21 return pathlib
.Path(org
.libreoffice
.unotest
.makeCopyFromTDOC(file_name
)).as_uri()
24 class CalcTextToColumns(UITestCase
):
26 def test_text_to_columns_dot(self
):
28 calc_doc
= self
.ui_test
.load_file(get_url_for_data_file("text_to_columns_dot.ods"))
29 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
30 gridwin
= xCalcDoc
.getChild("grid_window")
31 document
= self
.ui_test
.get_component()
32 #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged.
33 self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
34 xDialogOpt
= self
.xUITest
.getTopFocusWindow()
36 xPages
= xDialogOpt
.getChild("pages")
37 xWriterEntry
= xPages
.getChild('3') # Calc
38 xWriterEntry
.executeAction("EXPAND", tuple())
39 xWriterGeneralEntry
= xWriterEntry
.getChild('0')
40 xWriterGeneralEntry
.executeAction("SELECT", tuple()) #General / replwarncb
41 xreplwarncb
= xDialogOpt
.getChild("replwarncb")
42 print(get_state_as_dict(xreplwarncb
)["Selected"])
43 if (get_state_as_dict(xreplwarncb
)["Selected"]) == "false":
44 xreplwarncb
.executeAction("CLICK", tuple())
45 print(get_state_as_dict(xreplwarncb
)["Selected"])
46 xOKBtn
= xDialogOpt
.getChild("ok")
47 self
.ui_test
.close_dialog_through_button(xOKBtn
)
49 #Select A1:A5 on Sheet 'Dot_as_Separator'
50 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"}))
51 #Data - Text to Columns
52 self
.ui_test
.execute_dialog_through_command(".uno:TextToColumns")
53 xDialog
= self
.xUITest
.getTopFocusWindow()
54 #Untag Tab as separator and tag other. Put a dot into the input field next to the other checkbox
55 xtab
= xDialog
.getChild("tab")
56 xcomma
= xDialog
.getChild("comma")
57 xsemicolon
= xDialog
.getChild("semicolon")
58 xspace
= xDialog
.getChild("space")
59 xother
= xDialog
.getChild("other")
60 xinputother
= xDialog
.getChild("inputother")
62 if (get_state_as_dict(xother
)["Selected"]) == "false":
63 xother
.executeAction("CLICK", tuple())
64 xinputother
.executeAction("TYPE", mkPropertyValues({"TEXT":"."}))
66 #Does an overwrite warning come up? If not file an Issue.
67 #Tag the 'Do not show warning again' checkbox and press Ok.
68 xOK
= xDialog
.getChild("ok")
69 def handle_warn_dlg(dialog
):
70 xyesBtn
= dialog
.getChild("yes")
71 xask
= dialog
.getChild("ask")
72 xask
.executeAction("CLICK", tuple())
73 self
.ui_test
.close_dialog_through_button(xyesBtn
)
75 self
.ui_test
.execute_blocking_action(xOK
.executeAction
, args
=('CLICK', ()),
76 dialog_handler
=handle_warn_dlg
)
78 self
.assertEqual(get_cell_by_position(document
, 0, 0, 0).getValue(), 1)
79 self
.assertEqual(get_cell_by_position(document
, 0, 0, 1).getValue(), 2)
80 self
.assertEqual(get_cell_by_position(document
, 0, 0, 2).getValue(), 3)
81 self
.assertEqual(get_cell_by_position(document
, 0, 0, 3).getValue(), 4)
82 self
.assertEqual(get_cell_by_position(document
, 0, 0, 4).getValue(), 5)
83 self
.assertEqual(get_cell_by_position(document
, 0, 1, 0).getValue(), 2)
84 self
.assertEqual(get_cell_by_position(document
, 0, 1, 1).getValue(), 2)
85 self
.assertEqual(get_cell_by_position(document
, 0, 1, 2).getValue(), 2)
86 self
.assertEqual(get_cell_by_position(document
, 0, 1, 3).getValue(), 2)
87 self
.assertEqual(get_cell_by_position(document
, 0, 1, 4).getValue(), 2)
88 self
.assertEqual(get_cell_by_position(document
, 0, 2, 0).getValue(), 3)
89 self
.assertEqual(get_cell_by_position(document
, 0, 2, 1).getValue(), 3)
90 self
.assertEqual(get_cell_by_position(document
, 0, 2, 2).getValue(), 3)
91 self
.assertEqual(get_cell_by_position(document
, 0, 2, 3).getValue(), 3)
92 self
.assertEqual(get_cell_by_position(document
, 0, 2, 4).getValue(), 3)
93 self
.assertEqual(get_cell_by_position(document
, 0, 3, 0).getValue(), 4)
94 self
.assertEqual(get_cell_by_position(document
, 0, 3, 1).getValue(), 4)
95 self
.assertEqual(get_cell_by_position(document
, 0, 3, 2).getValue(), 4)
96 self
.assertEqual(get_cell_by_position(document
, 0, 3, 3).getValue(), 4)
97 self
.assertEqual(get_cell_by_position(document
, 0, 3, 4).getValue(), 4)
98 self
.assertEqual(get_cell_by_position(document
, 0, 4, 0).getValue(), 5)
99 self
.assertEqual(get_cell_by_position(document
, 0, 4, 1).getValue(), 5)
100 self
.assertEqual(get_cell_by_position(document
, 0, 4, 2).getValue(), 5)
101 self
.assertEqual(get_cell_by_position(document
, 0, 4, 3).getValue(), 5)
102 self
.assertEqual(get_cell_by_position(document
, 0, 4, 4).getValue(), 5)
103 self
.assertEqual(get_cell_by_position(document
, 0, 5, 0).getValue(), 6)
104 self
.assertEqual(get_cell_by_position(document
, 0, 5, 1).getValue(), 6)
105 self
.assertEqual(get_cell_by_position(document
, 0, 5, 2).getValue(), 6)
106 self
.assertEqual(get_cell_by_position(document
, 0, 5, 3).getValue(), 6)
107 self
.assertEqual(get_cell_by_position(document
, 0, 5, 4).getValue(), 6)
108 self
.assertEqual(get_cell_by_position(document
, 0, 6, 0).getString(), "random content")
109 self
.assertEqual(get_cell_by_position(document
, 0, 6, 1).getValue(), 0)
110 self
.assertEqual(get_cell_by_position(document
, 0, 6, 2).getValue(), 0)
111 self
.assertEqual(get_cell_by_position(document
, 0, 6, 3).getValue(), 0)
112 self
.assertEqual(get_cell_by_position(document
, 0, 6, 4).getString(), "random content")
113 #verify setting in options
114 self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
115 xDialogOpt
= self
.xUITest
.getTopFocusWindow()
117 xPages
= xDialogOpt
.getChild("pages")
118 xWriterEntry
= xPages
.getChild('3') # Calc
119 xWriterEntry
.executeAction("EXPAND", tuple())
120 xWriterGeneralEntry
= xWriterEntry
.getChild('0')
121 xWriterGeneralEntry
.executeAction("SELECT", tuple()) #General / replwarncb
122 xreplwarncb
= xDialogOpt
.getChild("replwarncb")
123 self
.assertEqual(get_state_as_dict(xreplwarncb
)["Selected"], "false")
124 xOKBtn
= xDialogOpt
.getChild("ok")
125 self
.ui_test
.close_dialog_through_button(xOKBtn
)
127 self
.ui_test
.close_doc()
129 def test_text_to_columns_comma(self
):
131 calc_doc
= self
.ui_test
.load_file(get_url_for_data_file("text_to_columns_comma.ods"))
132 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
133 gridwin
= xCalcDoc
.getChild("grid_window")
134 document
= self
.ui_test
.get_component()
135 #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged.
136 self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
137 xDialogOpt
= self
.xUITest
.getTopFocusWindow()
139 xPages
= xDialogOpt
.getChild("pages")
140 xWriterEntry
= xPages
.getChild('3') # Calc
141 xWriterEntry
.executeAction("EXPAND", tuple())
142 xWriterGeneralEntry
= xWriterEntry
.getChild('0')
143 xWriterGeneralEntry
.executeAction("SELECT", tuple()) #General / replwarncb
144 xreplwarncb
= xDialogOpt
.getChild("replwarncb")
145 print(get_state_as_dict(xreplwarncb
)["Selected"])
146 if (get_state_as_dict(xreplwarncb
)["Selected"]) == "false":
147 xreplwarncb
.executeAction("CLICK", tuple())
148 print(get_state_as_dict(xreplwarncb
)["Selected"])
149 xOKBtn
= xDialogOpt
.getChild("ok")
150 self
.ui_test
.close_dialog_through_button(xOKBtn
)
153 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"}))
154 # Data - Text to Columns
155 self
.ui_test
.execute_dialog_through_command(".uno:TextToColumns")
156 xDialog
= self
.xUITest
.getTopFocusWindow()
157 # Untag Tab as separator and tag comma.
158 xComma
= xDialog
.getChild("comma")
159 if (get_state_as_dict(xComma
)["Selected"]) == "false":
160 xComma
.executeAction("CLICK", tuple())
162 xOK
= xDialog
.getChild("ok")
163 def handle_warn_dlg(dialog
):
164 xyesBtn
= dialog
.getChild("yes")
165 self
.ui_test
.close_dialog_through_button(xyesBtn
)
167 self
.ui_test
.execute_blocking_action(xOK
.executeAction
, args
=('CLICK', ()),
168 dialog_handler
=handle_warn_dlg
)
170 self
.assertEqual(get_cell_by_position(document
, 0, 0, 0).getValue(), 1)
171 self
.assertEqual(get_cell_by_position(document
, 0, 0, 1).getValue(), 2)
172 self
.assertEqual(get_cell_by_position(document
, 0, 0, 2).getValue(), 3)
173 self
.assertEqual(get_cell_by_position(document
, 0, 0, 3).getValue(), 4)
174 self
.assertEqual(get_cell_by_position(document
, 0, 0, 4).getValue(), 5)
175 self
.assertEqual(get_cell_by_position(document
, 0, 1, 0).getValue(), 2)
176 self
.assertEqual(get_cell_by_position(document
, 0, 1, 1).getValue(), 2)
177 self
.assertEqual(get_cell_by_position(document
, 0, 1, 2).getValue(), 2)
178 self
.assertEqual(get_cell_by_position(document
, 0, 1, 3).getValue(), 2)
179 self
.assertEqual(get_cell_by_position(document
, 0, 1, 4).getValue(), 2)
180 self
.assertEqual(get_cell_by_position(document
, 0, 2, 0).getValue(), 3)
181 self
.assertEqual(get_cell_by_position(document
, 0, 2, 1).getValue(), 3)
182 self
.assertEqual(get_cell_by_position(document
, 0, 2, 2).getValue(), 3)
183 self
.assertEqual(get_cell_by_position(document
, 0, 2, 3).getValue(), 3)
184 self
.assertEqual(get_cell_by_position(document
, 0, 2, 4).getValue(), 3)
185 self
.assertEqual(get_cell_by_position(document
, 0, 3, 0).getValue(), 4)
186 self
.assertEqual(get_cell_by_position(document
, 0, 3, 1).getValue(), 4)
187 self
.assertEqual(get_cell_by_position(document
, 0, 3, 2).getValue(), 4)
188 self
.assertEqual(get_cell_by_position(document
, 0, 3, 3).getValue(), 4)
189 self
.assertEqual(get_cell_by_position(document
, 0, 3, 4).getValue(), 4)
190 self
.assertEqual(get_cell_by_position(document
, 0, 4, 0).getValue(), 5)
191 self
.assertEqual(get_cell_by_position(document
, 0, 4, 1).getValue(), 5)
192 self
.assertEqual(get_cell_by_position(document
, 0, 4, 2).getValue(), 5)
193 self
.assertEqual(get_cell_by_position(document
, 0, 4, 3).getValue(), 5)
194 self
.assertEqual(get_cell_by_position(document
, 0, 4, 4).getValue(), 5)
195 self
.assertEqual(get_cell_by_position(document
, 0, 5, 0).getValue(), 6)
196 self
.assertEqual(get_cell_by_position(document
, 0, 5, 1).getValue(), 6)
197 self
.assertEqual(get_cell_by_position(document
, 0, 5, 2).getValue(), 6)
198 self
.assertEqual(get_cell_by_position(document
, 0, 5, 3).getValue(), 6)
199 self
.assertEqual(get_cell_by_position(document
, 0, 5, 4).getValue(), 6)
200 self
.assertEqual(get_cell_by_position(document
, 0, 6, 0).getString(), "random content")
201 self
.assertEqual(get_cell_by_position(document
, 0, 6, 1).getValue(), 0)
202 self
.assertEqual(get_cell_by_position(document
, 0, 6, 2).getValue(), 0)
203 self
.assertEqual(get_cell_by_position(document
, 0, 6, 3).getValue(), 0)
204 self
.assertEqual(get_cell_by_position(document
, 0, 6, 4).getString(), "random content")
206 self
.ui_test
.close_doc()
207 def test_text_to_columns_semicolon(self
):
208 #Semicolon as Separator
209 calc_doc
= self
.ui_test
.load_file(get_url_for_data_file("text_to_columns_semicolon.ods"))
210 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
211 gridwin
= xCalcDoc
.getChild("grid_window")
212 document
= self
.ui_test
.get_component()
213 #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged.
214 self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
215 xDialogOpt
= self
.xUITest
.getTopFocusWindow()
217 xPages
= xDialogOpt
.getChild("pages")
218 xWriterEntry
= xPages
.getChild('3') # Calc
219 xWriterEntry
.executeAction("EXPAND", tuple())
220 xWriterGeneralEntry
= xWriterEntry
.getChild('0')
221 xWriterGeneralEntry
.executeAction("SELECT", tuple()) #General / replwarncb
222 xreplwarncb
= xDialogOpt
.getChild("replwarncb")
223 if (get_state_as_dict(xreplwarncb
)["Selected"]) == "false":
224 xreplwarncb
.executeAction("CLICK", tuple())
225 xOKBtn
= xDialogOpt
.getChild("ok")
226 self
.ui_test
.close_dialog_through_button(xOKBtn
)
228 # Select A1:A5 on Sheet
229 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"}))
230 # Data - Text to Columns
231 self
.ui_test
.execute_dialog_through_command(".uno:TextToColumns")
232 xDialog
= self
.xUITest
.getTopFocusWindow()
233 # Untag comma as separator and tag Semicolon
234 xSemicolon
= xDialog
.getChild("semicolon")
235 if (get_state_as_dict(xSemicolon
)["Selected"]) == "false":
236 xSemicolon
.executeAction("CLICK", tuple())
238 xOK
= xDialog
.getChild("ok")
239 def handle_warn_dlg(dialog
):
240 xyesBtn
= dialog
.getChild("yes")
241 self
.ui_test
.close_dialog_through_button(xyesBtn
)
243 self
.ui_test
.execute_blocking_action(xOK
.executeAction
, args
=('CLICK', ()),
244 dialog_handler
=handle_warn_dlg
)
246 self
.assertEqual(get_cell_by_position(document
, 0, 0, 0).getValue(), 1)
247 self
.assertEqual(get_cell_by_position(document
, 0, 0, 1).getValue(), 2)
248 self
.assertEqual(get_cell_by_position(document
, 0, 0, 2).getValue(), 3)
249 self
.assertEqual(get_cell_by_position(document
, 0, 0, 3).getValue(), 4)
250 self
.assertEqual(get_cell_by_position(document
, 0, 0, 4).getValue(), 5)
251 self
.assertEqual(get_cell_by_position(document
, 0, 1, 0).getValue(), 2)
252 self
.assertEqual(get_cell_by_position(document
, 0, 1, 1).getValue(), 2)
253 self
.assertEqual(get_cell_by_position(document
, 0, 1, 2).getValue(), 2)
254 self
.assertEqual(get_cell_by_position(document
, 0, 1, 3).getValue(), 2)
255 self
.assertEqual(get_cell_by_position(document
, 0, 1, 4).getValue(), 2)
256 self
.assertEqual(get_cell_by_position(document
, 0, 2, 0).getValue(), 3)
257 self
.assertEqual(get_cell_by_position(document
, 0, 2, 1).getValue(), 3)
258 self
.assertEqual(get_cell_by_position(document
, 0, 2, 2).getValue(), 3)
259 self
.assertEqual(get_cell_by_position(document
, 0, 2, 3).getValue(), 3)
260 self
.assertEqual(get_cell_by_position(document
, 0, 2, 4).getValue(), 3)
261 self
.assertEqual(get_cell_by_position(document
, 0, 3, 0).getValue(), 4)
262 self
.assertEqual(get_cell_by_position(document
, 0, 3, 1).getValue(), 4)
263 self
.assertEqual(get_cell_by_position(document
, 0, 3, 2).getValue(), 4)
264 self
.assertEqual(get_cell_by_position(document
, 0, 3, 3).getValue(), 4)
265 self
.assertEqual(get_cell_by_position(document
, 0, 3, 4).getValue(), 4)
266 self
.assertEqual(get_cell_by_position(document
, 0, 4, 0).getValue(), 5)
267 self
.assertEqual(get_cell_by_position(document
, 0, 4, 1).getValue(), 5)
268 self
.assertEqual(get_cell_by_position(document
, 0, 4, 2).getValue(), 5)
269 self
.assertEqual(get_cell_by_position(document
, 0, 4, 3).getValue(), 5)
270 self
.assertEqual(get_cell_by_position(document
, 0, 4, 4).getValue(), 5)
271 self
.assertEqual(get_cell_by_position(document
, 0, 5, 0).getValue(), 6)
272 self
.assertEqual(get_cell_by_position(document
, 0, 5, 1).getValue(), 6)
273 self
.assertEqual(get_cell_by_position(document
, 0, 5, 2).getValue(), 6)
274 self
.assertEqual(get_cell_by_position(document
, 0, 5, 3).getValue(), 6)
275 self
.assertEqual(get_cell_by_position(document
, 0, 5, 4).getValue(), 6)
276 self
.assertEqual(get_cell_by_position(document
, 0, 6, 0).getString(), "random content")
277 self
.assertEqual(get_cell_by_position(document
, 0, 6, 1).getValue(), 0)
278 self
.assertEqual(get_cell_by_position(document
, 0, 6, 2).getValue(), 0)
279 self
.assertEqual(get_cell_by_position(document
, 0, 6, 3).getValue(), 0)
280 self
.assertEqual(get_cell_by_position(document
, 0, 6, 4).getString(), "random content")
281 self
.ui_test
.close_doc()
283 def test_text_to_columns_space(self
):
285 calc_doc
= self
.ui_test
.load_file(get_url_for_data_file("text_to_columns_space.ods"))
286 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
287 gridwin
= xCalcDoc
.getChild("grid_window")
288 document
= self
.ui_test
.get_component()
289 #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged.
290 self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
291 xDialogOpt
= self
.xUITest
.getTopFocusWindow()
293 xPages
= xDialogOpt
.getChild("pages")
294 xWriterEntry
= xPages
.getChild('3') # Calc
295 xWriterEntry
.executeAction("EXPAND", tuple())
296 xWriterGeneralEntry
= xWriterEntry
.getChild('0')
297 xWriterGeneralEntry
.executeAction("SELECT", tuple()) #General / replwarncb
298 xreplwarncb
= xDialogOpt
.getChild("replwarncb")
299 if (get_state_as_dict(xreplwarncb
)["Selected"]) == "false":
300 xreplwarncb
.executeAction("CLICK", tuple())
301 xOKBtn
= xDialogOpt
.getChild("ok")
302 self
.ui_test
.close_dialog_through_button(xOKBtn
)
304 # Select A1:A5 on Sheet
305 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"}))
306 # Data - Text to Columns
307 self
.ui_test
.execute_dialog_through_command(".uno:TextToColumns")
308 xDialog
= self
.xUITest
.getTopFocusWindow()
309 # Untag comma as separator and tag Semicolon
310 xSpace
= xDialog
.getChild("space")
311 if (get_state_as_dict(xSpace
)["Selected"]) == "false":
312 xSpace
.executeAction("CLICK", tuple())
313 # xspace.executeAction("CLICK", tuple())
315 xOK
= xDialog
.getChild("ok")
316 def handle_warn_dlg(dialog
):
317 xyesBtn
= dialog
.getChild("yes")
318 self
.ui_test
.close_dialog_through_button(xyesBtn
)
320 self
.ui_test
.execute_blocking_action(xOK
.executeAction
, args
=('CLICK', ()),
321 dialog_handler
=handle_warn_dlg
)
323 self
.assertEqual(get_cell_by_position(document
, 0, 0, 0).getValue(), 1)
324 self
.assertEqual(get_cell_by_position(document
, 0, 0, 1).getValue(), 2)
325 self
.assertEqual(get_cell_by_position(document
, 0, 0, 2).getValue(), 3)
326 self
.assertEqual(get_cell_by_position(document
, 0, 0, 3).getValue(), 4)
327 self
.assertEqual(get_cell_by_position(document
, 0, 0, 4).getValue(), 5)
328 self
.assertEqual(get_cell_by_position(document
, 0, 1, 0).getValue(), 2)
329 self
.assertEqual(get_cell_by_position(document
, 0, 1, 1).getValue(), 2)
330 self
.assertEqual(get_cell_by_position(document
, 0, 1, 2).getValue(), 2)
331 self
.assertEqual(get_cell_by_position(document
, 0, 1, 3).getValue(), 2)
332 self
.assertEqual(get_cell_by_position(document
, 0, 1, 4).getValue(), 2)
333 self
.assertEqual(get_cell_by_position(document
, 0, 2, 0).getValue(), 3)
334 self
.assertEqual(get_cell_by_position(document
, 0, 2, 1).getValue(), 3)
335 self
.assertEqual(get_cell_by_position(document
, 0, 2, 2).getValue(), 3)
336 self
.assertEqual(get_cell_by_position(document
, 0, 2, 3).getValue(), 3)
337 self
.assertEqual(get_cell_by_position(document
, 0, 2, 4).getValue(), 3)
338 self
.assertEqual(get_cell_by_position(document
, 0, 3, 0).getValue(), 4)
339 self
.assertEqual(get_cell_by_position(document
, 0, 3, 1).getValue(), 4)
340 self
.assertEqual(get_cell_by_position(document
, 0, 3, 2).getValue(), 4)
341 self
.assertEqual(get_cell_by_position(document
, 0, 3, 3).getValue(), 4)
342 self
.assertEqual(get_cell_by_position(document
, 0, 3, 4).getValue(), 4)
343 self
.assertEqual(get_cell_by_position(document
, 0, 4, 0).getValue(), 5)
344 self
.assertEqual(get_cell_by_position(document
, 0, 4, 1).getValue(), 5)
345 self
.assertEqual(get_cell_by_position(document
, 0, 4, 2).getValue(), 5)
346 self
.assertEqual(get_cell_by_position(document
, 0, 4, 3).getValue(), 5)
347 self
.assertEqual(get_cell_by_position(document
, 0, 4, 4).getValue(), 5)
348 self
.assertEqual(get_cell_by_position(document
, 0, 5, 0).getValue(), 6)
349 self
.assertEqual(get_cell_by_position(document
, 0, 5, 1).getValue(), 6)
350 self
.assertEqual(get_cell_by_position(document
, 0, 5, 2).getValue(), 6)
351 self
.assertEqual(get_cell_by_position(document
, 0, 5, 3).getValue(), 6)
352 self
.assertEqual(get_cell_by_position(document
, 0, 5, 4).getValue(), 6)
353 self
.assertEqual(get_cell_by_position(document
, 0, 6, 0).getString(), "random content")
354 self
.assertEqual(get_cell_by_position(document
, 0, 6, 1).getValue(), 0)
355 self
.assertEqual(get_cell_by_position(document
, 0, 6, 2).getValue(), 0)
356 self
.assertEqual(get_cell_by_position(document
, 0, 6, 3).getValue(), 0)
357 self
.assertEqual(get_cell_by_position(document
, 0, 6, 4).getString(), "random content")
358 self
.ui_test
.close_doc()
360 def test_text_to_columns_pipe(self
):
362 calc_doc
= self
.ui_test
.load_file(get_url_for_data_file("text_to_columns_pipe.ods"))
363 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
364 gridwin
= xCalcDoc
.getChild("grid_window")
365 document
= self
.ui_test
.get_component()
366 #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged.
367 self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
368 xDialogOpt
= self
.xUITest
.getTopFocusWindow()
370 xPages
= xDialogOpt
.getChild("pages")
371 xWriterEntry
= xPages
.getChild('3') # Calc
372 xWriterEntry
.executeAction("EXPAND", tuple())
373 xWriterGeneralEntry
= xWriterEntry
.getChild('0')
374 xWriterGeneralEntry
.executeAction("SELECT", tuple()) #General / replwarncb
375 xreplwarncb
= xDialogOpt
.getChild("replwarncb")
376 if (get_state_as_dict(xreplwarncb
)["Selected"]) == "false":
377 xreplwarncb
.executeAction("CLICK", tuple())
378 xOKBtn
= xDialogOpt
.getChild("ok")
379 self
.ui_test
.close_dialog_through_button(xOKBtn
)
381 # Select A1:A5 on Sheet
382 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"}))
383 # Data - Text to Columns
384 self
.ui_test
.execute_dialog_through_command(".uno:TextToColumns")
385 xDialog
= self
.xUITest
.getTopFocusWindow()
386 # Untag comma as separator and tag Semicolon
387 xtab
= xDialog
.getChild("tab")
388 xcomma
= xDialog
.getChild("comma")
389 xsemicolon
= xDialog
.getChild("semicolon")
390 xspace
= xDialog
.getChild("space")
391 xother
= xDialog
.getChild("other")
392 xinputother
= xDialog
.getChild("inputother")
393 xSpace
= xDialog
.getChild("space")
394 if (get_state_as_dict(xother
)["Selected"]) == "false":
395 xother
.executeAction("CLICK", tuple())
396 xinputother
.executeAction("TYPE", mkPropertyValues({"TEXT":"|"}))
398 xOK
= xDialog
.getChild("ok")
399 def handle_warn_dlg(dialog
):
400 xyesBtn
= dialog
.getChild("yes")
401 self
.ui_test
.close_dialog_through_button(xyesBtn
)
403 self
.ui_test
.execute_blocking_action(xOK
.executeAction
, args
=('CLICK', ()),
404 dialog_handler
=handle_warn_dlg
)
406 self
.assertEqual(get_cell_by_position(document
, 0, 0, 0).getValue(), 1)
407 self
.assertEqual(get_cell_by_position(document
, 0, 0, 1).getValue(), 2)
408 self
.assertEqual(get_cell_by_position(document
, 0, 0, 2).getValue(), 3)
409 self
.assertEqual(get_cell_by_position(document
, 0, 0, 3).getValue(), 4)
410 self
.assertEqual(get_cell_by_position(document
, 0, 0, 4).getValue(), 5)
411 self
.assertEqual(get_cell_by_position(document
, 0, 1, 0).getValue(), 2)
412 self
.assertEqual(get_cell_by_position(document
, 0, 1, 1).getValue(), 2)
413 self
.assertEqual(get_cell_by_position(document
, 0, 1, 2).getValue(), 2)
414 self
.assertEqual(get_cell_by_position(document
, 0, 1, 3).getValue(), 2)
415 self
.assertEqual(get_cell_by_position(document
, 0, 1, 4).getValue(), 2)
416 self
.assertEqual(get_cell_by_position(document
, 0, 2, 0).getValue(), 3)
417 self
.assertEqual(get_cell_by_position(document
, 0, 2, 1).getValue(), 3)
418 self
.assertEqual(get_cell_by_position(document
, 0, 2, 2).getValue(), 3)
419 self
.assertEqual(get_cell_by_position(document
, 0, 2, 3).getValue(), 3)
420 self
.assertEqual(get_cell_by_position(document
, 0, 2, 4).getValue(), 3)
421 self
.assertEqual(get_cell_by_position(document
, 0, 3, 0).getValue(), 4)
422 self
.assertEqual(get_cell_by_position(document
, 0, 3, 1).getValue(), 4)
423 self
.assertEqual(get_cell_by_position(document
, 0, 3, 2).getValue(), 4)
424 self
.assertEqual(get_cell_by_position(document
, 0, 3, 3).getValue(), 4)
425 self
.assertEqual(get_cell_by_position(document
, 0, 3, 4).getValue(), 4)
426 self
.assertEqual(get_cell_by_position(document
, 0, 4, 0).getValue(), 5)
427 self
.assertEqual(get_cell_by_position(document
, 0, 4, 1).getValue(), 5)
428 self
.assertEqual(get_cell_by_position(document
, 0, 4, 2).getValue(), 5)
429 self
.assertEqual(get_cell_by_position(document
, 0, 4, 3).getValue(), 5)
430 self
.assertEqual(get_cell_by_position(document
, 0, 4, 4).getValue(), 5)
431 self
.assertEqual(get_cell_by_position(document
, 0, 5, 0).getValue(), 6)
432 self
.assertEqual(get_cell_by_position(document
, 0, 5, 1).getValue(), 6)
433 self
.assertEqual(get_cell_by_position(document
, 0, 5, 2).getValue(), 6)
434 self
.assertEqual(get_cell_by_position(document
, 0, 5, 3).getValue(), 6)
435 self
.assertEqual(get_cell_by_position(document
, 0, 5, 4).getValue(), 6)
436 self
.assertEqual(get_cell_by_position(document
, 0, 6, 0).getString(), "random content")
437 self
.assertEqual(get_cell_by_position(document
, 0, 6, 1).getValue(), 0)
438 self
.assertEqual(get_cell_by_position(document
, 0, 6, 2).getValue(), 0)
439 self
.assertEqual(get_cell_by_position(document
, 0, 6, 3).getValue(), 0)
440 self
.assertEqual(get_cell_by_position(document
, 0, 6, 4).getString(), "random content")
441 self
.ui_test
.close_doc()
443 def test_text_to_columns_pipespace(self
):
445 calc_doc
= self
.ui_test
.load_file(get_url_for_data_file("text_to_columns_pipe_space.ods"))
446 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
447 gridwin
= xCalcDoc
.getChild("grid_window")
448 document
= self
.ui_test
.get_component()
449 #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged.
450 self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
451 xDialogOpt
= self
.xUITest
.getTopFocusWindow()
453 xPages
= xDialogOpt
.getChild("pages")
454 xWriterEntry
= xPages
.getChild('3') # Calc
455 xWriterEntry
.executeAction("EXPAND", tuple())
456 xWriterGeneralEntry
= xWriterEntry
.getChild('0')
457 xWriterGeneralEntry
.executeAction("SELECT", tuple()) #General / replwarncb
458 xreplwarncb
= xDialogOpt
.getChild("replwarncb")
459 if (get_state_as_dict(xreplwarncb
)["Selected"]) == "false":
460 xreplwarncb
.executeAction("CLICK", tuple())
461 xOKBtn
= xDialogOpt
.getChild("ok")
462 self
.ui_test
.close_dialog_through_button(xOKBtn
)
464 # Select A1:A5 on Sheet
465 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"}))
466 # Data - Text to Columns
467 self
.ui_test
.execute_dialog_through_command(".uno:TextToColumns")
468 xDialog
= self
.xUITest
.getTopFocusWindow()
470 xtab
= xDialog
.getChild("tab")
471 xcomma
= xDialog
.getChild("comma")
472 xsemicolon
= xDialog
.getChild("semicolon")
473 xspace
= xDialog
.getChild("space")
474 xother
= xDialog
.getChild("other")
475 xinputother
= xDialog
.getChild("inputother")
476 if (get_state_as_dict(xspace
)["Selected"]) == "false":
477 xspace
.executeAction("CLICK", tuple())
478 if (get_state_as_dict(xother
)["Selected"]) == "false":
479 xother
.executeAction("CLICK", tuple())
480 xinputother
.executeAction("TYPE", mkPropertyValues({"TEXT":"|"}))
482 xOK
= xDialog
.getChild("ok")
483 def handle_warn_dlg(dialog
):
484 xyesBtn
= dialog
.getChild("yes")
485 self
.ui_test
.close_dialog_through_button(xyesBtn
)
487 self
.ui_test
.execute_blocking_action(xOK
.executeAction
, args
=('CLICK', ()),
488 dialog_handler
=handle_warn_dlg
)
490 self
.assertEqual(get_cell_by_position(document
, 0, 0, 0).getValue(), 1)
491 self
.assertEqual(get_cell_by_position(document
, 0, 0, 1).getValue(), 2)
492 self
.assertEqual(get_cell_by_position(document
, 0, 0, 2).getValue(), 3)
493 self
.assertEqual(get_cell_by_position(document
, 0, 0, 3).getValue(), 4)
494 self
.assertEqual(get_cell_by_position(document
, 0, 0, 4).getValue(), 5)
495 self
.assertEqual(get_cell_by_position(document
, 0, 1, 0).getValue(), 2)
496 self
.assertEqual(get_cell_by_position(document
, 0, 1, 1).getValue(), 2)
497 self
.assertEqual(get_cell_by_position(document
, 0, 1, 2).getValue(), 2)
498 self
.assertEqual(get_cell_by_position(document
, 0, 1, 3).getValue(), 2)
499 self
.assertEqual(get_cell_by_position(document
, 0, 1, 4).getValue(), 2)
500 self
.assertEqual(get_cell_by_position(document
, 0, 2, 0).getValue(), 3)
501 self
.assertEqual(get_cell_by_position(document
, 0, 2, 1).getValue(), 3)
502 self
.assertEqual(get_cell_by_position(document
, 0, 2, 2).getValue(), 3)
503 self
.assertEqual(get_cell_by_position(document
, 0, 2, 3).getValue(), 3)
504 self
.assertEqual(get_cell_by_position(document
, 0, 2, 4).getValue(), 3)
505 self
.assertEqual(get_cell_by_position(document
, 0, 3, 0).getValue(), 4)
506 self
.assertEqual(get_cell_by_position(document
, 0, 3, 1).getValue(), 4)
507 self
.assertEqual(get_cell_by_position(document
, 0, 3, 2).getValue(), 4)
508 self
.assertEqual(get_cell_by_position(document
, 0, 3, 3).getValue(), 4)
509 self
.assertEqual(get_cell_by_position(document
, 0, 3, 4).getValue(), 4)
510 self
.assertEqual(get_cell_by_position(document
, 0, 4, 0).getValue(), 5)
511 self
.assertEqual(get_cell_by_position(document
, 0, 4, 1).getValue(), 5)
512 self
.assertEqual(get_cell_by_position(document
, 0, 4, 2).getValue(), 5)
513 self
.assertEqual(get_cell_by_position(document
, 0, 4, 3).getValue(), 5)
514 self
.assertEqual(get_cell_by_position(document
, 0, 4, 4).getValue(), 5)
515 self
.assertEqual(get_cell_by_position(document
, 0, 5, 0).getValue(), 6)
516 self
.assertEqual(get_cell_by_position(document
, 0, 5, 1).getValue(), 6)
517 self
.assertEqual(get_cell_by_position(document
, 0, 5, 2).getValue(), 6)
518 self
.assertEqual(get_cell_by_position(document
, 0, 5, 3).getValue(), 6)
519 self
.assertEqual(get_cell_by_position(document
, 0, 5, 4).getValue(), 6)
520 self
.assertEqual(get_cell_by_position(document
, 0, 6, 0).getString(), "random content")
521 self
.assertEqual(get_cell_by_position(document
, 0, 6, 1).getValue(), 0)
522 self
.assertEqual(get_cell_by_position(document
, 0, 6, 2).getValue(), 0)
523 self
.assertEqual(get_cell_by_position(document
, 0, 6, 3).getValue(), 0)
524 self
.assertEqual(get_cell_by_position(document
, 0, 6, 4).getString(), "random content")
525 self
.ui_test
.close_doc()
526 # vim: set shiftwidth=4 softtabstop=4 expandtab: