build fix
[LibreOffice.git] / sot / source / base / filelist.cxx
blobb22e2c62acdafd8e60e055a14481c069c73e68e4
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 <sot/exchange.hxx>
23 #include <sot/filelist.hxx>
24 #include <osl/diagnose.h>
25 #include <osl/thread.h>
27 /*************************************************************************
29 |* FileList - Ctor/Dtor
31 \*************************************************************************/
33 FileList::~FileList()
35 ClearAll();
38 void FileList::ClearAll()
40 aStrList.clear();
43 /*************************************************************************
45 |* FileList - Zuweisungsoperator
47 \*************************************************************************/
49 FileList& FileList::operator=( const FileList& rFileList )
51 for (const auto & i : rFileList.aStrList)
52 aStrList.push_back( i );
53 return *this;
56 /******************************************************************************
58 |* Stream-Operatoren
60 \******************************************************************************/
62 /* #i28176#
63 The Windows clipboard bridge now provides a double '\0'
64 terminated list of file names for format SotClipboardFormatId::FILE_LIST
65 instead of the original Windows Sv_DROPFILES structure. All strings
66 in this list are UTF16 strings. Shell link files will be already
67 resolved by the Windows clipboard bridge.*/
68 SvStream& ReadFileList( SvStream& rIStm, FileList& rFileList )
70 rFileList.ClearAll();
72 OUStringBuffer sBuf(512);
73 sal_uInt16 c;
75 while (!rIStm.IsEof())
77 // read first character of filepath; c==0 > reach end of stream
78 rIStm.ReadUInt16( c );
79 if (!c)
80 break;
82 // read string till c==0
83 while (c && !rIStm.IsEof())
85 sBuf.append((sal_Unicode)c);
86 rIStm.ReadUInt16( c );
89 // append the filepath
90 rFileList.AppendFile(sBuf.toString());
91 sBuf.truncate();
93 return rIStm;
96 /******************************************************************************
98 |* Liste fuellen/abfragen
100 \******************************************************************************/
102 void FileList::AppendFile( const OUString& rStr )
104 aStrList.push_back( rStr );
107 OUString FileList::GetFile( size_t i ) const
109 OUString aStr;
110 if( i < aStrList.size() )
111 aStr = aStrList[ i ];
112 return aStr;
115 size_t FileList::Count() const
117 return aStrList.size();
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */