2 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
4 # This file is part of the LibreOffice UI_logger project.
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this
8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # This file contains the implementation of the Compiler
11 # for the new logger grammar
13 # ul stands for Ui_Logger
21 from textx
.metamodel
import metamodel_from_file
23 print("textx is a required package.")
24 print('Please install the package for example with "pip3 install --user textx"')
31 This function parses the command-line arguments
32 to get the input and output file details
34 parser
= argparse
.ArgumentParser(description
="Generate a UI test file from log")
35 parser
.add_argument("input_address", type=str, help="The log file address")
36 parser
.add_argument("output_address", type=str, help="The test file address")
37 args
= parser
.parse_args()
46 parent_hierarchy_count
= 0
48 flag_for_QuerySaveDialog
= False
49 math_element_selector_initializer
= False
51 def __init__(self
, input_address
, output_address
):
52 self
.ui_dsl_mm
= metamodel_from_file("ui_logger_dsl_grammar.tx")
53 self
.output_stream
= self
.initiate_test_generation(output_address
)
54 self
.input_address
= input_address
56 def get_log_file(self
, input_address
):
59 content
= self
.ui_dsl_mm
.model_from_file(input_address
)
60 except IOError as err
:
61 print("IO error: {0}".format(err
))
63 "Use " + os
.path
.basename(sys
.argv
[0]) + " -h to get usage instructions"
69 def initiate_test_generation(self
, output_address
):
70 self
.last_parent
.append("MainWindow")
72 f
= open(output_address
, "w")
73 except IOError as err
:
74 print("IO error: {0}".format(err
))
76 "Use " + os
.path
.basename(sys
.argv
[0]) + " -h to get usage instructions"
80 "# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-\n"
82 + "# This file is part of the LibreOffice project.\n"
84 + "# This Source Code Form is subject to the terms of the Mozilla Public\n"
85 + "# License, v. 2.0. If a copy of the MPL was not distributed with this\n"
86 + "# file, You can obtain one at http://mozilla.org/MPL/2.0/\n"
88 + "from uitest.framework import UITestCase\n"
89 + "from libreoffice.uno.propertyvalue import mkPropertyValues\n"
90 + "from uitest.uihelper.common import get_state_as_dict\n"
91 + "import importlib\n\n"
92 + "class TestClass(UITestCase):\n"
94 + "def test_function(self):\n"
97 self
.variables
.append(line
)
102 self
.ui_dsl_mm
.register_obj_processors(
104 "UNOCommand": self
.handle_uno
,
105 "StarterCommand": self
.handle_start
,
106 "CloseDialog": self
.handle_Dialog
,
107 "OpenModelessDialog": self
.handle_Dialog
,
108 "OpenModalDialog": self
.handle_Dialog
,
109 "ButtonUIObject": self
.handle_button
,
110 "CheckBoxUIObject": self
.handle_check_box
,
111 "TabControlUIObject": self
.handle_tab
,
112 "ComboBoxUIObject": self
.handle_Combo_box
,
113 "RadioButtonUIObject": self
.handle_Radio_button
,
114 "ListBoxUIObject": self
.handle_List_box
,
115 "SpinFieldUIObject": self
.handle_spin_field
,
116 "EditUIObject": self
.handle_Edit_uiObject
,
117 "ToolBoxUIObject": self
.handle_ToolBox_uiObject
,
118 "ValueSetUIObject": self
.handle_ValueSet_uiObject
,
119 "MenuBtnUIObjectOpen":self
.handle_MenuBtnUIObjectOpen
,
120 "MenuBtnUIObjectSelect":self
.handle_MenuBtnUIObjectSelect
,
121 "MenuBtnUIObjectClose":self
.handle_MenuBtnUIObjectClose
,
122 "writer_Type_command": self
.handle_writer_type
,
123 "writer_Select_command": self
.handle_writer_select
,
124 "writer_GOTO_command": self
.handle_writer_goto
,
125 "calc_Select_cell": self
.handle_calc_select
,
126 "calc_switch_sheet": self
.handle_calc_switch_sheet
,
127 "calc_Type_command": self
.handle_calc_Type_command
,
128 "calc_AutoFill_filter": self
.handle_calc_AutoFill_filter
,
129 "calc_SelectMenu_filter": self
.handle_calc_SelectMenu_filter
,
130 "calc_Open_Comment": self
.handle_calc_Open_Comment
,
131 "calc_Close_Comment": self
.handle_calc_Close_Comment
,
132 "impress_Type_command": self
.handle_impress_Type_command
,
133 "math_element_selector": self
.handle_math_element_selector
,
134 "math_Type_command": self
.handle_math_Type_command
,
135 "setZoom_command": self
.handle_setZoom_command
,
136 "draw_Type_command": self
.handle_draw_Type_command
,
137 "SideBar": self
.handle_SideBar
,
138 "writer_Comment_leave":self
.handle_writer_Comment_leave
,
139 "writer_Comment_show":self
.handle_writer_Comment_show
,
140 "writer_Comment_hide":self
.handle_writer_Comment_hide
,
141 "writer_Comment_delete":self
.handle_writer_Comment_delete
,
142 "writer_Comment_setresolved":self
.handle_writer_Comment_setresolved
,
143 "writer_Copy_Text": self
.do_nothing
,
144 "writer_Cut_Text": self
.do_nothing
,
145 "writer_Paste_Text": self
.do_nothing
,
146 "writer_Insert_BreakPage": self
.do_nothing
,
147 "writer_Create_table": self
.do_nothing
,
148 "calc_Remove_Content": self
.do_nothing
,
149 "calc_Delete_Cells": self
.do_nothing
,
150 "calc_insert_cells": self
.do_nothing
,
151 "calc_Cut_Cells": self
.do_nothing
,
152 "calc_Copy_Cells": self
.do_nothing
,
153 "calc_Merge_Cells": self
.do_nothing
,
154 "calc_UNMerge_Cells": self
.do_nothing
,
155 "calc_Rename_Sheet": self
.do_nothing
,
156 "calc_Insert_sheet": self
.do_nothing
,
157 "impress_Insert_Slide": self
.do_nothing
,
158 "impress_Delete_Page": self
.do_nothing
,
159 "impress_Duplicate_Slide": self
.do_nothing
,
160 "impress_Rename_Slide": self
.do_nothing
,
161 "draw_Insert_Page": self
.do_nothing
,
162 "draw_Delete_Page": self
.do_nothing
,
163 "draw_Rename_Page": self
.do_nothing
,
167 self
.log_lines
= self
.get_log_file(self
.input_address
)
170 if self
.current_app
in self
.objects
:
171 self
.objects
[self
.current_app
] += 1
173 self
.objects
[self
.current_app
] = 1
177 + ' = MainWindow.getChild("'
181 self
.variables
.append(line
)
183 def init_Object(self
, Id_of_Object
, name_of_child
, Obj_parent
):
185 if Id_of_Object
in self
.objects
:
186 self
.objects
[Id_of_Object
] += 1
188 self
.objects
[Id_of_Object
] = 1
199 self
.variables
.append(line
)
201 def write_line_without_parameters(self
, Action_holder
, Action
, Action_type
):
211 self
.variables
.append(line
)
213 def write_line_with_one_parameters(
214 self
, Action_holder
, Action
, Parameter_name
, parameter_value
221 + '", mkPropertyValues({"'
224 + str(parameter_value
)
227 self
.variables
.append(line
)
229 def write_line_with_two_parameters(
244 + '", mkPropertyValues({"'
247 + str(parameter_value_1
)
251 + str(parameter_value_2
)
254 self
.variables
.append(line
)
256 def handle_uno(self
, UNOCommand
):
257 if UNOCommand
.parameters
is None:
260 + 'self.xUITest.executeCommand("'
261 + UNOCommand
.uno_command_name
266 for p
in UNOCommand
.parameters
.parameter_data
:
267 parameters
= parameters
+ '"' + p
.key
+ '" : ' + str(p
.value
) + " ,"
268 parameters
= parameters
[:-1]
272 + 'self.xUITest.executeCommandWithParameters("'
273 + UNOCommand
.uno_command_name
274 + '", mkPropertyValues({'
279 self
.variables
.append(line
)
280 self
.prev_command
= UNOCommand
282 def handle_start(self
, StarterCommand
):
285 + 'with self.ui_test.create_doc_in_start_center("'
286 + StarterCommand
.program_name
287 + '") as document:\n'
289 self
.variables
.append(line
)
291 line
= tab
* 3 + "MainWindow = self.xUITest.getTopFocusWindow()\n"
292 self
.variables
.append(line
)
294 "writer": "writer_edit",
295 "calc": "grid_window",
296 "impress": "impress_win",
300 self
.current_app
= app
[StarterCommand
.program_name
]
301 self
.prev_command
= StarterCommand
303 def handle_SideBar(self
, SideBar
):
305 line
= ' self.xUITest.executeCommand(".uno:Sidebar")\n'
306 self
.variables
.append(line
)
308 self
.write_line_with_one_parameters(
309 "MainWindow", "SIDEBAR", "PANEL", SideBar
.name
312 self
.prev_command
= SideBar
314 def handle_Dialog(self
, DialogCommand
):
316 if DialogCommand
.__class
__.__name
__ == "OpenModalDialog":
318 if DialogCommand
.dialog_name
!= "QuerySaveDialog":
319 # This part is just to ignore saving the Save dialog while closing the app
321 old_line
= self
.variables
.pop()
322 if self
.prev_command
.__class
__.__name
__ == "UNOCommand":
323 key_word
= self
.prev_command
.uno_command_name
[-6:]
325 key_word
= old_line
[-9:-3]
327 if key_word
== "Dialog":
330 + 'with self.ui_test.execute_dialog_through_command("'
331 + self
.prev_command
.uno_command_name
333 + DialogCommand
.dialog_name
336 self
.variables
.append(old_line
)
337 self
.last_parent
.append(DialogCommand
.dialog_name
)
338 self
.parent_hierarchy_count
= self
.parent_hierarchy_count
+ 1
341 self
.flag_for_QuerySaveDialog
= True
343 elif DialogCommand
.__class
__.__name
__ == "OpenModelessDialog":
344 old_line
= self
.variables
.pop()
345 if self
.prev_command
.__class
__.__name
__ == "UNOCommand":
346 key_word
= self
.prev_command
.uno_command_name
[-6:]
348 key_word
= old_line
[-9:-3]
350 if key_word
== "Dialog":
353 + 'with self.ui_test.execute_modeless_dialog_through_command("'
354 + self
.prev_command
.uno_command_name
356 + DialogCommand
.dialog_name
359 self
.variables
.append(old_line
)
360 self
.last_parent
.append(DialogCommand
.dialog_name
)
361 self
.parent_hierarchy_count
= self
.parent_hierarchy_count
+ 1
363 elif DialogCommand
.__class
__.__name
__ == "CloseDialog":
365 if not (self
.flag_for_QuerySaveDialog
):
366 # This part is just to ignore saving the Save dialog while closing the app
368 if self
.prev_command
.__class
__.__name
__ == "ButtonUIObject":
369 old_line
= self
.variables
.pop()
371 if keyword
.iskeyword(self
.prev_command
.ui_button
):
374 + "self.ui_test.close_dialog_through_button(x"
375 + self
.prev_command
.ui_button
381 + "self.ui_test.close_dialog_through_button("
382 + self
.prev_command
.ui_button
385 self
.variables
.append(line
)
386 self
.last_parent
.pop()
387 self
.parent_hierarchy_count
= self
.parent_hierarchy_count
- 1
389 self
.flag_for_QuerySaveDialog
= False
391 # This is to solve the problem of re-using the same id again in different Dialogs
395 self
.prev_command
= DialogCommand
397 def handle_button(self
, ButtonUIObject
):
399 if ButtonUIObject
.parent_id
!= "QuerySaveDialog":
400 # This part is just to ignore saving the Save dialog while closing the app
403 if keyword
.iskeyword(ButtonUIObject
.ui_button
):
404 name_of_obj
= "x" + ButtonUIObject
.ui_button
406 name_of_obj
= ButtonUIObject
.ui_button
408 if ButtonUIObject
.parent_id
== "":
411 ButtonUIObject
.ui_button
,
412 self
.last_parent
[self
.parent_hierarchy_count
],
416 name_of_obj
, ButtonUIObject
.ui_button
, ButtonUIObject
.parent_id
419 self
.write_line_without_parameters(name_of_obj
, "CLICK", "tuple")
421 self
.prev_command
= ButtonUIObject
423 def handle_check_box(self
, CheckBoxUIObject
):
426 if keyword
.iskeyword(CheckBoxUIObject
.Check_box_id
):
427 name_of_obj
= "x" + CheckBoxUIObject
.Check_box_id
429 name_of_obj
= CheckBoxUIObject
.Check_box_id
431 if CheckBoxUIObject
.parent_id
== "":
434 CheckBoxUIObject
.Check_box_id
,
435 self
.last_parent
[self
.parent_hierarchy_count
],
439 name_of_obj
, CheckBoxUIObject
.Check_box_id
, CheckBoxUIObject
.parent_id
442 self
.write_line_without_parameters(name_of_obj
, "CLICK", "tuple")
444 self
.prev_command
= CheckBoxUIObject
446 def handle_tab(self
, TabControlUIObject
):
449 if keyword
.iskeyword(TabControlUIObject
.tab_id
):
450 name_of_obj
= "x" + TabControlUIObject
.tab_id
452 name_of_obj
= TabControlUIObject
.tab_id
454 if TabControlUIObject
.parent_id
== "":
457 TabControlUIObject
.tab_id
,
458 self
.last_parent
[self
.parent_hierarchy_count
],
462 name_of_obj
, TabControlUIObject
.tab_id
, TabControlUIObject
.parent_id
465 self
.write_line_with_one_parameters(
466 name_of_obj
, "SELECT", "POS", TabControlUIObject
.tab_page_number
469 self
.prev_command
= TabControlUIObject
471 def handle_Combo_box(self
, ComboBoxUIObject
):
474 if keyword
.iskeyword(ComboBoxUIObject
.Combo_box_id
):
475 name_of_obj
= "x" + ComboBoxUIObject
.Combo_box_id
477 name_of_obj
= ComboBoxUIObject
.Combo_box_id
479 if ComboBoxUIObject
.parent_id
== "":
482 ComboBoxUIObject
.Combo_box_id
,
483 self
.last_parent
[self
.parent_hierarchy_count
],
487 name_of_obj
, ComboBoxUIObject
.Combo_box_id
, ComboBoxUIObject
.parent_id
490 self
.write_line_with_one_parameters(
491 name_of_obj
, "SELECT", "POS", ComboBoxUIObject
.item_num
494 self
.prev_command
= ComboBoxUIObject
496 def handle_Radio_button(self
, RadioButtonUIObject
):
499 if keyword
.iskeyword(RadioButtonUIObject
.Radio_button_id
):
500 name_of_obj
= "x" + RadioButtonUIObject
.Radio_button_id
502 name_of_obj
= RadioButtonUIObject
.Radio_button_id
504 if RadioButtonUIObject
.parent_id
== "":
507 RadioButtonUIObject
.Radio_button_id
,
508 self
.last_parent
[self
.parent_hierarchy_count
],
513 RadioButtonUIObject
.Radio_button_id
,
514 RadioButtonUIObject
.parent_id
,
517 self
.write_line_without_parameters(name_of_obj
, "CLICK", "tuple")
519 self
.prev_command
= RadioButtonUIObject
521 def handle_List_box(self
, ListBoxUIObject
):
524 if keyword
.iskeyword(ListBoxUIObject
.list_id
):
525 name_of_obj
= "x" + ListBoxUIObject
.list_id
527 name_of_obj
= ListBoxUIObject
.list_id
529 if ListBoxUIObject
.parent_id
== "":
532 ListBoxUIObject
.list_id
,
533 self
.last_parent
[self
.parent_hierarchy_count
],
537 name_of_obj
, ListBoxUIObject
.list_id
, ListBoxUIObject
.parent_id
540 self
.write_line_with_one_parameters(
541 name_of_obj
, "SELECT", "POS", ListBoxUIObject
.POS
544 self
.prev_command
= ListBoxUIObject
546 def handle_spin_field(self
, SpinFieldUIObject
):
549 if keyword
.iskeyword(SpinFieldUIObject
.Spin_id
):
550 name_of_obj
= "x" + SpinFieldUIObject
.Spin_id
552 name_of_obj
= SpinFieldUIObject
.Spin_id
554 if SpinFieldUIObject
.parent_id
== "":
557 SpinFieldUIObject
.Spin_id
,
558 self
.last_parent
[self
.parent_hierarchy_count
],
562 name_of_obj
, SpinFieldUIObject
.Spin_id
, SpinFieldUIObject
.parent_id
565 if SpinFieldUIObject
.change
== "Increase":
566 self
.write_line_without_parameters(name_of_obj
, "UP", "tuple")
567 elif SpinFieldUIObject
.change
== "Decrease":
568 self
.write_line_without_parameters(name_of_obj
, "DOWN", "tuple")
569 self
.prev_command
= SpinFieldUIObject
571 def handle_Edit_uiObject(self
, EditUIObject
):
574 if keyword
.iskeyword(EditUIObject
.action
.edit_button
):
575 name_of_obj
= "x" + EditUIObject
.action
.edit_button
577 name_of_obj
= EditUIObject
.action
.edit_button
579 if EditUIObject
.parent_id
== "":
582 EditUIObject
.action
.edit_button
,
583 self
.last_parent
[self
.parent_hierarchy_count
],
587 name_of_obj
, EditUIObject
.action
.edit_button
, EditUIObject
.parent_id
590 if EditUIObject
.action
.__class
__.__name
__ == "Type_action":
592 if EditUIObject
.action
.what_to_type
.__class
__.__name
__ == "char":
593 self
.write_line_with_one_parameters(
597 EditUIObject
.action
.what_to_type
.input_char
,
600 elif EditUIObject
.action
.what_to_type
.__class
__.__name
__ == "KeyCode":
601 self
.write_line_with_one_parameters(
605 EditUIObject
.action
.what_to_type
.input_key_code
,
608 if EditUIObject
.action
.__class
__.__name
__ == "SELECT":
610 self
.write_line_with_two_parameters(
614 EditUIObject
.action
.from_pos
,
616 EditUIObject
.action
.to_pos
,
619 if EditUIObject
.action
.__class
__.__name
__ == "Clear":
621 self
.write_line_without_parameters(name_of_obj
, "CLEAR", "tuple")
623 self
.prev_command
= EditUIObject
625 def handle_ToolBox_uiObject(self
, ToolBoxUIObject
):
627 if keyword
.iskeyword(ToolBoxUIObject
.toolbox_id
):
628 name_of_obj
= "x" + ToolBoxUIObject
.toolbox_id
630 name_of_obj
= ToolBoxUIObject
.toolbox_id
634 ToolBoxUIObject
.toolbox_id
,
635 self
.last_parent
[self
.parent_hierarchy_count
],
638 self
.write_line_with_one_parameters(
639 name_of_obj
, "CLICK", "POS", ToolBoxUIObject
.POS
642 self
.prev_command
= ToolBoxUIObject
644 def handle_ValueSet_uiObject(self
, ValueSetUIObject
):
647 if keyword
.iskeyword(ValueSetUIObject
.value_set_id
):
648 name_of_obj
= "x" + ValueSetUIObject
.value_set_id
650 name_of_obj
= ValueSetUIObject
.value_set_id
652 parent_txt
= ValueSetUIObject
.parent_id
.split("/")
653 parent
= parent_txt
[len(parent_txt
)-2]
654 if( parent
.upper() != self
.last_parent
[self
.parent_hierarchy_count
].upper()):
658 self
.last_parent
[self
.parent_hierarchy_count
],
662 name_of_obj
, ValueSetUIObject
.value_set_id
, parent
667 name_of_obj
, ValueSetUIObject
.value_set_id
, self
.last_parent
[self
.parent_hierarchy_count
]
670 self
.write_line_with_one_parameters(
671 name_of_obj
, "CHOOSE", "POS", ValueSetUIObject
.POS
674 self
.prev_command
= ValueSetUIObject
676 def handle_MenuBtnUIObjectOpen(self
, MenuBtnUIObjectOpen
):
678 if keyword
.iskeyword(MenuBtnUIObjectOpen
.MenuBtn_ID
):
679 name_of_obj
= "x" + MenuBtnUIObjectOpen
.MenuBtn_ID
681 name_of_obj
= MenuBtnUIObjectOpen
.MenuBtn_ID
685 MenuBtnUIObjectOpen
.MenuBtn_ID
,
686 self
.last_parent
[self
.parent_hierarchy_count
],
689 self
.write_line_with_one_parameters(
690 name_of_obj
, "OPENLIST", "", ""
693 self
.prev_command
= MenuBtnUIObjectOpen
695 def handle_MenuBtnUIObjectClose(self
, MenuBtnUIObjectClose
):
697 if keyword
.iskeyword(MenuBtnUIObjectClose
.MenuBtn_ID
):
698 name_of_obj
= "x" + MenuBtnUIObjectClose
.MenuBtn_ID
700 name_of_obj
= MenuBtnUIObjectClose
.MenuBtn_ID
704 MenuBtnUIObjectClose
.MenuBtn_ID
,
705 self
.last_parent
[self
.parent_hierarchy_count
],
708 self
.write_line_with_one_parameters(
709 name_of_obj
, "CLOSELIST", "", ""
712 self
.prev_command
= MenuBtnUIObjectClose
714 def handle_MenuBtnUIObjectSelect(self
, MenuBtnUIObjectSelect
):
716 if keyword
.iskeyword(MenuBtnUIObjectSelect
.MenuBtn_ID
):
717 name_of_obj
= "x" + MenuBtnUIObjectSelect
.MenuBtn_ID
719 name_of_obj
= MenuBtnUIObjectSelect
.MenuBtn_ID
723 MenuBtnUIObjectSelect
.MenuBtn_ID
,
724 self
.last_parent
[self
.parent_hierarchy_count
],
727 self
.write_line_with_one_parameters(
728 name_of_obj
, "OPENFROMLIST", "POS", MenuBtnUIObjectSelect
.item_num
[0]
731 self
.prev_command
= MenuBtnUIObjectSelect
733 def handle_writer_type(self
, writer_Type_command
):
737 if writer_Type_command
.what_to_type
.__class
__.__name
__ == "char":
738 self
.write_line_with_one_parameters(
742 writer_Type_command
.what_to_type
.input_char
,
745 elif writer_Type_command
.what_to_type
.__class
__.__name
__ == "KeyCode":
746 self
.write_line_with_one_parameters(
750 writer_Type_command
.what_to_type
.input_key_code
,
753 self
.prev_command
= writer_Type_command
755 def handle_writer_select(self
, writer_Select_command
):
759 self
.write_line_with_two_parameters(
763 writer_Select_command
.from_pos
,
765 writer_Select_command
.to_pos
,
768 self
.prev_command
= writer_Select_command
770 def handle_writer_goto(self
, writer_GOTO_command
):
774 self
.write_line_with_one_parameters(
775 self
.current_app
, "GOTO", "PAGE", writer_GOTO_command
.page_num
778 self
.prev_command
= writer_GOTO_command
780 def handle_calc_select(self
, calc_Select_cell
):
784 if calc_Select_cell
.select_op
.__class
__.__name
__ == "range_of_cells":
785 self
.write_line_with_one_parameters(
789 calc_Select_cell
.select_op
.input_range
,
792 elif calc_Select_cell
.select_op
.__class
__.__name
__ == "one_cell":
793 self
.write_line_with_one_parameters(
797 calc_Select_cell
.select_op
.input_cell
,
800 self
.prev_command
= calc_Select_cell
802 def handle_calc_switch_sheet(self
, calc_switch_sheet
):
806 self
.write_line_with_one_parameters(
807 self
.current_app
, "SELECT", "TABLE", calc_switch_sheet
.sheet_num
810 self
.prev_command
= calc_switch_sheet
812 def handle_calc_Type_command(self
, calc_Type_command
):
816 if calc_Type_command
.what_to_type
.__class
__.__name
__ == "char":
817 self
.write_line_with_one_parameters(
821 calc_Type_command
.what_to_type
.input_char
,
824 elif calc_Type_command
.what_to_type
.__class
__.__name
__ == "KeyCode":
825 self
.write_line_with_one_parameters(
829 calc_Type_command
.what_to_type
.input_key_code
,
832 self
.prev_command
= calc_Type_command
834 def handle_calc_AutoFill_filter(self
, calc_AutoFill_filter
):
841 + '.executeAction("LAUNCH", mkPropertyValues'
842 + '({"AUTOFILTER": "", "COL": "'
843 + str(calc_AutoFill_filter
.col_num
)
846 + str(calc_AutoFill_filter
.row_num
)
850 self
.variables
.append(line
)
851 self
.prev_command
= calc_AutoFill_filter
853 def handle_calc_Open_Comment(self
, calc_Open_Comment
):
858 + '.executeAction("COMMENT", mkPropertyValues'
859 + '({"OPEN": " "}))\n'
862 self
.variables
.append(line
)
864 self
.prev_command
= calc_Open_Comment
866 def handle_calc_Close_Comment(self
, calc_Close_Comment
):
871 + '.executeAction("COMMENT", mkPropertyValues'
872 + '({"CLOSE": " "}))\n'
875 self
.variables
.append(line
)
877 self
.prev_command
= calc_Close_Comment
879 def handle_calc_SelectMenu_filter(self
, calc_SelectMenu_filter
):
886 + '.executeAction("LAUNCH", mkPropertyValues'
887 + '({"SELECTMENU": "", "COL": "'
888 + str(calc_SelectMenu_filter
.col_num
)
891 + str(calc_SelectMenu_filter
.row_num
)
895 self
.variables
.append(line
)
896 self
.prev_command
= calc_SelectMenu_filter
898 def handle_impress_Type_command(self
, impress_Type_command
):
902 if impress_Type_command
.what_to_type
.__class
__.__name
__ == "char":
903 self
.write_line_with_one_parameters(
907 impress_Type_command
.what_to_type
.input_char
,
910 elif impress_Type_command
.what_to_type
.__class
__.__name
__ == "KeyCode":
911 self
.write_line_with_one_parameters(
915 impress_Type_command
.what_to_type
.input_key_code
,
918 self
.prev_command
= impress_Type_command
920 def handle_math_Type_command(self
, math_Type_command
):
923 if math_Type_command
.what_to_type
.__class
__.__name
__ == "char":
924 self
.write_line_with_one_parameters(
928 math_Type_command
.what_to_type
.input_char
,
931 elif math_Type_command
.what_to_type
.__class
__.__name
__ == "KeyCode":
932 self
.write_line_with_one_parameters(
936 math_Type_command
.what_to_type
.input_key_code
,
939 self
.prev_command
= math_Type_command
941 def handle_draw_Type_command(self
, draw_Type_command
):
944 if draw_Type_command
.what_to_type
.__class
__.__name
__ == "char":
945 self
.write_line_with_one_parameters(
949 draw_Type_command
.what_to_type
.input_char
,
952 elif draw_Type_command
.what_to_type
.__class
__.__name
__ == "KeyCode":
953 self
.write_line_with_one_parameters(
957 draw_Type_command
.what_to_type
.input_key_code
,
960 self
.prev_command
= draw_Type_command
962 def handle_math_element_selector(self
, math_element_selector
):
964 if not self
.math_element_selector_initializer
:
965 # This part is for initializing the element selector in the Math application
966 self
.math_element_selector_initializer
= True
970 + ' = MainWindow.getChild("'
974 self
.variables
.append(line
)
976 # This inserts a prefix of 'x' to avoid creating variables with only numeric characters
977 element_name
="x"+str(math_element_selector
.element_no
)
979 self
.init_Object(element_name
,str(math_element_selector
.element_no
),"element_selector")
981 self
.write_line_without_parameters(
982 str(element_name
), "SELECT", "tuple"
985 self
.prev_command
= math_element_selector
987 def handle_writer_Comment_leave(self
,writer_Comment_leave
):
992 writer_Comment_leave
.comment_id
, writer_Comment_leave
.comment_id
, "MainWindow"
995 self
.write_line_with_one_parameters(
996 writer_Comment_leave
.comment_id
, "LEAVE", "", ""
999 self
.prev_command
= writer_Comment_leave
1001 def handle_writer_Comment_show(self
,writer_Comment_show
):
1006 writer_Comment_show
.comment_id
, writer_Comment_show
.comment_id
, "MainWindow"
1009 self
.write_line_with_one_parameters(
1010 writer_Comment_show
.comment_id
, "SHOW", "", ""
1013 self
.prev_command
= writer_Comment_show
1015 def handle_writer_Comment_hide(self
,writer_Comment_hide
):
1020 writer_Comment_hide
.comment_id
, writer_Comment_hide
.comment_id
, "MainWindow"
1023 self
.write_line_with_one_parameters(
1024 writer_Comment_hide
.comment_id
, "HIDE", "", ""
1027 self
.prev_command
= writer_Comment_hide
1029 def handle_writer_Comment_delete(self
,writer_Comment_delete
):
1034 writer_Comment_delete
.comment_id
, writer_Comment_delete
.comment_id
, "MainWindow"
1037 self
.write_line_with_one_parameters(
1038 writer_Comment_delete
.comment_id
, "DELETE", "", ""
1041 self
.prev_command
= writer_Comment_delete
1043 def handle_writer_Comment_setresolved(self
,writer_Comment_setresolved
):
1048 writer_Comment_setresolved
.comment_id
, writer_Comment_setresolved
.comment_id
, "MainWindow"
1051 self
.write_line_with_one_parameters(
1052 writer_Comment_setresolved
.comment_id
, "RESOLVE", "", ""
1055 self
.prev_command
= writer_Comment_setresolved
1057 def handle_setZoom_command(self
, setZoom_command
):
1061 self
.write_line_with_one_parameters(
1062 self
.current_app
, "SET", "ZOOM", setZoom_command
.zoom_value
1065 self
.prev_command
= setZoom_command
1067 def Generate_UI_test(self
):
1068 line
= "\n\n# vim: set shiftwidth=4 softtabstop=4 expandtab:"
1069 self
.variables
.append(line
)
1071 for line
in self
.variables
:
1072 self
.output_stream
.write(str(line
))
1074 def do_nothing(self
, Command
):
1075 # to be added in the future
1079 self
.output_stream
.close()
1084 ui_logger
= ul_Compiler(args
.input_address
, args
.output_address
)
1086 for statement
in ui_logger
.log_lines
.commands
:
1088 ui_logger
.Generate_UI_test()
1092 if __name__
== "__main__":