1 /*************************************************************************
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: filelist.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sot.hxx"
34 #include<tools/list.hxx>
35 #include<tools/stream.hxx>
36 #include<tools/string.hxx>
37 #include<tools/rtti.hxx>
38 #include<sot/exchange.hxx>
39 #include<filelist.hxx>
40 #include <osl/thread.h>
42 TYPEINIT1_AUTOFACTORY( FileList
, SvDataCopyStream
);
44 // String-Liste zum Speichern der Namen deklarieren
45 DECLARE_LIST( FileStringList
, String
* )
48 /*************************************************************************
50 |* FileList - Ctor/Dtor
52 \*************************************************************************/
56 pStrList
= new FileStringList();
64 void FileList::ClearAll( void )
66 // Strings in der Liste loeschen
67 ULONG nCount
= pStrList
->Count();
68 for( ULONG i
= 0 ; i
< nCount
; i
++ )
69 delete pStrList
->GetObject( i
);
75 /*************************************************************************
77 |* FileList - Zuweisungsoperator
79 \*************************************************************************/
81 FileList
& FileList::operator=( const FileList
& rFileList
)
84 *pStrList
= *rFileList
.pStrList
;
86 // Strings in der Liste kopieren
87 ULONG nCount
= pStrList
->Count();
88 for( ULONG i
= 0 ; i
< nCount
; i
++ )
89 pStrList
->Replace( new String( *rFileList
.pStrList
->GetObject( i
) ), i
);
94 /*************************************************************************
96 |* FileList::GetFormatName()
98 \*************************************************************************/
100 ULONG
FileList::GetFormat()
102 return FORMAT_FILE_LIST
;
105 /******************************************************************************
107 |* virtuelle SvData-Methoden
109 \******************************************************************************/
111 void FileList::Load( SvStream
& rIStm
)
116 void FileList::Save( SvStream
& rOStm
)
121 void FileList::Assign( const SvDataCopyStream
& rCopyStream
)
123 *this = (const FileList
&)rCopyStream
;
126 /******************************************************************************
130 \******************************************************************************/
133 * NOTE: to correctly handle this Protocol with Unicode, native Win32 must be called:
137 SvStream
& operator<<( SvStream
& rOStm
, const FileList
& /*rFileList*/ )
139 OSL_ENSURE(false, "Not implemented!");
144 The Windows clipboard bridge now provides a double '\0'
145 terminated list of file names for format SOT_FORMAT_FILE_LIST
146 instead of the original Windows Sv_DROPFILES structure. All strings
147 in this list are UTF16 strings. Shell link files will be already
148 resolved by the Windows clipboard bridge.*/
149 SvStream
& operator>>( SvStream
& rIStm
, FileList
& rFileList
)
151 rFileList
.ClearAll();
152 rFileList
.pStrList
= new FileStringList();
157 while (!rIStm
.IsEof())
161 // read first character of filepath; c==0 > reach end of stream
166 // read string till c==0
167 while (c
&& !rIStm
.IsEof())
169 aStr
+= (sal_Unicode
)c
;
173 // append the filepath
174 rFileList
.AppendFile(aStr
);
179 /******************************************************************************
181 |* Liste fuellen/abfragen
183 \******************************************************************************/
185 void FileList::AppendFile( const String
& rStr
)
187 pStrList
->Insert( new String( rStr
) , pStrList
->Count() );
190 String
FileList::GetFile( ULONG i
) const
193 if( i
< pStrList
->Count() )
194 aStr
= *pStrList
->GetObject( i
);
198 ULONG
FileList::Count( void ) const
200 return pStrList
->Count();