bump product version to 4.2.0.1
[LibreOffice.git] / sot / source / base / filelist.cxx
blobda4cd9f446a1d6bb67972b06fabd1bc6d6bdc10d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 \*************************************************************************/
35 FileList::~FileList()
37 ClearAll();
40 void FileList::ClearAll( void )
42 for ( size_t i = 0, n = aStrList.size(); i < n; ++i )
43 delete aStrList[ i ];
44 aStrList.clear();
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 ] ) );
57 return *this;
60 /******************************************************************************
62 |* virtuelle SvData-Methoden
64 \******************************************************************************/
66 void FileList::Load( SvStream& rIStm )
68 rIStm >> *this;
71 void FileList::Save( SvStream& rOStm )
73 rOStm << *this;
76 void FileList::Assign( const SvDataCopyStream& rCopyStream )
78 *this = (const FileList&)rCopyStream;
81 /******************************************************************************
83 |* Stream-Operatoren
85 \******************************************************************************/
88 * NOTE: to correctly handle this Protocol with Unicode, native Win32 must be called:
89 * e.g. DropQueryFile
92 SvStream& operator<<( SvStream& rOStm, SAL_UNUSED_PARAMETER const FileList& )
94 OSL_FAIL("TODO: Not implemented!");
95 return rOStm;
98 /* #i28176#
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);
109 sal_uInt16 c;
111 while (!rIStm.IsEof())
113 // read first character of filepath; c==0 > reach end of stream
114 rIStm >> c;
115 if (!c)
116 break;
118 // read string till c==0
119 while (c && !rIStm.IsEof())
121 sBuf.append((sal_Unicode)c);
122 rIStm >> c;
125 // append the filepath
126 rFileList.AppendFile(sBuf.toString());
127 sBuf.truncate();
129 return rIStm;
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
145 OUString aStr;
146 if( i < aStrList.size() )
147 aStr = *aStrList[ i ];
148 return aStr;
151 size_t FileList::Count( void ) const
153 return aStrList.size();
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */