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 = "TestExtension.oxt" 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'UserFieldKennungen 61Global const cYes = "y", cNo = "n" 62Global const cStateNo = 0, cStateYes = 1 63 64'Feldtypen 65Global const cFtExtUser = 21, cFtPageNum = 5, cFtStatistic = 8, cFtDateTime = 27, cFtDatabase = 31 66 67'UnoStrings 68Global const cUnoSeparator = "." 69Global const cUnoPrefix = "com.sun.star." 70Global const cUnoUserField = cUnoPrefix + "text.FieldMaster.User" 71Global const cUnoExtUserField = cUnoPrefix + "text.TextField.ExtendedUser" 72Global const cUnoMasterDataBase = cUnoPrefix + "text.FieldMaster.Database" 73Global const cUnoDataBase = cUnoPrefix + "text.TextField.Database" 74Global const cUnoDateTime = cUnoPrefix + "text.TextField.DateTime" 75Global const cUnoTextGraphi2 = cUnoPrefix + "text.Graphic" 76Global const cUnoJavaLoader = cUnoPrefix + "loader.Java" 77Global const cUnoDatabaseContext = cUnoPrefix + "sdb.DatabaseContext" 78Global const cUnoRowSet = cUnoPrefix + "sdb.RowSet" 79Global const cUnoSmoketestTestExtension = cUnoPrefix + "comp.smoketest.TestExtension" 80Global const cUnoSmoketestCommandEnvironment = cUnoPrefix + "deployment.test.SmoketestCommandEnvironment" 81Global const cExtensionManager = cUnoPrefix + "deployment.ExtensionManager" 82 83'UserFieldNames 84Global const cUserFieldTestWriter = "Writer", cUserFieldTestCalc = "Calc", cUserFieldTestImpress = "Impress" 85Global const cUserFieldTestDraw = "Draw", cUserFieldTestMath = "Math", cUserFieldTestChart = "Chart" 86Global const cUserFieldTestHTML = "HTML", cUserFieldTestJava = "Java", cUserFieldTestDatabase = "Database" 87Global const cUserFieldTestExtension = "Extension" 88Global const cUserFieldTestOpenSaveXML = "SaveOpenXML" 89Global const cUserFieldTestTerminateAfterTest = "Terminate", cUserFieldTestOpenSave8 = "SaveOpen8" 90 91Global const cOptionsDialogName = "OptionsDlg", cTest10Modul = "Standard" 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( "assertion caught: " + 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) = "windows" 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 ' 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 ' print the 'test complete' marker 189 Print #LocalTestLog%, "---" 190 LocalTestLog% = 0 191 192 gOutputDoc.setModified( bWasModified ) 193 194 CaptureAssertions( "" ) 195 Exit Sub 196 197MainError: 198 If ( gCurrentTestCase = cLogfileFailed ) then 199 LogTestResult( "", False ) 200 Exit Sub 201 else 202 LogTestResult( "testclosure " + 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 = "setup" 212 case cTestClosureWriteStatus 213 GetTestGlueDescription = "write_status" 214 case Else 215 GetTestGlueDescription = "" 216 End Select 217End Function 218 219Sub CreateStatusTable 220 dim tableHeaders(7) as string 221 tableHeaders(cStWriter) = "Writer" 222 tableHeaders(cStCalc) = "Calc" 223 tableHeaders(cStPraesentation) = "Präsen- tation" 224 tableHeaders(cStZeichnen) = "Zeichn." 225 tableHeaders(cStChart) = "Diagr." 226 tableHeaders(cStMath) = "Math" 227 tableHeaders(cStHTML) = "HTML" 228 tableHeaders(cStJava) = "Java" 229 230 dim tableRows(3) as string 231 tableRows(cDocNew) = "new" 232 tableRows(cDocSaveOpen8) = "V8.0" 233 tableRows(cDocSaveOpenXML) = "XML" 234 tableRows(cDocClose) = "close" 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("com.sun.star.text.TextTable") 249 table.initialize(5,9) 250 table.Name = "StTab1" 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) = "Database" 268 tableHeaders(1) = "" 269 tableHeaders(2) = "Extension" 270 tableHeaders(3) = "" 271 tableHeaders(4) = "Other" 272 273 dim tableRows(5) as string 274 tableRows(cDBService ) = "services" 275 tableRows(cDBOpen ) = "open" 276 tableRows(cDBInsert ) = "insert" 277 tableRows(cDBDelete ) = "delete" 278 tableRows(cDBSeek ) = "seek" 279 tableRows(cDBClose ) = "close" 280 281 dim tableRows2(2) as string 282 tableRows2(cEXTService ) = "services" 283 tableRows2(cEXTInstall ) = "install" 284 tableRows2(cEXTUninstall ) = "uninstall" 285 286 dim tableRows3(1) as string 287 tableRows3(cTestClosureSetupDoc ) = "setup test" 288 tableRows3(cTestClosureWriteStatus ) = "write test result" 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("com.sun.star.text.TextTable") 302 table.initialize(7,6) 303 table.Name = "StTab2" 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% ) <> "" ) Then 351 Dim annotation as Object 352 annotation = aDoc.createInstance( "com.sun.star.text.TextField.Annotation" ) 353 annotation.Author = "smoketest" 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 ) <> "" ) Then 386 Dim annotation as Object 387 annotation = aDoc.createInstance( "com.sun.star.text.TextField.Annotation" ) 388 annotation.Author = "smoketest" 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 = "creating logfile '" + GetLogFileName( gCurrentDocTest ) + "' failed" 408 LogState( FALSE, sAnnotation, GlobalTestLog ) 409 RecordTestCaseStatus( 0, FALSE, sAnnotation ) 410 Else 411 bSuccess = RecordTestCaseStatus( gCurrentTestCase, bSuccess, sTestCaseDescription ) 412 If ( LocalTestLog <> 0 ) Then 413 LogState( bSuccess, sTestCaseDescription, LocalTestLog ) 414 EndIf 415 if ( GlobalTestLog <> 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 ' don't overwrite a previous "failed" 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 <> "" ) 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 ' text document 451 case frmCalc 452 GetStatusType = cStCalc ' spreadsheet document 453 case frmImpress 454 GetStatusType = cStPraesentation ' presentation 455 case frmDraw 456 GetStatusType = cStZeichnen ' drawing 457 case frmMath 458 GetStatusType = cStMath ' formula 459 case frmHyperText 460 GetStatusType = cStHTML ' HTML document 461 case frmChart 462 GetStatusType = cStChart ' chart 463 case frmJava 464 GetStatusType = cStJava 'Java 465 case frmTestClosure 466 GetStatusType = cStTestGlue ' test framework 467 case frmDataBase 468 GetStatusType = cStDataBase 'DataBase 469 case frmExtension 470 GetStatusType = cStExtension '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="" 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="" 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 ' 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("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 (cUserFieldTestTerminateAfterTest, -(gOptionsDialog.getControl("cbTerminateAfterTest").getState), gOutputDoc) 569end Sub 570 571Sub GetOptions 572 call SetGlobalDoc 573 gOptionsDialog.getControl("cbWriterTest").setState( -( GetUserFieldState (cUserFieldTestWriter, gOutputDoc))) 574 gOptionsDialog.getControl("cbCalcTest").setState ( -( GetUserFieldState (cUserFieldTestCalc, gOutputDoc))) 575 gOptionsDialog.getControl("cbImpressTest").setState( -( GetUserFieldState (cUserFieldTestImpress, gOutputDoc))) 576 gOptionsDialog.getControl("cbDrawTest").setState( -( GetUserFieldState (cUserFieldTestDraw, gOutputDoc))) 577 gOptionsDialog.getControl("cbHTMLTest").setState( -( GetUserFieldState (cUserFieldTestHTML, gOutputDoc))) 578 gOptionsDialog.getControl("cbMathTest").setState( -( GetUserFieldState (cUserFieldTestMath, gOutputDoc))) 579 gOptionsDialog.getControl("cbChartTest").setState( -( GetUserFieldState (cUserFieldTestChart, gOutputDoc))) 580 gOptionsDialog.getControl("cbJavaTest").setState( -( GetUserFieldState (cUserFieldTestJava, gOutputDoc))) 581 gOptionsDialog.getControl("cbDatabaseTest").setState( -( GetUserFieldState (cUserFieldTestDatabase, gOutputDoc))) 582 gOptionsDialog.getControl("cbExtensionTest").setState( -( GetUserFieldState (cUserFieldTestExtension, gOutputDoc))) 583 gOptionsDialog.getControl("cbSaveOpenXMLTest").setState( -( GetUserFieldState (cUserFieldTestOpenSaveXML, gOutputDoc))) 584 gOptionsDialog.getControl("cbSaveOpen8Test").setState( -( GetUserFieldState (cUserFieldTestOpenSave8, gOutputDoc))) 585 gOptionsDialog.getControl("cbTerminateAfterTest").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("SOLAR_JAVA") = "" 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 'StarDesktop.Terminate 636 637 'EnableReschedule( false ) 638 '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) = "Writer" 649 component(cStCalc) = "Calc" 650 component(cStPraesentation) = "Impress" 651 component(cStZeichnen) = "Draw" 652 component(cStChart) = "Chart" 653 component(cStMath) = "Math" 654 component(cStHTML) = "HTML" 655 component(cStJava) = "Java" 656 component(cStDataBase) = "Base" 657 component(cStExtension) = "Extensions" 658 dim action(3) as string 659 action(cDocNew) = "new" 660 action(cDocSaveOpen8) = "V8.0" 661 action(cDocSaveOpenXML) = "XML" 662 action(cDocClose) = "close" 663 dim baseAction(5) as string 664 baseAction(cDBService) = "services" 665 baseAction(cDBOpen) = "open" 666 baseAction(cDBInsert) = "insert" 667 baseAction(cDBDelete) = "delete" 668 baseAction(cDBSeek) = "seek" 669 baseAction(cDBClose) = "close" 670 dim extAction(2) as string 671 extAction(cEXTService) = "services" 672 extAction(cEXTInstall) = "install" 673 extAction(cEXTUninstall) = "uninstall" 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 & " " & component(i) & ":" 679 if i = cStDataBase then 680 result = result & baseAction(j) 681 else if i = cStExtension then 682 result = result & extAction(j) 683 else 684 result = result & 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("com.sun.star.util.URLTransformer") 700 oUrl.Complete = "slot:" & CStr(SlotID) 701 oTrans.parsestrict(oUrl) 702 703 oDisp = StarDesktop.queryDispatch(oUrl, "_self", 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 = "LibraryName" 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("com.sun.star.util.URLTransformer" ) 718 url.Complete = "slot:6517" 719 trans.parsestrict( url ) 720 721 dim disp as object 722 disp = StarDesktop.currentFrame.queryDispatch( url, "", 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("com.sun.star.util.URLTransformer" ) 734 url.Complete = "slot:" + SlotNr 735 trans.parsestrict( url ) 736 737 disp = oDoc.CurrentController.Frame.queryDispatch( url, "", 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 <> 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 '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 = "" 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