xref: /aoo41x/main/smoketestdoc/data/Test_10er.xml (revision cdf0e10c)
1<?xml version="1.0" encoding="UTF-8"?>
2<!--**********************************************************************
3*
4* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5*
6* Copyright 2000, 2010 Oracle and/or its affiliates.
7*
8* OpenOffice.org - a multi-platform office productivity suite
9*
10* This file is part of OpenOffice.org.
11*
12* OpenOffice.org is free software: you can redistribute it and/or modify
13* it under the terms of the GNU Lesser General Public License version 3
14* only, as published by the Free Software Foundation.
15*
16* OpenOffice.org is distributed in the hope that it will be useful,
17* but WITHOUT ANY WARRANTY; without even the implied warranty of
18* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19* GNU Lesser General Public License version 3 for more details
20* (a copy is included in the LICENSE file that accompanied this code).
21*
22* You should have received a copy of the GNU Lesser General Public License
23* version 3 along with OpenOffice.org.  If not, see
24* <http://www.openoffice.org/license.html>
25* for a copy of the LGPLv3 License.
26*
27**********************************************************************-->
28<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
29<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Test_10er" script:language="StarBasic">REM  10er Test
30
31const sSWLogFileName = &quot;swlog.dat&quot;, sSCLogFileName = &quot;sclog.dat&quot;
32const sSDLogFileName = &quot;sdlog.dat&quot;, sSMathLogFileName = &quot;smalog.dat&quot;
33const sSChartLogFileName = &quot;schlog.dat&quot;
34const sSHptLogFileName = &quot;shptlog.dat&quot;
35const sSDrawLogFileName = &quot;sdrwlog.dat&quot;, sJavaLogFileName = &quot;javalog.dat&quot;
36const sSDBLogFileName = &quot;dblog.dat&quot;, sExtLogFileName = &quot;extlog.dat&quot;
37const sTestGlueLogFileName = &quot;testclosure.log&quot;
38const sLogFileName = &quot;smoketest.log&quot;
39const cTempFileName = &quot;smoketest_file&quot;
40
41const cMessageSaveOpen8Doc = &quot;Save/Open open Documents (8.0)&quot;
42const cMessageSaveOpenXMLDoc = &quot;Save/Open Document XML (6/7)&quot;
43const cMessageNewDoc = &quot;New Document&quot;
44const cMessageCloseDoc = &quot;Close Document&quot;
45
46Global sWorkPath$
47Global sWorkPathURL$
48Global LocalTestLog%
49Global GlobalTestLog%
50
51Sub Main
52	call TestAllDocs()
53end Sub
54
55Sub DeleteAllSavedFiles()
56	Dim sFileName as String
57	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmWriter)
58	If FileExists (sFileName) then
59		Kill (sFileName)
60	End If
61	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmCalc)
62	If FileExists (sFileName) then
63		Kill (sFileName)
64	End If
65	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmImpress)
66	If FileExists (sFileName) then
67		Kill (sFileName)
68	End If
69	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmDraw)
70	If FileExists (sFileName) then
71		Kill (sFileName)
72	End If
73	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmHyperText)
74	If FileExists (sFileName) then
75		Kill (sFileName)
76	End If
77	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmWriter or cFltXML)
78	If FileExists (sFileName) then
79		Kill (sFileName)
80	End If
81	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmCalc or cFltXML)
82	If FileExists (sFileName) then
83		Kill (sFileName)
84	End If
85	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmImpress or cFltXML)
86	If FileExists (sFileName) then
87		Kill (sFileName)
88	End If
89	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmDraw or cFltXML)
90	If FileExists (sFileName) then
91		Kill (sFileName)
92	End If
93End Sub
94
95Sub DeleteAllLogFiles()
96	If FileExists (sWorkPath+sLogFileName) then
97		Kill (sWorkPath+sLogFileName)
98	End If
99	If FileExists (sWorkPath+sSWLogFileName) then
100		Kill (sWorkPath+sSWLogFileName)
101	End If
102	If FileExists (sWorkPath+sSCLogFileName) then
103		Kill (sWorkPath+sSCLogFileName)
104	End If
105	If FileExists (sWorkPath+sSDLogFileName) then
106		Kill (sWorkPath+sSDLogFileName)
107	End If
108	If FileExists (sWorkPath+sSMathLogFileName) then
109		Kill (sWorkPath+sSMathLogFileName)
110	End If
111	If FileExists (sWorkPath+sSChartLogFileName) then
112		Kill (sWorkPath+sSChartLogFileName)
113	End If
114	If FileExists (sWorkPath+sSHptLogFileName) then
115		Kill (sWorkPath+sSHptLogFileName)
116	End If
117	If FileExists (sWorkPath+sSDrawLogFileName) then
118		Kill (sWorkPath+sSDrawLogFileName)
119	End If
120	If FileExists (sWorkPath+sJavaLogFileName) then
121		Kill (sWorkPath+sJavaLogFileName)
122	End If
123	If FileExists (sWorkPath+sTestGlueLogFileName) then
124		Kill (sWorkPath+sTestGlueLogFileName)
125	End If
126	If FileExists (sWorkPath+sSDBLogFileName) then
127		Kill (sWorkPath+sSDBLogFileName)
128	End If
129	If FileExists (sWorkPath+sExtLogFileName) then
130		Kill (sWorkPath+sExtLogFileName)
131	End If
132end Sub
133
134Function OpenLogDat (sFileName as String) as Integer
135	Dim LocaleFileChannel%
136	If FileExists (sWorkPath+sFileName) then
137		Kill (sWorkPath+sFileName)
138	End If
139	LocaleFileChannel% = Freefile
140	Open sWorkPath+sFileName For Output As LocaleFileChannel%
141	OpenLogDat = LocaleFileChannel%
142end Function
143
144Sub SetupWorkPath
145	Dim configManager as Object
146	configManager = CreateUnoService( &quot;com.sun.star.config.SpecialConfigManager&quot; )
147
148	sWorkPath = configManager.SubstituteVariables( &quot;$(userpath)/temp/&quot; )
149	sWorkPathURL = configManager.SubstituteVariables( &quot;$(userurl)/temp/&quot; )
150End Sub
151
152Function GetSystem (sTmpWorkPath as string) as string
153	GetSystem = &quot;&quot;
154	if InStr (sTmpWorkPath, &quot;:&quot;) then
155		GetSystem = &quot;windows&quot;
156	else
157		GetSystem = &quot;unix&quot;
158	End If
159end Function
160
161Function ConvertPathToWin (sTmpWorkPath as string) as string
162	for i%=1 to Len(sTmpWorkPath)
163		sTemp = Mid (sTmpWorkPath, i%, 1)
164		if sTemp = &quot;/&quot; then
165			sTmpWorkPath = Left (sTmpWorkPath, i%-1) + &quot;\&quot; + Right (sTmpWorkPath, Len(sTmpWorkPath)-i%)
166		else
167			if sTemp = &quot;|&quot; then
168				sTmpWorkPath = Left (sTmpWorkPath, i%-1) + &quot;:&quot; + Right (sTmpWorkPath, Len(sTmpWorkPath)-i%)
169			end If
170		end If
171	next i%
172	ConvertPathToWin = sTmpWorkPath
173end Function
174
175Sub TestAllDocs()
176DIM sDocURL as String, sDocPath as String
177DIM nStrPos as Long
178
179	&apos;search ExtensionURL
180	sDocURL = gOutputDoc.URL
181	CompatibilityMode(true)
182	nStrPos = InStrRev (sDocURL, &quot;/&quot; )
183	CompatibilityMode(false)
184	sExtensionURL = Left (sDocURL, nStrPos)
185
186	GlobalTestLog = OpenLogDat (sLogFileName)
187	call WriteTestSequence
188	if bMakeWriterTest then
189    gCurrentDocTest = frmWriter
190		call MakeDocTest
191	end if
192	if bMakeCalcTest then
193    gCurrentDocTest = frmCalc
194		call MakeDocTest
195	end if
196	if bMakeImpressTest then
197    gCurrentDocTest = frmImpress
198		call MakeDocTest
199	end if
200	if bMakeDrawTest then
201    gCurrentDocTest = frmDraw
202		call MakeDocTest
203	end if
204	if bMakeHTMLTest then
205    gCurrentDocTest = frmHyperText
206		call MakeDocTest
207	end if
208	if bMakeChartTest then
209    gCurrentDocTest = frmChart
210		call MakeChartTest
211	end if
212	if bMakeMathTest then
213    gCurrentDocTest = frmMath
214		call MakeNewDoc
215	end if
216	if bMakeJavaTest then
217    gCurrentDocTest = frmJava
218		call TestJava
219	end if
220	if bMakeDBTest then
221    gCurrentDocTest = frmDataBase
222		call Test_DB.TestDB
223	end if
224	if bMakeExtensionTest then
225    gCurrentDocTest = frmExtension
226		call Test_Ext.TestExtensions
227	end if
228
229	Close #GlobalTestLog
230	GlobalTestLog = 0
231end Sub
232
233Sub WriteTestSequence
234	Print #GlobalTestLog, &quot;Sequence of testing&quot;
235
236	if bMakeWriterTest then
237		WriteTests (&quot;writer  : &quot;, true, GlobalTestLog)
238	end if
239	if bMakeCalcTest then
240		WriteTests (&quot;calc    : &quot;, true, GlobalTestLog)
241	end if
242	if bMakeImpressTest then
243		WriteTests (&quot;impress : &quot;, true, GlobalTestLog)
244	end if
245	if bMakeDrawTest then
246		WriteTests (&quot;draw    : &quot;, true, GlobalTestLog)
247	end if
248	if bMakeHTMLTest then
249		WriteTests (&quot;HTML    : &quot;, true, GlobalTestLog)
250	end if
251	if bMakeChartTest then
252		WriteTests (&quot;chart   : &quot;, false, GlobalTestLog)
253	end if
254	if bMakeMathTest then
255		WriteTests (&quot;math    : &quot;, false, GlobalTestLog)
256	end if
257	if bMakeJavaTest then
258		WriteTests (&quot;Java    : &quot;, false, GlobalTestLog)
259	end if
260	if bMakeDBTest then
261		WriteDBTests (&quot;Database    : &quot;, GlobalTestLog)
262	end if
263	if bMakeExtensionTest then
264		WriteExtensionTests (&quot;Extension   : &quot;, GlobalTestLog)
265  end if
266
267  Print #GlobalTestLog, &quot;testclosure : setup, write_status&quot;
268
269  Print #GlobalTestLog
270  end Sub
271
272  Sub WriteTests (sText as string, bTestAll as boolean)
273  Dim sWriteStr as string
274
275  sWriteStr = sText
276  sWriteStr = sWriteStr + &quot;new&quot;
277	if bTestAll then
278	if bMakeSaveOpen8Test then
279		sWriteStr = sWriteStr + &quot;, save 8.0&quot;
280	end if
281	if bMakeSaveOpenXMLTest then
282		sWriteStr = sWriteStr + &quot;, save XML&quot;
283	end if
284	if bMakeSaveOpen8Test then
285		sWriteStr = sWriteStr + &quot;, open 8.0&quot;
286	end if
287	if bMakeSaveOpenXMLTest then
288		sWriteStr = sWriteStr + &quot;, open XML&quot;
289	end if
290	end if
291
292	sWriteStr = sWriteStr + &quot;, close&quot;
293
294	Print #GlobalTestLog, sWriteStr
295end Sub
296
297Sub WriteDBTests (sText as string, nFileChannel as integer)
298	Dim sWriteStr as string
299
300	sWriteStr = sText
301	sWriteStr = sWriteStr + &quot;open / services&quot;
302	sWriteStr = sWriteStr + &quot;, insert&quot;
303	sWriteStr = sWriteStr + &quot;, delete&quot;
304	sWriteStr = sWriteStr + &quot;, seek&quot;
305	sWriteStr = sWriteStr + &quot;, close&quot;
306
307	Print #nFileChannel, sWriteStr
308end Sub
309
310Sub WriteExtensionTests (sText as string, nFileChannel as integer)
311	Dim sWriteStr as string
312
313	sWriteStr = sText
314	sWriteStr = sWriteStr + &quot;services&quot;
315	sWriteStr = sWriteStr + &quot;, install&quot;
316	sWriteStr = sWriteStr + &quot;, uninstall&quot;
317
318	Print #nFileChannel, sWriteStr
319end Sub
320
321Sub MakeDocTest
322	Dim oDoc as Object
323	Dim sFileNameXML$, sFileName8$
324	Dim bSuccess as Boolean
325
326	On Local Error GoTo DOCTESTERROR
327	gCurrentTestCase = cLogfileFailed
328	LocalTestLog% = OpenLogDat (GetLogFileName(gCurrentDocTest))
329	gCurrentTestCase = cDocNew
330	oDoc = LoadDoc (&quot;private:factory/&quot; + GetDocFilter(gCurrentDocTest or cFltNewDoc))
331	LogTestResult( GetDocFilter(gCurrentDocTest or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, not IsNull (oDoc) )
332	if not IsNull (oDoc) then
333    gCurrentTestCase = cDocSaveOpen8
334    if bMakeSaveOpen8Test and IsFilterAvailable (gCurrentDocTest or cFlt8) then
335      sFileName8 = sWorkPathURL+cTempFileName+&quot;.&quot;+GetDocEndings(gCurrentDocTest or cFlt8)
336			SaveDoc (sFileName8, oDoc, GetDocFilter(gCurrentDocTest or cFlt8))
337		end if
338		gCurrentTestCase = cDocSaveOpenXML
339		if bMakeSaveOpenXMLTest and IsFilterAvailable (gCurrentDocTest or cFltXML) then
340			sFileNameXML = sWorkPathURL+cTempFileName+&quot;.&quot;+GetDocEndings(gCurrentDocTest or cFltXML)
341			SaveDoc (sFileNameXML, oDoc, GetDocFilter(gCurrentDocTest or cFltXML))
342		end if
343		gCurrentTestCase = cDocClose
344		bSuccess = CloseDoc( oDoc )
345		LogTestResult( GetDocFilter(gCurrentDocTest)+&quot; &quot;+ cMessageCloseDoc, bSuccess )
346		gCurrentTestCase = cDocSaveOpen8
347		if bMakeSaveOpen8Test and IsFilterAvailable (gCurrentDocTest or cFlt8) then
348			oDoc = LoadDoc (sFileName8)
349
350&apos;			oDoc = Documents.open(sFileName)
351			LogTestResult( GetDocFilter(gCurrentDocTest or cFltNewDoc)+&quot; &quot;+ cMessageSaveOpen8Doc, not IsNull (oDoc) )
352
353			if not IsNull (oDoc) then
354				gCurrentTestCase = cDocClose
355				oDoc.close (true)
356			end If
357		end if
358
359		gCurrentTestCase = cDocSaveOpenXML
360		if bMakeSaveOpenXMLTest and IsFilterAvailable (gCurrentDocTest or cFltXML) then
361			oDoc = LoadDoc (sFileNameXML)
362
363&apos;			oDoc = Documents.open(sFileName)
364			LogTestResult( GetDocFilter(gCurrentDocTest or cFltNewDoc)+&quot; &quot;+ cMessageSaveOpenXMLDoc, not IsNull (oDoc) )
365
366			if not IsNull (oDoc) then
367				gCurrentTestCase = cDocClose
368				oDoc.close (true)
369			end If
370		end if
371
372	end If
373	Print #LocalTestLog, &quot;---&quot;
374	Close #LocalTestLog%
375	LocalTestLog = 0
376	Exit Sub &apos; Without error
377
378	DOCTESTERROR:
379	If ( gCurrentTestCase = cLogfileFailed ) then
380		LogTestResult( &quot; &quot;, False )
381		Exit Sub
382	else
383		LogTestResult( GetDocFilter(gCurrentDocTest or cFltNewDoc)+&quot; &quot;+ GetErrorMessage(gCurrentTestCase), False )
384		Close #LocalTestLog%
385		LocalTestLog = 0
386	End If
387	Exit Sub &apos; With error
388End Sub
389
390Sub MakeNewDoc
391	DIM oDoc as Object
392	Dim bSuccess as Boolean
393	On Local Error GoTo DOCTESTERROR2
394	gCurrentTestCase = cLogfileFailed
395	LocalTestLog% = OpenLogDat (GetLogFileName(gCurrentDocTest))
396	gCurrentTestCase = cDocNew
397&apos;	oDoc = Documents.Add(GetDocFilter(gCurrentDocTest))
398	oDoc = LoadDoc (&quot;private:factory/&quot; + GetDocFilter(gCurrentDocTest or cFltNewDoc))
399	LogTestResult( GetDocFilter(gCurrentDocTest or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, not IsNull (oDoc) )
400	if not IsNull (oDoc) then
401		gCurrentTestCase = cDocClose
402		bSuccess = CloseDoc( oDoc )
403		LogTestResult( GetDocFilter(gCurrentDocTest)+&quot; &quot;+ cMessageCloseDoc, bSuccess )
404	end	If
405	Print #LocalTestLog, &quot;---&quot;
406	Close #LocalTestLog%
407	LocalTestLog = 0
408	Exit Sub &apos; Without error
409
410	DOCTESTERROR2:
411	If ( gCurrentTestCase = cLogfileFailed ) then
412		LogTestResult( &quot; &quot;, False )
413		Exit Sub
414	else
415		LogTestResult( GetDocFilter(gCurrentDocTest or cFltNewDoc)+&quot; &quot;+ GetErrorMessage(gCurrentTestCase), False )
416		Close #LocalTestLog%
417		LocalTestLog = 0
418	End If
419	Exit Sub &apos; With error
420End Sub
421
422Sub MakeChartTest
423	Dim oCharts as Object
424	Dim oDoc as Object
425	Dim oRange(0) as New com.sun.star.table.CellRangeAddress
426	Dim oRect as New com.sun.star.awt.Rectangle
427	const cChartName=&quot;TestChart&quot;
428  Dim bSuccess as Boolean
429  On Local Error GoTo CHARTTESTERROR
430  gCurrentTestCase = cLogfileFailed
431  LocalTestLog% = OpenLogDat (GetLogFileName(gCurrentDocTest))
432  gCurrentTestCase = cDocNew
433  oDoc = LoadDoc (&quot;private:factory/&quot; + GetDocFilter(frmCalc or cFltNewDoc))
434	if not IsNull (oDoc) then
435		oCharts = oDoc.sheets(0).Charts
436		oCharts.AddNewByName (cChartName, oRect, oRange(), true, true)
437		bSuccess=oCharts.HasByName(cChartName)
438		LogTestResult( GetDocFilter(gCurrentDocTest or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, bSuccess )
439		gCurrentTestCase = cDocClose
440		oDoc.close (true)
441	else
442		LogTestResult( GetDocFilter(frmCalc or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, FALSE )
443	End if
444	Print #LocalTestLog, &quot;---&quot;
445	Close #LocalTestLog%
446	LocalTestLog = 0
447	Exit Sub &apos; Without error
448
449	CHARTTESTERROR:
450	If ( gCurrentTestCase = cLogfileFailed ) then
451		LogTestResult( &quot; &quot;, False )
452		Exit Sub
453	else
454		LogTestResult( GetDocFilter(gCurrentDocTest or cFltNewDoc)+&quot; &quot;+ GetErrorMessage(gCurrentTestCase), FALSE )
455		Close #LocalTestLog%
456		LocalTestLog = 0
457	End If
458	Exit Sub &apos; With error
459End Sub
460
461Sub LogState (bState as Boolean, sText as String, nLocaleFileChannel as integer)
462	if bState then
463		Print #nLocaleFileChannel, sText+&quot; -&gt; ok&quot;
464	else
465		Print #nLocaleFileChannel, sText+&quot; -&gt; error&quot;
466	end If
467end Sub
468
469Function GetDocEndings (DocType as Integer) as String
470	Select Case ( DocType )
471		case frmWriter or cFlt8
472			GetDocEndings = &quot;odt&quot; &apos; Textdokument
473		case frmCalc or cFlt8
474			GetDocEndings = &quot;ods&quot; &apos;Tabellendokument
475		case frmImpress or cFlt8
476			GetDocEndings = &quot;odp&quot; &apos;PrÕsentation
477		case frmDraw or cFlt8
478			GetDocEndings = &quot;odg&quot; &apos;Zeichen
479		case frmHyperText, frmHyperText or cFltXML
480			GetDocEndings = &quot;html&quot; &apos;Hypertext-Dokument
481		case frmWriter or cFltXML
482			GetDocEndings = &quot;sxw&quot; &apos; Textdokument
483		case frmCalc or cFltXML
484			GetDocEndings = &quot;sxc&quot; &apos;Tabellendokument
485		case frmImpress or cFltXML
486			GetDocEndings = &quot;sxi&quot; &apos;PrÕsentation
487		case frmDraw or cFltXML
488			GetDocEndings = &quot;sxd&quot; &apos;Zeichen
489		case else
490			GetDocEndings = &quot;&quot;
491	end Select
492end Function
493
494Function GetDocFilter (DocType as Integer) as String
495	Select Case ( DocType )
496		case frmWriter or cFlt8
497			GetDocFilter = &quot;writer8&quot; &apos; text document
498		case frmCalc or cFlt8
499			GetDocFilter = &quot;calc8&quot; &apos; spreadsheet document
500		case frmImpress or cFlt8
501			GetDocFilter = &quot;impress8&quot; &apos; presentation
502		case frmDraw or cFlt8
503			GetDocFilter = &quot;draw8&quot; &apos; drawing
504		case frmMath or cFlt8
505			GetDocFilter = &quot;math8&quot; &apos; formula
506
507		case frmWriter or cFltXML
508			GetDocFilter = &quot;StarOffice XML (Writer)&quot; &apos; text document
509		case frmCalc or cFltXML
510			GetDocFilter = &quot;StarOffice XML (Calc)&quot; &apos; spreadsheet document
511		case frmImpress or cFltXML
512			GetDocFilter = &quot;StarOffice XML (Impress)&quot; &apos; presentation
513		case frmDraw or cFltXML
514			GetDocFilter = &quot;StarOffice XML (Draw)&quot; &apos; drawing
515		case frmMath or cFltXML
516			GetDocFilter = &quot;StarOffice XML (Math)&quot; &apos; formula
517
518		case frmHyperText, frmHyperText or cFltXML
519			GetDocFilter = &quot;HTML&quot; &apos; HTML document
520
521		case frmWriter or cFltNewDoc
522			GetDocFilter = &quot;swriter&quot; &apos; text document
523		case frmCalc or cFltNewDoc
524			GetDocFilter = &quot;scalc&quot; &apos; spreadsheet document
525		case frmImpress or cFltNewDoc
526			GetDocFilter = &quot;simpress&quot; &apos; presentation
527		case frmDraw or cFltNewDoc
528			GetDocFilter = &quot;sdraw&quot; &apos; drawing
529		case frmMath or cFltNewDoc
530			GetDocFilter = &quot;smath&quot; &apos; formula
531		case frmHyperText or cFltNewDoc
532			GetDocFilter = &quot;swriter/web&quot; &apos; HTML document
533		case frmChart or cFltNewDoc
534			GetDocFilter = &quot;schart&quot; &apos; chart
535		case else
536			GetDocFilter = &quot;&quot;
537	end Select
538end Function
539
540Function GetLogFileName (DocType as Integer) as String
541	Select Case ( DocType )
542		case frmWriter
543			GetLogFileName = sSWLogFileName &apos; text document
544		case frmCalc
545			GetLogFileName = sSCLogFileName &apos; spreadsheet document
546		case frmImpress
547			GetLogFileName = sSDLogFileName &apos; presentation
548		case frmDraw
549			GetLogFileName = sSDrawLogFileName &apos; drawing
550		case frmMath
551			GetLogFileName = sSMathLogFileName &apos; formula
552		case frmHyperText
553			GetLogFileName = sSHptLogFileName &apos; HTML document
554		case frmChart
555			GetLogFileName = sSChartLogFileName &apos; chart
556		case frmJava
557			GetLogFileName = sJavaLogFileName &apos;Java
558		case frmTestClosure
559			GetLogFileName = sTestGlueLogFileName &apos; test framework
560		case frmDataBase
561			GetLogFileName = sSDBLogFileName &apos;Database
562		case frmExtension
563			GetLogFileName = sExtLogFileName &apos;Extension
564		case else
565			GetLogFileName = &quot;&quot;
566	end Select
567end Function
568
569Function GetErrorMessageOnAction (nAction as Integer) as String
570	Select Case ( nAction )
571		case cDocNew
572			GetErrorMessageOnAction = cMessageNewDoc
573		case cDocSaveOpen8
574			GetErrorMessageOnAction = cMessageSaveOpen8Doc
575		case cDocSaveOpenXML
576			GetErrorMessageOnAction = cMessageSaveOpenXMLDoc
577		case cDocClose
578			GetErrorMessageOnAction = cMessageCloseDoc
579		case else
580			GetErrorMessageOnAction = &quot;&quot;
581	end Select
582end Function
583
584Function IsFilterAvailable (FilterType as Integer) as boolean
585	IsFilterAvailable = true
586	if ((FilterType = (frmHyperText or cFltXML))) then
587		IsFilterAvailable = false
588	end if
589End Function
590
591Function TestJava
592	Dim oObj as Object
593	gCurrentTestCase = cLogfileFailed
594	LocalTestLog% = OpenLogDat (GetLogFileName(gCurrentDocTest))
595	gCurrentTestCase = cDocNew
596	oObj = createUnoService( cUnoJavaLoader )
597	LogTestResult( &quot;Java &quot;+ cMessageNewDoc, not IsNull (oObj) )
598
599	Print #LocalTestLog, &quot;---&quot;
600	Close #LocalTestLog%
601	LocalTestLog = 0
602
603	TestJava = not IsNull (oObj)
604End Function
605
606Sub LoadLibrary( LibName as String )
607
608	dim args(1)
609	dim arg as new com.sun.star.beans.PropertyValue
610	arg.Name = &quot;LibraryName&quot;
611	arg.Value = LibName
612	args(0) = arg
613
614	dim url as new com.sun.star.util.URL
615	dim trans as object
616	trans = createUnoService(&quot;com.sun.star.util.URLTransformer&quot; )
617	url.Complete = &quot;slot:6517&quot;
618	trans.parsestrict( url )
619
620	dim disp as object
621	disp = StarDesktop.currentFrame.queryDispatch( url, &quot;&quot;, 0 )
622	disp.dispatch( url, args() )
623
624End Sub
625
626Sub LoadDoc (DocName as String) as Object
627	dim trans as object
628	trans = createUnoService(&quot;com.sun.star.util.URLTransformer&quot; )
629	url = createUnoStruct(&quot;com.sun.star.util.URL&quot; )
630	url.Complete = DocName
631	if Left(DocName, 5 ) &lt;&gt; &quot;file:&quot; then
632	trans.parsestrict( url )
633	endif
634
635	Dim aPropArray(0) as Object
636	aPropArray(0) = CreateUnoStruct(&quot;com.sun.star.beans.PropertyValue&quot;)
637	aPropArray(0).Name = &quot;OpenFlags&quot;
638	aPropArray(0).Value = &quot;S&quot;
639
640	dim doc as object
641	dim noargs()
642	doc = StarDesktop.loadComponentFromURL( url.Complete, &quot;_blank&quot;, 0, aPropArray() )	&apos; XModel
643	LoadDoc = doc
644End Sub
645
646Sub SaveDoc (DocName as String, oDoc as Object, sFilterName as string )
647	dim trans as object
648	trans = createUnoService(&quot;com.sun.star.util.URLTransformer&quot; )
649	url = createUnoStruct(&quot;com.sun.star.util.URL&quot; )
650	url.Complete = DocName
651	if Left(DocName, 5 ) &lt;&gt; &quot;file:&quot; then
652	trans.parsestrict( url )
653	endif
654
655	if not (sFilterName = &quot;&quot;) then
656		Dim aPropArray(0) as Object
657		aPropArray(0) = CreateUnoStruct(&quot;com.sun.star.beans.PropertyValue&quot;)
658		aPropArray(0).Name = &quot;FilterName&quot;
659		aPropArray(0).Value = sFilterName
660
661		oDoc.storeAsURL( url.Complete, aPropArray() )
662	else
663		MessageBox &quot;Filtername is unknown!&quot;
664	end if
665end Sub
666
667Function CloseDoc( oDoc as Object )
668  Dim oListener as Object
669  oListener = CreateUnoListener( "Events.closeListener_", "com.sun.star.util.XCloseListener" )
670  oDoc.addCloseListener( oListener )
671
672  Events.ResetCloseListenerFlag()
673  oDoc.close( true )
674  closeDoc = Events.HasCloseListenerBeenCalled()
675
676  if ( Not Events.HasCloseListenerBeenCalled() ) Then
677    &apos; do this only if closing was not successful - otherwise, we'd get a DisposedException
678    oDoc.removeCloseListener( oListener )
679  End If
680End Function
681</script:module>
682