1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <tools/stream.hxx>
22 #include <tools/string.hxx>
23 #include <tools/rtti.hxx>
24 #include <sot/exchange.hxx>
25 #include<sot/filelist.hxx>
26 #include <osl/thread.h>
28 TYPEINIT1_AUTOFACTORY( FileList
, SvDataCopyStream
);
30 /*************************************************************************
32 |* FileList - Ctor/Dtor
34 \*************************************************************************/
41 void FileList::ClearAll( void )
43 for ( size_t i
= 0, n
= aStrList
.size(); i
< n
; ++i
)
48 /*************************************************************************
50 |* FileList - Zuweisungsoperator
52 \*************************************************************************/
54 FileList
& FileList::operator=( const FileList
& rFileList
)
56 for ( size_t i
= 0, n
= rFileList
.aStrList
.size(); i
< n
; ++i
)
57 aStrList
.push_back( new String( *rFileList
.aStrList
[ i
] ) );
61 /******************************************************************************
63 |* virtuelle SvData-Methoden
65 \******************************************************************************/
67 void FileList::Load( SvStream
& rIStm
)
72 void FileList::Save( SvStream
& rOStm
)
77 void FileList::Assign( const SvDataCopyStream
& rCopyStream
)
79 *this = (const FileList
&)rCopyStream
;
82 /******************************************************************************
86 \******************************************************************************/
89 * NOTE: to correctly handle this Protocol with Unicode, native Win32 must be called:
93 SvStream
& operator<<( SvStream
& rOStm
, SAL_UNUSED_PARAMETER
const FileList
& )
95 OSL_FAIL("TODO: Not implemented!");
100 The Windows clipboard bridge now provides a double '\0'
101 terminated list of file names for format SOT_FORMAT_FILE_LIST
102 instead of the original Windows Sv_DROPFILES structure. All strings
103 in this list are UTF16 strings. Shell link files will be already
104 resolved by the Windows clipboard bridge.*/
105 SvStream
& operator>>( SvStream
& rIStm
, FileList
& rFileList
)
107 rFileList
.ClearAll();
112 while (!rIStm
.IsEof())
116 // read first character of filepath; c==0 > reach end of stream
121 // read string till c==0
122 while (c
&& !rIStm
.IsEof())
124 aStr
+= (sal_Unicode
)c
;
128 // append the filepath
129 rFileList
.AppendFile(aStr
);
134 /******************************************************************************
136 |* Liste fuellen/abfragen
138 \******************************************************************************/
140 void FileList::AppendFile( const String
& rStr
)
142 aStrList
.push_back( new String( rStr
) );
145 String
FileList::GetFile( size_t i
) const
148 if( i
< aStrList
.size() )
149 aStr
= *aStrList
[ i
];
153 size_t FileList::Count( void ) const
155 return aStrList
.size();
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */