1 //========================================================================
2 //
3 // This file is under the GPLv2 or later license
4 //
5 // Copyright (C) 2005-2006 Kristian Høgsberg <krh@redhat.com>
6 // Copyright (C) 2005, 2018-2020 Albert Astals Cid <aacid@kde.org>
7 // Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>
8 // Copyright (C) 2019 Oliver Sander <oliver.sander@tu-dresden.de>
9 //
10 // To see a description of the changes please see the Changelog file that
11 // came with your tarball or type make ChangeLog if you are building from git
12 //
13 //========================================================================
14 
15 #ifndef PAGELABELINFO_H
16 #define PAGELABELINFO_H
17 
18 #include <climits>
19 #include <cstdlib>
20 #include <cstdio>
21 #include <cctype>
22 #include <cassert>
23 #include <string>
24 #include <vector>
25 
26 #include "Object.h"
27 
28 class PageLabelInfo
29 {
30 public:
31     PageLabelInfo(Object *tree, int numPages);
32 
33     PageLabelInfo(const PageLabelInfo &) = delete;
34     PageLabelInfo &operator=(const PageLabelInfo &) = delete;
35 
36     bool labelToIndex(GooString *label, int *index) const;
37     bool indexToLabel(int index, GooString *label) const;
38 
39 private:
40     void parse(const Object *tree, std::set<int> &parsedRefs);
41 
42 private:
43     struct Interval
44     {
45         Interval(Object *dict, int baseA);
46 
47         std::string prefix;
48         enum NumberStyle
49         {
50             None,
51             Arabic,
52             LowercaseRoman,
53             UppercaseRoman,
54             UppercaseLatin,
55             LowercaseLatin
56         } style;
57         int first, base, length;
58     };
59 
60     std::vector<Interval> intervals;
61 };
62 
63 #endif
64