Update ooo320-m1
[ooovba.git] / smoketestoo_native / data / scripts / Global.xba
blobc56b444cf03094cea4abd6937bfb7c44c7b450de
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3 <script:module xmlns:script="http://openoffice.org/2000/script" script:name="Global" script:language="StarBasic">REM ***** BASIC *****
5 const cMaxErrorStates = 13
7 const cCoGreen = 4057917, cCoRed = 16711680, cCoGrey = 12632256
8 const cParagraphBreak = 0
10 global const cExtensionFileName = &quot;TestExtension.oxt&quot;
12 global const cDocNew = 0, cDocCut = 1, cDocPaste = 2, cDocSaveOpen8 = 3, cDocSaveOpenXML = 4, cDocSaveOpen50 = 5, cDocClose = 6, cDocWrite = 7
13 global const cNewsInit = 0, cNewsSend = 1, cNewsRead = 2
14 global const cDBService = 0, cDBOpen = 1, cDBInsert = 2, cDBDelete = 3, cDBSeek = 4, cDBClose = 5
15 global const cEXTService = 0, cEXTInstall = 1, cEXTUninstall = 2
16 global const cScheduleDateRead = 0
17 global const cLogfileFailed = 255
19 global const cStWriter = 0, cStCalc = 1, cStPraesentation = 2, cStZeichnen = 3
20 global const cStMessage = 12, cStHTML = 6, cStChart = 4, cStJava = 7
21 global const cStMath = 5, cStNews = 10, cStSchedule = 8, cStDataBase = 9
22 global const cStExtension = 11
23 global const cStNone = -1
25 global const cFlt8 = 0, cFlt50 = 32, cFltNewDoc = 64, cFltXML = 128
27 global const frmWriter = 1, frmCalc = 2, frmMessage = 3, frmImpress = 4
28 global const frmMath = 5, frmImage = 6, frmChart = 7, frmHyperText = 8, frmDraw = 9
29 global const frmDataBase = 10, frmSchedule = 11, frmNews = 12, frmJava = 13
30 global const frmExtension = 14
32 global const cLogUnknown = 0, cLogFalse = 1, cLogTrue = 2
34 &apos;UserFieldKennungen
35 Global const cYes = &quot;y&quot;, cNo = &quot;n&quot;
36 Global const cStateNo = 0, cStateYes = 1
38 &apos;Feldtypen
39 Global const cFtExtUser = 21, cFtPageNum = 5, cFtStatistic = 8, cFtDateTime = 27, cFtDatabase = 31
41 &apos;UnoStrings
42 Global const cUnoSeparator = &quot;.&quot;
43 Global const cUnoPrefix = &quot;com.sun.star.&quot;
44 Global const cUnoUserField = cUnoPrefix + &quot;text.FieldMaster.User&quot;
45 Global const cUnoExtUserField = cUnoPrefix + &quot;text.TextField.ExtendedUser&quot;
46 Global const cUnoMasterDataBase = cUnoPrefix + &quot;text.FieldMaster.Database&quot;
47 Global const cUnoDataBase = cUnoPrefix + &quot;text.TextField.Database&quot;
48 Global const cUnoDateTime = cUnoPrefix + &quot;text.TextField.DateTime&quot;
49 Global const cUnoTextGraphi2 = cUnoPrefix + &quot;text.Graphic&quot;
50 Global const cUnoJavaLoader = cUnoPrefix + &quot;loader.Java&quot;
51 Global const cUnoDatabaseContext = cUnoPrefix + &quot;sdb.DatabaseContext&quot;
52 Global const cUnoRowSet = cUnoPrefix + &quot;sdb.RowSet&quot;
53 Global const cUnoSmoketestTestExtension = cUnoPrefix + &quot;comp.smoketest.TestExtension&quot;
54 Global const cUnoSmoketestCommandEnvironment = cUnoPrefix + &quot;deployment.test.SmoketestCommandEnvironment&quot;
55 Global const cUnothePackageManagerFactory = cUnoPrefix + &quot;deployment.thePackageManagerFactory&quot;
57 &apos;UserFieldNames
58 Global const cUserFieldTestWriter = &quot;Writer&quot;, cUserFieldTestCalc = &quot;Calc&quot;, cUserFieldTestImpress = &quot;Impress&quot;
59 Global const cUserFieldTestDraw = &quot;Draw&quot;, cUserFieldTestMath = &quot;Math&quot;, cUserFieldTestChart = &quot;Chart&quot;
60 Global const cUserFieldTestHTML = &quot;HTML&quot;, cUserFieldTestJava = &quot;Java&quot;, cUserFieldTestDatabase = &quot;Database&quot;
61 Global const cUserFieldTestExtension = &quot;Extension&quot;
62 Global const cUserFieldTestOpenSaveXML = &quot;SaveOpenXML&quot;, cUserFieldTestOpenSave50 = &quot;SaveOpen50&quot;, cUserFieldTestCut = &quot;Cut&quot;
63 Global const cUserFieldTestPaste = &quot;Paste&quot;, cUserFieldTestTerminateAfterTest = &quot;Terminate&quot;, cUserFieldTestOpenSave8 = &quot;SaveOpen8&quot;
65 Global const cOptionsDialogName = &quot;OptionsDlg&quot;, cTest10Modul = &quot;Standard&quot;
67 Global const cDlgCancel = 1, cDlgOk = 0, cDlgStartTest = 2
69 global gErrorState (cMaxErrorStates, 5) as integer
71 global gOutputDoc as Object
72 global gOutputDocNotUno as Object
73 global gOptionsDialog as Object
74 Dim bMakeMailAccount as Boolean, bTestMail as Boolean, bTestDocs as Boolean
75 Dim bTestSchedule as Boolean, bTestAdr as Boolean
77 Global bMakeWriterTest as boolean, bMakeCalcTest as boolean, bMakeImpressTest as boolean
78 Global bMakeDrawTest as Boolean, bMakeMathTest as boolean, bMakeChartTest as boolean
79 Global bMakeHTMLTest as boolean, bMakeJavaTest as boolean, bMakeDBTest as boolean
80 Global bMakeExtensionTest as boolean
81 Global bMakeSaveOpenXMLTest as boolean, bMakeSaveOpen50Test as boolean, bMakeCutTest as boolean
82 Global bMakePasteTest as boolean, bMakeTerminateAfterTest as boolean, bShowTable as boolean
83 Global bMakeSaveOpen8Test as boolean
85 global sExtensionURL as string
87 Dim gDlgState as Integer
89 Sub SetGlobalDoc
90 gOutPutDoc = StarDesktop.CurrentComponent
91 end Sub
93 Sub ClearStatus
94 for j% = 0 to cMaxErrorStates
95 for i% = 0 to 5
96 gErrorState (j%, i%) = cLogUnknown
97 next i%
98 next j%
99 end Sub
101 Sub ClearAllText
102 call SetGlobalDoc
103 call ClearDoc (gOutPutDoc)
104 call ClearStatus
105 end Sub
107 Sub Main
108 call SetGlobalDoc
109 if bShowTable then
110 call ClearDoc (gOutPutDoc)
111 end If
113 call ClearStatus
115 Call Test_10er.Main
117 if bShowTable then
118 call CreateStatusTable2
119 call CreateStatusTable
120 call CreateDocState
121 call CreateSecondState
122 gOutputDoc.CurrentController.ViewCursor.JumpToFirstPage
123 end if
124 End Sub
126 Sub CreateStatusTable
127 dim tableHeaders(7) as string
128 tableHeaders(cStWriter) = &quot;Writer&quot;
129 tableHeaders(cStCalc) = &quot;Calc&quot;
130 tableHeaders(cStPraesentation) = &quot;Präsen- tation&quot;
131 tableHeaders(cStZeichnen) = &quot;Zeichn.&quot;
132 tableHeaders(cStChart) = &quot;Diagr.&quot;
133 tableHeaders(cStMath) = &quot;Math&quot;
134 tableHeaders(cStHTML) = &quot;HTML&quot;
135 tableHeaders(cStJava) = &quot;Java&quot;
137 dim tableColums(5) as string
138 tableColums(cDocNew) = &quot;new&quot;
139 tableColums(cDocCut) = &quot;cut&quot;
140 tableColums(cDocPaste) = &quot;paste&quot;
141 tableColums(cDocSaveOpen8) = &quot;V8.0&quot;
142 tableColums(cDocSaveOpenXML) = &quot;XML&quot;
143 tableColums(cDocSaveOpen50) = &quot;V5.0&quot;
144 &apos; tableColums(cDocClose) = &quot;close&quot;
146 aDoc = gOutPutDoc
148 xText = aDoc.Text
149 xCursor = xText.createTextCursor()
151 &apos; xCursor.gotoStart(FALSE)
152 &apos; xCursor.GoRight (2, False)
153 &apos; SetParagraphBreak (xCursor)
154 &apos; SetParagraphBreak (xCursor)
155 xCursor.gotoStart(FALSE)
156 xCursor.GoRight (4, False)
157 SetParagraphBreak (xCursor)
158 xCursor.GoRight (1, False)
159 SetParagraphBreak (xCursor)
160 xCursor.GoRight (1, False)
162 table = aDoc.createInstance(&quot;com.sun.star.text.TextTable&quot;)
163 table.initialize(7,9)
164 table.Name = &quot;StTab1&quot;
165 xText.insertTextContent(xCursor, table, FALSE)
167 tableCursor = table.createCursorByCellName(table.CellNames(0))
168 tableCursor.gotoStart(FALSE)
169 tableCursor.goRight(1,FALSE)
171 for i% = 0 to 7
172 cName = tableCursor.getRangeName()
173 xCell = table.getCellByName(cName)
174 xCell.String=tableHeaders(i%)
176 xCell.BackTransparent = False
177 xCell.BackColor = cCoGrey
179 tableCursor.goRight(1,FALSE)
180 next i%
182 xCursor.gotoStart(FALSE)
183 &apos; SetParagraphBreak (xCursor)
184 &apos; SetParagraphBreak (xCursor)
186 tableCursor.gotoStart(FALSE)
187 cName = tableCursor.getRangeName()
188 xCell = table.getCellByName(cName)
189 xCell.BackTransparent = False
190 xCell.BackColor = cCoGrey
192 for i% = 0 to 5
193 tableCursor.goDown(1,FALSE)
194 cName = tableCursor.getRangeName()
195 xCell = table.getCellByName(cName)
196 xCell.String=tableColums(i%)
198 xCell.BackTransparent = False
199 xCell.BackColor = cCoGrey
200 next i%
201 end Sub
203 Sub CreateStatusTable2
204 dim tableHeaders(5) as string
205 tableHeaders(cStDataBase-9) = &quot;Database&quot;
206 tableHeaders(1) = &quot;&quot;
207 tableHeaders(cStExtension-9) = &quot;Extension&quot;
208 tableHeaders(3) = &quot;&quot;
209 tableHeaders(4) = &quot;&quot;
211 dim tableColums(5) as string
212 tableColums(cDBService ) = &quot;services&quot;
213 tableColums(cDBOpen ) = &quot;open&quot;
214 tableColums(cDBInsert ) = &quot;insert&quot;
215 tableColums(cDBDelete ) = &quot;delete&quot;
216 tableColums(cDBSeek ) = &quot;seek&quot;
217 tableColums(cDBClose ) = &quot;close&quot;
219 dim tableColums2(3) as string
220 tableColums2(cEXTService ) = &quot;services&quot;
221 tableColums2(cEXTInstall ) = &quot;install&quot;
222 tableColums2(cEXTUninstall ) = &quot;uninstall&quot;
224 aDoc = gOutPutDoc
226 xText = aDoc.Text
227 xCursor = xText.createTextCursor()
229 xCursor.gotoStart(FALSE)
230 xCursor.GoRight (4, False)
231 SetParagraphBreak (xCursor)
232 SetParagraphBreak (xCursor)
233 xCursor.gotoEnd(FALSE)
235 table = aDoc.createInstance(&quot;com.sun.star.text.TextTable&quot;)
236 table.initialize(7,6)
237 table.Name = &quot;StTab2&quot;
238 &apos;table.RelativeWidth =500
240 xText.insertTextContent(xCursor, table, FALSE)
242 tableCursor = table.createCursorByCellName(table.CellNames(0))
243 tableCursor.gotoStart(FALSE)
244 tableCursor.goRight(1,FALSE)
246 for i% = 0 to 5
247 cName = tableCursor.getRangeName()
248 xCell = table.getCellByName(cName)
249 xCell.String=tableHeaders(i%)
251 xCell.BackTransparent = False
252 xCell.BackColor = cCoGrey
254 tableCursor.goRight(1,FALSE)
255 next i%
257 tableCursor.gotoStart(FALSE)
259 cName = tableCursor.getRangeName()
260 xCell = table.getCellByName(cName)
261 xCell.BackTransparent = False
262 xCell.BackColor = cCoGrey
264 for i% = 0 to 5
265 tableCursor.goDown(1,FALSE)
266 cName = tableCursor.getRangeName()
267 xCell = table.getCellByName(cName)
268 xCell.String=tableColums(i%)
270 xCell.BackTransparent = False
271 xCell.BackColor = cCoGrey
272 next i%
274 tableCursor.gotoStart(FALSE)
275 tableCursor.goRight(2,FALSE)
277 for i% = 0 to 3
278 tableCursor.goDown(1,FALSE)
279 cName = tableCursor.getRangeName()
280 xCell = table.getCellByName(cName)
281 xCell.String=tableColums2(i%)
283 xCell.BackTransparent = False
284 xCell.BackColor = cCoGrey
285 next i%
286 end Sub
289 Sub CreateDocState
290 aDoc = gOutPutDoc
291 table = aDoc.TextTables.GetByIndex (1)
292 &apos;table = aDoc.TextTables.GetByName (&quot;StTab1&quot;)
294 for j% = 0 to 7
295 for i% = 0 to 5
296 sRangeName = GetRangeName(j%, i%+1)
298 tableCursor = table.createCursorByCellName(sRangeName)
300 cName = tableCursor.getRangeName()
301 xCell = table.getCellByName(cName)
303 xCell.BackTransparent = False
305 if gErrorState (j%, i%) = cLogTrue then
306 xCell.BackColor = cCoGreen
307 else if gErrorState (j%, i%) = cLogFalse then
308 xCell.BackColor = cCoRed
309 else
310 xCell.BackColor = cCoGrey
311 end If
312 end If
314 next i%
315 next j%
316 end Sub
318 Sub CreateSecondState
319 aDoc = gOutPutDoc
320 table = aDoc.TextTables.GetByIndex (0)
321 &apos;table = aDoc.TextTables.GetByName (&quot;StTab2&quot;)
323 for j% = 0 to cMaxErrorStates-9
324 for i% = 0 to 5
325 sRangeName = GetRangeName(j%, i%+1)
327 tableCursor = table.createCursorByCellName(sRangeName)
329 cName = tableCursor.getRangeName()
330 xCell = table.getCellByName(cName)
332 xCell.BackTransparent = False
334 if gErrorState (j%+9, i%) = cLogTrue then
335 xCell.BackColor = cCoGreen
336 else if gErrorState (j%+9, i%) = cLogFalse then
337 xCell.BackColor = cCoRed
338 else
339 xCell.BackColor = cCoGrey
340 end If
341 end If
343 next i%
344 next j%
345 end Sub
347 Function GetRangeName (nColumn as integer, nRow as integer) as string
348 GetRangeName = chr (nColumn+66) + Trim(Str(nRow+1))
349 end Function
351 Sub SetStatus (nDocType as Integer, nAction as Integer, bState as Boolean)
352 Dim nStatusType as Integer
353 Dim nState as integer
354 nStatusType = GetStatusType (nDocType)
355 If nStatusType = cStNone then Exit Sub
357 if bState then
358 nState = cLogTrue
359 else
360 nState = cLogFalse
361 end If
363 gErrorState (nStatusType, nAction) = nState
364 end Sub
366 Function GetStatusType (nDocType as Integer) as Integer
367 Select Case ( nDocType )
368 case frmWriter
369 GetStatusType = cStWriter &apos; Textdokument
370 case frmCalc
371 GetStatusType = cStCalc &apos;Tabellendokument
372 case frmMessage
373 GetStatusType = cStMessage &apos;Nachricht
374 case frmImpress
375 GetStatusType = cStPraesentation &apos;Präsentation
376 case frmDraw
377 GetStatusType = cStZeichnen &apos;Zeichnen
378 case frmMath
379 GetStatusType = cStMath &apos;Formel
380 case frmImage
381 GetStatusType = cStBild &apos;Bild
382 case frmHyperText
383 GetStatusType = cStHTML &apos;Hypertext-Dokument
384 case frmChart
385 GetStatusType = cStChart &apos;Diagramm
386 case frmSchedule
387 GetStatusType = cStSchedule &apos;Diagramm
388 case frmJava
389 GetStatusType = cStJava &apos;Java
390 case frmNews
391 GetStatusType = cStNews &apos;News
392 case frmDataBase
393 GetStatusType = cStDataBase &apos;DataBase
394 case frmExtension
395 GetStatusType = cStExtension &apos;Extension
396 case else
397 GetStatusType = cStNone
398 end Select
399 end Function
401 Sub SetParagraphBreak (aCursor as Object)
402 aCursor.Text.InsertControlCharacter (aCursor, cParagraphBreak, True)
403 end Sub
405 Sub ClearDoc (aDoc as Object)
406 Dim aText as Object
407 Dim i%
408 for i%=1 to aDoc.TextTables.count
409 aDoc.TextTables.GetByIndex(0).dispose
410 next
412 aText = aDoc.Text.CreateTextCursor
413 aText.GotoStart (False)
414 aText.GoRight (3, False)
415 SetParagraphBreak (aText)
416 aText.GotoEnd (True)
417 aText.String=&quot;&quot;
418 end Sub
420 Sub ClearDocFull (aDoc as Object)
421 Dim aText as Object
422 Dim i%
423 for i%=1 to aDoc.TextTables.count
424 aDoc.TextTables.GetByIndex(0).dispose
425 next
427 aText = aDoc.Text.CreateTextCursor
428 aText.GotoStart (False)
429 aText.GotoEnd (True)
430 aText.String=&quot;&quot;
431 end Sub
433 Sub SetGlobalOptionsDialog ()
435 Dim oLibContainer As Object, oLib As Object
436 Dim oInputStreamProvider As Object
437 Dim oDialog As Object
439 Const sLibName = cTest10Modul
440 Const sDialogName = cOptionsDialogName
442 REM get library and input stream provider
443 oLibContainer = DialogLibraries
445 REM load the library
446 oLibContainer.loadLibrary( sLibName )
448 oLib = oLibContainer.getByName( sLibName )
449 oInputStreamProvider = oLib.getByName( sDialogName )
451 REM create dialog control
452 gOptionsDialog = CreateUnoDialog( oInputStreamProvider )
454 end Sub
456 Sub ShowOptionsDlg
458 call SetGlobalDoc
459 call SetGlobalOptionsDialog
460 call GetOptions
462 REM show the dialog
463 gOptionsDialog.execute()
465 &apos; jetzt läuft der Dialog, bis ein Button gedrückt wird
467 Select Case (gDlgState)
468 case cDlgOk
469 call SetOptions ()
470 case cDlgStartTest
471 call SetOptions ()
472 call StartTestByOptions ()
473 end Select
475 gOptionsDialog.dispose()
477 end Sub
479 Sub SetOptions
480 call SetGlobalDoc
481 SetUserFieldState (cUserFieldTestWriter, -(gOptionsDialog.getControl(&quot;cbWriterTest&quot;).getState), gOutPutDoc)
482 SetUserFieldState (cUserFieldTestCalc, -(gOptionsDialog.getControl(&quot;cbCalcTest&quot;).getState), gOutPutDoc)
483 SetUserFieldState (cUserFieldTestImpress, -(gOptionsDialog.getControl(&quot;cbImpressTest&quot;).getState), gOutPutDoc)
484 SetUserFieldState (cUserFieldTestDraw, -(gOptionsDialog.getControl(&quot;cbDrawTest&quot;).getState), gOutPutDoc)
485 SetUserFieldState (cUserFieldTestHTML, -(gOptionsDialog.getControl(&quot;cbHTMLTest&quot;).getState), gOutPutDoc)
486 SetUserFieldState (cUserFieldTestMath, -(gOptionsDialog.getControl(&quot;cbMathTest&quot;).getState), gOutPutDoc)
487 SetUserFieldState (cUserFieldTestChart, -(gOptionsDialog.getControl(&quot;cbChartTest&quot;).getState), gOutPutDoc)
488 SetUserFieldState (cUserFieldTestJava, -(gOptionsDialog.getControl(&quot;cbJavaTest&quot;).getState), gOutPutDoc)
489 SetUserFieldState (cUserFieldTestDatabase, -(gOptionsDialog.getControl(&quot;cbDatabaseTest&quot;).getState), gOutPutDoc)
490 SetUserFieldState (cUserFieldTestExtension, -(gOptionsDialog.getControl(&quot;cbExtensionTest&quot;).getState), gOutPutDoc)
491 SetUserFieldState (cUserFieldTestOpenSaveXML, -(gOptionsDialog.getControl(&quot;cbSaveOpenXMLTest&quot;).getState), gOutPutDoc)
492 SetUserFieldState (cUserFieldTestOpenSave50, -(gOptionsDialog.getControl(&quot;cbSaveOpen50Test&quot;).getState), gOutPutDoc)
493 SetUserFieldState (cUserFieldTestOpenSave8, -(gOptionsDialog.getControl(&quot;cbSaveOpen8Test&quot;).getState), gOutPutDoc)
494 SetUserFieldState (cUserFieldTestCut, -(gOptionsDialog.getControl(&quot;cbCutTest&quot;).getState), gOutPutDoc)
495 SetUserFieldState (cUserFieldTestPaste, -(gOptionsDialog.getControl(&quot;cbPasteTest&quot;).getState), gOutPutDoc)
496 SetUserFieldState (cUserFieldTestTerminateAfterTest, -(gOptionsDialog.getControl(&quot;cbTerminateAfterTest&quot;).getState), gOutPutDoc)
497 end Sub
499 Sub GetOptions
500 call SetGlobalDoc
501 gOptionsDialog.getControl(&quot;cbWriterTest&quot;).setState( -( GetUserFieldState (cUserFieldTestWriter, gOutPutDoc)))
502 gOptionsDialog.getControl(&quot;cbCalcTest&quot;).setState ( -( GetUserFieldState (cUserFieldTestCalc, gOutPutDoc)))
503 gOptionsDialog.getControl(&quot;cbImpressTest&quot;).setState( -( GetUserFieldState (cUserFieldTestImpress, gOutPutDoc)))
504 gOptionsDialog.getControl(&quot;cbDrawTest&quot;).setState( -( GetUserFieldState (cUserFieldTestDraw, gOutPutDoc)))
505 gOptionsDialog.getControl(&quot;cbHTMLTest&quot;).setState( -( GetUserFieldState (cUserFieldTestHTML, gOutPutDoc)))
506 gOptionsDialog.getControl(&quot;cbMathTest&quot;).setState( -( GetUserFieldState (cUserFieldTestMath, gOutPutDoc)))
507 gOptionsDialog.getControl(&quot;cbChartTest&quot;).setState( -( GetUserFieldState (cUserFieldTestChart, gOutPutDoc)))
508 gOptionsDialog.getControl(&quot;cbJavaTest&quot;).setState( -( GetUserFieldState (cUserFieldTestJava, gOutPutDoc)))
509 gOptionsDialog.getControl(&quot;cbDatabaseTest&quot;).setState( -( GetUserFieldState (cUserFieldTestDatabase, gOutPutDoc)))
510 gOptionsDialog.getControl(&quot;cbExtensionTest&quot;).setState( -( GetUserFieldState (cUserFieldTestExtension, gOutPutDoc)))
511 gOptionsDialog.getControl(&quot;cbSaveOpenXMLTest&quot;).setState( -( GetUserFieldState (cUserFieldTestOpenSaveXML, gOutPutDoc)))
512 gOptionsDialog.getControl(&quot;cbSaveOpen50Test&quot;).setState( -( GetUserFieldState (cUserFieldTestOpenSave50, gOutPutDoc)))
513 gOptionsDialog.getControl(&quot;cbSaveOpen8Test&quot;).setState( -( GetUserFieldState (cUserFieldTestOpenSave8, gOutPutDoc)))
514 gOptionsDialog.getControl(&quot;cbCutTest&quot;).setState( -( GetUserFieldState (cUserFieldTestCut, gOutPutDoc)))
515 gOptionsDialog.getControl(&quot;cbPasteTest&quot;).setState( -( GetUserFieldState (cUserFieldTestPaste, gOutPutDoc)))
516 gOptionsDialog.getControl(&quot;cbTerminateAfterTest&quot;).setState( -( GetUserFieldState (cUserFieldTestTerminateAfterTest, gOutPutDoc)))
517 End Sub
519 Sub ReadOptions
520 call SetGlobalDoc
521 bTestDocs = true
522 bMakeWriterTest = GetUserFieldState (cUserFieldTestWriter, gOutPutDoc)
523 bMakeCalcTest = GetUserFieldState (cUserFieldTestCalc, gOutPutDoc)
524 bMakeImpressTest = GetUserFieldState (cUserFieldTestImpress, gOutPutDoc)
525 bMakeDrawTest = GetUserFieldState (cUserFieldTestDraw, gOutPutDoc)
526 bMakeHTMLTest = GetUserFieldState (cUserFieldTestHTML, gOutPutDoc)
527 bMakeMathTest = GetUserFieldState (cUserFieldTestMath, gOutPutDoc)
528 bMakeChartTest = GetUserFieldState (cUserFieldTestChart, gOutPutDoc)
529 bMakeJavaTest = GetUserFieldState (cUserFieldTestJava, gOutPutDoc)
530 bMakeDBTest = GetUserFieldState (cUserFieldTestDatabase, gOutPutDoc)
531 bMakeExtensionTest = GetUserFieldState (cUserFieldTestExtension, gOutPutDoc)
532 bMakeSaveOpenXMLTest = GetUserFieldState (cUserFieldTestOpenSaveXML, gOutPutDoc)
533 bMakeSaveOpen50Test = GetUserFieldState (cUserFieldTestOpenSave50, gOutPutDoc)
534 bMakeSaveOpen8Test = GetUserFieldState (cUserFieldTestOpenSave8, gOutPutDoc)
535 bMakeCutTest = GetUserFieldState (cUserFieldTestCut, gOutPutDoc)
536 bMakePasteTest = GetUserFieldState (cUserFieldTestPaste, gOutPutDoc)
537 bMakeTerminateAfterTest = GetUserFieldState (cUserFieldTestTerminateAfterTest, gOutPutDoc)
538 end Sub
540 Sub SetDefaultOptions
541 bTestDocs = true
542 bMakeWriterTest = true
543 bMakeCalcTest = true
544 bMakeImpressTest = true
545 bMakeDrawTest = true
546 bMakeHTMLTest = true
547 bMakeMathTest = true
548 bMakeChartTest = true
549 bMakeJavaTest = true
550 bMakeDBTest = true
551 bMakeExtensionTest = true
552 bMakeSaveOpenXMLTest = true
553 REM Disable StarOffice 5.0 tests in case binfilter has not been included
554 if Environ(&quot;WITH_BINFILTER&quot;) = &quot;NO&quot; then
555 bMakeSaveOpen50Test = false
556 else
557 bMakeSaveOpen50Test = true
558 End If
559 bMakeSaveOpen8Test = true
560 bMakeCutTest = true
561 bMakePasteTest = true
562 bMakeTerminateAfterTest = true
563 end Sub
565 Sub ShutdownQuickstarter
566 dim qs as Object
567 qs = createUnoService(&quot;com.sun.star.comp.desktop.QuickstartWrapper&quot; )
568 qs.setFastPropertyValue( 0, false )
569 end Sub
571 Sub StartTestByOptions
572 call ShutdownQuickstarter
573 bShowTable = true
574 call ReadOptions
575 call Main
577 if bMakeTerminateAfterTest then
579 ClearDocFull (gOutPutDoc)
580 gOutPutDoc.dispose
581 &apos;StarDesktop.Terminate
583 &apos;EnableReschedule( false )
584 &apos;DispatchSlot( 5300 )
585 stop
586 End If
587 end Sub
589 Sub StartTestWithDefaultOptions
590 call ShutdownQuickstarter
591 bShowTable = false
592 call SetDefaultOptions
593 call Main
595 if bMakeTerminateAfterTest then
596 stop
598 ClearDocFull (gOutPutDoc)
599 gOutPutDoc.dispose
600 &apos;StarDesktop.Terminate
601 &apos;EnableReschedule( false )
602 &apos;DispatchSlot( 5300 )
603 stop
604 End If
605 end Sub
607 Sub DispatchSlot(SlotID as Integer)
608 Dim oArg() as new com.sun.star.beans.PropertyValue
609 Dim oUrl as new com.sun.star.util.URL
610 Dim oTrans as Object
611 Dim oDisp as Object
613 oTrans = createUNOService(&quot;com.sun.star.util.URLTransformer&quot;)
614 oUrl.Complete = &quot;slot:&quot; &amp; CStr(SlotID)
615 oTrans.parsestrict(oUrl)
617 oDisp = StarDesktop.queryDispatch(oUrl, &quot;_self&quot;, 0)
618 oDisp.dispatch(oUrl, oArg())
619 End Sub
621 Sub LoadLibrary( LibName As String )
623 dim args(1)
624 dim arg as new com.sun.star.beans.PropertyValue
625 arg.Name = &quot;LibraryName&quot;
626 arg.Value = LibName
627 args(0) = arg
629 dim url as new com.sun.star.util.URL
630 dim trans as object
631 trans = createUnoService(&quot;com.sun.star.util.URLTransformer&quot; )
632 url.Complete = &quot;slot:6517&quot;
633 trans.parsestrict( url )
635 dim disp as object
636 disp = StarDesktop.currentFrame.queryDispatch( url, &quot;&quot;, 0 )
637 disp.dispatch( url, args() )
639 End Sub
641 Sub ExecuteSlot( SlotNr As String, oDoc as Object )
642 dim args()
643 dim url as new com.sun.star.util.URL
644 dim trans as object
645 dim disp as object
647 trans = createUnoService(&quot;com.sun.star.util.URLTransformer&quot; )
648 url.Complete = &quot;slot:&quot; + SlotNr
649 trans.parsestrict( url )
651 disp = oDoc.CurrentController.Frame.queryDispatch( url, &quot;&quot;, 0 )
652 disp.dispatch( url, args() )
654 End Sub
656 Sub CutText (oDoc as Object)
657 ExecuteSlot (&quot;5710&quot;, oDoc)
658 End Sub
660 Sub PasteText (oDoc as Object)
661 ExecuteSlot (&quot;5712&quot;, oDoc)
662 End Sub
664 Sub DelAllUserFields (aDoc as Object)
665 Dim aFieldType as Object
666 Dim aElements as Variant
667 Dim i%
668 Dim aFieldMasters, aFieldMaster as Object
669 Dim sElement$
670 aFieldMasters = aDoc.TextFieldMasters
671 aElements = aFieldMasters.ElementNames
672 for i = 0 to UBound(aElements)
673 sElement$ = aElements(i)
674 if 0 &lt;&gt; instr(sElement$, cUnoUserField ) then
675 aFieldMaster = aFieldMasters.GetByName(sElement$)
676 aFieldMaster.Dispose
677 endif
678 next
679 end Sub
681 Function GetUserFieldState (sName as String, aDoc as Object) as boolean
682 Dim sFieldText as String
683 Dim bState as boolean
684 sFieldText = ReadUserField (sName, aDoc)
686 if LCase(sFieldText) = cYes then
687 bState = true
688 else
689 bState = false
690 end IF
692 GetUserFieldState = bState
693 end Function
695 Sub SetUserFieldState (sName as String, nState as boolean, aDoc as Object)
696 Dim sFieldText as String
698 sFieldText = cNo &apos;default
700 Select case nState
701 case true
702 sFieldText = cYes
703 case false
704 sFieldText = cNo
705 end Select
707 WriteUserField (sFieldText, sName, aDoc)
708 end Sub
710 Function ReadUserField(sFieldName as String, aDoc as Object) as String
711 Dim aMasters as Object
712 aMasters = aDoc.TextFieldMasters
713 if aMasters.HasByName (cUnoUserField+cUnoSeparator+sFieldName) then
714 ReadUserField = aMasters.GetByName (cUnoUserField+cUnoSeparator+sFieldName).Content
715 else
716 ReadUserField = &quot;&quot;
717 end If
718 End Function
720 Sub WriteUserField(sValue as String, sFieldName as String, aDoc as Object, optional aCursor as Object)
721 Dim aMasters, aUserField, aTxtCursor as Object
722 aMasters = aDoc.TextFieldMasters
723 if aMasters.HasByName (cUnoUserField+cUnoSeparator+sFieldName) then
724 aUserField = aMasters.GetByName (cUnoUserField+cUnoSeparator+sFieldName)
725 else
726 aUserField = aDoc.CreateInstance (cUnoUserField)
727 aUserField.Name = sFieldName
728 end if
729 aUserField.Content = sValue
730 End Sub
732 Sub WriteExtUserField(nIndex as Integer, aCursor as Object, aDoc as Object)
733 Dim aUserField as Object
734 aUserField = aDoc.CreateInstance (cUnoExtUserField)
735 aUserField.UserDataType = nIndex
736 aCursor.Text.InsertTextContent (aCursor, aUserField, True)
737 aUserField.Fix = True
738 End Sub
739 </script:module>