]> saetta.ns0.it Git - reptool/libreptool/commitdiff
Added "output-type", "output-filename" and "copies" to xml for report
authorAndrea Zagli <azagli@libero.it>
Sat, 2 Oct 2010 08:56:18 +0000 (10:56 +0200)
committerAndrea Zagli <azagli@libero.it>
Sat, 2 Oct 2010 08:56:18 +0000 (10:56 +0200)
and print definition.
Added functions RptCommon::stroutputtype_to_enum, RptCommon::enum_to_stroutputtype,
RptPrint::set_output_type, RptPrint::set_output_filename, RptPrint::set_copies,
RptReport::set_output_type, RptReport::set_output_filename, RptReport::set_copies.
Renamed RPTP_OUTPUT* to RPT_OUTPUT*.

13 files changed:
.gitignore
data/reptool.dtd
data/reptool_report.dtd
docs/reference/libreptool-overrides.txt [new file with mode: 0644]
src/rptcommon.c
src/rptcommon.h
src/rptprint.c
src/rptprint.h
src/rptreport.c
src/rptreport.h
tests/test_rptprint.c
tests/test_rptreport.c
tests/test_rptreport_creation.c

index a3169c8885b1b26b8d21aca4c692ef868b2e1700..e1ac3efdfd896c0c10b8b457509d0fd2d4de45c4 100644 (file)
@@ -38,6 +38,9 @@ config.status
 docs/reference/version.xml
 docs/reference/html/
 docs/reference/xml/
+docs/reference/libreptool-decl-list.txt
+docs/reference/libreptool-decl.txt
+docs/reference/libreptool-scan.c
 libtool
 stamp-h1
 tests/test*.png
index ebf2e93fa0bf845bff4cc4989c03aadcf976ed1f..c809b7c1237bf2684288e587ee845af472fddcfe 100644 (file)
 
 <!ELEMENT reptool (properties?, database?, page, report)>
 
-<!ELEMENT properties (unit-length?)>
+<!ELEMENT properties (unit-length?, output-type?, output-filename?, copies?)>
 <!ELEMENT unit-length (pt | in | cm | mm) #IMPLIED>
+<!ELEMENT output-type (png, pdf, ps, svg, gtk, gtk-default) #IMPLIED>
+<!ELEMENT output-filename CDATA #IMPLIED>
+<!ELEMENT copies CDATA #IMPLIED>
 
 <!ELEMENT database (provider, connection-string, sql)>
 <!ELEMENT provider (#PCDATA)>
index f9f1ab620e4e1288989fac46c340086e25f3d30c..90842c711116cbf142f30460f0c7c7033fb72234 100644 (file)
 
 <!ELEMENT reptool_report (properties?, page*)>
 
-<!ELEMENT properties (unit-length?)>
+<!ELEMENT properties (unit-length?, output-type?, output-filename?, copies?)>
 <!ELEMENT unit-length (pt | in | cm | mm) #IMPLIED>
+<!ELEMENT output-type (png, pdf, ps, svg, gtk, gtk-default) #IMPLIED>
+<!ELEMENT output-filename CDATA #IMPLIED>
+<!ELEMENT copies CDATA #IMPLIED>
 
 <!ELEMENT page (%objects;)>
 <!ATTLIST page
diff --git a/docs/reference/libreptool-overrides.txt b/docs/reference/libreptool-overrides.txt
new file mode 100644 (file)
index 0000000..e69de29
index 583648f382b590429cb848a787ad465f3c73b3f5..e9a764e825a81084b2489bc5948b6087c71ac268 100644 (file)
@@ -184,6 +184,103 @@ const gchar
        return ret;
 }
 
+/**
+ * rpt_common_stroutputtype_to_enum:
+ * @output_type:
+ *
+ * Returns: the enum value that match the string @output_type.
+ */
+eRptOutputType
+rpt_common_stroutputtype_to_enum (const gchar *output_type)
+{
+       eRptOutputType ret;
+
+       gchar *real_outputtype;
+
+       ret = RPT_OUTPUT_PDF;
+
+       if (output_type != NULL)
+               {
+                       real_outputtype = g_strstrip (g_strdup (output_type));
+                       if (g_ascii_strcasecmp (real_outputtype, "pdf") == 0)
+                               {
+                                       /* already setted */
+                               }
+                       else if (g_ascii_strcasecmp (real_outputtype, "png") == 0)
+                               {
+                                       ret = RPT_OUTPUT_PNG;
+                               }
+                       else if (g_ascii_strcasecmp (real_outputtype, "ps") == 0)
+                               {
+                                       ret = RPT_OUTPUT_PS;
+                               }
+                       else if (g_ascii_strcasecmp (real_outputtype, "svg") == 0)
+                               {
+                                       ret = RPT_OUTPUT_SVG;
+                               }
+                       else if (g_ascii_strcasecmp (real_outputtype, "gtk") == 0)
+                               {
+                                       ret = RPT_OUTPUT_GTK;
+                               }
+                       else if (g_ascii_strcasecmp (real_outputtype, "gtk-default") == 0)
+                               {
+                                       ret = RPT_OUTPUT_GTK_DEFAULT_PRINTER;
+                               }
+                       else
+                               {
+                                       g_warning ("Output type «%s» not available.", real_outputtype);
+                               }
+               }
+
+       return ret;
+}
+
+/**
+ * rpt_common_enum_to_stroutputtype:
+ * @output_type:
+ *
+ * Returns: the string value that represents then enum value @output_type.
+ */
+const gchar
+*rpt_common_enum_to_stroutputtype (eRptOutputType output_type)
+{
+       gchar *ret;
+
+       switch (output_type)
+               {
+                       case RPT_OUTPUT_PDF:
+                               ret = g_strdup ("df");
+                               break;
+
+                       case RPT_OUTPUT_PNG:
+                               ret = g_strdup ("png");
+                               break;
+
+                       case RPT_OUTPUT_PS:
+                               ret = g_strdup ("ps");
+                               break;
+
+                       case RPT_OUTPUT_SVG:
+                               ret = g_strdup ("svg");
+                               break;
+
+                       case RPT_OUTPUT_GTK:
+                               ret = g_strdup ("gtk");
+                               break;
+
+                       case RPT_OUTPUT_GTK_DEFAULT_PRINTER:
+                               ret = g_strdup ("gtk-default");
+                               break;
+
+                       default:
+                               g_warning ("Output type «%d» not available.", output_type);
+                               ret = g_strdup ("pdf");
+                               break;
+               }
+
+       return ret;
+}
+
 /**
  * rpt_common_rptpoint_new:
  *
index 1036864476a633f39dace17a52ca0d955c5e36c7..3b27c69c58b8a7d12d937d3a6f72b04f60e66c38 100644 (file)
@@ -38,6 +38,16 @@ typedef enum
        RPT_UNIT_MILLIMETRE
 } eRptUnitLength;
 
+typedef enum
+{
+       RPT_OUTPUT_PNG,
+       RPT_OUTPUT_PDF,
+       RPT_OUTPUT_PS,
+       RPT_OUTPUT_SVG,
+       RPT_OUTPUT_GTK,
+       RPT_OUTPUT_GTK_DEFAULT_PRINTER
+} eRptOutputType;
+
 /**
  * RptColor:
  * @r: the red channel; value from 0 to 1.
@@ -171,6 +181,9 @@ gdouble rpt_common_points_to_value (eRptUnitLength unit, gdouble value);
 eRptUnitLength rpt_common_strunit_to_enum (const gchar *unit);
 const gchar *rpt_common_enum_to_strunit (eRptUnitLength unit);
 
+eRptOutputType rpt_common_stroutputtype_to_enum (const gchar *output_type);
+const gchar *rpt_common_enum_to_stroutputtype (eRptOutputType output_type);
+
 RptPoint *rpt_common_rptpoint_new (void);
 RptPoint *rpt_common_get_position (xmlNode *xnode);
 void rpt_common_set_position (xmlNode *xnode,
index 37837e239f37035fe096435d3da959f92c2acabd..3b74dd3f244270c3b070fa17ec2715f46454de22 100644 (file)
@@ -39,6 +39,7 @@ enum
        PROP_UNIT_LENGTH,
        PROP_OUTPUT_TYPE,
        PROP_OUTPUT_FILENAME,
+       PROP_COPIES,
        PROP_PATH_RELATIVES_TO
 };
 
@@ -106,6 +107,11 @@ struct _RptPrintPrivate
        {
                eRptUnitLength unit;
 
+               eRptOutputType output_type;
+               gchar *output_filename;
+
+               guint copies;
+
                gdouble width;
                gdouble height;
                gdouble margin_top;
@@ -115,9 +121,6 @@ struct _RptPrintPrivate
 
                xmlDoc *xdoc;
 
-               RptPrintOutputType output_type;
-               gchar *output_filename;
-
                gchar *path_relatives_to;
 
                xmlNodeSet *pages;
@@ -177,17 +180,25 @@ rpt_print_class_init (RptPrintClass *klass)
                                         g_param_spec_int ("output-type",
                                                           "Output Type",
                                                           "The output type.",
-                                                          RPTP_OUTPUT_PNG, RPTP_OUTPUT_GTK,
-                                                          RPTP_OUTPUT_PDF,
+                                                          RPT_OUTPUT_PNG, RPT_OUTPUT_GTK,
+                                                          RPT_OUTPUT_PDF,
                                                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
        g_object_class_install_property (object_class, PROP_OUTPUT_FILENAME,
                                         g_param_spec_string ("output-filename",
                                                              "Output File Name",
                                                              "The output file's name.",
-                                                             "",
+                                                             "rptreport.pdf",
                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
+       g_object_class_install_property (object_class, PROP_COPIES,
+                                        g_param_spec_uint ("copies",
+                                                           "Copies",
+                                                           "The number of copies to print.",
+                                                           1, G_MAXUINT,
+                                                           1,
+                                                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
        g_object_class_install_property (object_class, PROP_PATH_RELATIVES_TO,
                                         g_param_spec_string ("path-relatives-to",
                                                              "Path are relatives to",
@@ -267,8 +278,10 @@ RptPrint
  *
  */
 void
-rpt_print_set_output_type (RptPrint *rpt_print, RptPrintOutputType output_type)
+rpt_print_set_output_type (RptPrint *rpt_print, eRptOutputType output_type)
 {
+       g_return_if_fail (IS_RPT_PRINT (rpt_print));
+
        RptPrintPrivate *priv = RPT_PRINT_GET_PRIVATE (rpt_print);
 
        priv->output_type = output_type;
@@ -283,9 +296,32 @@ rpt_print_set_output_type (RptPrint *rpt_print, RptPrintOutputType output_type)
 void
 rpt_print_set_output_filename (RptPrint *rpt_print, const gchar *output_filename)
 {
+       g_return_if_fail (IS_RPT_PRINT (rpt_print));
+
        RptPrintPrivate *priv = RPT_PRINT_GET_PRIVATE (rpt_print);
 
        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.");
+                       priv->output_filename = g_strdup ("rptreport.pdf");
+               }
+}
+
+/**
+ * rpt_print_set_copies:
+ * @rpt_print: an #RptPrint object.
+ * @copies: number of copies.
+ *
+ */
+void
+rpt_print_set_copies (RptPrint *rpt_print, guint copies)
+{
+       g_return_if_fail (IS_RPT_PRINT (rpt_print));
+
+       RptPrintPrivate *priv = RPT_PRINT_GET_PRIVATE (rpt_print);
+
+       priv->copies = copies;
 }
 
 /**
@@ -344,6 +380,18 @@ rpt_print_print (RptPrint *rpt_print)
                                                                {
                                                                        g_object_set (G_OBJECT (rpt_print), "unit-length", rpt_common_strunit_to_enum ((const gchar *)xmlNodeGetContent (cur_property)), NULL);
                                                                }
+                                                       else if (strcmp (cur_property->name, "output-type") == 0)
+                                                               {
+                                                                       rpt_print_set_output_type (rpt_print, rpt_common_stroutputtype_to_enum ((const gchar *)xmlNodeGetContent (cur_property)));
+                                                               }
+                                                       else if (strcmp (cur_property->name, "output-filename") == 0)
+                                                               {
+                                                                       rpt_print_set_output_filename (rpt_print, (const gchar *)xmlNodeGetContent (cur_property));
+                                                               }
+                                                       else if (strcmp (cur_property->name, "copies") == 0)
+                                                               {
+                                                                       rpt_print_set_copies (rpt_print, strtol ((const gchar *)xmlNodeGetContent (cur_property), NULL, 10));
+                                                               }
 
                                                        cur_property = cur_property->next;
                                                }
@@ -365,8 +413,8 @@ rpt_print_print (RptPrint *rpt_print)
                        return;
                }
 
-       if (priv->output_type == RPTP_OUTPUT_GTK
-           || priv->output_type == RPTP_OUTPUT_GTK_DEFAULT_PRINTER)
+       if (priv->output_type == RPT_OUTPUT_GTK
+           || priv->output_type == RPT_OUTPUT_GTK_DEFAULT_PRINTER)
                {
                        gchar *locale_old;
                        gchar *locale_num;
@@ -385,7 +433,7 @@ rpt_print_print (RptPrint *rpt_print)
 
                        locale_num = setlocale (LC_NUMERIC, "C");
                        gtk_print_operation_run (operation,
-                                                (priv->output_type == RPTP_OUTPUT_GTK ? GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG : GTK_PRINT_OPERATION_ACTION_PRINT),
+                                                (priv->output_type == RPT_OUTPUT_GTK ? GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG : GTK_PRINT_OPERATION_ACTION_PRINT),
                                                 NULL, NULL);
                        setlocale (LC_NUMERIC, locale_num);
                        setlocale (LC_ALL, locale_old);
@@ -396,21 +444,21 @@ rpt_print_print (RptPrint *rpt_print)
                                {
                                        switch (priv->output_type)
                                                {
-                                                       case RPTP_OUTPUT_PNG:
+                                                       case RPT_OUTPUT_PNG:
                                                                priv->output_filename = g_strdup ("reptool.png");
                                                                break;
-                                                       case RPTP_OUTPUT_PDF:
+                                                       case RPT_OUTPUT_PDF:
                                                                priv->output_filename = g_strdup ("reptool.pdf");
                                                                break;
-                                                       case RPTP_OUTPUT_PS:
+                                                       case RPT_OUTPUT_PS:
                                                                priv->output_filename = g_strdup ("reptool.ps");
                                                                break;
-                                                       case RPTP_OUTPUT_SVG:
+                                                       case RPT_OUTPUT_SVG:
                                                                priv->output_filename = g_strdup ("reptool.svg");
                                                                break;
                                                }
                                }
-                       if (priv->output_type != RPTP_OUTPUT_PNG && priv->output_type != RPTP_OUTPUT_SVG)
+                       if (priv->output_type != RPT_OUTPUT_PNG && priv->output_type != RPT_OUTPUT_SVG)
                                {
                                        fout = fopen (priv->output_filename, "w");
                                        if (fout == NULL)
@@ -432,19 +480,19 @@ rpt_print_print (RptPrint *rpt_print)
                                                                        width = rpt_common_value_to_points (priv->unit, priv->width);
                                                                        height = rpt_common_value_to_points (priv->unit, priv->height);
 
-                                                                       if (priv->output_type == RPTP_OUTPUT_PNG)
+                                                                       if (priv->output_type == RPT_OUTPUT_PNG)
                                                                                {
                                                                                        priv->surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, (int)width, (int)height);
                                                                                }
-                                                                       else if (priv->output_type == RPTP_OUTPUT_PDF && npage == 0)
+                                                                       else if (priv->output_type == RPT_OUTPUT_PDF && npage == 0)
                                                                                {
                                                                                        priv->surface = cairo_pdf_surface_create (priv->output_filename, width, height);
                                                                                }
-                                                                       else if (priv->output_type == RPTP_OUTPUT_PS && npage == 0)
+                                                                       else if (priv->output_type == RPT_OUTPUT_PS && npage == 0)
                                                                                {
                                                                                        priv->surface = cairo_ps_surface_create (priv->output_filename, width, height);
                                                                                }
-                                                                       else if (priv->output_type == RPTP_OUTPUT_SVG)
+                                                                       else if (priv->output_type == RPT_OUTPUT_SVG)
                                                                                {
                                                                                        gchar *new_out_filename = rpt_print_new_numbered_filename (priv->output_filename, npage + 1);
                                                                                        fout = fopen (new_out_filename, "w");
@@ -460,7 +508,7 @@ rpt_print_print (RptPrint *rpt_print)
 
                                                                        if (cairo_surface_status (priv->surface) == CAIRO_STATUS_SUCCESS)
                                                                                {
-                                                                                       if (priv->output_type == RPTP_OUTPUT_PNG || priv->output_type == RPTP_OUTPUT_SVG)
+                                                                                       if (priv->output_type == RPT_OUTPUT_PNG || priv->output_type == RPT_OUTPUT_SVG)
                                                                                                {
                                                                                                        priv->cr = cairo_create (priv->surface);
                                                                                                }
@@ -469,7 +517,7 @@ rpt_print_print (RptPrint *rpt_print)
                                                                                                        priv->cr = cairo_create (priv->surface);
                                                                                                }
 
-                                                                                       if (priv->output_type != RPTP_OUTPUT_PNG && priv->output_type != RPTP_OUTPUT_SVG && npage == 0)
+                                                                                       if (priv->output_type != RPT_OUTPUT_PNG && priv->output_type != RPT_OUTPUT_SVG && npage == 0)
                                                                                                {
                                                                                                        cairo_surface_destroy (priv->surface);
                                                                                                }
@@ -478,7 +526,7 @@ rpt_print_print (RptPrint *rpt_print)
                                                                                                {
                                                                                                        rpt_print_page (rpt_print, cur);
 
-                                                                                                       if (priv->output_type == RPTP_OUTPUT_PNG)
+                                                                                                       if (priv->output_type == RPT_OUTPUT_PNG)
                                                                                                                {
                                                                                                                        gchar *new_out_filename = rpt_print_new_numbered_filename (priv->output_filename, npage + 1);
                                                                                                                
@@ -492,7 +540,7 @@ rpt_print_print (RptPrint *rpt_print)
                                                                                                                        cairo_show_page (priv->cr);
                                                                                                                }
 
-                                                                                                       if (priv->output_type == RPTP_OUTPUT_SVG)
+                                                                                                       if (priv->output_type == RPT_OUTPUT_SVG)
                                                                                                                {
                                                                                                                        cairo_surface_destroy (priv->surface);
                                                                                                                        cairo_destroy (priv->cr);
@@ -529,7 +577,7 @@ rpt_print_print (RptPrint *rpt_print)
                                {
                                        cairo_destroy (priv->cr);
                                }
-                       if (priv->output_type != RPTP_OUTPUT_PNG && priv->output_type != RPTP_OUTPUT_SVG)
+                       if (priv->output_type != RPT_OUTPUT_PNG && priv->output_type != RPT_OUTPUT_SVG)
                                {
                                        fclose (fout);
                                }
@@ -557,6 +605,10 @@ rpt_print_set_property (GObject *object, guint property_id, const GValue *value,
                                rpt_print_set_output_filename (rpt_print, g_value_get_string (value));
                                break;
 
+                       case PROP_COPIES:
+                               rpt_print_set_copies (rpt_print, g_value_get_uint (value));
+                               break;
+
                        case PROP_PATH_RELATIVES_TO:
                                priv->path_relatives_to = g_strstrip (g_strdup (g_value_get_string (value)));
                                break;
@@ -588,6 +640,10 @@ rpt_print_get_property (GObject *object, guint property_id, GValue *value, GPara
                                g_value_set_string (value, priv->output_filename);
                                break;
 
+                       case PROP_COPIES:
+                               g_value_set_uint (value, priv->copies);
+                               break;
+
                        case PROP_PATH_RELATIVES_TO:
                                g_value_set_string (value, priv->path_relatives_to);
                                break;
@@ -1324,6 +1380,14 @@ rpt_print_gtk_begin_print (GtkPrintOperation *operation,
        gtk_print_operation_set_default_page_setup (operation, page_set);
        gtk_print_operation_set_unit (operation, GTK_UNIT_POINTS);
        gtk_print_operation_set_n_pages (operation, priv->pages->nodeNr);
+
+       GtkPrintSettings *settings = gtk_print_operation_get_print_settings (operation);
+       if (settings == NULL)
+               {
+                       settings = gtk_print_settings_new ();
+               }
+       gtk_print_settings_set_n_copies (settings, priv->copies);
+       gtk_print_operation_set_print_settings (operation, settings);
 }
 
 static void
index 01a8b88d62b513938c70ab122d190c21132f78d7..a1a91cd694c3b5d55cffef0d6f8438c8e55a7cb7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2007 Andrea Zagli <azagli@inwind.it>
+ * Copyright (C) 2006-2010 Andrea Zagli <azagli@inwind.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,6 +24,8 @@
 #include <glib-object.h>
 #include <libxml/tree.h>
 
+#include "rptcommon.h"
+
 G_BEGIN_DECLS
 
 
@@ -51,22 +53,14 @@ struct _RptPrintClass
 GType rpt_print_get_type (void) G_GNUC_CONST;
 
 
-typedef enum
-{
-       RPTP_OUTPUT_PNG,
-       RPTP_OUTPUT_PDF,
-       RPTP_OUTPUT_PS,
-       RPTP_OUTPUT_SVG,
-       RPTP_OUTPUT_GTK,
-       RPTP_OUTPUT_GTK_DEFAULT_PRINTER
-} RptPrintOutputType;
-
 RptPrint *rpt_print_new_from_xml (xmlDoc *xdoc);
 RptPrint *rpt_print_new_from_file (const gchar *filename);
 
-void rpt_print_set_output_type (RptPrint *rpt_print, RptPrintOutputType output_type);
+void rpt_print_set_output_type (RptPrint *rpt_print, eRptOutputType output_type);
 void rpt_print_set_output_filename (RptPrint *rpt_print, const gchar *output_filename);
 
+void rpt_print_set_copies (RptPrint *rpt_print, guint copies);
+
 void rpt_print_print (RptPrint *rpt_print);
 
 
index b3dd5309796a6375b2cf5e3b7426aeb51c59e461..25a9cbb29139b80230c2e7cda9c3a1a8abee3c90 100644 (file)
@@ -132,7 +132,7 @@ static void rpt_report_rptprint_section (RptReport *rpt_report,
                                          gdouble *cur_y,
                                          RptReportSection section,
                                          gint row);
-                                                                         
+
 static void rpt_report_rptprint_parse_text_source (RptReport *rpt_report,
                                                    RptObject *rptobj,
                                                    xmlNode *xnode,
@@ -148,6 +148,11 @@ struct _RptReportPrivate
        {
                eRptUnitLength unit;
 
+               eRptOutputType output_type;
+               gchar *output_filename;
+
+               guint copies;
+
                Database *db;
 
                Page *page;
@@ -251,6 +256,10 @@ rpt_report_init (RptReport *rpt_report)
        priv->body->height = 0.0;
        priv->body->objects = NULL;
        priv->body->new_page_after = FALSE;
+
+       priv->output_type = RPT_OUTPUT_PDF;
+       priv->output_filename = g_strdup ("rptreport.pdf");
+       priv->copies = 1;
 }
 
 /**
@@ -331,6 +340,18 @@ RptReport
                                                                                                {
                                                                                                        g_object_set (G_OBJECT (rpt_report), "unit-length", rpt_common_strunit_to_enum ((const gchar *)xmlNodeGetContent (cur_property)), NULL);
                                                                                                }
+                                                                                       else if (strcmp (cur_property->name, "output-type") == 0)
+                                                                                               {
+                                                                                                       rpt_report_set_output_type (rpt_report, rpt_common_stroutputtype_to_enum ((const gchar *)xmlNodeGetContent (cur_property)));
+                                                                                               }
+                                                                                       else if (strcmp (cur_property->name, "output-filename") == 0)
+                                                                                               {
+                                                                                                       rpt_report_set_output_filename (rpt_report, (const gchar *)xmlNodeGetContent (cur_property));
+                                                                                               }
+                                                                                       else if (strcmp (cur_property->name, "copies") == 0)
+                                                                                               {
+                                                                                                       rpt_report_set_copies (rpt_report, strtol ((const gchar *)xmlNodeGetContent (cur_property), NULL, 10));
+                                                                                               }
 
                                                                                        cur_property = cur_property->next;
                                                                                }
@@ -517,6 +538,59 @@ RptReport
        return rpt_report;
 }
 
+/**
+ * rpt_report_set_output_type:
+ * @rpt_report:
+ * @output_type:
+ *
+ */
+void
+rpt_report_set_output_type (RptReport *rpt_report, eRptOutputType output_type)
+{
+       g_return_if_fail (IS_RPT_REPORT (rpt_report));
+
+       RptReportPrivate *priv = RPT_REPORT_GET_PRIVATE (rpt_report);
+
+       priv->output_type = output_type;
+}
+
+/**
+ * rpt_report_set_output_filename:
+ * @rpt_report:
+ * @output_filename:
+ *
+ */
+void
+rpt_report_set_output_filename (RptReport *rpt_report, const gchar *output_filename)
+{
+       g_return_if_fail (IS_RPT_REPORT (rpt_report));
+
+       RptReportPrivate *priv = RPT_REPORT_GET_PRIVATE (rpt_report);
+
+       priv->output_filename = g_strstrip (g_strdup (output_filename));
+       if (g_strcmp0 (priv->output_filename, "") == 0)
+               {
+                       g_warning ("It's not possible to set an empty output filename.");
+                       priv->output_filename = g_strdup ("rptreport.pdf");
+               }
+}
+
+/**
+ * rpt_report_set_copies:
+ * @rpt_report:
+ * @copies:
+ *
+ */
+void
+rpt_report_set_copies (RptReport *rpt_report, guint copies)
+{
+       g_return_if_fail (IS_RPT_REPORT (rpt_report));
+
+       RptReportPrivate *priv = RPT_REPORT_GET_PRIVATE (rpt_report);
+
+       priv->copies = copies;
+}
+
 /**
  * rpt_report_database_get_provider:
  * @rpt_report:
@@ -1127,6 +1201,18 @@ xmlDoc
        xmlNodeSetContent (xnode, rpt_common_enum_to_strunit (priv->unit));
        xmlAddChild (xnodeprop, xnode);
 
+       xnode = xmlNewNode (NULL, "output-type");
+       xmlNodeSetContent (xnode, rpt_common_enum_to_stroutputtype (priv->output_type));
+       xmlAddChild (xnodeprop, xnode);
+
+       xnode = xmlNewNode (NULL, "output-filename");
+       xmlNodeSetContent (xnode, priv->output_filename);
+       xmlAddChild (xnodeprop, xnode);
+
+       xnode = xmlNewNode (NULL, "copies");
+       xmlNodeSetContent (xnode, g_strdup_printf ("%d", priv->copies));
+       xmlAddChild (xnodeprop, xnode);
+
        if (priv->db != NULL)
                {
                        xmlNode *xnodedb = xmlNewNode (NULL, "database");
@@ -1229,6 +1315,18 @@ xmlDoc
        xmlNodeSetContent (xnode, rpt_common_enum_to_strunit (priv->unit));
        xmlAddChild (xnodeprop, xnode);
 
+       xnode = xmlNewNode (NULL, "output-type");
+       xmlNodeSetContent (xnode, rpt_common_enum_to_stroutputtype (priv->output_type));
+       xmlAddChild (xnodeprop, xnode);
+
+       xnode = xmlNewNode (NULL, "output-filename");
+       xmlNodeSetContent (xnode, priv->output_filename);
+       xmlAddChild (xnodeprop, xnode);
+
+       xnode = xmlNewNode (NULL, "copies");
+       xmlNodeSetContent (xnode, g_strdup_printf ("%d", priv->copies));
+       xmlAddChild (xnodeprop, xnode);
+
        if (priv->db != NULL)
                {
                        gint row;
index 2b728ba9244856b38ededf457ab4c9014c0da3d2..9a8151170ba734dc5c9ac018979cc6562950b767 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Andrea Zagli <azagli@inwind.it>
+ * Copyright (C) 2007-2010 Andrea Zagli <azagli@inwind.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -70,6 +70,11 @@ RptReport *rpt_report_new (void);
 RptReport *rpt_report_new_from_xml (xmlDoc *xdoc);
 RptReport *rpt_report_new_from_file (const gchar *filename);
 
+void rpt_report_set_output_type (RptReport *rpt_report, eRptOutputType output_type);
+void rpt_report_set_output_filename (RptReport *rpt_report, const gchar *output_filename);
+
+void rpt_report_set_copies (RptReport *rpt_report, guint copies);
+
 const gchar *rpt_report_database_get_provider (RptReport *rpt_report);
 const gchar *rpt_report_database_get_connection_string (RptReport *rpt_report);
 const gchar *rpt_report_database_get_sql (RptReport *rpt_report);
@@ -107,7 +112,7 @@ void rpt_report_section_remove (RptReport *rpt_report, RptReportSection section)
 gboolean rpt_report_get_report_header_new_page_after (RptReport *rpt_report);
 void rpt_report_set_report_header_new_page_after (RptReport *rpt_report,
                                                   gboolean new_page_after);
-                                                                                                 
+
 gboolean rpt_report_get_report_footer_new_page_before (RptReport *rpt_report);
 void rpt_report_set_report_footer_new_page_before (RptReport *rpt_report,
                                                    gboolean new_page_before);
index 4f8d264e3ac9ab26b86ccd3c98b01f06405cc1a2..eff361b2a02424291fb45c3029101027c8ef2965 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2007 Andrea Zagli <azagli@inwind.it>
+ * Copyright (C) 2006-2010 Andrea Zagli <azagli@inwind.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
@@ -29,7 +29,7 @@ main (int argc, char **argv)
 
        if (rptp != NULL)
                {
-                       rpt_print_set_output_type (rptp, RPTP_OUTPUT_PNG);
+                       rpt_print_set_output_type (rptp, RPT_OUTPUT_PNG);
                        rpt_print_set_output_filename (rptp, "test.png");
                        rpt_print_print (rptp);
                }
index 45b9638429e279365f9186b3f854d147e5b442a6..23ccacf11c60b01938517c62194c35b066561627 100644 (file)
@@ -67,7 +67,7 @@ main (int argc, char **argv)
                        rptp = rpt_print_new_from_xml (rptprint);
                        if (rptp != NULL)
                                {
-                                       rpt_print_set_output_type (rptp, RPTP_OUTPUT_PDF);
+                                       rpt_print_set_output_type (rptp, RPT_OUTPUT_PDF);
                                        rpt_print_set_output_filename (rptp, "test.pdf");
                                        rpt_print_print (rptp);
                                }
index e85cb7792bffda6a4a16997f3750cc5ddfa9e285..f2156af7b65170d7076b789d8aaa887cc4b83f70 100644 (file)
@@ -121,7 +121,7 @@ main (int argc, char **argv)
                        rptp = rpt_print_new_from_xml (rptprint);
                        if (rptp != NULL)
                                {
-                                       rpt_print_set_output_type (rptp, RPTP_OUTPUT_PDF);
+                                       rpt_print_set_output_type (rptp, RPT_OUTPUT_PDF);
                                        rpt_print_set_output_filename (rptp, "test_report_created.pdf");
                                        rpt_print_print (rptp);
                                }