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,
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)
g_warning ("Not a valid RepTool print report format.");
}
}
+ else
+ {
+ g_warning ("No root element on xmlDoc.");
+ }
return rpt_print;
}
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)
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");
}
}
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);
}
}
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 */
{
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
if (prop != NULL)
{
fill_color = rpt_common_parse_color (prop);
+ xmlFree (prop);
}
if (rotation != NULL)
}
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);
/*
- * 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);
}