1 'encoding UTF-8 Do not remove or change this line!
2 '**************************************************************************
3 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 '* Copyright 2008 by Sun Microsystems, Inc.
7 '* OpenOffice.org - a multi-platform office productivity suite
9 '* $RCSfile: w_loadsave.inc,v $
11 '* $Revision: 1.1.4.3 $
13 '* last change: $Author: fredrikh $ $Date: 2008/10/06 18:36:45 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org. If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/************************************************************************
34 '* owner : helge.delfs@sun.com
36 '* short description : Checks the export to all available Filters from
38 '***********************************************************************
40 ' #1 tExportAllReadableFormatsIntoODF
41 ' #1 tExportAllReadableFormatsIntoThemselves
42 ' #1 tExportTop5FormatsIntoTop5
44 '\***********************************************************************
46 testcase tExportAllReadableFormatsIntoODF
49 QAErrorlog "#100970#test only support english language"
53 Dim AvailableFilters( 35 ) as String
54 Dim TemplateFilterFile as String
55 Dim ImportFileList ( 300 ) as String
56 Dim ExportFileList ( 300 ) as String
57 Dim WorkDirectory as String
58 Dim ImportDir as String
59 Dim SavedCorrectly as Boolean
60 Dim sExportFilter as string
61 Dim sExportFile as string
64 TemplateFilterFile = ConvertPath ( gTesttoolPath + "writer\optional\input\filterlist.txt")
65 WorkDirectory = ( ConvertPath ( gOfficePath + "user\work\" + gPlatgroup + "\export\"))
66 ImportDir = ConvertPath ( gTesttoolPath + "writer\optional\input\import\")
68 if gSamePC = TRUE then ' delete export directory
69 GetFileList ( WorkDirectory, "*.*", ExportFileList() )
70 if KillFileList ( ExportFileList() ) <> TRUE then
71 Warnlog "Couldn't delete all Files in Output-Directory, the followings are still there:"
72 for i=1 to FehlerListe(0)
73 printlog " <> " & FehlerListe(i)
78 app.Mkdir WorkDirectory
80 Printlog "- Read the directory with files we wish to import."
81 GetFileList ( ImportDir, "*.*", ImportFileList() )
84 printlog "- Start loading files in list"
85 For i = 1 to listCount(ImportFileList())
86 printlog "- " & i & ". load: " & ImportFileList(i)
87 Call hFileOpen ( ImportFileList(i) )
91 if TextImport.Exists then
93 printlog "- Text import dialog passed"
96 Kontext "Filterauswahl"
97 if Filterauswahl.Exists then
99 printlog "- Filterdialog passed"
102 Kontext "AsciiFilterOptionen"
103 if AsciiFilterOptionen.Exists then
104 AsciiFilterOptionen.Ok
105 printlog "- ASCII-Filter dialog passed"
108 Kontext "SecurityWarning"
109 if SecurityWarning.Exists(3) then
111 printlog "- Security warning passed"
114 Kontext "DocumentWriter"
115 if DocumentWriter.Exists(3) then
116 Do until DocumentWriter.StatusIsProgress = false
120 Kontext "DocumentCalc"
121 if DocumentCalc.Exists(3) then
122 Do until DocumentCalc.StatusIsProgress = false
126 Warnlog "Neither DocumentWriter or DocumentCalc existed? Some other dialogue in focus?"
130 ' Check for macro alert
131 Kontext "SecurityWarning"
132 if SecurityWarning.Exists then
133 if inStr(ImportFileList(i),"sw40") = false then
134 QAErrorlog "Macro-Security Warning is up though document should have no macro! Macro disabled"
136 SecurityWarning.Cancel
140 Kontext "AlienWarning"
141 if AlienWarning.Exists then
143 printlog "- Alien warning passed"
146 ' HTML-File can't be exported as odf this way
147 if GetExtention(ImportFileList(i)) <> "html" then
149 sExportFile = WorkDirectory & "ExportedFile" & i & ".odf"
150 Printlog "- Save as : " & ConvertPath ( sExportFile )
151 if hFileSaveAsWithFilterKill (sExportFile, "writer8") = true then
153 printlog "- close file"
156 Printlog "- Open previous saved file"
157 Call hFileOpenWithFilter (sExportFile, "writer8")
159 ' Check for macro alert
160 Kontext "SecurityWarning"
161 if SecurityWarning.Exists then
162 if inStr(ImportFileList(i),"sw40") = false then
163 QAErrorlog "Macro-Security Warning is up though document should have no macro! Macro disabled"
165 SecurityWarning.Cancel
169 Warnlog "Unable to save file: " & sExportFile
172 printlog "- HTML-file is not exported this way"
175 printlog "- Close all open files."
176 Do Until GetDocumentCount = 0
183 '---------------------------------------------------------------------------------------------------------------------
185 testcase tExportAllReadableFormatsIntoThemselves
187 if iSprache <> 1 then
188 QAErrorlog "#100970#test only support english language"
192 Dim AvailableFilters( 35 ) as String
193 Dim TemplateFilterFile as String
194 Dim SavedCorrectly as Boolean
195 Dim ImportFileList ( 300 ) as String
196 Dim ExportFileList ( 300 ) as String
198 Dim sLoadFile as String
199 Dim sSaveFile as String
200 Dim sCurrentFile as String
201 Dim sCurrentFilter as String
202 Dim sWorkDirectory as String
203 Dim sImportDir as String
204 Dim iCurrentFileIndex as Integer
205 Dim iCounter as integer
206 Dim DocumentCount as integer
208 TemplateFilterFile = ConvertPath ( gTesttoolPath + "writer\optional\input\filterlist.txt")
209 sWorkDirectory = ( ConvertPath ( gOfficePath + "user\work\" + gPlatgroup + "\export\"))
210 sImportDir = ConvertPath ( gTesttoolPath + "writer\optional\input\import\")
212 if gSamePC = TRUE then ' delete export directory
213 GetFileList ( sWorkDirectory, "*.*", ExportFileList() )
214 if KillFileList ( ExportFileList() ) <> TRUE then
215 Warnlog "Couldn't delete all Files in Output-Directory, the followings are still there:"
216 for iCounter=1 to FileList(0)
217 printlog " <> " & FileList(i)
221 app.Mkdir sWorkDirectory
223 QAErrorlog "#i102221#Pocketword-filter seems broken."
225 For iCurrentFileIndex = 1 to 16
226 select case iCurrentFileIndex
227 case 1 : sCurrentFile = "xml2.odt"
228 sCurrentFilter = "writer8"
229 case 2 : sCurrentFile = "wpsfile.wps"
230 sCurrentFilter = "Text (encoded)"
231 case 3 : sCurrentFile = "dostext.txt"
232 sCurrentFilter = "Text (encoded)"
233 case 4 : sCurrentFile = "sw30.sdw"
234 sCurrentFilter = "StarWriter 3.0"
235 case 5 : sCurrentFile = "sw50.vor"
236 sCurrentFilter = "StarWriter 5.0 Vorlage/Template"
237 case 6 : sCurrentFile = "sw31.sdw"
238 sCurrentFilter = "StarWriter 3.0"
239 case 7 : sCurrentFile = "sw31.vor"
240 sCurrentFilter = "StarWriter 3.0 Vorlage/Template"
241 case 8 : sCurrentFile = "sw40.sdw"
242 sCurrentFilter = "StarWriter 4.0"
243 case 9 : sCurrentFile = "sw40_sp2.vor"
244 sCurrentFilter = "StarWriter 4.0 Vorlage/Template"
245 case 10 : sCurrentFile = "sw50.sdw"
246 sCurrentFilter = "StarWriter 5.0"
247 case 11 : sCurrentFile = "html.html"
248 sCurrentFilter = "HTML (StarWriter)"
249 case 12 : sCurrentFile = "rtf.rtf"
250 sCurrentFilter = "Rich Text Format"
251 case 13 : sCurrentFile = "sw60.sxw"
252 sCurrentFilter = "StarOffice XML (Writer)"
253 case 14 : sCurrentFile = "winw97.doc"
254 sCurrentFilter = "MS Word 97"
255 case 15 : sCurrentFile = "winword6.doc"
256 sCurrentFilter = "MS Word 95"
257 case 16 : sCurrentFile = "wintext.txt"
258 sCurrentFilter = "Text (encoded)"
259 ' case 17 : sCurrentFile = "pocketword.psw"
260 ' sCurrentFilter = "PocketWord File"
263 'TODO: 18-23 not applyable. Can be opened, but saving in the format is not supported.
265 ' case 18 : sCurrentFile = "unixtext.txt"
266 ' sCurrentFilter = "Text"
267 ' case 19 : sCurrentFile = "sw2.sdw"
268 ' sCurrentFilter = "StarWriter 2.0"
269 ' case 20 : sCurrentFile = "amipro3.sam"
270 ' sCurrentFilter = "Ami Pro 1.x-3.1 (W4W)"
271 ' case 21 : sCurrentFile = "mactext.txt"
272 ' sCurrentFilter = "Mac Write 4.x 5.0 (W4W)"
273 ' case 22 : sCurrentFile = "sw1.sdw"
274 ' sCurrentFilter = "StarWriter 1.0"
275 ' case 23 : sCurrentFile = "swdoc.txt"
276 ' sCurrentFilter = "Text (encoded) (StarWriter/GlobalDocument)"
277 ' case 24 : sCurrentFile = "hangul.hwp"
278 ' sCurrentFilter = "writer_MIZI_Hwp_97"
281 printlog " - Export of File nr " + iCurrentFileIndex + " started."
283 sLoadFile = sImportDir & sCurrentFile
284 sSaveFile = sWorkDirectory & "filenr_" & iCurrentFileIndex
289 Call hFileOpenWithFilter(sLoadFile, sCurrentFilter, false)
292 if active.exists(2) then
294 warnlog "Error with file " + sLoadFile + " as " + sSaveFile + "."
298 if TextImport.Exists then
302 Kontext "Filterauswahl"
303 if Filterauswahl.Exists then
307 Kontext "AsciiFilterOptionen"
308 if AsciiFilterOptionen.Exists then AsciiFilterOptionen.Ok
309 Kontext "SecurityWarning"
310 if SecurityWarning.Exists(3) then SecurityWarning.Ok
311 Kontext "DocumentWriter"
312 if DocumentWriter.Exists(3) then
313 Do until DocumentWriter.StatusIsProgress = false
317 Kontext "DocumentCalc"
318 if DocumentCalc.Exists(3) then
319 Do until DocumentCalc.StatusIsProgress = false
323 Warnlog "Neither DocumentWriter or DocumentCalc existed? Some other dialogue in focus?"
327 ' Check for macro alert
328 Kontext "SecurityWarning"
329 if SecurityWarning.Exists then
330 if inStr(currentfile,"sw40") = false then
331 QAErrorlog "Macro-Security Warning is up though document should have no macro! Macro disabled"
333 SecurityWarning.Cancel
337 Kontext "AlienWarning"
338 if AlienWarning.Exists then AlienWarning.Ok
341 Call hFileSaveAsWithFilterKill(sSaveFile, sCurrentFilter)
344 if active.exists(2) then
346 warnlog "Error saving file " + sLoadFile + " as " + sSaveFile + "."
350 ' Load Out-file again
351 Call hFileOpenWithFilter(sSaveFile, sCurrentFilter, false)
353 ' Check for macro alert
354 Kontext "SecurityWarning"
355 if SecurityWarning.Exists then
356 if inStr(currentfile,"sw40") > 0 then
357 QAErrorlog "Macro-Security Warning is up though document should have no macro! Macro disabled"
359 SecurityWarning.Cancel
364 Warnlog "Error with file: " + sLoadFile
369 if active.exists(2) then
371 warnlog "Error with file " + sLoadFile + " as " + sSaveFile + "."
374 printlog " Close all open files."
375 Do Until GetDocumentCount = 0
379 printlog " - File nr " + iCurrentFileIndex + " completed."
380 Next iCurrentFileIndex
384 '---------------------------------------------------------------------------------------------------------------------
386 testcase tExportTop5FormatsIntoTop5
388 if iSprache <> 1 then
389 QAErrorlog "#100970#test only support english language"
393 Dim ExportFileList(300) as String
394 Dim sWorkDirectory as String
395 Dim sImportDir as String
396 Dim iCurrentLoadFileIndex as Integer
397 Dim sCurrentLoadFile as String
398 Dim sCurrentLoadFilter as String
399 Dim iCurrentSaveFileIndex as Integer
400 Dim sCurrentSaveFile as String
401 Dim sCurrentSaveFilter as String
402 Dim iCounter as Integer
403 Dim DocumentCount as Integer
404 Dim FileList as String
406 sWorkDirectory = ( ConvertPath ( gOfficePath + "user\work\" + gPlatgroup + "\loadsavetop5\"))
407 sImportDir = ConvertPath ( gTesttoolPath + "writer\optional\input\import\")
409 if gSamePC = TRUE then ' delete export directory
410 GetFileList ( sWorkDirectory, "*.*", ExportFileList() )
411 if KillFileList ( ExportFileList() ) <> TRUE then
412 Warnlog "Couldn't delete all Files in Output-Directory, the followings are still there:"
413 for iCounter=1 to FileList(0)
414 printlog " <> " & FileList(i)
418 app.Mkdir sWorkDirectory
420 '// Start of the LOAD-Loop
421 For iCurrentLoadFileIndex = 1 to 4
422 Select case iCurrentLoadFileIndex
423 case 1 : sCurrentLoadFile = "xml2.odt"
424 sCurrentLoadFilter = "writer8"
425 case 2 : sCurrentLoadFile = "sw60.sxw"
426 sCurrentLoadFilter = "StarOffice XML (Writer)"
427 case 3 : sCurrentLoadFile = "winw97.doc"
428 sCurrentLoadFilter = "MS Word 97"
429 case 4 : sCurrentLoadFile = "rtf.rtf"
430 sCurrentLoadFilter = "Rich Text Format"
431 case 5 : sCurrentLoadFile = "html.html"
432 sCurrentLoadFilter = "HTML (StarWriter)"
435 printlog " - Export of File nr " + iCurrentLoadFileIndex + " started."
437 call fLoadTheFile((sImportDir & sCurrentLoadFile), sCurrentLoadFilter)
439 '/// Here comes the SAVE-Loop
440 For iCurrentSaveFileIndex = 1 to 5
441 Select case iCurrentSaveFileIndex
442 case 1 : sCurrentSaveFile = "SavedFile_l" + iCurrentLoadFileIndex + "_s1.odt"
443 sCurrentSaveFilter = "writer8"
444 case 2 : sCurrentSaveFile = "SavedFile_l" + iCurrentLoadFileIndex + "_s2.sxw"
445 sCurrentSaveFilter = "StarOffice XML (Writer)"
446 case 3 : sCurrentSaveFile = "SavedFile_l" + iCurrentLoadFileIndex + "_s3.doc"
447 sCurrentSaveFilter = "MS Word 97"
448 case 4 : sCurrentSaveFile = "SavedFile_l" + iCurrentLoadFileIndex + "_s4.rtf"
449 sCurrentSaveFilter = "Rich Text Format"
450 case 5 : sCurrentSaveFile = "SavedFile_l" + iCurrentLoadFileIndex + "_s5.html"
451 sCurrentSaveFilter = "HTML (StarWriter)"
454 Call hFileSaveAsWithFilterKill((sWorkDirectory & sCurrentSaveFile), sCurrentSaveFilter)
456 if hFileExists (sWorkDirectory & sCurrentSaveFile) then
458 'Check if the saved file can be loaded
459 call fLoadTheFile((sWorkDirectory & sCurrentSaveFile), sCurrentSaveFilter)
461 'Close the opened file
462 Do Until GetDocumentCount = 1
467 Next iCurrentSaveFileIndex
468 '/// Here ends the Save-Loop
472 if active.exists(2) then
474 warnlog "Error. Last file processed: " + sCurrentLoadFile + " as " + sCurrentSaveFile + "."
477 printlog " Close all open files."
479 Do Until GetDocumentCount = 0
483 printlog " - File nr " + iCurrentLoadFileIndex + " completed."
484 Next iCurrentLoadFileIndex
485 '// End of the LOAD-Loop.
488 '---------------------------------------------------------------------------------------------------------------------
490 function fLoadTheFile(sLoadFile as string, sCurrentFilter as string)
494 Call hFileOpenWithFilter(sLoadFile, sCurrentFilter, false)
497 if active.exists(2) then
499 warnlog "Error with file " + sLoadFile + " as " + sSaveFile + "."
503 if TextImport.Exists then
507 Kontext "Filterauswahl"
508 if Filterauswahl.Exists then
512 Kontext "AsciiFilterOptionen"
513 if AsciiFilterOptionen.Exists then AsciiFilterOptionen.Ok
514 Kontext "SecurityWarning"
515 if SecurityWarning.Exists(3) then SecurityWarning.Ok
516 Kontext "DocumentWriter"
517 if DocumentWriter.Exists(3) then
518 Do until DocumentWriter.StatusIsProgress = false
522 Kontext "DocumentCalc"
523 if DocumentCalc.Exists(3) then
524 Do until DocumentCalc.StatusIsProgress = false
528 Warnlog "Neither DocumentWriter or DocumentCalc existed? Some other dialogue in focus?"
532 ' Check for macro alert
533 Kontext "SecurityWarning"
534 if SecurityWarning.Exists then
535 if inStr(currentfile,"sw40") > 0 then
536 QAErrorlog "Macro-Security Warning is up though document should have no macro! Macro disabled"
538 SecurityWarning.Cancel
542 Kontext "AlienWarning"
543 if AlienWarning.Exists then AlienWarning.Ok
546 Warnlog "Error with file: " + sLoadFile
548 end function 'fLoadTheFile
550 '------------------------------------------------------------------------------------------------------------------------------------------------