summaryrefslogtreecommitdiff
path: root/smoketestoo_native/data/scripts/Test_10er.xba
blob: b475dfe53b42a6532defcec02f4964fb1f0253b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Test_10er" script:language="StarBasic">REM  10er Test

const sSWLogFileName = &quot;swlog.dat&quot;, sSCLogFileName = &quot;sclog.dat&quot;
const sSDLogFileName = &quot;sdlog.dat&quot;, sSMathLogFileName = &quot;smalog.dat&quot;
const sSImDLogFileName = &quot;simlog.dat&quot;, sSChartLogFileName = &quot;schlog.dat&quot;
const sSHptLogFileName = &quot;shptlog.dat&quot;, sSMessageLogFileName = &quot;smeslog.dat&quot;
const sSDrawLogFileName = &quot;sdrwlog.dat&quot;, sJavaLogFileName = &quot;javalog.dat&quot;
const sSDBLogFileName = &quot;dblog.dat&quot;, sExtLogFileName = &quot;extlog.dat&quot;
const sLogFileName = &quot;log.dat&quot;
const cTempFileName = &quot;ttt&quot;

const cMessageSaveOpen8Doc = &quot;Save/Open open Documents (8.0)&quot;
const cMessageSaveOpenXMLDoc = &quot;Save/Open Document XML (6/7)&quot;
const cMessageSaveOpen50Doc = &quot;Save/Open Document 5.0&quot;
const cMessageNewDoc = &quot;New Document&quot;
const cMessageCloseDoc = &quot;Close Document&quot;
const cMessageCutObj = &quot;Cut Object&quot;
const cMessagePasteObj = &quot;Paste Object&quot;

Global sWorkPath$
Global sWorkPathURL$
Global FileChannel%
Global MainFileChannel%

Sub Main
	call TestAllDocs()
end Sub

Sub DeleteAllSavedFiles()
	Dim sFileName as String
	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmWriter)
	If FileExists (sFileName) then
		Kill (sFileName)
	End If
	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmCalc)
	If FileExists (sFileName) then
		Kill (sFileName)
	End If
	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmImpress)
	If FileExists (sFileName) then
		Kill (sFileName)
	End If
	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmDraw)
	If FileExists (sFileName) then
		Kill (sFileName)
	End If
	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmHyperText)
	If FileExists (sFileName) then
		Kill (sFileName)
	End If
	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmWriter or cFltXML)
	If FileExists (sFileName) then
		Kill (sFileName)
	End If
	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmCalc or cFltXML)
	If FileExists (sFileName) then
		Kill (sFileName)
	End If
	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmImpress or cFltXML)
	If FileExists (sFileName) then
		Kill (sFileName)
	End If
	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmDraw or cFltXML)
	If FileExists (sFileName) then
		Kill (sFileName)
	End If	
	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmWriter or cFlt50)
	If FileExists (sFileName) then
		Kill (sFileName)
	End If
	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmCalc or cFlt50)
	If FileExists (sFileName) then
		Kill (sFileName)
	End If
	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmImpress or cFlt50)
	If FileExists (sFileName) then
		Kill (sFileName)
	End If
	sFileName = sWorkPath+cTempFileName+&quot;.&quot;+GetDocEndings(frmDraw or cFlt50)
	If FileExists (sFileName) then
		Kill (sFileName)
	End If
End Sub

Sub DeleteAllLogFiles()
	If FileExists (sWorkPath+sLogFileName) then
		Kill (sWorkPath+sLogFileName)
	End If
	If FileExists (sWorkPath+sSWLogFileName) then
		Kill (sWorkPath+sSWLogFileName)
	End If
	If FileExists (sWorkPath+sSCLogFileName) then
		Kill (sWorkPath+sSCLogFileName)
	End If	
	If FileExists (sWorkPath+sSDLogFileName) then
		Kill (sWorkPath+sSDLogFileName)
	End If	
	If FileExists (sWorkPath+sSMathLogFileName) then
		Kill (sWorkPath+sSMathLogFileName)
	End If	
	If FileExists (sWorkPath+sSImDLogFileName) then
		Kill (sWorkPath+sSImDLogFileName)
	End If	
	If FileExists (sWorkPath+sSChartLogFileName) then
		Kill (sWorkPath+sSChartLogFileName)
	End If	
	If FileExists (sWorkPath+sSHptLogFileName) then
		Kill (sWorkPath+sSHptLogFileName)
	End If	
	If FileExists (sWorkPath+sSMessageLogFileName) then
		Kill (sWorkPath+sSMessageLogFileName)
	End If
	If FileExists (sWorkPath+sSDrawLogFileName) then
		Kill (sWorkPath+sSDrawLogFileName)
	End If
	If FileExists (sWorkPath+sJavaLogFileName) then
		Kill (sWorkPath+sJavaLogFileName)
	End If
	If FileExists (sWorkPath+sSDBLogFileName) then
		Kill (sWorkPath+sSDBLogFileName)
	End If
	If FileExists (sWorkPath+sExtLogFileName) then
		Kill (sWorkPath+sExtLogFileName)
	End If
end Sub

Function OpenLogDat (sFileName as String) as Integer
	Dim LocaleFileChannel%
	If FileExists (sWorkPath+sFileName) then
		Kill (sWorkPath+sFileName)
	End If	
	LocaleFileChannel% = Freefile 
	Open sWorkPath+sFileName For Output As LocaleFileChannel%
	OpenLogDat = LocaleFileChannel%
end Function

Function GetWorkPath as string
	sTemp = &quot;$(userpath)/temp/&quot;
	GetWorkPath = CreateUnoService(&quot;com.sun.star.config.SpecialConfigManager&quot;).SubstituteVariables(sTemp)
End Function

Function GetWorkURL as string
	sTemp = &quot;$(userurl)/temp/&quot;
	GetWorkURL = CreateUnoService(&quot;com.sun.star.config.SpecialConfigManager&quot;).SubstituteVariables(sTemp)
End Function

Function GetSystem (sTmpWorkPath as string) as string
	GetSystem = &quot;&quot;
	if InStr (sTmpWorkPath, &quot;:&quot;) then
		GetSystem = &quot;windows&quot;
	else
		GetSystem = &quot;unix&quot;
	End If
end Function

Function ConvertPathToWin (sTmpWorkPath as string) as string
	for i%=1 to Len(sTmpWorkPath)
		sTemp = Mid (sTmpWorkPath, i%, 1)
		if sTemp = &quot;/&quot; then
			sTmpWorkPath = Left (sTmpWorkPath, i%-1) + &quot;\&quot; + Right (sTmpWorkPath, Len(sTmpWorkPath)-i%)
		else
			if sTemp = &quot;|&quot; then
				sTmpWorkPath = Left (sTmpWorkPath, i%-1) + &quot;:&quot; + Right (sTmpWorkPath, Len(sTmpWorkPath)-i%)
			end If
		end If
	next i%
	ConvertPathToWin = sTmpWorkPath
end Function

Sub TestAllDocs()
DIM sDocURL as String, sDocPath as String
DIM nStrPos as Long

	sWorkPath = GetWorkPath
	sWorkPathURL = GetWorkURL
	
	if GetSystem (sWorkPath) = &quot;windows&quot; then
		sWorkPath = ConvertPathToWin (sWorkPath)
	end if
	
	&apos;search ExtensionURL
	sExtensionURL = sWorkPathURL
	If not FileExists (sExtensionURL + cExtensionFileName) then
		if bShowTable then
		    sDocURL = gOutPutDoc.URL
		    CompatibilityMode(true)
		    nStrPos = InStrRev (sDocURL, &quot;/&quot; )
   		    CompatibilityMode(false)
   	    	if nStrPos then
	   	        sDocURL = Left (sDocURL, nStrPos)
	   	        sExtensionURL = sDocURL
	        	If not FileExists (sExtensionURL + cExtensionFileName) then
	   				bMakeExtensionTest = false &apos; test is not possible then
   				end if
			else
				bMakeExtensionTest = false &apos; test is not possible then
   			end if

		else    
			bMakeExtensionTest = false &apos; test is not possible then
		end if

	end if 
		
	call DeleteAllSavedFiles()
	call DeleteAllLogFiles()
	MainFileChannel = OpenLogDat (sLogFileName)
    call WriteTestSequence (MainFileChannel)
	if bMakeWriterTest then
		call MakeDocTest (frmWriter)
	end if
	if bMakeCalcTest then
		call MakeDocTest (frmCalc)
	end if
	if bMakeImpressTest then
		call MakeDocTest (frmImpress)
	end if
	if bMakeDrawTest then
		call MakeDocTest (frmDraw)
	end if
	if bMakeHTMLTest then
		call MakeDocTest (frmHyperText)
	end if
	if bMakeChartTest then
		call MakeChartTest (frmChart)
	end if	
	if bMakeMathTest then
		call MakeNewDoc (frmMath)
	end if
	if bMakeJavaTest then
		call TestJava (frmJava)
	end if
	if bMakeDBTest then
		call Test_DB.TestDB (frmDataBase)
	end if
	if bMakeExtensionTest then
		call Test_Ext.TestExtensions (frmExtension)
	end if
	
	Close #MainFileChannel
end Sub

Sub WriteTestSequence (FileChannel as integer)
	Print #FileChannel, &quot;Sequence of testing&quot;
	
	if bMakeWriterTest then
		WriteTests (&quot;writer  : &quot;, true, FileChannel)
	end if
	if bMakeCalcTest then
		WriteTests (&quot;calc    : &quot;, true, FileChannel)
	end if
	if bMakeImpressTest then
		WriteTests (&quot;impress : &quot;, true, FileChannel)
	end if
	if bMakeDrawTest then
		WriteTests (&quot;draw    : &quot;, true, FileChannel)
	end if
	if bMakeHTMLTest then
		WriteTests (&quot;HTML    : &quot;, true, FileChannel)
	end if
	if bMakeChartTest then
		WriteTests (&quot;chart   : &quot;, false, FileChannel)
	end if	
	if bMakeMathTest then
		WriteTests (&quot;math    : &quot;, false, FileChannel)
	end if
	if bMakeJavaTest then
		WriteTests (&quot;Java    : &quot;, false, FileChannel)
	end if
	if bMakeDBTest then
		WriteDBTests (&quot;Database    : &quot;, FileChannel)
	end if
	if bMakeExtensionTest then
		WriteExtensionTests (&quot;Extension    : &quot;, FileChannel)
	end if
		
	Print #FileChannel
end Sub

Sub WriteTests (sText as string, bTestAll as boolean, nFileChannel as integer)
	Dim sWriteStr as string
	
	sWriteStr = sText
	sWriteStr = sWriteStr + &quot;new&quot;
	if bTestAll then
	if bMakeCutTest then
		sWriteStr = sWriteStr + &quot;, cut&quot;
	end if
	if bMakePasteTest then
		sWriteStr = sWriteStr + &quot;, paste&quot;
	end if
	if bMakeSaveOpen8Test then
		sWriteStr = sWriteStr + &quot;, save 8.0&quot;
	end if
	if bMakeSaveOpenXMLTest then
		sWriteStr = sWriteStr + &quot;, save XML&quot;
	end if
	if bMakeSaveOpen50Test then
		sWriteStr = sWriteStr + &quot;, save 5.0&quot;
	end if
	if bMakeSaveOpen8Test then
		sWriteStr = sWriteStr + &quot;, open 8.0&quot;
	end if
	if bMakeSaveOpenXMLTest then
		sWriteStr = sWriteStr + &quot;, open XML&quot;
	end if
	if bMakeSaveOpen50Test then
		sWriteStr = sWriteStr + &quot;, open 5.0&quot;
	end if
	end if
	
	sWriteStr = sWriteStr + &quot;, close&quot;
	
	Print #nFileChannel, sWriteStr
end Sub

Sub WriteDBTests (sText as string, nFileChannel as integer)
	Dim sWriteStr as string
	
	sWriteStr = sText
	sWriteStr = sWriteStr + &quot;open / services&quot;
	sWriteStr = sWriteStr + &quot;, insert&quot;
	sWriteStr = sWriteStr + &quot;, delete&quot;
	sWriteStr = sWriteStr + &quot;, seek&quot;
	sWriteStr = sWriteStr + &quot;, close&quot;
	
	Print #nFileChannel, sWriteStr
end Sub

Sub WriteExtensionTests (sText as string, nFileChannel as integer)
	Dim sWriteStr as string
	
	sWriteStr = sText
	sWriteStr = sWriteStr + &quot;services&quot;
	sWriteStr = sWriteStr + &quot;, install&quot;
	sWriteStr = sWriteStr + &quot;, uninstall&quot;
	
	Print #nFileChannel, sWriteStr
end Sub

Sub MakeDocTest (FilterType as Integer)
	Dim oDoc as Object
	Dim sFileNameXML$, sFileName50$, sFileName8$
	Dim bError as Boolean
	Dim nCurrentAction as Integer
	
	On Local Error GoTo DOCTESTERROR
	nCurrentAction = cLogfileFailed
	FileChannel% = OpenLogDat (GetLogFileName(FilterType))
	nCurrentAction = cDocNew
	oDoc = LoadDoc (&quot;private:factory/&quot; + GetDocFilter(FilterType or cFltNewDoc))
	LogState (not IsNull (oDoc), GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, FileChannel)
	LogState (not IsNull (oDoc), GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, MainFileChannel)
	SetStatus (FilterType, cDocNew, not IsNull (oDoc))
	if not IsNull (oDoc) then
		nCurrentAction = cDocCut
		call CutAndPaste(FilterType, oDoc)
