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 2000, 2010 Oracle and/or its affiliates.
7 ' OpenOffice.org - a multi-platform office productivity suite
9 ' This file is part of OpenOffice.org.
11 ' OpenOffice.org is free software: you can redistribute it and/or modify
12 ' it under the terms of the GNU Lesser General Public License version 3
13 ' only, as published by the Free Software Foundation.
15 ' OpenOffice.org is distributed in the hope that it will be useful,
16 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ' GNU Lesser General Public License version 3 for more details
19 ' (a copy is included in the LICENSE file that accompanied this code).
21 ' You should have received a copy of the GNU Lesser General Public License
22 ' version 3 along with OpenOffice.org. If not, see
23 ' <http://www.openoffice.org/license.html>
24 ' for a copy of the LGPLv3 License.
26 '/******************************************************************************
28 '* owner : gregor.hartmann@oracle.com
30 '* short description : Copy a control with i18n data
32 '\******************************************************************************
34 testcase tBasicDialogI18nCopyControl
37 const COMMAND_BUTTON = 1 ' id of the command button (formcontrols.inc)
38 const DIALOG_NAME = "DialogExport" ' Name of the first module
39 const LANGUAGES_TO_COPY = 5 ' Only copy n languages
40 const TARGET_DIALOG = "Target" ' The name of the dialog the control is pasted to
41 const DEFAULT_TIMEOUT = 2
43 dim cLanguageList( LANGUAGES_TO_COPY ) as string ' Note: Index 0 is used
44 dim iCurrentLanguage as integer
46 ' These are the strings used to simulate localized text
47 dim cIDStrings( 5 ) as string
48 cIDStrings( 0 ) = "language_a"
49 cIDStrings( 1 ) = "language_b"
50 cIDStrings( 2 ) = "language_c"
51 cIDStrings( 3 ) = "language_d"
52 cIDStrings( 4 ) = "language_e"
53 cIDStrings( 5 ) = "language_f"
55 dim cTempString as string
57 ' These are the IDE internal coordinates of the control, used to restore
58 ' identical coordinates in the source and target dialogs
59 dim iOriginalCoordinates( 4 ) as integer
63 printlog( "Test init: Setting up environment" )
64 if ( hInitFormControls( DIALOG_NAME ) ) then
66 printlog( "Draw a commandbutton on the dialog" )
67 hDrawControlOnDialog( COMMAND_BUTTON )
69 printlog( "Open the property browser" )
70 hOpenPropertyBrowser()
71 kontext "TabGeneralControl"
72 printlog( "Get internal coordinates for the control" )
73 iOriginalCoordinates( 1 ) = height.getText()
74 iOriginalCoordinates( 2 ) = width.getText()
75 iOriginalCoordinates( 3 ) = PosX.getText()
76 iOriginalCoordinates( 4 ) = PosY.getText()
77 printlog( "Height: " & iOriginalCoordinates( 1 ) )
78 printlog( "Width.: " & iOriginalCoordinates( 2 ) )
79 printlog( "Pos X.: " & iOriginalCoordinates( 3 ) )
80 printlog( "Pos Y.: " & iOriginalCoordinates( 4 ) )
81 hClosePropertyBrowser()
83 qaerrorlog( "#i80456# properties button not enabled when a formcontrol is inserted via keyboard" )
85 kontext "ToolsCollectionBar"
86 printlog( "Click <Manage Languages>" )
87 ManageLanguage.click()
89 kontext "ManageUILanguages"
90 if ( ManageUILanguages.exists( DEFAULT_TIMEOUT ) ) then
92 printlog( "Click <Add>" )
95 kontext "SetDefaultLanguage"
96 if ( SetDefaultLanguage.exists( DEFAULT_TIMEOUT ) ) then
97 hCloseDialog( SetDefaultLanguage, "ok" )
99 warnlog( "Set Default Language dialog is missing" )
102 warnlog( "Unable to open Manage UI Languages dialog" )
105 kontext "ManageUILanguages"
106 if ( ManageUILanguages.exists( DEFAULT_TIMEOUT ) ) then
108 printlog( "Click <Add>" )
111 kontext "AddUserInterface"
112 if ( AddUserInterface.exists( DEFAULT_TIMEOUT ) ) then
113 for iCurrentLanguage = 1 to LANGUAGES_TO_COPY
114 AddNewControl.select( iCurrentLanguage )
115 AddNewControl.check()
116 next iCurrentLanguage
117 hCloseDialog( AddUserInterface, "ok" )
119 warnlog( "Add User Interface Language dialog is missing" )
122 warnlog( "Unable to open Manage UI Languages dialog" )
125 kontext "ManageUILanguages"
126 for iCurrentLanguage = 0 to LANGUAGES_TO_COPY
127 PresentLanguages.select( iCurrentLanguage + 1 )
128 cLanguageList( iCurrentLanguage ) = PresentLanguages.getSelText()
129 printlog( iCurrentLanguage & ": " & cLanguageList( iCurrentLanguage ) )
130 next iCurrentLanguage
132 kontext "ManageUILanguages"
133 hCloseDialog( ManageUILanguages, "close" )
135 printlog( "Localizing control" )
136 for iCurrentLanguage = 0 to LANGUAGES_TO_COPY
137 kontext "TranslationBar"
138 CurrentLanguage.select( iCurrentLanguage + 1 )
140 hSelectControl( COMMAND_BUTTON )
141 hOpenPropertyBrowser()
142 printlog( "Setting string: " & cIDStrings( iCurrentLanguage ) )
143 kontext "TabGeneralControl"
144 NameText.typeKeys( cIDStrings( iCurrentLanguage ) & "<RETURN>" )
145 hClosePropertyBrowser()
146 next iCurrentLanguage
148 printlog( "Copy control" )
149 hUseAsyncSlot( "EditCopy" )
151 printlog( "New dialog" )
154 printlog( "Paste control" )
155 hUseAsyncSlot( "EditPaste" )
157 hOpenPropertyBrowser()
158 kontext "TabGeneralControl"
159 printlog( "Set coordinates to be identical with those from the source control" )
161 PosX.typeKeys ( "<HOME><SHIFT END>" & iOriginalCoordinates( 3 ) & "<RETURN>" )
162 PosY.typeKeys ( "<HOME><SHIFT END>" & iOriginalCoordinates( 4 ) & "<RETURN>" )
163 Height.typeKeys( "<HOME><SHIFT END>" & iOriginalCoordinates( 1 ) & "<RETURN>" )
164 Width.typeKeys ( "<HOME><SHIFT END>" & iOriginalCoordinates( 2 ) & "<RETURN>" )
165 hClosePropertyBrowser
168 hOpenPropertyBrowser()
169 kontext "TabGeneralControl"
170 printlog( "Get internal coordinates for the control" )
171 iOriginalCoordinates( 1 ) = height.getText()
172 iOriginalCoordinates( 2 ) = width.getText()
173 iOriginalCoordinates( 3 ) = PosX.getText()
174 iOriginalCoordinates( 4 ) = PosY.getText()
175 printlog( "Height: " & iOriginalCoordinates( 1 ) )
176 printlog( "Width.: " & iOriginalCoordinates( 2 ) )
177 printlog( "Pos X.: " & iOriginalCoordinates( 3 ) )
178 printlog( "Pos Y.: " & iOriginalCoordinates( 4 ) )
179 hClosePropertyBrowser()
182 kontext "TranslationBar"
183 for iCurrentLanguage = 0 to LANGUAGES_TO_COPY
184 CurrentLanguage.select( iCurrentLanguage + 1 )
185 cTempString = CurrentLanguage.getSelText()
186 if ( cTempString = cLanguageList( iCurrentLanguage ) ) then
187 printlog( "Language <" & cTempString & "> was successfully copied" )
189 warnlog( "Either a language was lost or the sort order changed" )
190 printlog( "Expected: " & cLanguageList( iCurrentLanguage ) )
191 printlog( "Found...: " & cTempString )
193 next iCurrentLanguage
197 warnlog( "Failed to initialize dialog" )