Coverage Report

Created: 2026-09-28 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sot/source/base/filelist.cxx
Line
Count
Source
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.*/
32
SvStream& ReadFileList( SvStream& rIStm, FileList& rFileList )
33
0
{
34
0
    rFileList.clear();
35
36
0
    OUStringBuffer sBuf(512);
37
0
    sal_uInt16 c;
38
39
0
    while (!rIStm.eof())
40
0
    {
41
        // read first character of filepath; c==0 > reach end of stream
42
0
        rIStm.ReadUInt16( c );
43
0
        if (!c)
44
0
            break;
45
46
        // read string till c==0
47
0
        while (c && !rIStm.eof())
48
0
        {
49
0
            sBuf.append(static_cast<sal_Unicode>(c));
50
0
            rIStm.ReadUInt16( c );
51
0
        }
52
53
        // append the filepath
54
0
        rFileList.AppendFile(sBuf.toString());
55
0
        sBuf.truncate();
56
0
    }
57
0
    return rIStm;
58
0
}
59
60
/* Fill in / check the list */
61
void FileList::AppendFile( const OUString& rStr )
62
0
{
63
0
    aStrList.push_back( rStr );
64
0
}
65
66
OUString FileList::GetFile( size_t i ) const
67
0
{
68
0
    OUString aStr;
69
0
    if( i < aStrList.size() )
70
0
        aStr = aStrList[ i ];
71
0
    return aStr;
72
0
}
73
74
size_t FileList::Count() const
75
0
{
76
0
    return aStrList.size();
77
0
}
78
79
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */