[poppler] poppler/glib: poppler-document.cc, 1.31,
1.32 poppler-page.cc, 1.42, 1.43 poppler-private.h, 1.13,
1.14 test-poppler-glib.c, 1.17, 1.18
Kristian Høgsberg
krh at kemper.freedesktop.org
Tue Feb 28 10:25:02 PST 2006
Update of /cvs/poppler/poppler/glib
In directory kemper:/tmp/cvs-serv19780/glib
Modified Files:
poppler-document.cc poppler-page.cc poppler-private.h
test-poppler-glib.c
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: poppler-document.cc
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-document.cc,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- poppler-document.cc 24 Jan 2006 06:21:39 -0000 1.31
+++ poppler-document.cc 28 Feb 2006 18:25:00 -0000 1.32
@@ -315,40 +315,23 @@
return g_list_reverse (retval);
}
-static gboolean
-has_unicode_marker (GooString *string)
-{
- return ((string->getChar (0) & 0xff) == 0xfe &&
- (string->getChar (1) & 0xff) == 0xff);
-}
-
-static void
-info_dict_get_string (Dict *info_dict, const gchar *key, GValue *value)
+char *_poppler_goo_string_to_utf8(GooString *s)
{
- Object obj;
- GooString *goo_value;
- gchar *result;
-
- if (!info_dict->lookup ((gchar *)key, &obj)->isString ()) {
- obj.free ();
- return;
- }
-
- goo_value = obj.getString ();
+ char *result;
- if (has_unicode_marker (goo_value)) {
- result = g_convert (goo_value->getCString () + 2,
- goo_value->getLength () - 2,
+ if (s->hasUnicodeMarker()) {
+ result = g_convert (s->getCString () + 2,
+ s->getLength () - 2,
"UTF-8", "UTF-16BE", NULL, NULL, NULL);
} else {
int len;
gunichar *ucs4_temp;
int i;
- len = goo_value->getLength ();
+ len = s->getLength ();
ucs4_temp = g_new (gunichar, len + 1);
for (i = 0; i < len; ++i) {
- ucs4_temp[i] = pdfDocEncoding[(unsigned char)goo_value->getChar(i)];
+ ucs4_temp[i] = pdfDocEncoding[(unsigned char)s->getChar(i)];
}
ucs4_temp[i] = 0;
@@ -357,6 +340,25 @@
g_free (ucs4_temp);
}
+ return result;
+}
+
+static void
+info_dict_get_string (Dict *info_dict, const gchar *key, GValue *value)
+{
+ Object obj;
+ GooString *goo_value;
+ gchar *result;
+
+ if (!info_dict->lookup ((gchar *)key, &obj)->isString ()) {
+ obj.free ();
+ return;
+ }
+
+ goo_value = obj.getString ();
+
+ result = _poppler_goo_string_to_utf8(goo_value);
+
obj.free ();
g_value_set_string (value, result);
@@ -382,7 +384,7 @@
goo_value = obj.getString ();
- if (has_unicode_marker (goo_value)) {
+ if (goo_value->hasUnicodeMarker()) {
date_string = g_convert (goo_value->getCString () + 2,
goo_value->getLength () - 2,
"UTF-8", "UTF-16BE", NULL, NULL, NULL);
Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-page.cc,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- poppler-page.cc 24 Jan 2006 06:21:39 -0000 1.42
+++ poppler-page.cc 28 Feb 2006 18:25:00 -0000 1.43
@@ -498,14 +498,18 @@
selection->x2, selection->y2);
GfxColor gfx_background_color = {
- background_color->red,
- background_color->green,
- background_color->blue
+ {
+ background_color->red,
+ background_color->green,
+ background_color->blue
+ }
};
GfxColor gfx_glyph_color = {
- glyph_color->red,
- glyph_color->green,
- glyph_color->blue
+ {
+ glyph_color->red,
+ glyph_color->green,
+ glyph_color->blue
+ }
};
text_dev = poppler_page_get_text_output_dev (page);
@@ -687,7 +691,7 @@
matches = NULL;
xMin = 0;
yMin = 0;
-#warning you probably want to add caseSensitive and backwards as parameters
+
while (output_dev->findText (ucs4, ucs4_len,
gFalse, gTrue, // startAtTop, stopAtBottom
gTrue, gFalse, // startAtLast, stopAtLast
@@ -745,12 +749,15 @@
{
PopplerPage *page = POPPLER_PAGE (object);
GooString label;
+ char *utf8_label;
switch (prop_id)
{
case PROP_LABEL:
page->document->doc->getCatalog ()->indexToLabel (page->index, &label);
- g_value_set_string (value, label.getCString());
+ utf8_label = _poppler_goo_string_to_utf8(&label);
+ g_value_set_string (value, utf8_label);
+ g_free (utf8_label);
break;
}
}
Index: poppler-private.h
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-private.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- poppler-private.h 24 Jan 2006 06:21:39 -0000 1.13
+++ poppler-private.h 28 Feb 2006 18:25:00 -0000 1.14
@@ -67,4 +67,7 @@
PopplerAttachment *_poppler_attachment_new (PopplerDocument *document,
EmbFile *file);
+
+char *_poppler_goo_string_to_utf8(GooString *s);
+
#endif
Index: test-poppler-glib.c
===================================================================
RCS file: /cvs/poppler/poppler/glib/test-poppler-glib.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- test-poppler-glib.c 24 Jan 2006 06:21:39 -0000 1.17
+++ test-poppler-glib.c 28 Feb 2006 18:25:00 -0000 1.18
@@ -218,7 +218,7 @@
poppler_attachment_save (attachment, name, NULL);
i++;
}
- g_list_foreach (list, g_object_unref, NULL);
+ g_list_foreach (list, (GFunc) g_object_unref, NULL);
g_list_free (list);
}
else
More information about the poppler
mailing list