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: ole_tools.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 12:18:15 $
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 : thorsten.bosbach@sun.com
36 '* short description : global-level-1-test -> insert all OLE-Objects out of OLE-dialog into all doc-types
38 '\******************************************************************************
41 'Only for bughandling if closing an OLE object fails
42 Warnlog "Cannot release Chart Object -> #107005#?"
44 'if Active.Exists ( 1 ) then Active.TypeKeys "<RIGHT><ENTER>"
48 '*******************************************************************************
50 sub hOleSelektieren ( xStart%, yStart%, xEnde%, yEnde% )
52 select case gApplication
53 case "CALC" :Kontext "DocumentCalc"
54 DocumentCalc.MouseDown xStart%, yStart%
55 DocumentCalc.MouseMove xEnde%, yEnde%
56 DocumentCalc.MouseUp xEnde%, yEnde%
58 case "DRAW" :Kontext "DocumentDraw"
59 DocumentDraw.MouseDown xStart%, yStart%
60 DocumentDraw.MouseMove xEnde%, yEnde%
61 DocumentDraw.MouseUp xEnde%, yEnde%
62 case "WRITER" :Kontext "DocumentWriter"
63 DocumentWriter.MouseDown xStart%, yStart%
64 DocumentWriter.MouseMove xEnde%, yEnde%
65 DocumentWriter.MouseUp xEnde%, yEnde%
66 case "IMPRESS" :Kontext "DocumentImpress"
67 DocumentImpress.MouseDown xStart%, yStart%
68 DocumentImpress.MouseMove xEnde%, yEnde%
69 DocumentImpress.MouseUp xEnde%, yEnde%
70 case "MATH" :Kontext "DocumentMath"
71 DocumentMath.MouseDown xStart%, yStart%
72 DocumentMath.MouseMove xEnde%, yEnde%
73 DocumentMath.MouseUp xEnde%, yEnde%
74 case "MASTERDOCUMENT":Kontext "DocumentMasterDoc"
75 DocumentMasterDoc.MouseDown xStart%, yStart%
76 DocumentMasterDoc.MouseMove xEnde%, yEnde%
77 DocumentMasterDoc.MouseUp xEnde%, yEnde%
81 '*******************************************************************************
83 sub hSetToStandardView ( DieApp$ )
86 gApplication = "WRITER"
88 Kontext "DocumentWriter"
90 gApplication = "MASTERDOCUMENT"
92 Kontext "DocumentMasterDoc"
101 '*******************************************************************************
103 sub SendEscape(optional iTimes as Integer)
105 const ICWAIT as Integer = 1
107 if IsMissing( iTimes ) then
111 printlog( " - send <ESCAPE> keystroke to document" )
112 select case gApplication
114 Kontext "DocumentWriter"
117 DocumentWriter.TypeKeys( "<ESCAPE>" , 1 , TRUE )
120 Kontext "DocumentCalc"
123 DocumentCalc.TypeKeys( "<ESCAPE>" , 1 , TRUE )
125 case "MASTERDOCUMENT"
126 Kontext "DocumentMasterDoc"
129 DocumentMasterDoc.TypeKeys( "<ESCAPE>" , 1 , TRUE )
132 Kontext "DocumentDraw"
135 DocumentDraw.TypeKeys( "<ESCAPE>" , 1 , TRUE )
138 Kontext "DocumentImpress"
141 DocumentImpress.TypeKeys( "<ESCAPE>" , 1 , TRUE )
144 warnlog( "Invalid gApplication: " & gApplication )
148 '*******************************************************************************
150 sub DisableNavigator()
151 printlog( " - disable the navigator in globaldoc/writer" )
152 select case gApplication
153 case "MASTERDOCUMENT" : Kontext "NavigatorGlobalDoc"
154 if NavigatorGlobalDoc.Exists() then
157 case "WRITER" : Kontext "NavigatorWriter"
158 if NavigatorWriter.Exists() then
165 '*******************************************************************************
167 sub UncheckAutoFileExtension()
168 '///+uncheck automatic file extension, if checked
169 Kontext "SpeichernDlg"
170 if SpeichernDlg.exists(5) then
171 if AutomatischeDateinamenserweiterung.Exists() then
172 printlog("l1_ole_tools::UncheckAutoFileExtension - unchecking automatic file extension" )
173 If AutomatischeDateinamenserweiterung.IsChecked() then
174 AutomatischeDateinamenserweiterung.Uncheck()
177 QAErrorLog ( "OBSOLETE: l1_ole_tools::UncheckAutoFileExtension Checkbox 'Automatic Filename Extension' unavailable" )
180 warnlog( "l1_ole_tools::UncheckAutoFileExtension SaveAs Dialog not open." )
184 '*******************************************************************************
186 function getExtension( optional sExtension as string ) as string
187 qaerrorlog( "getExtension is outdated. Use hGetSuffix( ... ) instead" )
188 printlog("l1_ole_ttols::getExtension:: - define the expected file extension" )
189 select case gApplication
200 case "MASTERDOCUMENT"
203 warnlog( "Invalid gApplication: " & gApplication )
205 getExtension = sExtension
208 '*******************************************************************************
211 '///+activate the OLE-Object with a doubleclick
212 const ICWAIT as Integer = 10
213 PrintLog " - set focus to OLE object (edit mode)"
214 select case gApplication
216 printlog " Select and deselect " + gApplication
217 Kontext "DocumentWriter"
218 DocumentWriter.TypeKeys("<F6>" , 4 , TRUE )
219 DocumentWriter.TypeKeys("<DOWN>" , 3 , TRUE )
220 DocumentWriter.TypeKeys("<RIGHT>" , 1 , TRUE )
221 DocumentWriter.TypeKeys("<MOD1 RETURN>" , 1 , TRUE )
222 DocumentWriter.TypeKeys("<TAB>" , 1 , TRUE )
223 DocumentWriter.TypeKeys("<RETURN>" , 1 , TRUE )
224 'DocumentWriter.MouseDoubleClick ( 50, 50 )
226 call SendEscape( 3 ) '(to close the float as well)
228 printlog " Select and deselect " + gApplication
229 Kontext "DocumentImpress"
230 DocumentImpress.MouseDoubleClick ( 50, 50 )
233 printlog " Select and deselect " + gApplication
234 Kontext "DocumentCalc"
235 DocumentCalc.TypeKeys( "<F6>" , 5 , TRUE )
236 DocumentCalc.TypeKeys( "<DOWN>" , 3 , TRUE )
237 DocumentCalc.TypeKeys( "<MOD1 RETURN>" , 1 , TRUE )
238 DocumentCalc.TypeKeys( "<RETURN>" , 1 , TRUE )
239 'gMouseClick ( 20, 20 )
240 'DocumentCalc.MouseDoubleClick ( 20, 20 )
242 call SendEscape( 3 ) '(to close the float as well)
243 case "MASTERDOCUMENT"
244 printlog " Select and deselect " + gApplication
245 Kontext "DocumentMasterDoc"
246 DocumentMasterDoc.MouseDown( 50 , 50 , 1 )
247 DocumentMasterDoc.MouseUp( 50 , 50 , 1 )
248 hUseAsyncSlot( "EditObjectEdit" )
251 warnlog( "Invalid gApplication: " & gApplication )
256 '*******************************************************************************
259 '///+activate the OLE-Object with a doubleclick
261 const ICWAIT as Integer = 1
262 PrintLog " - set focus to OLE object (edit mode)"
263 select case gApplication
265 Kontext "DocumentWriter"
268 Kontext ' This is by intention, do not change!
269 active.SetPage TabType
272 hUseAsyncSlot( "EditObjectEdit" )
274 warnlog "Can't activate object"
277 gMouseClick ( 5 , 5 ) 'out of edit mode
278 gMouseClick ( 5 , 5 ) 'remove focus
280 Kontext "DocumentDraw"
281 if OLEApp = "MATH" then
282 DocumentDraw.MouseDoubleClick ( 45, 46 )
284 DocumentDraw.MouseDoubleClick ( 50, 45 )
287 gMouseClick ( 1 , 1 )
289 Kontext "DocumentImpress"
290 printlog( " - using accessibility shortcuts for objecthandling" )
291 printlog( " (select, activate and release object)" )
292 DocumentImpress.TypeKeys( "<F6>" , 5 , TRUE )
293 DocumentImpress.TypeKeys( "<TAB><RETURN>" )
297 Kontext "DocumentCalc"
298 printlog( " - using accessibility shortcuts for objecthandling" )
299 printlog( " (select, activate and release object)" )
300 DocumentCalc.TypeKeys( "<F6>" , 5 , TRUE )
301 DocumentCalc.TypeKeys( "<DOWN>" , 3 , TRUE )
302 DocumentCalc.TypeKeys( "<RIGHT>" , 1 , TRUE )
303 DocumentCalc.TypeKeys( "<MOD1 RETURN>" , 1 , TRUE )
304 DocumentCalc.TypeKeys( "<RETURN>" , 1 , TRUE )
307 case "MASTERDOCUMENT"
308 Kontext "DocumentMasterDoc"
312 Kontext ' This is by intention, do not change!
313 Active.SetPage TabType
316 hUseAsyncSlot( "EditObjectEdit" )
318 qaerrorlog( "The object is not selected after reload." )
321 Kontext "DocumentMasterDoc"
322 DocumentMasterDoc.MouseDoubleClick ( 1 , 1 )
324 warnlog( "Invalid gApplication: " & gApplication )
329 '*******************************************************************************
332 'TODO: Get rid of as many mousemovements as possible
334 const ICWAIT as Integer = 1
335 printlog( " - set focus to OLE object (edit mode)" )
336 select case gApplication
338 Kontext "DocumentWriter"
342 Kontext ' This is by intention, do not change!
343 active.SetPage TabType
346 hUseAsyncSlot( "EditObjectEdit" )
348 warnlog "Can't activate object"
353 Kontext "DocumentDraw"
354 DocumentDraw.TypeKeys ("<Tab>")
355 DocumentDraw.MouseDoubleClick ( 50, 50 )
359 Kontext "DocumentImpress"
360 printlog( " - Using accessibility-shortcuts to manipulate object")
361 DocumentImpress.TypeKeys( "<TAB>" )
363 DocumentImpress.TypeKeys( "<SHIFT RETURN>" )
365 case "MASTERDOCUMENT"
366 Kontext "DocumentMasterDoc"
370 Kontext ' This is by intention, do not change!
371 active.SetPage( TabType )
374 hUseAsyncSlot( "EditObjectEdit" )
376 qaerrorlog( "The object is not selected after reload." )
381 warnlog( "Invalid gApplication: " & gApplication )
386 '*******************************************************************************
389 '///+Deselect OLE object
390 printlog( "Remove focus from OLE object for " & gApplication )
391 select case gApplication
392 case "WRITER" : call SendEscape( 2 )
393 case "MASTERDOCUMENT" : Kontext "DocumentMasterDoc"
394 DocumentMasterDoc.MouseDoubleClick ( 1, 1 )
395 case "IMPRESS" : gMouseClick ( 5, 99 )
396 case "CALC" : Kontext "DocumentCalc"
401 '*******************************************************************************
403 sub ClosePresentationFloat()
404 gApplication = "IMPRESS"
405 '///+Open a new document
406 printlog( "Open a new document" )
408 'use the tiny little hammer to kill the presentation float
409 printlog( "Reset the application (which closes the presentation toolbar)" )
411 '///+Open a new document
412 printlog( "Open a new document" )
414 '///+Look if the presentation toolbar is visible, if yes->warning
415 Kontext "CommonTaskbar"
417 printlog( "Try to click a button on the presentation toolbar" )
418 Seiteduplizieren.click()
419 warnlog( "The presentation toolbar is open" )
421 printlog( "Button is unavailable. Good" )
423 '///+Close the document
424 printlog( "Close the document" )
426 gApplication = "WRITER" ' reset, just in case...
430 '*******************************************************************************
432 function hStepThroughChartWizard() as boolean
435 '///<h3>Step through the Chart Wizard leaving all defaults</h3>
436 '///<i>This functin just steps through the Chart Wizard using the
437 '///+ "Next..." button on each page. It will not change any
438 '///+ values under way. The Wizard is closed using the "Finish"
439 '///+ button.</i><br><br>
441 '///<u>Parameter(s):</u><br>
443 '///+<li>No input parameters</li>
447 '///<u>Returns:</u><br>
449 '///+<li>Errorcondition (Boolean)</li>
451 '///+<li>TRUE: Wizard finished without errors</li>
452 '///+<li>FALSE: Wizard did not open</li>
453 '///+<li>In case of problems you need to perfom recovery yourself</li>
457 const CFN = "hStepThroughChartWizard::"
458 printlog( CFN & "Enter" )
459 dim brc as boolean 'a multi purpose boolean returnvalue
461 '///<u>Description:</u>
463 '///+<li>Verify that the Chart Wizard is open</li>
464 Kontext "ChartWizard"
465 if ( not chartWizard.exists( 1 ) ) then
467 warnlog( CFN & "Chart Wizard not open within reasonable time" )
468 hStepThroughChartWizard() = false
472 '///+<li>Click "Next" on the first page of the Chart wizard</li>
473 Kontext "ChartWizard"
476 '///+<li>Click "Next" on the second page of the Chart wizard</li>
477 Kontext "ChartWizard"
480 '///+<li>Click "Next" on the third page of the Chart wizard</li>
481 Kontext "ChartWizard"
484 '///+<li>Click "Finish" on the fourth page of the Chart wizard</li>
485 Kontext "ChartWizard"
491 '///+<li>Verify that the Chart Wizard is closed</li>
492 kontext "ChartWizard"
493 if ( ChartWizard.exists( 1 ) ) then
494 warnlog( CFN & "Chart Wizard is still open" )
499 printlog( CFN & "Exit" )
501 hStepThroughChartWizard() = true