update credits
[LibreOffice.git] / smoketest / data / Basic / Standard / Global.xml
blob64e6a3d1bf4e17ed1bb0e7381003735e6fdc04cb
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  -->
19 <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
20 <script:module xmlns:script="http://openoffice.org/2000/script" script:name="Global" script:language="StarBasic">REM  *****  BASIC  *****
22 const cMaxErrorStates = 14
24 const cCoGreen = 4057917, cCoRed = 16711680, cCoGrey = 12632256
25 const cParagraphBreak = 0
27 global const cExtensionFileName = &quot;TestExtension.oxt&quot;
29 global const cDocNew = 0, cDocSaveOpen8 = 1, cDocSaveOpenXML = 2, cDocClose = 3, cDocMacros = 4
30 global const cDBService = 0, cDBOpen = 1, cDBInsert = 2, cDBDelete = 3, cDBSeek = 4, cDBClose = 5
31 global const cEXTService = 0, cEXTInstall = 1, cEXTUninstall = 2
32 global const cTestClosureSetupDoc = 0, cTestClosureWriteStatus = 1
33 global const cLogfileFailed = 255
35 global const cStWriter = 0, cStCalc = 1, cStPraesentation = 2, cStZeichnen = 3
36 global const cStHTML = 6, cStChart = 4, cStJava = 7
37 global const cStMath = 5, cStDataBase = 9
38 global const cStExtension = 11
39 global const cStTestGlue = 12
40 global const cStNone = -1
42 global const cFlt8 = 0, cFltNewDoc = 64, cFltXML = 128
44 global const frmWriter = 1, frmCalc = 2, frmImpress = 4
45 global const frmMath = 5, frmChart = 7, frmHyperText = 8, frmDraw = 9
46 global const frmDataBase = 10, frmJava = 13
47 global const frmExtension = 14
48 global const frmTestClosure = 15
50 Global gCurrentDocTest As Integer
51 Global gCurrentTestCase As Integer
53 global const cLogUnknown = 0, cLogFalse = 1, cLogTrue = 2
55 &apos;UserFieldKennungen
56 Global const cYes = &quot;y&quot;, cNo = &quot;n&quot;
57 Global const cStateNo = 0, cStateYes = 1
59 &apos;Feldtypen
60 Global const cFtExtUser = 21, cFtPageNum = 5, cFtStatistic = 8, cFtDateTime = 27, cFtDatabase = 31
62 &apos;UnoStrings
63 Global const cUnoSeparator = &quot;.&quot;
64 Global const cUnoPrefix = &quot;com.sun.star.&quot;
65 Global const cUnoUserField = cUnoPrefix + &quot;text.FieldMaster.User&quot;
66 Global const cUnoExtUserField = cUnoPrefix + &quot;text.TextField.ExtendedUser&quot;
67 Global const cUnoMasterDataBase = cUnoPrefix + &quot;text.FieldMaster.Database&quot;
68 Global const cUnoDataBase = cUnoPrefix + &quot;text.TextField.Database&quot;
69 Global const cUnoDateTime = cUnoPrefix + &quot;text.TextField.DateTime&quot;
70 Global const cUnoTextGraphi2 = cUnoPrefix + &quot;text.Graphic&quot;
71 Global const cUnoJavaLoader = cUnoPrefix + &quot;loader.Java&quot;
72 Global const cUnoDatabaseContext = cUnoPrefix + &quot;sdb.DatabaseContext&quot;
73 Global const cUnoRowSet = cUnoPrefix + &quot;sdb.RowSet&quot;
74 Global const cUnoSmoketestTestExtension = cUnoPrefix + &quot;comp.smoketest.TestExtension&quot;
75 Global const cUnoSmoketestCommandEnvironment = cUnoPrefix + &quot;deployment.test.SmoketestCommandEnvironment&quot;
76 Global const cExtensionManager = cUnoPrefix + &quot;deployment.ExtensionManager&quot;
78 &apos;UserFieldNames
79 Global const cUserFieldTestWriter = &quot;Writer&quot;, cUserFieldTestCalc = &quot;Calc&quot;, cUserFieldTestImpress = &quot;Impress&quot;
80 Global const cUserFieldTestDraw = &quot;Draw&quot;, cUserFieldTestMath = &quot;Math&quot;, cUserFieldTestChart = &quot;Chart&quot;
81 Global const cUserFieldTestHTML = &quot;HTML&quot;, cUserFieldTestJava = &quot;Java&quot;, cUserFieldTestDatabase = &quot;Database&quot;
82 Global const cUserFieldTestExtension = &quot;Extension&quot;
83 Global const cUserFieldTestOpenSaveXML = &quot;SaveOpenXML&quot;
84 Global const cUserFieldTestTerminateAfterTest = &quot;Terminate&quot;, cUserFieldTestOpenSave8 = &quot;SaveOpen8&quot;, cUserFieldTestMacros = &quot;Macros&quot;
86 Global const cOptionsDialogName = &quot;OptionsDlg&quot;, cTest10Modul = &quot;Standard&quot;
88 Global const cDlgCancel = 1, cDlgOk = 0, cDlgStartTest = 2
90 global gErrorState (cMaxErrorStates, 5) as integer
91 Global gTestCaseAnnotations( cMaxErrorStates, 5 ) As String
93 global gOutputDoc as Object
94 global gOutputDocNotUno as Object
95 global gOptionsDialog as Object
97 Global bMakeWriterTest as boolean, bMakeCalcTest as  boolean, bMakeImpressTest as boolean
98 Global bMakeDrawTest as Boolean, bMakeMathTest as boolean, bMakeChartTest as boolean
99 Global bMakeHTMLTest as boolean, bMakeJavaTest as boolean, bMakeDBTest as boolean
100 Global bMakeExtensionTest as boolean
101 Global bMakeSaveOpenXMLTest as boolean
102 Global bMakeTerminateAfterTest as boolean, bShowTable as boolean
103 Global bMakeSaveOpen8Test as boolean, bMakeMacrosTest as boolean
105 global sExtensionURL as string
107 Dim gDlgState as Integer
109 Sub SetGlobalDoc
110     gOutputDoc = ThisComponent
111 end Sub
113 Sub ClearStatus
114     for j% = 0 to cMaxErrorStates
115         for i% = 0 to 5
116             gErrorState (j%, i%) = cLogUnknown
117             gTestCaseAnnotations( J%, i% ) = ""
118         next i%
119     next j%
120 end Sub
122 Sub ClearAllText
123     call SetGlobalDoc
124     call ClearDoc (gOutputDoc)
125     call ClearStatus
126 end Sub
128 Sub AssertionHandler( sMessage as String )
129     LogTestResult( &quot;assertion caught: &quot; + sMessage, FALSE )
130 End Sub
132 Sub Main
133     On Local Error Goto MainError
135     gCurrentDocTest = frmTestClosure
136     gCurrentTestCase = cLogfileFailed
138     DeleteAllSavedFiles()
139     DeleteAllLogFiles()
140     SetupWorkPath()
142     if GetSystem (sWorkPath) = &quot;windows&quot; then
143         sWorkPath = ConvertPathToWin (sWorkPath)
144     end if
146     LocalTestLog% = OpenLogDat( GetLogFileName( gCurrentDocTest ) )
148     gCurrentTestCase = cTestClosureSetupDoc
149     CaptureAssertions( "AssertionHandler" )
151     call SetGlobalDoc
153     Dim bWasModified as Boolean
154     bWasModified = gOutputDoc.isModified()
156     if bShowTable then
157         call ClearDoc (gOutputDoc)
158     end If
160     call ClearStatus
162     LogTestResult( GetTestGlueDescription( gCurrentTestCase ), TRUE )
164     Dim nPreserveFileHandle%
165     nPreserveFileHandle% = LocalTestLog%
166     Call Test_10er.Main
167     LocalTestLog% = nPreserveFileHandle%
169     gCurrentDocTest = frmTestClosure
170     gCurrentTestCase = cTestClosureWriteStatus
171     if bShowTable then
172         call CreateStatusTable2
173         call CreateStatusTable
174         call CreateDocState
175         LogTestResult( GetTestGlueDescription( gCurrentTestCase ), TRUE )
176             &apos; do this LogTestResult call before CreateSecondState, since the latter accesses (and displays) the result
177         call CreateSecondState
178         gOutputDoc.CurrentController.ViewCursor.JumpToFirstPage
179     Else
180         LogTestResult( GetTestGlueDescription( gCurrentTestCase ), TRUE )
181     End If
183     &apos; print the &apos;test complete&apos; marker
184     Print #LocalTestLog%, &quot;---&quot;
185     LocalTestLog% = 0
187     gOutputDoc.setModified( bWasModified )
189     CaptureAssertions( &quot;&quot; )
190     Exit Sub
192 MainError:
193     If ( gCurrentTestCase = cLogfileFailed ) then
194         LogTestResult( &quot;&quot;, False )
195         Exit Sub
196     else
197         LogTestResult( &quot;testclosure &quot; + GetTestGlueDescription( gCurrentTestCase ), FALSE )
198         Close #LocalTestLog%
199         LocalTestLog = 0
200     End If
201 End Sub
203 Function GetTestGlueDescription( nTestCase as Integer )
204     Select Case ( nTestCase )
205         case cTestClosureSetupDoc
206             GetTestGlueDescription = &quot;setup&quot;
207         case cTestClosureWriteStatus
208             GetTestGlueDescription = &quot;write_status&quot;
209         case Else
210             GetTestGlueDescription = &quot;&quot;
211     End Select
212 End Function
214 Sub CreateStatusTable
215     dim tableHeaders(7) as string
216     tableHeaders(cStWriter) = &quot;Writer&quot;
217     tableHeaders(cStCalc) = &quot;Calc&quot;
218     tableHeaders(cStPraesentation) = &quot;Präsen- tation&quot;
219     tableHeaders(cStZeichnen) = &quot;Zeichn.&quot;
220     tableHeaders(cStChart) = &quot;Diagr.&quot;
221     tableHeaders(cStMath) = &quot;Math&quot;
222     tableHeaders(cStHTML) = &quot;HTML&quot;
223     tableHeaders(cStJava) = &quot;Java&quot;
225     dim tableRows(4) as string
226     tableRows(cDocNew) = &quot;new&quot;
227     tableRows(cDocSaveOpen8) = &quot;V8.0&quot;
228     tableRows(cDocSaveOpenXML) = &quot;XML&quot;
229     tableRows(cDocClose) = &quot;close&quot;
230     tableRows(cDocMacros) = &quot;macros&quot;
232     aDoc = gOutputDoc
234     xText = aDoc.Text
235     xCursor = xText.createTextCursor()
237     xCursor.gotoStart(FALSE)
238     xCursor.GoRight (4, False)
239     SetParagraphBreak (xCursor)
240     xCursor.GoRight (1, False)
241     SetParagraphBreak (xCursor)
242     xCursor.GoRight (1, False)
244     table = aDoc.createInstance(&quot;com.sun.star.text.TextTable&quot;)
245     table.initialize(7,9)
246     table.Name = &quot;StTab1&quot;
247   table.BackColor = cCoGrey
248     xText.insertTextContent(xCursor, table, FALSE)
250     for i% = 0 to 7
251         tableCell = table.getCellByPosition( i% + 1, 0 )
252         tableCell.String = tableHeaders( i% )
253     next i%
255     for i% = LBound( tableRows ) to UBound( tableRows )
256         tableCell = table.getCellByPosition( 0, i% + 1 )
257       tableCell.String=tableRows(i%)
258     next i%
259 end Sub
261 Sub CreateStatusTable2
262     dim tableHeaders(4) as string
263     tableHeaders(0) = &quot;Database&quot;
264     tableHeaders(1) = &quot;&quot;
265     tableHeaders(2) = &quot;Extension&quot;
266     tableHeaders(3) = &quot;&quot;
267     tableHeaders(4) = &quot;Other&quot;
269     dim tableRows(5) as string
270     tableRows(cDBService ) = &quot;services&quot;
271     tableRows(cDBOpen ) = &quot;open&quot;
272     tableRows(cDBInsert ) = &quot;insert&quot;
273     tableRows(cDBDelete  ) = &quot;delete&quot;
274     tableRows(cDBSeek ) = &quot;seek&quot;
275     tableRows(cDBClose ) = &quot;close&quot;
277     dim tableRows2(2) as string
278     tableRows2(cEXTService ) = &quot;services&quot;
279     tableRows2(cEXTInstall ) = &quot;install&quot;
280     tableRows2(cEXTUninstall ) = &quot;uninstall&quot;
282     dim tableRows3(1) as string
283     tableRows3(cTestClosureSetupDoc ) = &quot;setup test&quot;
284     tableRows3(cTestClosureWriteStatus ) = &quot;write test result&quot;
286     aDoc = gOutputDoc
288     xText = aDoc.Text
289     xCursor = xText.createTextCursor()
291     xCursor.gotoStart(FALSE)
292     xCursor.GoRight (4, False)
293     SetParagraphBreak (xCursor)
294     SetParagraphBreak (xCursor)
295     xCursor.gotoEnd(FALSE)
297     table = aDoc.createInstance(&quot;com.sun.star.text.TextTable&quot;)
298     table.initialize(7,6)
299     table.Name = &quot;StTab2&quot;
300     table.BackColor = cCoGrey
302     xText.insertTextContent(xCursor, table, FALSE)
304     for i% = LBound( tableHeaders ) to UBound( tableHeaders )
305         tableCell = table.getCellByPosition( i% + 1, 0 )
306         tableCell.String = tableHeaders(i%)
307     next i%
309     for i% = LBound( tableRows ) to UBound( tableRows )
310         tableCell = table.getCellByPosition( 0, i% + 1 )
311       tableCell.String=tableRows(i%)
312     next i%
314     for i% = LBound( tableRows2 ) to UBound( tableRows2 )
315         tableCell = table.getCellByPosition( 2, i% + 1 )
316       tableCell.String=tableRows2(i%)
317     next i%
319     for i% = LBound( tableRows3 ) to UBound( tableRows3 )
320         tableCell = table.getCellByPosition( 4, i% + 1 )
321       tableCell.String=tableRows3(i%)
322     next i%
323 end Sub
326 Sub CreateDocState
327     aDoc = gOutputDoc
328     table = aDoc.TextTables.GetByIndex (1)
330     for j% = 0 to 7
331         for i% = 0 to 5
332             sRangeName = GetRangeName(j%, i%+1)
334             tableCursor = table.createCursorByCellName(sRangeName)
336             cName = tableCursor.getRangeName()
337             xCell = table.getCellByName(cName)
339             xCell.BackTransparent = False
341             If gErrorState (j%, i%) = cLogTrue Then
342                 xCell.BackColor = cCoGreen
343             else
344                 If gErrorState (j%, i%) = cLogFalse Then
345                     xCell.BackColor = cCoRed
346                     If ( gTestCaseAnnotations( j%, i% ) &lt;&gt; "" ) Then
347                         Dim annotation as Object
348                         annotation = aDoc.createInstance( &quot;com.sun.star.text.TextField.Annotation&quot; )
349                         annotation.Author = &quot;smoketest&quot;
350                         annotation.Content = gTestCaseAnnotations( j%, i% )
351                         xCell.insertTextContent( xCell, annotation, false )
352                     End If
353                 else
354                     xCell.BackColor = cCoGrey
355                 end If
356             end If
357         next i%
358     next j%
359 end Sub
361 Sub CreateSecondState
362     aDoc = gOutputDoc
363     table = aDoc.TextTables.GetByIndex (0)
365     Dim stateIndex(2) as Integer
366     stateIndex(0) = cStDataBase
367     stateIndex(1) = cStExtension
368     stateIndex(2) = cStTestGlue
370     Dim j as Integer
371     For j = LBound( stateIndex ) To UBound( stateIndex )
372         for i% = 1 to 6
373             tableCell = table.getCellByPosition( 2 * j + 1, i% )
374             tableCell.BackTransparent = False
376             if gErrorState( stateIndex(j), i% - 1 ) = cLogTrue then
377                 tableCell.BackColor = cCoGreen
378             else
379                 if gErrorState ( stateIndex(j), i% - 1 ) = cLogFalse then
380                     tableCell.BackColor = cCoRed
381                     If ( gTestCaseAnnotations( stateIndex(j), i% - 1 ) &lt;&gt; &quot;&quot; ) Then
382                         Dim annotation as Object
383                         annotation = aDoc.createInstance( &quot;com.sun.star.text.TextField.Annotation&quot; )
384                         annotation.Author = &quot;smoketest&quot;
385                         annotation.Content = gTestCaseAnnotations( stateIndex(j), i% - 1 )
386                         tableCell.insertTextContent( tableCell, annotation, false )
387                     End If
388                 else
389                     tableCell.BackColor = cCoGrey
390                 end If
391               end If
392         next i%
393     next j%
394 end Sub
396 Function GetRangeName (nColumn as integer, nRow as integer) as string
397     GetRangeName = chr (nColumn+66) + Trim(Str(nRow+1))
398 end Function
400 Sub LogTestResult( sTestCaseDescription as String, bSuccess as Boolean )
401     If ( gCurrentTestCase = cLogfileFailed ) Then
402         Dim sAnnotation as String
403         sAnnotation = &quot;creating logfile &apos;&quot; + GetLogFileName( gCurrentDocTest ) + &quot;&apos; failed&quot;
404         LogState( FALSE, sAnnotation, GlobalTestLog )
405         RecordTestCaseStatus( 0, FALSE, sAnnotation )
406     Else
407         bSuccess = RecordTestCaseStatus( gCurrentTestCase, bSuccess, sTestCaseDescription )
408         If ( LocalTestLog &lt;&gt; 0 ) Then
409             LogState( bSuccess, sTestCaseDescription, LocalTestLog )
410         EndIf
411         if ( GlobalTestLog &lt;&gt; 0 ) Then
412             LogState( bSuccess, sTestCaseDescription, GlobalTestLog )
413         EndIf
414     End If
415 End Sub
417 Function RecordTestCaseStatus( nAction as Integer, bState as Boolean, sFailureAnnotation as String ) as Boolean
418     Dim nStatusType as Integer
419     Dim nState as integer
420     nStatusType = GetStatusType( gCurrentDocTest )
421     If nStatusType = cStNone then Exit Function
423   If ( gErrorState( nStatusType, nAction ) = cLogFalse ) Then
424     &apos; don't overwrite a previous &quot;failed&quot; state for this test
425     bState = FALSE
426   End If
428     if bState then
429         nState = cLogTrue
430     else
431         nState = cLogFalse
432     end If
434     gErrorState (nStatusType, nAction) = nState
436     If ( nState = cLogFalse ) And ( sFailureAnnotation &lt;&gt; &quot;&quot; ) Then
437         if gTestCaseAnnotations(nStatusType, nAction) &lt;&gt; &quot;&quot; then
438             gTestCaseAnnotations(nStatusType, nAction) = _
439                 gTestCaseAnnotations(nStatusType, nAction) &amp; &quot;; &quot;
440         end if
441         gTestCaseAnnotations( nStatusType, nAction ) = gTestCaseAnnotations( nStatusType, nAction ) + sFailureAnnotation
442     End If
444     RecordTestCaseStatus = bState
445 End Function
447 Function 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
474 end Function
476 Sub SetParagraphBreak (aCursor as Object)
477     aCursor.Text.InsertControlCharacter (aCursor, cParagraphBreak, True)
478 end Sub
480 Sub 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
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;
493 end Sub
495 Sub 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
502     aText = aDoc.Text.CreateTextCursor
503     aText.GotoStart (False)
504     aText.GotoEnd (True)
505     aText.String=&quot;&quot;
506 end Sub
508 Sub SetGlobalOptionsDialog ()
510     Dim oLibContainer As Object, oLib As Object
511     Dim oInputStreamProvider As Object
512     Dim oDialog As Object
514     Const sLibName = cTest10Modul
515     Const sDialogName = cOptionsDialogName
517     REM get library and input stream provider
518     oLibContainer = DialogLibraries
520     REM load the library
521     oLibContainer.loadLibrary( sLibName )
523     oLib = oLibContainer.getByName( sLibName )
524     oInputStreamProvider = oLib.getByName( sDialogName )
526     REM create dialog control
527     gOptionsDialog = CreateUnoDialog( oInputStreamProvider )
529 end Sub
531 Sub ShowOptionsDlg
533     call SetGlobalDoc
534     call SetGlobalOptionsDialog
535     call GetOptions
537     REM show the dialog
538     gOptionsDialog.execute()
540        &apos; jetzt läuft der Dialog, bis ein Button gedrĂ¼ckt wird
542        Select Case (gDlgState)
543            case cDlgOk
544                call SetOptions ()
545            case cDlgStartTest
546                call SetOptions ()
547                call StartTestByOptions ()
548     end Select
550     gOptionsDialog.dispose()
552 end Sub
554 Sub 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 (cUserFieldTestMacros, -(gOptionsDialog.getControl(&quot;cbMacrosTest&quot;).getState), gOutputDoc)
569     SetUserFieldState (cUserFieldTestTerminateAfterTest, -(gOptionsDialog.getControl(&quot;cbTerminateAfterTest&quot;).getState), gOutputDoc)
570 end Sub
572 Sub GetOptions
573     call SetGlobalDoc
574     gOptionsDialog.getControl(&quot;cbWriterTest&quot;).setState( -( GetUserFieldState (cUserFieldTestWriter, gOutputDoc)))
575     gOptionsDialog.getControl(&quot;cbCalcTest&quot;).setState ( -( GetUserFieldState (cUserFieldTestCalc, gOutputDoc)))
576     gOptionsDialog.getControl(&quot;cbImpressTest&quot;).setState( -( GetUserFieldState (cUserFieldTestImpress, gOutputDoc)))
577     gOptionsDialog.getControl(&quot;cbDrawTest&quot;).setState( -( GetUserFieldState (cUserFieldTestDraw, gOutputDoc)))
578     gOptionsDialog.getControl(&quot;cbHTMLTest&quot;).setState( -( GetUserFieldState (cUserFieldTestHTML, gOutputDoc)))
579     gOptionsDialog.getControl(&quot;cbMathTest&quot;).setState( -( GetUserFieldState (cUserFieldTestMath, gOutputDoc)))
580     gOptionsDialog.getControl(&quot;cbChartTest&quot;).setState( -( GetUserFieldState (cUserFieldTestChart, gOutputDoc)))
581     gOptionsDialog.getControl(&quot;cbJavaTest&quot;).setState( -( GetUserFieldState (cUserFieldTestJava, gOutputDoc)))
582     gOptionsDialog.getControl(&quot;cbDatabaseTest&quot;).setState( -( GetUserFieldState (cUserFieldTestDatabase, gOutputDoc)))
583     gOptionsDialog.getControl(&quot;cbExtensionTest&quot;).setState( -( GetUserFieldState (cUserFieldTestExtension, gOutputDoc)))
584     gOptionsDialog.getControl(&quot;cbSaveOpenXMLTest&quot;).setState( -( GetUserFieldState (cUserFieldTestOpenSaveXML, gOutputDoc)))
585     gOptionsDialog.getControl(&quot;cbSaveOpen8Test&quot;).setState( -( GetUserFieldState (cUserFieldTestOpenSave8, gOutputDoc)))
586     gOptionsDialog.getControl(&quot;cbMacrosTest&quot;).setState( -( GetUserFieldState (cUserFieldTestMacros, gOutputDoc)))
587     gOptionsDialog.getControl(&quot;cbTerminateAfterTest&quot;).setState( -( GetUserFieldState (cUserFieldTestTerminateAfterTest, gOutputDoc)))
588 End Sub
590 Sub ReadOptions
591     call SetGlobalDoc
592     bMakeWriterTest = GetUserFieldState (cUserFieldTestWriter, gOutputDoc)
593     bMakeCalcTest = GetUserFieldState (cUserFieldTestCalc, gOutputDoc)
594     bMakeImpressTest = GetUserFieldState (cUserFieldTestImpress, gOutputDoc)
595     bMakeDrawTest = GetUserFieldState (cUserFieldTestDraw, gOutputDoc)
596     bMakeHTMLTest = GetUserFieldState (cUserFieldTestHTML, gOutputDoc)
597     bMakeMathTest = GetUserFieldState (cUserFieldTestMath, gOutputDoc)
598     bMakeChartTest = GetUserFieldState (cUserFieldTestChart, gOutputDoc)
599     bMakeJavaTest = GetUserFieldState (cUserFieldTestJava, gOutputDoc)
600     bMakeDBTest = GetUserFieldState (cUserFieldTestDatabase, gOutputDoc)
601     bMakeExtensionTest = GetUserFieldState (cUserFieldTestExtension, gOutputDoc)
602     bMakeSaveOpenXMLTest = GetUserFieldState (cUserFieldTestOpenSaveXML, gOutputDoc)
603     bMakeSaveOpen8Test = GetUserFieldState (cUserFieldTestOpenSave8, gOutputDoc)
604     bMakeMacrosTest = GetUserFieldState (cUserFieldTestMacros, gOutputDoc)
605     bMakeTerminateAfterTest = GetUserFieldState (cUserFieldTestTerminateAfterTest, gOutputDoc)
606 end Sub
608 Sub SetDefaultOptions
609     bMakeWriterTest = true
610     bMakeCalcTest = true
611     bMakeImpressTest = true
612     bMakeDrawTest = true
613     bMakeHTMLTest = true
614     bMakeMathTest = true
615     bMakeChartTest = true
616     if Environ(&quot;SOLAR_JAVA&quot;) = &quot;&quot; then
617         bMakeJavaTest = false
618         bMakeDBTest = false
619         bMakeExtensionTest = false
620     else
621         bMakeJavaTest = true
622         bMakeDBTest = true
623         bMakeExtensionTest = true
624     End If
625     bMakeSaveOpenXMLTest = true
626     bMakeSaveOpen8Test = true
627     bMakeMacrosTest = true
628     bMakeTerminateAfterTest = false
629 end Sub
631 Sub StartTestByOptions
632     bShowTable = true
633     call ReadOptions
634     call Main
635     if bMakeTerminateAfterTest then
636         ClearDocFull (gOutputDoc)
637         gOutputDoc.dispose
638         &apos;StarDesktop.Terminate
640         &apos;EnableReschedule( false )
641         &apos;DispatchSlot( 5300 )
642         stop
643     End If
644 end Sub
646 Function StartTestWithDefaultOptions
647     bShowTable = false
648     call SetDefaultOptions
649     call Main
650     dim component(cMaxErrorStates) as string
651     component(cStWriter) = &quot;Writer&quot;
652     component(cStCalc) = &quot;Calc&quot;
653     component(cStPraesentation) = &quot;Impress&quot;
654     component(cStZeichnen) = &quot;Draw&quot;
655     component(cStChart) = &quot;Chart&quot;
656     component(cStMath) = &quot;Math&quot;
657     component(cStHTML) = &quot;HTML&quot;
658     component(cStJava) = &quot;Java&quot;
659     component(cStDataBase) = &quot;Base&quot;
660     component(cStExtension) = &quot;Extensions&quot;
661     dim action(4) as string
662     action(cDocNew) = &quot;new&quot;
663     action(cDocSaveOpen8) = &quot;V8.0&quot;
664     action(cDocSaveOpenXML) = &quot;XML&quot;
665     action(cDocClose) = &quot;close&quot;
666     action(cDocMacros) = &quot;macros&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                 if gTestCaseAnnotations(i, j) &lt;&gt; &quot;&quot; then
692                     result = result &amp; &quot;(&quot; &amp; _
693                         gTestCaseAnnotations(i, j) &amp; &quot;)&quot;
694                 end if
695             end if
696         next j
697     next i
698     StartTestWithDefaultOptions = result
699 end Function
701 Sub DispatchSlot(SlotID as Integer)
702     Dim oArg() as new com.sun.star.beans.PropertyValue
703     Dim oUrl as new com.sun.star.util.URL
704     Dim oTrans as Object
705     Dim oDisp as Object
707     oTrans = createUNOService(&quot;com.sun.star.util.URLTransformer&quot;)
708     oUrl.Complete = &quot;slot:&quot; &amp; CStr(SlotID)
709     oTrans.parsestrict(oUrl)
711     oDisp = StarDesktop.queryDispatch(oUrl, &quot;_self&quot;, 0)
712     oDisp.dispatch(oUrl, oArg())
713 End Sub
715 Sub LoadLibrary( LibName As String )
717     dim args(1)
718     dim arg as new com.sun.star.beans.PropertyValue
719     arg.Name = &quot;LibraryName&quot;
720     arg.Value = LibName
721     args(0) = arg
723     dim url as new com.sun.star.util.URL
724     dim trans as object
725     trans = createUnoService(&quot;com.sun.star.util.URLTransformer&quot; )
726     url.Complete = &quot;slot:6517&quot;
727     trans.parsestrict( url )
729     dim disp as object
730     disp = StarDesktop.currentFrame.queryDispatch( url, &quot;&quot;, 0 )
731     disp.dispatch( url, args() )
733 End Sub
735 Sub ExecuteSlot( SlotNr As String, oDoc as Object )
736     dim args()
737     dim url as new com.sun.star.util.URL
738     dim trans as object
739     dim disp as object
741     trans = createUnoService(&quot;com.sun.star.util.URLTransformer&quot; )
742     url.Complete = &quot;slot:&quot; + SlotNr
743     trans.parsestrict( url )
745     disp = oDoc.CurrentController.Frame.queryDispatch( url, &quot;&quot;, 0 )
746     disp.dispatch( url, args() )
748 End Sub
750 Sub DelAllUserFields (aDoc as Object)
751     Dim aFieldType as Object
752     Dim aElements as Variant
753     Dim i%
754     Dim aFieldMasters, aFieldMaster as Object
755     Dim sElement$
756     aFieldMasters = aDoc.TextFieldMasters
757     aElements = aFieldMasters.ElementNames
758     for i = 0 to UBound(aElements)
759         sElement$ = aElements(i)
760         if 0 &lt;&gt; instr(sElement$, cUnoUserField ) then
761             aFieldMaster = aFieldMasters.GetByName(sElement$)
762             aFieldMaster.Dispose
763         endif
764     next
765 end Sub
767 Function GetUserFieldState (sName as String, aDoc as Object) as boolean
768     Dim sFieldText as String
769     Dim bState as boolean
770     sFieldText = ReadUserField (sName, aDoc)
772     if LCase(sFieldText) = cYes then
773         bState = true
774     else
775         bState = false
776     end IF
778     GetUserFieldState = bState
779 end Function
781 Sub SetUserFieldState (sName as String, nState as boolean, aDoc as Object)
782     Dim sFieldText as String
784     sFieldText = cNo &apos;default
786     Select case nState
787         case true
788             sFieldText = cYes
789         case false
790             sFieldText = cNo
791     end Select
793     WriteUserField (sFieldText, sName, aDoc)
794 end Sub
796 Function ReadUserField(sFieldName as String, aDoc as Object) as String
797     Dim aMasters as Object
798     aMasters = aDoc.TextFieldMasters
799     if aMasters.HasByName (cUnoUserField+cUnoSeparator+sFieldName) then
800         ReadUserField = aMasters.GetByName (cUnoUserField+cUnoSeparator+sFieldName).Content
801     else
802         ReadUserField = &quot;&quot;
803     end If
804 End Function
806 Sub WriteUserField(sValue as String, sFieldName as String, aDoc as Object, optional aCursor as Object)
807     Dim aMasters, aUserField, aTxtCursor as Object
808     aMasters = aDoc.TextFieldMasters
809     if aMasters.HasByName (cUnoUserField+cUnoSeparator+sFieldName) then
810         aUserField = aMasters.GetByName (cUnoUserField+cUnoSeparator+sFieldName)
811     else
812         aUserField = aDoc.CreateInstance (cUnoUserField)
813         aUserField.Name = sFieldName
814     end if
815     aUserField.Content = sValue
816 End Sub
818 Sub WriteExtUserField(nIndex as Integer, aCursor as Object, aDoc as Object)
819     Dim aUserField as Object
820     aUserField = aDoc.CreateInstance (cUnoExtUserField)
821     aUserField.UserDataType = nIndex
822     aCursor.Text.InsertTextContent (aCursor, aUserField, True)
823     aUserField.Fix = True
824 End Sub
825 </script:module>