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 .
20 #include <rtl/ustrbuf.hxx>
21 #include <tools/stream.hxx>
22 #include <tools/rtti.hxx>
23 #include <sot/exchange.hxx>
24 #include <sot/filelist.hxx>
25 #include <osl/thread.h>
27 TYPEINIT1_AUTOFACTORY( FileList
, SvDataCopyStream
);
29 /*************************************************************************
31 |* FileList - Ctor/Dtor
33 \*************************************************************************/
40 void FileList::ClearAll( void )
42 for ( size_t i
= 0, n
= aStrList
.size(); i
< n
; ++i
)
47 /*************************************************************************
49 |* FileList - Zuweisungsoperator
51 \*************************************************************************/
53 FileList
& FileList::operator=( const FileList
& rFileList
)
55 for ( size_t i
= 0, n
= rFileList
.aStrList
.size(); i
< n
; ++i
)
56 aStrList
.push_back( new OUString( *rFileList
.aStrList
[ i
] ) );
60 /******************************************************************************
62 |* virtuelle SvData-Methoden
64 \******************************************************************************/
66 void FileList::Load( SvStream
& rIStm
)
71 void FileList::Save( SvStream
& rOStm
)
76 void FileList::Assign( const SvDataCopyStream
& rCopyStream
)
78 *this = (const FileList
&)rCopyStream
;
81 /******************************************************************************
85 \******************************************************************************/
88 * NOTE: to correctly handle this Protocol with Unicode, native Win32 must be called:
92 SvStream
& operator<<( SvStream
& rOStm
, SAL_UNUSED_PARAMETER
const FileList
& )
94 OSL_FAIL("TODO: Not implemented!");
99 The Windows clipboard bridge now provides a double '\0'
100 terminated list of file names for format SOT_FORMAT_FILE_LIST
101 instead of the original Windows Sv_DROPFILES structure. All strings
102 in this list are UTF16 strings. Shell link files will be already
103 resolved by the Windows clipboard bridge.*/
104 SvStream
& operator>>( SvStream
& rIStm
, FileList
& rFileList
)
106 rFileList
.ClearAll();
108 OUStringBuffer
sBuf(512);
111 while (!rIStm
.IsEof())
113 // read first character of filepath; c==0 > reach end of stream
118 // read string till c==0
119 while (c
&& !rIStm
.IsEof())
121 sBuf
.append((sal_Unicode
)c
);
125 // append the filepath
126 rFileList
.AppendFile(sBuf
.toString());
132 /******************************************************************************
134 |* Liste fuellen/abfragen
136 \******************************************************************************/
138 void FileList::AppendFile( const OUString
& rStr
)
140 aStrList
.push_back( new OUString( rStr
) );
143 OUString
FileList::GetFile( size_t i
) const
146 if( i
< aStrList
.size() )
147 aStr
= *aStrList
[ i
];
151 size_t FileList::Count( void ) const
153 return aStrList
.size();
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */