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