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 2000, 2010 Oracle and/or its affiliates.
7 ' OpenOffice.org - a multi-platform office productivity suite
9 ' This file is part of OpenOffice.org.
11 ' OpenOffice.org is free software: you can redistribute it and/or modify
12 ' it under the terms of the GNU Lesser General Public License version 3
13 ' only, as published by the Free Software Foundation.
15 ' OpenOffice.org is distributed in the hope that it will be useful,
16 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ' GNU Lesser General Public License version 3 for more details
19 ' (a copy is included in the LICENSE file that accompanied this code).
21 ' You should have received a copy of the GNU Lesser General Public License
22 ' version 3 along with OpenOffice.org. If not, see
23 ' <http://www.openoffice.org/license.html>
24 ' for a copy of the LGPLv3 License.
26 '/************************************************************************
28 '* owner : gregor.hartmann@oracle.com
30 '* short description : check the internal file dialog ( extended tests )
32 '\******************************************************************************
34 testcase tSaveReservedNamesWin()
36 if ( gPlatGroup <> "w95" ) then
37 printlog( "Test not relevant for Windows" )
42 ' This sub creates invalid filenames on Windows and tries to save files
43 ' with those names. This should fail.
44 ' The names are created dependent on the gApplication (documenttype)
45 ' which must have been specified in advance. To generate the names the
46 ' function hNameGenASCII_append( int, boolean ) is used which generates
47 ' the file-suffix based on the current 'gApplication'
48 ' Since saving is expected to fail in every case, there is no reload-test
51 dim cStrangeName as string
52 dim iCounter as integer
57 dim iCurrentDocType as integer
59 for iCurrentDocType = 1 to 2
62 printlog( "Document Type is: " & hNumericDocType( iCurrentDocType ) )
66 printlog( "Check if reserved filenames on Windows are handled ok" )
70 ' serial ports with extension (COM1.xxx-COM9.xxx are not allowed)
71 printlog( CHR$(13) + "Serial ports with extensions" )
72 for iCounter = 1 to MAX_NUMBER
73 cStrangeName = "COM" & CHR$( iCounter + 48 )
74 cStrangeName = cStrangeName & hGetSuffix( "current" )
75 brc = hSaveFileExpectFailure( cStrangeName , 0 )
76 if ( not brc ) then warnlog( "failed" )
80 ' parallel ports with extension (LPT1.xxx-LPT9.xxx are not allowed)
81 printlog( CHR$(13) + "Parallel ports with extension" )
82 for iCounter = 1 to MAX_NUMBER
83 cStrangeName = "LPT" & CHR$( iCounter + 48 )
84 cStrangeName = cStrangeName & hGetSuffix( "current" )
85 brc = hSaveFileExpectFailure( cStrangeName , 0 )
86 if ( not brc ) then warnlog( "failed" )
91 printlog( "Reserved characters" )
93 ' descr: hNameGenASCII_append takes an ASCII-char as int and a boolean
94 ' value for "append file suffix" if true
95 ' descr: SaveFileExpectFailure takes a filename and a numeric value for
96 ' the type of errorhandling (0 = invalid char, 1 = path separator)
98 cStrangeName = hNameGen_append( 60 ) ' char "<"
99 brc = hSaveFileExpectFailure( cStrangeName , 0 )
100 if ( not brc ) then warnlog( "failed" )
102 cStrangeName = hNameGen_append( 62 ) ' char ">"
103 brc = hSaveFileExpectFailure( cStrangeName , 0 )
104 if ( not brc ) then warnlog( "failed" )
106 cStrangeName = hNameGen_append( 34 ) ' char '"'
107 brc = hSaveFileExpectFailure( cStrangeName , 0 )
108 if ( not brc ) then warnlog( "failed" )
110 cStrangeName = hNameGen_append( 124 ) ' char "|"
111 brc = hSaveFileExpectFailure( cStrangeName , 0 )
112 if ( not brc ) then warnlog( "failed" )
114 'misinterpreted characters (seen as UNC name or device by Windows)
115 cStrangeName = hNameGen_append( 92 ) ' char "\"
116 brc = hSaveFileExpectFailure( cStrangeName , 1 )
117 if ( not brc ) then warnlog( "failed" )
119 cStrangeName = hNameGen_append( 47 ) ' char "/"
120 brc = hSaveFileExpectFailure( cStrangeName , 1 )
121 if ( not brc ) then warnlog( "failed" )
123 cStrangeName = hNameGen_append( 58 ) ' char ":"
124 brc = hSaveFileExpectFailure( cStrangeName , 0 )
125 if ( not brc ) then warnlog( "failed" )
127 printlog( "Close the document" )
128 brc = hDestroyDocument()