summaryrefslogtreecommitdiff
path: root/backend/djvu/djvu-document.c
diff options
context:
space:
mode:
Diffstat (limited to 'backend/djvu/djvu-document.c')
-rw-r--r--backend/djvu/djvu-document.c110
1 files changed, 55 insertions, 55 deletions
diff --git a/backend/djvu/djvu-document.c b/backend/djvu/djvu-document.c
index 65f7f0f4..b3e41a8d 100644
--- a/backend/djvu/djvu-document.c
+++ b/backend/djvu/djvu-document.c
@@ -75,7 +75,7 @@ ev_djvu_error_quark (void)
static GQuark q = 0;
if (q == 0)
q = g_quark_from_string ("ev-djvu-quark");
-
+
return q;
}
@@ -85,7 +85,7 @@ handle_message (const ddjvu_message_t *msg, GError **error)
switch (msg->m_any.tag) {
case DDJVU_ERROR: {
gchar *error_str;
-
+
if (msg->m_error.filename) {
error_str = g_strdup_printf ("DjvuLibre error: %s:%d",
msg->m_error.filename,
@@ -94,16 +94,16 @@ handle_message (const ddjvu_message_t *msg, GError **error)
error_str = g_strdup_printf ("DjvuLibre error: %s",
msg->m_error.message);
}
-
+
if (error) {
g_set_error_literal (error, EV_DJVU_ERROR, 0, error_str);
} else {
g_warning ("%s", error_str);
}
-
+
g_free (error_str);
return;
- }
+ }
break;
default:
break;
@@ -115,7 +115,7 @@ djvu_handle_events (DjvuDocument *djvu_document, int wait, GError **error)
{
ddjvu_context_t *ctx = djvu_document->d_context;
const ddjvu_message_t *msg;
-
+
if (!ctx)
return;
@@ -162,7 +162,7 @@ djvu_document_load (EvDocument *document,
filename = g_filename_from_uri (uri, NULL, error);
if (!filename)
return FALSE;
-
+
doc = ddjvu_document_create_by_filename (djvu_document->d_context, filename, TRUE);
if (!doc) {
@@ -205,10 +205,10 @@ djvu_document_load (EvDocument *document,
g_free (filename);
ddjvu_document_release (djvu_document->d_document);
djvu_document->d_document = NULL;
-
+
return FALSE;
}
-
+
g_free (djvu_document->uri);
djvu_document->uri = g_strdup (uri);
@@ -223,7 +223,7 @@ djvu_document_load (EvDocument *document,
for (i = 0; i < n_files; i++) {
struct ddjvu_fileinfo_s fileinfo;
gchar *file;
-
+
ddjvu_document_get_fileinfo (djvu_document->d_document,
i, &fileinfo);
@@ -234,7 +234,7 @@ djvu_document_load (EvDocument *document,
if (!g_file_test (file, G_FILE_TEST_EXISTS)) {
missing_files = TRUE;
g_free (file);
-
+
break;
}
g_free (file);
@@ -271,9 +271,9 @@ int
djvu_document_get_n_pages (EvDocument *document)
{
DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
-
+
g_return_val_if_fail (djvu_document->d_document, 0);
-
+
return ddjvu_document_get_pagenum (djvu_document->d_document);
}
@@ -285,14 +285,14 @@ document_get_page_size (DjvuDocument *djvu_document,
{
ddjvu_pageinfo_t info;
ddjvu_status_t r;
-
+
while ((r = ddjvu_document_get_pageinfo(djvu_document->d_document, page, &info)) < DDJVU_JOB_OK)
djvu_handle_events(djvu_document, TRUE, NULL);
-
+
if (r >= DDJVU_JOB_FAILED)
djvu_handle_events(djvu_document, TRUE, NULL);
- *width = info.width * SCALE_FACTOR;
+ *width = info.width * SCALE_FACTOR;
*height = info.height * SCALE_FACTOR;
}
@@ -311,7 +311,7 @@ djvu_document_get_page_size (EvDocument *document,
}
static cairo_surface_t *
-djvu_document_render (EvDocument *document,
+djvu_document_render (EvDocument *document,
EvRenderContext *rc)
{
DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
@@ -325,31 +325,31 @@ djvu_document_render (EvDocument *document,
double page_width, page_height, tmp;
d_page = ddjvu_page_create_by_pageno (djvu_document->d_document, rc->page->index);
-
+
while (!ddjvu_page_decoding_done (d_page))
djvu_handle_events(djvu_document, TRUE, NULL);
page_width = ddjvu_page_get_width (d_page) * rc->scale * SCALE_FACTOR + 0.5;
page_height = ddjvu_page_get_height (d_page) * rc->scale * SCALE_FACTOR + 0.5;
-
+
switch (rc->rotation) {
case 90:
rotation = DDJVU_ROTATE_90;
tmp = page_height;
page_height = page_width;
page_width = tmp;
-
+
break;
case 180:
rotation = DDJVU_ROTATE_180;
-
+
break;
case 270:
rotation = DDJVU_ROTATE_270;
tmp = page_height;
page_height = page_width;
page_width = tmp;
-
+
break;
default:
rotation = DDJVU_ROTATE_0;
@@ -367,7 +367,7 @@ djvu_document_render (EvDocument *document,
rrect = prect;
ddjvu_page_set_rotation (d_page, rotation);
-
+
ddjvu_page_render (d_page, DDJVU_RENDER_COLOR,
&prect,
&rrect,
@@ -387,18 +387,18 @@ djvu_document_finalize (GObject *object)
if (djvu_document->d_document)
ddjvu_document_release (djvu_document->d_document);
-
+
if (djvu_document->opts)
g_string_free (djvu_document->opts, TRUE);
if (djvu_document->ps_filename)
g_free (djvu_document->ps_filename);
-
+
ddjvu_context_release (djvu_document->d_context);
ddjvu_format_release (djvu_document->d_format);
ddjvu_format_release (djvu_document->thumbs_format);
g_free (djvu_document->uri);
-
+
G_OBJECT_CLASS (djvu_document_parent_class)->finalize (object);
}
@@ -432,7 +432,7 @@ djvu_text_copy (DjvuDocument *djvu_document,
if (page_text != miniexp_nil) {
DjvuTextPage *page = djvu_text_page_new (page_text);
-
+
text = djvu_text_page_copy (page, rectangle);
djvu_text_page_free (page);
ddjvu_miniexp_release (djvu_document->d_document, page_text);
@@ -451,19 +451,19 @@ djvu_selection_get_selected_text (EvSelection *selection,
double width, height;
EvRectangle rectangle;
gchar *text;
-
+
djvu_document_get_page_size (EV_DOCUMENT (djvu_document),
page, &width, &height);
rectangle.x1 = points->x1 / SCALE_FACTOR;
rectangle.y1 = (height - points->y2) / SCALE_FACTOR;
rectangle.x2 = points->x2 / SCALE_FACTOR;
rectangle.y2 = (height - points->y1) / SCALE_FACTOR;
-
+
text = djvu_text_copy (djvu_document, page->index, &rectangle);
-
+
if (text == NULL)
text = g_strdup ("");
-
+
return text;
}
@@ -475,13 +475,13 @@ djvu_selection_iface_init (EvSelectionInterface *iface)
static void
djvu_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
- EvRenderContext *rc,
+ EvRenderContext *rc,
gint *width,
gint *height)
{
- DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
+ DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
gdouble page_width, page_height;
-
+
djvu_document_get_page_size (EV_DOCUMENT(djvu_document), rc->page,
&page_width, &page_height);
@@ -504,12 +504,12 @@ djvu_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
gdouble page_width, page_height;
gint thumb_width, thumb_height;
guchar *pixels;
-
+
g_return_val_if_fail (djvu_document->d_document, NULL);
djvu_document_get_page_size (EV_DOCUMENT(djvu_document), rc->page,
&page_width, &page_height);
-
+
thumb_width = (gint) (page_width * rc->scale);
thumb_height = (gint) (page_height * rc->scale);
@@ -517,14 +517,14 @@ djvu_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
thumb_width, thumb_height);
gdk_pixbuf_fill (pixbuf, 0xffffffff);
pixels = gdk_pixbuf_get_pixels (pixbuf);
-
+
while (ddjvu_thumbnail_status (djvu_document->d_document, rc->page->index, 1) < DDJVU_JOB_OK)
djvu_handle_events(djvu_document, TRUE, NULL);
-
- ddjvu_thumbnail_render (djvu_document->d_document, rc->page->index,
+
+ ddjvu_thumbnail_render (djvu_document->d_document, rc->page->index,
&thumb_width, &thumb_height,
djvu_document->thumbs_format,
- gdk_pixbuf_get_rowstride (pixbuf),
+ gdk_pixbuf_get_rowstride (pixbuf),
(gchar *)pixels);
rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rc->rotation);
@@ -532,11 +532,11 @@ djvu_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
if (border) {
GdkPixbuf *tmp_pixbuf = rotated_pixbuf;
-
+
rotated_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf);
g_object_unref (tmp_pixbuf);
}
-
+
return rotated_pixbuf;
}
@@ -553,9 +553,9 @@ djvu_document_file_exporter_begin (EvFileExporter *exporter,
EvFileExporterContext *fc)
{
DjvuDocument *djvu_document = DJVU_DOCUMENT (exporter);
-
+
if (djvu_document->ps_filename)
- g_free (djvu_document->ps_filename);
+ g_free (djvu_document->ps_filename);
djvu_document->ps_filename = g_strdup (fc->filename);
g_string_assign (djvu_document->opts, "-page=");
@@ -566,14 +566,14 @@ djvu_document_file_exporter_do_page (EvFileExporter *exporter,
EvRenderContext *rc)
{
DjvuDocument *djvu_document = DJVU_DOCUMENT (exporter);
-
- g_string_append_printf (djvu_document->opts, "%d,", (rc->page->index) + 1);
+
+ g_string_append_printf (djvu_document->opts, "%d,", (rc->page->index) + 1);
}
static void
djvu_document_file_exporter_end (EvFileExporter *exporter)
{
- int d_optc = 1;
+ int d_optc = 1;
const char *d_optv[d_optc];
DjvuDocument *djvu_document = DJVU_DOCUMENT (exporter);
@@ -583,15 +583,15 @@ djvu_document_file_exporter_end (EvFileExporter *exporter)
g_warning ("Cannot open file ā€œ%sā€.", djvu_document->ps_filename);
return;
}
-
- d_optv[0] = djvu_document->opts->str;
+
+ d_optv[0] = djvu_document->opts->str;
ddjvu_job_t * job = ddjvu_document_print(djvu_document->d_document, fn, d_optc, d_optv);
- while (!ddjvu_job_done(job)) {
+ while (!ddjvu_job_done(job)) {
djvu_handle_events (djvu_document, TRUE, NULL);
}
- fclose(fn);
+ fclose(fn);
}
static EvFileExporterCapabilities
@@ -617,7 +617,7 @@ static void
djvu_document_init (DjvuDocument *djvu_document)
{
guint masks[4] = { 0xff0000, 0xff00, 0xff, 0xff000000 };
-
+
djvu_document->d_context = ddjvu_context_create ("Atril");
djvu_document->d_format = ddjvu_format_create (DDJVU_FORMAT_RGBMASK32, 4, masks);
ddjvu_format_set_row_order (djvu_document->d_format, 1);
@@ -627,7 +627,7 @@ djvu_document_init (DjvuDocument *djvu_document)
djvu_document->ps_filename = NULL;
djvu_document->opts = g_string_new ("");
-
+
djvu_document->d_document = NULL;
}
@@ -651,7 +651,7 @@ djvu_document_find_find_text (EvDocumentFind *document,
if (page_text != miniexp_nil) {
DjvuTextPage *tpage = djvu_text_page_new (page_text);
-
+
djvu_text_page_prepare_search (tpage, case_sensitive);
if (tpage->links->len > 0) {
djvu_text_page_search (tpage, text, case_sensitive);
@@ -675,7 +675,7 @@ djvu_document_find_find_text (EvDocumentFind *document,
r->y1 = height - r->y2 * SCALE_FACTOR;
r->y2 = height - tmp * SCALE_FACTOR;
}
-
+
return matches;
}