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:19:05 $
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 : Special tasks on filedialogs
38 '\******************************************************************************
40 function hFileOpenMultiSelect( iArray() as integer ) as integer
43 '///<h3>Multiselect files with the fileopen dialog</h3>
44 '///<i>This function uses keyboard navigation to select a number of files
45 '///+ (multiselection).</i><br>
46 '///<u>Starting point</u>: FileOpen dialog has context, workdirectory is
49 '///<u>Input value(s):</u><br>
51 '///+<li>Array (integer)</li>
53 '///+<li>if ( array( n ) = 1 ) select the file at pos n, starting at n = 1</li>
54 '///+<li>Any other value: Do not select, preferably preset with 0!</li>
55 '///+<li>The size of the array must less or equal the number of files in the filepicker<br>
56 '///+ Array( 0 ) is ignored</li>
60 '///<u>Return Value:</u><br>
62 '///+<li>Number of selected files (integer)</li>
64 '///+<li>= 0: any error</li>
65 '///+<li>> 0: Number of selected files (Sum of Array( n ) = 1)</li>
69 const CFN = "hFileOpenMultiSelect::"
70 dim brc as boolean 'a multi purpose boolean returnvalue
72 dim iArraySize as integer
73 dim iCurrentFile as integer
74 dim cCurrentFile as string
75 dim iSelectedFilesCount as integer
76 iSelectedFilesCount = 0
78 '///<u>Description:</u>
80 '///+<li>Get the size of the array</li>
81 iArraySize = ubound( iArray() )
83 '///+<li>Get the number of items from the filepicker</li>
85 iFileCount = Dateiauswahl.getItemCount()
87 '///+<li>Verify that the array size is equal or less the number of files<br>
88 '///+ Exit with rc = 0 on error</li>
89 ' Note: This can be done because it is quite simply expected that we know the
90 ' number of files within the workdirectory. Take one input-dir.
91 if ( iFileCount < iArraySize ) then
92 qaerrorlog( CFN & "Array too large. Array must be <= file count" )
93 printlog( CFN & "Files present in dialog: " & iFileCount )
94 printlog( CFN & "Arraysize..............: " & iArraySize )
95 hFileOpenMultiSelect() = 0
99 '///+<li>Select the first object in the filelist</li>
101 DateiAuswahl.typeKeys( "<HOME>" )
103 '///+<li>Run through the filelist and select all items that are marked in the array</li>
105 for iCurrentFile = 1 to iArraySize
107 '///+<li>Select a file with CTRL+SPACE</li>
108 if ( iArray( iCurrentFile ) = 1 ) then
109 DateiAuswahl.typeKeys( "<MOD1 SPACE>" )
110 cCurrentFile = DateiAuswahl.getSelText() ' does this work?
111 printlog( CFN & "Select: " & cCurrentFile & " at pos: " & iCurrentFile )
112 iSelectedFilesCount = iSelectedFilesCount + 1
115 '///+<li>Move one down with CTRL key pressed</li>
116 DateiAuswahl.typekeys( "<MOD1 DOWN>" )
121 hFileOpenMultiSelect() = 0