]> saetta.ns0.it Git - reptool/libreptool/commitdiff
Added attribute "rotation".
authorAndrea Zagli <azagli@libero.it>
Sun, 6 May 2007 08:34:54 +0000 (08:34 +0000)
committerAndrea Zagli <azagli@libero.it>
Sun, 6 May 2007 08:34:54 +0000 (08:34 +0000)
Some bugfixes on png and svg output.

git-svn-id: svn+ssh://saetta.homelinux.org/svn/libreptool/trunk@16 3191ed1d-3fce-41bb-ab4a-0cebc0943b59

14 files changed:
ChangeLog
TODO [new file with mode: 0644]
data/reptool.dtd
data/reptool_report.dtd
src/rptcommon.c
src/rptcommon.h
src/rptobjectimage.c
src/rptobjectline.c
src/rptobjectrect.c
src/rptobjecttext.c
src/rptprint.c
src/rptreport.c
tests/test_report.rpt
tests/test_rptprint.c

index 9ba911ba22267b87072de5eeabfa832c4b6a784b..1c5817e3e96c547a335af9bd6c094302b49f9602 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2007-05-06 Andrea Zagli <azagli@inwind.it>
+
+       * src/rptobjecttext.c:
+       * src/rptobjectline.c:
+       * src/rptobjectimage.c:
+       * src/rptobjectrect.c: added attribute "rotation"
+
+2007-05-05 Andrea Zagli <azagli@inwind.it>
+
+       * src/rptprint.c: some bugfixes for png and svg output
+       * src/rptcommon.h:
+       * src/rptcommon.c: added struct RptRotation;
+       managed RptRotation with rpt_common_get_rotation() and
+       rpt_common_set_rotation()
+       * src/rptreport.h:
+       * src/rptreport.c: some bugfixes
+
 2007-05-01 Andrea Zagli <azagli@inwind.it>
 
        * src/lexycal.fl:
        * src/parser.tab.h:
        * src/parser.tab.c:
        * src/rptreport.c: added parser for text's attribute "source"
-       * src/rptreport.c: added spcial value @Pages for text's attribute "source"
+       * src/rptreport.c: added special value @Pages for text's attribute
+       "source"
 
 2007-04-22 Andrea Zagli <azagli@inwind.it>
 
        * src/rptcommon.h:
        * src/rptcommon.c: changed rpt_common_convert_to_str_color()'s name in
-       rpt_common_rptcolor_to_string()
-       added function rpt_common_styke_to_array()
+       rpt_common_rptcolor_to_string(); added function rpt_common_styke_to_array()
        * src/rptcommon.h:
        * src/rptcommon.c:
        * src/rptprint.c:
@@ -34,8 +51,7 @@
        * src/rptobjtext.c: added text's attributes padding*
        * src/rptprint.c: managed text's attributes padding*
        * src/rptreport.c: static text in text's source attribute must be enclosed
-       into "" (xml entity &quot;);
-       added page's attributes margin*
+       into "" (xml entity &quot;); added page's attributes margin*
 
 2007-04-13 Andrea Zagli <azagli@inwind.it>
 
 2007-04-04 Andrea Zagli <azagli@inwind.it>
 
        * src/rptreport.h:
-       * src/rptreport.c: added rpt_report_set_database(), rpt_report_set_section_height(),
-       rpt_report_set_page_size()
+       * src/rptreport.c: added rpt_report_set_database(),
+       rpt_report_set_section_height(), rpt_report_set_page_size()
        * src/rptreport.c: changed rpt_report_object_is_in_section()'s prototype;
        added special source's text objects values @Date and @Time
 
 2007-04-02 Andrea Zagli <azagli@inwind.it>
 
        * src/rptreport.h:
-       * src/rptreport.c: added rpt_report_new(), rpt_report_add_object_to_section(),
-       rpt_report_remove_object() and rpt_report_get_object_from_name()
+       * src/rptreport.c: added rpt_report_new(),
+       rpt_report_add_object_to_section(), rpt_report_remove_object() and
+       rpt_report_get_object_from_name()
 
 2007-04-01 Andrea Zagli <azagli@inwind.it>
 
        * src/rptcommon.h: moved some functions from rpt_print to rpt_common
        * src/rptobjtext.c:
        * src/rptobjtext.h: extended RptObjText (border, font and align attributes)
-       * src/rptobjtext.c: RptObjText's source attribute now read values from db (if
-       there's a connection)
+       * src/rptobjtext.c: RptObjText's source attribute now read values from db,
+       if      there's a connection
diff --git a/TODO b/TODO
new file mode 100644 (file)
index 0000000..842bfa7
--- /dev/null
+++ b/TODO
@@ -0,0 +1,11 @@
+- visibile
+- nascondi duplicati
+- espandibile
+- riducibile
+- ombra
+- interruzione di pagina (solo nel corpo???)
+- stampa sezione unita
+- attributi template
+- attributi globali
+- watermark
+
index 9039c2897048b419d9cf4a6f43150019e04a2391..013e5877cfcad69a603ce8968e566803b532aa50 100644 (file)
   height   CDATA #REQUIRED"
 >
 
+<!ENTITY % object_rotation_attrs
+ "rotation   CDATA #IMPLIED"
+>
+
 <!ENTITY % object_data_attrs
   "source   CDATA #IMPLIED"
 >
@@ -57,6 +61,7 @@
 <!ATTLIST text
   %object_commons_attrs;
   %object_size_attrs;
+  %object_rotation_attrs;
   %object_border_attrs;
   %object_font_attrs;
   %object_text_align_attrs;
@@ -72,6 +77,7 @@
 <!ATTLIST line
   %object_commons_attrs;
   %object_size_attrs;
+  %object_rotation_attrs;
   %object_stroke_attrs;
 >
 
@@ -79,6 +85,7 @@
 <!ATTLIST rect
   %object_commons_attrs;
   %object_size_attrs;
+  %object_rotation_attrs;
   %object_stroke_attrs;
   fill-color   CDATA #IMPLIED
 >
@@ -87,6 +94,7 @@
 <!ATTLIST ellipse
   %object_commons_attrs;
   %object_size_attrs;
+  %object_rotation_attrs;
   %object_stroke_attrs;
   fill-color   CDATA #IMPLIED
 >
 <!ATTLIST image
   %object_commons_attrs;
   %object_size_attrs;
+  %object_rotation_attrs;
   %object_border_attrs;
   source   CDATA #REQUIRED
   adapt    (to-box | to-image | none) #IMPLIED
index 38e722c477c553ca6e1c754abcd73732d2a82467..04860f5359e20dad17e6b2078f751d84215ef8e6 100644 (file)
    height   CDATA #REQUIRED"
 >
 
+<!ENTITY % object_rotation_attrs
+ "rotation   CDATA #IMPLIED"
+>
+
 <!ENTITY % object_border_attrs
  "border-top-width      CDATA #IMPLIED
   border-right-width    CDATA #IMPLIED
@@ -52,6 +56,7 @@
 <!ATTLIST text
   %object_position_attrs;
   %object_size_attrs;
+  %object_rotation_attrs;
   %object_border_attrs;
   %object_font_attrs;
   %object_text_align_attrs;
@@ -66,6 +71,7 @@
 <!ATTLIST line
   %object_poisition_attrs;
   %object_size_attrs;
+  %object_rotation_attrs;
   %object_stroke_attrs;
 >
 
@@ -73,6 +79,7 @@
 <!ATTLIST rect
   %object_poisition_attrs;
   %object_size_attrs;
+  %object_rotation_attrs;
   %object_stroke_attrs;
   fill-color   CDATA #IMPLIED
 >
@@ -81,6 +88,7 @@
 <!ATTLIST ellipse
   %object_poisition_attrs;
   %object_size_attrs;
+  %object_rotation_attrs;
   %object_stroke_attrs;
   fill-color   CDATA #IMPLIED
 >
@@ -89,6 +97,7 @@
 <!ATTLIST image
   %object_position_attrs;
   %object_size_attrs;
+  %object_rotation_attrs;
   %object_border_attrs;
   source   CDATA #REQUIRED
   adapt    (to-box | to-image | none) #IMPLIED
index ac9b378bf07994efa7498c543c1224643131af6a..34e9eaf4bdeda4c72c396646fae9d03314fd1f82 100644 (file)
@@ -106,6 +106,42 @@ rpt_common_set_size (xmlNode *xnode, const RptSize *size)
                }
 }
 
+/**
+ * rpt_common_get_rotation:
+ * @xnode: an #xmlNode.
+ *
+ */
+RptRotation
+*rpt_common_get_rotation (xmlNode *xnode)
+{
+       gchar *prop;
+       RptRotation *rotation = NULL;
+
+       prop = xmlGetProp (xnode, "rotation");
+       if (prop != NULL)
+               {
+                       rotation = (RptRotation *)g_malloc0 (sizeof (RptRotation));
+                       rotation->angle = strtod (prop, NULL);
+               }
+
+       return rotation;
+}
+
+/**
+ * rpt_common_set_rotation:
+ * @xnode: an #xmlNode.
+ * @rotation:
+ *
+ */
+void
+rpt_common_set_rotation (xmlNode *xnode, const RptRotation *rotation)
+{
+       if (rotation != NULL)
+               {
+                       xmlSetProp (xnode, "rotation", g_strdup_printf ("%f", rotation->angle));
+               }
+}
+
 /**
  * rpt_common_get_font:
  * @xnode: an #xmlNode.
index 14988156bbd15b7f5e9b5bc5dec09b4e45585595..ccda9189646d11613ac7fad8e834c66d868bf502 100644 (file)
@@ -58,6 +58,12 @@ struct _RptSize
 };
 typedef struct _RptSize RptSize;
 
+struct _RptRotation
+{
+       gdouble angle;
+};
+typedef struct _RptRotation RptRotation;
+
 /**
  * RptFont:
  * @name: the font's family name.
@@ -136,6 +142,10 @@ RptSize *rpt_common_get_size (xmlNode *xnode);
 void rpt_common_set_size (xmlNode *xnode,
                           const RptSize *size);
 
+RptRotation *rpt_common_get_rotation (xmlNode *xnode);
+void rpt_common_set_rotation (xmlNode *xnode,
+                              const RptRotation *rotation);
+
 RptFont *rpt_common_get_font (xmlNode *xnode);
 void rpt_common_set_font (xmlNode *xnode,
                           const RptFont *font);
index 96e27dfa1034fe5dd4cbc27bcff58b00a38beb85..7170b17178875166a0854574fe21ce6765ac2975 100644 (file)
@@ -23,6 +23,7 @@ enum
 {
        PROP_0,
        PROP_SIZE,
+       PROP_ROTATION,
        PROP_BORDER,
        PROP_SOURCE,
        PROP_ADAPT
@@ -47,6 +48,7 @@ typedef struct _RptObjImagePrivate RptObjImagePrivate;
 struct _RptObjImagePrivate
        {
                RptSize *size;
+               RptRotation *rotation;
                RptBorder *border;
                gchar *source;
                guint adapt;
@@ -98,6 +100,11 @@ rpt_obj_image_class_init (RptObjImageClass *klass)
                                                               "Size",
                                                               "The object's size.",
                                                               G_PARAM_READWRITE));
+       g_object_class_install_property (object_class, PROP_ROTATION,
+                                        g_param_spec_pointer ("rotation",
+                                                              "Rotation",
+                                                              "The object's rotation.",
+                                                              G_PARAM_READWRITE));
        g_object_class_install_property (object_class, PROP_BORDER,
                                         g_param_spec_pointer ("border",
                                                               "Border",
@@ -126,7 +133,8 @@ rpt_obj_image_init (RptObjImage *rpt_obj_image)
        priv->size->width = 0.0;
        priv->size->height = 0.0;
 
-       priv->border = (RptBorder *)g_malloc0 (sizeof (RptBorder));
+       priv->rotation = NULL;
+       priv->border = NULL;
 }
 
 /**
@@ -185,6 +193,7 @@ RptObject
                                        priv = RPT_OBJ_IMAGE_GET_PRIVATE (rpt_obj_image);
 
                                        priv->size = rpt_common_get_size (xnode);
+                                       priv->rotation = rpt_common_get_rotation (xnode);
                                        priv->border = rpt_common_get_border (xnode);
 
                                        priv->source = (gchar *)xmlGetProp (xnode, "source");
@@ -217,6 +226,7 @@ rpt_obj_image_get_xml (RptObject *rpt_objimage, xmlNode *xnode)
        xmlNodeSetName (xnode, "image");
 
        rpt_common_set_size (xnode, priv->size);
+       rpt_common_set_rotation (xnode, priv->rotation);
        rpt_common_set_border (xnode, priv->border);
 
        xmlSetProp (xnode, "source", priv->source);
@@ -246,6 +256,10 @@ rpt_obj_image_set_property (GObject *object, guint property_id, const GValue *va
                                priv->size = g_memdup (g_value_get_pointer (value), sizeof (RptSize));
                                break;
 
+                       case PROP_ROTATION:
+                               priv->rotation = g_memdup (g_value_get_pointer (value), sizeof (RptRotation));
+                               break;
+
                        case PROP_BORDER:
                                priv->border = g_memdup (g_value_get_pointer (value), sizeof (RptBorder));
                                break;
@@ -277,6 +291,10 @@ rpt_obj_image_get_property (GObject *object, guint property_id, GValue *value, G
                                g_value_set_pointer (value, g_memdup (priv->size, sizeof (RptSize)));
                                break;
 
+                       case PROP_ROTATION:
+                               g_value_set_pointer (value, g_memdup (priv->rotation, sizeof (RptRotation)));
+                               break;
+
                        case PROP_BORDER:
                                g_value_set_pointer (value, g_memdup (priv->border, sizeof (RptBorder)));
                                break;
index 6df40b4e1e67c99675095b9c55f01da1de1a3eb1..5d590a1dfd299df496d019bc16f8c72f56e33b3a 100644 (file)
@@ -23,6 +23,7 @@ enum
 {
        PROP_0,
        PROP_SIZE,
+       PROP_ROTATION,
        PROP_STROKE
 };
 
@@ -45,6 +46,7 @@ typedef struct _RptObjLinePrivate RptObjLinePrivate;
 struct _RptObjLinePrivate
        {
                RptSize *size;
+               RptRotation *rotation;
                RptStroke *stroke;
        };
 
@@ -94,6 +96,11 @@ rpt_obj_line_class_init (RptObjLineClass *klass)
                                                               "Size",
                                                               "The object's size.",
                                                               G_PARAM_READWRITE));
+       g_object_class_install_property (object_class, PROP_ROTATION,
+                                        g_param_spec_pointer ("rotation",
+                                                              "Rotation",
+                                                              "The object's rotation.",
+                                                              G_PARAM_READWRITE));
        g_object_class_install_property (object_class, PROP_STROKE,
                                         g_param_spec_pointer ("stroke",
                                                               "Stroke",
@@ -110,7 +117,8 @@ rpt_obj_line_init (RptObjLine *rpt_obj_line)
        priv->size->width = 0.0;
        priv->size->height = 0.0;
 
-       priv->stroke = (RptStroke *)g_malloc0 (sizeof (RptStroke));
+       priv->rotation = NULL;
+       priv->stroke = NULL;
 }
 
 /**
@@ -169,6 +177,7 @@ RptObject
                                        priv = RPT_OBJ_LINE_GET_PRIVATE (rpt_obj_line);
 
                                        priv->size = rpt_common_get_size (xnode);
+                                       priv->rotation = rpt_common_get_rotation (xnode);
                                        priv->stroke = rpt_common_get_stroke (xnode);
                                }
                }
@@ -190,6 +199,7 @@ rpt_obj_line_get_xml (RptObject *rpt_objline, xmlNode *xnode)
        xmlNodeSetName (xnode, "line");
 
        rpt_common_set_size (xnode, priv->size);
+       rpt_common_set_rotation (xnode, priv->rotation);
        rpt_common_set_stroke (xnode, priv->stroke);
 }
 
@@ -206,6 +216,10 @@ rpt_obj_line_set_property (GObject *object, guint property_id, const GValue *val
                                priv->size = g_memdup (g_value_get_pointer (value), sizeof (RptSize));
                                break;
 
+                       case PROP_ROTATION:
+                               priv->rotation = g_memdup (g_value_get_pointer (value), sizeof (RptRotation));
+                               break;
+
                        case PROP_STROKE:
                                priv->stroke = g_memdup (g_value_get_pointer (value), sizeof (RptStroke));
                                break;
@@ -229,6 +243,10 @@ rpt_obj_line_get_property (GObject *object, guint property_id, GValue *value, GP
                                g_value_set_pointer (value, g_memdup (priv->size, sizeof (RptSize)));
                                break;
 
+                       case PROP_ROTATION:
+                               g_value_set_pointer (value, g_memdup (priv->rotation, sizeof (RptRotation)));
+                               break;
+
                        case PROP_STROKE:
                                g_value_set_pointer (value, g_memdup (priv->stroke, sizeof (RptStroke)));
                                break;
index e0d1a6f6f2d73c5f9482a832b8078ce247f4f70e..c350cb04ca9351972d44bafd50e343a63ae281c2 100644 (file)
@@ -157,15 +157,18 @@ RptObject
                                {
                                        const gchar *prop;
                                        RptSize *size;
+                                       RptRotation *rotation;
                                        RptStroke *stroke;
 
                                        priv = RPT_OBJ_RECT_GET_PRIVATE (rpt_obj_rect);
 
                                        size = rpt_common_get_size (xnode);
+                                       rotation = rpt_common_get_rotation (xnode);
                                        stroke = rpt_common_get_stroke (xnode);
                                        g_object_set (G_OBJECT (rpt_obj_rect),
                                                      "size", size,
                                                      "stroke", stroke,
+                                                     "rotation", rotation,
                                                      NULL);
 
                                        prop = (const gchar *)xmlGetProp (xnode, "fill-color");
index f2f44d036b5822e7c2393c7435e276924e1c28ad..26a890577dcd434f071e46b7259ba69fba1976cf 100644 (file)
@@ -23,6 +23,7 @@ enum
 {
        PROP_0,
        PROP_SIZE,
+       PROP_ROTATION,
        PROP_BORDER,
        PROP_FONT,
        PROP_ALIGN,
@@ -53,6 +54,7 @@ typedef struct _RptObjTextPrivate RptObjTextPrivate;
 struct _RptObjTextPrivate
        {
                RptSize *size;
+               RptRotation *rotation;
                RptBorder *border;
                RptFont *font;
                RptAlign *align;
@@ -110,6 +112,11 @@ rpt_obj_text_class_init (RptObjTextClass *klass)
                                                               "Size",
                                                               "The object's size.",
                                                               G_PARAM_READWRITE));
+       g_object_class_install_property (object_class, PROP_ROTATION,
+                                        g_param_spec_pointer ("rotation",
+                                                              "Rotation",
+                                                              "The object's rotation.",
+                                                              G_PARAM_READWRITE));
        g_object_class_install_property (object_class, PROP_BORDER,
                                         g_param_spec_pointer ("border",
                                                               "Border",
@@ -171,6 +178,7 @@ rpt_obj_text_init (RptObjText *rpt_obj_text)
        priv->size->width = 0.0;
        priv->size->height = 0.0;
 
+       priv->rotation = NULL;
        priv->border = NULL;
        priv->font = NULL;
        priv->align = NULL;
@@ -235,6 +243,7 @@ RptObject
                                        priv = RPT_OBJ_TEXT_GET_PRIVATE (rpt_obj_text);
 
                                        priv->size = rpt_common_get_size (xnode);
+                                       priv->rotation = rpt_common_get_rotation (xnode);
                                        priv->border = rpt_common_get_border (xnode);
                                        priv->font = rpt_common_get_font (xnode);
                                        priv->align = rpt_common_get_align (xnode);
@@ -290,6 +299,7 @@ rpt_obj_text_get_xml (RptObject *rpt_objtext, xmlNode *xnode)
        xmlNodeSetName (xnode, "text");
 
        rpt_common_set_size (xnode, priv->size);
+       rpt_common_set_rotation (xnode, priv->rotation);
        rpt_common_set_border (xnode, priv->border);
        rpt_common_set_font (xnode, priv->font);
        rpt_common_set_align (xnode, priv->align);
@@ -332,6 +342,10 @@ rpt_obj_text_set_property (GObject *object, guint property_id, const GValue *val
                                priv->size = g_memdup (g_value_get_pointer (value), sizeof (RptSize));
                                break;
 
+                       case PROP_ROTATION:
+                               priv->rotation = g_memdup (g_value_get_pointer (value), sizeof (RptRotation));
+                               break;
+
                        case PROP_BORDER:
                                priv->border = g_memdup (g_value_get_pointer (value), sizeof (RptBorder));
                                break;
@@ -387,6 +401,10 @@ rpt_obj_text_get_property (GObject *object, guint property_id, GValue *value, GP
                                g_value_set_pointer (value, g_memdup (priv->size, sizeof (RptSize)));
                                break;
 
+                       case PROP_ROTATION:
+                               g_value_set_pointer (value, g_memdup (priv->rotation, sizeof (RptRotation)));
+                               break;
+
                        case PROP_BORDER:
                                g_value_set_pointer (value, g_memdup (priv->border, sizeof (RptBorder)));
                                break;
index c5e19bdae31859f1dff7e1eca92491f92100b081..490f4a991edde5bc798d21d8751e943c9445ad6c 100644 (file)
@@ -62,11 +62,17 @@ static void rpt_print_image_xml (RptPrint *rpt_print,
 static void rpt_print_line (RptPrint *rpt_print,
                             const RptPoint *from_p,
                             const RptPoint *to_p,
-                            const RptStroke *stroke);
+                            const RptStroke *stroke,
+                                                       const RptRotation *rotation);
 static void rpt_print_border (RptPrint *rpt_print,
                               const RptPoint *position,
                               const RptSize *size,
-                              const RptBorder *border);
+                              const RptBorder *border,
+                              const RptRotation *rotation);
+
+
+static gchar *rpt_print_new_numbered_filename (const gchar *filename, int number);
+static void rpt_print_rotate (RptPrint *rpt_print, const RptPoint *position, const RptSize *size, gdouble angle);
 
 
 #define RPT_PRINT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_RPT_PRINT, RptPrintPrivate))
@@ -154,12 +160,12 @@ RptPrint
                                        RptPrintPrivate *priv;
 
                                        gint npage = 0;
-                               
+
                                        rpt_print = RPT_PRINT (g_object_new (rpt_print_get_type (), NULL));
 
                                        priv = RPT_PRINT_GET_PRIVATE (rpt_print);
 
-                                       if (output_type != RPTP_OUTPUT_PNG)
+                                       if (output_type != RPTP_OUTPUT_PNG && output_type != RPTP_OUTPUT_SVG)
                                                {
                                                        fout = fopen (out_filename, "w");
                                                        if (fout == NULL)
@@ -209,40 +215,43 @@ RptPrint
 
                                                                        if (priv->width != 0 && priv->height != 0)
                                                                                {
-                                                                                       if (npage == 1)
+                                                                                       if (output_type == RPTP_OUTPUT_PNG)
+                                                                                               {
+                                                                                                       priv->surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, (int)priv->width, (int)priv->height);
+                                                                                               }
+                                                                                       else if (output_type == RPTP_OUTPUT_PDF && npage == 1)
+                                                                                               {
+                                                                                                       priv->surface = cairo_pdf_surface_create (out_filename, priv->width, priv->height);
+                                                                                               }
+                                                                                       else if (output_type == RPTP_OUTPUT_PS && npage == 1)
+                                                                                               {
+                                                                                                       priv->surface = cairo_ps_surface_create (out_filename, priv->width, priv->height);
+                                                                                               }
+                                                                                       else if (output_type == RPTP_OUTPUT_SVG)
                                                                                                {
-                                                                                                       switch (output_type)
+                                                                                                       gchar *new_out_filename = rpt_print_new_numbered_filename (out_filename, npage);
+                                                                                                       fout = fopen (new_out_filename, "w");
+                                                                                                       if (fout == NULL)
                                                                                                                {
-                                                                                                                       case RPTP_OUTPUT_PNG:
-                                                                                                                               priv->surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, (int)priv->width, (int)priv->height);
-                                                                                                                               break;
-                                                                                                               
-                                                                                                                       case RPTP_OUTPUT_PDF:
-                                                                                                                               priv->surface = cairo_pdf_surface_create (out_filename, priv->width, priv->height);
-                                                                                                                               break;
-               
-                                                                                                                       case RPTP_OUTPUT_PS:
-                                                                                                                               priv->surface = cairo_ps_surface_create (out_filename, priv->width, priv->height);
-                                                                                                                               break;
-               
-                                                                                                                       case RPTP_OUTPUT_SVG:
-                                                                                                                               priv->surface = cairo_svg_surface_create (out_filename, priv->width, priv->height);
-                                                                                                                               break;
+                                                                                                                       /* TO DO */
+                                                                                                                       return NULL;
                                                                                                                }
+
+                                                                                                       priv->surface = cairo_svg_surface_create (new_out_filename, priv->width, priv->height);
                                                                                                }
 
                                                                                        if (cairo_surface_status (priv->surface) == CAIRO_STATUS_SUCCESS)
                                                                                                {
-                                                                                                       if (npage == 1)
+                                                                                                       if (output_type == RPTP_OUTPUT_PNG || output_type == RPTP_OUTPUT_SVG)
                                                                                                                {
                                                                                                                        priv->cr = cairo_create (priv->surface);
                                                                                                                }
-                                                                                                       else
+                                                                                                       else if (npage == 1)
                                                                                                                {
-                                                                                                                       /* TO DO */
+                                                                                                                       priv->cr = cairo_create (priv->surface);
                                                                                                                }
 
-                                                                                                       if (npage == 1 && output_type != RPTP_OUTPUT_PNG)
+                                                                                                       if (output_type != RPTP_OUTPUT_PNG && output_type != RPTP_OUTPUT_SVG && npage == 1)
                                                                                                                {
                                                                                                                        cairo_surface_destroy (priv->surface);
                                                                                                                }
@@ -250,18 +259,32 @@ RptPrint
                                                                                                        if (cairo_status (priv->cr) == CAIRO_STATUS_SUCCESS)
                                                                                                                {
                                                                                                                        rpt_print_page (rpt_print, cur);
+
                                                                                                                        if (output_type == RPTP_OUTPUT_PNG)
                                                                                                                                {
-                                                                                                                                       cairo_surface_write_to_png (priv->surface, out_filename);
+                                                                                                                                       gchar *new_out_filename = rpt_print_new_numbered_filename (out_filename, npage);
+                                                                                                                               
+                                                                                                                                       cairo_surface_write_to_png (priv->surface,
+                                                                                                                                                                   new_out_filename);
                                                                                                                                        cairo_surface_destroy (priv->surface);
+                                                                                                                                       cairo_destroy (priv->cr);
+                                                                                                                               }
+                                                                                                                       else
+                                                                                                                               {
+                                                                                                                                       cairo_show_page (priv->cr);
                                                                                                                                }
 
-                                                                                                                       cairo_show_page (priv->cr);
+                                                                                                                       if (output_type == RPTP_OUTPUT_SVG)
+                                                                                                                               {
+                                                                                                                                       cairo_surface_destroy (priv->surface);
+                                                                                                                                       cairo_destroy (priv->cr);
+                                                                                                                                       fclose (fout);
+                                                                                                                               }
                                                                                                                }
                                                                                                        else
                                                                                                                {
                                                                                                                        /* TO DO */
-                                                                                                                       g_warning ("cairo status not sucess: %d",cairo_status (priv->cr));
+                                                                                                                       g_warning ("cairo status not sucess: %d", cairo_status (priv->cr));
                                                                                                                }                                                                                               
                                                                                                }
                                                                                        else
@@ -285,10 +308,10 @@ RptPrint
                                                }
 
                                        if (priv->cr != NULL)
-                                               {                                               
+                                               {
                                                        cairo_destroy (priv->cr);
                                                }
-                                       if (output_type != RPTP_OUTPUT_PNG)
+                                       if (output_type != RPTP_OUTPUT_PNG && output_type != RPTP_OUTPUT_SVG)
                                                {
                                                        fclose (fout);
                                                }
@@ -408,6 +431,7 @@ rpt_print_text_xml (RptPrint *rpt_print, xmlNode *xnode)
 
        RptPoint *position;
        RptSize *size;
+       RptRotation *rotation;
        RptAlign *align;
        RptBorder *border;
        RptFont *font;
@@ -429,10 +453,17 @@ rpt_print_text_xml (RptPrint *rpt_print, xmlNode *xnode)
 
        position = rpt_common_get_position (xnode);
        size = rpt_common_get_size (xnode);
+       rotation = rpt_common_get_rotation (xnode);
        align = rpt_common_get_align (xnode);
        border = rpt_common_get_border (xnode);
        font = rpt_common_get_font (xnode);
 
+       if (position == NULL)
+               {
+                       /* TO DO */
+                       return;
+               }
+
        /* padding */
        prop = xmlGetProp (xnode, (const xmlChar *)"padding-top");
        if (prop != NULL)
@@ -520,6 +551,11 @@ rpt_print_text_xml (RptPrint *rpt_print, xmlNode *xnode)
                        pango_layout_set_attributes (playout, lpattr);
                }
 
+       if (rotation != NULL)
+               {
+                       rpt_print_rotate (rpt_print, position, size, rotation->angle);
+               }
+
        /* background */
        prop = xmlGetProp (xnode, (const xmlChar *)"background-color");
        if (prop != NULL && position != NULL && size != NULL)
@@ -532,9 +568,9 @@ rpt_print_text_xml (RptPrint *rpt_print, xmlNode *xnode)
                }
 
        /* drawing border */
-       rpt_print_border (rpt_print, position, size, border);
+       rpt_print_border (rpt_print, position, size, border, rotation);
 
-       /* setting alignment */
+       /* setting horizontal alignment */
        switch (align->h_align)
                {
                        case RPT_HALIGN_LEFT:
@@ -553,6 +589,8 @@ rpt_print_text_xml (RptPrint *rpt_print, xmlNode *xnode)
                                break;
                }
 
+       /* TO DO */
+       /* setting vertical alignment */
        switch (align->v_align)
                {
                        case RPT_VALIGN_TOP:
@@ -566,7 +604,7 @@ rpt_print_text_xml (RptPrint *rpt_print, xmlNode *xnode)
                }
 
        /* setting clipping region */
-       if (position != NULL && size != NULL)
+       if (size != NULL)
                {
                        cairo_rectangle (priv->cr,
                                         position->x + padding_left,
@@ -588,10 +626,9 @@ rpt_print_text_xml (RptPrint *rpt_print, xmlNode *xnode)
                                        cairo_set_source_rgba (priv->cr, 0.0, 0.0, 0.0, 1.0);
                                }
                }
-       if (position != NULL)
-               {
-                       cairo_move_to (priv->cr, position->x + padding_left, position->y + padding_top);
-               }
+
+       cairo_move_to (priv->cr, position->x + padding_left, position->y + padding_top);
+
        pango_layout_set_text (playout, text, -1);
        pango_cairo_show_layout (priv->cr, playout);
 
@@ -608,10 +645,12 @@ rpt_print_line_xml (RptPrint *rpt_print, xmlNode *xnode)
        RptPoint *from_p = (RptPoint *)g_malloc0 (sizeof (RptPoint));
        RptPoint *to_p = (RptPoint *)g_malloc0 (sizeof (RptPoint));
        RptSize *size;
+       RptRotation *rotation;
        RptStroke *stroke;
 
        position = rpt_common_get_position (xnode);
        size = rpt_common_get_size (xnode);
+       rotation = rpt_common_get_rotation (xnode);
        stroke = rpt_common_get_stroke (xnode);
 
        from_p->x = position->x;
@@ -619,7 +658,7 @@ rpt_print_line_xml (RptPrint *rpt_print, xmlNode *xnode)
        to_p->x = position->x + size->width;
        to_p->y = position->y + size->height;
 
-       rpt_print_line (rpt_print, from_p, to_p, stroke);
+       rpt_print_line (rpt_print, from_p, to_p, stroke, rotation);
 }
 
 static void
@@ -627,6 +666,7 @@ rpt_print_rect_xml (RptPrint *rpt_print, xmlNode *xnode)
 {
        RptPoint *position;
        RptSize *size;
+       RptRotation *rotation;
        RptStroke *stroke;
        RptColor *fill_color;
        gchar *prop;
@@ -635,6 +675,7 @@ rpt_print_rect_xml (RptPrint *rpt_print, xmlNode *xnode)
 
        position = rpt_common_get_position (xnode);
        size = rpt_common_get_size (xnode);
+       rotation = rpt_common_get_rotation (xnode);
        stroke = rpt_common_get_stroke (xnode);
 
        if (position == NULL || size == NULL)
@@ -647,6 +688,7 @@ rpt_print_rect_xml (RptPrint *rpt_print, xmlNode *xnode)
                        stroke->width = 1.0;
                        stroke->color = (RptColor *)g_malloc0 (sizeof (RptColor));
                        stroke->color->a = 1.0;
+                       stroke->style = NULL;
                }
 
        prop = xmlGetProp (xnode, (const xmlChar *)"fill-color");
@@ -655,6 +697,12 @@ rpt_print_rect_xml (RptPrint *rpt_print, xmlNode *xnode)
                        fill_color = rpt_common_parse_color (prop);
                }
 
+       if (rotation != NULL)
+               {
+                       rpt_print_rotate (rpt_print, position, size, rotation->angle);
+               }
+
+       /* TO DO */
        /*cairo_set_line_width (priv->cr, stroke.width);*/
        cairo_rectangle (priv->cr, position->x, position->y, size->width, size->height);
 
@@ -664,6 +712,12 @@ rpt_print_rect_xml (RptPrint *rpt_print, xmlNode *xnode)
                        cairo_fill_preserve (priv->cr);
                }
 
+       if (stroke->style != NULL)
+               {
+                       gdouble *dash = rpt_common_style_to_array (stroke->style);
+                       cairo_set_dash (priv->cr, dash, stroke->style->len, 0.0);
+               }
+
        cairo_set_source_rgba (priv->cr, stroke->color->r, stroke->color->g, stroke->color->b, stroke->color->a);
        cairo_stroke (priv->cr);
 }
@@ -693,6 +747,7 @@ rpt_print_ellipse_xml (RptPrint *rpt_print, xmlNode *xnode)
                        stroke->width = 1.0;
                        stroke->color = (RptColor *)g_malloc0 (sizeof (RptColor));
                        stroke->color->a = 1.0;
+                       stroke->style = NULL;
                }
 
        prop = xmlGetProp (xnode, (const xmlChar *)"fill-color");
@@ -724,6 +779,7 @@ rpt_print_image_xml (RptPrint *rpt_print, xmlNode *xnode)
 {
        RptPoint *position;
        RptSize *size;
+       RptRotation *rotation;
        RptBorder *border;
 
        cairo_surface_t *image;
@@ -753,12 +809,18 @@ rpt_print_image_xml (RptPrint *rpt_print, xmlNode *xnode)
 
        position = rpt_common_get_position (xnode);
        size = rpt_common_get_size (xnode);
+       rotation = rpt_common_get_rotation (xnode);
        border = rpt_common_get_border (xnode);
 
        image = cairo_image_surface_create_from_png (filename);
 
        pattern = cairo_pattern_create_for_surface (image);
 
+       if (rotation != NULL)
+               {
+                       rpt_print_rotate (rpt_print, position, size, rotation->angle);
+               }
+
        cairo_matrix_init_identity (&matrix);
        if (strcmp (adapt, "none") != 0)
                {
@@ -783,14 +845,14 @@ rpt_print_image_xml (RptPrint *rpt_print, xmlNode *xnode)
        cairo_rectangle (priv->cr, position->x, position->y, size->width, size->height);
        cairo_fill (priv->cr);
 
-       rpt_print_border (rpt_print, position, size, border);
+       rpt_print_border (rpt_print, position, size, border, rotation);
        
        cairo_pattern_destroy (pattern);
        cairo_surface_destroy (image);
 }
 
 static void
-rpt_print_line (RptPrint *rpt_print, const RptPoint *from_p, const RptPoint *to_p, const RptStroke *stroke)
+rpt_print_line (RptPrint *rpt_print, const RptPoint *from_p, const RptPoint *to_p, const RptStroke *stroke, const RptRotation *rotation)
 {
        RptPrintPrivate *priv = RPT_PRINT_GET_PRIVATE (rpt_print);
 
@@ -798,6 +860,7 @@ rpt_print_line (RptPrint *rpt_print, const RptPoint *from_p, const RptPoint *to_
 
        if (stroke != NULL)
                {
+                       /* TO DO */
                        /*cairo_set_line_width (priv->cr, stroke.width);*/
                        cairo_set_source_rgba (priv->cr, stroke->color->r, stroke->color->g, stroke->color->b, stroke->color->a);
                        if (stroke->style != NULL)
@@ -810,6 +873,17 @@ rpt_print_line (RptPrint *rpt_print, const RptPoint *from_p, const RptPoint *to_
                {
                        cairo_set_source_rgba (priv->cr, 0.0, 0.0, 0.0, 1.0);
                }
+
+       if (rotation != NULL)
+               {
+                       RptSize size;
+
+                       size.width = to_p->x - from_p->x;
+                       size.height = to_p->y - from_p->y;
+
+                       rpt_print_rotate (rpt_print, from_p, &size, rotation->angle);
+               }
+
        cairo_move_to (priv->cr, from_p->x, from_p->y);
        cairo_line_to (priv->cr, to_p->x, to_p->y);
        cairo_stroke (priv->cr);
@@ -821,7 +895,7 @@ rpt_print_line (RptPrint *rpt_print, const RptPoint *from_p, const RptPoint *to_
 }
 
 static void
-rpt_print_border (RptPrint *rpt_print, const RptPoint *position, const RptSize *size, const RptBorder *border)
+rpt_print_border (RptPrint *rpt_print, const RptPoint *position, const RptSize *size, const RptBorder *border, const RptRotation *rotation)
 {
        RptPrintPrivate *priv = RPT_PRINT_GET_PRIVATE (rpt_print);
 
@@ -840,7 +914,7 @@ rpt_print_border (RptPrint *rpt_print, const RptPoint *position, const RptSize *
                        stroke->width = border->top_width;
                        stroke->color = border->top_color;
                        stroke->style = border->top_style;
-                       rpt_print_line (rpt_print, from_p, to_p, stroke);
+                       rpt_print_line (rpt_print, from_p, to_p, stroke, NULL);
                }
        if (border->right_width != 0.0)
                {
@@ -851,7 +925,7 @@ rpt_print_border (RptPrint *rpt_print, const RptPoint *position, const RptSize *
                        stroke->width = border->right_width;
                        stroke->color = border->right_color;
                        stroke->style = border->right_style;
-                       rpt_print_line (rpt_print, from_p, to_p, stroke);
+                       rpt_print_line (rpt_print, from_p, to_p, stroke, NULL);
                }
        if (border->bottom_width != 0.0)
                {
@@ -862,7 +936,7 @@ rpt_print_border (RptPrint *rpt_print, const RptPoint *position, const RptSize *
                        stroke->width = border->bottom_width;
                        stroke->color = border->bottom_color;
                        stroke->style = border->bottom_style;
-                       rpt_print_line (rpt_print, from_p, to_p, stroke);
+                       rpt_print_line (rpt_print, from_p, to_p, stroke, NULL);
                }
        if (border->left_width != 0.0)
                {
@@ -873,6 +947,40 @@ rpt_print_border (RptPrint *rpt_print, const RptPoint *position, const RptSize *
                        stroke->width = border->left_width;
                        stroke->color = border->left_color;
                        stroke->style = border->left_style;
-                       rpt_print_line (rpt_print, from_p, to_p, stroke);
+                       rpt_print_line (rpt_print, from_p, to_p, stroke, NULL);
                }
 }
+
+static gchar
+*rpt_print_new_numbered_filename (const gchar *filename, int number)
+{
+       gchar *new_out_filename = NULL;
+
+       gchar *filename_ext = g_strrstr (filename, ".");
+       if (filename_ext == NULL)
+               {
+                       new_out_filename = g_strdup_printf ("%s%d", filename, number);
+               }
+       else
+               {
+                       new_out_filename = g_strdup_printf ("%s%d%s",
+                                                                                               g_strndup (filename, strlen (filename) - strlen (filename_ext)),
+                                                                                               number,
+                                                                                               filename_ext);
+               }
+
+       return new_out_filename;
+}
+
+static void
+rpt_print_rotate (RptPrint *rpt_print, const RptPoint *position, const RptSize *size, gdouble angle)
+{
+       RptPrintPrivate *priv = RPT_PRINT_GET_PRIVATE (rpt_print);
+
+       gdouble tx = position->x + size->width / 2;
+       gdouble ty = position->y + size->height / 2;
+
+       cairo_translate (priv->cr, tx, ty);
+       cairo_rotate (priv->cr, angle * G_PI / 180.);
+       cairo_translate (priv->cr, -tx, -ty);
+}
index ae7f8f0c37cb49c2e2aebe1ce69d34e18ed005a0..8951a23dbf62b9a72647a38f30257349e4cc499e 100644 (file)
@@ -1638,13 +1638,17 @@ gchar
 
        RptReportPrivate *priv = RPT_REPORT_GET_PRIVATE (rpt_report);
 
-       col = gda_data_model_get_column_position (priv->db->gda_datamodel, field_name);
-
-       if (col > -1)
+       if (priv->db != NULL && priv->db->gda_datamodel != NULL)
                {
-                       ret = gda_value_stringify ((GdaValue *)gda_data_model_get_value_at (priv->db->gda_datamodel, col, row));
+                       col = gda_data_model_get_column_position (priv->db->gda_datamodel, field_name);
+               
+                       if (col > -1)
+                               {
+                                       ret = gda_value_stringify ((GdaValue *)gda_data_model_get_value_at (priv->db->gda_datamodel, col, row));
+                               }
                }
-       else
+
+       if (ret == NULL)
                {
                        ret = rpt_report_ask_field (rpt_report, field_name, row);
                }
@@ -1661,8 +1665,16 @@ gchar
 
        RptReportClass *klass = RPT_REPORT_GET_CLASS (rpt_report);
 
-       g_signal_emit (rpt_report, klass->field_request_signal_id,
-                                  0, field, priv->db->gda_datamodel, row, &ret);
+       if (priv->db != NULL && priv->db->gda_datamodel != NULL)
+               {
+                       g_signal_emit (rpt_report, klass->field_request_signal_id,
+                                      0, field, priv->db->gda_datamodel, row, &ret);
+               }
+       else
+               {
+                       g_signal_emit (rpt_report, klass->field_request_signal_id,
+                                      0, field, NULL, row, &ret);
+               }
        if (ret != NULL)
                {
                        ret = g_strdup (ret);
index b95fc60ad63e1c622c6e129813d45645a0c113a7..815a1bf66896f10f8b5bd584b85b32958654fe22 100644 (file)
@@ -3,7 +3,7 @@
        <page width="595" height="842" margin-top="50" margin-left="100" margin-right="10" />
 
        <report>
-               <body height="500">
+               <body height="800">
                        <text name="text4" x="-50" y="10" width="500" height="150" source="&quot;text outside from left&quot;" />
                        <text name="text1" x="100" y="50" width="500" height="150" source="&quot;the text's content&quot;" />
                        <text name="date" x="100" y="150" width="500" height="150" source="@Date" />
                                source="&quot;text very very long to try padding and border&quot;" />
                        <text name="text3" x="400" y="350" width="200" height="50" source="&quot;another long text to test page margins&quot;" />
                        <text name="text5" x="50" y="460" width="200" height="50" source="[field_to_request]" />
+                       <text name="text6" x="50" y="600" width="200" height="50"
+                               border-top-width="1.0" border-right-width="1.0" border-bottom-width="1.0" border-left-width="1.0"
+                               border-bottom-style="10"
+                               rotation="45" source="&quot;Rotated text&quot;" />
+                       <line name="line1" x="350" y="50" width="200" height="0" rotation="-45" />
+                       <rect name="rect1" x="350" y="250" width="200" height="50" fill-color="#FFFF00" rotation="45" stroke-style="10" />
+                       <image name="image1" x="200" y="460" width="200" height="150" 
+                               border-top-width="1.0" border-right-width="1.0" border-bottom-width="1.0" border-left-width="1.0"
+                               border-top-color="#FF0000" border-right-color="#FF0000" border-bottom-color="#FF0000" border-left-color="#FF0000"
+                               rotation="135" source="tests/city.png" />
                </body>
        </report>
 </reptool>
index dd3f82d558197811187ba03bd78eb21ceef15011..bc4c945f9051d78472de4fad2881d2f5486c0e06 100644 (file)
@@ -25,7 +25,7 @@ main (int argc, char **argv)
 
        g_type_init ();
 
-       rptp = rpt_print_new_from_file (argv[1], RPTP_OUTPUT_PDF, "test.pdf");
+       rptp = rpt_print_new_from_file (argv[1], RPTP_OUTPUT_PNG, "test.png");
 
        if (rptp != NULL)
                {