Coverage Report

Created: 2026-09-28 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/source/pdf/ExternalPDFStreams.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
 */
10
11
#include <pdf/ExternalPDFStreams.hxx>
12
#include <comphelper/hash.hxx>
13
14
namespace vcl
15
{
16
sal_Int32 ExternalPDFStreams::store(BinaryDataContainer const& rDataContainer)
17
0
{
18
0
    sal_Int32 nIndex = -1;
19
20
0
    std::vector<sal_uInt8> aHash = comphelper::Hash::calculateHash(
21
0
        rDataContainer.getData(), rDataContainer.getSize(), comphelper::HashType::SHA1);
22
23
0
    auto it = maStreamIndexMap.find(aHash);
24
0
    if (it == maStreamIndexMap.end())
25
0
    {
26
0
        auto& rExternalStream = maStreamList.emplace_back();
27
0
        rExternalStream.maDataContainer = rDataContainer;
28
0
        nIndex = maStreamList.size() - 1;
29
0
        maStreamIndexMap.emplace(aHash, nIndex);
30
0
    }
31
0
    else
32
0
    {
33
0
        nIndex = it->second;
34
0
    }
35
36
0
    return nIndex;
37
0
}
38
39
0
ExternalPDFStream& ExternalPDFStreams::get(sal_uInt32 nIndex) { return maStreamList.at(nIndex); }
40
}
41
42
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */