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_reserved_names_windows.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 ( extended tests )
38 '\******************************************************************************
40 testcase tSaveReservedNamesWin()
42 if ( gPlatGroup <> "w95" ) then
43 printlog( "Test not relevant for Windows" )
47 '///<h1>Check reserved filenames on Windows using the File-Save dialog</h1>
49 ' This sub creates invalid filenames on Windows and tries to save files
50 ' with those names. This should fail.
51 ' The names are created dependent on the gApplication (documenttype)
52 ' which must have been specified in advance. To generate the names the
53 ' function hNameGenASCII_append( int, boolean ) is used which generates
54 ' the file-suffix based on the current 'gApplication'
55 ' Since saving is expected to fail in every case, there is no reload-test
58 dim cStrangeName as string
59 dim iCounter as integer
64 dim iCurrentDocType as integer
66 for iCurrentDocType = 1 to 2
69 printlog( "Document Type is: " & hNumericDocType( iCurrentDocType ) )
72 '///+<li>Reserved filenames are e.g. LPT1, COM2, NUL etc.</li>
75 printlog( "Check if reserved filenames on Windows are handled ok" )
79 ' serial ports with extension (COM1.xxx-COM9.xxx are not allowed)
80 '///+<li>Try to save files to names of serial ports with extension</li>
81 printlog( CHR$(13) + "Serial ports with extensions" )
82 for iCounter = 1 to MAX_NUMBER
83 cStrangeName = "COM" & CHR$( iCounter + 48 )
84 cStrangeName = cStrangeName & hGetSuffix( "current" )
85 brc = hSaveFileExpectFailure( cStrangeName , 0 )
86 if ( not brc ) then warnlog( "failed" )
90 ' parallel ports with extension (LPT1.xxx-LPT9.xxx are not allowed)
91 '///+<li>Try to save files to parallel ports with extension</li>
92 printlog( CHR$(13) + "Parallel ports with extension" )
93 for iCounter = 1 to MAX_NUMBER
94 cStrangeName = "LPT" & CHR$( iCounter + 48 )
95 cStrangeName = cStrangeName & hGetSuffix( "current" )
96 brc = hSaveFileExpectFailure( cStrangeName , 0 )
97 if ( not brc ) then warnlog( "failed" )
102 printlog( "Reserved characters" )
104 ' descr: hNameGenASCII_append takes an ASCII-char as int and a boolean
105 ' value for "append file suffix" if true
106 ' descr: SaveFileExpectFailure takes a filename and a numeric value for
107 ' the type of errorhandling (0 = invalid char, 1 = path separator)
109 cStrangeName = hNameGen_append( 60 ) ' char "<"
110 brc = hSaveFileExpectFailure( cStrangeName , 0 )
111 if ( not brc ) then warnlog( "failed" )
113 cStrangeName = hNameGen_append( 62 ) ' char ">"
114 brc = hSaveFileExpectFailure( cStrangeName , 0 )
115 if ( not brc ) then warnlog( "failed" )
117 cStrangeName = hNameGen_append( 34 ) ' char '"'
118 brc = hSaveFileExpectFailure( cStrangeName , 0 )
119 if ( not brc ) then warnlog( "failed" )
121 cStrangeName = hNameGen_append( 124 ) ' char "|"
122 brc = hSaveFileExpectFailure( cStrangeName , 0 )
123 if ( not brc ) then warnlog( "failed" )
125 'misinterpreted characters (seen as UNC name or device by Windows)
126 cStrangeName = hNameGen_append( 92 ) ' char "\"
127 brc = hSaveFileExpectFailure( cStrangeName , 1 )
128 if ( not brc ) then warnlog( "failed" )
130 cStrangeName = hNameGen_append( 47 ) ' char "/"
131 brc = hSaveFileExpectFailure( cStrangeName , 1 )
132 if ( not brc ) then warnlog( "failed" )
134 cStrangeName = hNameGen_append( 58 ) ' char ":"
135 brc = hSaveFileExpectFailure( cStrangeName , 0 )
136 if ( not brc ) then warnlog( "failed" )
138 '///+<li>Close the document</li>
139 printlog( "Close the document" )
140 brc = hDestroyDocument()