[dia] Support CairoScript export when available



commit d34d9e05cdd5a396f17326774ba1af44f6b9db8f
Author: Hans Breuer <hans breuer org>
Date:   Sun Jun 28 17:52:37 2009 +0200

    Support CairoScript export when available

 plug-ins/cairo/diacairo.c |   36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)
---
diff --git a/plug-ins/cairo/diacairo.c b/plug-ins/cairo/diacairo.c
index 2075a58..2a2e042 100644
--- a/plug-ins/cairo/diacairo.c
+++ b/plug-ins/cairo/diacairo.c
@@ -62,6 +62,9 @@
    /* avoid namespace collisions */
 #  define Rectangle RectangleWin32
 #  endif
+#  ifdef CAIRO_HAS_SCRIPT_SURFACE
+#  include <cairo-script.h>
+#  endif
 #endif
 
 #ifdef HAVE_PANGOCAIRO_H
@@ -88,7 +91,8 @@ typedef enum OutputKind
   OUTPUT_WMF,
   OUTPUT_EMF,
   OUTPUT_CLIPBOARD,
-  OUTPUT_SVG
+  OUTPUT_SVG,
+  OUTPUT_CAIRO_SCRIPT
 } OutputKind;
 
 #if defined CAIRO_HAS_WIN32_SURFACE && CAIRO_VERSION > 10510
@@ -195,6 +199,18 @@ export_data(DiagramData *data, const gchar *filename,
 						(int)width, (int)height);
     break;
 #endif
+#ifdef CAIRO_HAS_SCRIPT_SURFACE
+  case OUTPUT_CAIRO_SCRIPT :
+    /* quite arbitrary, but consistent with ../pixbuf ;-) */
+    renderer->scale = 20.0 * data->paper.scaling; 
+    width  = (data->extents.right - data->extents.left) * renderer->scale;
+    height = (data->extents.bottom - data->extents.top) * renderer->scale;
+    DIAG_NOTE(g_message ("CairoScript Surface %dx%d\n", (int)width, (int)height));
+    renderer->surface = cairo_script_surface_create(filename_crt,
+						    width, height);
+    cairo_script_surface_set_mode(renderer->surface, CAIRO_SCRIPT_MODE_ASCII);
+    break;
+#endif
   /* finally cairo can render to MetaFiles */
 #if DIA_CAIRO_CAN_EMF
   case OUTPUT_EMF :
@@ -361,6 +377,18 @@ static DiaExportFilter svg_export_filter = {
 };
 #endif
 
+#ifdef CAIRO_HAS_SCRIPT_SURFACE
+static const gchar *cs_extensions[] = { "cs", NULL };
+static DiaExportFilter cs_export_filter = {
+    N_("CairoScript"),
+    cs_extensions,
+    export_data,
+    (void*)OUTPUT_CAIRO_SCRIPT,
+    "cairo-script",
+    FILTER_DONT_GUESS /* don't use this if not asked explicit */
+};
+#endif
+
 static const gchar *png_extensions[] = { "png", NULL };
 static DiaExportFilter png_export_filter = {
     N_("Cairo PNG"),
@@ -449,6 +477,9 @@ _plugin_unload (PluginInfo *info)
 #ifdef CAIRO_HAS_SVG_SURFACE
   filter_unregister_export(&svg_export_filter);
 #endif
+#ifdef CAIRO_HAS_SCRIPT_SURFACE
+  filter_unregister_export(&cs_export_filter);
+#endif
 #if defined CAIRO_HAS_PNG_SURFACE || defined CAIRO_HAS_PNG_FUNCTIONS
   filter_unregister_export(&png_export_filter);
   filter_unregister_export(&pnga_export_filter);
@@ -485,6 +516,9 @@ dia_plugin_init(PluginInfo *info)
 #ifdef CAIRO_HAS_SVG_SURFACE
   filter_register_export(&svg_export_filter);
 #endif
+#ifdef CAIRO_HAS_SCRIPT_SURFACE
+  filter_register_export(&cs_export_filter);
+#endif
 #if defined CAIRO_HAS_PNG_SURFACE || defined CAIRO_HAS_PNG_FUNCTIONS
   filter_register_export(&png_export_filter);
   filter_register_export(&pnga_export_filter);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]