summaryrefslogtreecommitdiff
path: root/poppler/PageLabelInfo.h
blob: 557bc4444f2b472d01f229145a27b1471bcda978 (plain)
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
//========================================================================
//
// This file is under the GPLv2 or later license
//
// Copyright (C) 2005-2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005, 2018, 2019 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>
// Copyright (C) 2019 Oliver Sander <oliver.sander@tu-dresden.de>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
//
//========================================================================

#ifndef PAGELABELINFO_H
#define PAGELABELINFO_H

#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
#include <string>
#include <vector>

#include "Object.h"

class PageLabelInfo {
public:
  PageLabelInfo(Object *tree, int numPages);

  PageLabelInfo(const PageLabelInfo &) = delete;
  PageLabelInfo& operator=(const PageLabelInfo &) = delete;

  bool labelToIndex(GooString *label, int *index) const;
  bool indexToLabel(int index, GooString *label) const;

private:
  void parse(Object *tree);

private:
  struct Interval {
    Interval(Object *dict, int baseA);

    std::string prefix;
    enum NumberStyle {
      None,
      Arabic,
      LowercaseRoman,
      UppercaseRoman,
      UppercaseLatin,
      LowercaseLatin
    } style;
    int first, base, length;
  };

  std::vector<Interval> intervals;
};

#endif