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: ch2_losa.inc,v $
13 '* last change: $Author: obo $ $Date: 2008-07-22 10:36:32 $
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 : oliver.craemer@sun.com
36 '* short description : Load file of one Spreadsheet format and save to another
38 '************************************************************************
40 ' #1 subLoSaFromTo ' Initial routine
43 '\************************************************************************
46 Dim sSourcePath as STRING
47 Dim lsInputFileList ( 500 ) as STRING
48 Dim iFilesInList as INTEGER
49 Dim sCurrentFileInList as STRING
50 Dim iMainIndex as INTEGER
52 '///<u><b>Load/Save files with charts</b></u>
53 printLog Chr(13) + "--------- Save with filter: " & gsFileFormat & " ----------"
54 sSourcePath = convertPath ( gtesttoolpath & "chart2\optional\input\" & gsDirectoryInSourcePath &"\" )
55 '///+<ul><li>Determine list of files to test (All files in 'chart2\loadsave\input\<gsDirectoryInSourcePath>\')</li>
56 Call GetAllFileList( sSourcePath , "*." & gsDirectoryInSourcePath , lsInputFileList() )
57 '///+<li>Determine number of files found</li>
58 iFilesInList = cInt( lsInputFileList(0) )
59 '///+<li>Run testcase 'tLoadSaveFromTo' for each file in list</li></ul>
60 for iMainIndex = 2 to iFilesInList
61 sCurrentFileInList = lsInputFileList( iMainIndex )
62 printlog "* * * * * * *"
63 printlog "Loop " & ( iMainIndex - 1 ) & " of " & ( iFilesInList - 1 )
64 printlog "Test document: " & sCurrentFileInList
65 call tLoadSaveFromTo ( sCurrentFileInList )
69 '*******************************************************************
71 testcase tLoadSaveFromTo ( sCurrentFile as STRING )
72 Dim sCurrentFileLength as INTEGER
73 Dim iCurrentPostionInFileName as INTEGER
74 Dim iLastPathSignePositon as INTEGER
75 Dim sExtractedFileName as STRING
76 Dim sExtractedExtension as STRING
77 Dim sTemporaryFile as STRING
78 Dim sOutputFile as STRING
81 '///<u><b>Load file - SaveAs... - Close - Relaod</b></u>
82 sCurrentFileLength = len ( sCurrentFile )
83 iCurrentPostionInFileName = 0
84 iLastPathSignePositon = 0
85 'Remove path and extension from file name
87 iCurrentPostionInFileName = instr ( iCurrentPostionInFileName + 1 , sCurrentFile , gPathSigne )
88 if iCurrentPostionInFileName = 0 then
91 iLastPathSignePositon = iCurrentPostionInFileName
93 sExtractedFileName = right ( sCurrentFile , sCurrentFileLength - iLastPathSignePositon )
94 sCurrentFileLength = len ( sExtractedFileName )
95 sExtractedExtension = right ( sExtractedFileName , 4 )
96 sExtractedFileName = left ( sExtractedFileName , sCurrentFileLength - 4 )
97 sTemporaryFile = ( gOfficePath & ConvertPath("user\work\TemporaryFileToAvoidLocking" ) )
98 sOutputFile = ( gOfficePath & ConvertPath("user\work\") & sExtractedFileName & "_" & gsDirectoryInSourcePath & "_to" & gsOutputFileCustomExtension )
99 '///+<ul><li>Open test document</li>
101 call hFileOpen(sCurrentFile)
103 warnlog "Serious Problem occured while loading the input file -> Quit"
107 '///+<li>Save file localy to avoid locking issues</li>
108 if hFileSaveAsKill ( sTemporaryFile & sExtractedExtension ) then
109 printlog ">> OK, successfully saved the test document localy!"
111 warnlog "Saving the testdocument localy in source format failed!"
115 '///+<li>Check existence of chart in file using following steps</li>
116 '///+<li>1. Select Chart</li>
117 printlog ">> Check if chart exist after loading file"
120 Kontext "DocumentCalc"
122 '///+<li>2. Invoke 'Edit::Object::Edit' to enter inplace mode</li>
125 '///+<li>3. Invoke Chart Type</li>
127 '///+<li>4. Check if Chart Type came up</li>
129 if ChartType.exists(2) then
130 printlog ">> OK, found a Chart object after loading the file."
132 warnlog "Chart Type did not appear -> Check this out!"
134 '///+<li>5. Close Chart Type</li>
138 warnlog "Chart does not exist in file or a serious problem occured -> Check this out!"
142 '///+<li>Hit 'ESCAPE' key to leave inplace mode</li>
143 Kontext "DocumentCalc"
145 DocumentCalc.TypeKeys "<ESCAPE>"
151 '///+<li>Save file using ODS format</li>
152 printlog "Save file as " & sOutputFile
154 if hFileSaveAsWithFilter ( sOutputFile , gsFileFormat ) then
155 printlog ">> OK, successfully saved the test document!"
157 warnlog "Saving the testdocument failed!"
160 warnlog "A serious problem occured while saving file to target format -> Check this out!"
165 '///+<li>Close document</li>
166 printlog "Closing test document"
170 '///+<li>Open document again</li>
171 printlog "Reloading saved document"
173 call hFileOpen(sOutputFile)
175 warnlog "Serious Problem occured while reloading the output file -> Quit"
180 '///+<li>Check existence of chart after saving to target format in file using following steps</li>
181 '///+<li>1. Select Chart</li>
182 printlog ">> Check if chart exist after saving file to target format"
185 Kontext "DocumentCalc"
187 '///+<li>2. Invoke 'Edit::Object::Edit' to enter inplace mode</li>
189 '///+<li>3. Invoke Chart Type</li>
191 '///+<li>4. Check if Chart Type came up</li>
193 if ChartType.exists(2) then
194 printlog ">> OK, found a Chart object after saving the file to target format."
196 warnlog "Chart Type did not appear after saving the file to target format -> Check this out!"
198 '///+<li>5. Close Chart Type</li>
202 warnlog "Chart does not exist in file or a serious problem occured after saving the file to target format -> Check this out!"
206 '///+<li>Hit 'ESCAPE' key to leave inplace mode</li>
207 Kontext "DocumentCalc"
209 DocumentCalc.TypeKeys "<ESCAPE>"
215 '///+<li>Close document</li>
216 printlog "Closing test document"
218 '///+<li>END</li></ul>