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 =
"swlog.dat
", sSCLogFileName =
"sclog.dat
"
6 const sSDLogFileName =
"sdlog.dat
", sSMathLogFileName =
"smalog.dat
"
7 const sSImDLogFileName =
"simlog.dat
", sSChartLogFileName =
"schlog.dat
"
8 const sSHptLogFileName =
"shptlog.dat
", sSMessageLogFileName =
"smeslog.dat
"
9 const sSDrawLogFileName =
"sdrwlog.dat
", sJavaLogFileName =
"javalog.dat
"
10 const sSDBLogFileName =
"dblog.dat
", sExtLogFileName =
"extlog.dat
"
11 const sLogFileName =
"log.dat
"
12 const cTempFileName =
"ttt
"
14 const cMessageSaveOpen8Doc =
"Save/Open open Documents (
8.0)
"
15 const cMessageSaveOpenXMLDoc =
"Save/Open Document XML (
6/
7)
"
16 const cMessageSaveOpen50Doc =
"Save/Open Document
5.0"
17 const cMessageNewDoc =
"New Document
"
18 const cMessageCloseDoc =
"Close Document
"
19 const cMessageCutObj =
"Cut Object
"
20 const cMessagePasteObj =
"Paste Object
"
25 Global MainFileChannel%
31 Sub DeleteAllSavedFiles()
32 Dim sFileName as String
33 sFileName = sWorkPath+cTempFileName+
".
"+GetDocEndings(frmWriter)
34 If FileExists (sFileName) then
37 sFileName = sWorkPath+cTempFileName+
".
"+GetDocEndings(frmCalc)
38 If FileExists (sFileName) then
41 sFileName = sWorkPath+cTempFileName+
".
"+GetDocEndings(frmImpress)
42 If FileExists (sFileName) then
45 sFileName = sWorkPath+cTempFileName+
".
"+GetDocEndings(frmDraw)
46 If FileExists (sFileName) then
49 sFileName = sWorkPath+cTempFileName+
".
"+GetDocEndings(frmHyperText)
50 If FileExists (sFileName) then
53 sFileName = sWorkPath+cTempFileName+
".
"+GetDocEndings(frmWriter or cFltXML)
54 If FileExists (sFileName) then
57 sFileName = sWorkPath+cTempFileName+
".
"+GetDocEndings(frmCalc or cFltXML)
58 If FileExists (sFileName) then
61 sFileName = sWorkPath+cTempFileName+
".
"+GetDocEndings(frmImpress or cFltXML)
62 If FileExists (sFileName) then
65 sFileName = sWorkPath+cTempFileName+
".
"+GetDocEndings(frmDraw or cFltXML)
66 If FileExists (sFileName) then
69 sFileName = sWorkPath+cTempFileName+
".
"+GetDocEndings(frmWriter or cFlt50)
70 If FileExists (sFileName) then
73 sFileName = sWorkPath+cTempFileName+
".
"+GetDocEndings(frmCalc or cFlt50)
74 If FileExists (sFileName) then
77 sFileName = sWorkPath+cTempFileName+
".
"+GetDocEndings(frmImpress or cFlt50)
78 If FileExists (sFileName) then
81 sFileName = sWorkPath+cTempFileName+
".
"+GetDocEndings(frmDraw or cFlt50)
82 If FileExists (sFileName) then
87 Sub DeleteAllLogFiles()
88 If FileExists (sWorkPath+sLogFileName) then
89 Kill (sWorkPath+sLogFileName)
91 If FileExists (sWorkPath+sSWLogFileName) then
92 Kill (sWorkPath+sSWLogFileName)
94 If FileExists (sWorkPath+sSCLogFileName) then
95 Kill (sWorkPath+sSCLogFileName)
97 If FileExists (sWorkPath+sSDLogFileName) then
98 Kill (sWorkPath+sSDLogFileName)
100 If FileExists (sWorkPath+sSMathLogFileName) then
101 Kill (sWorkPath+sSMathLogFileName)
103 If FileExists (sWorkPath+sSImDLogFileName) then
104 Kill (sWorkPath+sSImDLogFileName)
106 If FileExists (sWorkPath+sSChartLogFileName) then
107 Kill (sWorkPath+sSChartLogFileName)
109 If FileExists (sWorkPath+sSHptLogFileName) then
110 Kill (sWorkPath+sSHptLogFileName)
112 If FileExists (sWorkPath+sSMessageLogFileName) then
113 Kill (sWorkPath+sSMessageLogFileName)
115 If FileExists (sWorkPath+sSDrawLogFileName) then
116 Kill (sWorkPath+sSDrawLogFileName)
118 If FileExists (sWorkPath+sJavaLogFileName) then
119 Kill (sWorkPath+sJavaLogFileName)
121 If FileExists (sWorkPath+sSDBLogFileName) then
122 Kill (sWorkPath+sSDBLogFileName)
124 If FileExists (sWorkPath+sExtLogFileName) then
125 Kill (sWorkPath+sExtLogFileName)
129 Function OpenLogDat (sFileName as String) as Integer
130 Dim LocaleFileChannel%
131 If FileExists (sWorkPath+sFileName) then
132 Kill (sWorkPath+sFileName)
134 LocaleFileChannel% = Freefile
135 Open sWorkPath+sFileName For Output As LocaleFileChannel%
136 OpenLogDat = LocaleFileChannel%
139 Function GetWorkPath as string
140 sTemp =
"$(userpath)/temp/
"
141 GetWorkPath = CreateUnoService(
"com.sun.star.config.SpecialConfigManager
").SubstituteVariables(sTemp)
144 Function GetWorkURL as string
145 sTemp =
"$(userurl)/temp/
"
146 GetWorkURL = CreateUnoService(
"com.sun.star.config.SpecialConfigManager
").SubstituteVariables(sTemp)
149 Function GetSystem (sTmpWorkPath as string) as string
150 GetSystem =
""
151 if InStr (sTmpWorkPath,
":
") then
152 GetSystem =
"windows
"
154 GetSystem =
"unix
"
158 Function ConvertPathToWin (sTmpWorkPath as string) as string
159 for i%=
1 to Len(sTmpWorkPath)
160 sTemp = Mid (sTmpWorkPath, i%,
1)
161 if sTemp =
"/
" then
162 sTmpWorkPath = Left (sTmpWorkPath, i%-
1) +
"\
" + Right (sTmpWorkPath, Len(sTmpWorkPath)-i%)
164 if sTemp =
"|
" then
165 sTmpWorkPath = Left (sTmpWorkPath, i%-
1) +
":
" + Right (sTmpWorkPath, Len(sTmpWorkPath)-i%)
169 ConvertPathToWin = sTmpWorkPath
173 DIM sDocURL as String, sDocPath as String
176 sWorkPath = GetWorkPath
177 sWorkPathURL = GetWorkURL
179 if GetSystem (sWorkPath) =
"windows
" then
180 sWorkPath = ConvertPathToWin (sWorkPath)
183 'search ExtensionURL
184 sExtensionURL = sWorkPathURL
185 If not FileExists (sExtensionURL + cExtensionFileName) then
187 sDocURL = gOutPutDoc.URL
188 CompatibilityMode(true)
189 nStrPos = InStrRev (sDocURL,
"/
" )
190 CompatibilityMode(false)
192 sDocURL = Left (sDocURL, nStrPos)
193 sExtensionURL = sDocURL
194 If not FileExists (sExtensionURL + cExtensionFileName) then
195 bMakeExtensionTest = false
' test is not possible then
198 bMakeExtensionTest = false
' test is not possible then
202 bMakeExtensionTest = false
' test is not possible then
207 call DeleteAllSavedFiles()
208 call DeleteAllLogFiles()
209 MainFileChannel = OpenLogDat (sLogFileName)
210 call WriteTestSequence (MainFileChannel)
211 if bMakeWriterTest then
212 call MakeDocTest (frmWriter)
214 if bMakeCalcTest then
215 call MakeDocTest (frmCalc)
217 if bMakeImpressTest then
218 call MakeDocTest (frmImpress)
220 if bMakeDrawTest then
221 call MakeDocTest (frmDraw)
223 if bMakeHTMLTest then
224 call MakeDocTest (frmHyperText)
226 if bMakeChartTest then
227 call MakeChartTest (frmChart)
229 if bMakeMathTest then
230 call MakeNewDoc (frmMath)
232 if bMakeJavaTest then
233 call TestJava (frmJava)
236 call Test_DB.TestDB (frmDataBase)
238 if bMakeExtensionTest then
239 call Test_Ext.TestExtensions (frmExtension)
242 Close #MainFileChannel
245 Sub WriteTestSequence (FileChannel as integer)
246 Print #FileChannel,
"Sequence of testing
"
248 if bMakeWriterTest then
249 WriteTests (
"writer :
", true, FileChannel)
251 if bMakeCalcTest then
252 WriteTests (
"calc :
", true, FileChannel)
254 if bMakeImpressTest then
255 WriteTests (
"impress :
", true, FileChannel)
257 if bMakeDrawTest then
258 WriteTests (
"draw :
", true, FileChannel)
260 if bMakeHTMLTest then
261 WriteTests (
"HTML :
", true, FileChannel)
263 if bMakeChartTest then
264 WriteTests (
"chart :
", false, FileChannel)
266 if bMakeMathTest then
267 WriteTests (
"math :
", false, FileChannel)
269 if bMakeJavaTest then
270 WriteTests (
"Java :
", false, FileChannel)
273 WriteDBTests (
"Database :
", FileChannel)
275 if bMakeExtensionTest then
276 WriteExtensionTests (
"Extension :
", FileChannel)
282 Sub WriteTests (sText as string, bTestAll as boolean, nFileChannel as integer)
283 Dim sWriteStr as string
286 sWriteStr = sWriteStr +
"new
"
289 sWriteStr = sWriteStr +
", cut
"
291 if bMakePasteTest then
292 sWriteStr = sWriteStr +
", paste
"
294 if bMakeSaveOpen8Test then
295 sWriteStr = sWriteStr +
", save
8.0"
297 if bMakeSaveOpenXMLTest then
298 sWriteStr = sWriteStr +
", save XML
"
300 if bMakeSaveOpen50Test then
301 sWriteStr = sWriteStr +
", save
5.0"
303 if bMakeSaveOpen8Test then
304 sWriteStr = sWriteStr +
", open
8.0"
306 if bMakeSaveOpenXMLTest then
307 sWriteStr = sWriteStr +
", open XML
"
309 if bMakeSaveOpen50Test then
310 sWriteStr = sWriteStr +
", open
5.0"
314 sWriteStr = sWriteStr +
", close
"
316 Print #nFileChannel, sWriteStr
319 Sub WriteDBTests (sText as string, nFileChannel as integer)
320 Dim sWriteStr as string
323 sWriteStr = sWriteStr +
"open / services
"
324 sWriteStr = sWriteStr +
", insert
"
325 sWriteStr = sWriteStr +
", delete
"
326 sWriteStr = sWriteStr +
", seek
"
327 sWriteStr = sWriteStr +
", close
"
329 Print #nFileChannel, sWriteStr
332 Sub WriteExtensionTests (sText as string, nFileChannel as integer)
333 Dim sWriteStr as string
336 sWriteStr = sWriteStr +
"services
"
337 sWriteStr = sWriteStr +
", install
"
338 sWriteStr = sWriteStr +
", uninstall
"
340 Print #nFileChannel, sWriteStr
343 Sub MakeDocTest (FilterType as Integer)
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 (
"private:factory/
" + GetDocFilter(FilterType or cFltNewDoc))
354 LogState (not IsNull (oDoc), GetDocFilter(FilterType or cFltNewDoc)+
" "+ cMessageNewDoc, FileChannel)
355 LogState (not IsNull (oDoc), GetDocFilter(FilterType or cFltNewDoc)+
" "+ cMessageNewDoc, MainFileChannel)
356 SetStatus (FilterType, cDocNew, not IsNull (oDoc))
357 if not IsNull (oDoc) then
358 nCurrentAction = cDocCut
359 call CutAndPaste(FilterType, oDoc)
360 ' bError = oDoc.CurrentController.frame.close
361 nCurrentAction = cDocSaveOpen8
362 if bMakeSaveOpen8Test and IsFilterAvailable (FilterType or cFlt8) then
363 sFileName8 = sWorkPathURL+cTempFileName+
".
"+GetDocEndings(FilterType or cFlt8)
364 SaveDoc (sFileName8, oDoc, GetDocFilter(FilterType or cFlt8))
366 nCurrentAction = cDocSaveOpenXML
367 if bMakeSaveOpenXMLTest and IsFilterAvailable (FilterType or cFltXML) then
368 sFileNameXML = sWorkPathURL+cTempFileName+
".
"+GetDocEndings(FilterType or cFltXML)
369 SaveDoc (sFileNameXML, oDoc, GetDocFilter(FilterType or cFltXML))
371 nCurrentAction = cDocSaveOpen50
372 if bMakeSaveOpen50Test and IsFilterAvailable (FilterType or cFlt50) then
373 sFileName50 = sWorkPathURL+cTempFileName+
".
"+GetDocEndings(FilterType or cFlt50)
374 SaveDoc (sFileName50, oDoc, GetDocFilter(FilterType or cFlt50))
377 nCurrentAction = cDocClose
379 ' bError = true
' nur zum ¦bergang, weil bError = oDoc.CurrentController.frame.close nicht geht
380 ' LogState (bError, GetDocFilter(FilterType)+
" "+ cMessageCloseDoc, FileChannel)
381 ' LogState (bError, GetDocFilter(FilterType)+
" "+ cMessageCloseDoc, MainFileChannel)
382 ' SetStatus (FilterType, cDocClose, bError)
383 nCurrentAction = cDocSaveOpen8
384 if bMakeSaveOpen8Test and IsFilterAvailable (FilterType or cFlt8) then
385 oDoc = LoadDoc (sFileName8)
387 ' oDoc = Documents.open(sFileName)
388 LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+
" "+ cMessageSaveOpen8Doc, FileChannel)
389 LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+
" "+ cMessageSaveOpen8Doc, MainFileChannel)
390 SetStatus (FilterType, cDocSaveOpen8, not IsNull (oDoc))
392 if not IsNull (oDoc) then
394 nCurrentAction = cDocClose
399 nCurrentAction = cDocSaveOpenXML
400 if bMakeSaveOpenXMLTest and IsFilterAvailable (FilterType or cFltXML) then
401 oDoc = LoadDoc (sFileNameXML)
403 ' oDoc = Documents.open(sFileName)
404 LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+
" "+ cMessageSaveOpenXMLDoc, FileChannel)
405 LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+
" "+ cMessageSaveOpenXMLDoc, MainFileChannel)
406 SetStatus (FilterType, cDocSaveOpenXML, not IsNull (oDoc))
408 if not IsNull (oDoc) then
410 nCurrentAction = cDocClose
415 nCurrentAction = cDocSaveOpen50
416 if bMakeSaveOpen50Test and IsFilterAvailable (FilterType or cFlt50) then
417 oDoc = LoadDoc (sFileName50)
419 ' oDoc = Documents.open(sFileName)
420 LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+
" "+ cMessageSaveOpen50Doc, FileChannel)
421 LogState (not IsNull (oDoc),GetDocFilter(FilterType or cFltNewDoc)+
" "+ cMessageSaveOpen50Doc, MainFileChannel)
422 SetStatus (FilterType, cDocSaveOpen50, not IsNull (oDoc))
424 if not IsNull (oDoc) then
426 nCurrentAction = cDocClose
431 Print #FileChannel,
"---
"
433 Exit Sub
' Without error
436 If (nCurrentAction = cLogfileFailed) then
437 SetStatus (FilterType, cDocNew, False)
440 LogState (False, GetDocFilter(FilterType or cFltNewDoc)+
" "+ GetErrorMessage(nCurrentAction), FileChannel)
441 LogState (False, GetDocFilter(FilterType or cFltNewDoc)+
" "+ GetErrorMessage(nCurrentAction), MainFileChannel)
442 SetStatus (FilterType, nCurrentAction, False)
445 Exit Sub
' With error
448 Sub MakeNewDoc (FilterType as Integer)
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 ' oDoc = Documents.Add(GetDocFilter(FilterType))
457 oDoc = LoadDoc (
"private:factory/
" + GetDocFilter(FilterType or cFltNewDoc))
458 LogState (not IsNull (oDoc), GetDocFilter(FilterType or cFltNewDoc)+
" "+ cMessageNewDoc, FileChannel)
459 LogState (not IsNull (oDoc), GetDocFilter(FilterType or cFltNewDoc)+
" "+ cMessageNewDoc, MainFileChannel)
460 SetStatus (FilterType, cDocNew, not IsNull (oDoc))
461 if not IsNull (oDoc) then
462 nCurrentAction = cDocClose
465 ' bError = true
' nur zum ¦bergang, weil bError = oDoc.CurrentController.frame.close nicht geht
466 ' LogState (bError, GetDocFilter(FilterType)+
" "+ cMessageCloseDoc, FileChannel)
467 ' LogState (bError, GetDocFilter(FilterType)+
" "+ cMessageCloseDoc, MainFileChannel)
468 ' SetStatus (FilterType, cDocClose, bError)
470 Print #FileChannel,
"---
"
472 Exit Sub
' Without error
475 If (nCurrentAction = cLogfileFailed) then
476 SetStatus (FilterType, cDocNew, False)
479 LogState (False, GetDocFilter(FilterType or cFltNewDoc)+
" "+ GetErrorMessage(nCurrentAction), FileChannel)
480 LogState (False, GetDocFilter(FilterType or cFltNewDoc)+
" "+ GetErrorMessage(nCurrentAction), MainFileChannel)
481 SetStatus (FilterType, nCurrentAction, False)
484 Exit Sub
' With error
487 Sub MakeChartTest (FilterType as Integer)
488 Dim oCharts 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=
"TestChart
"
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 (
"private:factory/
" + 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)+
" "+ cMessageNewDoc, FileChannel)
505 LogState (bError, GetDocFilter(FilterType or cFltNewDoc)+
" "+ cMessageNewDoc, MainFileChannel)
506 SetStatus (FilterType, cDocNew, bError)
508 nCurrentAction = cDocClose
511 LogState (not IsNull (oDoc), GetDocFilter(frmCalc or cFltNewDoc)+
" "+ cMessageNewDoc, FileChannel)
512 LogState (not IsNull (oDoc), GetDocFilter(frmCalc or cFltNewDoc)+
" "+ cMessageNewDoc, MainFileChannel)
513 SetStatus (frmCalc, cDocNew, not IsNull (oDoc))
515 Print #FileChannel,
"---
"
517 Exit Sub
' Without error
520 If (nCurrentAction = cLogfileFailed) then
521 SetStatus (FilterType, cDocNew, False)
524 LogState (False, GetDocFilter(FilterType or cFltNewDoc)+
" "+ GetErrorMessage(nCurrentAction), FileChannel)
525 LogState (False, GetDocFilter(FilterType or cFltNewDoc)+
" "+ GetErrorMessage(nCurrentAction), MainFileChannel)
526 SetStatus (FilterType, nCurrentAction, False)
529 Exit Sub
' With error
532 Sub LogState (bState as Boolean, sText as String, nLocaleFileChannel as integer)
534 Print #nLocaleFileChannel, sText+
" -
> ok
"
536 Print #nLocaleFileChannel, sText+
" -
> error
"
540 Function GetDocEndings (DocType as Integer) as String
541 Select Case ( DocType )
542 case frmWriter or cFlt8
543 GetDocEndings =
"odt
" ' Textdokument
544 case frmCalc or cFlt8
545 GetDocEndings =
"ods
" 'Tabellendokument
546 case frmImpress or cFlt8
547 GetDocEndings =
"odp
" 'PrÕsentation
548 case frmDraw or cFlt8
549 GetDocEndings =
"odg
" 'Zeichen
550 case frmHyperText, frmHyperText or cFlt50, frmHyperText or cFltXML
551 GetDocEndings =
"html
" 'Hypertext-Dokument
552 case frmWriter or cFlt50
553 GetDocEndings =
"sdw
" ' Textdokument
5.0
554 case frmCalc or cFlt50
555 GetDocEndings =
"sdc
" 'Tabellendokument
5.0
556 case frmImpress or cFlt50
557 GetDocEndings =
"sdd
" 'PrÕsentation
5.0
558 case frmDraw or cFlt50
559 GetDocEndings =
"sda
" 'Zeichen
5.0
560 case frmWriter or cFltXML
561 GetDocEndings =
"sxw
" ' Textdokument
562 case frmCalc or cFltXML
563 GetDocEndings =
"sxc
" 'Tabellendokument
564 case frmImpress or cFltXML
565 GetDocEndings =
"sxi
" 'PrÕsentation
566 case frmDraw or cFltXML
567 GetDocEndings =
"sxd
" 'Zeichen
569 GetDocEndings =
""
573 Function GetDocFilter (DocType as Integer) as String
574 Select Case ( DocType )
575 case frmWriter or cFlt8
576 GetDocFilter =
"writer8
" ' Textdokument
577 case frmCalc or cFlt8
578 GetDocFilter =
"calc8
" 'Tabellendokument
579 case frmImpress or cFlt8
580 GetDocFilter =
"impress8
" 'Präsentation
581 case frmDraw or cFlt8
582 GetDocFilter =
"draw8
" 'Zeichen
583 case frmMath or cFlt8
584 GetDocFilter =
"math8
" 'Formel
586 case frmWriter or cFltXML
587 GetDocFilter =
"StarOffice XML (Writer)
" ' Textdokument
588 case frmCalc or cFltXML
589 GetDocFilter =
"StarOffice XML (Calc)
" 'Tabellendokument
590 case frmImpress or cFltXML
591 GetDocFilter =
"StarOffice XML (Impress)
" 'Präsentation
592 case frmDraw or cFltXML
593 GetDocFilter =
"StarOffice XML (Draw)
" 'Zeichen
594 case frmMath or cFltXML
595 GetDocFilter =
"StarOffice XML (Math)
" 'Formel
597 case frmHyperText, frmHyperText or cFlt50, frmHyperText or cFltXML
598 GetDocFilter =
"HTML
" 'Hypertext-Dokument
599 case frmWriter or cFlt50
600 GetDocFilter =
"StarWriter
5.0" ' Textdokument
5.0
601 case frmCalc or cFlt50
602 GetDocFilter =
"StarCalc
5.0" 'Tabellendokument
5.0
603 case frmImpress or cFlt50
604 GetDocFilter =
"StarImpress
5.0" 'Präsentation
5.0
605 case frmDraw or cFlt50
606 GetDocFilter =
"StarDraw
5.0" 'Zeichen
5.0
607 case frmMath or cFlt50
608 GetDocFilter =
"StarMath
5.0" 'Formel
5.0
610 case frmWriter or cFltNewDoc
611 GetDocFilter =
"swriter
" ' Textdokument
612 case frmCalc or cFltNewDoc
613 GetDocFilter =
"scalc
" 'Tabellendokument
614 case frmMessage or cFltNewDoc
615 GetDocFilter =
"Message
" 'Nachricht
616 case frmImpress or cFltNewDoc
617 GetDocFilter =
"simpress
" 'Präsentation
618 case frmDraw or cFltNewDoc
619 GetDocFilter =
"sdraw
" 'Zeichen
620 case frmMath or cFltNewDoc
621 GetDocFilter =
"smath
" 'Formel
622 case frmImage or cFltNewDoc
623 GetDocFilter =
"simage
" 'Bild
624 case frmHyperText or cFltNewDoc
625 GetDocFilter =
"swriter/web
" 'Hypertext-Dokument
626 case frmChart or cFltNewDoc
627 GetDocFilter =
"schart
" 'Diagramm
629 GetDocFilter =
""
633 Function GetLogFileName (DocType as Integer) as String
634 Select Case ( DocType )
636 GetLogFileName = sSWLogFileName
' Textdokument
638 GetLogFileName = sSCLogFileName
'Tabellendokument
640 GetLogFileName = sSMessageLogFileName
'Nachricht
642 GetLogFileName = sSDLogFileName
'PrÕsentation
644 GetLogFileName = sSDrawLogFileName
'Zeichnen
646 GetLogFileName = sSMathLogFileName
'Formel
648 GetLogFileName = sSImDLogFileName
'Bild
650 GetLogFileName = sSHptLogFileName
'Hypertext-Dokument
652 GetLogFileName = sSChartLogFileName
'Diagramm
654 GetLogFileName = sJavaLogFileName
'Java
656 GetLogFileName = sSDBLogFileName
'Database
658 GetLogFileName = sExtLogFileName
'Extension
660 GetLogFileName =
""
664 Function GetErrorMessageOnAction (nAction as Integer) as String
665 Select Case ( nAction )
667 GetErrorMessageOnAction = cMessageNewDoc
669 GetErrorMessageOnAction = cMessageCutObj
671 GetErrorMessageOnAction = cMessagePasteObj
673 GetErrorMessageOnAction = cMessageSaveOpen8Doc
675 GetErrorMessageOnAction = cMessageSaveOpenXMLDoc
677 GetErrorMessageOnAction = cMessageSaveOpen50Doc
679 GetErrorMessageOnAction = cMessageCloseDoc
681 GetErrorMessageOnAction =
""
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
692 Function TestJava (FilterType as Integer) as boolean
694 FileChannel% = OpenLogDat (GetLogFileName(FilterType))
695 oObj = createUnoService(cUnoJavaLoader)
696 LogState (not IsNull (oObj),
"Java
"+ cMessageNewDoc, FileChannel)
697 LogState (not IsNull (oObj),
"Java
"+ cMessageNewDoc, MainFileChannel)
698 SetStatus (FilterType, cDocNew, not IsNull (oObj))
700 Print #FileChannel,
"---
"
703 TestJava = not IsNull (oObj)
706 Sub CutAndPaste (DocType as Integer, oDoc as Object)
711 Dim bCutState as boolean, bPasteState as boolean
712 Select Case ( DocType )
714 Dim oCursor as Object
716 sText =
"AutomaticText
"
718 oCursor = oText.CreateTextCursor
719 oText.InsertString(oCursor, sText, true)
' Cursor selektiert den Text
720 oView = oDoc.getCurrentController
721 oView.Select(oCursor)
726 if oText.GetString =
"" Then
731 SetStatus (DocType, cDocCut, bCutState)
732 LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+
" "+ cMessageCutObj, FileChannel)
733 LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+
" "+ cMessageCutObj, MainFileChannel)
736 if bMakePasteTest and bMakeCutTest then
737 call PasteText (oDoc)
739 if oText.GetString = sText Then
744 SetStatus (DocType, cDocPaste, bPasteState)
745 LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+
" "+ cMessagePasteObj, FileChannel)
746 LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+
" "+ cMessagePasteObj, MainFileChannel)
752 sText =
"AutomaticText
"
753 oCell = oDoc.Sheets(
0).GetCellByPosition(
0,
0)
755 oView = oDoc.getCurrentController
761 if oCell.String =
"" Then
766 SetStatus (DocType, cDocCut, bCutState)
767 LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+
" "+ cMessageCutObj, FileChannel)
768 LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+
" "+ cMessageCutObj, MainFileChannel)
771 if bMakePasteTest and bMakeCutTest then
772 call PasteText (oDoc)
774 if oCell.String = sText Then
779 SetStatus (DocType, cDocPaste, bPasteState)
780 LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+
" "+ cMessagePasteObj, FileChannel)
781 LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+
" "+ cMessagePasteObj, MainFileChannel)
784 case frmImpress, frmDraw
789 Dim bObjState as Boolean
791 xSize = CreateUnoStruct (
"com.sun.star.awt.Size
")
792 xPoint = CreateUnoStruct (
"com.sun.star.awt.Point
")
797 oPage = oDoc.DrawPages(
0)
798 oRect = oDoc.CreateInstance(
"com.sun.star.drawing.RectangleShape
")
800 oRect.Position = xPoint
803 oView = oDoc.getCurrentController
806 ' Prüft ob überhaupt ein Object angelegt wurde
807 if oPage.count =
1 Then
816 if (oPage.count =
0) and bObjState Then
821 SetStatus (DocType, cDocCut, bCutState)
822 LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+
" "+ cMessageCutObj, FileChannel)
823 LogState (bCutState, GetDocFilter(DocType or cFltNewDoc)+
" "+ cMessageCutObj, MainFileChannel)
826 wait (
1000)
'wait after cut
828 if bMakePasteTest and bMakeCutTest then
829 call PasteText (oDoc)
831 if (oPage.count =
1) and bObjState Then
836 SetStatus (DocType, cDocPaste, bPasteState)
837 LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+
" "+ cMessagePasteObj, FileChannel)
838 LogState (bPasteState, GetDocFilter(DocType or cFltNewDoc)+
" "+ cMessagePasteObj, MainFileChannel)
847 Sub LoadLibrary( LibName as String )
850 dim arg as new com.sun.star.beans.PropertyValue
851 arg.Name =
"LibraryName
"
855 dim url as new com.sun.star.util.URL
857 trans = createUnoService(
"com.sun.star.util.URLTransformer
" )
858 url.Complete =
"slot:
6517"
859 trans.parsestrict( url )
862 disp = StarDesktop.currentFrame.queryDispatch( url,
"",
0 )
863 disp.dispatch( url, args() )
867 Sub LoadDoc (DocName as String) as Object
869 trans = createUnoService(
"com.sun.star.util.URLTransformer
" )
870 url = createUnoStruct(
"com.sun.star.util.URL
" )
871 url.Complete = DocName
872 if Left(DocName,
5 )
<> "file:
" then
873 trans.parsestrict( url )
876 Dim aPropArray(
0) as Object
877 aPropArray(
0) = CreateUnoStruct(
"com.sun.star.beans.PropertyValue
")
878 aPropArray(
0).Name =
"OpenFlags
"
879 aPropArray(
0).Value =
"S
"
883 doc = StarDesktop.loadComponentFromURL( url.Complete,
"_blank
",
0, aPropArray() )
' XModel
887 Sub SaveDoc (DocName as String, oDoc as Object, sFilterName as string )
889 trans = createUnoService(
"com.sun.star.util.URLTransformer
" )
890 url = createUnoStruct(
"com.sun.star.util.URL
" )
891 url.Complete = DocName
892 if Left(DocName,
5 )
<> "file:
" then
893 trans.parsestrict( url )
896 if not (sFilterName =
"") then
897 Dim aPropArray(
0) as Object
898 aPropArray(
0) = CreateUnoStruct(
"com.sun.star.beans.PropertyValue
")
899 aPropArray(
0).Name =
"FilterName
"
900 aPropArray(
0).Value = sFilterName
902 oDoc.storeAsURL( url.Complete, aPropArray() )
904 MessageBox
"Filtername is unknown!
"