&apos;		bError = oDoc.CurrentController.frame.close
		nCurrentAction = cDocSaveOpen8
		if bMakeSaveOpen8Test and IsFilterAvailable (FilterType or cFlt8) then
			sFileName8 = sWorkPathURL+cTempFileName+&quot;.&quot;+GetDocEndings(FilterType or cFlt8)
			SaveDoc (sFileName8, oDoc, GetDocFilter(FilterType or cFlt8))
		end if
		nCurrentAction = cDocSaveOpenXML
		if bMakeSaveOpenXMLTest and IsFilterAvailable (FilterType or cFltXML) then
			sFileNameXML = sWorkPathURL+cTempFileName+&quot;.&quot;+GetDocEndings(FilterType or cFltXML)
			SaveDoc (sFileNameXML, oDoc, GetDocFilter(FilterType or cFltXML))
		end if
		nCurrentAction = cDocSaveOpen50
		if bMakeSaveOpen50Test and IsFilterAvailable (FilterType or cFlt50) then
			sFileName50 = sWorkPathURL+cTempFileName+&quot;.&quot;+GetDocEndings(FilterType or cFlt50)
			SaveDoc (sFileName50, oDoc, GetDocFilter(FilterType or cFlt50))
		end if	
&apos;		oDoc.dispose
		nCurrentAction = cDocClose
		oDoc.close (true)
&apos;		bError = true &apos; nur zum ¦bergang, weil bError = oDoc.CurrentController.frame.close nicht geht
&apos;		LogState (bError, GetDocFilter(FilterType)+&quot; &quot;+ cMessageCloseDoc, FileChannel)
&apos;		LogState (bError, GetDocFilter(FilterType)+&quot; &quot;+ cMessageCloseDoc, MainFileChannel)
&apos;		SetStatus (FilterType, cDocClose, bError)
		nCurrentAction = cDocSaveOpen8
		if bMakeSaveOpen8Test and IsFilterAvailable (FilterType or cFlt8) then
			oDoc = LoadDoc (sFileName8)
			
&apos;			oDoc = Documents.open(sFileName)
			LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageSaveOpen8Doc, FileChannel)
			LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageSaveOpen8Doc, MainFileChannel)
			SetStatus (FilterType, cDocSaveOpen8, not IsNull (oDoc))
			
			if not IsNull (oDoc) then
&apos;				oDoc.dispose
				nCurrentAction = cDocClose
				oDoc.close (true)
			end If	
		end if
		
		nCurrentAction = cDocSaveOpenXML
		if bMakeSaveOpenXMLTest and IsFilterAvailable (FilterType or cFltXML) then
			oDoc = LoadDoc (sFileNameXML)
			
&apos;			oDoc = Documents.open(sFileName)
			LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageSaveOpenXMLDoc, FileChannel)
			LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageSaveOpenXMLDoc, MainFileChannel)
			SetStatus (FilterType, cDocSaveOpenXML, not IsNull (oDoc))
			
			if not IsNull (oDoc) then
&apos;				oDoc.dispose
				nCurrentAction = cDocClose
				oDoc.close (true)
			end If	
		end if
		
		nCurrentAction = cDocSaveOpen50
		if bMakeSaveOpen50Test and IsFilterAvailable (FilterType or cFlt50) then
			oDoc = LoadDoc (sFileName50)
			
&apos;			oDoc = Documents.open(sFileName)
			LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageSaveOpen50Doc, FileChannel)
			LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageSaveOpen50Doc, MainFileChannel)
			SetStatus (FilterType, cDocSaveOpen50, not IsNull (oDoc))
			
			if not IsNull (oDoc) then
&apos;				oDoc.dispose
				nCurrentAction = cDocClose
				oDoc.close (true)
			end If	
		end if
	end If		
	Print #FileChannel, &quot;---&quot;
	Close #FileChannel%
	Exit Sub &apos; Without error
	
	DOCTESTERROR:
	If 	(nCurrentAction = cLogfileFailed) then
		SetStatus (FilterType, cDocNew, False)
		Exit Sub
	else
		LogState (False, GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ GetErrorMessage(nCurrentAction), FileChannel)
		LogState (False, GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ GetErrorMessage(nCurrentAction), MainFileChannel)
		SetStatus (FilterType, nCurrentAction, False)
		Close #FileChannel%
	End If	
	Exit Sub &apos; With error
End Sub

Sub MakeNewDoc (FilterType as Integer)
	DIM oDoc as Object
	Dim bError as Boolean
	Dim nCurrentAction as Integer
	On Local Error GoTo DOCTESTERROR2
	nCurrentAction = cLogfileFailed
	FileChannel% = OpenLogDat (GetLogFileName(FilterType))
	nCurrentAction = cDocNew
