Update ooo320-m1
[ooovba.git] / smoketestoo_native / data / scripts / Test_10er.xba
blobb475dfe53b42a6532defcec02f4964fb1f0253b9
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="Test_10er" script:language="StarBasic">REM 10er Test
5 const sSWLogFileName = &quot;swlog.dat&quot;, sSCLogFileName = &quot;sclog.dat&quot;
6 const sSDLogFileName = &quot;sdlog.dat&quot;, sSMathLogFileName = &quot;smalog.dat&quot;
7 const sSImDLogFileName = &quot;simlog.dat&quot;, sSChartLogFileName = &quot;schlog.dat&quot;
8 const sSHptLogFileName = &quot;shptlog.dat&quot;, sSMessageLogFileName = &quot;smeslog.dat&quot;
9 const sSDrawLogFileName = &quot;sdrwlog.dat&quot;, sJavaLogFileName = &quot;javalog.dat&quot;
10 const sSDBLogFileName = &quot;dblog.dat&quot;, sExtLogFileName = &quot;extlog.dat&quot;
11 const sLogFileName = &quot;log.dat&quot;
12 const cTempFileName = &quot;ttt&quot;
14 const cMessageSaveOpen8Doc = &quot;Save/Open open Documents (8.0)&quot;
15 const cMessageSaveOpenXMLDoc = &quot;Save/Open Document XML (6/7)&quot;
16 const cMessageSaveOpen50Doc = &quot;Save/Open Document 5.0&quot;
17 const cMessageNewDoc = &quot;New Document&quot;
18 const cMessageCloseDoc = &quot;Close Document&quot;
19 const cMessageCutObj = &quot;Cut Object&quot;
20 const cMessagePasteObj = &quot;Paste Object&quot;
22 Global sWorkPath$
23 Global sWorkPathURL$
24 Global FileChannel%
25 Global MainFileChannel%
27 Sub Main
28 call TestAllDocs()
29 end Sub
31 Sub DeleteAllSavedFiles()
32 Dim sFileName as String
33 sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmWriter)
34 If FileExists (sFileName) then
35 Kill (sFileName)
36 End If
37 sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmCalc)
38 If FileExists (sFileName) then
39 Kill (sFileName)
40 End If
41 sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmImpress)
42 If FileExists (sFileName) then
43 Kill (sFileName)
44 End If
45 sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmDraw)
46 If FileExists (sFileName) then
47 Kill (sFileName)
48 End If
49 sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmHyperText)
50 If FileExists (sFileName) then
51 Kill (sFileName)
52 End If
53 sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmWriter or cFltXML)
54 If FileExists (sFileName) then
55 Kill (sFileName)
56 End If
57 sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmCalc or cFltXML)
58 If FileExists (sFileName) then
59 Kill (sFileName)
60 End If
61 sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmImpress or cFltXML)
62 If FileExists (sFileName) then
63 Kill (sFileName)
64 End If
65 sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmDraw or cFltXML)
66 If FileExists (sFileName) then
67 Kill (sFileName)
68 End If
69 sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmWriter or cFlt50)
70 If FileExists (sFileName) then
71 Kill (sFileName)
72 End If
73 sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmCalc or cFlt50)
74 If FileExists (sFileName) then
75 Kill (sFileName)
76 End If
77 sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmImpress or cFlt50)
78 If FileExists (sFileName) then
79 Kill (sFileName)
80 End If
81 sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmDraw or cFlt50)
82 If FileExists (sFileName) then
83 Kill (sFileName)
84 End If
85 End Sub
87 Sub DeleteAllLogFiles()
88 If FileExists (sWorkPath+sLogFileName) then
89 Kill (sWorkPath+sLogFileName)
90 End If
91 If FileExists (sWorkPath+sSWLogFileName) then
92 Kill (sWorkPath+sSWLogFileName)
93 End If
94 If FileExists (sWorkPath+sSCLogFileName) then
95 Kill (sWorkPath+sSCLogFileName)
96 End If
97 If FileExists (sWorkPath+sSDLogFileName) then
98 Kill (sWorkPath+sSDLogFileName)
99 End If
100 If FileExists (sWorkPath+sSMathLogFileName) then
101 Kill (sWorkPath+sSMathLogFileName)
102 End If
103 If FileExists (sWorkPath+sSImDLogFileName) then
104 Kill (sWorkPath+sSImDLogFileName)
105 End If
106 If FileExists (sWorkPath+sSChartLogFileName) then
107 Kill (sWorkPath+sSChartLogFileName)
108 End If
109 If FileExists (sWorkPath+sSHptLogFileName) then
110 Kill (sWorkPath+sSHptLogFileName)
111 End If
112 If FileExists (sWorkPath+sSMessageLogFileName) then
113 Kill (sWorkPath+sSMessageLogFileName)
114 End If
115 If FileExists (sWorkPath+sSDrawLogFileName) then
116 Kill (sWorkPath+sSDrawLogFileName)
117 End If
118 If FileExists (sWorkPath+sJavaLogFileName) then
119 Kill (sWorkPath+sJavaLogFileName)
120 End If
121 If FileExists (sWorkPath+sSDBLogFileName) then
122 Kill (sWorkPath+sSDBLogFileName)
123 End If
124 If FileExists (sWorkPath+sExtLogFileName) then
125 Kill (sWorkPath+sExtLogFileName)
126 End If
127 end Sub
129 Function OpenLogDat (sFileName as String) as Integer
130 Dim LocaleFileChannel%
131 If FileExists (sWorkPath+sFileName) then
132 Kill (sWorkPath+sFileName)
133 End If
134 LocaleFileChannel% = Freefile
135 Open sWorkPath+sFileName For Output As LocaleFileChannel%
136 OpenLogDat = LocaleFileChannel%
137 end Function
139 Function GetWorkPath as string
140 sTemp = &quot;$(userpath)/temp/&quot;
141 GetWorkPath = CreateUnoService(&quot;com.sun.star.config.SpecialConfigManager&quot;).SubstituteVariables(sTemp)
142 End Function
144 Function GetWorkURL as string
145 sTemp = &quot;$(userurl)/temp/&quot;
146 GetWorkURL = CreateUnoService(&quot;com.sun.star.config.SpecialConfigManager&quot;).SubstituteVariables(sTemp)
147 End Function
149 Function GetSystem (sTmpWorkPath as string) as string
150 GetSystem = &quot;&quot;
151 if InStr (sTmpWorkPath, &quot;:&quot;) then
152 GetSystem = &quot;windows&quot;
153 else
154 GetSystem = &quot;unix&quot;
155 End If
156 end Function
158 Function ConvertPathToWin (sTmpWorkPath as string) as string
159 for i%=1 to Len(sTmpWorkPath)
160 sTemp = Mid (sTmpWorkPath, i%, 1)
161 if sTemp = &quot;/&quot; then
162 sTmpWorkPath = Left (sTmpWorkPath, i%-1) + &quot;\&quot; + Right (sTmpWorkPath, Len(sTmpWorkPath)-i%)
163 else
164 if sTemp = &quot;|&quot; then
165 sTmpWorkPath = Left (sTmpWorkPath, i%-1) + &quot;:&quot; + Right (sTmpWorkPath, Len(sTmpWorkPath)-i%)
166 end If
167 end If
168 next i%
169 ConvertPathToWin = sTmpWorkPath
170 end Function
172 Sub TestAllDocs()
173 DIM sDocURL as String, sDocPath as String
174 DIM nStrPos as Long
176 sWorkPath = GetWorkPath
177 sWorkPathURL = GetWorkURL
179 if GetSystem (sWorkPath) = &quot;windows&quot; then
180 sWorkPath = ConvertPathToWin (sWorkPath)
181 end if
183 &apos;search ExtensionURL
184 sExtensionURL = sWorkPathURL
185 If not FileExists (sExtensionURL + cExtensionFileName) then
186 if bShowTable then
187 sDocURL = gOutPutDoc.URL
188 CompatibilityMode(true)
189 nStrPos = InStrRev (sDocURL, &quot;/&quot; )
190 CompatibilityMode(false)
191 if nStrPos then
192 sDocURL = Left (sDocURL, nStrPos)
193 sExtensionURL = sDocURL
194 If not FileExists (sExtensionURL + cExtensionFileName) then
195 bMakeExtensionTest = false &apos; test is not possible then
196 end if
197 else
198 bMakeExtensionTest = false &apos; test is not possible then
199 end if
201 else
202 bMakeExtensionTest = false &apos; test is not possible then
203 end if
205 end if
207 call DeleteAllSavedFiles()
208 call DeleteAllLogFiles()
209 MainFileChannel = OpenLogDat (sLogFileName)
210 call WriteTestSequence (MainFileChannel)
211 if bMakeWriterTest then
212 call MakeDocTest (frmWriter)
213 end if
214 if bMakeCalcTest then
215 call MakeDocTest (frmCalc)
216 end if
217 if bMakeImpressTest then
218 call MakeDocTest (frmImpress)
219 end if
220 if bMakeDrawTest then
221 call MakeDocTest (frmDraw)
222 end if
223 if bMakeHTMLTest then
224 call MakeDocTest (frmHyperText)
225 end if
226 if bMakeChartTest then
227 call MakeChartTest (frmChart)
228 end if
229 if bMakeMathTest then
230 call MakeNewDoc (frmMath)
231 end if
232 if bMakeJavaTest then
233 call TestJava (frmJava)
234 end if
235 if bMakeDBTest then
236 call Test_DB.TestDB (frmDataBase)
237 end if
238 if bMakeExtensionTest then
239 call Test_Ext.TestExtensions (frmExtension)
240 end if
242 Close #MainFileChannel
243 end Sub
245 Sub WriteTestSequence (FileChannel as integer)
246 Print #FileChannel, &quot;Sequence of testing&quot;
248 if bMakeWriterTest then
249 WriteTests (&quot;writer : &quot;, true, FileChannel)
250 end if
251 if bMakeCalcTest then
252 WriteTests (&quot;calc : &quot;, true, FileChannel)
253 end if
254 if bMakeImpressTest then
255 WriteTests (&quot;impress : &quot;, true, FileChannel)
256 end if
257 if bMakeDrawTest then
258 WriteTests (&quot;draw : &quot;, true, FileChannel)
259 end if
260 if bMakeHTMLTest then
261 WriteTests (&quot;HTML : &quot;, true, FileChannel)
262 end if
263 if bMakeChartTest then
264 WriteTests (&quot;chart : &quot;, false, FileChannel)
265 end if
266 if bMakeMathTest then
267 WriteTests (&quot;math : &quot;, false, FileChannel)
268 end if
269 if bMakeJavaTest then
270 WriteTests (&quot;Java : &quot;, false, FileChannel)
271 end if
272 if bMakeDBTest then
273 WriteDBTests (&quot;Database : &quot;, FileChannel)
274 end if
275 if bMakeExtensionTest then
276 WriteExtensionTests (&quot;Extension : &quot;, FileChannel)
277 end if
279 Print #FileChannel
280 end Sub
282 Sub WriteTests (sText as string, bTestAll as boolean, nFileChannel as integer)
283 Dim sWriteStr as string
285 sWriteStr = sText
286 sWriteStr = sWriteStr + &quot;new&quot;
287 if bTestAll then
288 if bMakeCutTest then
289 sWriteStr = sWriteStr + &quot;, cut&quot;
290 end if
291 if bMakePasteTest then
292 sWriteStr = sWriteStr + &quot;, paste&quot;
293 end if
294 if bMakeSaveOpen8Test then
295 sWriteStr = sWriteStr + &quot;, save 8.0&quot;
296 end if
297 if bMakeSaveOpenXMLTest then
298 sWriteStr = sWriteStr + &quot;, save XML&quot;
299 end if
300 if bMakeSaveOpen50Test then
301 sWriteStr = sWriteStr + &quot;, save 5.0&quot;
302 end if
303 if bMakeSaveOpen8Test then
304 sWriteStr = sWriteStr + &quot;, open 8.0&quot;
305 end if
306 if bMakeSaveOpenXMLTest then
307 sWriteStr = sWriteStr + &quot;, open XML&quot;
308 end if
309 if bMakeSaveOpen50Test then
310 sWriteStr = sWriteStr + &quot;, open 5.0&quot;
311 end if
312 end if
314 sWriteStr = sWriteStr + &quot;, close&quot;
316 Print #nFileChannel, sWriteStr
317 end Sub
319 Sub WriteDBTests (sText as string, nFileChannel as integer)
320 Dim sWriteStr as string
322 sWriteStr = sText
323 sWriteStr = sWriteStr + &quot;open / services&quot;
324 sWriteStr = sWriteStr + &quot;, insert&quot;
325 sWriteStr = sWriteStr + &quot;, delete&quot;
326 sWriteStr = sWriteStr + &quot;, seek&quot;
327 sWriteStr = sWriteStr + &quot;, close&quot;
329 Print #nFileChannel, sWriteStr
330 end Sub
332 Sub WriteExtensionTests (sText as string, nFileChannel as integer)
333 Dim sWriteStr as string
335 sWriteStr = sText
336 sWriteStr = sWriteStr + &quot;services&quot;
337 sWriteStr = sWriteStr + &quot;, install&quot;
338 sWriteStr = sWriteStr + &quot;, uninstall&quot;
340 Print #nFileChannel, sWriteStr
341 end Sub
343 Sub MakeDocTest (FilterType as Integer)
344 Dim oDoc as Object
345 Dim sFileNameXML$, sFileName50$, sFileName8$
346 Dim bError as Boolean
347 Dim nCurrentAction as Integer
349 On Local Error GoTo DOCTESTERROR
350 nCurrentAction = cLogfileFailed
351 FileChannel% = OpenLogDat (GetLogFileName(FilterType))
352 nCurrentAction = cDocNew
353 oDoc = LoadDoc (&quot;private:factory/&quot; + GetDocFilter(FilterType or cFltNewDoc))
354 LogState (not IsNull (oDoc), GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, FileChannel)
355 LogState (not IsNull (oDoc), GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, MainFileChannel)
356 SetStatus (FilterType, cDocNew, not IsNull (oDoc))
357 if not IsNull (oDoc) then
358 nCurrentAction = cDocCut
359 call CutAndPaste(FilterType, oDoc)
360 &apos; bError = oDoc.CurrentController.frame.close
361 nCurrentAction = cDocSaveOpen8
362 if bMakeSaveOpen8Test and IsFilterAvailable (FilterType or cFlt8) then
363 sFileName8 = sWorkPathURL+cTempFileName+&quot;.&quot;+GetDocEndings(FilterType or cFlt8)
364 SaveDoc (sFileName8, oDoc, GetDocFilter(FilterType or cFlt8))
365 end if
366 nCurrentAction = cDocSaveOpenXML
367 if bMakeSaveOpenXMLTest and IsFilterAvailable (FilterType or cFltXML) then
368 sFileNameXML = sWorkPathURL+cTempFileName+&quot;.&quot;+GetDocEndings(FilterType or cFltXML)
369 SaveDoc (sFileNameXML, oDoc, GetDocFilter(FilterType or cFltXML))
370 end if
371 nCurrentAction = cDocSaveOpen50
372 if bMakeSaveOpen50Test and IsFilterAvailable (FilterType or cFlt50) then
373 sFileName50 = sWorkPathURL+cTempFileName+&quot;.&quot;+GetDocEndings(FilterType or cFlt50)
374 SaveDoc (sFileName50, oDoc, GetDocFilter(FilterType or cFlt50))
375 end if
376 &apos; oDoc.dispose
377 nCurrentAction = cDocClose
378 oDoc.close (true)
379 &apos; bError = true &apos; nur zum ¦bergang, weil bError = oDoc.CurrentController.frame.close nicht geht
380 &apos; LogState (bError, GetDocFilter(FilterType)+&quot; &quot;+ cMessageCloseDoc, FileChannel)
381 &apos; LogState (bError, GetDocFilter(FilterType)+&quot; &quot;+ cMessageCloseDoc, MainFileChannel)
382 &apos; SetStatus (FilterType, cDocClose, bError)
383 nCurrentAction = cDocSaveOpen8
384 if bMakeSaveOpen8Test and IsFilterAvailable (FilterType or cFlt8) then
385 oDoc = LoadDoc (sFileName8)
387 &apos; oDoc = Documents.open(sFileName)
388 LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageSaveOpen8Doc, FileChannel)
389 LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageSaveOpen8Doc, MainFileChannel)
390 SetStatus (FilterType, cDocSaveOpen8, not IsNull (oDoc))
392 if not IsNull (oDoc) then
393 &apos; oDoc.dispose
394 nCurrentAction = cDocClose
395 oDoc.close (true)
396 end If
397 end if
399 nCurrentAction = cDocSaveOpenXML
400 if bMakeSaveOpenXMLTest and IsFilterAvailable (FilterType or cFltXML) then
401 oDoc = LoadDoc (sFileNameXML)
403 &apos; oDoc = Documents.open(sFileName)
404 LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageSaveOpenXMLDoc, FileChannel)
405 LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageSaveOpenXMLDoc, MainFileChannel)
406 SetStatus (FilterType, cDocSaveOpenXML, not IsNull (oDoc))
408 if not IsNull (oDoc) then
409 &apos; oDoc.dispose
410 nCurrentAction = cDocClose
411 oDoc.close (true)
412 end If
413 end if
415 nCurrentAction = cDocSaveOpen50
416 if bMakeSaveOpen50Test and IsFilterAvailable (FilterType or cFlt50) then
417 oDoc = LoadDoc (sFileName50)
419 &apos; oDoc = Documents.open(sFileName)
420 LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageSaveOpen50Doc, FileChannel)
421 LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageSaveOpen50Doc, MainFileChannel)
422 SetStatus (FilterType, cDocSaveOpen50, not IsNull (oDoc))
424 if not IsNull (oDoc) then
425 &apos; oDoc.dispose
426 nCurrentAction = cDocClose
427 oDoc.close (true)
428 end If
429 end if
430 end If
431 Print #FileChannel, &quot;---&quot;
432 Close #FileChannel%
433 Exit Sub &apos; Without error
435 DOCTESTERROR:
436 If (nCurrentAction = cLogfileFailed) then
437 SetStatus (FilterType, cDocNew, False)
438 Exit Sub
439 else
440 LogState (False, GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ GetErrorMessage(nCurrentAction), FileChannel)
441 LogState (False, GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ GetErrorMessage(nCurrentAction), MainFileChannel)
442 SetStatus (FilterType, nCurrentAction, False)
443 Close #FileChannel%
444 End If
445 Exit Sub &apos; With error
446 End Sub
448 Sub MakeNewDoc (FilterType as Integer)
449 DIM oDoc as Object
450 Dim bError as Boolean
451 Dim nCurrentAction as Integer
452 On Local Error GoTo DOCTESTERROR2
453 nCurrentAction = cLogfileFailed
454 FileChannel% = OpenLogDat (GetLogFileName(FilterType))
455 nCurrentAction = cDocNew
456 &apos; oDoc = Documents.Add(GetDocFilter(FilterType))
457 oDoc = LoadDoc (&quot;private:factory/&quot; + GetDocFilter(FilterType or cFltNewDoc))
458 LogState (not IsNull (oDoc), GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, FileChannel)
459 LogState (not IsNull (oDoc), GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, MainFileChannel)
460 SetStatus (FilterType, cDocNew, not IsNull (oDoc))
461 if not IsNull (oDoc) then
462 nCurrentAction = cDocClose
463 &apos; oDoc.dispose
464 oDoc.close (true)
465 &apos; bError = true &apos; nur zum ¦bergang, weil bError = oDoc.CurrentController.frame.close nicht geht
466 &apos; LogState (bError, GetDocFilter(FilterType)+&quot; &quot;+ cMessageCloseDoc, FileChannel)
467 &apos; LogState (bError, GetDocFilter(FilterType)+&quot; &quot;+ cMessageCloseDoc, MainFileChannel)
468 &apos; SetStatus (FilterType, cDocClose, bError)
469 end If
470 Print #FileChannel, &quot;---&quot;
471 Close #FileChannel%
472 Exit Sub &apos; Without error
474 DOCTESTERROR2:
475 If (nCurrentAction = cLogfileFailed) then
476 SetStatus (FilterType, cDocNew, False)
477 Exit Sub
478 else
479 LogState (False, GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ GetErrorMessage(nCurrentAction), FileChannel)
480 LogState (False, GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ GetErrorMessage(nCurrentAction), MainFileChannel)
481 SetStatus (FilterType, nCurrentAction, False)
482 Close #FileChannel%
483 End If
484 Exit Sub &apos; With error
485 End Sub
487 Sub MakeChartTest (FilterType as Integer)
488 Dim oCharts as Object
489 Dim oDoc as Object
490 Dim oRange(0) as New com.sun.star.table.CellRangeAddress
491 Dim oRect as New com.sun.star.awt.Rectangle
492 const cChartName=&quot;TestChart&quot;
493 Dim bError as Boolean
494 Dim nCurrentAction as Integer
495 On Local Error GoTo CHARTTESTERROR
496 nCurrentAction = cLogfileFailed
497 FileChannel% = OpenLogDat (GetLogFileName(FilterType))
498 nCurrentAction = cDocNew
499 oDoc = LoadDoc (&quot;private:factory/&quot; + GetDocFilter(frmCalc or cFltNewDoc))
500 if not IsNull (oDoc) then
501 oCharts = oDoc.sheets(0).Charts
502 oCharts.AddNewByName (cChartName, oRect, oRange(), true, true)
503 bError=oCharts.HasByName(cChartName)
504 LogState (bError, GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, FileChannel)
505 LogState (bError, GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, MainFileChannel)
506 SetStatus (FilterType, cDocNew, bError)
507 &apos; oDoc.dispose
508 nCurrentAction = cDocClose
509 oDoc.close (true)
510 else
511 LogState (not IsNull (oDoc), GetDocFilter(frmCalc or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, FileChannel)
512 LogState (not IsNull (oDoc), GetDocFilter(frmCalc or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, MainFileChannel)
513 SetStatus (frmCalc, cDocNew, not IsNull (oDoc))
514 End if
515 Print #FileChannel, &quot;---&quot;
516 Close #FileChannel%
517 Exit Sub &apos; Without error
519 CHARTTESTERROR:
520 If (nCurrentAction = cLogfileFailed) then
521 SetStatus (FilterType, cDocNew, False)
522 Exit Sub
523 else
524 LogState (False, GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ GetErrorMessage(nCurrentAction), FileChannel)
525 LogState (False, GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ GetErrorMessage(nCurrentAction), MainFileChannel)
526 SetStatus (FilterType, nCurrentAction, False)
527 Close #FileChannel%
528 End If
529 Exit Sub &apos; With error
530 End Sub
532 Sub LogState (bState as Boolean, sText as String, nLocaleFileChannel as integer)
533 if bState then
534 Print #nLocaleFileChannel, sText+&quot; -&gt; ok&quot;
535 else
536 Print #nLocaleFileChannel, sText+&quot; -&gt; error&quot;
537 end If
538 end Sub
540 Function GetDocEndings (DocType as Integer) as String
541 Select Case ( DocType )
542 case frmWriter or cFlt8
543 GetDocEndings = &quot;odt&quot; &apos; Textdokument
544 case frmCalc or cFlt8
545 GetDocEndings = &quot;ods&quot; &apos;Tabellendokument
546 case frmImpress or cFlt8
547 GetDocEndings = &quot;odp&quot; &apos;PrÕsentation
548 case frmDraw or cFlt8
549 GetDocEndings = &quot;odg&quot; &apos;Zeichen
550 case frmHyperText, frmHyperText or cFlt50, frmHyperText or cFltXML
551 GetDocEndings = &quot;html&quot; &apos;Hypertext-Dokument
552 case frmWriter or cFlt50
553 GetDocEndings = &quot;sdw&quot; &apos; Textdokument 5.0
554 case frmCalc or cFlt50
555 GetDocEndings = &quot;sdc&quot; &apos;Tabellendokument 5.0
556 case frmImpress or cFlt50
557 GetDocEndings = &quot;sdd&quot; &apos;PrÕsentation 5.0
558 case frmDraw or cFlt50
559 GetDocEndings = &quot;sda&quot; &apos;Zeichen 5.0
560 case frmWriter or cFltXML
561 GetDocEndings = &quot;sxw&quot; &apos; Textdokument
562 case frmCalc or cFltXML
563 GetDocEndings = &quot;sxc&quot; &apos;Tabellendokument
564 case frmImpress or cFltXML
565 GetDocEndings = &quot;sxi&quot; &apos;PrÕsentation
566 case frmDraw or cFltXML
567 GetDocEndings = &quot;sxd&quot; &apos;Zeichen
568 case else
569 GetDocEndings = &quot;&quot;
570 end Select
571 end Function
573 Function GetDocFilter (DocType as Integer) as String
574 Select Case ( DocType )
575 case frmWriter or cFlt8
576 GetDocFilter = &quot;writer8&quot; &apos; Textdokument
577 case frmCalc or cFlt8
578 GetDocFilter = &quot;calc8&quot; &apos;Tabellendokument
579 case frmImpress or cFlt8
580 GetDocFilter = &quot;impress8&quot; &apos;Präsentation
581 case frmDraw or cFlt8
582 GetDocFilter = &quot;draw8&quot; &apos;Zeichen
583 case frmMath or cFlt8
584 GetDocFilter = &quot;math8&quot; &apos;Formel
586 case frmWriter or cFltXML
587 GetDocFilter = &quot;StarOffice XML (Writer)&quot; &apos; Textdokument
588 case frmCalc or cFltXML
589 GetDocFilter = &quot;StarOffice XML (Calc)&quot; &apos;Tabellendokument
590 case frmImpress or cFltXML
591 GetDocFilter = &quot;StarOffice XML (Impress)&quot; &apos;Präsentation
592 case frmDraw or cFltXML
593 GetDocFilter = &quot;StarOffice XML (Draw)&quot; &apos;Zeichen
594 case frmMath or cFltXML
595 GetDocFilter = &quot;StarOffice XML (Math)&quot; &apos;Formel
597 case frmHyperText, frmHyperText or cFlt50, frmHyperText or cFltXML
598 GetDocFilter = &quot;HTML&quot; &apos;Hypertext-Dokument
599 case frmWriter or cFlt50
600 GetDocFilter = &quot;StarWriter 5.0&quot; &apos; Textdokument 5.0
601 case frmCalc or cFlt50
602 GetDocFilter = &quot;StarCalc 5.0&quot; &apos;Tabellendokument 5.0
603 case frmImpress or cFlt50
604 GetDocFilter = &quot;StarImpress 5.0&quot; &apos;Präsentation 5.0
605 case frmDraw or cFlt50
606 GetDocFilter = &quot;StarDraw 5.0&quot; &apos;Zeichen 5.0
607 case frmMath or cFlt50
608 GetDocFilter = &quot;StarMath 5.0&quot; &apos;Formel 5.0
610 case frmWriter or cFltNewDoc
611 GetDocFilter = &quot;swriter&quot; &apos; Textdokument
612 case frmCalc or cFltNewDoc
613 GetDocFilter = &quot;scalc&quot; &apos;Tabellendokument
614 case frmMessage or cFltNewDoc
615 GetDocFilter = &quot;Message&quot; &apos;Nachricht
616 case frmImpress or cFltNewDoc
617 GetDocFilter = &quot;simpress&quot; &apos;Präsentation
618 case frmDraw or cFltNewDoc
619 GetDocFilter = &quot;sdraw&quot; &apos;Zeichen
620 case frmMath or cFltNewDoc
621 GetDocFilter = &quot;smath&quot; &apos;Formel
622 case frmImage or cFltNewDoc
623 GetDocFilter = &quot;simage&quot; &apos;Bild
624 case frmHyperText or cFltNewDoc
625 GetDocFilter = &quot;swriter/web&quot; &apos;Hypertext-Dokument
626 case frmChart or cFltNewDoc
627 GetDocFilter = &quot;schart&quot; &apos;Diagramm
628 case else
629 GetDocFilter = &quot;&quot;
630 end Select
631 end Function
633 Function GetLogFileName (DocType as Integer) as String
634 Select Case ( DocType )
635 case frmWriter
636 GetLogFileName = sSWLogFileName &apos; Textdokument
637 case frmCalc
638 GetLogFileName = sSCLogFileName &apos;Tabellendokument
639 case frmMessage
640 GetLogFileName = sSMessageLogFileName &apos;Nachricht
641 case frmImpress
642 GetLogFileName = sSDLogFileName &apos;PrÕsentation
643 case frmDraw
644 GetLogFileName = sSDrawLogFileName &apos;Zeichnen
645 case frmMath
646 GetLogFileName = sSMathLogFileName &apos;Formel
647 case frmImage
648 GetLogFileName = sSImDLogFileName &apos;Bild
649 case frmHyperText
650 GetLogFileName = sSHptLogFileName &apos;Hypertext-Dokument
651 case frmChart
652 GetLogFileName = sSChartLogFileName &apos;Diagramm
653 case frmJava
654 GetLogFileName = sJavaLogFileName &apos;Java
655 case frmDataBase
656 GetLogFileName = sSDBLogFileName &apos;Database
657 case frmExtension
658 GetLogFileName = sExtLogFileName &apos;Extension
659 case else
660 GetLogFileName = &quot;&quot;
661 end Select
662 end Function
664 Function GetErrorMessageOnAction (nAction as Integer) as String
665 Select Case ( nAction )
666 case cDocNew
667 GetErrorMessageOnAction = cMessageNewDoc
668 case cDocCut
669 GetErrorMessageOnAction = cMessageCutObj
670 case cDocPaste
671 GetErrorMessageOnAction = cMessagePasteObj
672 case cDocSaveOpen8
673 GetErrorMessageOnAction = cMessageSaveOpen8Doc
674 case cDocSaveOpenXML
675 GetErrorMessageOnAction = cMessageSaveOpenXMLDoc
676 case cDocSaveOpen50
677 GetErrorMessageOnAction = cMessageSaveOpen50Doc
678 case cDocClose
679 GetErrorMessageOnAction = cMessageCloseDoc
680 case else
681 GetErrorMessageOnAction = &quot;&quot;
682 end Select
683 end Function
685 Function IsFilterAvailable (FilterType as Integer) as boolean
686 IsFilterAvailable = true
687 if ((FilterType = (frmHyperText or cFlt50)) or (FilterType = (frmHyperText or cFltXML))) then
688 IsFilterAvailable = false
689 end if
690 End Function
692 Function TestJava (FilterType as Integer) as boolean
693 Dim oObj as Object
694 FileChannel% = OpenLogDat (GetLogFileName(FilterType))
695 oObj = createUnoService(cUnoJavaLoader)
696 LogState (not IsNull (oObj), &quot;Java &quot;+ cMessageNewDoc, FileChannel)
697 LogState (not IsNull (oObj), &quot;Java &quot;+ cMessageNewDoc, MainFileChannel)
698 SetStatus (FilterType, cDocNew, not IsNull (oObj))
700 Print #FileChannel, &quot;---&quot;
701 Close #FileChannel%
703 TestJava = not IsNull (oObj)
704 End Function
706 Sub CutAndPaste (DocType as Integer, oDoc as Object)
707 Dim sText as String
708 Dim oWin as Object
709 Dim oText as Object
710 Dim oView as Object
711 Dim bCutState as boolean, bPasteState as boolean
712 Select Case ( DocType )
713 case frmWriter
714 Dim oCursor as Object
716 sText = &quot;AutomaticText&quot;
717 oText = oDoc.GetText
718 oCursor = oText.CreateTextCursor
719 oText.InsertString(oCursor, sText, true) &apos; Cursor selektiert den Text
720 oView = oDoc.getCurrentController
721 oView.Select(oCursor)
723 if bMakeCutTest then
724 call CutText (oDoc)
726 if oText.GetString = &quot;&quot; Then
727 bCutState = True
728 else
729 bCutState = False
730 end If
731 SetStatus (DocType, cDocCut, bCutState)
732 LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessageCutObj, FileChannel)
733 LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessageCutObj, MainFileChannel)
734 end if
736 if bMakePasteTest and bMakeCutTest then
737 call PasteText (oDoc)
739 if oText.GetString = sText Then
740 bPasteState = True
741 else
742 bPasteState = False
743 end If
744 SetStatus (DocType, cDocPaste, bPasteState)
745 LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessagePasteObj, FileChannel)
746 LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessagePasteObj, MainFileChannel)
747 end if
749 case frmCalc
750 DIM oCell as Object
752 sText = &quot;AutomaticText&quot;
753 oCell = oDoc.Sheets(0).GetCellByPosition(0, 0)
754 oCell.String = sText
755 oView = oDoc.getCurrentController
756 oView.Select(oCell)
758 if bMakeCutTest then
759 call CutText (oDoc)
761 if oCell.String = &quot;&quot; Then
762 bCutState = True
763 else
764 bCutState = False
765 end If
766 SetStatus (DocType, cDocCut, bCutState)
767 LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessageCutObj, FileChannel)
768 LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessageCutObj, MainFileChannel)
769 end if
771 if bMakePasteTest and bMakeCutTest then
772 call PasteText (oDoc)
774 if oCell.String = sText Then
775 bPasteState = True
776 else
777 bPasteState = False
778 end If
779 SetStatus (DocType, cDocPaste, bPasteState)
780 LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessagePasteObj, FileChannel)
781 LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessagePasteObj, MainFileChannel)
782 end if
783 case frmMessage
784 case frmImpress, frmDraw
785 Dim oPage as Object
786 Dim oRect as Object
787 Dim xSize as Object
788 Dim xPoint as Object
789 Dim bObjState as Boolean
791 xSize = CreateUnoStruct (&quot;com.sun.star.awt.Size&quot;)
792 xPoint = CreateUnoStruct (&quot;com.sun.star.awt.Point&quot;)
793 xSize.Width = 2000
794 xSize.Height = 2000
795 xPoint.x = 10000
796 xPoint.y = 10000
797 oPage = oDoc.DrawPages(0)
798 oRect = oDoc.CreateInstance(&quot;com.sun.star.drawing.RectangleShape&quot;)
799 oRect.Size = xSize
800 oRect.Position = xPoint
801 oPage.add(oRect)
803 oView = oDoc.getCurrentController
804 oView.Select(oRect)
806 &apos; Prüft ob überhaupt ein Object angelegt wurde
807 if oPage.count = 1 Then
808 bObjState = True
809 else
810 bObjState = False
811 end If
813 if bMakeCutTest then
814 call CutText (oDoc)
816 if (oPage.count = 0) and bObjState Then
817 bCutState = True
818 else
819 bCutState = False
820 end If
821 SetStatus (DocType, cDocCut, bCutState)
822 LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessageCutObj, FileChannel)
823 LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessageCutObj, MainFileChannel)
824 end if
826 wait (1000) &apos;wait after cut
828 if bMakePasteTest and bMakeCutTest then
829 call PasteText (oDoc)
831 if (oPage.count = 1) and bObjState Then
832 bPasteState = True
833 else
834 bPasteState = False
835 end If
836 SetStatus (DocType, cDocPaste, bPasteState)
837 LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessagePasteObj, FileChannel)
838 LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessagePasteObj, MainFileChannel)
839 end if
840 case frmMath
841 case frmImage
842 case frmHyperText
843 case frmChart
844 end Select
845 end Sub
847 Sub LoadLibrary( LibName as String )
849 dim args(1)
850 dim arg as new com.sun.star.beans.PropertyValue
851 arg.Name = &quot;LibraryName&quot;
852 arg.Value = LibName
853 args(0) = arg
855 dim url as new com.sun.star.util.URL
856 dim trans as object
857 trans = createUnoService(&quot;com.sun.star.util.URLTransformer&quot; )
858 url.Complete = &quot;slot:6517&quot;
859 trans.parsestrict( url )
861 dim disp as object
862 disp = StarDesktop.currentFrame.queryDispatch( url, &quot;&quot;, 0 )
863 disp.dispatch( url, args() )
865 End Sub
867 Sub LoadDoc (DocName as String) as Object
868 dim trans as object
869 trans = createUnoService(&quot;com.sun.star.util.URLTransformer&quot; )
870 url = createUnoStruct(&quot;com.sun.star.util.URL&quot; )
871 url.Complete = DocName
872 if Left(DocName, 5 ) &lt;&gt; &quot;file:&quot; then
873 trans.parsestrict( url )
874 endif
876 Dim aPropArray(0) as Object
877 aPropArray(0) = CreateUnoStruct(&quot;com.sun.star.beans.PropertyValue&quot;)
878 aPropArray(0).Name = &quot;OpenFlags&quot;
879 aPropArray(0).Value = &quot;S&quot;
881 dim doc as object
882 dim noargs()
883 doc = StarDesktop.loadComponentFromURL( url.Complete, &quot;_blank&quot;, 0, aPropArray() ) &apos; XModel
884 LoadDoc = doc
885 End Sub
887 Sub SaveDoc (DocName as String, oDoc as Object, sFilterName as string )
888 dim trans as object
889 trans = createUnoService(&quot;com.sun.star.util.URLTransformer&quot; )
890 url = createUnoStruct(&quot;com.sun.star.util.URL&quot; )
891 url.Complete = DocName
892 if Left(DocName, 5 ) &lt;&gt; &quot;file:&quot; then
893 trans.parsestrict( url )
894 endif
896 if not (sFilterName = &quot;&quot;) then
897 Dim aPropArray(0) as Object
898 aPropArray(0) = CreateUnoStruct(&quot;com.sun.star.beans.PropertyValue&quot;)
899 aPropArray(0).Name = &quot;FilterName&quot;
900 aPropArray(0).Value = sFilterName
902 oDoc.storeAsURL( url.Complete, aPropArray() )
903 else
904 MessageBox &quot;Filtername is unknown!&quot;
905 end if
906 end Sub
907 </script:module>