~naesten/tex-live/trunk

« back to all changes in this revision

Viewing changes to libs/poppler/poppler-src/poppler/PageLabelInfo.cc

  • Committer: karl
  • Date: 2018-01-09 18:53:05 UTC
  • Revision ID: svn-v4:c570f23f-e606-0410-a88d-b1316a301751:trunk/Build/source:46257
poppler 0.62.0, requiring C++11; luatex not updated yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
// This file is under the GPLv2 or later license
4
4
//
5
5
// Copyright (C) 2005-2006 Kristian Høgsberg <krh@redhat.com>
6
 
// Copyright (C) 2005, 2009, 2013 Albert Astals Cid <aacid@kde.org>
 
6
// Copyright (C) 2005, 2009, 2013, 2017 Albert Astals Cid <aacid@kde.org>
7
7
// Copyright (C) 2011 Simon Kellner <kellner@kit.edu>
8
8
// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
9
9
//
22
22
#include "PageLabelInfo_p.h"
23
23
 
24
24
PageLabelInfo::Interval::Interval(Object *dict, int baseA) {
25
 
  Object obj;
26
 
 
27
25
  style = None;
28
 
  if (dict->dictLookup("S", &obj)->isName()) {
 
26
  Object obj = dict->dictLookup("S");
 
27
  if (obj.isName()) {
29
28
    if (obj.isName("D")) {
30
29
      style = Arabic;
31
30
    } else if (obj.isName("R")) {
38
37
      style = LowercaseLatin;
39
38
    }
40
39
  }
41
 
  obj.free();
42
40
 
43
 
  if (dict->dictLookup("P", &obj)->isString())
 
41
  obj = dict->dictLookup("P");
 
42
  if (obj.isString())
44
43
    prefix = obj.getString()->copy();
45
44
  else
46
45
    prefix = new GooString("");
47
 
  obj.free();
48
46
 
49
 
  if (dict->dictLookup("St", &obj)->isInt())
 
47
  obj = dict->dictLookup("St");
 
48
  if (obj.isInt())
50
49
    first = obj.getInt();
51
50
  else
52
51
    first = 1;
53
 
  obj.free();
54
52
 
55
53
  base = baseA;
56
54
}
86
84
}
87
85
 
88
86
void PageLabelInfo::parse(Object *tree) {
89
 
  Object nums, obj;
90
 
  Object kids, kid, limits, low, high;
91
 
  int i, base;
92
 
  Interval *interval;
93
 
 
94
87
  // leaf node
95
 
  if (tree->dictLookup("Nums", &nums)->isArray()) {
96
 
    for (i = 0; i < nums.arrayGetLength(); i += 2) {
97
 
      if (!nums.arrayGet(i, &obj)->isInt()) {
98
 
        obj.free();
 
88
  Object nums = tree->dictLookup("Nums");
 
89
  if (nums.isArray()) {
 
90
    for (int i = 0; i < nums.arrayGetLength(); i += 2) {
 
91
      Object obj = nums.arrayGet(i);
 
92
      if (!obj.isInt()) {
99
93
        continue;
100
94
      }
101
 
      base = obj.getInt();
102
 
      obj.free();
103
 
      if (!nums.arrayGet(i + 1, &obj)->isDict()) {
104
 
        obj.free();
 
95
      int base = obj.getInt();
 
96
      obj = nums.arrayGet(i + 1);
 
97
      if (!obj.isDict()) {
105
98
        continue;
106
99
      }
107
100
 
108
 
      interval = new Interval(&obj, base);
109
 
      obj.free();
110
 
      intervals.append(interval);
 
101
      intervals.append(new Interval(&obj, base));
111
102
    }
112
103
  }
113
 
  nums.free();
114
104
 
115
 
  if (tree->dictLookup("Kids", &kids)->isArray()) {
116
 
    for (i = 0; i < kids.arrayGetLength(); ++i) {
117
 
      if (kids.arrayGet(i, &kid)->isDict())
 
105
  Object kids = tree->dictLookup("Kids");
 
106
  if (kids.isArray()) {
 
107
    for (int i = 0; i < kids.arrayGetLength(); ++i) {
 
108
      Object kid = kids.arrayGet(i);
 
109
      if (kid.isDict())
118
110
        parse(&kid);
119
 
      kid.free();
120
111
    }
121
112
  }
122
 
  kids.free();
123
113
}
124
114
 
125
115
GBool PageLabelInfo::labelToIndex(GooString *label, int *index)