]> saetta.ns0.it Git - reptool/libreptool/commitdiff
Many code adjustments.
authorAndrea Zagli <azagli@libero.it>
Wed, 3 Aug 2011 17:06:11 +0000 (19:06 +0200)
committerAndrea Zagli <azagli@libero.it>
Wed, 3 Aug 2011 17:06:11 +0000 (19:06 +0200)
Added command line parameters to test_rptprint.

AUTHORS
configure.ac
src/rptobject.c
src/rptobjectellipse.c
src/rptobjectimage.c
src/rptobjectline.c
src/rptobjectrect.c
src/rptprint.c
src/rptreport_priv.h
tests/test_rptprint.c

diff --git a/AUTHORS b/AUTHORS
index 948556f926e7a89199d5226c460d85e4e83b83cc..ad1de0f8096192c15b6a46be65e1828685a639ea 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1 +1 @@
-Andrea Zagli <azagli@inwind.it>
+Andrea Zagli <azagli@libero.it>
index 38ea2f4967e3922ca9292b47673ed1e21cecab7b..919e9e92022b929cf64036a293267abefa685a84 100644 (file)
@@ -63,13 +63,13 @@ AC_FUNC_STRTOD
 AC_CHECK_FUNCS([memset strcasecmp strstr strtol])
 
 AC_CONFIG_FILES([
-  libreptool.pc
-  Makefile
-  src/Makefile
-  tests/Makefile
-  docs/Makefile
-  docs/reference/Makefile
-  docs/reference/version.xml
-  data/Makefile
+       libreptool.pc
+       Makefile
+       src/Makefile
+       tests/Makefile
+       docs/Makefile
+       docs/reference/Makefile
+       docs/reference/version.xml
+       data/Makefile
 ])
 AC_OUTPUT
index 70f9a2f174bacda032411ca316c0b81efca986ad..4ccf8fb104f9fa9f6877e22e416565cbb612f09d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Andrea Zagli <azagli@inwind.it>
+ * Copyright (C) 2007 Andrea Zagli <azagli@libero.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 280a628a7b2acd7e6b4f6df22072b357b70aa220..08b046424309b9854471e45d5d874a90b569de59 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2010 Andrea Zagli <azagli@inwind.it>
+ * Copyright (C) 2007-2010 Andrea Zagli <azagli@libero.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 7170b17178875166a0854574fe21ce6765ac2975..c9f0b8817262e8332affbe81739a0aea6073d090 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Andrea Zagli <azagli@inwind.it>
+ * Copyright (C) 2007 Andrea Zagli <azagli@libero.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 27e4312cab8ca58a090d8568e0a786f26023814a..f734592ebef18e3f784aedfe22cfa7dc17039a82 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Andrea Zagli <azagli@inwind.it>
+ * Copyright (C) 2007 Andrea Zagli <azagli@libero.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 99980175857e66993b3181a6d5076d2966c257e7..81db44dd2603d7a67f6fa3a908f0cf12c8022488 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Andrea Zagli <azagli@inwind.it>
+ * Copyright (C) 2007 Andrea Zagli <azagli@libero.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index c1b21cffbc56ecb493eb47b52b75fc038cfac474..4c74c4cd4c034822b34679dcdc4f17f0fba0b863 100644 (file)
@@ -81,8 +81,12 @@ static void rpt_print_border (RptPrint *rpt_print,
                               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);
+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);
 
 
 static void rpt_print_gtk_begin_print (GtkPrintOperation *operation, 
@@ -201,7 +205,9 @@ rpt_print_init (RptPrint *rpt_print)
 RptPrint
 *rpt_print_new_from_xml (xmlDoc *xdoc)
 {
-       RptPrint *rpt_print = NULL;
+       RptPrint *rpt_print;
+
+       rpt_print = NULL;
 
        xmlNode *cur = xmlDocGetRootElement (xdoc);
        if (cur != NULL)
@@ -222,6 +228,10 @@ RptPrint
                                        g_warning ("Not a valid RepTool print report format.");
                                }
                }
+       else
+               {
+                       g_warning ("No root element on xmlDoc.");
+               }
 
        return rpt_print;
 }
@@ -237,7 +247,9 @@ RptPrint
 RptPrint
 *rpt_print_new_from_file (const gchar *filename)
 {
-       RptPrint *rpt_print = NULL;
+       RptPrint *rpt_print;
+
+       rpt_print = NULL;
 
        xmlDoc *xdoc = xmlParseFile (filename);
        if (xdoc != NULL)
@@ -280,7 +292,7 @@ rpt_print_set_output_filename (RptPrint *rpt_print, const gchar *output_filename
        priv->output_filename = g_strdup (output_filename);
        if (g_strcmp0 (priv->output_filename, "") == 0)
                {
-                       g_warning ("It's not possible to set an empty output filename.");
+                       g_warning ("It's not possible to set an empty output filename; default to rptreport.pdf.");
                        priv->output_filename = g_strdup ("rptreport.pdf");
                }
 }
@@ -654,31 +666,37 @@ rpt_print_get_xml_page_attributes (RptPrint *rpt_print, xmlNode *xml_page)
        if (prop != NULL)
                {
                        priv->width = g_strtod (prop, NULL);
+                       xmlFree (prop);
                }
        prop = xmlGetProp (xml_page, (const xmlChar *)"height");
        if (prop != NULL)
                {
                        priv->height = g_strtod (prop, NULL);
+                       xmlFree (prop);
                }
        prop = xmlGetProp (xml_page, (const xmlChar *)"margin-top");
        if (prop != NULL)
                {
                        priv->margin_top = g_strtod (prop, NULL);
+                       xmlFree (prop);
                }
        prop = xmlGetProp (xml_page, (const xmlChar *)"margin-right");
        if (prop != NULL)
                {
                        priv->margin_right = g_strtod (prop, NULL);
+                       xmlFree (prop);
                }
        prop = xmlGetProp (xml_page, (const xmlChar *)"margin-bottom");
        if (prop != NULL)
                {
                        priv->margin_bottom = g_strtod (prop, NULL);
+                       xmlFree (prop);
                }
        prop = xmlGetProp (xml_page, (const xmlChar *)"margin-left");
        if (prop != NULL)
                {
                        priv->margin_left = g_strtod (prop, NULL);
+                       xmlFree (prop);
                }
 }
 
@@ -780,22 +798,26 @@ rpt_print_text_xml (RptPrint *rpt_print, xmlNode *xnode)
        prop = xmlGetProp (xnode, (const xmlChar *)"padding-top");
        if (prop != NULL)
                {
-                       padding_top = rpt_common_value_to_points (priv->unit, atof (prop));
+                       padding_top = rpt_common_value_to_points (priv->unit, g_strtod (prop, NULL));
+                       xmlFree (prop);
                }
        prop = xmlGetProp (xnode, (const xmlChar *)"padding-right");
        if (prop != NULL)
                {
-                       padding_right = rpt_common_value_to_points (priv->unit, atof (prop));
+                       padding_right = rpt_common_value_to_points (priv->unit, g_strtod (prop, NULL));
+                       xmlFree (prop);
                }
        prop = xmlGetProp (xnode, (const xmlChar *)"padding-bottom");
        if (prop != NULL)
                {
-                       padding_bottom = rpt_common_value_to_points (priv->unit, atof (prop));
+                       padding_bottom = rpt_common_value_to_points (priv->unit, g_strtod (prop, NULL));
+                       xmlFree (prop);
                }
        prop = xmlGetProp (xnode, (const xmlChar *)"padding-left");
        if (prop != NULL)
                {
-                       padding_left = rpt_common_value_to_points (priv->unit, atof (prop));
+                       padding_left = rpt_common_value_to_points (priv->unit, g_strtod (prop, NULL));
+                       xmlFree (prop);
                }
 
        /* creating pango layout */
@@ -965,6 +987,13 @@ rpt_print_text_xml (RptPrint *rpt_print, xmlNode *xnode)
                {
                        cairo_reset_clip (priv->cr);
                }
+
+       g_free (position);
+       g_free (size);
+       g_free (rotation);
+       g_free (align);
+       g_free (border);
+       g_free (font);
 }
 
 static void
@@ -1032,6 +1061,7 @@ rpt_print_rect_xml (RptPrint *rpt_print, xmlNode *xnode)
        if (prop != NULL)
                {
                        fill_color = rpt_common_parse_color (prop);
+                       xmlFree (prop);
                }
 
        if (rotation != NULL)
@@ -1288,7 +1318,11 @@ rpt_print_line (RptPrint *rpt_print,
 }
 
 static void
-rpt_print_border (RptPrint *rpt_print, const RptPoint *position, const RptSize *size, const RptBorder *border, const RptRotation *rotation)
+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);
 
index bc2d36f4c8adeff0c04baf75a9668be5344c2c3f..22e0c55f3beefb2ac6bf20f23e0603d9893fed30 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Andrea Zagli <azagli@inwind.it>
+ * Copyright (C) 2007 Andrea Zagli <azagli@libero.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 549ed0139aa5e4c3a52ba31bbbbfaf1f2b5a3373..d0c1fbe85c4bf10123de2ada7e985758d2111061 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2010 Andrea Zagli <azagli@inwind.it>
+ * Copyright (C) 2006-2011 Andrea Zagli <azagli@libero.it>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 
 #include <rptprint.h>
 
+static gchar *rptr_file_name = NULL;
+static gchar *output_type = NULL;
+static gchar *output_file_name = NULL;
+
+static GOptionEntry entries[] =
+{
+       { "rptr-file-name", 'r', 0, G_OPTION_ARG_STRING, &rptr_file_name, "RptPrint definition file name", "RPTR_FILE_NAME" },
+       { "output-type", 'o', 0, G_OPTION_ARG_STRING, &output_type, "Output type (png | pdf | ps | svg | gtk | gtk-default)", "OUTPUT-TYPE" },
+       { "output-file-name", 'f', 0, G_OPTION_ARG_FILENAME, &output_file_name, "Output file name", "FILE-NAME" },
+       { NULL }
+};
+
 int
 main (int argc, char **argv)
 {
+       GError *error;
+       GOptionContext *context;
+
        RptPrint *rptp;
 
        g_type_init ();
 
-       rptp = rpt_print_new_from_file (argv[1]);
+       context = g_option_context_new ("- test rptprint");
+       g_option_context_add_main_entries (context, entries, NULL);
+
+       error = NULL;
+       if (!g_option_context_parse (context, &argc, &argv, &error))
+               {
+                       g_error ("option parsing failed: %s\n", error->message);
+                       return 0;
+               }
+
+       rptp = rpt_print_new_from_file (rptr_file_name);
 
        if (rptp != NULL)
                {
-                       rpt_print_set_output_type (rptp, RPT_OUTPUT_PNG);
-                       rpt_print_set_output_filename (rptp, "test.png");
+                       rpt_print_set_output_type (rptp, rpt_common_stroutputtype_to_enum (output_type));
+                       rpt_print_set_output_filename (rptp, output_file_name == NULL ? "test.out" : output_file_name);
                        rpt_print_print (rptp, NULL);
                }