LibreOffice Module vcl (master) 1
ExternalPDFStreams.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 */
10
12#include <comphelper/hash.hxx>
13
14namespace vcl
15{
16sal_Int32 ExternalPDFStreams::store(BinaryDataContainer const& rDataContainer)
17{
18 sal_Int32 nIndex = -1;
19
20 std::vector<sal_uInt8> aHash = comphelper::Hash::calculateHash(
21 rDataContainer.getData(), rDataContainer.getSize(), comphelper::HashType::SHA1);
22
23 auto it = maStreamIndexMap.find(aHash);
24 if (it == maStreamIndexMap.end())
25 {
26 auto& rExternalStream = maStreamList.emplace_back();
27 rExternalStream.maDataContainer = rDataContainer;
28 nIndex = maStreamList.size() - 1;
29 maStreamIndexMap.emplace(aHash, nIndex);
30 }
31 else
32 {
33 nIndex = it->second;
34 }
35
36 return nIndex;
37}
38
40}
41
42/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Container for the binary data, whose responsibility is to manage the make it as simple as possible to...
const sal_uInt8 * getData() const
static std::vector< unsigned char > calculateHash(const unsigned char *pInput, size_t length, HashType eType)
ExternalPDFStream & get(sal_uInt32 nIndex)
std::vector< ExternalPDFStream > maStreamList
std::map< std::vector< sal_uInt8 >, sal_Int32 > maStreamIndexMap
sal_Int32 store(BinaryDataContainer const &rDataContainer)
sal_Int32 nIndex