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 : thorsten.bosbach@oracle.com
30 '* short description :
32 '\******************************************************************************
34 testcase tDraw_As_OLE_Object()
36 call ClosePresentationfloat()
37 call hInsertOLEObject( true, gOLEDraw, "DRAW" )
38 'call hInsertOLEObject( false, gOLEDraw, "DRAW" )
42 testcase tCalc_as_OLE_Object()
44 call ClosePresentationfloat()
45 call hInsertOLEObject( true, gOLECalc, "CALC" )
46 'call hInsertOLEObject( false, gOLECalc, "CALC" )
50 testcase tImpress_As_OLE_Object()
52 call ClosePresentationfloat()
53 call hInsertOLEObject( true, gOLEImpress, "IMPRESS" )
54 'call hInsertOLEObject( false, gOLEImpress, "IMPRESS" )
58 testcase tWriter_As_OLE_Object()
60 call ClosePresentationfloat()
61 call hInsertOLEObject( true, gOLEWriter, "WRITER" )
62 'call hInsertOLEObject( false, gOLEWriter, "WRITER" )
66 testcase tMath_As_OLE_Object()
68 call ClosePresentationfloat()
69 call hInsertOLEObject( true, gOLEMath, "MATH" )
70 'call hInsertOLEObject( false, gOLEMath, "MATH" )
74 testcase tChart_As_OLE_Object()
76 call ClosePresentationfloat()
77 call hInsertOLEObject( true, gOLEChart, "CHART" )
78 'call hInsertOLEObject( false, gOLEChart, "CHART" )
82 '*******************************************************************************
84 function hInsertOLEObject( bRemoveFocus as boolean, cOLEObject as string, cOleType as string ) as beoolean
87 dim bOleAvailable as boolean
90 printlog( "Beginning testcase with options: " )
91 printlog( "* Remove focus...: " & bRemoveFocus )
92 printlog( "* OLE object name: " & cOLEObject )
93 printlog( "* OLE object type: " & cOLEType )
94 printlog( "* Document type..: " & gApplication )
97 ' We cannot insert an OLE object of same type as the current document
98 ' So writer/writer, calc/calc, masterdoc/writer is skipped ...
99 if ( gApplication = cOleType ) then
100 printlog( "Skipping " & cOleType & " as OLE object" )
101 hInsertOLEObject() = false
105 if ( gApplication = "MASTERDOCUMENT" and cOleType = "WRITER" ) then
106 printlog( "Skipping " & cOleType & " as OLE object" )
107 hInsertOLEObject() = false
113 printlog( "Menu: insert / object / OLE object" )
114 InsertObjectOLEObject
116 Kontext "OLEObjektEinfuegen"
117 if ( OLEObjektEinfuegen.exists( 1 ) ) then
119 printlog( "Select 'create new'" )
122 printlog( "Select objecttype: " & cOLEObject )
123 ObjektTyp.Select( cOLEObject )
125 printlog( "Click OK" )
126 hCloseDialog( OLEObjektEinfuegen, "ok" )
128 warnlog( "Insert OLE object dialog is missing, test ends" )
130 hInsertOLEObject() = false
134 if ( bRemoveFocus ) then
135 printlog( "Remove focus from OLE object" )
136 call OLERemoveFocus()
138 printlog( "Focus is not to be removed from OLE object" )
140 ' The following can - in some cases - reproduce a nasty crash-bug when
141 ' saving files with selected/activated OLE object
142 select case gApplication
143 case "DRAW" : gMouseClick( 99 , 99 )
144 case "IMPRESS" : gMouseClick( 99 , 99 )
148 sFile = ConvertPath ( gOfficePath + "user\work\ole_" & cOleType )
149 printlog( "Save the file; File to be written (w/o extension): " & sFile )
154 printlog( "Reopen the file: " & sFile )
157 bOleAvailable = isOleAvailable()
158 if ( bOleAvailable ) then
161 if ( Navigator.exists() ) then hCloseDialog( Navigator, "close,optional" )
167 qaErrorLog( "#i44725# OLE Object not saved in Master Document" )
170 printlog( "Cleanup: Close the document, delete workfile" )
173 hInsertOLEObject() = true
177 '*******************************************************************************
179 function isOleAvailable() as boolean
184 const CFN = "isOleAvailable::"
186 printlog( CFN & "Testing whether OLE object is present in Navigator" )
187 ' qaerrorlog( CFN & "Replace me i'm old, poorly written and undocumented" )
189 isOleAvailable = FALSE
190 ' check if OLE-Objects are in the document with the navigator
191 kontext "NavigatorGlobaldoc"
192 if NavigatorGlobaldoc.exists( 1 ) then
193 printlog CFN & "Navigator globaldoc is available"
194 if NOT AuswahlListe.exists then
197 a = AuswahlListe.getItemCount
198 ' somehow not all items might be displayed
201 i = AuswahlListe.getItemCount
208 AuswahlListe.typeKeys("<home>")
211 AuswahlListe.typeKeys("-<down>")
213 ' unfold everything, until there is something to unfold
214 ' then we found the object we looked for: OLE
215 AuswahlListe.typeKeys("<home>")
217 a = AuswahlListe.getItemCount
218 ' don't run indefinite
219 while ((AuswahlListe.getItemCount = a) AND (i < a))
220 AuswahlListe.typeKeys("+<down>")
224 printlog CFN & AuswahlListe.getSelText
226 qaerrorlog CFN & "no item in navigator is selected"
229 AuswahlListe.typeKeys("<return>")
230 i = AuswahlListe.getItemCount
233 isOleAvailable = TRUE
235 isOleAvailable = FALSE
238 Kontext "NavigatorWriter"
239 if NOT NavigatorWriter.exists( 1 ) then
242 Kontext "NavigatorWriter"
243 if NavigatorWriter.exists( 2 ) then ' was 5 secs
244 printlog CFN & "Navigator writer was available"
245 if NOT AuswahlListe.exists then
249 a = AuswahlListe.getItemCount
250 ' somehow not all items might be displayed
253 a = AuswahlListe.getItemCount
258 i = AuswahlListe.getItemCount
265 AuswahlListe.typeKeys("<home>")
268 AuswahlListe.typeKeys("-<down>")
270 ' unfold everything, until there is something to unfold
271 ' then we found the object we looked for: OLE
272 AuswahlListe.typeKeys("<home>")
274 a = AuswahlListe.getItemCount
275 ' don't run indefinite
276 while ((AuswahlListe.getItemCount = a) AND (i < a))
277 AuswahlListe.typeKeys("+<down>")
281 printlog CFN & AuswahlListe.getSelText
283 qaerrorlog CFN & "no item in navigator is selected"
285 i = AuswahlListe.getItemCount
287 AuswahlListe.typeKeys("<return>")
289 isOleAvailable = TRUE
291 isOleAvailable = FALSE
294 kontext "NavigatorDraw"
295 if NavigatorDraw.exists( 2 ) then ' was 5 secs
296 printlog CFN & "Navigator draw is available"
300 kontext "NavigatorDraw"
301 if NavigatorDraw.exists( 2 ) then ' was 5 secs
302 printlog CFN & "Navigator draw is available."
303 if NOT Liste.exists then
306 Liste.typeKeys("<home>")
308 a = Liste.getItemCount
310 Liste.typeKeys("-<down>")
312 ' unfold everything, until there is something to unfold
313 ' then we found the object we looked for: OLE
314 Liste.typeKeys("<home>")
316 a = Liste.getItemCount
317 ' don't run indefinite
318 while ((Liste.getItemCount = a) AND (i < a))
319 Liste.typeKeys("+<down>")
323 printlog CFN & Liste.getSelText
325 qaerrorlog CFN & "no item in navigator is selected"
327 i = Liste.getItemCount
329 isOleAvailable = TRUE
331 isOleAvailable = FALSE
335 ' check if something is selected
338 printlog CFN & "Something was selected; executed Edit->Copy"
339 isOleAvailable = TRUE
341 qaErrorLog CFN & "Nothing is selected."
342 isOleAvailable = FALSE