Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/impress/r_draw.c
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2006-07-10 21:04:30 (GMT)
committer Nickolay V. Shmyrev <nshmyrev@src.gnome.org>2006-07-10 21:04:30 (GMT)
commitf00b898dd13b85e510188714f6b9d9a349d23ed2 (patch)
tree03e0fbeee50a46690b969c5de567fffa88cf7056 /impress/r_draw.c
parentd626744c21e61733228f6dfc6b29dec1f38a92e4 (diff)
New backend to support impress slides. Fixes bug #30867.
2006-07-11 Bastien Nocera <hadess@hadess.net> * Makefile.am: * backend/Makefile.am: * backend/ev-document-factory.c: (ev_document_factory_add_filters): * backend/ev-document-factory.h: * configure.ac: * impress/.cvsignore: * impress/Makefile.am: * impress/common.h: * impress/document.c: (_imp_load_xml), (imp_open), (imp_nr_pages), (imp_get_page), (imp_next_page), (imp_prev_page), (imp_get_page_no), (imp_get_page_name), (imp_get_xml), (imp_close): * impress/f_oasis.c: (render_object), (render_page), (get_geometry), (_imp_oasis_load): * impress/f_oo13.c: (render_object), (render_page), (get_geometry), (_imp_oo13_load): * impress/iksemel.c: (iks_malloc), (iks_free), (iks_set_mem_funcs), (iks_strdup), (iks_strcat), (iks_strcmp), (iks_strcasecmp), (iks_strncmp), (iks_strncasecmp), (iks_strlen), (iks_escape), (iks_unescape), (find_space), (iks_stack_new), (iks_stack_alloc), (iks_stack_strdup), (iks_stack_strcat), (iks_stack_stat), (iks_stack_delete), (iks_sax_new), (iks_sax_extend), (iks_parser_stack), (iks_user_data), (iks_nr_bytes), (iks_nr_lines), (stack_init), (stack_expand), (sax_core), (iks_parse), (iks_parser_reset), (iks_parser_delete), (iks_new), (iks_new_within), (iks_insert), (iks_insert_cdata), (iks_insert_attrib), (iks_insert_node), (iks_hide), (iks_delete), (iks_next), (iks_next_tag), (iks_prev), (iks_prev_tag), (iks_parent), (iks_root), (iks_child), (iks_first_tag), (iks_attrib), (iks_find), (iks_find_cdata), (iks_find_attrib), (iks_find_with_attrib), (iks_stack), (iks_type), (iks_name), (iks_cdata), (iks_cdata_size), (iks_has_children), (iks_has_attribs), (escape_size), (my_strcat), (escape), (iks_string), (iks_copy_within), (iks_copy), (tagHook), (cdataHook), (deleteHook), (iks_dom_new), (iks_set_size_hint), (iks_tree), (iks_load), (iks_save): * impress/iksemel.h: * impress/imposter.h: * impress/impress-document.c: (G_DEFINE_TYPE_WITH_CODE), (imp_render_draw_bezier_real), (imp_render_get_size), (imp_render_set_fg_color), (imp_render_draw_line), (imp_render_draw_rect), (imp_render_draw_polygon), (imp_render_draw_arc), (imp_render_draw_bezier), (imp_render_open_image), (imp_render_get_image_size), (imp_render_scale_image), (imp_render_draw_image), (imp_render_close_image), (imp_render_markup), (imp_render_get_text_size), (imp_render_draw_text), (impress_document_load), (impress_document_save), (impress_document_get_n_pages), (impress_document_get_page_size), (imp_render_get_from_drawable), (impress_document_render_pixbuf), (impress_document_finalize), (impress_document_class_init), (impress_document_can_get_text), (impress_document_get_info), (impress_document_document_iface_init), (impress_document_thumbnails_get_thumbnail), (impress_document_thumbnails_get_dimensions), (impress_document_document_thumbnails_iface_init), (impress_document_init): * impress/impress-document.h: * impress/internal.h: * impress/r_back.c: (_imp_fill_back): * impress/r_draw.c: (_imp_draw_rect), (_imp_draw_line_end), (_imp_draw_image), (_imp_tile_image): * impress/r_geometry.c: (r_parse_color), (r_get_color), (fg_color), (r_get_x), (r_get_y), (r_get_angle), (r_get_viewbox), (r_polygon), (r_polyline): * impress/r_gradient.c: (poly_rotate), (r_draw_gradient_simple), (r_draw_gradient_complex), (r_draw_gradient): * impress/r_style.c: (get_style), (r_get_style), (get_style_x), (r_get_bullet): * impress/r_text.c: (add_line), (add_span), (calc_sizes), (calc_pos), (_imp_draw_layout), (text_span), (text_p), (text_list), (r_text): * impress/render.c: (imp_create_context), (imp_context_set_page), (imp_context_set_step), (imp_render), (imp_delete_context): * impress/render.h: * impress/zip.c: (zip_error), (find_cd), (get_long), (get_word), (list_files), (zip_open), (zip_close), (find_file), (seek_file), (zip_load_xml), (zip_get_size), (zip_load): * impress/zip.h: * shell/ev-utils.c: New backend to support impress slides. Fixes bug #30867.
Diffstat (limited to 'impress/r_draw.c')
-rw-r--r--impress/r_draw.c119
1 files changed, 119 insertions, 0 deletions
diff --git a/impress/r_draw.c b/impress/r_draw.c
new file mode 100644
index 0000000..746afbd
--- /dev/null
+++ b/impress/r_draw.c
@@ -0,0 +1,119 @@
+/* imposter (OO.org Impress viewer)
+** Copyright (C) 2003-2005 Gurer Ozen
+** This code is free software; you can redistribute it and/or
+** modify it under the terms of GNU General Public License.
+*/
+
+#include "common.h"
+#include "internal.h"
+#include <math.h>
+
+void
+_imp_draw_rect(ImpRenderCtx *ctx, void *drw_data, int fill, int x, int y, int w, int h, int round)
+{
+ int a;
+
+ if (0 == round) {
+ ctx->drw->draw_rect(drw_data, fill, x, y, w, h);
+ return;
+ }
+
+ ctx->drw->draw_arc(drw_data, fill,
+ x, y, round, round, 90, 90);
+ ctx->drw->draw_arc(drw_data, fill,
+ x + w - round, y, round, round, 0, 90);
+ ctx->drw->draw_arc(drw_data, fill,
+ x + w - round, y + h - round, round, round, 270, 90);
+ ctx->drw->draw_arc(drw_data, fill,
+ x, y + h - round, round, round, 180, 90);
+
+ a = round / 2;
+ if (fill) {
+ ctx->drw->draw_rect(drw_data, 1, x + a, y, w - a - a, h);
+ ctx->drw->draw_rect(drw_data, 1, x, y + a, w, h - a - a);
+ return;
+ }
+ ctx->drw->draw_line(drw_data, x + a, y, x + w - a, y);
+ ctx->drw->draw_line(drw_data, x + a, y + h, x + w - a, y + h);
+ ctx->drw->draw_line(drw_data, x, y + a, x, y + h - a);
+ ctx->drw->draw_line(drw_data, x + w, y + a, x + w, y + h - a);
+}
+
+void
+_imp_draw_line_end(ImpRenderCtx *ctx, void *drw_data, int type, int size, int x, int y, int x2, int y2)
+{
+ ImpPoint pts[4];
+ double ia, a;
+
+ // FIXME: different types and sizes
+
+ pts[0].x = x2;
+ pts[0].y = y2;
+
+ ia = 20 * 3.14 * 2 / 360;
+
+ if (x2-x == 0) {
+ if (y < y2) a = 3.14 + (3.14 / 2); else a = (3.14 / 2);
+ } else if (y2-y == 0) {
+ if (x < x2) a = 3.14; else a = 0;
+ } else
+ a = atan ((y2-y) / (x2-x)) - 3.14;
+
+ pts[1].x = x2 + 0.3 * ctx->fact_x * cos (a - ia);
+ pts[1].y = y2 + 0.3 * ctx->fact_y * sin (a - ia);
+
+ pts[2].x = x2 + 0.3 * ctx->fact_x * cos (a + ia);
+ pts[2].y = y2 + 0.3 * ctx->fact_y * sin (a + ia);
+
+ ctx->drw->draw_polygon(drw_data, 1, pts, 3);
+}
+
+void
+_imp_draw_image(ImpRenderCtx *ctx, void *drw_data, const char *name, int x, int y, int w, int h)
+{
+ void *img1, *img2;
+ char *pix;
+ size_t len;
+
+ len = zip_get_size(ctx->page->doc->zfile, name);
+ pix = malloc(len);
+ if (!pix) return;
+ zip_load(ctx->page->doc->zfile, name, pix);
+
+ img1 = ctx->drw->open_image(drw_data, pix, len);
+ free(pix);
+ if (!img1) return;
+ img2 = ctx->drw->scale_image(drw_data, img1, w, h);
+ if (img2) {
+ ctx->drw->draw_image(drw_data, img2, x, y, w, h);
+ ctx->drw->close_image(drw_data, img2);
+ }
+ ctx->drw->close_image(drw_data, img1);
+}
+
+void
+_imp_tile_image(ImpRenderCtx *ctx, void *drw_data, const char *name, int x, int y, int w, int h)
+{
+ void *img1;
+ char *pix;
+ size_t len;
+ int gx, gy, gw, gh;
+
+ len = zip_get_size(ctx->page->doc->zfile, name);
+ pix = malloc(len);
+ if (!pix) return;
+ zip_load(ctx->page->doc->zfile, name, pix);
+
+ img1 = ctx->drw->open_image(drw_data, pix, len);
+ free(pix);
+ if (!img1) return;
+
+ ctx->drw->get_image_size(drw_data, img1, &gw, &gh);
+ for (gx = x; gx < w; gx += gw) {
+ for (gy = y; gy < h; gy += gh) {
+ ctx->drw->draw_image(drw_data, img1, gx, gy, gw, gh);
+ }
+ }
+
+ ctx->drw->close_image(drw_data, img1);
+}