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: filedlg_tools.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 12:18:14 $
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 : check the internal file dialog ( 1. part )
38 '\***************************************************************************
40 sub CheckDirectoryName( dirname as string )
42 ' Try to create a folder twice and make sure a warning comes up that the
43 ' folder already exists
46 dim FULLPATH as string
47 FULLPATH = gOfficePath + "user\work\" + dirname + "\"
49 printlog( " - Create the folder and verify it's existence" )
55 printlog( " - creating folder for the " + i + ". time" )
58 printlog( " - press 'new folder' button" )
62 if ( NeuerOrdner.exists( 2 ) ) then
63 printlog( " - name the folder" )
64 OrdnerName.SetText( dirname )
65 printlog( " - press OK")
68 warnlog( "New Folder dialog not displayed" )
71 ' Take care of the File Exists Dialog
72 printlog( " - check for 'File Exists'-Dialog" )
74 If Active.Exists() then
77 'if the file exists during first run of the test: just go on
79 warnlog( "File exists. Did you clean the output-dir?" )
82 'if the active exists, we will return to the 'new folder' dialog
83 'it must be closed as well
87 'this should only be displayed on second run
89 warnlog( "No message that the folder '" + dirname + "' exists!" )
95 printlog( " - verify the existence of the new directory" )
96 if App.Dir ( ConvertPath ( FULLPATH ), 16 ) = "" then
97 Warnlog( "The directory'" + dirname + "' wasn't created!" )
99 printlog( " - delete it")
100 App.RmDir ( ConvertPath ( FULLPATH ) )
106 warnlog( "Could not create the directory. Bugid: #108256# or #106510# ?" )
112 '*******************************************************************************
114 sub CreateInvalidDirectory( dirname as string )
116 'Try to create a directory with a name that is invalid by using characters
117 'that are not allowed for a filesystems. An errormessage is expected.
120 dim FULLPATH as string
121 FULLPATH = gOfficePath + "user\work\" + dirname + "\" 'experimental
123 printlog( " - Trying to create directory <" + FULLPATH + ">" )
128 if ( OeffnenDlg.exists( 2 ) ) then
132 Kontext "NeuerOrdner"
133 if ( NeuerOrdner.exists( 2 ) ) then
135 OrdnerName.SetText( dirname )
138 warnlog( "New Folder dialog did not open" )
142 if gPlatgroup() = "unx" then
144 'unx allows weird filenames
145 if App.Dir ( ConvertPath ( FULLPATH ), 16 ) = "" then
146 Warnlog " the '" + dirname + "'-dir wasn't created!"
148 App.RmDir ( ConvertPath ( FULLPATH ) )
155 if Active.Exists( 2 ) then
157 printlog( " - handle the 'Active' dialog" )
161 if Active.Exists( 2 ) then
162 warnlog( "Double errormessage displayed, one expected." )
166 Kontext "NeuerOrdner"
171 warnlog( "No warning that the folder can't be created!" )
175 if App.Dir( ConvertPath ( FULLPATH ), 16 ) <> "" then
176 Warnlog "The directory '"+ dirname + "' contains invalid chars"
177 App.RmDir( ConvertPath ( FULLPATH ) )
186 warnlog( "Could not create the directory. Bugid: #108256# or #106510# ?" )
192 '*******************************************************************************
194 sub CreateValidDirectory( dirname as string )
196 'Create a directory that has a valid name at a valid location
197 'The directory should not exist.
198 'It will be created in the user's directory
200 dim FULLPATH as string
201 FULLPATH = gOfficePath() + "user\work\" + dirname + "\" 'experimental
204 printlog( " - Trying to create directory: <" + FULLPATH + ">" )
208 printlog( " - Open the file-open dialog" )
212 printlog( " - name the folder" )
213 Kontext "NeuerOrdner"
214 OrdnerName.SetText( dirname )
217 printlog( " - check if the directory has been created" )
218 if App.Dir ( ConvertPath ( FULLPATH ) , 16 ) = "" then
219 warnlog( "The '" + dirname + "' has not been created!" )
221 App.RmDir( ConvertPath ( FULLPATH ) )
222 printlog( " - existing file was successfully deleted" )
227 warnlog( "Could not create the directory. Bugid: #108256# or #106510# ?" )
233 '*******************************************************************************
235 sub CreateValidDirectoryCrop( dirname as string , cropname as string)
237 'Create a directory that has a name with leading or trailing spaces.
238 'Those names are valid but must be cropped.
239 'The directory should not exist.
240 'It will be created in the user's directory.
242 dim FULLPATH as string
243 FULLPATH = gOfficePath + "user\work\" + dirname + "\" 'experimental
244 dim CROPPATH as string
245 CROPPATH = gOfficePath + "user\work\" + cropname + "\" 'experimental
247 printlog( " - Trying to create directory: <" + FULLPATH + ">" )
251 printlog( " - open the file-open dialog" )
255 printlog( " - name the folder" )
256 Kontext "NeuerOrdner"
257 OrdnerName.SetText( dirname )
261 printlog( " - check if the directory has been created" )
262 if App.Dir( ConvertPath ( CROPPATH ), 16 ) = "" then
264 warnlog( "The leading or trailing spaces have not been deleted!" )
269 App.RmDir( ConvertPath ( CROPPATH ) )
270 printlog( " - existing directory was successfully deleted." )
276 warnlog( "Could not create the directory. Bugid: #108256# or #106510# ?" )
282 '*******************************************************************************
284 function LoadDocumentReadOnly ( sDatei as String, TypeOfDocument as Integer, ReadOnlyFlag as Boolean ) as Boolean
286 LoadDocumentReadOnly = TRUE
291 Dateiname.SetText sDatei
293 if ReadOnlyFlag = TRUE then
301 if Active.Exists( 2 ) then
302 LoadDocumentReadOnly = FALSE
303 Warnlog Active.GetText
306 if Active.Exists( 1 ) then
307 Warnlog "A second messagebox is active!"
311 Kontext "Filterauswahl"
312 If FilterAuswahl.Exists( 2 ) then
313 Warnlog "Filterbox is also active!"
318 'printlog( " - check for (unexpected) filter-dialog" )
319 Kontext "Filterauswahl"
321 If ( FilterAuswahl.Exists( 2 ) ) then
322 Warnlog( "Filterbox is active, this is not expected" )
323 FilterAuswahl.Cancel()
325 qaerrorlog( "TODO: There is no way that this function can handle " & _
326 "the filterdialog correctly, rewrite it!" )
327 warnlog( "The test will most likely fail!" )
329 LoadDocumentReadOnly() = false
338 if ( OeffnenDlg.exists( 2 ) ) then
339 warnlog( "File-Open dialog is open, this is not expected at this point" )
340 printlog( "Exiting routine to recover" )
344 LoadDocumentReadOnly() = false
351 select case TypeOfDocument
353 case 1 : InsertSection ' Writer
355 Active.Setpage TabBereiche
356 Kontext "TabBereiche"
358 case 2 : FormatCells ' Calc
360 Active.SetPage TabZahlen
363 case 3 : SlideShowPresentationSettings ' Impress
364 Kontext "Bildschirmpraesentation"
365 Bildschirmpraesentation.Cancel
366 case 4 : InsertLayer ' Draw
367 Kontext "EbeneEinfuegenDlg"
368 EbeneEinfuegenDlg.Cancel
369 case 5 : FormatLegend ' Chart
370 Kontext "TabUmrandungChart" :
371 TabUmrandungChart.Cancel
372 case 6 : FormatFonts ' Math
373 Kontext "Schriftarten"
377 if LoadDocumentReadOnly = TRUE then
378 Warnlog "The document wasn't loaded read only"
387 '*******************************************************************************
389 sub hSetUNIXAttributes()
391 ' NOTE: Requested by TBO
392 ' This sub tries to set the file-attributes on the qatesttool-snapshot on
394 ' Since all BASIC commands are platform independent, it cannot be checked
396 ' If you are not the owner of the testtool snapshot, this is *not* going to
399 '///Make sure the file-attributes are correct for the next tests.
401 dim cFullPath as string
402 dim cParameter as string
403 dim cCommand as string
406 if ( gPLatGroup = "unx" ) then
408 cCommand = "chmod" ' Fallback, if no following definition matches
409 if ( gPlatform = "sol" ) then
410 cCommand = "/usr/bin/chmod"
412 if ( gPlatform = "x86" ) then
413 cCommand = "/usr/bin/chmod"
415 if ( gPlatform = "lin" ) then
416 cCommand = "/bin/chmod"
419 cFullPath = convertpath( gTesttoolPath + "framework/filedlg/input/noentry" )
420 printlog( "Trying to set attributes for " + cFullPath )
421 cParameter = "-R 000 " + cFullPath
422 rc = shell( cCommand , 0 , cParameter , false )
424 ' the readentry-directory must be readonly, the files as well
425 cFullPath = convertpath( gTesttoolPath + "framework/filedlg/input/readentry" )
426 printlog( "Trying to set attributes for " + cFullPath )
427 cParameter = "-R 444 " + cFullPath
428 rc = shell( cCommand , 0 , cParameter , false )
429 'need to remove the "S" attribute
430 cParameter = "-R -s " + cFullPath
431 rc = shell( cCommand , 0 , cParameter , false )
433 ' the readonly-directory: Only the directory is read-only, the files are rw
434 cFullPath = convertpath( gTesttoolPath + "framework/filedlg/input/readonly/*.*" )
435 printlog( "Trying to set attributes for " + cFullPath )
436 cParameter = "444 " + cFullPath
437 rc = shell( cCommand , 0 , cParameter , false )
441 printlog( "No file-attribute setting for non-UNIX platforms" )
448 '*******************************************************************************
450 function hGetFirstNameFromFileList() as string
453 '///<h3>Retrieve the first valid ffilename from the filepickers filelist</h3><br>
455 '///<u>Parameter(s):</u><br>
457 '///+<li>No input parameters</li>
461 '///<u>Returns:</u><br>
463 '///+<li>First valid filename from filelist (either first or second item)</li>
465 '///+<li>Eliminates directory "CVS"</li>
469 const CFN = "hGetFirstNameFromFileList()::"
470 dim brc as boolean 'a multi purpose boolean returnvalue
471 dim cFileName as string
473 '///<u>Description:</u>
475 '///+<li>Select the first item in the filelist of the File Open Dialog</li>
478 Dateiauswahl.typeKeys( "<HOME>" )
479 Dateiauswahl.typeKeys( "<SPACE>" )
481 '///+<li>Retrieve the current name (First entry, usually this is <CVS>)</li>
482 cFileName =lcase( Dateiauswahl.GetSelText() )
483 printlog( CFN & "File: " & cFileName )
485 '///+<li>Intercept blank filename (might be a timing issue)</li>
486 if ( cFileName = "" ) then
487 warnlog( CFN & "Filename is empty, probably a timing issue" )
490 '///+<li>Move one down if we are on the CVS directory</li>
491 if ( cFileName = "cvs" ) then
492 printlog( CFN & "Skipping CVS directory" )
493 Dateiauswahl.TypeKeys( "<Down>" )
495 '///+<li>Retrieve the filename at pos. 2</li>
496 cFileName = lcase ( Dateiauswahl.GetSelText() )
497 printlog( CFN & "File: " & cFileName )
500 '///+<li>Return the filename</li>
501 hGetFirstNameFromFileList() = cFileName