1 'encoding UTF-8 Do not remove or change this line!
2 '**************************************************************************
3 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 '* Copyright 2008 by Sun Microsystems, Inc.
7 '* OpenOffice.org - a multi-platform office productivity suite
9 '* $RCSfile: basic_dialog_i18n_copy_control.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 12:18:13 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org. If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/******************************************************************************
34 '* owner : Joerg.Skottke@Sun.Com
36 '* short description : Copy a control with i18n data
38 '\******************************************************************************
40 testcase tBasicDialogI18nCopyControl
42 '///<h1>Copy a formcontrol with i18n data within BASIC IDE</h1>
43 '///<u><pre>Synopsis</pre></u>Apply localization to a form control and copy
44 '///+ it within the BASIC IDE. Verify that the localized data is preserved<br>
45 '///<u><pre>Specification document</pre></u><a href="http://specs.openoffice.org/appwide/dialog_ide/GUI_Translation_in_Dialog_IDE.odt">
46 '///+ GUI translation in Dialog IDE</a><br>
47 '///<u><pre>Files used</pre></u>None<br>
48 '///<u><pre>Test case specification</pre></u>
50 const COMMAND_BUTTON = 1 ' id of the command button (formcontrols.inc)
51 const DIALOG_NAME = "DialogExport" ' Name of the first module
52 const LANGUAGES_TO_COPY = 5 ' Only copy n languages
53 const TARGET_DIALOG = "Target" ' The name of the dialog the control is pasted to
55 dim cLanguageList( LANGUAGES_TO_COPY ) as string ' Note: Index 0 is used
56 dim iCurrentLanguage as integer
58 ' These are the strings used to simulate localized text
59 dim cIDStrings( 5 ) as string
60 cIDStrings( 0 ) = "language_a"
61 cIDStrings( 1 ) = "language_b"
62 cIDStrings( 2 ) = "language_c"
63 cIDStrings( 3 ) = "language_d"
64 cIDStrings( 4 ) = "language_e"
65 cIDStrings( 5 ) = "language_f"
67 dim cTempString as string
69 ' These are the IDE internal coordinates of the control, used to restore
70 ' identical coordinates in the source and target dialogs
71 dim iOriginalCoordinates( 4 ) as integer
73 ' Some multi purpose returncode
77 '///+<li>Create a new document</li>
80 '///+<li>Open the Macro Organizer</li>
81 '///+<li>Create a new module for the document</li>
82 '///+<li>Open the BASIC IDE</li>
83 '///+<li>Create a new Dialog via the tabbar at the bottom of the IDE</li>
84 printlog( "Test init: Setting up environment" )
85 brc = hInitFormControls( DIALOG_NAME )
87 warnlog( "Failed to initialize BASIC IDE/Dialog editor, aborting" )
91 '///+<li>Draw a Command Button</li>
92 hDrawControlOnDialog( COMMAND_BUTTON )
94 '///+<li>Retrieve the current BASIC IDE internal coordinates of the control for
95 '///+ later usage</li>
96 hOpenPropertyBrowser()
97 kontext "TabGeneralControl"
98 printlog( "Get internal coordinates for the control" )
99 iOriginalCoordinates( 1 ) = height.getText()
100 iOriginalCoordinates( 2 ) = width.getText()
101 iOriginalCoordinates( 3 ) = PosX.getText()
102 iOriginalCoordinates( 4 ) = PosY.getText()
103 printlog( "Height: " & iOriginalCoordinates( 1 ) )
104 printlog( "Width.: " & iOriginalCoordinates( 2 ) )
105 printlog( "Pos X.: " & iOriginalCoordinates( 3 ) )
106 printlog( "Pos Y.: " & iOriginalCoordinates( 4 ) )
107 hClosePropertyBrowser()
109 qaerrorlog( "#i80456# properties button not enabled when a formcontrol is inserted via keyboard" )
111 '///+<li>Click Manage Language button on ToolsCollection Bar</li>
112 kontext "ToolsCollectionBar"
113 ManageLanguage.click()
115 '///+<li>Add a default language</li>
116 kontext "ManageUILanguages"
117 if ( ManageUILanguages.exists( 2 ) ) then
121 kontext "SetDefaultLanguage"
122 if ( SetDefaultLanguage.exists( 1 ) ) then
123 SetDefaultLanguage.ok()
125 warnlog( "Set Default Language dialog is missing" )
128 warnlog( "Unable to open Manage UI Languages dialog" )
131 '///+<li>Add a number of additional languages</li>
132 kontext "ManageUILanguages"
133 if ( ManageUILanguages.exists( 1 ) ) then
137 kontext "AddUserInterface"
138 if ( AddUserInterface.exists( 1 ) ) then
139 for iCurrentLanguage = 1 to LANGUAGES_TO_COPY
140 AddNewControl.select( iCurrentLanguage )
141 AddNewControl.check()
142 next iCurrentLanguage
143 AddUserInterface.ok()
145 warnlog( "Add User Interface Language dialog is missing" )
148 warnlog( "Unable to open Manage UI Languages dialog" )
151 '///+<li>Store the installed languages for further usage</li>
152 kontext "ManageUILanguages"
153 for iCurrentLanguage = 0 to LANGUAGES_TO_COPY
154 PresentLanguages.select( iCurrentLanguage + 1 )
155 cLanguageList( iCurrentLanguage ) = PresentLanguages.getSelText()
156 printlog( iCurrentLanguage & ": " & cLanguageList( iCurrentLanguage ) )
157 next iCurrentLanguage
159 '///+<li>Close the Manage UI Languages dialog</li>
160 kontext "ManageUILanguages"
161 ManageUILanguages.close()
163 '///+<li>Change the property "NameText" for all languages</li>
164 printlog( "Localizing control" )
165 for iCurrentLanguage = 0 to LANGUAGES_TO_COPY
166 kontext "TranslationBar"
167 CurrentLanguage.select( iCurrentLanguage + 1 )
169 hSelectControl( COMMAND_BUTTON )
170 hOpenPropertyBrowser()
171 printlog( "Setting string: " & cIDStrings( iCurrentLanguage ) )
172 kontext "TabGeneralControl"
173 NameText.typeKeys( cIDStrings( iCurrentLanguage ) & "<RETURN>" )
174 hClosePropertyBrowser()
175 next iCurrentLanguage
177 '///+<li>Execute edit/copy on the currently selected command button</li>
178 printlog( "Copy control" )
181 '///+<li>Create a second dialog</li>
182 printlog( "New dialog" )
185 '///+<li>Paste the content of the clipboard (the control) to the dialog window</li>
186 printlog( "Paste control" )
189 '///+<li>Apply the coordinates from the source control (the control is placed
190 '///+ at random within the dialog pane, now we move it to the same coordinates
191 '///+ as its source control). We wouldn't be able to handle it otherwise</li>
192 hOpenPropertyBrowser()
193 kontext "TabGeneralControl"
194 printlog( "Set coordinates to be identical with those from the source control" )
196 PosX.typeKeys ( "<HOME><SHIFT END>" & iOriginalCoordinates( 3 ) & "<RETURN>" )
197 PosY.typeKeys ( "<HOME><SHIFT END>" & iOriginalCoordinates( 4 ) & "<RETURN>" )
198 Height.typeKeys( "<HOME><SHIFT END>" & iOriginalCoordinates( 1 ) & "<RETURN>" )
199 Width.typeKeys ( "<HOME><SHIFT END>" & iOriginalCoordinates( 2 ) & "<RETURN>" )
200 hClosePropertyBrowser
203 '///+<li>Retrieve the current BASIC IDE internal coordinates of the control for
204 '///+ later usage</li>
205 hOpenPropertyBrowser()
206 kontext "TabGeneralControl"
207 printlog( "Get internal coordinates for the control" )
208 iOriginalCoordinates( 1 ) = height.getText()
209 iOriginalCoordinates( 2 ) = width.getText()
210 iOriginalCoordinates( 3 ) = PosX.getText()
211 iOriginalCoordinates( 4 ) = PosY.getText()
212 printlog( "Height: " & iOriginalCoordinates( 1 ) )
213 printlog( "Width.: " & iOriginalCoordinates( 2 ) )
214 printlog( "Pos X.: " & iOriginalCoordinates( 3 ) )
215 printlog( "Pos Y.: " & iOriginalCoordinates( 4 ) )
216 hClosePropertyBrowser()
219 '///+<li>Get the list of transferred languages from the translation bar</li>
220 kontext "TranslationBar"
221 for iCurrentLanguage = 0 to LANGUAGES_TO_COPY
222 CurrentLanguage.select( iCurrentLanguage + 1 )
223 cTempString = CurrentLanguage.getSelText()
224 if ( cTempString = cLanguageList( iCurrentLanguage ) ) then
225 printlog( "Language <" & cTempString & "> was successfully copied" )
227 warnlog( "Either a language was lost or the sort order changed" )
228 printlog( "Expected: " & cLanguageList( iCurrentLanguage ) )
229 printlog( "Found...: " & cTempString )
231 next iCurrentLanguage