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: extras_modify_objects.inc,v $
13 '* last change: $Author: rt $ $Date: 2008-08-28 11:40:12 $
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 : joerg.skottke@sun.com
36 '* short description : Perform standard operations on all samples/templates etc.
38 '\***********************************************************************
40 private const MAX_FILE_COUNT = 3000 ' the max number of templates or samples
42 ' NOTE: Usually we have only about a 100 templates but in multi-language
43 ' installations there are more than 2100. You should not run these
44 ' tests on multi language installations. Really.
46 testcase tModifyObjects( iMode as integer, cCategory as string, sVer as string )
48 const CFN = "tModifyObjects::"
50 const TEMPLATE_COUNT = 236 ' For en-US/StarOffice, numbers may differ for Languages/Brands
51 const SAMPLE_COUNT = 60 ' For en-US/StarOffice, numbers may differ for Languages/Brands
53 '///<h1>Open all Objects, save, close, reload, save and close them</h1>
54 '///<i>The test should be able to handle any OOo 1.x and 2.x files</i><br>
57 dim iObjectFolder as integer
58 dim iObjectFolders as integer
60 dim iObject as integer ' Iterator
61 dim iObjectCount( 20 ) as integer
62 dim iObjectSum as integer : iObjectSum = 0
63 dim iObjectCountExpected as integer
67 sPath = hGetWorkPath()
72 dim iReset as integer : iReset = 0
76 select case( lcase( cCategory ))
77 case "templates" : iObjectCountExpected = TEMPLATE_COUNT
78 case "samples" : iObjectCountExpected = SAMPLE_COUNT
81 '///+<li>Open File->New->Templates and documents</li>
84 '///+<li>select the category in the template dialog (left pane)</li>
85 hSelectCategory( cCategory )
87 '///+<li>Get the number of folders in the root of cCategory</li>
88 iObjectFolders = FileList.getItemCount()
90 '///+<li>get the number of all objects below cCategory and its subfolders</li>
91 for iObject = 1 to iObjectFolders
93 '///+<li>select and open a folder</li>
94 hSelectFileFolder( iObject , true )
96 '///+<li>count the items in the list</li>
97 iObjectCount( iObject ) = FileList.getItemCount()
98 iObjectSum = iObjectSum + iObjectCount( iObject )
100 '///+<li>move back up to the root of cCategory</li>
105 if ( gProductName = "StarOffice" and gISOLang = "en-US" ) then
106 if ( iObjectSum <> iObjectCountExpected ) then
107 warnlog( "Number of objects has changed. OLD: " & iObjectCountExpected &_
108 " NEW: " & iObjectSum )
110 printlog( "Object count is ok for en-US / StarOffice" )
113 printlog( "Template count testing skipped for non-en_US/StarOffice" )
116 Kontext "TemplateAndDocuments"
118 '///+<li>Click the document-info button, do not load the preview</li>
121 '///+<li>close the templates and samples dialog</li>
122 TemplateAndDocuments.cancel()
125 printlog( "Starting to load/save/close/reload/close all Objects" )
128 '///+<li>Step through all folders and Objects</li>
129 for iObjectFolder = 1 to iObjectFolders
131 for iObject = 1 to iObjectCount( iObjectFolder )
133 ' to skip a document add the rule here and jump to SkipThisObject:
135 gApplication = "WRITER"
138 printlog( "Folder index = " & iObjectFolder & ", Object index = " & iObject )
140 do while ( getDocumentCount > 0 )
144 if ( iReset = 10 ) then
146 call exitRestartTheOffice()
154 '///+<li>Select the desired-category: Templates/Samples ...</li>
155 hSelectCategory( cCategory )
157 '///+<li>Select the current folder</li>
158 hSelectFileFolder( iObjectFolder , false )
160 '///+<li>Select the desired Object, open or edit it</li>
161 crc = hSelectDocumentObject( iObject , iMode )
163 '///+<li>If the object can be edited we open it. Skip otherwise</li>
164 ' treat it like a folder
165 kontext "TemplateAndDocuments"
166 if ( TemplateAndDocuments.exists() ) then
167 if ( not edit.isEnabled() ) then
171 printlog( "Templates And Documents dialog is closed" )
174 '///+<li>If object is a folder, we skip the entire test</li>
175 if ( crc = "Folder" ) then
176 printlog( CFN & "Object is folder or #edit# is disabled, skipping" )
178 TemplateAndDocuments.cancel()
182 '///+<li>Cancel the filterdialog if present -> bug</li>
183 irc = hFileWait( false )
186 warnlog( "Load failure: ASCII filter dialog displayed" )
187 kontext "FilterAuswahl"
188 FilterAuswahl.cancel()
192 printlog( CFN & "Skipping document" )
195 '///+<li>Close the navigator if present</li>
196 brc = hCloseNavigator()
198 '///+<li>Build the filename</li>
199 sFile = sPath & cCategory & iObjectFolder & "_" & iObject
201 '///+<li>Save the file without suffix, use default filter, overwrite</li>
202 brc = hFileSaveAsKill( sFile )
204 '///+<li>Close the document</li>
205 brc = hDestroyDocument()
207 '///+<li>Load the file again</li>
208 brc = hFileOpen( sFile )
209 brc = hHandleActivesOnLoad( 1 , 2 )
211 '///+<li>Close the navigator if present</li>
212 brc = hCloseNavigator()
214 '///+<li>Close the document</li>
215 brc = hDestroyDocument()
217 '///+<li>Delete the file after completion</li>
218 brc = hDeleteFile( sFile )