Bump version to 24.04.3.4
[LibreOffice.git] / sot / source / base / filelist.cxx
blob9ccce2cc2bb5f4730f20d4c9012a6afe3a1892aa
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/filelist.hxx>
24 /* Stream operators */
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.*/
32 SvStream& ReadFileList( SvStream& rIStm, FileList& rFileList )
34 rFileList.clear();
36 OUStringBuffer sBuf(512);
37 sal_uInt16 c;
39 while (!rIStm.eof())
41 // read first character of filepath; c==0 > reach end of stream
42 rIStm.ReadUInt16( c );
43 if (!c)
44 break;
46 // read string till c==0
47 while (c && !rIStm.eof())
49 sBuf.append(static_cast<sal_Unicode>(c));
50 rIStm.ReadUInt16( c );
53 // append the filepath
54 rFileList.AppendFile(sBuf.toString());
55 sBuf.truncate();
57 return rIStm;
60 /* Fill in / check the list */
61 void FileList::AppendFile( const OUString& rStr )
63 aStrList.push_back( rStr );
66 OUString FileList::GetFile( size_t i ) const
68 OUString aStr;
69 if( i < aStrList.size() )
70 aStr = aStrList[ i ];
71 return aStr;
74 size_t FileList::Count() const
76 return aStrList.size();
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */