diff options
author | Alessio Treglia <alessio@debian.org> | 2011-09-15 09:50:37 +0200 |
---|---|---|
committer | Alessio Treglia <alessio@debian.org> | 2011-09-15 09:50:37 +0200 |
commit | 9097fc9898cbe625774298600a0bb64f71b0fefa (patch) | |
tree | 2af66b8acaa9c1fb562169d0e31e39a801e125b5 /src/book.c | |
parent | d5a65678615027cd6efd4a34d43b945a5b765f73 (diff) | |
parent | 23a3dc6838d8b60b0b4b0c3c33e7ba489d3906ff (diff) |
Merge commit 'upstream/3.1.91'
Diffstat (limited to 'src/book.c')
-rw-r--r-- | src/book.c | 2485 |
1 files changed, 1744 insertions, 741 deletions
@@ -1,4 +1,4 @@ -/* book.c generated by valac 0.13.1, the Vala compiler +/* book.c generated by valac 0.13.4, the Vala compiler * generated from book.vala, do not modify */ /* @@ -306,16 +306,24 @@ static gpointer _page_ref0 (gpointer self) { Page* book_append_page (Book* self, gint width, gint height, gint dpi, ScanDirection scan_direction) { Page* result = NULL; - Page* _tmp0_ = NULL; + gint _tmp0_; + gint _tmp1_; + gint _tmp2_; + ScanDirection _tmp3_; + Page* _tmp4_; Page* page; - Page* _tmp1_; + Page* _tmp5_; g_return_val_if_fail (self != NULL, NULL); - _tmp0_ = page_new (width, height, dpi, scan_direction); - page = _tmp0_; + _tmp0_ = width; + _tmp1_ = height; + _tmp2_ = dpi; + _tmp3_ = scan_direction; + _tmp4_ = page_new (_tmp0_, _tmp1_, _tmp2_, _tmp3_); + page = _tmp4_; g_signal_connect (page, "pixels-changed", (GCallback) _book_page_changed_cb_page_pixels_changed, self); g_signal_connect (page, "crop-changed", (GCallback) _book_page_changed_cb_page_crop_changed, self); - _tmp1_ = _page_ref0 (page); - self->priv->pages = g_list_append (self->priv->pages, _tmp1_); + _tmp5_ = _page_ref0 (page); + self->priv->pages = g_list_append (self->priv->pages, _tmp5_); g_signal_emit_by_name (self, "page-added", page); book_set_needs_saving (self, TRUE); result = page; @@ -325,78 +333,116 @@ Page* book_append_page (Book* self, gint width, gint height, gint dpi, ScanDirec void book_move_page (Book* self, Page* page, guint location) { Page* _tmp0_; + Page* _tmp1_; + Page* _tmp2_; + guint _tmp3_; g_return_if_fail (self != NULL); g_return_if_fail (page != NULL); - self->priv->pages = g_list_remove (self->priv->pages, page); - _tmp0_ = _page_ref0 (page); - self->priv->pages = g_list_insert (self->priv->pages, _tmp0_, (gint) location); + _tmp0_ = page; + self->priv->pages = g_list_remove (self->priv->pages, _tmp0_); + _tmp1_ = page; + _tmp2_ = _page_ref0 (_tmp1_); + _tmp3_ = location; + self->priv->pages = g_list_insert (self->priv->pages, _tmp2_, (gint) _tmp3_); g_signal_emit_by_name (self, "reordered"); book_set_needs_saving (self, TRUE); } void book_delete_page (Book* self, Page* page) { - guint _tmp0_; - guint _tmp1_; + Page* _tmp0_; + guint _tmp1_ = 0U; + Page* _tmp2_; + guint _tmp3_ = 0U; + Page* _tmp4_; + Page* _tmp5_; g_return_if_fail (self != NULL); g_return_if_fail (page != NULL); - g_signal_parse_name ("pixels-changed", TYPE_PAGE, &_tmp0_, NULL, FALSE); - g_signal_handlers_disconnect_matched (page, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, 0, NULL, (GCallback) _book_page_changed_cb_page_pixels_changed, self); - g_signal_parse_name ("crop-changed", TYPE_PAGE, &_tmp1_, NULL, FALSE); - g_signal_handlers_disconnect_matched (page, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _book_page_changed_cb_page_crop_changed, self); - g_signal_emit_by_name (self, "page-removed", page); - self->priv->pages = g_list_remove (self->priv->pages, page); + _tmp0_ = page; + g_signal_parse_name ("pixels-changed", TYPE_PAGE, &_tmp1_, NULL, FALSE); + g_signal_handlers_disconnect_matched (_tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _book_page_changed_cb_page_pixels_changed, self); + _tmp2_ = page; + g_signal_parse_name ("crop-changed", TYPE_PAGE, &_tmp3_, NULL, FALSE); + g_signal_handlers_disconnect_matched (_tmp2_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp3_, 0, NULL, (GCallback) _book_page_changed_cb_page_crop_changed, self); + _tmp4_ = page; + g_signal_emit_by_name (self, "page-removed", _tmp4_); + _tmp5_ = page; + self->priv->pages = g_list_remove (self->priv->pages, _tmp5_); book_set_needs_saving (self, TRUE); } guint book_get_n_pages (Book* self) { guint result = 0U; - guint _tmp0_; + GList* _tmp0_; + guint _tmp1_ = 0U; g_return_val_if_fail (self != NULL, 0U); - _tmp0_ = g_list_length (self->priv->pages); - result = _tmp0_; + _tmp0_ = self->priv->pages; + _tmp1_ = g_list_length (_tmp0_); + result = _tmp1_; return result; } Page* book_get_page (Book* self, gint page_number) { Page* result = NULL; - gconstpointer _tmp1_ = NULL; - Page* _tmp2_; + gint _tmp0_; + GList* _tmp4_; + gint _tmp5_; + gconstpointer _tmp6_ = NULL; + Page* _tmp7_; g_return_val_if_fail (self != NULL, NULL); - if (page_number < 0) { - guint _tmp0_; - _tmp0_ = g_list_length (self->priv->pages); - page_number = ((gint) _tmp0_) + page_number; - } - _tmp1_ = g_list_nth_data (self->priv->pages, (guint) page_number); - _tmp2_ = _page_ref0 ((Page*) _tmp1_); - result = _tmp2_; + _tmp0_ = page_number; + if (_tmp0_ < 0) { + GList* _tmp1_; + guint _tmp2_ = 0U; + gint _tmp3_; + _tmp1_ = self->priv->pages; + _tmp2_ = g_list_length (_tmp1_); + _tmp3_ = page_number; + page_number = ((gint) _tmp2_) + _tmp3_; + } + _tmp4_ = self->priv->pages; + _tmp5_ = page_number; + _tmp6_ = g_list_nth_data (_tmp4_, (guint) _tmp5_); + _tmp7_ = _page_ref0 ((Page*) _tmp6_); + result = _tmp7_; return result; } guint book_get_page_index (Book* self, Page* page) { guint result = 0U; - gint _tmp0_; + GList* _tmp0_; + Page* _tmp1_; + gint _tmp2_ = 0; g_return_val_if_fail (self != NULL, 0U); g_return_val_if_fail (page != NULL, 0U); - _tmp0_ = g_list_index (self->priv->pages, page); - result = (guint) _tmp0_; + _tmp0_ = self->priv->pages; + _tmp1_ = page; + _tmp2_ = g_list_index (_tmp0_, _tmp1_); + result = (guint) _tmp2_; return result; } static gint string_last_index_of_char (const gchar* self, gunichar c, gint start_index) { gint result = 0; - gchar* _tmp0_ = NULL; + gint _tmp0_; + gunichar _tmp1_; + gchar* _tmp2_ = NULL; gchar* _result_; + gchar* _tmp3_; g_return_val_if_fail (self != NULL, 0); - _tmp0_ = g_utf8_strrchr (((gchar*) self) + start_index, (gssize) (-1), c); - _result_ = _tmp0_; - if (_result_ != NULL) { - result = (gint) (_result_ - ((gchar*) self)); + _tmp0_ = start_index; + _tmp1_ = c; + _tmp2_ = g_utf8_strrchr (((gchar*) self) + _tmp0_, (gssize) (-1), _tmp1_); + _result_ = _tmp2_; + _tmp3_ = _result_; + if (_tmp3_ != NULL) { + gchar* _tmp4_; + _tmp4_ = _result_; + result = (gint) (_tmp4_ - ((gchar*) self)); return result; } else { result = -1; @@ -408,90 +454,166 @@ static gint string_last_index_of_char (const gchar* self, gunichar c, gint start static gchar* string_slice (const gchar* self, glong start, glong end) { gchar* result = NULL; gint _tmp0_; + gint _tmp1_; glong string_length; - gboolean _tmp1_ = FALSE; - gboolean _tmp2_ = FALSE; - gchar* _tmp3_ = NULL; + glong _tmp2_; + glong _tmp5_; + gboolean _tmp8_ = FALSE; + glong _tmp9_; + gboolean _tmp12_; + gboolean _tmp13_ = FALSE; + glong _tmp14_; + gboolean _tmp17_; + glong _tmp18_; + glong _tmp19_; + glong _tmp20_; + glong _tmp21_; + glong _tmp22_; + gchar* _tmp23_ = NULL; g_return_val_if_fail (self != NULL, NULL); _tmp0_ = strlen (self); - string_length = (glong) _tmp0_; - if (start < ((glong) 0)) { - start = string_length + start; - } - if (end < ((glong) 0)) { - end = string_length + end; - } - if (start >= ((glong) 0)) { - _tmp1_ = start <= string_length; + _tmp1_ = _tmp0_; + string_length = (glong) _tmp1_; + _tmp2_ = start; + if (_tmp2_ < ((glong) 0)) { + glong _tmp3_; + glong _tmp4_; + _tmp3_ = string_length; + _tmp4_ = start; + start = _tmp3_ + _tmp4_; + } + _tmp5_ = end; + if (_tmp5_ < ((glong) 0)) { + glong _tmp6_; + glong _tmp7_; + _tmp6_ = string_length; + _tmp7_ = end; + end = _tmp6_ + _tmp7_; + } + _tmp9_ = start; + if (_tmp9_ >= ((glong) 0)) { + glong _tmp10_; + glong _tmp11_; + _tmp10_ = start; + _tmp11_ = string_length; + _tmp8_ = _tmp10_ <= _tmp11_; } else { - _tmp1_ = FALSE; - } - g_return_val_if_fail (_tmp1_, NULL); - if (end >= ((glong) 0)) { - _tmp2_ = end <= string_length; + _tmp8_ = FALSE; + } + _tmp12_ = _tmp8_; + g_return_val_if_fail (_tmp12_, NULL); + _tmp14_ = end; + if (_tmp14_ >= ((glong) 0)) { + glong _tmp15_; + glong _tmp16_; + _tmp15_ = end; + _tmp16_ = string_length; + _tmp13_ = _tmp15_ <= _tmp16_; } else { - _tmp2_ = FALSE; - } - g_return_val_if_fail (_tmp2_, NULL); - g_return_val_if_fail (start <= end, NULL); - _tmp3_ = g_strndup (((gchar*) self) + start, (gsize) (end - start)); - result = _tmp3_; + _tmp13_ = FALSE; + } + _tmp17_ = _tmp13_; + g_return_val_if_fail (_tmp17_, NULL); + _tmp18_ = start; + _tmp19_ = end; + g_return_val_if_fail (_tmp18_ <= _tmp19_, NULL); + _tmp20_ = start; + _tmp21_ = end; + _tmp22_ = start; + _tmp23_ = g_strndup (((gchar*) self) + _tmp20_, (gsize) (_tmp21_ - _tmp22_)); + result = _tmp23_; return result; } static GFile* book_make_indexed_file (Book* self, const gchar* uri, gint i) { GFile* result = NULL; - gchar* _tmp1_ = NULL; + gint _tmp0_; + const gchar* _tmp3_; + gchar* _tmp4_ = NULL; gchar* basename; - gchar* _tmp2_; + const gchar* _tmp5_; + gchar* _tmp6_; gchar* prefix; - gchar* _tmp3_; + gchar* _tmp7_; gchar* suffix; - gint _tmp4_; + const gchar* _tmp8_; + gint _tmp9_ = 0; gint extension_index; - gchar* _tmp10_ = NULL; - gchar* _tmp11_; - GFile* _tmp12_ = NULL; - GFile* _tmp13_; + gint _tmp10_; + const gchar* _tmp25_; + gint _tmp26_; + const gchar* _tmp27_; + gchar* _tmp28_ = NULL; + gchar* _tmp29_; + GFile* _tmp30_ = NULL; + GFile* _tmp31_; g_return_val_if_fail (self != NULL, NULL); g_return_val_if_fail (uri != NULL, NULL); - if (i == 0) { - GFile* _tmp0_ = NULL; - _tmp0_ = g_file_new_for_uri (uri); - result = _tmp0_; + _tmp0_ = i; + if (_tmp0_ == 0) { + const gchar* _tmp1_; + GFile* _tmp2_ = NULL; + _tmp1_ = uri; + _tmp2_ = g_file_new_for_uri (_tmp1_); + result = _tmp2_; return result; } - _tmp1_ = g_path_get_basename (uri); - basename = _tmp1_; - _tmp2_ = g_strdup (uri); - prefix = _tmp2_; - _tmp3_ = g_strdup (""); - suffix = _tmp3_; - _tmp4_ = string_last_index_of_char (basename, (gunichar) '.', 0); - extension_index = _tmp4_; - if (extension_index >= 0) { - gint _tmp5_; - gchar* _tmp6_ = NULL; - gint _tmp7_; - gint _tmp8_; - gchar* _tmp9_ = NULL; - _tmp5_ = strlen (basename); - _tmp6_ = string_slice (basename, (glong) extension_index, (glong) _tmp5_); + _tmp3_ = uri; + _tmp4_ = g_path_get_basename (_tmp3_); + basename = _tmp4_; + _tmp5_ = uri; + _tmp6_ = g_strdup (_tmp5_); + prefix = _tmp6_; + _tmp7_ = g_strdup (""); + suffix = _tmp7_; + _tmp8_ = basename; + _tmp9_ = string_last_index_of_char (_tmp8_, (gunichar) '.', 0); + extension_index = _tmp9_; + _tmp10_ = extension_index; + if (_tmp10_ >= 0) { + const gchar* _tmp11_; + gint _tmp12_; + const gchar* _tmp13_; + gint _tmp14_; + gint _tmp15_; + gchar* _tmp16_ = NULL; + const gchar* _tmp17_; + const gchar* _tmp18_; + gint _tmp19_; + gint _tmp20_; + const gchar* _tmp21_; + gint _tmp22_; + gint _tmp23_; + gchar* _tmp24_ = NULL; + _tmp11_ = basename; + _tmp12_ = extension_index; + _tmp13_ = basename; + _tmp14_ = strlen (_tmp13_); + _tmp15_ = _tmp14_; + _tmp16_ = string_slice (_tmp11_, (glong) _tmp12_, (glong) _tmp15_); _g_free0 (suffix); - suffix = _tmp6_; - _tmp7_ = strlen (uri); - _tmp8_ = strlen (suffix); - _tmp9_ = string_slice (uri, (glong) 0, (glong) (_tmp7_ - _tmp8_)); + suffix = _tmp16_; + _tmp17_ = uri; + _tmp18_ = uri; + _tmp19_ = strlen (_tmp18_); + _tmp20_ = _tmp19_; + _tmp21_ = suffix; + _tmp22_ = strlen (_tmp21_); + _tmp23_ = _tmp22_; + _tmp24_ = string_slice (_tmp17_, (glong) 0, (glong) (_tmp20_ - _tmp23_)); _g_free0 (prefix); - prefix = _tmp9_; - } - _tmp10_ = g_strdup_printf ("%s-%d%s", prefix, i, suffix); - _tmp11_ = _tmp10_; - _tmp12_ = g_file_new_for_uri (_tmp11_); - _tmp13_ = _tmp12_; - _g_free0 (_tmp11_); - result = _tmp13_; + prefix = _tmp24_; + } + _tmp25_ = prefix; + _tmp26_ = i; + _tmp27_ = suffix; + _tmp28_ = g_strdup_printf ("%s-%d%s", _tmp25_, _tmp26_, _tmp27_); + _tmp29_ = _tmp28_; + _tmp30_ = g_file_new_for_uri (_tmp29_); + _tmp31_ = _tmp30_; + _g_free0 (_tmp29_); + result = _tmp31_; _g_free0 (suffix); _g_free0 (prefix); _g_free0 (basename); @@ -501,38 +623,50 @@ static GFile* book_make_indexed_file (Book* self, const gchar* uri, gint i) { static void book_save_multi_file (Book* self, const gchar* type, GFile* file, GError** error) { gint i; + GList* _tmp0_; GError * _inner_error_ = NULL; g_return_if_fail (self != NULL); g_return_if_fail (type != NULL); g_return_if_fail (file != NULL); i = 0; + _tmp0_ = self->priv->pages; { GList* page_collection = NULL; GList* page_it = NULL; - page_collection = self->priv->pages; + page_collection = _tmp0_; for (page_it = page_collection; page_it != NULL; page_it = page_it->next) { - Page* _tmp0_; + Page* _tmp1_; Page* page = NULL; - _tmp0_ = _page_ref0 ((Page*) page_it->data); - page = _tmp0_; + _tmp1_ = _page_ref0 ((Page*) page_it->data); + page = _tmp1_; { - gchar* _tmp1_ = NULL; - gchar* _tmp2_; - GFile* _tmp3_ = NULL; + Page* _tmp2_; + const gchar* _tmp3_; GFile* _tmp4_; - _tmp1_ = g_file_get_uri (file); - _tmp2_ = _tmp1_; - _tmp3_ = book_make_indexed_file (self, _tmp2_, i); - _tmp4_ = _tmp3_; - page_save (page, type, _tmp4_, &_inner_error_); - _g_object_unref0 (_tmp4_); - _g_free0 (_tmp2_); + gchar* _tmp5_ = NULL; + gchar* _tmp6_; + gint _tmp7_; + GFile* _tmp8_ = NULL; + GFile* _tmp9_; + gint _tmp10_; + _tmp2_ = page; + _tmp3_ = type; + _tmp4_ = file; + _tmp5_ = g_file_get_uri (_tmp4_); + _tmp6_ = _tmp5_; + _tmp7_ = i; + _tmp8_ = book_make_indexed_file (self, _tmp6_, _tmp7_); + _tmp9_ = _tmp8_; + page_save (_tmp2_, _tmp3_, _tmp9_, &_inner_error_); + _g_object_unref0 (_tmp9_); + _g_free0 (_tmp6_); if (_inner_error_ != NULL) { g_propagate_error (error, _inner_error_); _page_unref0 (page); return; } - i++; + _tmp10_ = i; + i = _tmp10_ + 1; _page_unref0 (page); } } @@ -541,18 +675,26 @@ static void book_save_multi_file (Book* self, const gchar* type, GFile* file, GE static void book_save_ps_pdf_surface (Book* self, cairo_surface_t* surface, GdkPixbuf* image, gdouble dpi) { - cairo_t* _tmp0_ = NULL; + cairo_surface_t* _tmp0_; + cairo_t* _tmp1_; cairo_t* context; - cairo_pattern_t* _tmp1_ = NULL; + gdouble _tmp2_; + gdouble _tmp3_; + GdkPixbuf* _tmp4_; + cairo_pattern_t* _tmp5_ = NULL; g_return_if_fail (self != NULL); g_return_if_fail (surface != NULL); g_return_if_fail (image != NULL); - _tmp0_ = cairo_create (surface); - context = _tmp0_; - cairo_scale (context, 72.0 / dpi, 72.0 / dpi); - gdk_cairo_set_source_pixbuf (context, image, (gdouble) 0, (gdouble) 0); - _tmp1_ = cairo_get_source (context); - cairo_pattern_set_filter (_tmp1_, CAIRO_FILTER_BEST); + _tmp0_ = surface; + _tmp1_ = cairo_create (_tmp0_); + context = _tmp1_; + _tmp2_ = dpi; + _tmp3_ = dpi; + cairo_scale (context, 72.0 / _tmp2_, 72.0 / _tmp3_); + _tmp4_ = image; + gdk_cairo_set_source_pixbuf (context, _tmp4_, (gdouble) 0, (gdouble) 0); + _tmp5_ = cairo_get_source (context); + cairo_pattern_set_filter (_tmp5_, CAIRO_FILTER_BEST); cairo_paint (context); _cairo_destroy0 (context); } @@ -564,56 +706,88 @@ static gpointer _cairo_surface_reference0 (gpointer self) { static void book_save_ps (Book* self, GFile* file, GError** error) { - GFileOutputStream* _tmp0_ = NULL; + GFile* _tmp0_; + GFileOutputStream* _tmp1_ = NULL; GFileOutputStream* stream; - PsWriter* _tmp1_ = NULL; + PsWriter* _tmp2_; PsWriter* writer; - cairo_surface_t* _tmp2_; + PsWriter* _tmp3_; + cairo_surface_t* _tmp4_; + cairo_surface_t* _tmp5_; cairo_surface_t* surface; + GList* _tmp6_; GError * _inner_error_ = NULL; g_return_if_fail (self != NULL); g_return_if_fail (file != NULL); - _tmp0_ = g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &_inner_error_); - stream = _tmp0_; + _tmp0_ = file; + _tmp1_ = g_file_replace (_tmp0_, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &_inner_error_); + stream = _tmp1_; if (_inner_error_ != NULL) { g_propagate_error (error, _inner_error_); return; } - _tmp1_ = ps_writer_new (stream); - writer = _tmp1_; - _tmp2_ = _cairo_surface_reference0 (writer->surface); - surface = _tmp2_; + _tmp2_ = ps_writer_new (stream); + writer = _tmp2_; + _tmp3_ = writer; + _tmp4_ = _tmp3_->surface; + _tmp5_ = _cairo_surface_reference0 (_tmp4_); + surface = _tmp5_; + _tmp6_ = self->priv->pages; { GList* page_collection = NULL; GList* page_it = NULL; - page_collection = self->priv->pages; + page_collection = _tmp6_; for (page_it = page_collection; page_it != NULL; page_it = page_it->next) { - Page* _tmp3_; + Page* _tmp7_; Page* page = NULL; - _tmp3_ = _page_ref0 ((Page*) page_it->data); - page = _tmp3_; + _tmp7_ = _page_ref0 ((Page*) page_it->data); + page = _tmp7_; { - GdkPixbuf* _tmp4_ = NULL; + Page* _tmp8_; + GdkPixbuf* _tmp9_ = NULL; GdkPixbuf* image; - gint _tmp5_; - gint _tmp6_; + GdkPixbuf* _tmp10_; + gint _tmp11_ = 0; + Page* _tmp12_; + gint _tmp13_ = 0; gdouble width; - gint _tmp7_; - gint _tmp8_; + GdkPixbuf* _tmp14_; + gint _tmp15_ = 0; + Page* _tmp16_; + gint _tmp17_ = 0; gdouble height; - gint _tmp9_; - _tmp4_ = page_get_image (page, TRUE); - image = _tmp4_; - _tmp5_ = gdk_pixbuf_get_width (image); - _tmp6_ = page_get_dpi (page); - width = (_tmp5_ * 72.0) / _tmp6_; - _tmp7_ = gdk_pixbuf_get_height (image); - _tmp8_ = page_get_dpi (page); - height = (_tmp7_ * 72.0) / _tmp8_; - cairo_ps_surface_set_size (surface, width, height); - _tmp9_ = page_get_dpi (page); - book_save_ps_pdf_surface (self, surface, image, (gdouble) _tmp9_); - cairo_surface_show_page (surface); + cairo_surface_t* _tmp18_; + gdouble _tmp19_; + gdouble _tmp20_; + cairo_surface_t* _tmp21_; + GdkPixbuf* _tmp22_; + Page* _tmp23_; + gint _tmp24_ = 0; + cairo_surface_t* _tmp25_; + _tmp8_ = page; + _tmp9_ = page_get_image (_tmp8_, TRUE); + image = _tmp9_; + _tmp10_ = image; + _tmp11_ = gdk_pixbuf_get_width (_tmp10_); + _tmp12_ = page; + _tmp13_ = page_get_dpi (_tmp12_); + width = (_tmp11_ * 72.0) / _tmp13_; + _tmp14_ = image; + _tmp15_ = gdk_pixbuf_get_height (_tmp14_); + _tmp16_ = page; + _tmp17_ = page_get_dpi (_tmp16_); + height = (_tmp15_ * 72.0) / _tmp17_; + _tmp18_ = surface; + _tmp19_ = width; + _tmp20_ = height; + cairo_ps_surface_set_size (_tmp18_, _tmp19_, _tmp20_); + _tmp21_ = surface; + _tmp22_ = image; + _tmp23_ = page; + _tmp24_ = page_get_dpi (_tmp23_); + book_save_ps_pdf_surface (self, _tmp21_, _tmp22_, (gdouble) _tmp24_); + _tmp25_ = surface; + cairo_surface_show_page (_tmp25_); _g_object_unref0 (image); _page_unref0 (page); } @@ -628,72 +802,109 @@ static void book_save_ps (Book* self, GFile* file, GError** error) { static guint8* book_compress_zlib (Book* self, guint8* data, int data_length1, int* result_length1) { guint8* result = NULL; z_stream stream = {0}; - guint8* _tmp0_ = NULL; + guint8* _tmp0_; + gint _tmp0__length1; + guint8* _tmp1_ = NULL; guint8* out_data; gint out_data_length1; gint _out_data_size_; + guint8* _tmp2_; + gint _tmp2__length1; + guint8* _tmp3_; + gint _tmp3__length1; + z_stream _tmp7_; + guint _tmp8_; + guint8* _tmp10_; + gint _tmp10__length1; + z_stream _tmp11_; + guint _tmp12_; guint n_written; - gint _tmp3_; - guint8* _tmp4_; + guint _tmp13_; + gint _tmp14_ = 0; + guint8* _tmp15_; + gint _tmp15__length1; g_return_val_if_fail (self != NULL, NULL); deflateInit (&stream, (gint) Z_BEST_COMPRESSION); - _tmp0_ = g_new0 (guint8, data_length1); - out_data = _tmp0_; - out_data_length1 = data_length1; + _tmp0_ = data; + _tmp0__length1 = data_length1; + _tmp1_ = g_new0 (guint8, _tmp0__length1); + out_data = _tmp1_; + out_data_length1 = _tmp0__length1; _out_data_size_ = out_data_length1; - stream.next_in = data; - stream.avail_in = data_length1; - stream.next_out = out_data; - stream.avail_out = out_data_length1; + _tmp2_ = data; + _tmp2__length1 = data_length1; + stream.next_in = _tmp2_; + stream.avail_in = _tmp2__length1; + _tmp3_ = out_data; + _tmp3__length1 = out_data_length1; + stream.next_out = _tmp3_; + stream.avail_out = _tmp3__length1; while (TRUE) { - gint _tmp1_; - if (!(stream.avail_in > ((guint) 0))) { + z_stream _tmp4_; + guint _tmp5_; + gint _tmp6_ = 0; + _tmp4_ = stream; + _tmp5_ = _tmp4_.avail_in; + if (!(_tmp5_ > ((guint) 0))) { break; } - _tmp1_ = deflate (&stream, (gint) Z_FINISH); - if (_tmp1_ == ((gint) Z_STREAM_ERROR)) { + _tmp6_ = deflate (&stream, (gint) Z_FINISH); + if (_tmp6_ == ((gint) Z_STREAM_ERROR)) { break; } } - if (stream.avail_in > ((guint) 0)) { - guint8* _tmp2_; - _tmp2_ = NULL; + _tmp7_ = stream; + _tmp8_ = _tmp7_.avail_in; + if (_tmp8_ > ((guint) 0)) { + guint8* _tmp9_; + gint _tmp9__length1; + _tmp9_ = NULL; + _tmp9__length1 = 0; if (result_length1) { - *result_length1 = 0; + *result_length1 = _tmp9__length1; } - result = _tmp2_; + result = _tmp9_; out_data = (g_free (out_data), NULL); deflateEnd (&stream); return result; } - n_written = data_length1 - stream.avail_out; - _tmp3_ = (gint) n_written; - out_data = g_renew (guint8, out_data, (gint) n_written); - (_tmp3_ > out_data_length1) ? memset (out_data + out_data_length1, 0, sizeof (guint8) * (_tmp3_ - out_data_length1)) : NULL; - out_data_length1 = _tmp3_; - _out_data_size_ = _tmp3_; - _tmp4_ = out_data; + _tmp10_ = data; + _tmp10__length1 = data_length1; + _tmp11_ = stream; + _tmp12_ = _tmp11_.avail_out; + n_written = _tmp10__length1 - _tmp12_; + _tmp13_ = n_written; + _tmp14_ = (gint) _tmp13_; + out_data = g_renew (guint8, out_data, (gint) _tmp13_); + (_tmp14_ > out_data_length1) ? memset (out_data + out_data_length1, 0, sizeof (guint8) * (_tmp14_ - out_data_length1)) : NULL; + out_data_length1 = _tmp14_; + _out_data_size_ = _tmp14_; + _tmp15_ = out_data; + _tmp15__length1 = out_data_length1; if (result_length1) { - *result_length1 = out_data_length1; + *result_length1 = _tmp15__length1; } - result = _tmp4_; + result = _tmp15_; deflateEnd (&stream); return result; } static void book_jpeg_init_cb (struct jpeg_compress_struct* info) { + g_return_if_fail (info != NULL); } static gboolean book_jpeg_empty_cb (struct jpeg_compress_struct* info) { gboolean result = FALSE; + g_return_val_if_fail (info != NULL, FALSE); result = TRUE; return result; } static void book_jpeg_term_cb (struct jpeg_compress_struct* info) { + g_return_if_fail (info != NULL); } @@ -715,24 +926,41 @@ static void _book_jpeg_term_cb_jpeg_termdestinationfunc (struct jpeg_compress_st static guint8* book_compress_jpeg (Book* self, GdkPixbuf* image, gsize* n_written, int* result_length1) { - gsize _n_written = 0UL; + gsize _vala_n_written = 0UL; guint8* result = NULL; struct jpeg_compress_struct info = {0}; struct jpeg_error_mgr jerr = {0}; struct jpeg_destination_mgr dest_mgr = {0}; struct jpeg_error_mgr* _tmp0_ = NULL; - gint _tmp1_; - gint _tmp2_; + GdkPixbuf* _tmp1_; + gint _tmp2_ = 0; + GdkPixbuf* _tmp3_; + gint _tmp4_ = 0; + struct jpeg_compress_struct _tmp5_; + gint _tmp6_; + struct jpeg_compress_struct _tmp7_; + gint _tmp8_; + struct jpeg_compress_struct _tmp9_; + gint _tmp10_; gint max_length; - guint8* _tmp3_ = NULL; + gint _tmp11_; + guint8* _tmp12_ = NULL; guint8* data; gint data_length1; gint _data_size_; - guint8* _tmp4_ = NULL; + guint8* _tmp13_; + gint _tmp13__length1; + gint _tmp14_; + GdkPixbuf* _tmp15_; + guint8* _tmp16_ = NULL; guint8* pixels; gint pixels_length1; gint _pixels_size_; - guint8* _tmp7_; + gint _tmp28_; + struct jpeg_destination_mgr _tmp29_; + gint _tmp30_; + guint8* _tmp31_; + gint _tmp31__length1; g_return_val_if_fail (self != NULL, NULL); g_return_val_if_fail (image != NULL, NULL); memset (&info, 0, sizeof (struct jpeg_compress_struct)); @@ -741,61 +969,98 @@ static guint8* book_compress_jpeg (Book* self, GdkPixbuf* image, gsize* n_writte _tmp0_ = jpeg_std_error (&jerr); info.err = _tmp0_; jpeg_create_compress (&info); - _tmp1_ = gdk_pixbuf_get_width (image); - info.image_width = _tmp1_; - _tmp2_ = gdk_pixbuf_get_height (image); - info.image_height = _tmp2_; + _tmp1_ = image; + _tmp2_ = gdk_pixbuf_get_width (_tmp1_); + info.image_width = _tmp2_; + _tmp3_ = image; + _tmp4_ = gdk_pixbuf_get_height (_tmp3_); + info.image_height = _tmp4_; info.input_components = 3; info.in_color_space = JCS_RGB; jpeg_set_defaults (&info); - max_length = (info.image_width * info.image_height) * info.input_components; - _tmp3_ = g_new0 (guint8, max_length); - data = _tmp3_; - data_length1 = max_length; + _tmp5_ = info; + _tmp6_ = _tmp5_.image_width; + _tmp7_ = info; + _tmp8_ = _tmp7_.image_height; + _tmp9_ = info; + _tmp10_ = _tmp9_.input_components; + max_length = (_tmp6_ * _tmp8_) * _tmp10_; + _tmp11_ = max_length; + _tmp12_ = g_new0 (guint8, _tmp11_); + data = _tmp12_; + data_length1 = _tmp11_; _data_size_ = data_length1; - dest_mgr.next_output_byte = data; - dest_mgr.free_in_buffer = max_length; + _tmp13_ = data; + _tmp13__length1 = data_length1; + dest_mgr.next_output_byte = _tmp13_; + _tmp14_ = max_length; + dest_mgr.free_in_buffer = _tmp14_; dest_mgr.init_destination = _book_jpeg_init_cb_jpeg_initdestinationfunc; dest_mgr.empty_output_buffer = _book_jpeg_empty_cb_jpeg_emptyoutputbufferfunc; dest_mgr.term_destination = _book_jpeg_term_cb_jpeg_termdestinationfunc; info.dest = &dest_mgr; jpeg_start_compress (&info, TRUE); - _tmp4_ = gdk_pixbuf_get_pixels (image); - pixels = _tmp4_; + _tmp15_ = image; + _tmp16_ = gdk_pixbuf_get_pixels (_tmp15_); + pixels = _tmp16_; pixels_length1 = -1; _pixels_size_ = pixels_length1; { gint r; r = 0; { - gboolean _tmp5_; - _tmp5_ = TRUE; + gboolean _tmp17_; + _tmp17_ = TRUE; while (TRUE) { + gboolean _tmp18_; + gint _tmp20_; + struct jpeg_compress_struct _tmp21_; + gint _tmp22_; guint8* row[1] = {0}; - gint _tmp6_; - if (!_tmp5_) { - r++; + guint8* _tmp23_; + gint _tmp23__length1; + gint _tmp24_; + GdkPixbuf* _tmp25_; + gint _tmp26_ = 0; + guint8* _tmp27_; + _tmp18_ = _tmp17_; + if (!_tmp18_) { + gint _tmp19_; + _tmp19_ = r; + r = _tmp19_ + 1; } - _tmp5_ = FALSE; - if (!(r < info.image_height)) { + _tmp17_ = FALSE; + _tmp20_ = r; + _tmp21_ = info; + _tmp22_ = _tmp21_.image_height; + if (!(_tmp20_ < _tmp22_)) { break; } - _tmp6_ = gdk_pixbuf_get_rowstride (image); - row[0] = ((guint8*) pixels) + (r * _tmp6_); + _tmp23_ = pixels; + _tmp23__length1 = pixels_length1; + _tmp24_ = r; + _tmp25_ = image; + _tmp26_ = gdk_pixbuf_get_rowstride (_tmp25_); + row[0] = ((guint8*) _tmp23_) + (_tmp24_ * _tmp26_); + _tmp27_ = row[0]; jpeg_write_scanlines (&info, row, 1); } } } jpeg_finish_compress (&info); - _n_written = (gsize) (max_length - dest_mgr.free_in_buffer); - _tmp7_ = data; + _tmp28_ = max_length; + _tmp29_ = dest_mgr; + _tmp30_ = _tmp29_.free_in_buffer; + _vala_n_written = (gsize) (_tmp28_ - _tmp30_); + _tmp31_ = data; + _tmp31__length1 = data_length1; if (result_length1) { - *result_length1 = data_length1; + *result_length1 = _tmp31__length1; } - result = _tmp7_; + result = _tmp31_; jpeg_destroy_compress (&info); if (n_written) { - *n_written = _n_written; + *n_written = _vala_n_written; } return result; } @@ -812,286 +1077,561 @@ static guint8* _vala_array_dup2 (guint8* self, int length) { static void book_save_pdf (Book* self, GFile* file, GError** error) { - GFileOutputStream* _tmp0_ = NULL; + GFile* _tmp0_; + GFileOutputStream* _tmp1_ = NULL; GFileOutputStream* stream; - PDFWriter* _tmp1_ = NULL; + PDFWriter* _tmp2_; PDFWriter* writer; - guint _tmp2_; + PDFWriter* _tmp3_; + PDFWriter* _tmp4_; + PDFWriter* _tmp5_; + guint _tmp6_ = 0U; guint catalog_number; - gchar* _tmp3_ = NULL; - gchar* _tmp4_; - gchar* _tmp5_ = NULL; - gchar* _tmp6_; - guint _tmp7_; - guint pages_number; - gchar* _tmp8_ = NULL; - gchar* _tmp9_; + PDFWriter* _tmp7_; + guint _tmp8_; + gchar* _tmp9_ = NULL; + gchar* _tmp10_; + PDFWriter* _tmp11_; + PDFWriter* _tmp12_; + PDFWriter* _tmp13_; guint _tmp14_; gchar* _tmp15_ = NULL; gchar* _tmp16_; - guint _tmp100_; + PDFWriter* _tmp17_; + PDFWriter* _tmp18_; + PDFWriter* _tmp19_; + PDFWriter* _tmp20_; + guint _tmp21_ = 0U; + guint pages_number; + PDFWriter* _tmp22_; + guint _tmp23_; + gchar* _tmp24_ = NULL; + gchar* _tmp25_; + PDFWriter* _tmp26_; + PDFWriter* _tmp27_; + PDFWriter* _tmp28_; + PDFWriter* _tmp39_; + PDFWriter* _tmp40_; + guint _tmp41_ = 0U; + gchar* _tmp42_ = NULL; + gchar* _tmp43_; + PDFWriter* _tmp44_; + PDFWriter* _tmp45_; + PDFWriter* _tmp359_; + PDFWriter* _tmp360_; + guint _tmp361_ = 0U; guint info_number; - gchar* _tmp101_ = NULL; - gchar* _tmp102_; - gchar* _tmp103_ = NULL; - gchar* _tmp104_; + PDFWriter* _tmp362_; + guint _tmp363_; + gchar* _tmp364_ = NULL; + gchar* _tmp365_; + PDFWriter* _tmp366_; + PDFWriter* _tmp367_; + gchar* _tmp368_ = NULL; + gchar* _tmp369_; + PDFWriter* _tmp370_; + PDFWriter* _tmp371_; + PDFWriter* _tmp372_; + gsize _tmp373_; gsize xref_offset; - guint _tmp105_; - gchar* _tmp106_ = NULL; - gchar* _tmp107_; - guint _tmp110_; - gchar* _tmp111_ = NULL; - gchar* _tmp112_; - gchar* _tmp113_ = NULL; - gchar* _tmp114_; - gchar* _tmp115_ = NULL; - gchar* _tmp116_; - gchar* _tmp117_ = NULL; - gchar* _tmp118_; + PDFWriter* _tmp374_; + PDFWriter* _tmp375_; + PDFWriter* _tmp376_; + GList* _tmp377_; + guint _tmp378_ = 0U; + gchar* _tmp379_ = NULL; + gchar* _tmp380_; + PDFWriter* _tmp381_; + GList* _tmp382_; + PDFWriter* _tmp387_; + PDFWriter* _tmp388_; + PDFWriter* _tmp389_; + PDFWriter* _tmp390_; + GList* _tmp391_; + guint _tmp392_ = 0U; + gchar* _tmp393_ = NULL; + gchar* _tmp394_; + PDFWriter* _tmp395_; + guint _tmp396_; + gchar* _tmp397_ = NULL; + gchar* _tmp398_; + PDFWriter* _tmp399_; + guint _tmp400_; + gchar* _tmp401_ = NULL; + gchar* _tmp402_; + PDFWriter* _tmp403_; + PDFWriter* _tmp404_; + PDFWriter* _tmp405_; + gsize _tmp406_; + gchar* _tmp407_ = NULL; + gchar* _tmp408_; + PDFWriter* _tmp409_; GError * _inner_error_ = NULL; g_return_if_fail (self != NULL); g_return_if_fail (file != NULL); - _tmp0_ = g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &_inner_error_); - stream = _tmp0_; + _tmp0_ = file; + _tmp1_ = g_file_replace (_tmp0_, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &_inner_error_); + stream = _tmp1_; if (_inner_error_ != NULL) { g_propagate_error (error, _inner_error_); return; } - _tmp1_ = pdf_writer_new (stream); - writer = _tmp1_; - pdf_writer_write_string (writer, "%PDF-1.3\n"); - pdf_writer_write_string (writer, "%\xe2\xe3\xcf\xd3\n"); - _tmp2_ = pdf_writer_start_object (writer); - catalog_number = _tmp2_; - _tmp3_ = g_strdup_printf ("%u 0 obj\n", catalog_number); - _tmp4_ = _tmp3_; - pdf_writer_write_string (writer, _tmp4_); - _g_free0 (_tmp4_); - pdf_writer_write_string (writer, "<<\n"); - pdf_writer_write_string (writer, "/Type /Catalog\n"); - _tmp5_ = g_strdup_printf ("/Pages %u 0 R\n", catalog_number + 1); - _tmp6_ = _tmp5_; - pdf_writer_write_string (writer, _tmp6_); - _g_free0 (_tmp6_); - pdf_writer_write_string (writer, ">>\n"); - pdf_writer_write_string (writer, "endobj\n"); - pdf_writer_write_string (writer, "\n"); - _tmp7_ = pdf_writer_start_object (writer); - pages_number = _tmp7_; - _tmp8_ = g_strdup_printf ("%u 0 obj\n", pages_number); - _tmp9_ = _tmp8_; - pdf_writer_write_string (writer, _tmp9_); - _g_free0 (_tmp9_); - pdf_writer_write_string (writer, "<<\n"); - pdf_writer_write_string (writer, "/Type /Pages\n"); - pdf_writer_write_string (writer, "/Kids ["); + _tmp2_ = pdf_writer_new (stream); + writer = _tmp2_; + _tmp3_ = writer; + pdf_writer_write_string (_tmp3_, "%PDF-1.3\n"); + _tmp4_ = writer; + pdf_writer_write_string (_tmp4_, "%\xe2\xe3\xcf\xd3\n"); + _tmp5_ = writer; + _tmp6_ = pdf_writer_start_object (_tmp5_); + catalog_number = _tmp6_; + _tmp7_ = writer; + _tmp8_ = catalog_number; + _tmp9_ = g_strdup_printf ("%u 0 obj\n", _tmp8_); + _tmp10_ = _tmp9_; + pdf_writer_write_string (_tmp7_, _tmp10_); + _g_free0 (_tmp10_); + _tmp11_ = writer; + pdf_writer_write_string (_tmp11_, "<<\n"); + _tmp12_ = writer; + pdf_writer_write_string (_tmp12_, "/Type /Catalog\n"); + _tmp13_ = writer; + _tmp14_ = catalog_number; + _tmp15_ = g_strdup_printf ("/Pages %u 0 R\n", _tmp14_ + 1); + _tmp16_ = _tmp15_; + pdf_writer_write_string (_tmp13_, _tmp16_); + _g_free0 (_tmp16_); + _tmp17_ = writer; + pdf_writer_write_string (_tmp17_, ">>\n"); + _tmp18_ = writer; + pdf_writer_write_string (_tmp18_, "endobj\n"); + _tmp19_ = writer; + pdf_writer_write_string (_tmp19_, "\n"); + _tmp20_ = writer; + _tmp21_ = pdf_writer_start_object (_tmp20_); + pages_number = _tmp21_; + _tmp22_ = writer; + _tmp23_ = pages_number; + _tmp24_ = g_strdup_printf ("%u 0 obj\n", _tmp23_); + _tmp25_ = _tmp24_; + pdf_writer_write_string (_tmp22_, _tmp25_); + _g_free0 (_tmp25_); + _tmp26_ = writer; + pdf_writer_write_string (_tmp26_, "<<\n"); + _tmp27_ = writer; + pdf_writer_write_string (_tmp27_, "/Type /Pages\n"); + _tmp28_ = writer; + pdf_writer_write_string (_tmp28_, "/Kids ["); { gint i; i = 0; { - gboolean _tmp10_; - _tmp10_ = TRUE; + gboolean _tmp29_; + _tmp29_ = TRUE; while (TRUE) { - guint _tmp11_; - gchar* _tmp12_ = NULL; - gchar* _tmp13_; - if (!_tmp10_) { - i++; + gboolean _tmp30_; + gint _tmp32_; + guint _tmp33_ = 0U; + PDFWriter* _tmp34_; + guint _tmp35_; + gint _tmp36_; + gchar* _tmp37_ = NULL; + gchar* _tmp38_; + _tmp30_ = _tmp29_; + if (!_tmp30_) { + gint _tmp31_; + _tmp31_ = i; + i = _tmp31_ + 1; } - _tmp10_ = FALSE; - _tmp11_ = book_get_n_pages (self); - if (!(((guint) i) < _tmp11_)) { + _tmp29_ = FALSE; + _tmp32_ = i; + _tmp33_ = book_get_n_pages (self); + if (!(((guint) _tmp32_) < _tmp33_)) { break; } - _tmp12_ = g_strdup_printf (" %u 0 R", (pages_number + 1) + (i * 3)); - _tmp13_ = _tmp12_; - pdf_writer_write_string (writer, _tmp13_); - _g_free0 (_tmp13_); + _tmp34_ = writer; + _tmp35_ = pages_number; + _tmp36_ = i; + _tmp37_ = g_strdup_printf (" %u 0 R", (_tmp35_ + 1) + (_tmp36_ * 3)); + _tmp38_ = _tmp37_; + pdf_writer_write_string (_tmp34_, _tmp38_); + _g_free0 (_tmp38_); } } } - pdf_writer_write_string (writer, " ]\n"); - _tmp14_ = book_get_n_pages (self); - _tmp15_ = g_strdup_printf ("/Count %u\n", _tmp14_); - _tmp16_ = _tmp15_; - pdf_writer_write_string (writer, _tmp16_); - _g_free0 (_tmp16_); - pdf_writer_write_string (writer, ">>\n"); - pdf_writer_write_string (writer, "endobj\n"); + _tmp39_ = writer; + pdf_writer_write_string (_tmp39_, " ]\n"); + _tmp40_ = writer; + _tmp41_ = book_get_n_pages (self); + _tmp42_ = g_strdup_printf ("/Count %u\n", _tmp41_); + _tmp43_ = _tmp42_; + pdf_writer_write_string (_tmp40_, _tmp43_); + _g_free0 (_tmp43_); + _tmp44_ = writer; + pdf_writer_write_string (_tmp44_, ">>\n"); + _tmp45_ = writer; + pdf_writer_write_string (_tmp45_, "endobj\n"); { gint i; i = 0; { - gboolean _tmp17_; - _tmp17_ = TRUE; + gboolean _tmp46_; + _tmp46_ = TRUE; while (TRUE) { - guint _tmp18_; - Page* _tmp19_ = NULL; + gboolean _tmp47_; + gint _tmp49_; + guint _tmp50_ = 0U; + gint _tmp51_; + Page* _tmp52_ = NULL; Page* page; - GdkPixbuf* _tmp20_ = NULL; + Page* _tmp53_; + GdkPixbuf* _tmp54_ = NULL; GdkPixbuf* image; - gint _tmp21_; + GdkPixbuf* _tmp55_; + gint _tmp56_ = 0; gint width; - gint _tmp22_; + GdkPixbuf* _tmp57_; + gint _tmp58_ = 0; gint height; - guint8* _tmp23_ = NULL; + GdkPixbuf* _tmp59_; + guint8* _tmp60_ = NULL; guint8* pixels; gint pixels_length1; gint _pixels_size_; - gint _tmp24_; + gint _tmp61_; + Page* _tmp62_; + gint _tmp63_ = 0; gdouble page_width; - gint _tmp25_; + gint _tmp64_; + Page* _tmp65_; + gint _tmp66_ = 0; gdouble page_height; gint depth; - gchar* _tmp26_; + gchar* _tmp67_; gchar* color_space; gchar* filter; - gchar* _tmp27_ = NULL; + gchar* _tmp68_ = NULL; gchar* width_buffer; gint width_buffer_length1; gint _width_buffer_size_; - gchar* _tmp28_ = NULL; + gchar* _tmp69_ = NULL; gchar* height_buffer; gint height_buffer_length1; gint _height_buffer_size_; guint8* data = NULL; gint data_length1 = 0; gint _data_size_ = 0; - gboolean _tmp29_; - gint _tmp52_; - guint8* _tmp53_ = NULL; + Page* _tmp70_; + gboolean _tmp71_ = FALSE; + guint8* _tmp237_; + gint _tmp237__length1; + gint _tmp238_ = 0; + guint8* _tmp239_ = NULL; guint8* compressed_data; gint compressed_data_length1; gint _compressed_data_size_; - guint _tmp63_; + guint8* _tmp240_; + gint _tmp240__length1; + PDFWriter* _tmp255_; + PDFWriter* _tmp256_; + guint _tmp257_ = 0U; guint number; - gchar* _tmp64_ = NULL; - gchar* _tmp65_; - gchar* _tmp66_ = NULL; - gchar* _tmp67_; - gchar* _tmp68_ = NULL; - gchar* _tmp69_; - const gchar* _tmp70_ = NULL; - const gchar* _tmp71_ = NULL; - gchar* _tmp72_ = NULL; - gchar* _tmp73_; - gchar* _tmp74_ = NULL; - gchar* _tmp75_; - guint _tmp76_; - gchar* _tmp77_ = NULL; - gchar* _tmp78_; - gchar* _tmp79_ = NULL; - gchar* _tmp80_; - gchar* _tmp81_ = NULL; - gchar* _tmp82_; - gchar* _tmp83_ = NULL; - gchar* _tmp84_; - gchar* _tmp85_ = NULL; - gchar* _tmp86_; - gchar* _tmp87_ = NULL; - gchar* _tmp88_; - const gchar* _tmp91_ = NULL; - const gchar* _tmp92_ = NULL; - gchar* _tmp93_ = NULL; + PDFWriter* _tmp258_; + guint _tmp259_; + gchar* _tmp260_ = NULL; + gchar* _tmp261_; + PDFWriter* _tmp262_; + PDFWriter* _tmp263_; + PDFWriter* _tmp264_; + guint _tmp265_; + gchar* _tmp266_ = NULL; + gchar* _tmp267_; + PDFWriter* _tmp268_; + gint _tmp269_; + guint _tmp270_; + gchar* _tmp271_ = NULL; + gchar* _tmp272_; + PDFWriter* _tmp273_; + gdouble _tmp274_; + gchar* _tmp275_; + gint _tmp275__length1; + const gchar* _tmp276_ = NULL; + gdouble _tmp277_; + gchar* _tmp278_; + gint _tmp278__length1; + const gchar* _tmp279_ = NULL; + gchar* _tmp280_ = NULL; + gchar* _tmp281_; + PDFWriter* _tmp282_; + guint _tmp283_; + gchar* _tmp284_ = NULL; + gchar* _tmp285_; + PDFWriter* _tmp286_; + PDFWriter* _tmp287_; + PDFWriter* _tmp288_; + PDFWriter* _tmp289_; + guint _tmp290_ = 0U; + PDFWriter* _tmp291_; + guint _tmp292_; + gchar* _tmp293_ = NULL; + gchar* _tmp294_; + PDFWriter* _tmp295_; + PDFWriter* _tmp296_; + PDFWriter* _tmp297_; + PDFWriter* _tmp298_; + gint _tmp299_; + gchar* _tmp300_ = NULL; + gchar* _tmp301_; + PDFWriter* _tmp302_; + gint _tmp303_; + gchar* _tmp304_ = NULL; + gchar* _tmp305_; + PDFWriter* _tmp306_; + const gchar* _tmp307_; + gchar* _tmp308_ = NULL; + gchar* _tmp309_; + PDFWriter* _tmp310_; + gint _tmp311_; + gchar* _tmp312_ = NULL; + gchar* _tmp313_; + PDFWriter* _tmp314_; + guint8* _tmp315_; + gint _tmp315__length1; + gchar* _tmp316_ = NULL; + gchar* _tmp317_; + const gchar* _tmp318_; + PDFWriter* _tmp323_; + PDFWriter* _tmp324_; + PDFWriter* _tmp325_; + guint8* _tmp326_; + gint _tmp326__length1; + PDFWriter* _tmp327_; + PDFWriter* _tmp328_; + PDFWriter* _tmp329_; + gdouble _tmp330_; + gchar* _tmp331_; + gint _tmp331__length1; + const gchar* _tmp332_ = NULL; + gdouble _tmp333_; + gchar* _tmp334_; + gint _tmp334__length1; + const gchar* _tmp335_ = NULL; + gint _tmp336_; + gchar* _tmp337_ = NULL; gchar* command; - guint _tmp94_; - gchar* _tmp95_ = NULL; - gchar* _tmp96_; - gint _tmp97_; - gchar* _tmp98_ = NULL; - gchar* _tmp99_; - if (!_tmp17_) { - i++; + PDFWriter* _tmp338_; + PDFWriter* _tmp339_; + guint _tmp340_ = 0U; + PDFWriter* _tmp341_; + guint _tmp342_; + gchar* _tmp343_ = NULL; + gchar* _tmp344_; + PDFWriter* _tmp345_; + PDFWriter* _tmp346_; + const gchar* _tmp347_; + gint _tmp348_; + gint _tmp349_; + gchar* _tmp350_ = NULL; + gchar* _tmp351_; + PDFWriter* _tmp352_; + PDFWriter* _tmp353_; + PDFWriter* _tmp354_; + const gchar* _tmp355_; + PDFWriter* _tmp356_; + PDFWriter* _tmp357_; + PDFWriter* _tmp358_; + _tmp47_ = _tmp46_; + if (!_tmp47_) { + gint _tmp48_; + _tmp48_ = i; + i = _tmp48_ + 1; } - _tmp17_ = FALSE; - _tmp18_ = book_get_n_pages (self); - if (!(((guint) i) < _tmp18_)) { + _tmp46_ = FALSE; + _tmp49_ = i; + _tmp50_ = book_get_n_pages (self); + if (!(((guint) _tmp49_) < _tmp50_)) { break; } - _tmp19_ = book_get_page (self, i); - page = _tmp19_; - _tmp20_ = page_get_image (page, TRUE); - image = _tmp20_; - _tmp21_ = gdk_pixbuf_get_width (image); - width = _tmp21_; - _tmp22_ = gdk_pixbuf_get_height (image); - height = _tmp22_; - _tmp23_ = gdk_pixbuf_get_pixels (image); - pixels = _tmp23_; + _tmp51_ = i; + _tmp52_ = book_get_page (self, _tmp51_); + page = _tmp52_; + _tmp53_ = page; + _tmp54_ = page_get_image (_tmp53_, TRUE); + image = _tmp54_; + _tmp55_ = image; + _tmp56_ = gdk_pixbuf_get_width (_tmp55_); + width = _tmp56_; + _tmp57_ = image; + _tmp58_ = gdk_pixbuf_get_height (_tmp57_); + height = _tmp58_; + _tmp59_ = image; + _tmp60_ = gdk_pixbuf_get_pixels (_tmp59_); + pixels = _tmp60_; pixels_length1 = -1; _pixels_size_ = pixels_length1; - _tmp24_ = page_get_dpi (page); - page_width = (width * 72.0) / _tmp24_; - _tmp25_ = page_get_dpi (page); - page_height = (height * 72.0) / _tmp25_; + _tmp61_ = width; + _tmp62_ = page; + _tmp63_ = page_get_dpi (_tmp62_); + page_width = (_tmp61_ * 72.0) / _tmp63_; + _tmp64_ = height; + _tmp65_ = page; + _tmp66_ = page_get_dpi (_tmp65_); + page_height = (_tmp64_ * 72.0) / _tmp66_; depth = 8; - _tmp26_ = g_strdup ("DeviceRGB"); - color_space = _tmp26_; + _tmp67_ = g_strdup ("DeviceRGB"); + color_space = _tmp67_; filter = NULL; - _tmp27_ = g_new0 (gchar, G_ASCII_DTOSTR_BUF_SIZE); - width_buffer = _tmp27_; + _tmp68_ = g_new0 (gchar, G_ASCII_DTOSTR_BUF_SIZE); + width_buffer = _tmp68_; width_buffer_length1 = G_ASCII_DTOSTR_BUF_SIZE; _width_buffer_size_ = width_buffer_length1; - _tmp28_ = g_new0 (gchar, G_ASCII_DTOSTR_BUF_SIZE); - height_buffer = _tmp28_; + _tmp69_ = g_new0 (gchar, G_ASCII_DTOSTR_BUF_SIZE); + height_buffer = _tmp69_; height_buffer_length1 = G_ASCII_DTOSTR_BUF_SIZE; _height_buffer_size_ = height_buffer_length1; - _tmp29_ = page_is_color (page); - if (_tmp29_) { - gchar* _tmp30_; + _tmp70_ = page; + _tmp71_ = page_is_color (_tmp70_); + if (_tmp71_) { + gchar* _tmp72_; + gint _tmp73_; + gint _tmp74_; gint data_length; - guint8* _tmp31_ = NULL; + gint _tmp75_; + guint8* _tmp76_ = NULL; depth = 8; - _tmp30_ = g_strdup ("DeviceRGB"); + _tmp72_ = g_strdup ("DeviceRGB"); _g_free0 (color_space); - color_space = _tmp30_; - data_length = ((height * width) * 3) + 1; - _tmp31_ = g_new0 (guint8, data_length); + color_space = _tmp72_; + _tmp73_ = height; + _tmp74_ = width; + data_length = ((_tmp73_ * _tmp74_) * 3) + 1; + _tmp75_ = data_length; + _tmp76_ = g_new0 (guint8, _tmp75_); data = (g_free (data), NULL); - data = _tmp31_; - data_length1 = data_length; + data = _tmp76_; + data_length1 = _tmp75_; _data_size_ = data_length1; { gint row; row = 0; { - gboolean _tmp32_; - _tmp32_ = TRUE; + gboolean _tmp77_; + _tmp77_ = TRUE; while (TRUE) { - gint _tmp33_; + gboolean _tmp78_; + gint _tmp80_; + gint _tmp81_; + gint _tmp82_; + GdkPixbuf* _tmp83_; + gint _tmp84_ = 0; gint in_offset; + gint _tmp85_; + gint _tmp86_; gint out_offset; - if (!_tmp32_) { - row++; + _tmp78_ = _tmp77_; + if (!_tmp78_) { + gint _tmp79_; + _tmp79_ = row; + row = _tmp79_ + 1; } - _tmp32_ = FALSE; - if (!(row < height)) { + _tmp77_ = FALSE; + _tmp80_ = row; + _tmp81_ = height; + if (!(_tmp80_ < _tmp81_)) { break; } - _tmp33_ = gdk_pixbuf_get_rowstride (image); - in_offset = row * _tmp33_; - out_offset = (row * width) * 3; + _tmp82_ = row; + _tmp83_ = image; + _tmp84_ = gdk_pixbuf_get_rowstride (_tmp83_); + in_offset = _tmp82_ * _tmp84_; + _tmp85_ = row; + _tmp86_ = width; + out_offset = (_tmp85_ * _tmp86_) * 3; { gint x; x = 0; { - gboolean _tmp34_; - _tmp34_ = TRUE; + gboolean _tmp87_; + _tmp87_ = TRUE; while (TRUE) { + gboolean _tmp88_; + gint _tmp90_; + gint _tmp91_; + gint _tmp92_; + gint _tmp93_; gint in_o; + gint _tmp94_; + gint _tmp95_; gint out_o; - if (!_tmp34_) { - x++; + guint8* _tmp96_; + gint _tmp96__length1; + gint _tmp97_; + guint8* _tmp98_; + gint _tmp98__length1; + gint _tmp99_; + guint8 _tmp100_; + guint8 _tmp101_; + guint8* _tmp102_; + gint _tmp102__length1; + gint _tmp103_; + guint8* _tmp104_; + gint _tmp104__length1; + gint _tmp105_; + guint8 _tmp106_; + guint8 _tmp107_; + guint8* _tmp108_; + gint _tmp108__length1; + gint _tmp109_; + guint8* _tmp110_; + gint _tmp110__length1; + gint _tmp111_; + guint8 _tmp112_; + guint8 _tmp113_; + _tmp88_ = _tmp87_; + if (!_tmp88_) { + gint _tmp89_; + _tmp89_ = x; + x = _tmp89_ + 1; } - _tmp34_ = FALSE; - if (!(x < width)) { + _tmp87_ = FALSE; + _tmp90_ = x; + _tmp91_ = width; + if (!(_tmp90_ < _tmp91_)) { break; } - in_o = in_offset + (x * 3); - out_o = out_offset + (x * 3); - data[out_o] = pixels[in_o]; - data[out_o + 1] = pixels[in_o + 1]; - data[out_o + 2] = pixels[in_o + 2]; + _tmp92_ = in_offset; + _tmp93_ = x; + in_o = _tmp92_ + (_tmp93_ * 3); + _tmp94_ = out_offset; + _tmp95_ = x; + out_o = _tmp94_ + (_tmp95_ * 3); + _tmp96_ = data; + _tmp96__length1 = data_length1; + _tmp97_ = out_o; + _tmp98_ = pixels; + _tmp98__length1 = pixels_length1; + _tmp99_ = in_o; + _tmp100_ = _tmp98_[_tmp99_]; + _tmp96_[_tmp97_] = _tmp100_; + _tmp101_ = _tmp96_[_tmp97_]; + _tmp102_ = data; + _tmp102__length1 = data_length1; + _tmp103_ = out_o; + _tmp104_ = pixels; + _tmp104__length1 = pixels_length1; + _tmp105_ = in_o; + _tmp106_ = _tmp104_[_tmp105_ + 1]; + _tmp102_[_tmp103_ + 1] = _tmp106_; + _tmp107_ = _tmp102_[_tmp103_ + 1]; + _tmp108_ = data; + _tmp108__length1 = data_length1; + _tmp109_ = out_o; + _tmp110_ = pixels; + _tmp110__length1 = pixels_length1; + _tmp111_ = in_o; + _tmp112_ = _tmp110_[_tmp111_ + 2]; + _tmp108_[_tmp109_ + 2] = _tmp112_; + _tmp113_ = _tmp108_[_tmp109_ + 2]; } } } @@ -1099,83 +1639,191 @@ static void book_save_pdf (Book* self, GFile* file, GError** error) { } } } else { - gint _tmp35_; - _tmp35_ = page_get_depth (page); - if (_tmp35_ == 2) { + Page* _tmp114_; + gint _tmp115_ = 0; + _tmp114_ = page; + _tmp115_ = page_get_depth (_tmp114_); + if (_tmp115_ == 2) { gint shift_count; - gchar* _tmp36_; + gchar* _tmp116_; + gint _tmp117_; + gint _tmp118_; gint data_length; - guint8* _tmp37_ = NULL; + gint _tmp119_; + guint8* _tmp120_ = NULL; gint offset; + guint8* _tmp121_; + gint _tmp121__length1; + gint _tmp122_; + guint8 _tmp123_; shift_count = 6; depth = 2; - _tmp36_ = g_strdup ("DeviceGray"); + _tmp116_ = g_strdup ("DeviceGray"); _g_free0 (color_space); - color_space = _tmp36_; - data_length = height * (((width * 2) + 7) / 8); - _tmp37_ = g_new0 (guint8, data_length); + color_space = _tmp116_; + _tmp117_ = height; + _tmp118_ = width; + data_length = _tmp117_ * (((_tmp118_ * 2) + 7) / 8); + _tmp119_ = data_length; + _tmp120_ = g_new0 (guint8, _tmp119_); data = (g_free (data), NULL); - data = _tmp37_; - data_length1 = data_length; + data = _tmp120_; + data_length1 = _tmp119_; _data_size_ = data_length1; offset = 0; - data[offset] = (guint8) 0; + _tmp121_ = data; + _tmp121__length1 = data_length1; + _tmp122_ = offset; + _tmp121_[_tmp122_] = (guint8) 0; + _tmp123_ = _tmp121_[_tmp122_]; { gint row; row = 0; { - gboolean _tmp38_; - _tmp38_ = TRUE; + gboolean _tmp124_; + _tmp124_ = TRUE; while (TRUE) { - gint _tmp39_; + gboolean _tmp125_; + gint _tmp127_; + gint _tmp128_; + gint _tmp129_; + gint _tmp134_; + GdkPixbuf* _tmp135_; + gint _tmp136_ = 0; gint in_offset; - if (!_tmp38_) { - row++; + _tmp125_ = _tmp124_; + if (!_tmp125_) { + gint _tmp126_; + _tmp126_ = row; + row = _tmp126_ + 1; } - _tmp38_ = FALSE; - if (!(row < height)) { + _tmp124_ = FALSE; + _tmp127_ = row; + _tmp128_ = height; + if (!(_tmp127_ < _tmp128_)) { break; } - if (shift_count != 6) { - offset++; - data[offset] = (guint8) 0; + _tmp129_ = shift_count; + if (_tmp129_ != 6) { + gint _tmp130_; + guint8* _tmp131_; + gint _tmp131__length1; + gint _tmp132_; + guint8 _tmp133_; + _tmp130_ = offset; + offset = _tmp130_ + 1; + _tmp131_ = data; + _tmp131__length1 = data_length1; + _tmp132_ = offset; + _tmp131_[_tmp132_] = (guint8) 0; + _tmp133_ = _tmp131_[_tmp132_]; shift_count = 6; } - _tmp39_ = gdk_pixbuf_get_rowstride (image); - in_offset = row * _tmp39_; + _tmp134_ = row; + _tmp135_ = image; + _tmp136_ = gdk_pixbuf_get_rowstride (_tmp135_); + in_offset = _tmp134_ * _tmp136_; { gint x; x = 0; { - gboolean _tmp40_; - _tmp40_ = TRUE; + gboolean _tmp137_; + _tmp137_ = TRUE; while (TRUE) { + gboolean _tmp138_; + gint _tmp140_; + gint _tmp141_; + guint8* _tmp142_; + gint _tmp142__length1; + gint _tmp143_; + gint _tmp144_; + guint8 _tmp145_; guint8 p; - if (!_tmp40_) { - x++; + guint8 _tmp146_; + gint _tmp161_; + _tmp138_ = _tmp137_; + if (!_tmp138_) { + gint _tmp139_; + _tmp139_ = x; + x = _tmp139_ + 1; } - _tmp40_ = FALSE; - if (!(x < width)) { + _tmp137_ = FALSE; + _tmp140_ = x; + _tmp141_ = width; + if (!(_tmp140_ < _tmp141_)) { break; } - p = pixels[in_offset + (x * 3)]; - if (((gint) p) >= 192) { - data[offset] |= (guint8) (3 << shift_count); + _tmp142_ = pixels; + _tmp142__length1 = pixels_length1; + _tmp143_ = in_offset; + _tmp144_ = x; + _tmp145_ = _tmp142_[_tmp143_ + (_tmp144_ * 3)]; + p = _tmp145_; + _tmp146_ = p; + if (((gint) _tmp146_) >= 192) { + guint8* _tmp147_; + gint _tmp147__length1; + gint _tmp148_; + gint _tmp149_; + guint8 _tmp150_; + _tmp147_ = data; + _tmp147__length1 = data_length1; + _tmp148_ = offset; + _tmp149_ = shift_count; + _tmp147_[_tmp148_] |= (guint8) (3 << _tmp149_); + _tmp150_ = _tmp147_[_tmp148_]; } else { - if (((gint) p) >= 128) { - data[offset] |= (guint8) (2 << shift_count); + guint8 _tmp151_; + _tmp151_ = p; + if (((gint) _tmp151_) >= 128) { + guint8* _tmp152_; + gint _tmp152__length1; + gint _tmp153_; + gint _tmp154_; + guint8 _tmp155_; + _tmp152_ = data; + _tmp152__length1 = data_length1; + _tmp153_ = offset; + _tmp154_ = shift_count; + _tmp152_[_tmp153_] |= (guint8) (2 << _tmp154_); + _tmp155_ = _tmp152_[_tmp153_]; } else { - if (((gint) p) >= 64) { - data[offset] |= (guint8) (1 << shift_count); + guint8 _tmp156_; + _tmp156_ = p; + if (((gint) _tmp156_) >= 64) { + guint8* _tmp157_; + gint _tmp157__length1; + gint _tmp158_; + gint _tmp159_; + guint8 _tmp160_; + _tmp157_ = data; + _tmp157__length1 = data_length1; + _tmp158_ = offset; + _tmp159_ = shift_count; + _tmp157_[_tmp158_] |= (guint8) (1 << _tmp159_); + _tmp160_ = _tmp157_[_tmp158_]; } } } - if (shift_count == 0) { - offset++; - data[offset] = (guint8) 0; + _tmp161_ = shift_count; + if (_tmp161_ == 0) { + gint _tmp162_; + guint8* _tmp163_; + gint _tmp163__length1; + gint _tmp164_; + guint8 _tmp165_; + _tmp162_ = offset; + offset = _tmp162_ + 1; + _tmp163_ = data; + _tmp163__length1 = data_length1; + _tmp164_ = offset; + _tmp163_[_tmp164_] = (guint8) 0; + _tmp165_ = _tmp163_[_tmp164_]; shift_count = 6; } else { - shift_count = shift_count - 2; + gint _tmp166_; + _tmp166_ = shift_count; + shift_count = _tmp166_ - 2; } } } @@ -1184,71 +1832,153 @@ static void book_save_pdf (Book* self, GFile* file, GError** error) { } } } else { - gint _tmp41_; - _tmp41_ = page_get_depth (page); - if (_tmp41_ == 1) { + Page* _tmp167_; + gint _tmp168_ = 0; + _tmp167_ = page; + _tmp168_ = page_get_depth (_tmp167_); + if (_tmp168_ == 1) { gint mask; - gchar* _tmp42_; + gchar* _tmp169_; + gint _tmp170_; + gint _tmp171_; gint data_length; - guint8* _tmp43_ = NULL; + gint _tmp172_; + guint8* _tmp173_ = NULL; gint offset; + guint8* _tmp174_; + gint _tmp174__length1; + gint _tmp175_; + guint8 _tmp176_; mask = 0x80; depth = 1; - _tmp42_ = g_strdup ("DeviceGray"); + _tmp169_ = g_strdup ("DeviceGray"); _g_free0 (color_space); - color_space = _tmp42_; - data_length = height * ((width + 7) / 8); - _tmp43_ = g_new0 (guint8, data_length); + color_space = _tmp169_; + _tmp170_ = height; + _tmp171_ = width; + data_length = _tmp170_ * ((_tmp171_ + 7) / 8); + _tmp172_ = data_length; + _tmp173_ = g_new0 (guint8, _tmp172_); data = (g_free (data), NULL); - data = _tmp43_; - data_length1 = data_length; + data = _tmp173_; + data_length1 = _tmp172_; _data_size_ = data_length1; offset = 0; - data[offset] = (guint8) 0; + _tmp174_ = data; + _tmp174__length1 = data_length1; + _tmp175_ = offset; + _tmp174_[_tmp175_] = (guint8) 0; + _tmp176_ = _tmp174_[_tmp175_]; { gint row; row = 0; { - gboolean _tmp44_; - _tmp44_ = TRUE; + gboolean _tmp177_; + _tmp177_ = TRUE; while (TRUE) { - gint _tmp45_; + gboolean _tmp178_; + gint _tmp180_; + gint _tmp181_; + gint _tmp182_; + gint _tmp187_; + GdkPixbuf* _tmp188_; + gint _tmp189_ = 0; gint in_offset; - if (!_tmp44_) { - row++; + _tmp178_ = _tmp177_; + if (!_tmp178_) { + gint _tmp179_; + _tmp179_ = row; + row = _tmp179_ + 1; } - _tmp44_ = FALSE; - if (!(row < height)) { + _tmp177_ = FALSE; + _tmp180_ = row; + _tmp181_ = height; + if (!(_tmp180_ < _tmp181_)) { break; } - if (mask != 0x80) { - offset++; - data[offset] = (guint8) 0; + _tmp182_ = mask; + if (_tmp182_ != 0x80) { + gint _tmp183_; + guint8* _tmp184_; + gint _tmp184__length1; + gint _tmp185_; + guint8 _tmp186_; + _tmp183_ = offset; + offset = _tmp183_ + 1; + _tmp184_ = data; + _tmp184__length1 = data_length1; + _tmp185_ = offset; + _tmp184_[_tmp185_] = (guint8) 0; + _tmp186_ = _tmp184_[_tmp185_]; mask = 0x80; } - _tmp45_ = gdk_pixbuf_get_rowstride (image); - in_offset = row * _tmp45_; + _tmp187_ = row; + _tmp188_ = image; + _tmp189_ = gdk_pixbuf_get_rowstride (_tmp188_); + in_offset = _tmp187_ * _tmp189_; { gint x; x = 0; { - gboolean _tmp46_; - _tmp46_ = TRUE; + gboolean _tmp190_; + _tmp190_ = TRUE; while (TRUE) { - if (!_tmp46_) { - x++; + gboolean _tmp191_; + gint _tmp193_; + gint _tmp194_; + guint8* _tmp195_; + gint _tmp195__length1; + gint _tmp196_; + gint _tmp197_; + guint8 _tmp198_; + gint _tmp203_; + gint _tmp204_; + _tmp191_ = _tmp190_; + if (!_tmp191_) { + gint _tmp192_; + _tmp192_ = x; + x = _tmp192_ + 1; } - _tmp46_ = FALSE; - if (!(x < width)) { + _tmp190_ = FALSE; + _tmp193_ = x; + _tmp194_ = width; + if (!(_tmp193_ < _tmp194_)) { break; } - if (((gint) pixels[in_offset + (x * 3)]) != 0) { - data[offset] |= (guint8) mask; + _tmp195_ = pixels; + _tmp195__length1 = pixels_length1; + _tmp196_ = in_offset; + _tmp197_ = x; + _tmp198_ = _tmp195_[_tmp196_ + (_tmp197_ * 3)]; + if (((gint) _tmp198_) != 0) { + guint8* _tmp199_; + gint _tmp199__length1; + gint _tmp200_; + gint _tmp201_; + guint8 _tmp202_; + _tmp199_ = data; + _tmp199__length1 = data_length1; + _tmp200_ = offset; + _tmp201_ = mask; + _tmp199_[_tmp200_] |= (guint8) _tmp201_; + _tmp202_ = _tmp199_[_tmp200_]; } - mask = mask >> 1; - if (mask == 0) { - offset++; - data[offset] = (guint8) 0; + _tmp203_ = mask; + mask = _tmp203_ >> 1; + _tmp204_ = mask; + if (_tmp204_ == 0) { + gint _tmp205_; + guint8* _tmp206_; + gint _tmp206__length1; + gint _tmp207_; + guint8 _tmp208_; + _tmp205_ = offset; + offset = _tmp205_ + 1; + _tmp206_ = data; + _tmp206__length1 = data_length1; + _tmp207_ = offset; + _tmp206_[_tmp207_] = (guint8) 0; + _tmp208_ = _tmp206_[_tmp207_]; mask = 0x80; } } @@ -1258,54 +1988,104 @@ static void book_save_pdf (Book* self, GFile* file, GError** error) { } } } else { - gchar* _tmp47_; + gchar* _tmp209_; + gint _tmp210_; + gint _tmp211_; gint data_length; - guint8* _tmp48_ = NULL; + gint _tmp212_; + guint8* _tmp213_ = NULL; depth = 8; - _tmp47_ = g_strdup ("DeviceGray"); + _tmp209_ = g_strdup ("DeviceGray"); _g_free0 (color_space); - color_space = _tmp47_; - data_length = (height * width) + 1; - _tmp48_ = g_new0 (guint8, data_length); + color_space = _tmp209_; + _tmp210_ = height; + _tmp211_ = width; + data_length = (_tmp210_ * _tmp211_) + 1; + _tmp212_ = data_length; + _tmp213_ = g_new0 (guint8, _tmp212_); data = (g_free (data), NULL); - data = _tmp48_; - data_length1 = data_length; + data = _tmp213_; + data_length1 = _tmp212_; _data_size_ = data_length1; { gint row; row = 0; { - gboolean _tmp49_; - _tmp49_ = TRUE; + gboolean _tmp214_; + _tmp214_ = TRUE; while (TRUE) { - gint _tmp50_; + gboolean _tmp215_; + gint _tmp217_; + gint _tmp218_; + gint _tmp219_; + GdkPixbuf* _tmp220_; + gint _tmp221_ = 0; gint in_offset; + gint _tmp222_; + gint _tmp223_; gint out_offset; - if (!_tmp49_) { - row++; + _tmp215_ = _tmp214_; + if (!_tmp215_) { + gint _tmp216_; + _tmp216_ = row; + row = _tmp216_ + 1; } - _tmp49_ = FALSE; - if (!(row < height)) { + _tmp214_ = FALSE; + _tmp217_ = row; + _tmp218_ = height; + if (!(_tmp217_ < _tmp218_)) { break; } - _tmp50_ = gdk_pixbuf_get_rowstride (image); - in_offset = row * _tmp50_; - out_offset = row * width; + _tmp219_ = row; + _tmp220_ = image; + _tmp221_ = gdk_pixbuf_get_rowstride (_tmp220_); + in_offset = _tmp219_ * _tmp221_; + _tmp222_ = row; + _tmp223_ = width; + out_offset = _tmp222_ * _tmp223_; { gint x; x = 0; { - gboolean _tmp51_; - _tmp51_ = TRUE; + gboolean _tmp224_; + _tmp224_ = TRUE; while (TRUE) { - if (!_tmp51_) { - x++; + gboolean _tmp225_; + gint _tmp227_; + gint _tmp228_; + guint8* _tmp229_; + gint _tmp229__length1; + gint _tmp230_; + gint _tmp231_; + guint8* _tmp232_; + gint _tmp232__length1; + gint _tmp233_; + gint _tmp234_; + guint8 _tmp235_; + guint8 _tmp236_; + _tmp225_ = _tmp224_; + if (!_tmp225_) { + gint _tmp226_; + _tmp226_ = x; + x = _tmp226_ + 1; } - _tmp51_ = FALSE; - if (!(x < width)) { + _tmp224_ = FALSE; + _tmp227_ = x; + _tmp228_ = width; + if (!(_tmp227_ < _tmp228_)) { break; } - data[out_offset + x] = pixels[in_offset + (x * 3)]; + _tmp229_ = data; + _tmp229__length1 = data_length1; + _tmp230_ = out_offset; + _tmp231_ = x; + _tmp232_ = pixels; + _tmp232__length1 = pixels_length1; + _tmp233_ = in_offset; + _tmp234_ = x; + _tmp235_ = _tmp232_[_tmp233_ + (_tmp234_ * 3)]; + _tmp229_[_tmp230_ + _tmp231_] = _tmp235_; + _tmp236_ = _tmp229_[_tmp230_ + _tmp231_]; } } } @@ -1315,149 +2095,250 @@ static void book_save_pdf (Book* self, GFile* file, GError** error) { } } } - _tmp53_ = book_compress_zlib (self, data, data_length1, &_tmp52_); - compressed_data = _tmp53_; - compressed_data_length1 = _tmp52_; + _tmp237_ = data; + _tmp237__length1 = data_length1; + _tmp239_ = book_compress_zlib (self, _tmp237_, _tmp237__length1, &_tmp238_); + compressed_data = _tmp239_; + compressed_data_length1 = _tmp238_; _compressed_data_size_ = compressed_data_length1; - if (compressed_data != NULL) { - if (depth > 1) { + _tmp240_ = compressed_data; + _tmp240__length1 = compressed_data_length1; + if (_tmp240_ != NULL) { + gint _tmp241_; + const gchar* _tmp251_; + _tmp241_ = depth; + if (_tmp241_ > 1) { gsize jpeg_length = 0UL; - gsize _tmp54_; - gint _tmp55_; - guint8* _tmp56_ = NULL; + GdkPixbuf* _tmp242_; + gsize _tmp243_ = 0UL; + gint _tmp244_ = 0; + guint8* _tmp245_ = NULL; guint8* jpeg_data; gint jpeg_data_length1; gint _jpeg_data_size_; - _tmp56_ = book_compress_jpeg (self, image, &_tmp54_, &_tmp55_); - jpeg_length = _tmp54_; - jpeg_data = _tmp56_; - jpeg_data_length1 = _tmp55_; + gsize _tmp246_; + guint8* _tmp247_; + gint _tmp247__length1; + _tmp242_ = image; + _tmp245_ = book_compress_jpeg (self, _tmp242_, &_tmp243_, &_tmp244_); + jpeg_length = _tmp243_; + jpeg_data = _tmp245_; + jpeg_data_length1 = _tmp244_; _jpeg_data_size_ = jpeg_data_length1; - if (jpeg_length < ((gsize) compressed_data_length1)) { - gchar* _tmp57_; - guint8* _tmp58_; - guint8* _tmp59_; - _tmp57_ = g_strdup ("DCTDecode"); + _tmp246_ = jpeg_length; + _tmp247_ = compressed_data; + _tmp247__length1 = compressed_data_length1; + if (_tmp246_ < ((gsize) _tmp247__length1)) { + gchar* _tmp248_; + guint8* _tmp249_; + gint _tmp249__length1; + guint8* _tmp250_; + gint _tmp250__length1; + _tmp248_ = g_strdup ("DCTDecode"); _g_free0 (filter); - filter = _tmp57_; - _tmp59_ = (_tmp58_ = jpeg_data, (_tmp58_ == NULL) ? ((gpointer) _tmp58_) : _vala_array_dup1 (_tmp58_, jpeg_data_length1)); + filter = _tmp248_; + _tmp249_ = jpeg_data; + _tmp249__length1 = jpeg_data_length1; + _tmp250_ = (_tmp249_ != NULL) ? _vala_array_dup1 (_tmp249_, _tmp249__length1) : ((gpointer) _tmp249_); + _tmp250__length1 = _tmp249__length1; data = (g_free (data), NULL); - data = _tmp59_; - data_length1 = jpeg_data_length1; + data = _tmp250_; + data_length1 = _tmp250__length1; _data_size_ = data_length1; } jpeg_data = (g_free (jpeg_data), NULL); } - if (filter == NULL) { - gchar* _tmp60_; - guint8* _tmp61_; - guint8* _tmp62_; - _tmp60_ = g_strdup ("FlateDecode"); + _tmp251_ = filter; + if (_tmp251_ == NULL) { + gchar* _tmp252_; + guint8* _tmp253_; + gint _tmp253__length1; + guint8* _tmp254_; + gint _tmp254__length1; + _tmp252_ = g_strdup ("FlateDecode"); _g_free0 (filter); - filter = _tmp60_; - _tmp62_ = (_tmp61_ = compressed_data, (_tmp61_ == NULL) ? ((gpointer) _tmp61_) : _vala_array_dup2 (_tmp61_, compressed_data_length1)); + filter = _tmp252_; + _tmp253_ = compressed_data; + _tmp253__length1 = compressed_data_length1; + _tmp254_ = (_tmp253_ != NULL) ? _vala_array_dup2 (_tmp253_, _tmp253__length1) : ((gpointer) _tmp253_); + _tmp254__length1 = _tmp253__length1; data = (g_free (data), NULL); - data = _tmp62_; - data_length1 = compressed_data_length1; + data = _tmp254_; + data_length1 = _tmp254__length1; _data_size_ = data_length1; } } - pdf_writer_write_string (writer, "\n"); - _tmp63_ = pdf_writer_start_object (writer); - number = _tmp63_; - _tmp64_ = g_strdup_printf ("%u 0 obj\n", number); - _tmp65_ = _tmp64_; - pdf_writer_write_string (writer, _tmp65_); - _g_free0 (_tmp65_); - pdf_writer_write_string (writer, "<<\n"); - pdf_writer_write_string (writer, "/Type /Page\n"); - _tmp66_ = g_strdup_printf ("/Parent %u 0 R\n", pages_number); - _tmp67_ = _tmp66_; - pdf_writer_write_string (writer, _tmp67_); - _g_free0 (_tmp67_); - _tmp68_ = g_strdup_printf ("/Resources << /XObject << /Im%d %u 0 R >> >>\n", i, number + 1); - _tmp69_ = _tmp68_; - pdf_writer_write_string (writer, _tmp69_); - _g_free0 (_tmp69_); - _tmp70_ = g_ascii_formatd (width_buffer, width_buffer_length1, "%.2f", page_width); - _tmp71_ = g_ascii_formatd (height_buffer, height_buffer_length1, "%.2f", page_height); - _tmp72_ = g_strdup_printf ("/MediaBox [ 0 0 %s %s ]\n", _tmp70_, _tmp71_); - _tmp73_ = _tmp72_; - pdf_writer_write_string (writer, _tmp73_); - _g_free0 (_tmp73_); - _tmp74_ = g_strdup_printf ("/Contents %u 0 R\n", number + 2); - _tmp75_ = _tmp74_; - pdf_writer_write_string (writer, _tmp75_); - _g_free0 (_tmp75_); - pdf_writer_write_string (writer, ">>\n"); - pdf_writer_write_string (writer, "endobj\n"); - pdf_writer_write_string (writer, "\n"); - _tmp76_ = pdf_writer_start_object (writer); - number = _tmp76_; - _tmp77_ = g_strdup_printf ("%u 0 obj\n", number); - _tmp78_ = _tmp77_; - pdf_writer_write_string (writer, _tmp78_); - _g_free0 (_tmp78_); - pdf_writer_write_string (writer, "<<\n"); - pdf_writer_write_string (writer, "/Type /XObject\n"); - pdf_writer_write_string (writer, "/Subtype /Image\n"); - _tmp79_ = g_strdup_printf ("/Width %d\n", width); - _tmp80_ = _tmp79_; - pdf_writer_write_string (writer, _tmp80_); - _g_free0 (_tmp80_); - _tmp81_ = g_strdup_printf ("/Height %d\n", height); - _tmp82_ = _tmp81_; - pdf_writer_write_string (writer, _tmp82_); - _g_free0 (_tmp82_); - _tmp83_ = g_strdup_printf ("/ColorSpace /%s\n", color_space); - _tmp84_ = _tmp83_; - pdf_writer_write_string (writer, _tmp84_); - _g_free0 (_tmp84_); - _tmp85_ = g_strdup_printf ("/BitsPerComponent %d\n", depth); - _tmp86_ = _tmp85_; - pdf_writer_write_string (writer, _tmp86_); - _g_free0 (_tmp86_); - _tmp87_ = g_strdup_printf ("/Length %d\n", data_length1); - _tmp88_ = _tmp87_; - pdf_writer_write_string (writer, _tmp88_); - _g_free0 (_tmp88_); - if (filter != NULL) { - gchar* _tmp89_ = NULL; - gchar* _tmp90_; - _tmp89_ = g_strdup_printf ("/Filter /%s\n", filter); - _tmp90_ = _tmp89_; - pdf_writer_write_string (writer, _tmp90_); - _g_free0 (_tmp90_); + _tmp255_ = writer; + pdf_writer_write_string (_tmp255_, "\n"); + _tmp256_ = writer; + _tmp257_ = pdf_writer_start_object (_tmp256_); + number = _tmp257_; + _tmp258_ = writer; + _tmp259_ = number; + _tmp260_ = g_strdup_printf ("%u 0 obj\n", _tmp259_); + _tmp261_ = _tmp260_; + pdf_writer_write_string (_tmp258_, _tmp261_); + _g_free0 (_tmp261_); + _tmp262_ = writer; + pdf_writer_write_string (_tmp262_, "<<\n"); + _tmp263_ = writer; + pdf_writer_write_string (_tmp263_, "/Type /Page\n"); + _tmp264_ = writer; + _tmp265_ = pages_number; + _tmp266_ = g_strdup_printf ("/Parent %u 0 R\n", _tmp265_); + _tmp267_ = _tmp266_; + pdf_writer_write_string (_tmp264_, _tmp267_); + _g_free0 (_tmp267_); + _tmp268_ = writer; + _tmp269_ = i; + _tmp270_ = number; + _tmp271_ = g_strdup_printf ("/Resources << /XObject << /Im%d %u 0 R >> >>\n", _tmp269_, _tmp270_ + 1); + _tmp272_ = _tmp271_; + pdf_writer_write_string (_tmp268_, _tmp272_); + _g_free0 (_tmp272_); + _tmp273_ = writer; + _tmp274_ = page_width; + _tmp275_ = width_buffer; + _tmp275__length1 = width_buffer_length1; + _tmp276_ = g_ascii_formatd (_tmp275_, _tmp275__length1, "%.2f", _tmp274_); + _tmp277_ = page_height; + _tmp278_ = height_buffer; + _tmp278__length1 = height_buffer_length1; + _tmp279_ = g_ascii_formatd (_tmp278_, _tmp278__length1, "%.2f", _tmp277_); + _tmp280_ = g_strdup_printf ("/MediaBox [ 0 0 %s %s ]\n", _tmp276_, _tmp279_); + _tmp281_ = _tmp280_; + pdf_writer_write_string (_tmp273_, _tmp281_); + _g_free0 (_tmp281_); + _tmp282_ = writer; + _tmp283_ = number; + _tmp284_ = g_strdup_printf ("/Contents %u 0 R\n", _tmp283_ + 2); + _tmp285_ = _tmp284_; + pdf_writer_write_string (_tmp282_, _tmp285_); + _g_free0 (_tmp285_); + _tmp286_ = writer; + pdf_writer_write_string (_tmp286_, ">>\n"); + _tmp287_ = writer; + pdf_writer_write_string (_tmp287_, "endobj\n"); + _tmp288_ = writer; + pdf_writer_write_string (_tmp288_, "\n"); + _tmp289_ = writer; + _tmp290_ = pdf_writer_start_object (_tmp289_); + number = _tmp290_; + _tmp291_ = writer; + _tmp292_ = number; + _tmp293_ = g_strdup_printf ("%u 0 obj\n", _tmp292_); + _tmp294_ = _tmp293_; + pdf_writer_write_string (_tmp291_, _tmp294_); + _g_free0 (_tmp294_); + _tmp295_ = writer; + pdf_writer_write_string (_tmp295_, "<<\n"); + _tmp296_ = writer; + pdf_writer_write_string (_tmp296_, "/Type /XObject\n"); + _tmp297_ = writer; + pdf_writer_write_string (_tmp297_, "/Subtype /Image\n"); + _tmp298_ = writer; + _tmp299_ = width; + _tmp300_ = g_strdup_printf ("/Width %d\n", _tmp299_); + _tmp301_ = _tmp300_; + pdf_writer_write_string (_tmp298_, _tmp301_); + _g_free0 (_tmp301_); + _tmp302_ = writer; + _tmp303_ = height; + _tmp304_ = g_strdup_printf ("/Height %d\n", _tmp303_); + _tmp305_ = _tmp304_; + pdf_writer_write_string (_tmp302_, _tmp305_); + _g_free0 (_tmp305_); + _tmp306_ = writer; + _tmp307_ = color_space; + _tmp308_ = g_strdup_printf ("/ColorSpace /%s\n", _tmp307_); + _tmp309_ = _tmp308_; + pdf_writer_write_string (_tmp306_, _tmp309_); + _g_free0 (_tmp309_); + _tmp310_ = writer; + _tmp311_ = depth; + _tmp312_ = g_strdup_printf ("/BitsPerComponent %d\n", _tmp311_); + _tmp313_ = _tmp312_; + pdf_writer_write_string (_tmp310_, _tmp313_); + _g_free0 (_tmp313_); + _tmp314_ = writer; + _tmp315_ = data; + _tmp315__length1 = data_length1; + _tmp316_ = g_strdup_printf ("/Length %d\n", _tmp315__length1); + _tmp317_ = _tmp316_; + pdf_writer_write_string (_tmp314_, _tmp317_); + _g_free0 (_tmp317_); + _tmp318_ = filter; + if (_tmp318_ != NULL) { + PDFWriter* _tmp319_; + const gchar* _tmp320_; + gchar* _tmp321_ = NULL; + gchar* _tmp322_; + _tmp319_ = writer; + _tmp320_ = filter; + _tmp321_ = g_strdup_printf ("/Filter /%s\n", _tmp320_); + _tmp322_ = _tmp321_; + pdf_writer_write_string (_tmp319_, _tmp322_); + _g_free0 (_tmp322_); } - pdf_writer_write_string (writer, ">>\n"); - pdf_writer_write_string (writer, "stream\n"); - pdf_writer_write (writer, data, data_length1); - pdf_writer_write_string (writer, "\n"); - pdf_writer_write_string (writer, "endstream\n"); - pdf_writer_write_string (writer, "endobj\n"); - _tmp91_ = g_ascii_formatd (width_buffer, width_buffer_length1, "%f", page_width); - _tmp92_ = g_ascii_formatd (height_buffer, height_buffer_length1, "%f", page_height); - _tmp93_ = g_strdup_printf ("q\n%s 0 0 %s 0 0 cm\n/Im%d Do\nQ", _tmp91_, _tmp92_, i); - command = _tmp93_; - pdf_writer_write_string (writer, "\n"); - _tmp94_ = pdf_writer_start_object (writer); - number = _tmp94_; - _tmp95_ = g_strdup_printf ("%u 0 obj\n", number); - _tmp96_ = _tmp95_; - pdf_writer_write_string (writer, _tmp96_); - _g_free0 (_tmp96_); - pdf_writer_write_string (writer, "<<\n"); - _tmp97_ = strlen (command); - _tmp98_ = g_strdup_printf ("/Length %d\n", _tmp97_ + 1); - _tmp99_ = _tmp98_; - pdf_writer_write_string (writer, _tmp99_); - _g_free0 (_tmp99_); - pdf_writer_write_string (writer, ">>\n"); - pdf_writer_write_string (writer, "stream\n"); - pdf_writer_write_string (writer, command); - pdf_writer_write_string (writer, "\n"); - pdf_writer_write_string (writer, "endstream\n"); - pdf_writer_write_string (writer, "endobj\n"); + _tmp323_ = writer; + pdf_writer_write_string (_tmp323_, ">>\n"); + _tmp324_ = writer; + pdf_writer_write_string (_tmp324_, "stream\n"); + _tmp325_ = writer; + _tmp326_ = data; + _tmp326__length1 = data_length1; + pdf_writer_write (_tmp325_, _tmp326_, _tmp326__length1); + _tmp327_ = writer; + pdf_writer_write_string (_tmp327_, "\n"); + _tmp328_ = writer; + pdf_writer_write_string (_tmp328_, "endstream\n"); + _tmp329_ = writer; + pdf_writer_write_string (_tmp329_, "endobj\n"); + _tmp330_ = page_width; + _tmp331_ = width_buffer; + _tmp331__length1 = width_buffer_length1; + _tmp332_ = g_ascii_formatd (_tmp331_, _tmp331__length1, "%f", _tmp330_); + _tmp333_ = page_height; + _tmp334_ = height_buffer; + _tmp334__length1 = height_buffer_length1; + _tmp335_ = g_ascii_formatd (_tmp334_, _tmp334__length1, "%f", _tmp333_); + _tmp336_ = i; + _tmp337_ = g_strdup_printf ("q\n%s 0 0 %s 0 0 cm\n/Im%d Do\nQ", _tmp332_, _tmp335_, _tmp336_); + command = _tmp337_; + _tmp338_ = writer; + pdf_writer_write_string (_tmp338_, "\n"); + _tmp339_ = writer; + _tmp340_ = pdf_writer_start_object (_tmp339_); + number = _tmp340_; + _tmp341_ = writer; + _tmp342_ = number; + _tmp343_ = g_strdup_printf ("%u 0 obj\n", _tmp342_); + _tmp344_ = _tmp343_; + pdf_writer_write_string (_tmp341_, _tmp344_); + _g_free0 (_tmp344_); + _tmp345_ = writer; + pdf_writer_write_string (_tmp345_, "<<\n"); + _tmp346_ = writer; + _tmp347_ = command; + _tmp348_ = strlen (_tmp347_); + _tmp349_ = _tmp348_; + _tmp350_ = g_strdup_printf ("/Length %d\n", _tmp349_ + 1); + _tmp351_ = _tmp350_; + pdf_writer_write_string (_tmp346_, _tmp351_); + _g_free0 (_tmp351_); + _tmp352_ = writer; + pdf_writer_write_string (_tmp352_, ">>\n"); + _tmp353_ = writer; + pdf_writer_write_string (_tmp353_, "stream\n"); + _tmp354_ = writer; + _tmp355_ = command; + pdf_writer_write_string (_tmp354_, _tmp355_); + _tmp356_ = writer; + pdf_writer_write_string (_tmp356_, "\n"); + _tmp357_ = writer; + pdf_writer_write_string (_tmp357_, "endstream\n"); + _tmp358_ = writer; + pdf_writer_write_string (_tmp358_, "endobj\n"); _g_free0 (command); compressed_data = (g_free (compressed_data), NULL); data = (g_free (data), NULL); @@ -1470,116 +2351,180 @@ static void book_save_pdf (Book* self, GFile* file, GError** error) { } } } - pdf_writer_write_string (writer, "\n"); - _tmp100_ = pdf_writer_start_object (writer); - info_number = _tmp100_; - _tmp101_ = g_strdup_printf ("%u 0 obj\n", info_number); - _tmp102_ = _tmp101_; - pdf_writer_write_string (writer, _tmp102_); - _g_free0 (_tmp102_); - pdf_writer_write_string (writer, "<<\n"); - _tmp103_ = g_strdup_printf ("/Creator (Simple Scan %s)\n", VERSION); - _tmp104_ = _tmp103_; - pdf_writer_write_string (writer, _tmp104_); - _g_free0 (_tmp104_); - pdf_writer_write_string (writer, ">>\n"); - pdf_writer_write_string (writer, "endobj\n"); - xref_offset = writer->offset; - pdf_writer_write_string (writer, "xref\n"); - _tmp105_ = g_list_length (writer->object_offsets); - _tmp106_ = g_strdup_printf ("1 %zu\n", (gsize) _tmp105_); - _tmp107_ = _tmp106_; - pdf_writer_write_string (writer, _tmp107_); - _g_free0 (_tmp107_); + _tmp359_ = writer; + pdf_writer_write_string (_tmp359_, "\n"); + _tmp360_ = writer; + _tmp361_ = pdf_writer_start_object (_tmp360_); + info_number = _tmp361_; + _tmp362_ = writer; + _tmp363_ = info_number; + _tmp364_ = g_strdup_printf ("%u 0 obj\n", _tmp363_); + _tmp365_ = _tmp364_; + pdf_writer_write_string (_tmp362_, _tmp365_); + _g_free0 (_tmp365_); + _tmp366_ = writer; + pdf_writer_write_string (_tmp366_, "<<\n"); + _tmp367_ = writer; + _tmp368_ = g_strdup_printf ("/Creator (Simple Scan %s)\n", VERSION); + _tmp369_ = _tmp368_; + pdf_writer_write_string (_tmp367_, _tmp369_); + _g_free0 (_tmp369_); + _tmp370_ = writer; + pdf_writer_write_string (_tmp370_, ">>\n"); + _tmp371_ = writer; + pdf_writer_write_string (_tmp371_, "endobj\n"); + _tmp372_ = writer; + _tmp373_ = _tmp372_->offset; + xref_offset = _tmp373_; + _tmp374_ = writer; + pdf_writer_write_string (_tmp374_, "xref\n"); + _tmp375_ = writer; + _tmp376_ = writer; + _tmp377_ = _tmp376_->object_offsets; + _tmp378_ = g_list_length (_tmp377_); + _tmp379_ = g_strdup_printf ("1 %zu\n", (gsize) _tmp378_); + _tmp380_ = _tmp379_; + pdf_writer_write_string (_tmp375_, _tmp380_); + _g_free0 (_tmp380_); + _tmp381_ = writer; + _tmp382_ = _tmp381_->object_offsets; { GList* offset_collection = NULL; GList* offset_it = NULL; - offset_collection = writer->object_offsets; + offset_collection = _tmp382_; for (offset_it = offset_collection; offset_it != NULL; offset_it = offset_it->next) { guint offset = 0U; offset = GPOINTER_TO_UINT (offset_it->data); { - gchar* _tmp108_ = NULL; - gchar* _tmp109_; - _tmp108_ = g_strdup_printf ("%010zu 00000 n \n", (gsize) offset); - _tmp109_ = _tmp108_; - pdf_writer_write_string (writer, _tmp109_); - _g_free0 (_tmp109_); + PDFWriter* _tmp383_; + guint _tmp384_; + gchar* _tmp385_ = NULL; + gchar* _tmp386_; + _tmp383_ = writer; + _tmp384_ = offset; + _tmp385_ = g_strdup_printf ("%010zu 00000 n \n", (gsize) _tmp384_); + _tmp386_ = _tmp385_; + pdf_writer_write_string (_tmp383_, _tmp386_); + _g_free0 (_tmp386_); } } } - pdf_writer_write_string (writer, "trailer\n"); - pdf_writer_write_string (writer, "<<\n"); - _tmp110_ = g_list_length (writer->object_offsets); - _tmp111_ = g_strdup_printf ("/Size %zu\n", (gsize) _tmp110_); - _tmp112_ = _tmp111_; - pdf_writer_write_string (writer, _tmp112_); - _g_free0 (_tmp112_); - _tmp113_ = g_strdup_printf ("/Info %u 0 R\n", info_number); - _tmp114_ = _tmp113_; - pdf_writer_write_string (writer, _tmp114_); - _g_free0 (_tmp114_); - _tmp115_ = g_strdup_printf ("/Root %u 0 R\n", catalog_number); - _tmp116_ = _tmp115_; - pdf_writer_write_string (writer, _tmp116_); - _g_free0 (_tmp116_); - pdf_writer_write_string (writer, ">>\n"); - pdf_writer_write_string (writer, "startxref\n"); - _tmp117_ = g_strdup_printf ("%zu\n", xref_offset); - _tmp118_ = _tmp117_; - pdf_writer_write_string (writer, _tmp118_); - _g_free0 (_tmp118_); - pdf_writer_write_string (writer, "%%EOF\n"); + _tmp387_ = writer; + pdf_writer_write_string (_tmp387_, "trailer\n"); + _tmp388_ = writer; + pdf_writer_write_string (_tmp388_, "<<\n"); + _tmp389_ = writer; + _tmp390_ = writer; + _tmp391_ = _tmp390_->object_offsets; + _tmp392_ = g_list_length (_tmp391_); + _tmp393_ = g_strdup_printf ("/Size %zu\n", (gsize) _tmp392_); + _tmp394_ = _tmp393_; + pdf_writer_write_string (_tmp389_, _tmp394_); + _g_free0 (_tmp394_); + _tmp395_ = writer; + _tmp396_ = info_number; + _tmp397_ = g_strdup_printf ("/Info %u 0 R\n", _tmp396_); + _tmp398_ = _tmp397_; + pdf_writer_write_string (_tmp395_, _tmp398_); + _g_free0 (_tmp398_); + _tmp399_ = writer; + _tmp400_ = catalog_number; + _tmp401_ = g_strdup_printf ("/Root %u 0 R\n", _tmp400_); + _tmp402_ = _tmp401_; + pdf_writer_write_string (_tmp399_, _tmp402_); + _g_free0 (_tmp402_); + _tmp403_ = writer; + pdf_writer_write_string (_tmp403_, ">>\n"); + _tmp404_ = writer; + pdf_writer_write_string (_tmp404_, "startxref\n"); + _tmp405_ = writer; + _tmp406_ = xref_offset; + _tmp407_ = g_strdup_printf ("%zu\n", _tmp406_); + _tmp408_ = _tmp407_; + pdf_writer_write_string (_tmp405_, _tmp408_); + _g_free0 (_tmp408_); + _tmp409_ = writer; + pdf_writer_write_string (_tmp409_, "%%EOF\n"); _pdf_writer_unref0 (writer); _g_object_unref0 (stream); } void book_save (Book* self, const gchar* type, GFile* file, GError** error) { - gint _tmp0_; + GCompareFunc _tmp0_; + const gchar* _tmp1_; + gint _tmp2_ = 0; GError * _inner_error_ = NULL; g_return_if_fail (self != NULL); g_return_if_fail (type != NULL); g_return_if_fail (file != NULL); - _tmp0_ = g_strcmp0 (type, "jpeg"); - if (_tmp0_ == 0) { - book_save_multi_file (self, "jpeg", file, &_inner_error_); + _tmp0_ = g_strcmp0; + _tmp1_ = type; + _tmp2_ = _tmp0_ (_tmp1_, "jpeg"); + if (_tmp2_ == 0) { + GFile* _tmp3_; + _tmp3_ = file; + book_save_multi_file (self, "jpeg", _tmp3_, &_inner_error_); if (_inner_error_ != NULL) { g_propagate_error (error, _inner_error_); return; } } else { - gint _tmp1_; - _tmp1_ = g_strcmp0 (type, "png"); - if (_tmp1_ == 0) { - book_save_multi_file (self, "png", file, &_inner_error_); + GCompareFunc _tmp4_; + const gchar* _tmp5_; + gint _tmp6_ = 0; + _tmp4_ = g_strcmp0; + _tmp5_ = type; + _tmp6_ = _tmp4_ (_tmp5_, "png"); + if (_tmp6_ == 0) { + GFile* _tmp7_; + _tmp7_ = file; + book_save_multi_file (self, "png", _tmp7_, &_inner_error_); if (_inner_error_ != NULL) { g_propagate_error (error, _inner_error_); return; } } else { - gint _tmp2_; - _tmp2_ = g_strcmp0 (type, "tiff"); - if (_tmp2_ == 0) { - book_save_multi_file (self, "tiff", file, &_inner_error_); + GCompareFunc _tmp8_; + const gchar* _tmp9_; + gint _tmp10_ = 0; + _tmp8_ = g_strcmp0; + _tmp9_ = type; + _tmp10_ = _tmp8_ (_tmp9_, "tiff"); + if (_tmp10_ == 0) { + GFile* _tmp11_; + _tmp11_ = file; + book_save_multi_file (self, "tiff", _tmp11_, &_inner_error_); if (_inner_error_ != NULL) { g_propagate_error (error, _inner_error_); return; } } else { - gint _tmp3_; - _tmp3_ = g_strcmp0 (type, "ps"); - if (_tmp3_ == 0) { - book_save_ps (self, file, &_inner_error_); + GCompareFunc _tmp12_; + const gchar* _tmp13_; + gint _tmp14_ = 0; + _tmp12_ = g_strcmp0; + _tmp13_ = type; + _tmp14_ = _tmp12_ (_tmp13_, "ps"); + if (_tmp14_ == 0) { + GFile* _tmp15_; + _tmp15_ = file; + book_save_ps (self, _tmp15_, &_inner_error_); if (_inner_error_ != NULL) { g_propagate_error (error, _inner_error_); return; } } else { - gint _tmp4_; - _tmp4_ = g_strcmp0 (type, "pdf"); - if (_tmp4_ == 0) { - book_save_pdf (self, file, &_inner_error_); + GCompareFunc _tmp16_; + const gchar* _tmp17_; + gint _tmp18_ = 0; + _tmp16_ = g_strcmp0; + _tmp17_ = type; + _tmp18_ = _tmp16_ (_tmp17_, "pdf"); + if (_tmp18_ == 0) { + GFile* _tmp19_; + _tmp19_ = file; + book_save_pdf (self, _tmp19_, &_inner_error_); if (_inner_error_ != NULL) { g_propagate_error (error, _inner_error_); return; @@ -1593,11 +2538,19 @@ void book_save (Book* self, const gchar* type, GFile* file, GError** error) { void book_set_needs_saving (Book* self, gboolean needs_saving) { + gboolean _tmp0_; gboolean needed_saving; + gboolean _tmp1_; + gboolean _tmp2_; + gboolean _tmp3_; g_return_if_fail (self != NULL); - needed_saving = self->priv->needs_saving; - self->priv->needs_saving = needs_saving; - if (needed_saving != needs_saving) { + _tmp0_ = self->priv->needs_saving; + needed_saving = _tmp0_; + _tmp1_ = needs_saving; + self->priv->needs_saving = _tmp1_; + _tmp2_ = needed_saving; + _tmp3_ = needs_saving; + if (_tmp2_ != _tmp3_) { g_signal_emit_by_name (self, "needs-saving-changed"); } } @@ -1605,8 +2558,10 @@ void book_set_needs_saving (Book* self, gboolean needs_saving) { gboolean book_get_needs_saving (Book* self) { gboolean result = FALSE; + gboolean _tmp0_; g_return_val_if_fail (self != NULL, FALSE); - result = self->priv->needs_saving; + _tmp0_ = self->priv->needs_saving; + result = _tmp0_; return result; } @@ -1806,11 +2761,13 @@ static gpointer _g_object_ref0 (gpointer self) { PDFWriter* pdf_writer_construct (GType object_type, GFileOutputStream* stream) { PDFWriter* self = NULL; GFileOutputStream* _tmp0_; + GFileOutputStream* _tmp1_; g_return_val_if_fail (stream != NULL, NULL); self = (PDFWriter*) g_type_create_instance (object_type); - _tmp0_ = _g_object_ref0 (stream); + _tmp0_ = stream; + _tmp1_ = _g_object_ref0 (_tmp0_); _g_object_unref0 (self->priv->stream); - self->priv->stream = _tmp0_; + self->priv->stream = _tmp1_; return self; } @@ -1821,10 +2778,19 @@ PDFWriter* pdf_writer_new (GFileOutputStream* stream) { void pdf_writer_write (PDFWriter* self, guint8* data, int data_length1) { + gsize _tmp4_; + guint8* _tmp5_; + gint _tmp5__length1; GError * _inner_error_ = NULL; g_return_if_fail (self != NULL); { - g_output_stream_write_all ((GOutputStream*) self->priv->stream, data, (gsize) data_length1, NULL, NULL, &_inner_error_); + GFileOutputStream* _tmp0_; + guint8* _tmp1_; + gint _tmp1__length1; + _tmp0_ = self->priv->stream; + _tmp1_ = data; + _tmp1__length1 = data_length1; + g_output_stream_write_all ((GOutputStream*) _tmp0_, _tmp1_, (gsize) _tmp1__length1, NULL, NULL, &_inner_error_); if (_inner_error_ != NULL) { goto __catch0_g_error; } @@ -1833,9 +2799,13 @@ void pdf_writer_write (PDFWriter* self, guint8* data, int data_length1) { __catch0_g_error: { GError* e = NULL; + GError* _tmp2_; + const gchar* _tmp3_; e = _inner_error_; _inner_error_ = NULL; - g_warning ("book.vala:529: Error writing PDF: %s", e->message); + _tmp2_ = e; + _tmp3_ = _tmp2_->message; + g_warning ("book.vala:529: Error writing PDF: %s", _tmp3_); _g_error_free0 (e); } __finally0: @@ -1844,59 +2814,80 @@ void pdf_writer_write (PDFWriter* self, guint8* data, int data_length1) { g_clear_error (&_inner_error_); return; } - self->offset = self->offset + data_length1; + _tmp4_ = self->offset; + _tmp5_ = data; + _tmp5__length1 = data_length1; + self->offset = _tmp4_ + _tmp5__length1; } static gchar* string_to_utf8 (const gchar* self, int* result_length1) { gchar* result = NULL; gint _tmp0_; - gchar* _tmp1_ = NULL; + gint _tmp1_; + gchar* _tmp2_ = NULL; gchar* _result_; gint _result__length1; gint __result__size_; - gint _tmp2_; - gchar* _tmp3_; + gint _tmp3_; + gchar* _tmp4_; + gint _tmp4__length1; + gint _tmp5_; + gint _tmp6_; + gchar* _tmp7_; + gint _tmp7__length1; g_return_val_if_fail (self != NULL, NULL); _tmp0_ = strlen (self); - _tmp1_ = g_new0 (gchar, _tmp0_ + 1); - _result_ = _tmp1_; - _result__length1 = _tmp0_ + 1; + _tmp1_ = _tmp0_; + _tmp2_ = g_new0 (gchar, _tmp1_ + 1); + _result_ = _tmp2_; + _result__length1 = _tmp1_ + 1; __result__size_ = _result__length1; - _result__length1--; - _tmp2_ = strlen (self); - memcpy (_result_, self, (gsize) _tmp2_); - _tmp3_ = _result_; + _tmp3_ = _result__length1; + _result__length1 = _tmp3_ - 1; + _tmp4_ = _result_; + _tmp4__length1 = _result__length1; + _tmp5_ = strlen (self); + _tmp6_ = _tmp5_; + memcpy (_tmp4_, self, (gsize) _tmp6_); + _tmp7_ = _result_; + _tmp7__length1 = _result__length1; if (result_length1) { - *result_length1 = _result__length1; + *result_length1 = _tmp7__length1; } - result = _tmp3_; + result = _tmp7_; return result; } void pdf_writer_write_string (PDFWriter* self, const gchar* text) { - gint _tmp0_; - gchar* _tmp1_ = NULL; - guint8* _tmp2_; - gint _tmp2__length1; + const gchar* _tmp0_; + gint _tmp1_ = 0; + gchar* _tmp2_ = NULL; + guint8* _tmp3_; + gint _tmp3__length1; g_return_if_fail (self != NULL); g_return_if_fail (text != NULL); - _tmp1_ = string_to_utf8 (text, &_tmp0_); - _tmp2_ = (guint8*) _tmp1_; - _tmp2__length1 = _tmp0_; - pdf_writer_write (self, _tmp2_, _tmp0_); - _tmp2_ = (g_free (_tmp2_), NULL); + _tmp0_ = text; + _tmp2_ = string_to_utf8 (_tmp0_, &_tmp1_); + _tmp3_ = (guint8*) _tmp2_; + _tmp3__length1 = _tmp1_; + pdf_writer_write (self, _tmp3_, _tmp1_); + _tmp3_ = (g_free (_tmp3_), NULL); } guint pdf_writer_start_object (PDFWriter* self) { guint result = 0U; - guint _tmp0_; + gsize _tmp0_; + GList* _tmp1_; + guint _tmp2_ = 0U; g_return_val_if_fail (self != NULL, 0U); - self->object_offsets = g_list_append (self->object_offsets, GUINT_TO_POINTER ((guint) self->offset)); - _tmp0_ = g_list_length (self->object_offsets); - result = _tmp0_; + _tmp0_ = self->offset; + self->object_offsets = g_list_append (self->object_offsets, GUINT_TO_POINTER ((guint) _tmp0_)); + _tmp1_ = self->object_offsets; + _tmp2_ = g_list_length (_tmp1_); + result = _tmp2_; return result; } @@ -2075,15 +3066,17 @@ static cairo_status_t _ps_writer_write_cairo_data_cairo_write_func_t (gpointer s PsWriter* ps_writer_construct (GType object_type, GFileOutputStream* stream) { PsWriter* self = NULL; GFileOutputStream* _tmp0_; - cairo_surface_t* _tmp1_ = NULL; + GFileOutputStream* _tmp1_; + cairo_surface_t* _tmp2_; g_return_val_if_fail (stream != NULL, NULL); self = (PsWriter*) g_type_create_instance (object_type); - _tmp0_ = _g_object_ref0 (stream); + _tmp0_ = stream; + _tmp1_ = _g_object_ref0 (_tmp0_); _g_object_unref0 (self->stream); - self->stream = _tmp0_; - _tmp1_ = cairo_ps_surface_create_for_stream (_ps_writer_write_cairo_data_cairo_write_func_t, self, (gdouble) 0, (gdouble) 0); + self->stream = _tmp1_; + _tmp2_ = cairo_ps_surface_create_for_stream (_ps_writer_write_cairo_data_cairo_write_func_t, self, (gdouble) 0, (gdouble) 0); _cairo_surface_destroy0 (self->surface); - self->surface = _tmp1_; + self->surface = _tmp2_; return self; } @@ -2098,7 +3091,13 @@ static cairo_status_t ps_writer_write_cairo_data (PsWriter* self, guint8* data, GError * _inner_error_ = NULL; g_return_val_if_fail (self != NULL, 0); { - g_output_stream_write_all ((GOutputStream*) self->stream, data, (gsize) data_length1, NULL, NULL, &_inner_error_); + GFileOutputStream* _tmp0_; + guint8* _tmp1_; + gint _tmp1__length1; + _tmp0_ = self->stream; + _tmp1_ = data; + _tmp1__length1 = data_length1; + g_output_stream_write_all ((GOutputStream*) _tmp0_, _tmp1_, (gsize) _tmp1__length1, NULL, NULL, &_inner_error_); if (_inner_error_ != NULL) { goto __catch1_g_error; } @@ -2107,9 +3106,13 @@ static cairo_status_t ps_writer_write_cairo_data (PsWriter* self, guint8* data, __catch1_g_error: { GError* e = NULL; + GError* _tmp2_; + const gchar* _tmp3_; e = _inner_error_; _inner_error_ = NULL; - g_warning ("book.vala:565: Error writing data: %s", e->message); + _tmp2_ = e; + _tmp3_ = _tmp2_->message; + g_warning ("book.vala:565: Error writing data: %s", _tmp3_); result = CAIRO_STATUS_WRITE_ERROR; _g_error_free0 (e); return result; |