summaryrefslogtreecommitdiff
path: root/poppler
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2006-02-28 18:25:00 +0000
committerKristian Høgsberg <krh@redhat.com>2006-02-28 18:25:00 +0000
commit0f7f2182b2abe965b382937f5569b65a8828fc93 (patch)
tree95818865cfbb40d5d08be32b35356cfde4753e29 /poppler
parent1bf83cdc8b75e1c76956ae643ee273e0b558fd08 (diff)
2006-02-28 Kristian Høgsberg <krh@redhat.com>
* glib/poppler-document.cc (info_dict_get_string): Refactor _popper_goo_string_to_utf8() out into it's own function. * glib/poppler-page.cc (poppler_page_get_property): Use _popper_goo_string_to_utf8() here to convert ucs2 page labels. * glib/poppler-page.cc (poppler_page_get_selection_region): Add braces to fix warning. * poppler/PageLabelInfo.cc: If the label prefix string has a ucs2 marker, append the number part of the label as ucs2 (#5952).
Diffstat (limited to 'poppler')
-rw-r--r--poppler/PageLabelInfo.cc39
-rw-r--r--poppler/PageLabelInfo.h2
2 files changed, 29 insertions, 12 deletions
diff --git a/poppler/PageLabelInfo.cc b/poppler/PageLabelInfo.cc
index 5ca0a1b0..6e70c8ff 100644
--- a/poppler/PageLabelInfo.cc
+++ b/poppler/PageLabelInfo.cc
@@ -158,9 +158,9 @@ PageLabelInfo::Interval::Interval(Object *dict, int baseA) {
obj.free();
if (dict->dictLookup("P", &obj)->isString())
- prefix = copyString(obj.getString()->getCString());
+ prefix = obj.getString()->copy();
else
- prefix = copyString("");
+ prefix = new GooString("");
obj.free();
if (dict->dictLookup("St", &obj)->isInt())
@@ -173,7 +173,7 @@ PageLabelInfo::Interval::Interval(Object *dict, int baseA) {
}
PageLabelInfo::Interval::~Interval() {
- gfree(prefix);
+ delete prefix;
}
PageLabelInfo::PageLabelInfo(Object *tree, int numPages) {
@@ -248,8 +248,8 @@ GBool PageLabelInfo::labelToIndex(GooString *label, int *index)
base = 0;
for (i = 0; i < intervals.getLength(); i++) {
interval = (Interval *) intervals.get(i);
- prefixLength = strlen(interval->prefix);
- if (strncmp(str, interval->prefix, prefixLength) != 0)
+ prefixLength = interval->prefix->getLength();
+ if (label->cmpN(interval->prefix, prefixLength) != 0)
continue;
switch (interval->style) {
@@ -291,9 +291,9 @@ GBool PageLabelInfo::indexToLabel(int index, GooString *label)
char buffer[32];
int i, base, number;
Interval *interval;
+ GooString number_string;
base = 0;
- label->clear();
interval = NULL;
for (i = 0; i < intervals.getLength(); i++) {
interval = (Interval *) intervals.get(i);
@@ -305,19 +305,17 @@ GBool PageLabelInfo::indexToLabel(int index, GooString *label)
if (i == intervals.getLength())
return gFalse;
- label->append(interval->prefix);
-
number = index - base + interval->first;
switch (interval->style) {
case Interval::Arabic:
snprintf (buffer, sizeof(buffer), "%d", number);
- label->append(buffer);
+ number_string.append(buffer);
break;
case Interval::LowercaseRoman:
- toRoman(number, label, gFalse);
+ toRoman(number, &number_string, gFalse);
break;
case Interval::UppercaseRoman:
- toRoman(number, label, gTrue);
+ toRoman(number, &number_string, gTrue);
break;
case Interval::UppercaseLatin:
case Interval::LowercaseLatin:
@@ -327,6 +325,25 @@ GBool PageLabelInfo::indexToLabel(int index, GooString *label)
break;
}
+ label->clear();
+ label->append(interval->prefix);
+ if (label->hasUnicodeMarker()) {
+ int i, len;
+ char ucs2_char[2];
+
+ /* Convert the ascii number string to ucs2 and append. */
+ len = number_string.getLength ();
+ ucs2_char[0] = 0;
+ for (i = 0; i < len; ++i) {
+ ucs2_char[1] = number_string.getChar(i);
+ label->append(ucs2_char, 2);
+ }
+ ucs2_char[1] = 0;
+ label->append(ucs2_char, 2);
+ } else {
+ label->append(&number_string);
+ }
+
return gTrue;
}
diff --git a/poppler/PageLabelInfo.h b/poppler/PageLabelInfo.h
index 98c51be0..f7364194 100644
--- a/poppler/PageLabelInfo.h
+++ b/poppler/PageLabelInfo.h
@@ -23,7 +23,7 @@ private:
struct Interval {
Interval(Object *dict, int baseA);
~Interval();
- char *prefix;
+ GooString *prefix;
enum NumberStyle {
None,
Arabic,