&apos;	oDoc = Documents.Add(GetDocFilter(FilterType))
	oDoc = LoadDoc (&quot;private:factory/&quot; + GetDocFilter(FilterType or cFltNewDoc))
	LogState (not IsNull (oDoc), GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, FileChannel)
	LogState (not IsNull (oDoc), GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, MainFileChannel)
	SetStatus (FilterType, cDocNew, not IsNull (oDoc))
	if not IsNull (oDoc) then
		nCurrentAction = cDocClose
&apos;		oDoc.dispose
		oDoc.close (true)
&apos;		bError = true &apos; nur zum ¦bergang, weil bError = oDoc.CurrentController.frame.close nicht geht
&apos;		LogState (bError, GetDocFilter(FilterType)+&quot; &quot;+ cMessageCloseDoc, FileChannel)
&apos;		LogState (bError, GetDocFilter(FilterType)+&quot; &quot;+ cMessageCloseDoc, MainFileChannel)
&apos;		SetStatus (FilterType, cDocClose, bError)
	end	If
	Print #FileChannel, &quot;---&quot;
	Close #FileChannel%
	Exit Sub &apos; Without error
	
	DOCTESTERROR2:
	If 	(nCurrentAction = cLogfileFailed) then
		SetStatus (FilterType, cDocNew, False)
		Exit Sub
	else
		LogState (False, GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ GetErrorMessage(nCurrentAction), FileChannel)
		LogState (False, GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ GetErrorMessage(nCurrentAction), MainFileChannel)
		SetStatus (FilterType, nCurrentAction, False)
		Close #FileChannel%
	End If	
	Exit Sub &apos; With error
End Sub

Sub MakeChartTest (FilterType as Integer)
	Dim oCharts as Object
	Dim oDoc as Object
	Dim oRange(0) as New com.sun.star.table.CellRangeAddress
	Dim oRect as New com.sun.star.awt.Rectangle
	const cChartName=&quot;TestChart&quot;
	Dim bError as Boolean
	Dim nCurrentAction as Integer
	On Local Error GoTo CHARTTESTERROR
	nCurrentAction = cLogfileFailed
	FileChannel% = OpenLogDat (GetLogFileName(FilterType))
	nCurrentAction = cDocNew
	oDoc = LoadDoc (&quot;private:factory/&quot; + GetDocFilter(frmCalc or cFltNewDoc))
	if not IsNull (oDoc) then
		oCharts = oDoc.sheets(0).Charts
		oCharts.AddNewByName (cChartName, oRect, oRange(), true, true)
		bError=oCharts.HasByName(cChartName)
		LogState (bError, GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, FileChannel)
		LogState (bError, GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, MainFileChannel)
		SetStatus (FilterType, cDocNew, bError)
