-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdfxref.h
86 lines (70 loc) · 2.17 KB
/
pdfxref.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
*
* Copyright: 2012-2017 Boomaga team https://github.com/Boomaga
* Authors:
* Alexander Sokoloff <[email protected]>
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#ifndef PDFXREF_H
#define PDFXREF_H
#include "pdfvalue.h"
#include <QMap>
namespace PDF {
class XRefEntry
{
friend class XRefTable;
public:
enum Type{
Free,
Used,
Compressed
};
XRefEntry():
mPos(0),
mObjNum(0),
mGenNum(0),
mType(Type::Free)
{
}
Type type() const { return mType; }
quint64 pos() const;
PDF::ObjNum objNum() const;
PDF::GenNum genNum() const;
PDF::ObjNum streamObjNum() const;
quint32 streamIndex() const;
private:
qint64 mPos;
PDF::ObjNum mObjNum;
PDF::GenNum mGenNum;
Type mType;
};
class XRefTable: public QMap<PDF::ObjNum, XRefEntry>
{
public:
qint32 maxObjNum() const;
XRefEntry addFreeObject(PDF::ObjNum objNum, PDF::GenNum genNum, PDF::ObjNum nextFreeObj = 0);
XRefEntry addUsedObject(PDF::ObjNum objNum, PDF::GenNum genNum, quint64 pos);
XRefEntry addCompressedObject(PDF::ObjNum objNum, PDF::ObjNum streamObjNum, quint32 streamIndex);
// Restore free entries chain.
void updateFreeChain();
};
} // namespace PDF
QDebug operator<<(QDebug debug, const PDF::XRefEntry &xref);
QDebug operator<<(QDebug debug, const PDF::XRefTable &xrefTable);
#endif // PDFXREF_H