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