&apos;		oDoc.dispose
		nCurrentAction = cDocClose
		oDoc.close (true)
	else
		LogState (not IsNull (oDoc), GetDocFilter(frmCalc or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, FileChannel)
		LogState (not IsNull (oDoc), GetDocFilter(frmCalc or cFltNewDoc)+&quot; &quot;+ cMessageNewDoc, MainFileChannel)
		SetStatus (frmCalc, cDocNew, not IsNull (oDoc))
	End if
	Print #FileChannel, &quot;---&quot;
	Close #FileChannel%
	Exit Sub &apos; Without error
	
	CHARTTESTERROR:
	If 	(nCurrentAction = cLogfileFailed) then
		SetStatus (FilterType, cDocNew, False)
		Exit Sub
	else
		LogState (False, GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ GetErrorMessage(nCurrentAction), FileChannel)
		LogState (False, GetDocFilter(FilterType or cFltNewDoc)+&quot; &quot;+ GetErrorMessage(nCurrentAction), MainFileChannel)
		SetStatus (FilterType, nCurrentAction, False)
		Close #FileChannel%
	End If	
	Exit Sub &apos; With error
End Sub

Sub LogState (bState as Boolean, sText as String, nLocaleFileChannel as integer)
	if bState then
		Print #nLocaleFileChannel, sText+&quot; -&gt; ok&quot;
	else
		Print #nLocaleFileChannel, sText+&quot; -&gt; error&quot;
	end If	
end Sub

Function GetDocEndings (DocType as Integer) as String
	Select Case ( DocType )
		case frmWriter or cFlt8
			GetDocEndings = &quot;odt&quot; &apos; Textdokument 
		case frmCalc or cFlt8
			GetDocEndings = &quot;ods&quot; &apos;Tabellendokument 
		case frmImpress or cFlt8
			GetDocEndings = &quot;odp&quot; &apos;PrÕsentation 
		case frmDraw or cFlt8
			GetDocEndings = &quot;odg&quot; &apos;Zeichen
		case frmHyperText, frmHyperText or cFlt50, frmHyperText or cFltXML
			GetDocEndings = &quot;html&quot; &apos;Hypertext-Dokument
		case frmWriter or cFlt50
			GetDocEndings = &quot;sdw&quot; &apos; Textdokument 5.0
		case frmCalc or cFlt50
			GetDocEndings = &quot;sdc&quot; &apos;Tabellendokument 5.0
		case frmImpress or cFlt50
			GetDocEndings = &quot;sdd&quot; &apos;PrÕsentation 5.0
		case frmDraw or cFlt50
			GetDocEndings = &quot;sda&quot; &apos;Zeichen 5.0
		case frmWriter or cFltXML
			GetDocEndings = &quot;sxw&quot; &apos; Textdokument 
		case frmCalc or cFltXML
			GetDocEndings = &quot;sxc&quot; &apos;Tabellendokument 
		case frmImpress or cFltXML
			GetDocEndings = &quot;sxi&quot; &apos;PrÕsentation 
		case frmDraw or cFltXML
			GetDocEndings = &quot;sxd&quot; &apos;Zeichen
		case else
			GetDocEndings = &quot;&quot;
	end Select		
end Function

Function GetDocFilter (DocType as Integer) as String
	Select Case ( DocType )
		case frmWriter or cFlt8 
			GetDocFilter = &quot;writer8&quot; &apos; Textdokument 
		case frmCalc or cFlt8
			GetDocFilter = &quot;calc8&quot; &apos;Tabellendokument 
		case frmImpress or cFlt8
			GetDocFilter = &quot;impress8&quot; &apos;Präsentation 
		case frmDraw or cFlt8
			GetDocFilter = &quot;draw8&quot; &apos;Zeichen
		case frmMath or cFlt8
			GetDocFilter = &quot;math8&quot; &apos;Formel
			
		case frmWriter or cFltXML
			GetDocFilter = &quot;StarOffice XML (Writer)&quot; &apos; Textdokument 
		case frmCalc or cFltXML
			GetDocFilter = &quot;StarOffice XML (Calc)&quot; &apos;Tabellendokument 
		case frmImpress or cFltXML
			GetDocFilter = &quot;StarOffice XML (Impress)&quot; &apos;Präsentation 
		case frmDraw or cFltXML
			GetDocFilter = &quot;StarOffice XML (Draw)&quot; &apos;Zeichen
		case frmMath or cFltXML
			GetDocFilter = &quot;StarOffice XML (Math)&quot; &apos;Formel 
			
		case frmHyperText, frmHyperText or cFlt50, frmHyperText or cFltXML
			GetDocFilter = &quot;HTML&quot; &apos;Hypertext-Dokument
		case frmWriter or cFlt50
			GetDocFilter = &quot;StarWriter 5.0&quot; &apos; Textdokument 5.0
		case frmCalc or cFlt50
			GetDocFilter = &quot;StarCalc 5.0&quot; &apos;Tabellendokument 5.0
		case frmImpress or cFlt50
			GetDocFilter = &quot;StarImpress 5.0&quot; &apos;Präsentation 5.0
		case frmDraw or cFlt50
			GetDocFilter = &quot;StarDraw 5.0&quot; &apos;Zeichen 5.0
		case frmMath or cFlt50
			GetDocFilter = &quot;StarMath 5.0&quot; &apos;Formel 5.0
			
		case frmWriter or cFltNewDoc
			GetDocFilter = &quot;swriter&quot; &apos; Textdokument 
		case frmCalc or cFltNewDoc
			GetDocFilter = &quot;scalc&quot; &apos;Tabellendokument 
		case frmMessage or cFltNewDoc
			GetDocFilter = &quot;Message&quot; &apos;Nachricht 
		case frmImpress or cFltNewDoc
			GetDocFilter = &quot;simpress&quot; &apos;Präsentation 
		case frmDraw or cFltNewDoc
			GetDocFilter = &quot;sdraw&quot; &apos;Zeichen
		case frmMath or cFltNewDoc
			GetDocFilter = &quot;smath&quot; &apos;Formel 
		case frmImage or cFltNewDoc
			GetDocFilter = &quot;simage&quot; &apos;Bild 
		case frmHyperText or cFltNewDoc
			GetDocFilter = &quot;swriter/web&quot; &apos;Hypertext-Dokument
		case frmChart or cFltNewDoc
			GetDocFilter = &quot;schart&quot; &apos;Diagramm 			
		case else
			GetDocFilter = &quot;&quot;
	end Select		
end Function

Function GetLogFileName (DocType as Integer) as String
	Select Case ( DocType )
		case frmWriter 
			GetLogFileName = sSWLogFileName &apos; Textdokument 
		case frmCalc
			GetLogFileName = sSCLogFileName &apos;Tabellendokument 
		case frmMessage
			GetLogFileName = sSMessageLogFileName &apos;Nachricht 
		case frmImpress
			GetLogFileName = sSDLogFileName &apos;PrÕsentation 
		case frmDraw
			GetLogFileName = sSDrawLogFileName &apos;Zeichnen
		case frmMath
			GetLogFileName = sSMathLogFileName &apos;Formel 
		case frmImage
			GetLogFileName = sSImDLogFileName &apos;Bild 
		case frmHyperText
			GetLogFileName = sSHptLogFileName &apos;Hypertext-Dokument 
		case frmChart
			GetLogFileName = sSChartLogFileName &apos;Diagramm 
		case frmJava
			GetLogFileName = sJavaLogFileName &apos;Java
		case frmDataBase
			GetLogFileName = sSDBLogFileName &apos;Database	
		case frmExtension
			GetLogFileName = sExtLogFileName &apos;Extension	
		case else
			GetLogFileName = &quot;&quot;
	end Select		
end Function

Function GetErrorMessageOnAction (nAction as Integer) as String
	Select Case ( nAction )
		case cDocNew 
			GetErrorMessageOnAction = cMessageNewDoc 
		case cDocCut
			GetErrorMessageOnAction = cMessageCutObj 
		case cDocPaste
			GetErrorMessageOnAction = cMessagePasteObj 
		case cDocSaveOpen8
			GetErrorMessageOnAction = cMessageSaveOpen8Doc
		case cDocSaveOpenXML
			GetErrorMessageOnAction = cMessageSaveOpenXMLDoc
		case cDocSaveOpen50
			GetErrorMessageOnAction = cMessageSaveOpen50Doc
		case cDocClose
			GetErrorMessageOnAction = cMessageCloseDoc
		case else
			GetErrorMessageOnAction = &quot;&quot;
	end Select		
end Function

Function IsFilterAvailable (FilterType as Integer) as boolean
	IsFilterAvailable = true
	if ((FilterType = (frmHyperText or cFlt50)) or (FilterType = (frmHyperText or cFltXML))) then
		IsFilterAvailable = false
	end if
End Function

Function TestJava (FilterType as Integer) as boolean
	Dim oObj as Object
	FileChannel% = OpenLogDat (GetLogFileName(FilterType))
	oObj = createUnoService(cUnoJavaLoader)
	LogState (not IsNull (oObj), &quot;Java &quot;+ cMessageNewDoc, FileChannel)
	LogState (not IsNull (oObj), &quot;Java &quot;+ cMessageNewDoc, MainFileChannel)
	SetStatus (FilterType, cDocNew, not IsNull (oObj))
	
	Print #FileChannel, &quot;---&quot;
	Close #FileChannel%
	
	TestJava = not IsNull (oObj)
End Function

Sub CutAndPaste (DocType as Integer, oDoc as Object)
	Dim sText as String
	Dim oWin as Object
	Dim oText as Object
	Dim oView as Object
	Dim bCutState as boolean, bPasteState as boolean
	Select Case ( DocType )
		case frmWriter
			Dim oCursor as Object
			
			sText = &quot;AutomaticText&quot;
			oText = oDoc.GetText
			oCursor = oText.CreateTextCursor
			oText.InsertString(oCursor, sText, true) &apos; Cursor selektiert den Text
			oView = oDoc.getCurrentController
			oView.Select(oCursor)
			
			if bMakeCutTest then
			call CutText (oDoc)
			
			if oText.GetString = &quot;&quot; Then
				bCutState = True
			else
				bCutState = False
			end If
			SetStatus (DocType, cDocCut, bCutState)
			LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessageCutObj, FileChannel)
			LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessageCutObj, MainFileChannel)
			end if
			
			if bMakePasteTest and bMakeCutTest then
			call PasteText (oDoc)
			
			if oText.GetString = sText Then
				bPasteState = True
			else
				bPasteState = False
			end If
			SetStatus (DocType, cDocPaste, bPasteState)
			LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessagePasteObj, FileChannel)
			LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessagePasteObj, MainFileChannel)
			end if

		case frmCalc
			DIM oCell as Object
			
			sText = &quot;AutomaticText&quot;
			oCell = oDoc.Sheets(0).GetCellByPosition(0, 0)
			oCell.String = sText
			oView = oDoc.getCurrentController
			oView.Select(oCell)
			
			if bMakeCutTest then
			call CutText (oDoc)
			
			if oCell.String = &quot;&quot; Then
				bCutState = True
			else
				bCutState = False
			end If
			SetStatus (DocType, cDocCut, bCutState)
			LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessageCutObj, FileChannel)
			LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessageCutObj, MainFileChannel)
			end if
			
			if bMakePasteTest and bMakeCutTest then
			call PasteText (oDoc)
			
			if oCell.String = sText Then
				bPasteState = True
			else
				bPasteState = False
			end If
			SetStatus (DocType, cDocPaste, bPasteState)
			LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessagePasteObj, FileChannel)
			LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessagePasteObj, MainFileChannel)
			end if
		case frmMessage
		case frmImpress, frmDraw
			Dim oPage as Object
			Dim oRect as Object
			Dim xSize as Object
			Dim xPoint as Object
			Dim bObjState as Boolean
			
			xSize = CreateUnoStruct (&quot;com.sun.star.awt.Size&quot;)
			xPoint = CreateUnoStruct (&quot;com.sun.star.awt.Point&quot;)
			xSize.Width = 2000
			xSize.Height = 2000
			xPoint.x = 10000
			xPoint.y = 10000
			oPage = oDoc.DrawPages(0)
			oRect = oDoc.CreateInstance(&quot;com.sun.star.drawing.RectangleShape&quot;)
			oRect.Size = xSize
			oRect.Position = xPoint
			oPage.add(oRect)
			
			oView = oDoc.getCurrentController
			oView.Select(oRect)
			
			&apos; Prüft ob überhaupt ein Object angelegt wurde
			if oPage.count = 1 Then
				bObjState = True
			else
				bObjState = False
			end If
			
			if bMakeCutTest then			
			call CutText (oDoc)
			
			if (oPage.count = 0) and bObjState Then
				bCutState = True
			else
				bCutState = False
			end If
			SetStatus (DocType, cDocCut, bCutState)
			LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessageCutObj, FileChannel)
			LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessageCutObj, MainFileChannel)
			end if 

			wait (1000) &apos;wait after cut
			
			if bMakePasteTest and bMakeCutTest then
			call PasteText (oDoc)
			
			if (oPage.count = 1) and bObjState Then
				bPasteState = True
			else
				bPasteState = False
			end If
			SetStatus (DocType, cDocPaste, bPasteState)
			LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessagePasteObj, FileChannel)
			LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+&quot; &quot;+ cMessagePasteObj, MainFileChannel)
			end if
		case frmMath
		case frmImage
		case frmHyperText
		case frmChart
	end Select		
end Sub

Sub LoadLibrary( LibName as String )
	
	dim args(1)
	dim arg as new com.sun.star.beans.PropertyValue
	arg.Name = &quot;LibraryName&quot;
	arg.Value = LibName
	args(0) = arg
	
	dim url as new com.sun.star.util.URL
	dim trans as object
	trans = createUnoService(&quot;com.sun.star.util.URLTransformer&quot; )
	url.Complete = &quot;slot:6517&quot;
	trans.parsestrict( url )

	dim disp as object
	disp = StarDesktop.currentFrame.queryDispatch( url, &quot;&quot;, 0 )
	disp.dispatch( url, args() )
	
End Sub

Sub LoadDoc (DocName as String) as Object
	dim trans as object
	trans = createUnoService(&quot;com.sun.star.util.URLTransformer&quot; )
	url = createUnoStruct(&quot;com.sun.star.util.URL&quot; )
	url.Complete = DocName
	if Left(DocName, 5 ) &lt;&gt; &quot;file:&quot; then
	trans.parsestrict( url )
	endif
	
	Dim aPropArray(0) as Object
	aPropArray(0) = CreateUnoStruct(&quot;com.sun.star.beans.PropertyValue&quot;)
	aPropArray(0).Name = &quot;OpenFlags&quot;
	aPropArray(0).Value = &quot;S&quot;

	dim doc as object
	dim noargs()
	doc = StarDesktop.loadComponentFromURL( url.Complete, &quot;_blank&quot;, 0, aPropArray() )	&apos; XModel
	LoadDoc = doc
End Sub

Sub SaveDoc (DocName as String, oDoc as Object, sFilterName as string )
	dim trans as object
	trans = createUnoService(&quot;com.sun.star.util.URLTransformer&quot; )
	url = createUnoStruct(&quot;com.sun.star.util.URL&quot; )
	url.Complete = DocName
	if Left(DocName, 5 ) &lt;&gt; &quot;file:&quot; then
	trans.parsestrict( url )
	endif
	
	if not (sFilterName = &quot;&quot;) then
		Dim aPropArray(0) as Object
		aPropArray(0) = CreateUnoStruct(&quot;com.sun.star.beans.PropertyValue&quot;)
		aPropArray(0).Name = &quot;FilterName&quot;
		aPropArray(0).Value = sFilterName
	
		oDoc.storeAsURL( url.Complete, aPropArray() )
	else
		MessageBox &quot;Filtername is unknown!&quot;
	end if	
end Sub
</script:module>