LibreOffice Module vcl (master) 1
ResourceDict.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
11#include <pdf/ResourceDict.hxx>
12
13namespace vcl::pdf
14{
15namespace
16{
17void appendResourceMap(OStringBuffer& rBuf, const char* pPrefix,
18 std::map<OString, sal_Int32> const& rList)
19{
20 if (rList.empty())
21 return;
22 rBuf.append('/');
23 rBuf.append(pPrefix);
24 rBuf.append("<<");
25 int ni = 0;
26 for (auto const& item : rList)
27 {
28 if (!item.first.isEmpty() && item.second > 0)
29 {
30 rBuf.append('/');
31 rBuf.append(item.first);
32 rBuf.append(' ');
33 rBuf.append(item.second);
34 rBuf.append(" 0 R");
35 if (((++ni) & 7) == 0)
36 rBuf.append('\n');
37 }
38 }
39 rBuf.append(">>\n");
40}
41}
42
43void ResourceDict::append(OStringBuffer& rBuf, sal_Int32 nFontDictObject)
44{
45 rBuf.append("<<\n");
46 if (nFontDictObject)
47 rBuf.append("/Font " + OString::number(nFontDictObject) + " 0 R\n");
48 appendResourceMap(rBuf, "XObject", m_aXObjects);
49 appendResourceMap(rBuf, "ExtGState", m_aExtGStates);
50 appendResourceMap(rBuf, "Shading", m_aShadings);
51 appendResourceMap(rBuf, "Pattern", m_aPatterns);
52 rBuf.append("/ProcSet[/PDF/Text");
53 if (!m_aXObjects.empty())
54 rBuf.append("/ImageC/ImageI/ImageB");
55 rBuf.append("]\n>>\n");
56}
57
58} // end vcl::pdf
59
60/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::map< OString, sal_Int32 > m_aPatterns
std::map< OString, sal_Int32 > m_aExtGStates
void append(OStringBuffer &rBuffer, sal_Int32 nFontDictObject)
std::map< OString, sal_Int32 > m_aShadings
std::map< OString, sal_Int32 > m_aXObjects