1 <?xml version="1.0" encoding="UTF-8"?>
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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 = "TestExtension.oxt"
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 'UserFieldKennungen
56 Global const cYes = "y", cNo = "n"
57 Global const cStateNo = 0, cStateYes = 1
60 Global const cFtExtUser = 21, cFtPageNum = 5, cFtStatistic = 8, cFtDateTime = 27, cFtDatabase = 31
63 Global const cUnoSeparator = "."
64 Global const cUnoPrefix = "com.sun.star."
65 Global const cUnoUserField = cUnoPrefix + "text.FieldMaster.User"
66 Global const cUnoExtUserField = cUnoPrefix + "text.TextField.ExtendedUser"
67 Global const cUnoMasterDataBase = cUnoPrefix + "text.FieldMaster.Database"
68 Global const cUnoDataBase = cUnoPrefix + "text.TextField.Database"
69 Global const cUnoDateTime = cUnoPrefix + "text.TextField.DateTime"
70 Global const cUnoTextGraphi2 = cUnoPrefix + "text.Graphic"
71 Global const cUnoJavaLoader = cUnoPrefix + "loader.Java"
72 Global const cUnoDatabaseContext = cUnoPrefix + "sdb.DatabaseContext"
73 Global const cUnoRowSet = cUnoPrefix + "sdb.RowSet"
74 Global const cUnoSmoketestTestExtension = cUnoPrefix + "comp.smoketest.TestExtension"
75 Global const cUnoSmoketestCommandEnvironment = cUnoPrefix + "deployment.test.SmoketestCommandEnvironment"
76 Global const cExtensionManager = cUnoPrefix + "deployment.ExtensionManager"
79 Global const cUserFieldTestWriter = "Writer", cUserFieldTestCalc = "Calc", cUserFieldTestImpress = "Impress"
80 Global const cUserFieldTestDraw = "Draw", cUserFieldTestMath = "Math", cUserFieldTestChart = "Chart"
81 Global const cUserFieldTestHTML = "HTML", cUserFieldTestJava = "Java", cUserFieldTestDatabase = "Database"
82 Global const cUserFieldTestExtension = "Extension"
83 Global const cUserFieldTestOpenSaveXML = "SaveOpenXML"
84 Global const cUserFieldTestTerminateAfterTest = "Terminate", cUserFieldTestOpenSave8 = "SaveOpen8", cUserFieldTestMacros = "Macros"
86 Global const cOptionsDialogName = "OptionsDlg", cTest10Modul = "Standard"
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
110 gOutputDoc = ThisComponent
114 for j% = 0 to cMaxErrorStates
116 gErrorState (j%, i%) = cLogUnknown
117 gTestCaseAnnotations( J%, i% ) = ""
124 call ClearDoc (gOutputDoc)
128 Sub AssertionHandler( sMessage as String )
129 LogTestResult( "assertion caught: " + sMessage, FALSE )
133 On Local Error Goto MainError
135 gCurrentDocTest = frmTestClosure
136 gCurrentTestCase = cLogfileFailed
138 DeleteAllSavedFiles()
142 if GetSystem (sWorkPath) = "windows" then
143 sWorkPath = ConvertPathToWin (sWorkPath)
146 LocalTestLog% = OpenLogDat( GetLogFileName( gCurrentDocTest ) )
148 gCurrentTestCase = cTestClosureSetupDoc
149 CaptureAssertions( "AssertionHandler" )
153 Dim bWasModified as Boolean
154 bWasModified = gOutputDoc.isModified()
157 call ClearDoc (gOutputDoc)
162 LogTestResult( GetTestGlueDescription( gCurrentTestCase ), TRUE )
164 Dim nPreserveFileHandle%
165 nPreserveFileHandle% = LocalTestLog%
167 LocalTestLog% = nPreserveFileHandle%
169 gCurrentDocTest = frmTestClosure
170 gCurrentTestCase = cTestClosureWriteStatus
172 call CreateStatusTable2
173 call CreateStatusTable
175 LogTestResult( GetTestGlueDescription( gCurrentTestCase ), TRUE )
176 ' do this LogTestResult call before CreateSecondState, since the latter accesses (and displays) the result
177 call CreateSecondState
178 gOutputDoc.CurrentController.ViewCursor.JumpToFirstPage
180 LogTestResult( GetTestGlueDescription( gCurrentTestCase ), TRUE )
183 ' print the 'test complete' marker
184 Print #LocalTestLog%, "---"
187 gOutputDoc.setModified( bWasModified )
189 CaptureAssertions( "" )
193 If ( gCurrentTestCase = cLogfileFailed ) then
194 LogTestResult( "", False )
197 LogTestResult( "testclosure " + GetTestGlueDescription( gCurrentTestCase ), FALSE )
203 Function GetTestGlueDescription( nTestCase as Integer )
204 Select Case ( nTestCase )
205 case cTestClosureSetupDoc
206 GetTestGlueDescription = "setup"
207 case cTestClosureWriteStatus
208 GetTestGlueDescription = "write_status"
210 GetTestGlueDescription = ""
214 Sub CreateStatusTable
215 dim tableHeaders(7) as string
216 tableHeaders(cStWriter) = "Writer"
217 tableHeaders(cStCalc) = "Calc"
218 tableHeaders(cStPraesentation) = "Präsen- tation"
219 tableHeaders(cStZeichnen) = "Zeichn."
220 tableHeaders(cStChart) = "Diagr."
221 tableHeaders(cStMath) = "Math"
222 tableHeaders(cStHTML) = "HTML"
223 tableHeaders(cStJava) = "Java"
225 dim tableRows(4) as string
226 tableRows(cDocNew) = "new"
227 tableRows(cDocSaveOpen8) = "V8.0"
228 tableRows(cDocSaveOpenXML) = "XML"
229 tableRows(cDocClose) = "close"
230 tableRows(cDocMacros) = "macros"
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("com.sun.star.text.TextTable")
245 table.initialize(7,9)
246 table.Name = "StTab1"
247 table.BackColor = cCoGrey
248 xText.insertTextContent(xCursor, table, FALSE)
251 tableCell = table.getCellByPosition( i% + 1, 0 )
252 tableCell.String = tableHeaders( i% )
255 for i% = LBound( tableRows ) to UBound( tableRows )
256 tableCell = table.getCellByPosition( 0, i% + 1 )
257 tableCell.String=tableRows(i%)
261 Sub CreateStatusTable2
262 dim tableHeaders(4) as string
263 tableHeaders(0) = "Database"
264 tableHeaders(1) = ""
265 tableHeaders(2) = "Extension"
266 tableHeaders(3) = ""
267 tableHeaders(4) = "Other"
269 dim tableRows(5) as string
270 tableRows(cDBService ) = "services"
271 tableRows(cDBOpen ) = "open"
272 tableRows(cDBInsert ) = "insert"
273 tableRows(cDBDelete ) = "delete"
274 tableRows(cDBSeek ) = "seek"
275 tableRows(cDBClose ) = "close"
277 dim tableRows2(2) as string
278 tableRows2(cEXTService ) = "services"
279 tableRows2(cEXTInstall ) = "install"
280 tableRows2(cEXTUninstall ) = "uninstall"
282 dim tableRows3(1) as string
283 tableRows3(cTestClosureSetupDoc ) = "setup test"
284 tableRows3(cTestClosureWriteStatus ) = "write test result"
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("com.sun.star.text.TextTable")
298 table.initialize(7,6)
299 table.Name = "StTab2"
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%)
309 for i% = LBound( tableRows ) to UBound( tableRows )
310 tableCell = table.getCellByPosition( 0, i% + 1 )
311 tableCell.String=tableRows(i%)
314 for i% = LBound( tableRows2 ) to UBound( tableRows2 )
315 tableCell = table.getCellByPosition( 2, i% + 1 )
316 tableCell.String=tableRows2(i%)
319 for i% = LBound( tableRows3 ) to UBound( tableRows3 )
320 tableCell = table.getCellByPosition( 4, i% + 1 )
321 tableCell.String=tableRows3(i%)
328 table = aDoc.TextTables.GetByIndex (1)
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
344 If gErrorState (j%, i%) = cLogFalse Then
345 xCell.BackColor = cCoRed
346 If ( gTestCaseAnnotations( j%, i% ) <> "" ) Then
347 Dim annotation as Object
348 annotation = aDoc.createInstance( "com.sun.star.text.TextField.Annotation" )
349 annotation.Author = "smoketest"
350 annotation.Content = gTestCaseAnnotations( j%, i% )
351 xCell.insertTextContent( xCell, annotation, false )
354 xCell.BackColor = cCoGrey
361 Sub CreateSecondState
363 table = aDoc.TextTables.GetByIndex (0)
365 Dim stateIndex(2) as Integer
366 stateIndex(0) = cStDataBase
367 stateIndex(1) = cStExtension
368 stateIndex(2) = cStTestGlue
371 For j = LBound( stateIndex ) To UBound( stateIndex )
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
379 if gErrorState ( stateIndex(j), i% - 1 ) = cLogFalse then
380 tableCell.BackColor = cCoRed
381 If ( gTestCaseAnnotations( stateIndex(j), i% - 1 ) <> "" ) Then
382 Dim annotation as Object
383 annotation = aDoc.createInstance( "com.sun.star.text.TextField.Annotation" )
384 annotation.Author = "smoketest"
385 annotation.Content = gTestCaseAnnotations( stateIndex(j), i% - 1 )
386 tableCell.insertTextContent( tableCell, annotation, false )
389 tableCell.BackColor = cCoGrey
396 Function GetRangeName (nColumn as integer, nRow as integer) as string
397 GetRangeName = chr (nColumn+66) + Trim(Str(nRow+1))
400 Sub LogTestResult( sTestCaseDescription as String, bSuccess as Boolean )
401 If ( gCurrentTestCase = cLogfileFailed ) Then
402 Dim sAnnotation as String
403 sAnnotation = "creating logfile '" + GetLogFileName( gCurrentDocTest ) + "' failed"
404 LogState( FALSE, sAnnotation, GlobalTestLog )
405 RecordTestCaseStatus( 0, FALSE, sAnnotation )
407 bSuccess = RecordTestCaseStatus( gCurrentTestCase, bSuccess, sTestCaseDescription )
408 If ( LocalTestLog <> 0 ) Then
409 LogState( bSuccess, sTestCaseDescription, LocalTestLog )
411 if ( GlobalTestLog <> 0 ) Then
412 LogState( bSuccess, sTestCaseDescription, GlobalTestLog )
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 ' don't overwrite a previous "failed" state for this test
434 gErrorState (nStatusType, nAction) = nState
436 If ( nState = cLogFalse ) And ( sFailureAnnotation <> "" ) Then
437 if gTestCaseAnnotations(nStatusType, nAction) <> "" then
438 gTestCaseAnnotations(nStatusType, nAction) = _
439 gTestCaseAnnotations(nStatusType, nAction) & "; "
441 gTestCaseAnnotations( nStatusType, nAction ) = gTestCaseAnnotations( nStatusType, nAction ) + sFailureAnnotation
444 RecordTestCaseStatus = bState
447 Function GetStatusType (nDocType as Integer) as Integer
448 Select Case ( nDocType )
450 GetStatusType = cStWriter ' text document
452 GetStatusType = cStCalc ' spreadsheet document
454 GetStatusType = cStPraesentation ' presentation
456 GetStatusType = cStZeichnen ' drawing
458 GetStatusType = cStMath ' formula
460 GetStatusType = cStHTML ' HTML document
462 GetStatusType = cStChart ' chart
464 GetStatusType = cStJava 'Java
466 GetStatusType = cStTestGlue ' test framework
468 GetStatusType = cStDataBase 'DataBase
470 GetStatusType = cStExtension 'Extension
472 GetStatusType = cStNone
476 Sub SetParagraphBreak (aCursor as Object)
477 aCursor.Text.InsertControlCharacter (aCursor, cParagraphBreak, True)
480 Sub ClearDoc (aDoc as Object)
483 for i%=1 to aDoc.TextTables.count
484 aDoc.TextTables.GetByIndex(0).dispose
487 aText = aDoc.Text.CreateTextCursor
488 aText.GotoStart (False)
489 aText.GoRight (3, False)
490 SetParagraphBreak (aText)
492 aText.String=""
495 Sub ClearDocFull (aDoc as Object)
498 for i%=1 to aDoc.TextTables.count
499 aDoc.TextTables.GetByIndex(0).dispose
502 aText = aDoc.Text.CreateTextCursor
503 aText.GotoStart (False)
505 aText.String=""
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
521 oLibContainer.loadLibrary( sLibName )
523 oLib = oLibContainer.getByName( sLibName )
524 oInputStreamProvider = oLib.getByName( sDialogName )
526 REM create dialog control
527 gOptionsDialog = CreateUnoDialog( oInputStreamProvider )
534 call SetGlobalOptionsDialog
538 gOptionsDialog.execute()
540 ' jetzt läuft der Dialog, bis ein Button gedrĂ¼ckt wird
542 Select Case (gDlgState)
547 call StartTestByOptions ()
550 gOptionsDialog.dispose()
556 SetUserFieldState (cUserFieldTestWriter, -(gOptionsDialog.getControl("cbWriterTest").getState), gOutputDoc)
557 SetUserFieldState (cUserFieldTestCalc, -(gOptionsDialog.getControl("cbCalcTest").getState), gOutputDoc)
558 SetUserFieldState (cUserFieldTestImpress, -(gOptionsDialog.getControl("cbImpressTest").getState), gOutputDoc)
559 SetUserFieldState (cUserFieldTestDraw, -(gOptionsDialog.getControl("cbDrawTest").getState), gOutputDoc)
560 SetUserFieldState (cUserFieldTestHTML, -(gOptionsDialog.getControl("cbHTMLTest").getState), gOutputDoc)
561 SetUserFieldState (cUserFieldTestMath, -(gOptionsDialog.getControl("cbMathTest").getState), gOutputDoc)
562 SetUserFieldState (cUserFieldTestChart, -(gOptionsDialog.getControl("cbChartTest").getState), gOutputDoc)
563 SetUserFieldState (cUserFieldTestJava, -(gOptionsDialog.getControl("cbJavaTest").getState), gOutputDoc)
564 SetUserFieldState (cUserFieldTestDatabase, -(gOptionsDialog.getControl("cbDatabaseTest").getState), gOutputDoc)
565 SetUserFieldState (cUserFieldTestExtension, -(gOptionsDialog.getControl("cbExtensionTest").getState), gOutputDoc)
566 SetUserFieldState (cUserFieldTestOpenSaveXML, -(gOptionsDialog.getControl("cbSaveOpenXMLTest").getState), gOutputDoc)
567 SetUserFieldState (cUserFieldTestOpenSave8, -(gOptionsDialog.getControl("cbSaveOpen8Test").getState), gOutputDoc)
568 SetUserFieldState (cUserFieldTestMacros, -(gOptionsDialog.getControl("cbMacrosTest").getState), gOutputDoc)
569 SetUserFieldState (cUserFieldTestTerminateAfterTest, -(gOptionsDialog.getControl("cbTerminateAfterTest").getState), gOutputDoc)
574 gOptionsDialog.getControl("cbWriterTest").setState( -( GetUserFieldState (cUserFieldTestWriter, gOutputDoc)))
575 gOptionsDialog.getControl("cbCalcTest").setState ( -( GetUserFieldState (cUserFieldTestCalc, gOutputDoc)))
576 gOptionsDialog.getControl("cbImpressTest").setState( -( GetUserFieldState (cUserFieldTestImpress, gOutputDoc)))
577 gOptionsDialog.getControl("cbDrawTest").setState( -( GetUserFieldState (cUserFieldTestDraw, gOutputDoc)))
578 gOptionsDialog.getControl("cbHTMLTest").setState( -( GetUserFieldState (cUserFieldTestHTML, gOutputDoc)))
579 gOptionsDialog.getControl("cbMathTest").setState( -( GetUserFieldState (cUserFieldTestMath, gOutputDoc)))
580 gOptionsDialog.getControl("cbChartTest").setState( -( GetUserFieldState (cUserFieldTestChart, gOutputDoc)))
581 gOptionsDialog.getControl("cbJavaTest").setState( -( GetUserFieldState (cUserFieldTestJava, gOutputDoc)))
582 gOptionsDialog.getControl("cbDatabaseTest").setState( -( GetUserFieldState (cUserFieldTestDatabase, gOutputDoc)))
583 gOptionsDialog.getControl("cbExtensionTest").setState( -( GetUserFieldState (cUserFieldTestExtension, gOutputDoc)))
584 gOptionsDialog.getControl("cbSaveOpenXMLTest").setState( -( GetUserFieldState (cUserFieldTestOpenSaveXML, gOutputDoc)))
585 gOptionsDialog.getControl("cbSaveOpen8Test").setState( -( GetUserFieldState (cUserFieldTestOpenSave8, gOutputDoc)))
586 gOptionsDialog.getControl("cbMacrosTest").setState( -( GetUserFieldState (cUserFieldTestMacros, gOutputDoc)))
587 gOptionsDialog.getControl("cbTerminateAfterTest").setState( -( GetUserFieldState (cUserFieldTestTerminateAfterTest, gOutputDoc)))
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)
608 Sub SetDefaultOptions
609 bMakeWriterTest = true
611 bMakeImpressTest = true
615 bMakeChartTest = true
616 if Environ("SOLAR_JAVA") = "" then
617 bMakeJavaTest = false
619 bMakeExtensionTest = false
623 bMakeExtensionTest = true
625 bMakeSaveOpenXMLTest = true
626 bMakeSaveOpen8Test = true
627 bMakeMacrosTest = true
628 bMakeTerminateAfterTest = false
631 Sub StartTestByOptions
635 if bMakeTerminateAfterTest then
636 ClearDocFull (gOutputDoc)
638 'StarDesktop.Terminate
640 'EnableReschedule( false )
641 'DispatchSlot( 5300 )
646 Function StartTestWithDefaultOptions
648 call SetDefaultOptions
650 dim component(cMaxErrorStates) as string
651 component(cStWriter) = "Writer"
652 component(cStCalc) = "Calc"
653 component(cStPraesentation) = "Impress"
654 component(cStZeichnen) = "Draw"
655 component(cStChart) = "Chart"
656 component(cStMath) = "Math"
657 component(cStHTML) = "HTML"
658 component(cStJava) = "Java"
659 component(cStDataBase) = "Base"
660 component(cStExtension) = "Extensions"
661 dim action(4) as string
662 action(cDocNew) = "new"
663 action(cDocSaveOpen8) = "V8.0"
664 action(cDocSaveOpenXML) = "XML"
665 action(cDocClose) = "close"
666 action(cDocMacros) = "macros"
667 dim baseAction(5) as string
668 baseAction(cDBService) = "services"
669 baseAction(cDBOpen) = "open"
670 baseAction(cDBInsert) = "insert"
671 baseAction(cDBDelete) = "delete"
672 baseAction(cDBSeek) = "seek"
673 baseAction(cDBClose) = "close"
674 dim extAction(2) as string
675 extAction(cEXTService) = "services"
676 extAction(cEXTInstall) = "install"
677 extAction(cEXTUninstall) = "uninstall"
679 for i = 0 to cMaxErrorStates
681 if gErrorState(i, j) = cLogFalse then
682 result = result & " " & component(i) & ":"
683 if i = cStDataBase then
684 result = result & baseAction(j)
685 else if i = cStExtension then
686 result = result & extAction(j)
688 result = result & action(j)
691 if gTestCaseAnnotations(i, j) <> "" then
692 result = result & "(" & _
693 gTestCaseAnnotations(i, j) & ")"
698 StartTestWithDefaultOptions = result
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
707 oTrans = createUNOService("com.sun.star.util.URLTransformer")
708 oUrl.Complete = "slot:" & CStr(SlotID)
709 oTrans.parsestrict(oUrl)
711 oDisp = StarDesktop.queryDispatch(oUrl, "_self", 0)
712 oDisp.dispatch(oUrl, oArg())
715 Sub LoadLibrary( LibName As String )
718 dim arg as new com.sun.star.beans.PropertyValue
719 arg.Name = "LibraryName"
723 dim url as new com.sun.star.util.URL
725 trans = createUnoService("com.sun.star.util.URLTransformer" )
726 url.Complete = "slot:6517"
727 trans.parsestrict( url )
730 disp = StarDesktop.currentFrame.queryDispatch( url, "", 0 )
731 disp.dispatch( url, args() )
735 Sub ExecuteSlot( SlotNr As String, oDoc as Object )
737 dim url as new com.sun.star.util.URL
741 trans = createUnoService("com.sun.star.util.URLTransformer" )
742 url.Complete = "slot:" + SlotNr
743 trans.parsestrict( url )
745 disp = oDoc.CurrentController.Frame.queryDispatch( url, "", 0 )
746 disp.dispatch( url, args() )
750 Sub DelAllUserFields (aDoc as Object)
751 Dim aFieldType as Object
752 Dim aElements as Variant
754 Dim aFieldMasters, aFieldMaster as Object
756 aFieldMasters = aDoc.TextFieldMasters
757 aElements = aFieldMasters.ElementNames
758 for i = 0 to UBound(aElements)
759 sElement$ = aElements(i)
760 if 0 <> instr(sElement$, cUnoUserField ) then
761 aFieldMaster = aFieldMasters.GetByName(sElement$)
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
778 GetUserFieldState = bState
781 Sub SetUserFieldState (sName as String, nState as boolean, aDoc as Object)
782 Dim sFieldText as String
784 sFieldText = cNo 'default
793 WriteUserField (sFieldText, sName, aDoc)
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
802 ReadUserField = ""
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)
812 aUserField = aDoc.CreateInstance (cUnoUserField)
813 aUserField.Name = sFieldName
815 aUserField.Content = sValue
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