LibreOffice Module sot (master) 1
filelist.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <rtl/ustrbuf.hxx>
21#include <tools/stream.hxx>
22#include <sot/filelist.hxx>
23
24/* Stream operators */
25
26/* #i28176#
27 The Windows clipboard bridge now provides a double '\0'
28 terminated list of file names for format SotClipboardFormatId::FILE_LIST
29 instead of the original Windows Sv_DROPFILES structure. All strings
30 in this list are UTF16 strings. Shell link files will be already
31 resolved by the Windows clipboard bridge.*/
32SvStream& ReadFileList( SvStream& rIStm, FileList& rFileList )
33{
34 rFileList.clear();
35
36 OUStringBuffer sBuf(512);
37 sal_uInt16 c;
38
39 while (!rIStm.eof())
40 {
41 // read first character of filepath; c==0 > reach end of stream
42 rIStm.ReadUInt16( c );
43 if (!c)
44 break;
45
46 // read string till c==0
47 while (c && !rIStm.eof())
48 {
49 sBuf.append(static_cast<sal_Unicode>(c));
50 rIStm.ReadUInt16( c );
51 }
52
53 // append the filepath
54 rFileList.AppendFile(sBuf.toString());
55 sBuf.truncate();
56 }
57 return rIStm;
58}
59
60/* Fill in / check the list */
61void FileList::AppendFile( const OUString& rStr )
62{
63 aStrList.push_back( rStr );
64}
65
66OUString FileList::GetFile( size_t i ) const
67{
68 OUString aStr;
69 if( i < aStrList.size() )
70 aStr = aStrList[ i ];
71 return aStr;
72}
73
74size_t FileList::Count() const
75{
76 return aStrList.size();
77}
78
79/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
size_t Count() const
Definition: filelist.cxx:74
void clear()
Definition: filelist.hxx:35
OUString GetFile(size_t nIndex) const
Definition: filelist.cxx:66
std::vector< OUString > aStrList
Definition: filelist.hxx:32
void AppendFile(const OUString &rStr)
Definition: filelist.cxx:61
bool eof() const
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
SvStream & ReadFileList(SvStream &rIStm, FileList &rFileList)
Definition: filelist.cxx:32
aStr
int i
sal_uInt16 sal_Unicode