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, 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 cUserFieldTestTerminateAfterTest = "Terminate", cUserFieldTestOpenSave8 = "SaveOpen8", cUserFieldTestMacros = "Macros"
85 Global const cOptionsDialogName = "OptionsDlg", cTest10Modul = "Standard"
87 Global const cDlgCancel = 1, cDlgOk = 0, cDlgStartTest = 2
89 global gErrorState (cMaxErrorStates, 5) as integer
90 Global gTestCaseAnnotations( cMaxErrorStates, 5 ) As String
92 global gOutputDoc as Object
93 global gOutputDocNotUno as Object
94 global gOptionsDialog as Object
96 Global bMakeWriterTest as boolean, bMakeCalcTest as boolean, bMakeImpressTest as boolean
97 Global bMakeDrawTest as Boolean, bMakeMathTest as boolean, bMakeChartTest as boolean
98 Global bMakeHTMLTest as boolean, bMakeJavaTest as boolean, bMakeDBTest as boolean
99 Global bMakeExtensionTest as boolean
100 Global bMakeTerminateAfterTest as boolean, bShowTable as boolean
101 Global bMakeSaveOpen8Test as boolean, bMakeMacrosTest as boolean
103 global sExtensionURL as string
105 Dim gDlgState as Integer
108 gOutputDoc = ThisComponent
112 for j% = 0 to cMaxErrorStates
114 gErrorState (j%, i%) = cLogUnknown
115 gTestCaseAnnotations( J%, i% ) = ""
122 call ClearDoc (gOutputDoc)
127 On Local Error Goto MainError
129 gCurrentDocTest = frmTestClosure
130 gCurrentTestCase = cLogfileFailed
132 DeleteAllSavedFiles()
136 if GetSystem (sWorkPath) = "windows" then
137 sWorkPath = ConvertPathToWin (sWorkPath)
140 LocalTestLog% = OpenLogDat( GetLogFileName( gCurrentDocTest ) )
142 gCurrentTestCase = cTestClosureSetupDoc
146 Dim bWasModified as Boolean
147 bWasModified = gOutputDoc.isModified()
150 call ClearDoc (gOutputDoc)
155 LogTestResult( GetTestGlueDescription( gCurrentTestCase ), TRUE )
157 Dim nPreserveFileHandle%
158 nPreserveFileHandle% = LocalTestLog%
160 LocalTestLog% = nPreserveFileHandle%
162 gCurrentDocTest = frmTestClosure
163 gCurrentTestCase = cTestClosureWriteStatus
165 call CreateStatusTable2
166 call CreateStatusTable
168 LogTestResult( GetTestGlueDescription( gCurrentTestCase ), TRUE )
169 ' do this LogTestResult call before CreateSecondState, since the latter accesses (and displays) the result
170 call CreateSecondState
171 gOutputDoc.CurrentController.ViewCursor.JumpToFirstPage
173 LogTestResult( GetTestGlueDescription( gCurrentTestCase ), TRUE )
176 ' print the 'test complete' marker
177 Print #LocalTestLog%, "---"
180 gOutputDoc.setModified( bWasModified )
185 If ( gCurrentTestCase = cLogfileFailed ) then
186 LogTestResult( "", False )
189 LogTestResult( "testclosure " + GetTestGlueDescription( gCurrentTestCase ), FALSE )
195 Function GetTestGlueDescription( nTestCase as Integer )
196 Select Case ( nTestCase )
197 case cTestClosureSetupDoc
198 GetTestGlueDescription = "setup"
199 case cTestClosureWriteStatus
200 GetTestGlueDescription = "write_status"
202 GetTestGlueDescription = ""
206 Sub CreateStatusTable
207 dim tableHeaders(7) as string
208 tableHeaders(cStWriter) = "Writer"
209 tableHeaders(cStCalc) = "Calc"
210 tableHeaders(cStPraesentation) = "Präsen- tation"
211 tableHeaders(cStZeichnen) = "Zeichn."
212 tableHeaders(cStChart) = "Diagr."
213 tableHeaders(cStMath) = "Math"
214 tableHeaders(cStHTML) = "HTML"
215 tableHeaders(cStJava) = "Java"
217 dim tableRows(4) as string
218 tableRows(cDocNew) = "new"
219 tableRows(cDocSaveOpen8) = "V8.0"
220 tableRows(cDocClose) = "close"
221 tableRows(cDocMacros) = "macros"
226 xCursor = xText.createTextCursor()
228 xCursor.gotoStart(FALSE)
229 xCursor.GoRight (4, False)
230 SetParagraphBreak (xCursor)
231 xCursor.GoRight (1, False)
232 SetParagraphBreak (xCursor)
233 xCursor.GoRight (1, False)
235 table = aDoc.createInstance("com.sun.star.text.TextTable")
236 table.initialize(7,9)
237 table.Name = "StTab1"
238 table.BackColor = cCoGrey
239 xText.insertTextContent(xCursor, table, FALSE)
242 tableCell = table.getCellByPosition( i% + 1, 0 )
243 tableCell.String = tableHeaders( i% )
246 for i% = LBound( tableRows ) to UBound( tableRows )
247 tableCell = table.getCellByPosition( 0, i% + 1 )
248 tableCell.String=tableRows(i%)
252 Sub CreateStatusTable2
253 dim tableHeaders(4) as string
254 tableHeaders(0) = "Database"
255 tableHeaders(1) = ""
256 tableHeaders(2) = "Extension"
257 tableHeaders(3) = ""
258 tableHeaders(4) = "Other"
260 dim tableRows(5) as string
261 tableRows(cDBService ) = "services"
262 tableRows(cDBOpen ) = "open"
263 tableRows(cDBInsert ) = "insert"
264 tableRows(cDBDelete ) = "delete"
265 tableRows(cDBSeek ) = "seek"
266 tableRows(cDBClose ) = "close"
268 dim tableRows2(2) as string
269 tableRows2(cEXTService ) = "services"
270 tableRows2(cEXTInstall ) = "install"
271 tableRows2(cEXTUninstall ) = "uninstall"
273 dim tableRows3(1) as string
274 tableRows3(cTestClosureSetupDoc ) = "setup test"
275 tableRows3(cTestClosureWriteStatus ) = "write test result"
280 xCursor = xText.createTextCursor()
282 xCursor.gotoStart(FALSE)
283 xCursor.GoRight (4, False)
284 SetParagraphBreak (xCursor)
285 SetParagraphBreak (xCursor)
286 xCursor.gotoEnd(FALSE)
288 table = aDoc.createInstance("com.sun.star.text.TextTable")
289 table.initialize(7,6)
290 table.Name = "StTab2"
291 table.BackColor = cCoGrey
293 xText.insertTextContent(xCursor, table, FALSE)
295 for i% = LBound( tableHeaders ) to UBound( tableHeaders )
296 tableCell = table.getCellByPosition( i% + 1, 0 )
297 tableCell.String = tableHeaders(i%)
300 for i% = LBound( tableRows ) to UBound( tableRows )
301 tableCell = table.getCellByPosition( 0, i% + 1 )
302 tableCell.String=tableRows(i%)
305 for i% = LBound( tableRows2 ) to UBound( tableRows2 )
306 tableCell = table.getCellByPosition( 2, i% + 1 )
307 tableCell.String=tableRows2(i%)
310 for i% = LBound( tableRows3 ) to UBound( tableRows3 )
311 tableCell = table.getCellByPosition( 4, i% + 1 )
312 tableCell.String=tableRows3(i%)
319 table = aDoc.TextTables.GetByIndex (1)
323 sRangeName = GetRangeName(j%, i%+1)
325 tableCursor = table.createCursorByCellName(sRangeName)
327 cName = tableCursor.getRangeName()
328 xCell = table.getCellByName(cName)
330 xCell.BackTransparent = False
332 If gErrorState (j%, i%) = cLogTrue Then
333 xCell.BackColor = cCoGreen
335 If gErrorState (j%, i%) = cLogFalse Then
336 xCell.BackColor = cCoRed
337 If ( gTestCaseAnnotations( j%, i% ) <> "" ) Then
338 Dim annotation as Object
339 annotation = aDoc.createInstance( "com.sun.star.text.TextField.Annotation" )
340 annotation.Author = "smoketest"
341 annotation.Content = gTestCaseAnnotations( j%, i% )
342 xCell.insertTextContent( xCell, annotation, false )
345 xCell.BackColor = cCoGrey
352 Sub CreateSecondState
354 table = aDoc.TextTables.GetByIndex (0)
356 Dim stateIndex(2) as Integer
357 stateIndex(0) = cStDataBase
358 stateIndex(1) = cStExtension
359 stateIndex(2) = cStTestGlue
362 For j = LBound( stateIndex ) To UBound( stateIndex )
364 tableCell = table.getCellByPosition( 2 * j + 1, i% )
365 tableCell.BackTransparent = False
367 if gErrorState( stateIndex(j), i% - 1 ) = cLogTrue then
368 tableCell.BackColor = cCoGreen
370 if gErrorState ( stateIndex(j), i% - 1 ) = cLogFalse then
371 tableCell.BackColor = cCoRed
372 If ( gTestCaseAnnotations( stateIndex(j), i% - 1 ) <> "" ) Then
373 Dim annotation as Object
374 annotation = aDoc.createInstance( "com.sun.star.text.TextField.Annotation" )
375 annotation.Author = "smoketest"
376 annotation.Content = gTestCaseAnnotations( stateIndex(j), i% - 1 )
377 tableCell.insertTextContent( tableCell, annotation, false )
380 tableCell.BackColor = cCoGrey
387 Function GetRangeName (nColumn as integer, nRow as integer) as string
388 GetRangeName = chr (nColumn+66) + Trim(Str(nRow+1))
391 Sub LogTestResult( sTestCaseDescription as String, bSuccess as Boolean )
392 If ( gCurrentTestCase = cLogfileFailed ) Then
393 Dim sAnnotation as String
394 sAnnotation = "creating logfile '" + GetLogFileName( gCurrentDocTest ) + "' failed"
395 LogState( FALSE, sAnnotation, GlobalTestLog )
396 RecordTestCaseStatus( 0, FALSE, sAnnotation )
398 bSuccess = RecordTestCaseStatus( gCurrentTestCase, bSuccess, sTestCaseDescription )
399 If ( LocalTestLog <> 0 ) Then
400 LogState( bSuccess, sTestCaseDescription, LocalTestLog )
402 if ( GlobalTestLog <> 0 ) Then
403 LogState( bSuccess, sTestCaseDescription, GlobalTestLog )
408 Function RecordTestCaseStatus( nAction as Integer, bState as Boolean, sFailureAnnotation as String ) as Boolean
409 Dim nStatusType as Integer
410 Dim nState as integer
411 nStatusType = GetStatusType( gCurrentDocTest )
412 If nStatusType = cStNone then Exit Function
414 If ( gErrorState( nStatusType, nAction ) = cLogFalse ) Then
415 ' don't overwrite a previous "failed" state for this test
425 gErrorState (nStatusType, nAction) = nState
427 If ( nState = cLogFalse ) And ( sFailureAnnotation <> "" ) Then
428 if gTestCaseAnnotations(nStatusType, nAction) <> "" then
429 gTestCaseAnnotations(nStatusType, nAction) = _
430 gTestCaseAnnotations(nStatusType, nAction) & "; "
432 gTestCaseAnnotations( nStatusType, nAction ) = gTestCaseAnnotations( nStatusType, nAction ) + sFailureAnnotation
435 RecordTestCaseStatus = bState
438 Function GetStatusType (nDocType as Integer) as Integer
439 Select Case ( nDocType )
441 GetStatusType = cStWriter ' text document
443 GetStatusType = cStCalc ' spreadsheet document
445 GetStatusType = cStPraesentation ' presentation
447 GetStatusType = cStZeichnen ' drawing
449 GetStatusType = cStMath ' formula
451 GetStatusType = cStHTML ' HTML document
453 GetStatusType = cStChart ' chart
455 GetStatusType = cStJava 'Java
457 GetStatusType = cStTestGlue ' test framework
459 GetStatusType = cStDataBase 'DataBase
461 GetStatusType = cStExtension 'Extension
463 GetStatusType = cStNone
467 Sub SetParagraphBreak (aCursor as Object)
468 aCursor.Text.InsertControlCharacter (aCursor, cParagraphBreak, True)
471 Sub ClearDoc (aDoc as Object)
474 for i%=1 to aDoc.TextTables.count
475 aDoc.TextTables.GetByIndex(0).dispose
478 aText = aDoc.Text.CreateTextCursor
479 aText.GotoStart (False)
480 aText.GoRight (3, False)
481 SetParagraphBreak (aText)
483 aText.String=""
486 Sub ClearDocFull (aDoc as Object)
489 for i%=1 to aDoc.TextTables.count
490 aDoc.TextTables.GetByIndex(0).dispose
493 aText = aDoc.Text.CreateTextCursor
494 aText.GotoStart (False)
496 aText.String=""
499 Sub SetGlobalOptionsDialog ()
501 Dim oLibContainer As Object, oLib As Object
502 Dim oInputStreamProvider As Object
503 Dim oDialog As Object
505 Const sLibName = cTest10Modul
506 Const sDialogName = cOptionsDialogName
508 REM get library and input stream provider
509 oLibContainer = DialogLibraries
512 oLibContainer.loadLibrary( sLibName )
514 oLib = oLibContainer.getByName( sLibName )
515 oInputStreamProvider = oLib.getByName( sDialogName )
517 REM create dialog control
518 gOptionsDialog = CreateUnoDialog( oInputStreamProvider )
525 call SetGlobalOptionsDialog
529 gOptionsDialog.execute()
531 ' now the dialog will run until a button is pressed
533 Select Case (gDlgState)
538 call StartTestByOptions ()
541 gOptionsDialog.dispose()
547 SetUserFieldState (cUserFieldTestWriter, -(gOptionsDialog.getControl("cbWriterTest").getState), gOutputDoc)
548 SetUserFieldState (cUserFieldTestCalc, -(gOptionsDialog.getControl("cbCalcTest").getState), gOutputDoc)
549 SetUserFieldState (cUserFieldTestImpress, -(gOptionsDialog.getControl("cbImpressTest").getState), gOutputDoc)
550 SetUserFieldState (cUserFieldTestDraw, -(gOptionsDialog.getControl("cbDrawTest").getState), gOutputDoc)
551 SetUserFieldState (cUserFieldTestHTML, -(gOptionsDialog.getControl("cbHTMLTest").getState), gOutputDoc)
552 SetUserFieldState (cUserFieldTestMath, -(gOptionsDialog.getControl("cbMathTest").getState), gOutputDoc)
553 SetUserFieldState (cUserFieldTestChart, -(gOptionsDialog.getControl("cbChartTest").getState), gOutputDoc)
554 SetUserFieldState (cUserFieldTestJava, -(gOptionsDialog.getControl("cbJavaTest").getState), gOutputDoc)
555 SetUserFieldState (cUserFieldTestDatabase, -(gOptionsDialog.getControl("cbDatabaseTest").getState), gOutputDoc)
556 SetUserFieldState (cUserFieldTestExtension, -(gOptionsDialog.getControl("cbExtensionTest").getState), gOutputDoc)
557 SetUserFieldState (cUserFieldTestOpenSave8, -(gOptionsDialog.getControl("cbSaveOpen8Test").getState), gOutputDoc)
558 SetUserFieldState (cUserFieldTestMacros, -(gOptionsDialog.getControl("cbMacrosTest").getState), gOutputDoc)
559 SetUserFieldState (cUserFieldTestTerminateAfterTest, -(gOptionsDialog.getControl("cbTerminateAfterTest").getState), gOutputDoc)
564 gOptionsDialog.getControl("cbWriterTest").setState( -( GetUserFieldState (cUserFieldTestWriter, gOutputDoc)))
565 gOptionsDialog.getControl("cbCalcTest").setState ( -( GetUserFieldState (cUserFieldTestCalc, gOutputDoc)))
566 gOptionsDialog.getControl("cbImpressTest").setState( -( GetUserFieldState (cUserFieldTestImpress, gOutputDoc)))
567 gOptionsDialog.getControl("cbDrawTest").setState( -( GetUserFieldState (cUserFieldTestDraw, gOutputDoc)))
568 gOptionsDialog.getControl("cbHTMLTest").setState( -( GetUserFieldState (cUserFieldTestHTML, gOutputDoc)))
569 gOptionsDialog.getControl("cbMathTest").setState( -( GetUserFieldState (cUserFieldTestMath, gOutputDoc)))
570 gOptionsDialog.getControl("cbChartTest").setState( -( GetUserFieldState (cUserFieldTestChart, gOutputDoc)))
571 gOptionsDialog.getControl("cbJavaTest").setState( -( GetUserFieldState (cUserFieldTestJava, gOutputDoc)))
572 gOptionsDialog.getControl("cbDatabaseTest").setState( -( GetUserFieldState (cUserFieldTestDatabase, gOutputDoc)))
573 gOptionsDialog.getControl("cbExtensionTest").setState( -( GetUserFieldState (cUserFieldTestExtension, gOutputDoc)))
574 gOptionsDialog.getControl("cbSaveOpen8Test").setState( -( GetUserFieldState (cUserFieldTestOpenSave8, gOutputDoc)))
575 gOptionsDialog.getControl("cbMacrosTest").setState( -( GetUserFieldState (cUserFieldTestMacros, gOutputDoc)))
576 gOptionsDialog.getControl("cbTerminateAfterTest").setState( -( GetUserFieldState (cUserFieldTestTerminateAfterTest, gOutputDoc)))
581 bMakeWriterTest = GetUserFieldState (cUserFieldTestWriter, gOutputDoc)
582 bMakeCalcTest = GetUserFieldState (cUserFieldTestCalc, gOutputDoc)
583 bMakeImpressTest = GetUserFieldState (cUserFieldTestImpress, gOutputDoc)
584 bMakeDrawTest = GetUserFieldState (cUserFieldTestDraw, gOutputDoc)
585 bMakeHTMLTest = GetUserFieldState (cUserFieldTestHTML, gOutputDoc)
586 bMakeMathTest = GetUserFieldState (cUserFieldTestMath, gOutputDoc)
587 bMakeChartTest = GetUserFieldState (cUserFieldTestChart, gOutputDoc)
588 bMakeJavaTest = GetUserFieldState (cUserFieldTestJava, gOutputDoc)
589 bMakeDBTest = GetUserFieldState (cUserFieldTestDatabase, gOutputDoc)
590 bMakeExtensionTest = GetUserFieldState (cUserFieldTestExtension, gOutputDoc)
591 bMakeSaveOpen8Test = GetUserFieldState (cUserFieldTestOpenSave8, gOutputDoc)
592 bMakeMacrosTest = GetUserFieldState (cUserFieldTestMacros, gOutputDoc)
593 bMakeTerminateAfterTest = GetUserFieldState (cUserFieldTestTerminateAfterTest, gOutputDoc)
596 Sub SetDefaultOptions
597 bMakeWriterTest = true
599 bMakeImpressTest = true
603 bMakeChartTest = true
604 if Environ("ENABLE_JAVA") = "" then
605 bMakeJavaTest = false
607 bMakeExtensionTest = false
611 bMakeExtensionTest = true
613 bMakeSaveOpen8Test = true
614 bMakeMacrosTest = true
615 bMakeTerminateAfterTest = false
618 Sub StartTestByOptions
622 if bMakeTerminateAfterTest then
623 ClearDocFull (gOutputDoc)
625 'StarDesktop.Terminate
627 'EnableReschedule( false )
628 'DispatchSlot( 5300 )
633 Function StartTestWithDefaultOptions
635 call SetDefaultOptions
637 dim component(cMaxErrorStates) as string
638 component(cStWriter) = "Writer"
639 component(cStCalc) = "Calc"
640 component(cStPraesentation) = "Impress"
641 component(cStZeichnen) = "Draw"
642 component(cStChart) = "Chart"
643 component(cStMath) = "Math"
644 component(cStHTML) = "HTML"
645 component(cStJava) = "Java"
646 component(cStDataBase) = "Base"
647 component(cStExtension) = "Extensions"
648 dim action(4) as string
649 action(cDocNew) = "new"
650 action(cDocSaveOpen8) = "V8.0"
651 action(cDocClose) = "close"
652 action(cDocMacros) = "macros"
653 dim baseAction(5) as string
654 baseAction(cDBService) = "services"
655 baseAction(cDBOpen) = "open"
656 baseAction(cDBInsert) = "insert"
657 baseAction(cDBDelete) = "delete"
658 baseAction(cDBSeek) = "seek"
659 baseAction(cDBClose) = "close"
660 dim extAction(2) as string
661 extAction(cEXTService) = "services"
662 extAction(cEXTInstall) = "install"
663 extAction(cEXTUninstall) = "uninstall"
665 for i = 0 to cMaxErrorStates
667 if gErrorState(i, j) = cLogFalse then
668 result = result & " " & component(i) & ":"
669 if i = cStDataBase then
670 result = result & baseAction(j)
671 else if i = cStExtension then
672 result = result & extAction(j)
674 result = result & action(j)
677 if gTestCaseAnnotations(i, j) <> "" then
678 result = result & "(" & _
679 gTestCaseAnnotations(i, j) & ")"
684 StartTestWithDefaultOptions = result
687 Sub DispatchSlot(SlotID as Integer)
688 Dim oArg() as new com.sun.star.beans.PropertyValue
689 Dim oUrl as new com.sun.star.util.URL
693 oTrans = createUNOService("com.sun.star.util.URLTransformer")
694 oUrl.Complete = "slot:" & CStr(SlotID)
695 oTrans.parsestrict(oUrl)
697 oDisp = StarDesktop.queryDispatch(oUrl, "_self", 0)
698 oDisp.dispatch(oUrl, oArg())
701 Sub LoadLibrary( LibName As String )
704 dim arg as new com.sun.star.beans.PropertyValue
705 arg.Name = "LibraryName"
709 dim url as new com.sun.star.util.URL
711 trans = createUnoService("com.sun.star.util.URLTransformer" )
712 url.Complete = "slot:6517"
713 trans.parsestrict( url )
716 disp = StarDesktop.currentFrame.queryDispatch( url, "", 0 )
717 disp.dispatch( url, args() )
721 Sub ExecuteSlot( SlotNr As String, oDoc as Object )
723 dim url as new com.sun.star.util.URL
727 trans = createUnoService("com.sun.star.util.URLTransformer" )
728 url.Complete = "slot:" + SlotNr
729 trans.parsestrict( url )
731 disp = oDoc.CurrentController.Frame.queryDispatch( url, "", 0 )
732 disp.dispatch( url, args() )
736 Sub DelAllUserFields (aDoc as Object)
737 Dim aFieldType as Object
738 Dim aElements as Variant
740 Dim aFieldMasters, aFieldMaster as Object
742 aFieldMasters = aDoc.TextFieldMasters
743 aElements = aFieldMasters.ElementNames
744 for i = 0 to UBound(aElements)
745 sElement$ = aElements(i)
746 if 0 <> instr(sElement$, cUnoUserField ) then
747 aFieldMaster = aFieldMasters.GetByName(sElement$)
753 Function GetUserFieldState (sName as String, aDoc as Object) as boolean
754 Dim sFieldText as String
755 Dim bState as boolean
756 sFieldText = ReadUserField (sName, aDoc)
758 if LCase(sFieldText) = cYes then
764 GetUserFieldState = bState
767 Sub SetUserFieldState (sName as String, nState as boolean, aDoc as Object)
768 Dim sFieldText as String
770 sFieldText = cNo 'default
779 WriteUserField (sFieldText, sName, aDoc)
782 Function ReadUserField(sFieldName as String, aDoc as Object) as String
783 Dim aMasters as Object
784 aMasters = aDoc.TextFieldMasters
785 if aMasters.HasByName (cUnoUserField+cUnoSeparator+sFieldName) then
786 ReadUserField = aMasters.GetByName (cUnoUserField+cUnoSeparator+sFieldName).Content
788 ReadUserField = ""
792 Sub WriteUserField(sValue as String, sFieldName as String, aDoc as Object, optional aCursor as Object)
793 Dim aMasters, aUserField, aTxtCursor as Object
794 aMasters = aDoc.TextFieldMasters
795 if aMasters.HasByName (cUnoUserField+cUnoSeparator+sFieldName) then
796 aUserField = aMasters.GetByName (cUnoUserField+cUnoSeparator+sFieldName)
798 aUserField = aDoc.CreateInstance (cUnoUserField)
799 aUserField.Name = sFieldName
801 aUserField.Content = sValue
804 Sub WriteExtUserField(nIndex as Integer, aCursor as Object, aDoc as Object)
805 Dim aUserField as Object
806 aUserField = aDoc.CreateInstance (cUnoExtUserField)
807 aUserField.UserDataType = nIndex
808 aCursor.Text.InsertTextContent (aCursor, aUserField, True)
809 aUserField.Fix = True