1/*
2 * Copyright (C) 2009, Pino Toscano <pino@kde.org>
3 * Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
4 * Copyright (C) 2014, Hans-Peter Deifel <hpdeifel@gmx.de>
5 * Copyright (C) 2016 Jakub Alba <jakubalba@gmail.com>
6 * Copyright (C) 2018, 2020, Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
7 * Copyright (C) 2018, 2020 Adam Reichold <adam.reichold@t-online.de>
8 * Copyright (C) 2018, 2020 Albert Astals Cid <aacid@kde.org>
9 * Copyright (C) 2018, Zsombor Hollay-Horvath <hollay.horvath@gmail.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
14 * any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
24 */
25
26#ifndef POPPLER_PRIVATE_H
27#define POPPLER_PRIVATE_H
28
29#include "poppler-global.h"
30#include "poppler-rectangle.h"
31#include "poppler-page.h" // to use text_box::writing_mode_enum
32
33#include "Error.h"
34#include "CharTypes.h"
35
36#include <cstdarg>
37
38class GooString;
39class PDFRectangle;
40
41#define PSTR(str) const_cast<char *>(str)
42
43namespace poppler {
44
45namespace detail {
46
47extern debug_func user_debug_function;
48extern void *debug_closure;
49void error_function(ErrorCategory category, Goffset pos, const char *msg);
50
51rectf pdfrectangle_to_rectf(const PDFRectangle &pdfrect);
52
53ustring unicode_GooString_to_ustring(const GooString *str);
54ustring unicode_to_ustring(const Unicode *u, int length);
55GooString *ustring_to_unicode_GooString(const ustring &str);
56
57}
58
59template<typename ConstIterator>
60void delete_all(ConstIterator it, ConstIterator end)
61{
62 while (it != end) {
63 delete *it++;
64 }
65}
66
67template<typename Collection>
68void delete_all(const Collection &c)
69{
70 delete_all(c.begin(), c.end());
71}
72
73class font_info;
74struct text_box_font_info_data
75{
76 ~text_box_font_info_data();
77
78 double font_size;
79 std::vector<text_box::writing_mode_enum> wmodes;
80
81 /*
82 * a duplication of the font_info_cache created by the
83 * poppler::font_iterator and owned by the poppler::page
84 * object. Its lifetime might differ from that of text_box
85 * object (think about collecting all text_box objects
86 * from all pages), so we have to duplicate it into all
87 * text_box instances.
88 */
89 std::vector<font_info> font_info_cache;
90
91 /*
92 * a std::vector from the glyph index in the owner
93 * text_box to the font_info index in font_info_cache.
94 * The "-1" means no corresponding fonts found in the
95 * cache.
96 */
97 std::vector<int> glyph_to_cache_index;
98};
99
100class font_info;
101struct text_box_data
102{
103 ~text_box_data();
104
105 ustring text;
106 rectf bbox;
107 int rotation;
108 std::vector<rectf> char_bboxes;
109 bool has_space_after;
110
111 std::unique_ptr<text_box_font_info_data> text_box_font;
112};
113
114}
115
116#endif
117

source code of poppler/cpp/poppler-private.h