1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?> 25111cb72SAndrew Rist<!--*********************************************************** 35111cb72SAndrew Rist * 45111cb72SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 55111cb72SAndrew Rist * or more contributor license agreements. See the NOTICE file 65111cb72SAndrew Rist * distributed with this work for additional information 75111cb72SAndrew Rist * regarding copyright ownership. The ASF licenses this file 85111cb72SAndrew Rist * to you under the Apache License, Version 2.0 (the 95111cb72SAndrew Rist * "License"); you may not use this file except in compliance 105111cb72SAndrew Rist * with the License. You may obtain a copy of the License at 115111cb72SAndrew Rist * 125111cb72SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 135111cb72SAndrew Rist * 145111cb72SAndrew Rist * Unless required by applicable law or agreed to in writing, 155111cb72SAndrew Rist * software distributed under the License is distributed on an 165111cb72SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 175111cb72SAndrew Rist * KIND, either express or implied. See the License for the 185111cb72SAndrew Rist * specific language governing permissions and limitations 195111cb72SAndrew Rist * under the License. 205111cb72SAndrew Rist * 215111cb72SAndrew Rist ***********************************************************--> 225111cb72SAndrew Rist 235111cb72SAndrew Rist 24cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 25cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Test_10er" script:language="StarBasic">REM 10er Test 26cdf0e10cSrcweir 27cdf0e10cSrcweirconst sSWLogFileName = "swlog.dat", sSCLogFileName = "sclog.dat" 28cdf0e10cSrcweirconst sSDLogFileName = "sdlog.dat", sSMathLogFileName = "smalog.dat" 29cdf0e10cSrcweirconst sSChartLogFileName = "schlog.dat" 30cdf0e10cSrcweirconst sSHptLogFileName = "shptlog.dat" 31cdf0e10cSrcweirconst sSDrawLogFileName = "sdrwlog.dat", sJavaLogFileName = "javalog.dat" 32cdf0e10cSrcweirconst sSDBLogFileName = "dblog.dat", sExtLogFileName = "extlog.dat" 33cdf0e10cSrcweirconst sTestGlueLogFileName = "testclosure.log" 34cdf0e10cSrcweirconst sLogFileName = "smoketest.log" 35cdf0e10cSrcweirconst cTempFileName = "smoketest_file" 36cdf0e10cSrcweir 37cdf0e10cSrcweirconst cMessageSaveOpen8Doc = "Save/Open open Documents (8.0)" 38cdf0e10cSrcweirconst cMessageSaveOpenXMLDoc = "Save/Open Document XML (6/7)" 39cdf0e10cSrcweirconst cMessageNewDoc = "New Document" 40cdf0e10cSrcweirconst cMessageCloseDoc = "Close Document" 41cdf0e10cSrcweir 42cdf0e10cSrcweirGlobal sWorkPath$ 43cdf0e10cSrcweirGlobal sWorkPathURL$ 44cdf0e10cSrcweirGlobal LocalTestLog% 45cdf0e10cSrcweirGlobal GlobalTestLog% 46cdf0e10cSrcweir 47cdf0e10cSrcweirSub Main 48cdf0e10cSrcweir call TestAllDocs() 49cdf0e10cSrcweirend Sub 50cdf0e10cSrcweir 51cdf0e10cSrcweirSub DeleteAllSavedFiles() 52cdf0e10cSrcweir Dim sFileName as String 53cdf0e10cSrcweir sFileName = sWorkPath+cTempFileName+"."+GetDocEndings(frmWriter) 54cdf0e10cSrcweir If FileExists (sFileName) then 55cdf0e10cSrcweir Kill (sFileName) 56cdf0e10cSrcweir End If 57cdf0e10cSrcweir sFileName = sWorkPath+cTempFileName+"."+GetDocEndings(frmCalc) 58cdf0e10cSrcweir If FileExists (sFileName) then 59cdf0e10cSrcweir Kill (sFileName) 60cdf0e10cSrcweir End If 61cdf0e10cSrcweir sFileName = sWorkPath+cTempFileName+"."+GetDocEndings(frmImpress) 62cdf0e10cSrcweir If FileExists (sFileName) then 63cdf0e10cSrcweir Kill (sFileName) 64cdf0e10cSrcweir End If 65cdf0e10cSrcweir sFileName = sWorkPath+cTempFileName+"."+GetDocEndings(frmDraw) 66cdf0e10cSrcweir If FileExists (sFileName) then 67cdf0e10cSrcweir Kill (sFileName) 68cdf0e10cSrcweir End If 69cdf0e10cSrcweir sFileName = sWorkPath+cTempFileName+"."+GetDocEndings(frmHyperText) 70cdf0e10cSrcweir If FileExists (sFileName) then 71cdf0e10cSrcweir Kill (sFileName) 72cdf0e10cSrcweir End If 73cdf0e10cSrcweir sFileName = sWorkPath+cTempFileName+"."+GetDocEndings(frmWriter or cFltXML) 74cdf0e10cSrcweir If FileExists (sFileName) then 75cdf0e10cSrcweir Kill (sFileName) 76cdf0e10cSrcweir End If 77cdf0e10cSrcweir sFileName = sWorkPath+cTempFileName+"."+GetDocEndings(frmCalc or cFltXML) 78cdf0e10cSrcweir If FileExists (sFileName) then 79cdf0e10cSrcweir Kill (sFileName) 80cdf0e10cSrcweir End If 81cdf0e10cSrcweir sFileName = sWorkPath+cTempFileName+"."+GetDocEndings(frmImpress or cFltXML) 82cdf0e10cSrcweir If FileExists (sFileName) then 83cdf0e10cSrcweir Kill (sFileName) 84cdf0e10cSrcweir End If 85cdf0e10cSrcweir sFileName = sWorkPath+cTempFileName+"."+GetDocEndings(frmDraw or cFltXML) 86cdf0e10cSrcweir If FileExists (sFileName) then 87cdf0e10cSrcweir Kill (sFileName) 88cdf0e10cSrcweir End If 89cdf0e10cSrcweirEnd Sub 90cdf0e10cSrcweir 91cdf0e10cSrcweirSub DeleteAllLogFiles() 92cdf0e10cSrcweir If FileExists (sWorkPath+sLogFileName) then 93cdf0e10cSrcweir Kill (sWorkPath+sLogFileName) 94cdf0e10cSrcweir End If 95cdf0e10cSrcweir If FileExists (sWorkPath+sSWLogFileName) then 96cdf0e10cSrcweir Kill (sWorkPath+sSWLogFileName) 97cdf0e10cSrcweir End If 98cdf0e10cSrcweir If FileExists (sWorkPath+sSCLogFileName) then 99cdf0e10cSrcweir Kill (sWorkPath+sSCLogFileName) 100cdf0e10cSrcweir End If 101cdf0e10cSrcweir If FileExists (sWorkPath+sSDLogFileName) then 102cdf0e10cSrcweir Kill (sWorkPath+sSDLogFileName) 103cdf0e10cSrcweir End If 104cdf0e10cSrcweir If FileExists (sWorkPath+sSMathLogFileName) then 105cdf0e10cSrcweir Kill (sWorkPath+sSMathLogFileName) 106cdf0e10cSrcweir End If 107cdf0e10cSrcweir If FileExists (sWorkPath+sSChartLogFileName) then 108cdf0e10cSrcweir Kill (sWorkPath+sSChartLogFileName) 109cdf0e10cSrcweir End If 110cdf0e10cSrcweir If FileExists (sWorkPath+sSHptLogFileName) then 111cdf0e10cSrcweir Kill (sWorkPath+sSHptLogFileName) 112cdf0e10cSrcweir End If 113cdf0e10cSrcweir If FileExists (sWorkPath+sSDrawLogFileName) then 114cdf0e10cSrcweir Kill (sWorkPath+sSDrawLogFileName) 115cdf0e10cSrcweir End If 116cdf0e10cSrcweir If FileExists (sWorkPath+sJavaLogFileName) then 117cdf0e10cSrcweir Kill (sWorkPath+sJavaLogFileName) 118cdf0e10cSrcweir End If 119cdf0e10cSrcweir If FileExists (sWorkPath+sTestGlueLogFileName) then 120cdf0e10cSrcweir Kill (sWorkPath+sTestGlueLogFileName) 121cdf0e10cSrcweir End If 122cdf0e10cSrcweir If FileExists (sWorkPath+sSDBLogFileName) then 123cdf0e10cSrcweir Kill (sWorkPath+sSDBLogFileName) 124cdf0e10cSrcweir End If 125cdf0e10cSrcweir If FileExists (sWorkPath+sExtLogFileName) then 126cdf0e10cSrcweir Kill (sWorkPath+sExtLogFileName) 127cdf0e10cSrcweir End If 128cdf0e10cSrcweirend Sub 129cdf0e10cSrcweir 130cdf0e10cSrcweirFunction OpenLogDat (sFileName as String) as Integer 131cdf0e10cSrcweir Dim LocaleFileChannel% 132cdf0e10cSrcweir If FileExists (sWorkPath+sFileName) then 133cdf0e10cSrcweir Kill (sWorkPath+sFileName) 134cdf0e10cSrcweir End If 135cdf0e10cSrcweir LocaleFileChannel% = Freefile 136cdf0e10cSrcweir Open sWorkPath+sFileName For Output As LocaleFileChannel% 137cdf0e10cSrcweir OpenLogDat = LocaleFileChannel% 138cdf0e10cSrcweirend Function 139cdf0e10cSrcweir 140cdf0e10cSrcweirSub SetupWorkPath 141cdf0e10cSrcweir Dim configManager as Object 142cdf0e10cSrcweir configManager = CreateUnoService( "com.sun.star.config.SpecialConfigManager" ) 143cdf0e10cSrcweir 144cdf0e10cSrcweir sWorkPath = configManager.SubstituteVariables( "$(userpath)/temp/" ) 145cdf0e10cSrcweir sWorkPathURL = configManager.SubstituteVariables( "$(userurl)/temp/" ) 146cdf0e10cSrcweirEnd Sub 147cdf0e10cSrcweir 148cdf0e10cSrcweirFunction GetSystem (sTmpWorkPath as string) as string 149cdf0e10cSrcweir GetSystem = "" 150cdf0e10cSrcweir if InStr (sTmpWorkPath, ":") then 151cdf0e10cSrcweir GetSystem = "windows" 152cdf0e10cSrcweir else 153cdf0e10cSrcweir GetSystem = "unix" 154cdf0e10cSrcweir End If 155cdf0e10cSrcweirend Function 156cdf0e10cSrcweir 157cdf0e10cSrcweirFunction ConvertPathToWin (sTmpWorkPath as string) as string 158cdf0e10cSrcweir for i%=1 to Len(sTmpWorkPath) 159cdf0e10cSrcweir sTemp = Mid (sTmpWorkPath, i%, 1) 160cdf0e10cSrcweir if sTemp = "/" then 161cdf0e10cSrcweir sTmpWorkPath = Left (sTmpWorkPath, i%-1) + "\" + Right (sTmpWorkPath, Len(sTmpWorkPath)-i%) 162cdf0e10cSrcweir else 163cdf0e10cSrcweir if sTemp = "|" then 164cdf0e10cSrcweir sTmpWorkPath = Left (sTmpWorkPath, i%-1) + ":" + Right (sTmpWorkPath, Len(sTmpWorkPath)-i%) 165cdf0e10cSrcweir end If 166cdf0e10cSrcweir end If 167cdf0e10cSrcweir next i% 168cdf0e10cSrcweir ConvertPathToWin = sTmpWorkPath 169cdf0e10cSrcweirend Function 170cdf0e10cSrcweir 171cdf0e10cSrcweirSub TestAllDocs() 172cdf0e10cSrcweirDIM sDocURL as String, sDocPath as String 173cdf0e10cSrcweirDIM nStrPos as Long 174cdf0e10cSrcweir 175cdf0e10cSrcweir 'search ExtensionURL 176cdf0e10cSrcweir sDocURL = gOutputDoc.URL 177cdf0e10cSrcweir CompatibilityMode(true) 178cdf0e10cSrcweir nStrPos = InStrRev (sDocURL, "/" ) 179cdf0e10cSrcweir CompatibilityMode(false) 180cdf0e10cSrcweir sExtensionURL = Left (sDocURL, nStrPos) 181cdf0e10cSrcweir 182cdf0e10cSrcweir GlobalTestLog = OpenLogDat (sLogFileName) 183cdf0e10cSrcweir call WriteTestSequence 184cdf0e10cSrcweir if bMakeWriterTest then 185cdf0e10cSrcweir gCurrentDocTest = frmWriter 186cdf0e10cSrcweir call MakeDocTest 187cdf0e10cSrcweir end if 188cdf0e10cSrcweir if bMakeCalcTest then 189cdf0e10cSrcweir gCurrentDocTest = frmCalc 190cdf0e10cSrcweir call MakeDocTest 191cdf0e10cSrcweir end if 192cdf0e10cSrcweir if bMakeImpressTest then 193cdf0e10cSrcweir gCurrentDocTest = frmImpress 194cdf0e10cSrcweir call MakeDocTest 195cdf0e10cSrcweir end if 196cdf0e10cSrcweir if bMakeDrawTest then 197cdf0e10cSrcweir gCurrentDocTest = frmDraw 198cdf0e10cSrcweir call MakeDocTest 199cdf0e10cSrcweir end if 200cdf0e10cSrcweir if bMakeHTMLTest then 201cdf0e10cSrcweir gCurrentDocTest = frmHyperText 202cdf0e10cSrcweir call MakeDocTest 203cdf0e10cSrcweir end if 204cdf0e10cSrcweir if bMakeChartTest then 205cdf0e10cSrcweir gCurrentDocTest = frmChart 206cdf0e10cSrcweir call MakeChartTest 207cdf0e10cSrcweir end if 208cdf0e10cSrcweir if bMakeMathTest then 209cdf0e10cSrcweir gCurrentDocTest = frmMath 210cdf0e10cSrcweir call MakeNewDoc 211cdf0e10cSrcweir end if 212cdf0e10cSrcweir if bMakeJavaTest then 213cdf0e10cSrcweir gCurrentDocTest = frmJava 214cdf0e10cSrcweir call TestJava 215cdf0e10cSrcweir end if 216cdf0e10cSrcweir if bMakeDBTest then 217cdf0e10cSrcweir gCurrentDocTest = frmDataBase 218cdf0e10cSrcweir call Test_DB.TestDB 219cdf0e10cSrcweir end if 220cdf0e10cSrcweir if bMakeExtensionTest then 221cdf0e10cSrcweir gCurrentDocTest = frmExtension 222cdf0e10cSrcweir call Test_Ext.TestExtensions 223cdf0e10cSrcweir end if 224cdf0e10cSrcweir 225cdf0e10cSrcweir Close #GlobalTestLog 226cdf0e10cSrcweir GlobalTestLog = 0 227cdf0e10cSrcweirend Sub 228cdf0e10cSrcweir 229cdf0e10cSrcweirSub WriteTestSequence 230cdf0e10cSrcweir Print #GlobalTestLog, "Sequence of testing" 231cdf0e10cSrcweir 232cdf0e10cSrcweir if bMakeWriterTest then 233cdf0e10cSrcweir WriteTests ("writer : ", true, GlobalTestLog) 234cdf0e10cSrcweir end if 235cdf0e10cSrcweir if bMakeCalcTest then 236cdf0e10cSrcweir WriteTests ("calc : ", true, GlobalTestLog) 237cdf0e10cSrcweir end if 238cdf0e10cSrcweir if bMakeImpressTest then 239cdf0e10cSrcweir WriteTests ("impress : ", true, GlobalTestLog) 240cdf0e10cSrcweir end if 241cdf0e10cSrcweir if bMakeDrawTest then 242cdf0e10cSrcweir WriteTests ("draw : ", true, GlobalTestLog) 243cdf0e10cSrcweir end if 244cdf0e10cSrcweir if bMakeHTMLTest then 245cdf0e10cSrcweir WriteTests ("HTML : ", true, GlobalTestLog) 246cdf0e10cSrcweir end if 247cdf0e10cSrcweir if bMakeChartTest then 248cdf0e10cSrcweir WriteTests ("chart : ", false, GlobalTestLog) 249cdf0e10cSrcweir end if 250cdf0e10cSrcweir if bMakeMathTest then 251cdf0e10cSrcweir WriteTests ("math : ", false, GlobalTestLog) 252cdf0e10cSrcweir end if 253cdf0e10cSrcweir if bMakeJavaTest then 254cdf0e10cSrcweir WriteTests ("Java : ", false, GlobalTestLog) 255cdf0e10cSrcweir end if 256cdf0e10cSrcweir if bMakeDBTest then 257cdf0e10cSrcweir WriteDBTests ("Database : ", GlobalTestLog) 258cdf0e10cSrcweir end if 259cdf0e10cSrcweir if bMakeExtensionTest then 260cdf0e10cSrcweir WriteExtensionTests ("Extension : ", GlobalTestLog) 261cdf0e10cSrcweir end if 262cdf0e10cSrcweir 263cdf0e10cSrcweir Print #GlobalTestLog, "testclosure : setup, write_status" 264cdf0e10cSrcweir 265cdf0e10cSrcweir Print #GlobalTestLog 266cdf0e10cSrcweir end Sub 267cdf0e10cSrcweir 268cdf0e10cSrcweir Sub WriteTests (sText as string, bTestAll as boolean) 269cdf0e10cSrcweir Dim sWriteStr as string 270cdf0e10cSrcweir 271cdf0e10cSrcweir sWriteStr = sText 272cdf0e10cSrcweir sWriteStr = sWriteStr + "new" 273cdf0e10cSrcweir if bTestAll then 274cdf0e10cSrcweir if bMakeSaveOpen8Test then 275cdf0e10cSrcweir sWriteStr = sWriteStr + ", save 8.0" 276cdf0e10cSrcweir end if 277cdf0e10cSrcweir if bMakeSaveOpenXMLTest then 278cdf0e10cSrcweir sWriteStr = sWriteStr + ", save XML" 279cdf0e10cSrcweir end if 280cdf0e10cSrcweir if bMakeSaveOpen8Test then 281cdf0e10cSrcweir sWriteStr = sWriteStr + ", open 8.0" 282cdf0e10cSrcweir end if 283cdf0e10cSrcweir if bMakeSaveOpenXMLTest then 284cdf0e10cSrcweir sWriteStr = sWriteStr + ", open XML" 285cdf0e10cSrcweir end if 286cdf0e10cSrcweir end if 287cdf0e10cSrcweir 288cdf0e10cSrcweir sWriteStr = sWriteStr + ", close" 289cdf0e10cSrcweir 290cdf0e10cSrcweir Print #GlobalTestLog, sWriteStr 291cdf0e10cSrcweirend Sub 292cdf0e10cSrcweir 293cdf0e10cSrcweirSub WriteDBTests (sText as string, nFileChannel as integer) 294cdf0e10cSrcweir Dim sWriteStr as string 295cdf0e10cSrcweir 296cdf0e10cSrcweir sWriteStr = sText 297cdf0e10cSrcweir sWriteStr = sWriteStr + "open / services" 298cdf0e10cSrcweir sWriteStr = sWriteStr + ", insert" 299cdf0e10cSrcweir sWriteStr = sWriteStr + ", delete" 300cdf0e10cSrcweir sWriteStr = sWriteStr + ", seek" 301cdf0e10cSrcweir sWriteStr = sWriteStr + ", close" 302cdf0e10cSrcweir 303cdf0e10cSrcweir Print #nFileChannel, sWriteStr 304cdf0e10cSrcweirend Sub 305cdf0e10cSrcweir 306cdf0e10cSrcweirSub WriteExtensionTests (sText as string, nFileChannel as integer) 307cdf0e10cSrcweir Dim sWriteStr as string 308cdf0e10cSrcweir 309cdf0e10cSrcweir sWriteStr = sText 310cdf0e10cSrcweir sWriteStr = sWriteStr + "services" 311cdf0e10cSrcweir sWriteStr = sWriteStr + ", install" 312cdf0e10cSrcweir sWriteStr = sWriteStr + ", uninstall" 313cdf0e10cSrcweir 314cdf0e10cSrcweir Print #nFileChannel, sWriteStr 315cdf0e10cSrcweirend Sub 316cdf0e10cSrcweir 317cdf0e10cSrcweirSub MakeDocTest 318cdf0e10cSrcweir Dim oDoc as Object 319cdf0e10cSrcweir Dim sFileNameXML$, sFileName8$ 320cdf0e10cSrcweir Dim bSuccess as Boolean 321cdf0e10cSrcweir 322cdf0e10cSrcweir On Local Error GoTo DOCTESTERROR 323cdf0e10cSrcweir gCurrentTestCase = cLogfileFailed 324cdf0e10cSrcweir LocalTestLog% = OpenLogDat (GetLogFileName(gCurrentDocTest)) 325cdf0e10cSrcweir gCurrentTestCase = cDocNew 326cdf0e10cSrcweir oDoc = LoadDoc ("private:factory/" + GetDocFilter(gCurrentDocTest or cFltNewDoc)) 327cdf0e10cSrcweir LogTestResult( GetDocFilter(gCurrentDocTest or cFltNewDoc)+" "+ cMessageNewDoc, not IsNull (oDoc) ) 328cdf0e10cSrcweir if not IsNull (oDoc) then 329cdf0e10cSrcweir gCurrentTestCase = cDocSaveOpen8 330cdf0e10cSrcweir if bMakeSaveOpen8Test and IsFilterAvailable (gCurrentDocTest or cFlt8) then 331cdf0e10cSrcweir sFileName8 = sWorkPathURL+cTempFileName+"."+GetDocEndings(gCurrentDocTest or cFlt8) 332cdf0e10cSrcweir SaveDoc (sFileName8, oDoc, GetDocFilter(gCurrentDocTest or cFlt8)) 333cdf0e10cSrcweir end if 334cdf0e10cSrcweir gCurrentTestCase = cDocSaveOpenXML 335cdf0e10cSrcweir if bMakeSaveOpenXMLTest and IsFilterAvailable (gCurrentDocTest or cFltXML) then 336cdf0e10cSrcweir sFileNameXML = sWorkPathURL+cTempFileName+"."+GetDocEndings(gCurrentDocTest or cFltXML) 337cdf0e10cSrcweir SaveDoc (sFileNameXML, oDoc, GetDocFilter(gCurrentDocTest or cFltXML)) 338cdf0e10cSrcweir end if 339cdf0e10cSrcweir gCurrentTestCase = cDocClose 340cdf0e10cSrcweir bSuccess = CloseDoc( oDoc ) 341cdf0e10cSrcweir LogTestResult( GetDocFilter(gCurrentDocTest)+" "+ cMessageCloseDoc, bSuccess ) 342cdf0e10cSrcweir gCurrentTestCase = cDocSaveOpen8 343cdf0e10cSrcweir if bMakeSaveOpen8Test and IsFilterAvailable (gCurrentDocTest or cFlt8) then 344cdf0e10cSrcweir oDoc = LoadDoc (sFileName8) 345cdf0e10cSrcweir 346cdf0e10cSrcweir' oDoc = Documents.open(sFileName) 347cdf0e10cSrcweir LogTestResult( GetDocFilter(gCurrentDocTest or cFltNewDoc)+" "+ cMessageSaveOpen8Doc, not IsNull (oDoc) ) 348cdf0e10cSrcweir 349cdf0e10cSrcweir if not IsNull (oDoc) then 350cdf0e10cSrcweir gCurrentTestCase = cDocClose 351cdf0e10cSrcweir oDoc.close (true) 352cdf0e10cSrcweir end If 353cdf0e10cSrcweir end if 354cdf0e10cSrcweir 355cdf0e10cSrcweir gCurrentTestCase = cDocSaveOpenXML 356cdf0e10cSrcweir if bMakeSaveOpenXMLTest and IsFilterAvailable (gCurrentDocTest or cFltXML) then 357cdf0e10cSrcweir oDoc = LoadDoc (sFileNameXML) 358cdf0e10cSrcweir 359cdf0e10cSrcweir' oDoc = Documents.open(sFileName) 360cdf0e10cSrcweir LogTestResult( GetDocFilter(gCurrentDocTest or cFltNewDoc)+" "+ cMessageSaveOpenXMLDoc, not IsNull (oDoc) ) 361cdf0e10cSrcweir 362cdf0e10cSrcweir if not IsNull (oDoc) then 363cdf0e10cSrcweir gCurrentTestCase = cDocClose 364cdf0e10cSrcweir oDoc.close (true) 365cdf0e10cSrcweir end If 366cdf0e10cSrcweir end if 367cdf0e10cSrcweir 368cdf0e10cSrcweir end If 369cdf0e10cSrcweir Print #LocalTestLog, "---" 370cdf0e10cSrcweir Close #LocalTestLog% 371cdf0e10cSrcweir LocalTestLog = 0 372cdf0e10cSrcweir Exit Sub ' Without error 373cdf0e10cSrcweir 374cdf0e10cSrcweir DOCTESTERROR: 375cdf0e10cSrcweir If ( gCurrentTestCase = cLogfileFailed ) then 376cdf0e10cSrcweir LogTestResult( " ", False ) 377cdf0e10cSrcweir Exit Sub 378cdf0e10cSrcweir else 379cdf0e10cSrcweir LogTestResult( GetDocFilter(gCurrentDocTest or cFltNewDoc)+" "+ GetErrorMessage(gCurrentTestCase), False ) 380cdf0e10cSrcweir Close #LocalTestLog% 381cdf0e10cSrcweir LocalTestLog = 0 382cdf0e10cSrcweir End If 383cdf0e10cSrcweir Exit Sub ' With error 384cdf0e10cSrcweirEnd Sub 385cdf0e10cSrcweir 386cdf0e10cSrcweirSub MakeNewDoc 387cdf0e10cSrcweir DIM oDoc as Object 388cdf0e10cSrcweir Dim bSuccess as Boolean 389cdf0e10cSrcweir On Local Error GoTo DOCTESTERROR2 390cdf0e10cSrcweir gCurrentTestCase = cLogfileFailed 391cdf0e10cSrcweir LocalTestLog% = OpenLogDat (GetLogFileName(gCurrentDocTest)) 392cdf0e10cSrcweir gCurrentTestCase = cDocNew 393cdf0e10cSrcweir' oDoc = Documents.Add(GetDocFilter(gCurrentDocTest)) 394cdf0e10cSrcweir oDoc = LoadDoc ("private:factory/" + GetDocFilter(gCurrentDocTest or cFltNewDoc)) 395cdf0e10cSrcweir LogTestResult( GetDocFilter(gCurrentDocTest or cFltNewDoc)+" "+ cMessageNewDoc, not IsNull (oDoc) ) 396cdf0e10cSrcweir if not IsNull (oDoc) then 397cdf0e10cSrcweir gCurrentTestCase = cDocClose 398cdf0e10cSrcweir bSuccess = CloseDoc( oDoc ) 399cdf0e10cSrcweir LogTestResult( GetDocFilter(gCurrentDocTest)+" "+ cMessageCloseDoc, bSuccess ) 400cdf0e10cSrcweir end If 401cdf0e10cSrcweir Print #LocalTestLog, "---" 402cdf0e10cSrcweir Close #LocalTestLog% 403cdf0e10cSrcweir LocalTestLog = 0 404cdf0e10cSrcweir Exit Sub ' Without error 405cdf0e10cSrcweir 406cdf0e10cSrcweir DOCTESTERROR2: 407cdf0e10cSrcweir If ( gCurrentTestCase = cLogfileFailed ) then 408cdf0e10cSrcweir LogTestResult( " ", False ) 409cdf0e10cSrcweir Exit Sub 410cdf0e10cSrcweir else 411cdf0e10cSrcweir LogTestResult( GetDocFilter(gCurrentDocTest or cFltNewDoc)+" "+ GetErrorMessage(gCurrentTestCase), False ) 412cdf0e10cSrcweir Close #LocalTestLog% 413cdf0e10cSrcweir LocalTestLog = 0 414cdf0e10cSrcweir End If 415cdf0e10cSrcweir Exit Sub ' With error 416cdf0e10cSrcweirEnd Sub 417cdf0e10cSrcweir 418cdf0e10cSrcweirSub MakeChartTest 419cdf0e10cSrcweir Dim oCharts as Object 420cdf0e10cSrcweir Dim oDoc as Object 421cdf0e10cSrcweir Dim oRange(0) as New com.sun.star.table.CellRangeAddress 422cdf0e10cSrcweir Dim oRect as New com.sun.star.awt.Rectangle 423cdf0e10cSrcweir const cChartName="TestChart" 424cdf0e10cSrcweir Dim bSuccess as Boolean 425cdf0e10cSrcweir On Local Error GoTo CHARTTESTERROR 426cdf0e10cSrcweir gCurrentTestCase = cLogfileFailed 427cdf0e10cSrcweir LocalTestLog% = OpenLogDat (GetLogFileName(gCurrentDocTest)) 428cdf0e10cSrcweir gCurrentTestCase = cDocNew 429cdf0e10cSrcweir oDoc = LoadDoc ("private:factory/" + GetDocFilter(frmCalc or cFltNewDoc)) 430cdf0e10cSrcweir if not IsNull (oDoc) then 431cdf0e10cSrcweir oCharts = oDoc.sheets(0).Charts 432cdf0e10cSrcweir oCharts.AddNewByName (cChartName, oRect, oRange(), true, true) 433cdf0e10cSrcweir bSuccess=oCharts.HasByName(cChartName) 434cdf0e10cSrcweir LogTestResult( GetDocFilter(gCurrentDocTest or cFltNewDoc)+" "+ cMessageNewDoc, bSuccess ) 435cdf0e10cSrcweir gCurrentTestCase = cDocClose 436cdf0e10cSrcweir oDoc.close (true) 437cdf0e10cSrcweir else 438cdf0e10cSrcweir LogTestResult( GetDocFilter(frmCalc or cFltNewDoc)+" "+ cMessageNewDoc, FALSE ) 439cdf0e10cSrcweir End if 440cdf0e10cSrcweir Print #LocalTestLog, "---" 441cdf0e10cSrcweir Close #LocalTestLog% 442cdf0e10cSrcweir LocalTestLog = 0 443cdf0e10cSrcweir Exit Sub ' Without error 444cdf0e10cSrcweir 445cdf0e10cSrcweir CHARTTESTERROR: 446cdf0e10cSrcweir If ( gCurrentTestCase = cLogfileFailed ) then 447cdf0e10cSrcweir LogTestResult( " ", False ) 448cdf0e10cSrcweir Exit Sub 449cdf0e10cSrcweir else 450cdf0e10cSrcweir LogTestResult( GetDocFilter(gCurrentDocTest or cFltNewDoc)+" "+ GetErrorMessage(gCurrentTestCase), FALSE ) 451cdf0e10cSrcweir Close #LocalTestLog% 452cdf0e10cSrcweir LocalTestLog = 0 453cdf0e10cSrcweir End If 454cdf0e10cSrcweir Exit Sub ' With error 455cdf0e10cSrcweirEnd Sub 456cdf0e10cSrcweir 457cdf0e10cSrcweirSub LogState (bState as Boolean, sText as String, nLocaleFileChannel as integer) 458cdf0e10cSrcweir if bState then 459cdf0e10cSrcweir Print #nLocaleFileChannel, sText+" -> ok" 460cdf0e10cSrcweir else 461cdf0e10cSrcweir Print #nLocaleFileChannel, sText+" -> error" 462cdf0e10cSrcweir end If 463cdf0e10cSrcweirend Sub 464cdf0e10cSrcweir 465cdf0e10cSrcweirFunction GetDocEndings (DocType as Integer) as String 466cdf0e10cSrcweir Select Case ( DocType ) 467cdf0e10cSrcweir case frmWriter or cFlt8 468cdf0e10cSrcweir GetDocEndings = "odt" ' Textdokument 469cdf0e10cSrcweir case frmCalc or cFlt8 470cdf0e10cSrcweir GetDocEndings = "ods" 'Tabellendokument 471cdf0e10cSrcweir case frmImpress or cFlt8 472cdf0e10cSrcweir GetDocEndings = "odp" 'PrÕsentation 473cdf0e10cSrcweir case frmDraw or cFlt8 474cdf0e10cSrcweir GetDocEndings = "odg" 'Zeichen 475cdf0e10cSrcweir case frmHyperText, frmHyperText or cFltXML 476cdf0e10cSrcweir GetDocEndings = "html" 'Hypertext-Dokument 477cdf0e10cSrcweir case frmWriter or cFltXML 478cdf0e10cSrcweir GetDocEndings = "sxw" ' Textdokument 479cdf0e10cSrcweir case frmCalc or cFltXML 480cdf0e10cSrcweir GetDocEndings = "sxc" 'Tabellendokument 481cdf0e10cSrcweir case frmImpress or cFltXML 482cdf0e10cSrcweir GetDocEndings = "sxi" 'PrÕsentation 483cdf0e10cSrcweir case frmDraw or cFltXML 484cdf0e10cSrcweir GetDocEndings = "sxd" 'Zeichen 485cdf0e10cSrcweir case else 486cdf0e10cSrcweir GetDocEndings = "" 487cdf0e10cSrcweir end Select 488cdf0e10cSrcweirend Function 489cdf0e10cSrcweir 490cdf0e10cSrcweirFunction GetDocFilter (DocType as Integer) as String 491cdf0e10cSrcweir Select Case ( DocType ) 492cdf0e10cSrcweir case frmWriter or cFlt8 493cdf0e10cSrcweir GetDocFilter = "writer8" ' text document 494cdf0e10cSrcweir case frmCalc or cFlt8 495cdf0e10cSrcweir GetDocFilter = "calc8" ' spreadsheet document 496cdf0e10cSrcweir case frmImpress or cFlt8 497cdf0e10cSrcweir GetDocFilter = "impress8" ' presentation 498cdf0e10cSrcweir case frmDraw or cFlt8 499cdf0e10cSrcweir GetDocFilter = "draw8" ' drawing 500cdf0e10cSrcweir case frmMath or cFlt8 501cdf0e10cSrcweir GetDocFilter = "math8" ' formula 502cdf0e10cSrcweir 503cdf0e10cSrcweir case frmWriter or cFltXML 504cdf0e10cSrcweir GetDocFilter = "StarOffice XML (Writer)" ' text document 505cdf0e10cSrcweir case frmCalc or cFltXML 506cdf0e10cSrcweir GetDocFilter = "StarOffice XML (Calc)" ' spreadsheet document 507cdf0e10cSrcweir case frmImpress or cFltXML 508cdf0e10cSrcweir GetDocFilter = "StarOffice XML (Impress)" ' presentation 509cdf0e10cSrcweir case frmDraw or cFltXML 510cdf0e10cSrcweir GetDocFilter = "StarOffice XML (Draw)" ' drawing 511cdf0e10cSrcweir case frmMath or cFltXML 512cdf0e10cSrcweir GetDocFilter = "StarOffice XML (Math)" ' formula 513cdf0e10cSrcweir 514cdf0e10cSrcweir case frmHyperText, frmHyperText or cFltXML 515cdf0e10cSrcweir GetDocFilter = "HTML" ' HTML document 516cdf0e10cSrcweir 517cdf0e10cSrcweir case frmWriter or cFltNewDoc 518cdf0e10cSrcweir GetDocFilter = "swriter" ' text document 519cdf0e10cSrcweir case frmCalc or cFltNewDoc 520cdf0e10cSrcweir GetDocFilter = "scalc" ' spreadsheet document 521cdf0e10cSrcweir case frmImpress or cFltNewDoc 522cdf0e10cSrcweir GetDocFilter = "simpress" ' presentation 523cdf0e10cSrcweir case frmDraw or cFltNewDoc 524cdf0e10cSrcweir GetDocFilter = "sdraw" ' drawing 525cdf0e10cSrcweir case frmMath or cFltNewDoc 526cdf0e10cSrcweir GetDocFilter = "smath" ' formula 527cdf0e10cSrcweir case frmHyperText or cFltNewDoc 528cdf0e10cSrcweir GetDocFilter = "swriter/web" ' HTML document 529cdf0e10cSrcweir case frmChart or cFltNewDoc 530cdf0e10cSrcweir GetDocFilter = "schart" ' chart 531cdf0e10cSrcweir case else 532cdf0e10cSrcweir GetDocFilter = "" 533cdf0e10cSrcweir end Select 534cdf0e10cSrcweirend Function 535cdf0e10cSrcweir 536cdf0e10cSrcweirFunction GetLogFileName (DocType as Integer) as String 537cdf0e10cSrcweir Select Case ( DocType ) 538cdf0e10cSrcweir case frmWriter 539cdf0e10cSrcweir GetLogFileName = sSWLogFileName ' text document 540cdf0e10cSrcweir case frmCalc 541cdf0e10cSrcweir GetLogFileName = sSCLogFileName ' spreadsheet document 542cdf0e10cSrcweir case frmImpress 543cdf0e10cSrcweir GetLogFileName = sSDLogFileName ' presentation 544cdf0e10cSrcweir case frmDraw 545cdf0e10cSrcweir GetLogFileName = sSDrawLogFileName ' drawing 546cdf0e10cSrcweir case frmMath 547cdf0e10cSrcweir GetLogFileName = sSMathLogFileName ' formula 548cdf0e10cSrcweir case frmHyperText 549cdf0e10cSrcweir GetLogFileName = sSHptLogFileName ' HTML document 550cdf0e10cSrcweir case frmChart 551cdf0e10cSrcweir GetLogFileName = sSChartLogFileName ' chart 552cdf0e10cSrcweir case frmJava 553cdf0e10cSrcweir GetLogFileName = sJavaLogFileName 'Java 554cdf0e10cSrcweir case frmTestClosure 555cdf0e10cSrcweir GetLogFileName = sTestGlueLogFileName ' test framework 556cdf0e10cSrcweir case frmDataBase 557cdf0e10cSrcweir GetLogFileName = sSDBLogFileName 'Database 558cdf0e10cSrcweir case frmExtension 559cdf0e10cSrcweir GetLogFileName = sExtLogFileName 'Extension 560cdf0e10cSrcweir case else 561cdf0e10cSrcweir GetLogFileName = "" 562cdf0e10cSrcweir end Select 563cdf0e10cSrcweirend Function 564cdf0e10cSrcweir 565cdf0e10cSrcweirFunction GetErrorMessageOnAction (nAction as Integer) as String 566cdf0e10cSrcweir Select Case ( nAction ) 567cdf0e10cSrcweir case cDocNew 568cdf0e10cSrcweir GetErrorMessageOnAction = cMessageNewDoc 569cdf0e10cSrcweir case cDocSaveOpen8 570cdf0e10cSrcweir GetErrorMessageOnAction = cMessageSaveOpen8Doc 571cdf0e10cSrcweir case cDocSaveOpenXML 572cdf0e10cSrcweir GetErrorMessageOnAction = cMessageSaveOpenXMLDoc 573cdf0e10cSrcweir case cDocClose 574cdf0e10cSrcweir GetErrorMessageOnAction = cMessageCloseDoc 575cdf0e10cSrcweir case else 576cdf0e10cSrcweir GetErrorMessageOnAction = "" 577cdf0e10cSrcweir end Select 578cdf0e10cSrcweirend Function 579cdf0e10cSrcweir 580cdf0e10cSrcweirFunction IsFilterAvailable (FilterType as Integer) as boolean 581cdf0e10cSrcweir IsFilterAvailable = true 582cdf0e10cSrcweir if ((FilterType = (frmHyperText or cFltXML))) then 583cdf0e10cSrcweir IsFilterAvailable = false 584cdf0e10cSrcweir end if 585cdf0e10cSrcweirEnd Function 586cdf0e10cSrcweir 587cdf0e10cSrcweirFunction TestJava 588cdf0e10cSrcweir Dim oObj as Object 589cdf0e10cSrcweir gCurrentTestCase = cLogfileFailed 590cdf0e10cSrcweir LocalTestLog% = OpenLogDat (GetLogFileName(gCurrentDocTest)) 591cdf0e10cSrcweir gCurrentTestCase = cDocNew 592cdf0e10cSrcweir oObj = createUnoService( cUnoJavaLoader ) 593cdf0e10cSrcweir LogTestResult( "Java "+ cMessageNewDoc, not IsNull (oObj) ) 594cdf0e10cSrcweir 595cdf0e10cSrcweir Print #LocalTestLog, "---" 596cdf0e10cSrcweir Close #LocalTestLog% 597cdf0e10cSrcweir LocalTestLog = 0 598cdf0e10cSrcweir 599cdf0e10cSrcweir TestJava = not IsNull (oObj) 600cdf0e10cSrcweirEnd Function 601cdf0e10cSrcweir 602cdf0e10cSrcweirSub LoadLibrary( LibName as String ) 603cdf0e10cSrcweir 604cdf0e10cSrcweir dim args(1) 605cdf0e10cSrcweir dim arg as new com.sun.star.beans.PropertyValue 606cdf0e10cSrcweir arg.Name = "LibraryName" 607cdf0e10cSrcweir arg.Value = LibName 608cdf0e10cSrcweir args(0) = arg 609cdf0e10cSrcweir 610cdf0e10cSrcweir dim url as new com.sun.star.util.URL 611cdf0e10cSrcweir dim trans as object 612cdf0e10cSrcweir trans = createUnoService("com.sun.star.util.URLTransformer" ) 613cdf0e10cSrcweir url.Complete = "slot:6517" 614cdf0e10cSrcweir trans.parsestrict( url ) 615cdf0e10cSrcweir 616cdf0e10cSrcweir dim disp as object 617cdf0e10cSrcweir disp = StarDesktop.currentFrame.queryDispatch( url, "", 0 ) 618cdf0e10cSrcweir disp.dispatch( url, args() ) 619cdf0e10cSrcweir 620cdf0e10cSrcweirEnd Sub 621cdf0e10cSrcweir 622cdf0e10cSrcweirSub LoadDoc (DocName as String) as Object 623cdf0e10cSrcweir dim trans as object 624cdf0e10cSrcweir trans = createUnoService("com.sun.star.util.URLTransformer" ) 625cdf0e10cSrcweir url = createUnoStruct("com.sun.star.util.URL" ) 626cdf0e10cSrcweir url.Complete = DocName 627cdf0e10cSrcweir if Left(DocName, 5 ) <> "file:" then 628cdf0e10cSrcweir trans.parsestrict( url ) 629cdf0e10cSrcweir endif 630cdf0e10cSrcweir 631cdf0e10cSrcweir Dim aPropArray(0) as Object 632cdf0e10cSrcweir aPropArray(0) = CreateUnoStruct("com.sun.star.beans.PropertyValue") 633cdf0e10cSrcweir aPropArray(0).Name = "OpenFlags" 634cdf0e10cSrcweir aPropArray(0).Value = "S" 635cdf0e10cSrcweir 636cdf0e10cSrcweir dim doc as object 637cdf0e10cSrcweir dim noargs() 638cdf0e10cSrcweir doc = StarDesktop.loadComponentFromURL( url.Complete, "_blank", 0, aPropArray() ) ' XModel 639cdf0e10cSrcweir LoadDoc = doc 640cdf0e10cSrcweirEnd Sub 641cdf0e10cSrcweir 642cdf0e10cSrcweirSub SaveDoc (DocName as String, oDoc as Object, sFilterName as string ) 643cdf0e10cSrcweir dim trans as object 644cdf0e10cSrcweir trans = createUnoService("com.sun.star.util.URLTransformer" ) 645cdf0e10cSrcweir url = createUnoStruct("com.sun.star.util.URL" ) 646cdf0e10cSrcweir url.Complete = DocName 647cdf0e10cSrcweir if Left(DocName, 5 ) <> "file:" then 648cdf0e10cSrcweir trans.parsestrict( url ) 649cdf0e10cSrcweir endif 650cdf0e10cSrcweir 651cdf0e10cSrcweir if not (sFilterName = "") then 652cdf0e10cSrcweir Dim aPropArray(0) as Object 653cdf0e10cSrcweir aPropArray(0) = CreateUnoStruct("com.sun.star.beans.PropertyValue") 654cdf0e10cSrcweir aPropArray(0).Name = "FilterName" 655cdf0e10cSrcweir aPropArray(0).Value = sFilterName 656cdf0e10cSrcweir 657cdf0e10cSrcweir oDoc.storeAsURL( url.Complete, aPropArray() ) 658cdf0e10cSrcweir else 659cdf0e10cSrcweir MessageBox "Filtername is unknown!" 660cdf0e10cSrcweir end if 661cdf0e10cSrcweirend Sub 662cdf0e10cSrcweir 663cdf0e10cSrcweirFunction CloseDoc( oDoc as Object ) 664cdf0e10cSrcweir Dim oListener as Object 665cdf0e10cSrcweir oListener = CreateUnoListener( "Events.closeListener_", "com.sun.star.util.XCloseListener" ) 666cdf0e10cSrcweir oDoc.addCloseListener( oListener ) 667cdf0e10cSrcweir 668cdf0e10cSrcweir Events.ResetCloseListenerFlag() 669cdf0e10cSrcweir oDoc.close( true ) 670cdf0e10cSrcweir closeDoc = Events.HasCloseListenerBeenCalled() 671cdf0e10cSrcweir 672cdf0e10cSrcweir if ( Not Events.HasCloseListenerBeenCalled() ) Then 673cdf0e10cSrcweir ' do this only if closing was not successful - otherwise, we'd get a DisposedException 674cdf0e10cSrcweir oDoc.removeCloseListener( oListener ) 675cdf0e10cSrcweir End If 676cdf0e10cSrcweirEnd Function 677cdf0e10cSrcweir</script:module> 678