xref: /trunk/test/smoketestdoc/data/Global.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="Global" script:language="StarBasic">REM  *****  BASIC  *****
30
31const cMaxErrorStates = 14
32
33const cCoGreen = 4057917, cCoRed = 16711680, cCoGrey = 12632256
34const cParagraphBreak = 0
35
36global const cExtensionFileName = &quot;TestExtension.oxt&quot;
37
38global const cDocNew = 0, cDocSaveOpen8 = 1, cDocSaveOpenXML = 2, cDocClose = 3
39global const cDBService = 0, cDBOpen = 1, cDBInsert = 2, cDBDelete = 3, cDBSeek = 4, cDBClose = 5
40global const cEXTService = 0, cEXTInstall = 1, cEXTUninstall = 2
41global const cTestClosureSetupDoc = 0, cTestClosureWriteStatus = 1
42global const cLogfileFailed = 255
43
44global const cStWriter = 0, cStCalc = 1, cStPraesentation = 2, cStZeichnen = 3
45global const cStHTML = 6, cStChart = 4, cStJava = 7
46global const cStMath = 5, cStDataBase = 9
47global const cStExtension = 11
48global const cStTestGlue = 12
49global const cStNone = -1
50
51global const cFlt8 = 0, cFlt50 = 32, cFltNewDoc = 64, cFltXML = 128
52
53global const frmWriter = 1, frmCalc = 2, frmImpress = 4
54global const frmMath = 5, frmChart = 7, frmHyperText = 8, frmDraw = 9
55global const frmDataBase = 10, frmJava = 13
56global const frmExtension = 14
57global const frmTestClosure = 15
58
59Global gCurrentDocTest As Integer
60Global gCurrentTestCase As Integer
61
62global const cLogUnknown = 0, cLogFalse = 1, cLogTrue = 2
63
64&apos;UserFieldKennungen
65Global const cYes = &quot;y&quot;, cNo = &quot;n&quot;
66Global const cStateNo = 0, cStateYes = 1
67
68&apos;Feldtypen
69Global const cFtExtUser = 21, cFtPageNum = 5, cFtStatistic = 8, cFtDateTime = 27, cFtDatabase = 31
70
71&apos;UnoStrings
72Global const cUnoSeparator = &quot;.&quot;
73Global const cUnoPrefix = &quot;com.sun.star.&quot;
74Global const cUnoUserField = cUnoPrefix + &quot;text.FieldMaster.User&quot;
75Global const cUnoExtUserField = cUnoPrefix + &quot;text.TextField.ExtendedUser&quot;
76Global const cUnoMasterDataBase = cUnoPrefix + &quot;text.FieldMaster.Database&quot;
77Global const cUnoDataBase = cUnoPrefix + &quot;text.TextField.Database&quot;
78Global const cUnoDateTime = cUnoPrefix + &quot;text.TextField.DateTime&quot;
79Global const cUnoTextGraphi2 = cUnoPrefix + &quot;text.Graphic&quot;
80Global const cUnoJavaLoader = cUnoPrefix + &quot;loader.Java&quot;
81Global const cUnoDatabaseContext = cUnoPrefix + &quot;sdb.DatabaseContext&quot;
82Global const cUnoRowSet = cUnoPrefix + &quot;sdb.RowSet&quot;
83Global const cUnoSmoketestTestExtension = cUnoPrefix + &quot;comp.smoketest.TestExtension&quot;
84Global const cUnoSmoketestCommandEnvironment = cUnoPrefix + &quot;deployment.test.SmoketestCommandEnvironment&quot;
85Global const cExtensionManager = cUnoPrefix + &quot;deployment.ExtensionManager&quot;
86
87&apos;UserFieldNames
88Global const cUserFieldTestWriter = &quot;Writer&quot;, cUserFieldTestCalc = &quot;Calc&quot;, cUserFieldTestImpress = &quot;Impress&quot;
89Global const cUserFieldTestDraw = &quot;Draw&quot;, cUserFieldTestMath = &quot;Math&quot;, cUserFieldTestChart = &quot;Chart&quot;
90Global const cUserFieldTestHTML = &quot;HTML&quot;, cUserFieldTestJava = &quot;Java&quot;, cUserFieldTestDatabase = &quot;Database&quot;
91Global const cUserFieldTestExtension = &quot;Extension&quot;
92Global const cUserFieldTestOpenSaveXML = &quot;SaveOpenXML&quot;
93Global const cUserFieldTestTerminateAfterTest = &quot;Terminate&quot;, cUserFieldTestOpenSave8 = &quot;SaveOpen8&quot;
94
95Global const cOptionsDialogName = &quot;OptionsDlg&quot;, cTest10Modul = &quot;Standard&quot;
96
97Global const cDlgCancel = 1, cDlgOk = 0, cDlgStartTest = 2
98
99global gErrorState (cMaxErrorStates, 5) as integer
100Global gTestCaseAnnotations( cMaxErrorStates, 5 ) As String
101
102global gOutputDoc as Object
103global gOutputDocNotUno as Object
104global gOptionsDialog as Object
105
106Global bMakeWriterTest as boolean, bMakeCalcTest as  boolean, bMakeImpressTest as boolean
107Global bMakeDrawTest as Boolean, bMakeMathTest as boolean, bMakeChartTest as boolean
108Global bMakeHTMLTest as boolean, bMakeJavaTest as boolean, bMakeDBTest as boolean
109Global bMakeExtensionTest as boolean
110Global bMakeSaveOpenXMLTest as boolean
111Global bMakeTerminateAfterTest as boolean, bShowTable as boolean
112Global bMakeSaveOpen8Test as boolean
113
114global sExtensionURL as string
115
116Dim gDlgState as Integer
117
118Sub SetGlobalDoc
119	gOutputDoc = ThisComponent
120end Sub
121
122Sub ClearStatus
123	for j% = 0 to cMaxErrorStates
124		for i% = 0 to 5
125			gErrorState (j%, i%) = cLogUnknown
126			gTestCaseAnnotations( J%, i% ) = ""
127		next i%
128	next j%
129end Sub
130
131Sub ClearAllText
132	call SetGlobalDoc
133	call ClearDoc (gOutputDoc)
134	call ClearStatus
135end Sub
136
137Sub AssertionHandler( sMessage as String )
138	LogTestResult( &quot;assertion caught: &quot; + sMessage, FALSE )
139End Sub
140
141Sub Main
142	On Local Error Goto MainError
143
144	gCurrentDocTest = frmTestClosure
145	gCurrentTestCase = cLogfileFailed
146
147	DeleteAllSavedFiles()
148	DeleteAllLogFiles()
149	SetupWorkPath()
150
151	if GetSystem (sWorkPath) = &quot;windows&quot; then
152		sWorkPath = ConvertPathToWin (sWorkPath)
153	end if
154
155	LocalTestLog% = OpenLogDat( GetLogFileName( gCurrentDocTest ) )
156
157	gCurrentTestCase = cTestClosureSetupDoc
158	CaptureAssertions( "AssertionHandler" )
159
160	call SetGlobalDoc
161
162	Dim bWasModified as Boolean
163	bWasModified = gOutputDoc.isModified()
164
165	if bShowTable then
166		call ClearDoc (gOutputDoc)
167	end If
168
169	call ClearStatus
170
171	LogTestResult( GetTestGlueDescription( gCurrentTestCase ), TRUE )
172
173	Dim nPreserveFileHandle%
174	nPreserveFileHandle% = LocalTestLog%
175	Call Test_10er.Main
176	LocalTestLog% = nPreserveFileHandle%
177
178	gCurrentDocTest = frmTestClosure
179	gCurrentTestCase = cTestClosureWriteStatus
180	if bShowTable then
181		call CreateStatusTable2
182		call CreateStatusTable
183		call CreateDocState
184		LogTestResult( GetTestGlueDescription( gCurrentTestCase ), TRUE )
185			&apos; do this LogTestResult call before CreateSecondState, since the latter accesses (and displays) the result
186		call CreateSecondState
187		gOutputDoc.CurrentController.ViewCursor.JumpToFirstPage
188	Else
189		LogTestResult( GetTestGlueDescription( gCurrentTestCase ), TRUE )
190	End If
191
192	&apos; print the &apos;test complete&apos; marker
193	Print #LocalTestLog%, &quot;---&quot;
194	LocalTestLog% = 0
195
196	gOutputDoc.setModified( bWasModified )
197
198	CaptureAssertions( &quot;&quot; )
199	Exit Sub
200
201MainError:
202	If ( gCurrentTestCase = cLogfileFailed ) then
203		LogTestResult( &quot;&quot;, False )
204		Exit Sub
205	else
206		LogTestResult( &quot;testclosure &quot; + GetTestGlueDescription( gCurrentTestCase ), FALSE )
207		Close #LocalTestLog%
208		LocalTestLog = 0
209	End If
210End Sub
211
212Function GetTestGlueDescription( nTestCase as Integer )
213	Select Case ( nTestCase )
214		case cTestClosureSetupDoc
215			GetTestGlueDescription = &quot;setup&quot;
216		case cTestClosureWriteStatus
217			GetTestGlueDescription = &quot;write_status&quot;
218		case Else
219			GetTestGlueDescription = &quot;&quot;
220	End Select
221End Function
222
223Sub CreateStatusTable
224	dim tableHeaders(7) as string
225	tableHeaders(cStWriter) = &quot;Writer&quot;
226	tableHeaders(cStCalc) = &quot;Calc&quot;
227	tableHeaders(cStPraesentation) = &quot;Präsen- tation&quot;
228	tableHeaders(cStZeichnen) = &quot;Zeichn.&quot;
229	tableHeaders(cStChart) = &quot;Diagr.&quot;
230	tableHeaders(cStMath) = &quot;Math&quot;
231	tableHeaders(cStHTML) = &quot;HTML&quot;
232	tableHeaders(cStJava) = &quot;Java&quot;
233
234	dim tableRows(3) as string
235	tableRows(cDocNew) = &quot;new&quot;
236	tableRows(cDocSaveOpen8) = &quot;V8.0&quot;
237	tableRows(cDocSaveOpenXML) = &quot;XML&quot;
238	tableRows(cDocClose) = &quot;close&quot;
239
240	aDoc = gOutputDoc
241
242	xText = aDoc.Text
243	xCursor = xText.createTextCursor()
244
245	xCursor.gotoStart(FALSE)
246	xCursor.GoRight (4, False)
247	SetParagraphBreak (xCursor)
248	xCursor.GoRight (1, False)
249	SetParagraphBreak (xCursor)
250	xCursor.GoRight (1, False)
251
252	table = aDoc.createInstance(&quot;com.sun.star.text.TextTable&quot;)
253	table.initialize(5,9)
254	table.Name = &quot;StTab1&quot;
255  table.BackColor = cCoGrey
256	xText.insertTextContent(xCursor, table, FALSE)
257
258	for i% = 0 to 7
259		tableCell = table.getCellByPosition( i% + 1, 0 )
260		tableCell.String = tableHeaders( i% )
261	next i%
262
263	for i% = LBound( tableRows ) to UBound( tableRows )
264		tableCell = table.getCellByPosition( 0, i% + 1 )
265	  tableCell.String=tableRows(i%)
266	next i%
267end Sub
268
269Sub CreateStatusTable2
270	dim tableHeaders(4) as string
271	tableHeaders(0) = &quot;Database&quot;
272	tableHeaders(1) = &quot;&quot;
273	tableHeaders(2) = &quot;Extension&quot;
274	tableHeaders(3) = &quot;&quot;
275	tableHeaders(4) = &quot;Other&quot;
276
277	dim tableRows(5) as string
278	tableRows(cDBService ) = &quot;services&quot;
279	tableRows(cDBOpen ) = &quot;open&quot;
280	tableRows(cDBInsert ) = &quot;insert&quot;
281	tableRows(cDBDelete  ) = &quot;delete&quot;
282	tableRows(cDBSeek ) = &quot;seek&quot;
283	tableRows(cDBClose ) = &quot;close&quot;
284
285	dim tableRows2(2) as string
286	tableRows2(cEXTService ) = &quot;services&quot;
287	tableRows2(cEXTInstall ) = &quot;install&quot;
288	tableRows2(cEXTUninstall ) = &quot;uninstall&quot;
289
290	dim tableRows3(1) as string
291	tableRows3(cTestClosureSetupDoc ) = &quot;setup test&quot;
292	tableRows3(cTestClosureWriteStatus ) = &quot;write test result&quot;
293
294	aDoc = gOutputDoc
295
296	xText = aDoc.Text
297	xCursor = xText.createTextCursor()
298
299	xCursor.gotoStart(FALSE)
300	xCursor.GoRight (4, False)
301	SetParagraphBreak (xCursor)
302	SetParagraphBreak (xCursor)
303	xCursor.gotoEnd(FALSE)
304
305	table = aDoc.createInstance(&quot;com.sun.star.text.TextTable&quot;)
306	table.initialize(7,6)
307	table.Name = &quot;StTab2&quot;
308	table.BackColor = cCoGrey
309
310	xText.insertTextContent(xCursor, table, FALSE)
311
312	for i% = LBound( tableHeaders ) to UBound( tableHeaders )
313		tableCell = table.getCellByPosition( i% + 1, 0 )
314		tableCell.String = tableHeaders(i%)
315	next i%
316
317	for i% = LBound( tableRows ) to UBound( tableRows )
318		tableCell = table.getCellByPosition( 0, i% + 1 )
319	  tableCell.String=tableRows(i%)
320	next i%
321
322	for i% = LBound( tableRows2 ) to UBound( tableRows2 )
323		tableCell = table.getCellByPosition( 2, i% + 1 )
324	  tableCell.String=tableRows2(i%)
325	next i%
326
327	for i% = LBound( tableRows3 ) to UBound( tableRows3 )
328		tableCell = table.getCellByPosition( 4, i% + 1 )
329	  tableCell.String=tableRows3(i%)
330	next i%
331end Sub
332
333
334Sub CreateDocState
335	aDoc = gOutputDoc
336	table = aDoc.TextTables.GetByIndex (1)
337
338	for j% = 0 to 7
339		for i% = 0 to 3
340			sRangeName = GetRangeName(j%, i%+1)
341
342			tableCursor = table.createCursorByCellName(sRangeName)
343
344			cName = tableCursor.getRangeName()
345			xCell = table.getCellByName(cName)
346
347			xCell.BackTransparent = False
348
349			If gErrorState (j%, i%) = cLogTrue Then
350				xCell.BackColor = cCoGreen
351			else
352				If gErrorState (j%, i%) = cLogFalse Then
353					xCell.BackColor = cCoRed
354					If ( gTestCaseAnnotations( j%, i% ) &lt;&gt; "" ) Then
355						Dim annotation as Object
356						annotation = aDoc.createInstance( &quot;com.sun.star.text.TextField.Annotation&quot; )
357						annotation.Author = &quot;smoketest&quot;
358						annotation.Content = gTestCaseAnnotations( j%, i% )
359						xCell.insertTextContent( xCell, annotation, false )
360					End If
361				else
362					xCell.BackColor = cCoGrey
363				end If
364			end If
365		next i%
366	next j%
367end Sub
368
369Sub CreateSecondState
370	aDoc = gOutputDoc
371	table = aDoc.TextTables.GetByIndex (0)
372
373	Dim stateIndex(2) as Integer
374	stateIndex(0) = cStDataBase
375	stateIndex(1) = cStExtension
376	stateIndex(2) = cStTestGlue
377
378	Dim j as Integer
379	For j = LBound( stateIndex ) To UBound( stateIndex )
380		for i% = 1 to 6
381			tableCell = table.getCellByPosition( 2 * j + 1, i% )
382			tableCell.BackTransparent = False
383
384			if gErrorState( stateIndex(j), i% - 1 ) = cLogTrue then
385				tableCell.BackColor = cCoGreen
386			else
387				if gErrorState ( stateIndex(j), i% - 1 ) = cLogFalse then
388					tableCell.BackColor = cCoRed
389					If ( gTestCaseAnnotations( stateIndex(j), i% - 1 ) &lt;&gt; &quot;&quot; ) Then
390						Dim annotation as Object
391						annotation = aDoc.createInstance( &quot;com.sun.star.text.TextField.Annotation&quot; )
392						annotation.Author = &quot;smoketest&quot;
393						annotation.Content = gTestCaseAnnotations( stateIndex(j), i% - 1 )
394						tableCell.insertTextContent( tableCell, annotation, false )
395					End If
396				else
397					tableCell.BackColor = cCoGrey
398				end If
399  			end If
400		next i%
401	next j%
402end Sub
403
404Function GetRangeName (nColumn as integer, nRow as integer) as string
405	GetRangeName = chr (nColumn+66) + Trim(Str(nRow+1))
406end Function
407
408Sub LogTestResult( sTestCaseDescription as String, bSuccess as Boolean )
409	If ( gCurrentTestCase = cLogfileFailed ) Then
410		Dim sAnnotation as String
411		sAnnotation = &quot;creating logfile &apos;&quot; + GetLogFileName( gCurrentDocTest ) + &quot;&apos; failed&quot;
412		LogState( FALSE, sAnnotation, GlobalTestLog )
413		RecordTestCaseStatus( 0, FALSE, sAnnotation )
414	Else
415		bSuccess = RecordTestCaseStatus( gCurrentTestCase, bSuccess, sTestCaseDescription )
416		If ( LocalTestLog &lt;&gt; 0 ) Then
417			LogState( bSuccess, sTestCaseDescription, LocalTestLog )
418		EndIf
419		if ( GlobalTestLog &lt;&gt; 0 ) Then
420			LogState( bSuccess, sTestCaseDescription, GlobalTestLog )
421		EndIf
422	End If
423End Sub
424
425Function RecordTestCaseStatus( nAction as Integer, bState as Boolean, sFailureAnnotation as String ) as Boolean
426	Dim nStatusType as Integer
427	Dim nState as integer
428	nStatusType = GetStatusType( gCurrentDocTest )
429	If nStatusType = cStNone then Exit Function
430
431  If ( gErrorState( nStatusType, nAction ) = cLogFalse ) Then
432    &apos; don't overwrite a previous &quot;failed&quot; state for this test
433    bState = FALSE
434  End If
435
436	if bState then
437		nState = cLogTrue
438	else
439		nState = cLogFalse
440	end If
441
442	gErrorState (nStatusType, nAction) = nState
443
444	If ( nState = cLogFalse ) And ( sFailureAnnotation &lt;&gt; &quot;&quot; ) Then
445		gTestCaseAnnotations( nStatusType, nAction ) = gTestCaseAnnotations( nStatusType, nAction ) + sFailureAnnotation + chr(13)
446	End If
447
448	RecordTestCaseStatus = bState
449End Function
450
451Function GetStatusType (nDocType as Integer) as Integer
452	Select Case ( nDocType )
453		case frmWriter
454			GetStatusType = cStWriter &apos; text document
455		case frmCalc
456			GetStatusType = cStCalc &apos; spreadsheet document
457		case frmImpress
458			GetStatusType = cStPraesentation &apos; presentation
459		case frmDraw
460			GetStatusType = cStZeichnen &apos; drawing
461		case frmMath
462			GetStatusType = cStMath &apos; formula
463		case frmHyperText
464			GetStatusType = cStHTML &apos; HTML document
465		case frmChart
466			GetStatusType = cStChart &apos; chart
467		case frmJava
468			GetStatusType = cStJava &apos;Java
469		case frmTestClosure
470			GetStatusType = cStTestGlue &apos; test framework
471		case frmDataBase
472			GetStatusType = cStDataBase	&apos;DataBase
473		case frmExtension
474			GetStatusType = cStExtension &apos;Extension
475		case else
476			GetStatusType = cStNone
477	end Select
478end Function
479
480Sub SetParagraphBreak (aCursor as Object)
481	aCursor.Text.InsertControlCharacter (aCursor, cParagraphBreak, True)
482end Sub
483
484Sub ClearDoc (aDoc as Object)
485	Dim aText as Object
486	Dim i%
487	for i%=1 to aDoc.TextTables.count
488		aDoc.TextTables.GetByIndex(0).dispose
489	next
490
491	aText = aDoc.Text.CreateTextCursor
492	aText.GotoStart (False)
493	aText.GoRight (3, False)
494	SetParagraphBreak (aText)
495	aText.GotoEnd (True)
496	aText.String=&quot;&quot;
497end Sub
498
499Sub ClearDocFull (aDoc as Object)
500	Dim aText as Object
501	Dim i%
502	for i%=1 to aDoc.TextTables.count
503		aDoc.TextTables.GetByIndex(0).dispose
504	next
505
506	aText = aDoc.Text.CreateTextCursor
507	aText.GotoStart (False)
508	aText.GotoEnd (True)
509	aText.String=&quot;&quot;
510end Sub
511
512Sub SetGlobalOptionsDialog ()
513
514    Dim oLibContainer As Object, oLib As Object
515    Dim oInputStreamProvider As Object
516    Dim oDialog As Object
517
518    Const sLibName = cTest10Modul
519    Const sDialogName = cOptionsDialogName
520
521    REM get library and input stream provider
522    oLibContainer = DialogLibraries
523
524    REM load the library
525    oLibContainer.loadLibrary( sLibName )
526
527    oLib = oLibContainer.getByName( sLibName )
528    oInputStreamProvider = oLib.getByName( sDialogName )
529
530    REM create dialog control
531    gOptionsDialog = CreateUnoDialog( oInputStreamProvider )
532
533end Sub
534
535Sub ShowOptionsDlg
536
537    call SetGlobalDoc
538    call SetGlobalOptionsDialog
539    call GetOptions
540
541    REM show the dialog
542    gOptionsDialog.execute()
543
544   	&apos; jetzt läuft der Dialog, bis ein Button gedrückt wird
545
546   	Select Case (gDlgState)
547   		case cDlgOk
548   			call SetOptions ()
549   		case cDlgStartTest
550   			call SetOptions ()
551   			call StartTestByOptions ()
552	end Select
553
554    gOptionsDialog.dispose()
555
556end Sub
557
558Sub SetOptions
559	call SetGlobalDoc
560	SetUserFieldState (cUserFieldTestWriter, -(gOptionsDialog.getControl(&quot;cbWriterTest&quot;).getState), gOutputDoc)
561	SetUserFieldState (cUserFieldTestCalc, -(gOptionsDialog.getControl(&quot;cbCalcTest&quot;).getState), gOutputDoc)
562	SetUserFieldState (cUserFieldTestImpress, -(gOptionsDialog.getControl(&quot;cbImpressTest&quot;).getState), gOutputDoc)
563	SetUserFieldState (cUserFieldTestDraw, -(gOptionsDialog.getControl(&quot;cbDrawTest&quot;).getState), gOutputDoc)
564	SetUserFieldState (cUserFieldTestHTML, -(gOptionsDialog.getControl(&quot;cbHTMLTest&quot;).getState), gOutputDoc)
565	SetUserFieldState (cUserFieldTestMath, -(gOptionsDialog.getControl(&quot;cbMathTest&quot;).getState), gOutputDoc)
566	SetUserFieldState (cUserFieldTestChart, -(gOptionsDialog.getControl(&quot;cbChartTest&quot;).getState), gOutputDoc)
567	SetUserFieldState (cUserFieldTestJava, -(gOptionsDialog.getControl(&quot;cbJavaTest&quot;).getState), gOutputDoc)
568	SetUserFieldState (cUserFieldTestDatabase, -(gOptionsDialog.getControl(&quot;cbDatabaseTest&quot;).getState), gOutputDoc)
569	SetUserFieldState (cUserFieldTestExtension, -(gOptionsDialog.getControl(&quot;cbExtensionTest&quot;).getState), gOutputDoc)
570	SetUserFieldState (cUserFieldTestOpenSaveXML, -(gOptionsDialog.getControl(&quot;cbSaveOpenXMLTest&quot;).getState), gOutputDoc)
571	SetUserFieldState (cUserFieldTestOpenSave8, -(gOptionsDialog.getControl(&quot;cbSaveOpen8Test&quot;).getState), gOutputDoc)
572	SetUserFieldState (cUserFieldTestTerminateAfterTest, -(gOptionsDialog.getControl(&quot;cbTerminateAfterTest&quot;).getState), gOutputDoc)
573end Sub
574
575Sub GetOptions
576	call SetGlobalDoc
577	gOptionsDialog.getControl(&quot;cbWriterTest&quot;).setState( -( GetUserFieldState (cUserFieldTestWriter, gOutputDoc)))
578	gOptionsDialog.getControl(&quot;cbCalcTest&quot;).setState ( -( GetUserFieldState (cUserFieldTestCalc, gOutputDoc)))
579	gOptionsDialog.getControl(&quot;cbImpressTest&quot;).setState( -( GetUserFieldState (cUserFieldTestImpress, gOutputDoc)))
580	gOptionsDialog.getControl(&quot;cbDrawTest&quot;).setState( -( GetUserFieldState (cUserFieldTestDraw, gOutputDoc)))
581	gOptionsDialog.getControl(&quot;cbHTMLTest&quot;).setState( -( GetUserFieldState (cUserFieldTestHTML, gOutputDoc)))
582	gOptionsDialog.getControl(&quot;cbMathTest&quot;).setState( -( GetUserFieldState (cUserFieldTestMath, gOutputDoc)))
583	gOptionsDialog.getControl(&quot;cbChartTest&quot;).setState( -( GetUserFieldState (cUserFieldTestChart, gOutputDoc)))
584	gOptionsDialog.getControl(&quot;cbJavaTest&quot;).setState( -( GetUserFieldState (cUserFieldTestJava, gOutputDoc)))
585	gOptionsDialog.getControl(&quot;cbDatabaseTest&quot;).setState( -( GetUserFieldState (cUserFieldTestDatabase, gOutputDoc)))
586	gOptionsDialog.getControl(&quot;cbExtensionTest&quot;).setState( -( GetUserFieldState (cUserFieldTestExtension, gOutputDoc)))
587	gOptionsDialog.getControl(&quot;cbSaveOpenXMLTest&quot;).setState( -( GetUserFieldState (cUserFieldTestOpenSaveXML, gOutputDoc)))
588	gOptionsDialog.getControl(&quot;cbSaveOpen8Test&quot;).setState( -( GetUserFieldState (cUserFieldTestOpenSave8, gOutputDoc)))
589	gOptionsDialog.getControl(&quot;cbTerminateAfterTest&quot;).setState( -( GetUserFieldState (cUserFieldTestTerminateAfterTest, gOutputDoc)))
590End Sub
591
592Sub ReadOptions
593	call SetGlobalDoc
594	bMakeWriterTest = GetUserFieldState (cUserFieldTestWriter, gOutputDoc)
595	bMakeCalcTest = GetUserFieldState (cUserFieldTestCalc, gOutputDoc)
596	bMakeImpressTest = GetUserFieldState (cUserFieldTestImpress, gOutputDoc)
597	bMakeDrawTest = GetUserFieldState (cUserFieldTestDraw, gOutputDoc)
598	bMakeHTMLTest = GetUserFieldState (cUserFieldTestHTML, gOutputDoc)
599	bMakeMathTest = GetUserFieldState (cUserFieldTestMath, gOutputDoc)
600	bMakeChartTest = GetUserFieldState (cUserFieldTestChart, gOutputDoc)
601	bMakeJavaTest = GetUserFieldState (cUserFieldTestJava, gOutputDoc)
602	bMakeDBTest = GetUserFieldState (cUserFieldTestDatabase, gOutputDoc)
603	bMakeExtensionTest = GetUserFieldState (cUserFieldTestExtension, gOutputDoc)
604	bMakeSaveOpenXMLTest = GetUserFieldState (cUserFieldTestOpenSaveXML, gOutputDoc)
605	bMakeSaveOpen8Test = GetUserFieldState (cUserFieldTestOpenSave8, gOutputDoc)
606	bMakeTerminateAfterTest = GetUserFieldState (cUserFieldTestTerminateAfterTest, gOutputDoc)
607end Sub
608
609Sub SetDefaultOptions
610	bMakeWriterTest = true
611	bMakeCalcTest = true
612	bMakeImpressTest = true
613	bMakeDrawTest = true
614	bMakeHTMLTest = true
615	bMakeMathTest = true
616	bMakeChartTest = true
617	if Environ(&quot;SOLAR_JAVA&quot;) = &quot;&quot; then
618		bMakeJavaTest = false
619		bMakeDBTest = false
620		bMakeExtensionTest = false
621	else
622		bMakeJavaTest = true
623		bMakeDBTest = true
624		bMakeExtensionTest = true
625	End If
626	bMakeSaveOpenXMLTest = true
627	REM Disable StarOffice 5.0 tests in case binfilter has not been included
628	bMakeSaveOpen8Test = true
629	bMakeTerminateAfterTest = false
630end Sub
631
632Sub StartTestByOptions
633	bShowTable = true
634	call ReadOptions
635	call Main
636	if bMakeTerminateAfterTest then
637		ClearDocFull (gOutputDoc)
638		gOutputDoc.dispose
639		&apos;StarDesktop.Terminate
640
641		&apos;EnableReschedule( false )
642		&apos;DispatchSlot( 5300 )
643		stop
644	End If
645end Sub
646
647Function StartTestWithDefaultOptions
648	bShowTable = false
649	call SetDefaultOptions
650	call Main
651	dim component(cMaxErrorStates) as string
652	component(cStWriter) = &quot;Writer&quot;
653	component(cStCalc) = &quot;Calc&quot;
654	component(cStPraesentation) = &quot;Impress&quot;
655	component(cStZeichnen) = &quot;Draw&quot;
656	component(cStChart) = &quot;Chart&quot;
657	component(cStMath) = &quot;Math&quot;
658	component(cStHTML) = &quot;HTML&quot;
659	component(cStJava) = &quot;Java&quot;
660	component(cStDataBase) = &quot;Base&quot;
661	component(cStExtension) = &quot;Extensions&quot;
662	dim action(3) as string
663	action(cDocNew) = &quot;new&quot;
664	action(cDocSaveOpen8) = &quot;V8.0&quot;
665	action(cDocSaveOpenXML) = &quot;XML&quot;
666	action(cDocClose) = &quot;close&quot;
667	dim baseAction(5) as string
668	baseAction(cDBService) = &quot;services&quot;
669	baseAction(cDBOpen) = &quot;open&quot;
670	baseAction(cDBInsert) = &quot;insert&quot;
671	baseAction(cDBDelete) = &quot;delete&quot;
672	baseAction(cDBSeek) = &quot;seek&quot;
673	baseAction(cDBClose) = &quot;close&quot;
674	dim extAction(2) as string
675	extAction(cEXTService) = &quot;services&quot;
676	extAction(cEXTInstall) = &quot;install&quot;
677	extAction(cEXTUninstall) = &quot;uninstall&quot;
678	dim result as string
679	for i = 0 to cMaxErrorStates
680		for j = 0 to 5
681			if gErrorState(i, j) = cLogFalse then
682				result = result &amp; &quot; &quot; &amp; component(i) &amp; &quot;:&quot;
683				if i = cStDataBase then
684					result = result &amp; baseAction(j)
685				else if i = cStExtension then
686					result = result &amp; extAction(j)
687				else
688					result = result &amp; action(j)
689				end if
690				end if
691			end if
692		next j
693	next i
694	StartTestWithDefaultOptions = result
695end Function
696
697Sub DispatchSlot(SlotID as Integer)
698	Dim oArg() as new com.sun.star.beans.PropertyValue
699	Dim oUrl as new com.sun.star.util.URL
700	Dim oTrans as Object
701	Dim oDisp as Object
702
703	oTrans = createUNOService(&quot;com.sun.star.util.URLTransformer&quot;)
704	oUrl.Complete = &quot;slot:&quot; &amp; CStr(SlotID)
705	oTrans.parsestrict(oUrl)
706
707	oDisp = StarDesktop.queryDispatch(oUrl, &quot;_self&quot;, 0)
708	oDisp.dispatch(oUrl, oArg())
709End Sub
710
711Sub LoadLibrary( LibName As String )
712
713	dim args(1)
714	dim arg as new com.sun.star.beans.PropertyValue
715	arg.Name = &quot;LibraryName&quot;
716	arg.Value = LibName
717	args(0) = arg
718
719	dim url as new com.sun.star.util.URL
720	dim trans as object
721	trans = createUnoService(&quot;com.sun.star.util.URLTransformer&quot; )
722	url.Complete = &quot;slot:6517&quot;
723	trans.parsestrict( url )
724
725	dim disp as object
726	disp = StarDesktop.currentFrame.queryDispatch( url, &quot;&quot;, 0 )
727	disp.dispatch( url, args() )
728
729End Sub
730
731Sub ExecuteSlot( SlotNr As String, oDoc as Object )
732	dim args()
733	dim url as new com.sun.star.util.URL
734	dim trans as object
735	dim disp as object
736
737	trans = createUnoService(&quot;com.sun.star.util.URLTransformer&quot; )
738	url.Complete = &quot;slot:&quot; + SlotNr
739	trans.parsestrict( url )
740
741	disp = oDoc.CurrentController.Frame.queryDispatch( url, &quot;&quot;, 0 )
742	disp.dispatch( url, args() )
743
744End Sub
745
746Sub DelAllUserFields (aDoc as Object)
747	Dim aFieldType as Object
748	Dim aElements as Variant
749	Dim i%
750	Dim aFieldMasters, aFieldMaster as Object
751	Dim sElement$
752	aFieldMasters = aDoc.TextFieldMasters
753	aElements = aFieldMasters.ElementNames
754	for i = 0 to UBound(aElements)
755		sElement$ = aElements(i)
756		if 0 &lt;&gt; instr(sElement$, cUnoUserField ) then
757			aFieldMaster = aFieldMasters.GetByName(sElement$)
758			aFieldMaster.Dispose
759		endif
760	next
761end Sub
762
763Function GetUserFieldState (sName as String, aDoc as Object) as boolean
764	Dim sFieldText as String
765	Dim bState as boolean
766	sFieldText = ReadUserField (sName, aDoc)
767
768	if LCase(sFieldText) = cYes then
769		bState = true
770	else
771		bState = false
772	end IF
773
774	GetUserFieldState = bState
775end Function
776
777Sub SetUserFieldState (sName as String, nState as boolean, aDoc as Object)
778	Dim sFieldText as String
779
780	sFieldText = cNo &apos;default
781
782	Select case nState
783		case true
784			sFieldText = cYes
785		case false
786			sFieldText = cNo
787	end Select
788
789	WriteUserField (sFieldText, sName, aDoc)
790end Sub
791
792Function ReadUserField(sFieldName as String, aDoc as Object) as String
793	Dim aMasters as Object
794	aMasters = aDoc.TextFieldMasters
795	if aMasters.HasByName (cUnoUserField+cUnoSeparator+sFieldName) then
796		ReadUserField = aMasters.GetByName (cUnoUserField+cUnoSeparator+sFieldName).Content
797	else
798		ReadUserField = &quot;&quot;
799	end If
800End Function
801
802Sub WriteUserField(sValue as String, sFieldName as String, aDoc as Object, optional aCursor as Object)
803	Dim aMasters, aUserField, aTxtCursor as Object
804	aMasters = aDoc.TextFieldMasters
805	if aMasters.HasByName (cUnoUserField+cUnoSeparator+sFieldName) then
806		aUserField = aMasters.GetByName (cUnoUserField+cUnoSeparator+sFieldName)
807	else
808		aUserField = aDoc.CreateInstance (cUnoUserField)
809		aUserField.Name = sFieldName
810	end if
811	aUserField.Content = sValue
812End Sub
813
814Sub WriteExtUserField(nIndex as Integer, aCursor as Object, aDoc as Object)
815	Dim aUserField as Object
816	aUserField = aDoc.CreateInstance (cUnoExtUserField)
817	aUserField.UserDataType = nIndex
818	aCursor.Text.InsertTextContent (aCursor, aUserField, True)
819	aUserField.Fix = True
820End Sub
821</script:module>
822