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_3.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 :
38 '\******************************************************************************
40 testcase tDraw_As_OLE_Object()
42 '///<h1>Insert, save, reload, close files with Draw as OLE object</h1>
43 call ClosePresentationfloat()
44 call hInsertOLEObject( true, gOLEDraw, "DRAW" )
45 'call hInsertOLEObject( false, gOLEDraw, "DRAW" )
49 testcase tCalc_as_OLE_Object()
51 '///<h1>Insert, save, reload, close files with Calc as OLE object</h1>
52 call ClosePresentationfloat()
53 call hInsertOLEObject( true, gOLECalc, "CALC" )
54 'call hInsertOLEObject( false, gOLECalc, "CALC" )
58 testcase tImpress_As_OLE_Object()
60 '///<h1>Insert, save, reload, close files with Impress as OLE object</h1>
61 call ClosePresentationfloat()
62 call hInsertOLEObject( true, gOLEImpress, "IMPRESS" )
63 'call hInsertOLEObject( false, gOLEImpress, "IMPRESS" )
67 testcase tWriter_As_OLE_Object()
69 '///<h1>Insert, save, reload, close files with Writer as OLE object</h1>
70 call ClosePresentationfloat()
71 call hInsertOLEObject( true, gOLEWriter, "WRITER" )
72 'call hInsertOLEObject( false, gOLEWriter, "WRITER" )
76 testcase tMath_As_OLE_Object()
78 '///<h1>Insert, save, reload, close files with Math as OLE object</h1>
79 call ClosePresentationfloat()
80 call hInsertOLEObject( true, gOLEMath, "MATH" )
81 'call hInsertOLEObject( false, gOLEMath, "MATH" )
85 testcase tChart_As_OLE_Object()
87 '///<h1>Insert, save, reload, close files with Chart as OLE object</h1>
88 call ClosePresentationfloat()
89 call hInsertOLEObject( true, gOLEChart, "CHART" )
90 'call hInsertOLEObject( false, gOLEChart, "CHART" )
94 '*******************************************************************************
96 sub hInsertOLEObject( bRemoveFocus as boolean, cOLEObject as string, cOleType as string )
99 dim bOleAvailable as boolean
101 '///<h3>Insert OLE objects into the applications / all possible combinations</h3>
104 '///+<li>bRemoveFocus (boolean)</li>
106 '///+<li>TRUE = Click into the application frame to remove focus from OLE object before saving</li>
107 '///+<li>FALSE = Do not remove focus from OLE object</li>
109 '///+<li>cOLEObject (string).</li>
111 '///+<li>Any valid entry stored in gOLExxxx (set those with GetOLEDefaultNames())</li>
114 '///+<li>cOLEType (string). valid options are:
116 '///+<li>"WRITER"</li>
117 '///+<li>"CALC"</li>
118 '///+<li>"DRAW"</li>
119 '///+<li>"IMPRESS"</li>
120 '///+<li>"CHART"</li>
121 '///+<li>"MATH"</li>
127 '///+<li>Nothing</li>
130 '///<u>Description</u>:
134 printlog( "Beginning testcase with options: " )
135 printlog( "* Remove focus...: " & bRemoveFocus )
136 printlog( "* OLE object name: " & cOLEObject )
137 printlog( "* OLE object type: " & cOLEType )
138 printlog( "* Document type..: " & gApplication )
141 ' We cannot insert an OLE object of same type as the current document
142 ' So writer/writer, calc/calc, masterdoc/writer is skipped ...
143 if ( gApplication = cOleType ) then
144 printlog( "Skipping " & cOleType & " as OLE object" )
148 if ( gApplication = "MASTERDOCUMENT" and cOleType = "WRITER" ) then
149 printlog( "Skipping " & cOleType & " as OLE object" )
153 '///+<li>Open a new document ( Writer / Calc / Draw / Masterdocument ... )</li>
156 '///+<li>Insert / object / OLE-object</li>
157 printlog( "Menu: insert / object / OLE object" )
158 InsertObjectOLEObject
160 Kontext "OLEObjektEinfuegen"
161 if ( OLEObjektEinfuegen.exists( 1 ) ) then
163 '///+<li>Select 'create new'</li>
164 printlog( "Select 'create new'" )
167 '///+<li>Select the draw-OLE-object ( you can find the name for each language at [TesttoolPath]/global/input/olenames/ole_[lang-code].txt )</li>
168 printlog( "Select objecttype: " & cOLEObject )
169 ObjektTyp.Select( cOLEObject )
171 '///+<li>Click 'OK'</li>
172 printlog( "Click OK" )
173 OLEObjektEinfuegen.OK()
176 warnlog( "Insert OLE object dialog is missing, test ends" )
181 '///+<li>Optionally remove focus from OLE object</li>
182 if ( bRemoveFocus ) then
183 printlog( "Remove focus from OLE object" )
184 call OLERemoveFocus()
186 printlog( "Focus is not to be removed from OLE object" )
188 ' The following can - in some cases - reproduce a nasty crash-bug when
189 ' saving files with selected/activated OLE object
190 select case gApplication
191 case "DRAW" : gMouseClick( 99 , 99 )
192 case "IMPRESS" : gMouseClick( 99 , 99 )
196 '///+<li>Build the filename with full path but without suffix</li>
197 sFile = ConvertPath ( gOfficePath + "user\work\ole_" & cOleType )
198 printlog( "Save the file; File to be written (w/o extension): " & sFile )
199 if fileexists(sFile) then
201 qaerrorlog("killed file from former test run")
204 '///+<li>Save the file via FileSave, current fileformat, overwrite</li>
205 hFileSaveAsKill( sFile )
207 '///+<li>Close the document</li>
208 printlog( "Close the document" )
211 '///+<li>Load the file again via FileOpen (filename with suffix)</li>
212 printlog( "Reopen the file: " & sFile )
215 '///+<li>Check that the OLE object is listed in the navigator</li>
216 bOleAvailable = isOleAvailable()
217 if ( bOleAvailable ) then
219 '///+<li>Disable the navigator if it exists</li>
220 call DisableNavigator()
222 '///+<li>Set focus to OLE object</li>
225 '///+<li>Remove focus from OLE object</li>
228 qaErrorLog( "#i44725# OLE Object not saved in Master Document" )
231 '///+<li>Cleanup: Close the document</li>
232 printlog( "Cleanup: Close the document" )
235 '///+<li>Cleanup: Delete the workfile</li>
236 printlog( "Cleanup: Delete the workfile" )
240 ' We end up here when the test has been skipped or aborted
245 '*******************************************************************************
247 function isOleAvailable() as boolean
249 '///<h3>Funtion to determine whether OLE is available</h3>
253 const CFN = "isOleAvailable::"
255 printlog( CFN & "Testing whether OLE object is present in Navigator" )
256 ' qaerrorlog( CFN & "Replace me i'm old, poorly written and undocumented" )
258 isOleAvailable = FALSE
259 ' check if OLE-Objects are in the document with the navigator
260 kontext "NavigatorGlobaldoc"
261 if NavigatorGlobaldoc.exists( 1 ) then
262 printlog CFN & "Navigator globaldoc is available"
263 if NOT AuswahlListe.exists then
266 a = AuswahlListe.getItemCount
267 ' somehow not all items might be displayed
270 i = AuswahlListe.getItemCount
277 AuswahlListe.typeKeys("<home>")
280 AuswahlListe.typeKeys("-<down>")
282 ' unfold everything, until there is something to unfold
283 ' then we found the object we looked for: OLE
284 AuswahlListe.typeKeys("<home>")
286 a = AuswahlListe.getItemCount
287 ' don't run indefinite
288 while ((AuswahlListe.getItemCount = a) AND (i < a))
289 AuswahlListe.typeKeys("+<down>")
293 printlog CFN & AuswahlListe.getSelText
295 qaerrorlog CFN & "no item in navigator is selected"
298 AuswahlListe.typeKeys("<return>")
299 i = AuswahlListe.getItemCount
302 isOleAvailable = TRUE
304 isOleAvailable = FALSE
307 Kontext "NavigatorWriter"
308 if NOT NavigatorWriter.exists( 1 ) then
311 Kontext "NavigatorWriter"
312 if NavigatorWriter.exists( 2 ) then ' was 5 secs
313 printlog CFN & "Navigator writer was available"
314 if NOT AuswahlListe.exists then
318 a = AuswahlListe.getItemCount
319 ' somehow not all items might be displayed
322 a = AuswahlListe.getItemCount
327 i = AuswahlListe.getItemCount
334 AuswahlListe.typeKeys("<home>")
337 AuswahlListe.typeKeys("-<down>")
339 ' unfold everything, until there is something to unfold
340 ' then we found the object we looked for: OLE
341 AuswahlListe.typeKeys("<home>")
343 a = AuswahlListe.getItemCount
344 ' don't run indefinite
345 while ((AuswahlListe.getItemCount = a) AND (i < a))
346 AuswahlListe.typeKeys("+<down>")
350 printlog CFN & AuswahlListe.getSelText
352 qaerrorlog CFN & "no item in navigator is selected"
354 i = AuswahlListe.getItemCount
356 AuswahlListe.typeKeys("<return>")
358 isOleAvailable = TRUE
360 isOleAvailable = FALSE
363 kontext "NavigatorDraw"
364 if NavigatorDraw.exists( 2 ) then ' was 5 secs
365 printlog CFN & "Navigator draw is available"
369 kontext "NavigatorDraw"
370 if NavigatorDraw.exists( 2 ) then ' was 5 secs
371 printlog CFN & "Navigator draw is available."
372 if NOT Liste.exists then
375 Liste.typeKeys("<home>")
377 a = Liste.getItemCount
379 Liste.typeKeys("-<down>")
381 ' unfold everything, until there is something to unfold
382 ' then we found the object we looked for: OLE
383 Liste.typeKeys("<home>")
385 a = Liste.getItemCount
386 ' don't run indefinite
387 while ((Liste.getItemCount = a) AND (i < a))
388 Liste.typeKeys("+<down>")
392 printlog CFN & Liste.getSelText
394 qaerrorlog CFN & "no item in navigator is selected"
396 i = Liste.getItemCount
398 isOleAvailable = TRUE
400 isOleAvailable = FALSE
404 ' check if something is selected
407 printlog CFN & "Something was selected; executed Edit->Copy"
408 isOleAvailable = TRUE
410 qaErrorLog CFN & "Nothing is selected."
411 isOleAvailable = FALSE