[poppler] poppler/poppler: PageLabelInfo.cc, 1.3, 1.4 PageLabelInfo.h, 1.2, 1.3

Kristian Høgsberg krh at kemper.freedesktop.org
Tue Feb 28 10:25:02 PST 2006


Update of /cvs/poppler/poppler/poppler
In directory kemper:/tmp/cvs-serv19780/poppler

Modified Files:
	PageLabelInfo.cc PageLabelInfo.h 
Log Message:
2006-02-28  Kristian Høgsberg  <krh at 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).



Index: PageLabelInfo.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/PageLabelInfo.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- PageLabelInfo.cc	18 Jan 2006 22:32:13 -0000	1.3
+++ PageLabelInfo.cc	28 Feb 2006 18:25:00 -0000	1.4
@@ -158,9 +158,9 @@
   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() {
-  gfree(prefix);
+  delete prefix;
 }
 
 PageLabelInfo::PageLabelInfo(Object *tree, int numPages) {
@@ -248,8 +248,8 @@
   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 @@
   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 @@
   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 @@
     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;
 }
 

Index: PageLabelInfo.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/PageLabelInfo.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- PageLabelInfo.h	28 Jul 2005 22:56:17 -0000	1.2
+++ PageLabelInfo.h	28 Feb 2006 18:25:00 -0000	1.3
@@ -23,7 +23,7 @@
   struct Interval {
     Interval(Object *dict, int baseA);
     ~Interval();
-    char *prefix;
+    GooString *prefix;
     enum NumberStyle {
       None,
       Arabic,



More information about the poppler mailing list