Tue Mar 29 02:36:00 2005 Jonathan Blandford <jrb@redhat.com>

        * glib/poppler-document.[ch] (PopplerIndexIter): Add an iter to
        extract the index from the doc.  Includes a bad hack, for now.

Mon Mar 28 22:02:07 2005  Jonathan Blandford  <jrb@redhat.com>

        * glib/poppler-page.cc:
        * glib/poppler-page.h (poppler_page_get_thumbnail_size): New
        function.
        * poppler-glib.pc.in: add -lpoppler-glib to the libs line.
parent 2de98f38
Tue Mar 29 02:36:00 2005 Jonathan Blandford <jrb@redhat.com>
* glib/poppler-document.[ch] (PopplerIndexIter): Add an iter to
extract the index from the doc. Includes a bad hack, for now.
Mon Mar 28 22:02:07 2005 Jonathan Blandford <jrb@redhat.com>
* glib/poppler-page.cc:
* glib/poppler-page.h (poppler_page_get_thumbnail_size): New
function.
* poppler-glib.pc.in: add -lpoppler-glib to the libs line.
2005-03-28 Kristian Høgsberg <krh@redhat.com>
* poppler/Page.cc (loadThumb): Backend agnostic method for
......
......@@ -52,7 +52,6 @@ poppler_document_new_from_file (const char *uri,
PDFDoc *newDoc;
GooString *filename_g;
GooString *password_g;
GooString *enc;
int err;
char *filename;
......@@ -233,7 +232,6 @@ poppler_document_get_property (GObject *object,
{
PopplerDocument *document = POPPLER_DOCUMENT (object);
Object info;
char *title;
document->doc->getDocInfo (&info);
if (!info.isDict ())
......@@ -270,3 +268,161 @@ static void
poppler_document_init (PopplerDocument *document)
{
}
/* PopplerIndexIter: For determining the index of a tree */
struct _PopplerIndexIter
{
PopplerDocument *document;
GooList *items;
int index;
};
PopplerIndexIter *
poppler_index_iter_new (PopplerDocument *document)
{
PopplerIndexIter *iter;
Outline *outline;
GooList *items;
outline = document->doc->getOutline();
if (outline == NULL)
return NULL;
items = outline->getItems();
if (items == NULL)
return NULL;
iter = g_new0 (PopplerIndexIter, 1);
iter->document = (PopplerDocument *) g_object_ref (document);
iter->items = items;
iter->index = 0;
return iter;
}
PopplerIndexIter *
poppler_index_iter_get_child (PopplerIndexIter *parent)
{
PopplerIndexIter *child;
OutlineItem *item;
g_return_val_if_fail (parent != NULL, NULL);
item = (OutlineItem *)parent->items->get (parent->index);
item->open ();
if (! (item->hasKids() && item->getKids()) )
return NULL;
child = g_new0 (PopplerIndexIter, 1);
child->document = (PopplerDocument *)g_object_ref (parent->document);
child->items = item->getKids ();
g_assert (child->items);
return child;
}
static gchar *
unicode_to_char (Unicode *unicode,
int len)
{
static UnicodeMap *uMap = NULL;
if (uMap == NULL) {
GooString *enc = new GooString("UTF-8");
uMap = globalParams->getUnicodeMap(enc);
uMap->incRefCnt ();
delete enc;
}
GooString gstr;
gchar buf[8]; /* 8 is enough for mapping an unicode char to a string */
int i, n;
for (i = 0; i < len; ++i) {
n = uMap->mapUnicode(unicode[i], buf, sizeof(buf));
gstr.append(buf, n);
}
return g_strdup (gstr.getCString ());
}
void
poppler_index_iter_get_values (PopplerIndexIter *iter,
char **text,
char **link_string,
int *page)
{
OutlineItem *item;
LinkAction *action;
g_return_if_fail (iter != NULL);
g_return_if_fail (text != NULL);
g_return_if_fail (link_string != NULL);
g_return_if_fail (page != NULL);
item = (OutlineItem *)iter->items->get (iter->index);
*text = unicode_to_char (item->getTitle(),
item->getTitleLength ());
*page = -1;
action = item->getAction ();
if (action->getKind () == actionGoTo) {
LinkDest *link_dest;
LinkGoTo *link_goto;
Ref page_ref;
gint page_num = -1;
GooString *named_dest;
link_goto = dynamic_cast <LinkGoTo *> (action);
link_dest = link_goto->getDest ();
named_dest = link_goto->getNamedDest ();
if (link_dest != NULL) {
link_dest = link_dest->copy ();
} else if (named_dest != NULL) {
named_dest = named_dest->copy ();
link_dest = iter->document->doc->findDest (named_dest);
delete named_dest;
}
if (link_dest != NULL) {
if (link_dest->isPageRef ()) {
page_ref = link_dest->getPageRef ();
page_num = iter->document->doc->findPage (page_ref.num, page_ref.gen);
} else {
page_num = link_dest->getPageNum ();
}
delete link_dest;
}
if (page_num > 0)
*page = page_num - 1;
}
}
gboolean
poppler_index_iter_next (PopplerIndexIter *iter)
{
g_return_val_if_fail (iter != NULL, FALSE);
iter->index++;
if (iter->index >= iter->items->getLength())
return FALSE;
return TRUE;
}
void
poppler_index_iter_free (PopplerIndexIter *iter)
{
if (iter == NULL)
return;
g_object_unref (iter->document);
// delete iter->items;
g_free (iter);
}
......@@ -30,6 +30,7 @@ G_BEGIN_DECLS
#define POPPLER_IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POPPLER_TYPE_DOCUMENT))
typedef struct _PopplerDocument PopplerDocument;
typedef struct _PopplerIndexIter PopplerIndexIter;
typedef struct _PopplerPage PopplerPage;
PopplerDocument *poppler_document_new_from_file (const char *uri,
......@@ -46,6 +47,20 @@ PopplerPage *poppler_document_get_page_by_label (PopplerDocument *document,
GType poppler_document_get_type (void) G_GNUC_CONST;
/* Interface for getting the Index of a poppler_document */
PopplerIndexIter *poppler_index_iter_new (PopplerDocument *document);
PopplerIndexIter *poppler_index_iter_get_child (PopplerIndexIter *parent);
//PopplerAction *poppler_index_iter_get_action (PopplerIndexIter *iter); /* Use when PopplerAction exists */
void poppler_index_iter_get_values (PopplerIndexIter *iter,
char **text,
char **link_string,
int *page);
gboolean poppler_index_iter_next (PopplerIndexIter *iter);
void poppler_index_iter_free (PopplerIndexIter *iter);
G_END_DECLS
#endif /* __POPPLER_DOCUMENT_H__ */
......@@ -112,7 +112,7 @@ poppler_page_render_to_pixbuf (PopplerPage *page,
SplashBitmap *bitmap;
SplashColorPtr color_ptr;
int splash_width, splash_height, splash_rowstride;
int pixbuf_width, pixbuf_height, pixbuf_rowstride, pixbuf_n_channels;
int pixbuf_rowstride, pixbuf_n_channels;
guchar *splash_data, *pixbuf_data, *src, *dst;
int x, y;
......@@ -179,6 +179,52 @@ poppler_page_get_thumbnail (PopplerPage *page)
destroy_thumb_data, NULL);
}
/**
* poppler_page_get_thumbnail_size:
* @page: A #PopplerPage
* @width: return location for width
* @height: return location for height
*
* Returns %TRUE if @page has a thumbnail associated with it. It also fills in
* @width and @height with the width and height of the thumbnail. The values of
* width and height are not changed if no appropriate thumbnail exists.
*
* Return value: %TRUE, if @page has a thumbnail associated with it.
**/
gboolean
poppler_page_get_thumbnail_size (PopplerPage *page,
int *width,
int *height)
{
Object thumb;
Dict *dict;
gboolean retval = FALSE;
g_return_val_if_fail (POPPLER_IS_PAGE (page), FALSE);
g_return_val_if_fail (width != NULL, FALSE);
g_return_val_if_fail (height != NULL, FALSE);
page->page->getThumb (&thumb);
if (thumb.isNull ())
{
thumb.free ();
return FALSE;
}
dict = thumb.streamGetDict();
/* Theoretically, this could succeed and you would still fail when loading the
* thumb */
if (dict->lookupInt ("Width", "W", width) &&
dict->lookupInt ("Height", "H", height))
retval = TRUE;
thumb.free ();
return retval;
}
static void
poppler_page_get_property (GObject *object,
guint prop_id,
......
......@@ -44,6 +44,9 @@ void poppler_page_get_size (PopplerPage *page,
double *height);
int poppler_page_get_index (PopplerPage *page);
GdkPixbuf *poppler_page_get_thumbnail (PopplerPage *page);
gboolean poppler_page_get_thumbnail_size (PopplerPage *page,
int *width,
int *height);
G_END_DECLS
......
......@@ -7,5 +7,5 @@ Name: poppler
Description: GLib wrapper for poppler
Version: @VERSION@
Libs: -L${libdir} -lpoppler
Libs: -L${libdir} -lpoppler -lpoppler-glib
Cflags: -I${includedir}/poppler/glib
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment