bump product version to 4.1.6.2
[LibreOffice.git] / sot / source / base / filelist.cxx
blobd9f85d509e75f3db8f4234ace1f28adef088aec7
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 .
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 \*************************************************************************/
36 FileList::~FileList()
38 ClearAll();
41 void FileList::ClearAll( void )
43 for ( size_t i = 0, n = aStrList.size(); i < n; ++i )
44 delete aStrList[ i ];
45 aStrList.clear();
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 ] ) );
58 return *this;
61 /******************************************************************************
63 |* virtuelle SvData-Methoden
65 \******************************************************************************/
67 void FileList::Load( SvStream& rIStm )
69 rIStm >> *this;
72 void FileList::Save( SvStream& rOStm )
74 rOStm << *this;
77 void FileList::Assign( const SvDataCopyStream& rCopyStream )
79 *this = (const FileList&)rCopyStream;
82 /******************************************************************************
84 |* Stream-Operatoren
86 \******************************************************************************/
89 * NOTE: to correctly handle this Protocol with Unicode, native Win32 must be called:
90 * e.g. DropQueryFile
93 SvStream& operator<<( SvStream& rOStm, SAL_UNUSED_PARAMETER const FileList& )
95 OSL_FAIL("TODO: Not implemented!");
96 return rOStm;
99 /* #i28176#
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();
109 String aStr;
110 sal_uInt16 c;
112 while (!rIStm.IsEof())
114 aStr.Erase();
116 // read first character of filepath; c==0 > reach end of stream
117 rIStm >> c;
118 if (!c)
119 break;
121 // read string till c==0
122 while (c && !rIStm.IsEof())
124 aStr += (sal_Unicode)c;
125 rIStm >> c;
128 // append the filepath
129 rFileList.AppendFile(aStr);
131 return rIStm;
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
147 String aStr;
148 if( i < aStrList.size() )
149 aStr = *aStrList[ i ];
150 return aStr;
153 size_t FileList::Count( void ) const
155 return aStrList.size();
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */