<!ELEMENT reptool (properties?, database?, page, report)>
-<!ELEMENT properties (name?, description?, unit-length?, output-type?, output-filename?, copies?)>
+<!ELEMENT properties (name?, description?, unit-length?, output-type?, output-filename?, copies?, translation?)>
<!ELEMENT name CDATA #IMPLIED>
<!ELEMENT description CDATA #IMPLIED>
<!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 translation EMPTY>
+<!ATTLIST translation
+ x CDATA #REQUIRED
+ y CDATA #REQUIRED
+>
<!ELEMENT database (provider, connection-string, sql)>
<!ELEMENT provider (#PCDATA)>
"text*, line*, rect*, ellipse*, image*"
>
+<!ENTITY % object_commons_attrs
+ "visible (y | n) #IMPLIED"
+>
+
<!ENTITY % object_position_attrs
"x CDATA #REQUIRED
y CDATA #REQUIRED
- visible (y | n) #IMPLIED"
>
<!ENTITY % object_size_attrs
<!ELEMENT text (#PCDATA)>
<!ATTLIST text
+ %object_common_attrs;
%object_position_attrs;
%object_size_attrs;
%object_rotation_attrs;
<!ELEMENT line EMPTY>
<!ATTLIST line
+ %object_common_attrs;
%object_poisition_attrs;
%object_size_attrs;
%object_rotation_attrs;
<!ELEMENT rect EMPTY>
<!ATTLIST rect
+ %object_common_attrs;
%object_poisition_attrs;
%object_size_attrs;
%object_rotation_attrs;
<!ELEMENT ellipse EMPTY>
<!ATTLIST ellipse
+ %object_common_attrs;
%object_poisition_attrs;
%object_size_attrs;
%object_rotation_attrs;
<!ELEMENT image EMPTY>
<!ATTLIST image
+ %object_common_attrs;
%object_position_attrs;
%object_size_attrs;
%object_rotation_attrs;
<!ELEMENT reptool_report (properties?, page*)>
-<!ELEMENT properties (name?, description?, unit-length?, output-type?, output-filename?, copies?)>
+<!ELEMENT properties (name?, description?, unit-length?, output-type?, output-filename?, copies?, translation?)>
<!ELEMENT name CDATA #IMPLIED>
<!ELEMENT description CDATA #IMPLIED>
<!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 translation EMPTY>
+<!ATTLIST translation
+ x CDATA #REQUIRED
+ y CDATA #REQUIRED
+>
<!ELEMENT page (%objects;)>
<!ATTLIST page
}
}
+/**
+ * rpt_common_rpttranslation_new:
+ *
+ * Returns: an new allocated #RptTranslation struct.
+ */
+RptTranslation
+*rpt_common_rpttranslation_new (void)
+{
+ RptTranslation *translation;
+
+ translation = (RptTranslation *)g_new0 (RptTranslation, 1);
+ translation->x = 0.0;
+ translation->y = 0.0;
+
+ return translation;
+}
+
+/**
+ * rpt_common_rpttranslation_new_with_values:
+ * @x:
+ * @y:
+ *
+ * Returns: an new allocated #RptTranslation struct.
+ */
+RptTranslation
+*rpt_common_rpttranslation_new_with_values (gdouble x, gdouble y)
+{
+ RptTranslation *translation;
+
+ translation = rpt_common_rpttranslation_new ();
+ translation->x = x;
+ translation->y = y;
+
+ return translation;
+}
+
+/**
+ * rpt_common_get_translation:
+ * @xnode: an #xmlNode.
+ *
+ * Returns: an #RptTranslation struct that represent the object's rotation
+ * specified on @xnode.
+ */
+RptTranslation
+*rpt_common_get_translation (xmlNode *xnode)
+{
+ gchar *prop;
+ RptTranslation *translation = NULL;
+
+ gdouble x;
+ gdouble y;
+
+ /* TODO try the first level of children */
+ if (xmlStrcmp (xnode->name, "translation") == 0)
+ {
+ x = 0.0;
+ y = 0.0;
+
+ prop = xmlGetProp (xnode, "x");
+ if (prop != NULL)
+ {
+ translation = rpt_common_rpttranslation_new ();
+ translation->x = g_strtod (prop, NULL);
+ xmlFree (prop);
+ }
+ prop = xmlGetProp (xnode, "y");
+ if (prop != NULL)
+ {
+ if (translation == NULL)
+ {
+ translation = rpt_common_rpttranslation_new ();
+ }
+ translation->y = g_strtod (prop, NULL);
+ xmlFree (prop);
+ }
+ }
+
+ return translation;
+}
+
+/**
+ * rpt_common_set_translation:
+ * @xnode: an #xmlNode.
+ * @rotation:
+ *
+ */
+void
+rpt_common_set_translation (xmlNode *xnode, const RptTranslation *translation)
+{
+ xmlNode *_node;
+
+ if (translation != NULL)
+ {
+ _node = NULL;
+ if (xmlStrcmp (xnode->name, "translation") == 0)
+ {
+ _node = xnode;
+ }
+ else
+ {
+ _node = xmlNewNode (NULL, "translation");
+ xmlAddChild (xnode, _node);
+ }
+
+ if (_node != NULL)
+ {
+ xmlSetProp (_node, "x", g_strdup_printf ("%f", translation->x));
+ xmlSetProp (_node, "y", g_strdup_printf ("%f", translation->y));
+ }
+ }
+}
+
/**
* rpt_common_rptrotation_new:
*
};
typedef struct _RptSize RptSize;
+struct _RptTranslation
+{
+ gdouble x;
+ gdouble y;
+};
+typedef struct _RptTranslation RptTranslation;
+
struct _RptRotation
{
gdouble angle;
void rpt_common_set_size (xmlNode *xnode,
const RptSize *size);
+RptTranslation *rpt_common_rpttranslation_new (void);
+RptTranslation *rpt_common_rpttranslation_new_with_values (gdouble x, gdouble y);
+RptTranslation *rpt_common_get_translation (xmlNode *xnode);
+void rpt_common_set_translation (xmlNode *xnode,
+ const RptTranslation *translation);
+
RptRotation *rpt_common_rptrotation_new (void);
RptRotation *rpt_common_rptrotation_new_with_values (gdouble angle);
RptRotation *rpt_common_get_rotation (xmlNode *xnode);
PROP_OUTPUT_TYPE,
PROP_OUTPUT_FILENAME,
PROP_COPIES,
+ PROP_TRANSLATION,
PROP_PATH_RELATIVES_TO
};
GtkPrintSettings *gtk_print_settings;
+ RptTranslation *translation;
+
gchar *path_relatives_to;
gdouble width;
1,
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_TRANSLATION,
+ g_param_spec_pointer ("translation",
+ "Translation",
+ "Translation of the entire report.",
+ G_PARAM_READWRITE));
+
g_object_class_install_property (object_class, PROP_PATH_RELATIVES_TO,
g_param_spec_string ("path-relatives-to",
"Path are relatives to",
priv->output_filename = NULL;
priv->gtk_print_settings = NULL;
priv->path_relatives_to = g_strdup ("");
+ priv->translation = NULL;
priv->surface = NULL;
priv->cr = NULL;
gtk_print_settings_set_n_copies (priv->gtk_print_settings, copies);
}
+/**
+ * rpt_print_set_translation:
+ * @rpt_print: an #RptPrint object.
+ * @translation: an #RptTranslation struct.
+ *
+ */
+void
+rpt_print_set_translation (RptPrint *rpt_print, RptTranslation *translation)
+{
+ g_return_if_fail (IS_RPT_PRINT (rpt_print));
+
+ RptPrintPrivate *priv = RPT_PRINT_GET_PRIVATE (rpt_print);
+
+ if (priv->translation != NULL)
+ {
+ g_free (priv->translation);
+ priv->translation = NULL;
+ }
+ if (translation != NULL)
+ {
+ priv->translation = rpt_common_rpttranslation_new_with_values (translation->x, translation->y);
+ }
+}
+
/**
* rpt_print_print:
* @rpt_print: an #RptPrint object.
{
rpt_print_set_copies (rpt_print, strtol ((const gchar *)xmlNodeGetContent (cur_property), NULL, 10));
}
+ else if (g_strcmp0 (cur_property->name, "translation") == 0
+ && priv->translation == NULL)
+ {
+ rpt_print_set_translation (rpt_print, rpt_common_get_translation (cur_property));
+ }
cur_property = cur_property->next;
}
rpt_print_set_copies (rpt_print, g_value_get_uint (value));
break;
+ case PROP_TRANSLATION:
+ rpt_print_set_translation (rpt_print, g_value_get_pointer (value));
+ break;
+
case PROP_PATH_RELATIVES_TO:
priv->path_relatives_to = g_strstrip (g_strdup (g_value_get_string (value)));
break;
}
break;
+ case PROP_TRANSLATION:
+ g_value_set_pointer (value, priv->translation);
+ break;
+
case PROP_PATH_RELATIVES_TO:
g_value_set_string (value, priv->path_relatives_to);
break;
gtk_print_context_get_width (priv->gtk_print_context) / rpt_common_value_to_points (priv->unit, priv->width),
gtk_print_context_get_height (priv->gtk_print_context) / rpt_common_value_to_points (priv->unit, priv->height));
+ if (priv->translation != NULL)
+ {
+ cairo_translate (priv->cr, priv->translation->x, priv->translation->y);
+ }
+
if (priv->width != 0 && priv->height != 0)
{
rpt_print_page (rpt_print, priv->pages->nodeTab[page_nr]);
void rpt_print_set_gtkprintsettings (RptPrint *rpt_print, GtkPrintSettings *settings);
void rpt_print_set_copies (RptPrint *rpt_print, guint copies);
+void rpt_print_set_translation (RptPrint *rpt_print, RptTranslation *translation);
void rpt_print_print (RptPrint *rpt_print, GtkWindow *transient);
PROP_0,
PROP_UNIT_LENGTH,
PROP_NAME,
- PROP_DESCRIPTION
+ PROP_DESCRIPTION,
+ PROP_TRANSLATION
};
static void rpt_report_class_init (RptReportClass *klass);
typedef struct _RptReportPrivate RptReportPrivate;
struct _RptReportPrivate
{
+ gchar *name;
+ gchar *description;
+
eRptUnitLength unit;
eRptOutputType output_type;
guint copies;
+ RptTranslation *translation;
+
Database *db;
Page *page;
PageFooter *page_footer;
Body *body;
- gchar *name;
- gchar *description;
-
guint cur_page;
gint cur_row;
GtkTreeIter *cur_iter;
"Report's description.",
"",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_TRANSLATION,
+ g_param_spec_pointer ("translation",
+ "Translation",
+ "Translation of the entire report.",
+ G_PARAM_READWRITE));
/**
* RptReport::field-request:
{
RptReportPrivate *priv = RPT_REPORT_GET_PRIVATE (rpt_report);
+ priv->output_type = RPT_OUTPUT_PDF;
+ priv->output_filename = g_strdup ("rptreport.pdf");
+ priv->copies = 1;
+ priv->translation = NULL;
+
priv->db = NULL;
priv->page = (Page *)g_malloc0 (sizeof (Page));
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;
-
priv->cur_row = -1;
priv->cur_iter = NULL;
}
{
rpt_report_set_copies (rpt_report, strtol ((const gchar *)xmlNodeGetContent (cur_property), NULL, 10));
}
+ else if (g_strcmp0 (cur_property->name, "translation") == 0)
+ {
+ rpt_report_set_translation (rpt_report, rpt_common_get_translation (cur_property));
+ }
cur_property = cur_property->next;
}
priv->copies = copies;
}
+/**
+ * rpt_report_set_translation:
+ * @rpt_report:
+ * @translation:
+ *
+ */
+void
+rpt_report_set_translation (RptReport *rpt_report, RptTranslation *translation)
+{
+ g_return_if_fail (IS_RPT_REPORT (rpt_report));
+
+ RptReportPrivate *priv = RPT_REPORT_GET_PRIVATE (rpt_report);
+
+ if (priv->translation != NULL)
+ {
+ g_free (priv->translation);
+ priv->translation = NULL;
+ }
+ if (translation != NULL)
+ {
+ priv->translation = rpt_common_rpttranslation_new_with_values (translation->x, translation->y);
+ }
+}
+
/**
* rpt_report_database_get_provider:
* @rpt_report:
xmlNodeSetContent (xnode, g_strdup_printf ("%d", priv->copies));
xmlAddChild (xnodeprop, xnode);
+ if (priv->translation != NULL)
+ {
+ rpt_common_set_translation (xnodeprop, priv->translation);
+ }
+
if (priv->db != NULL)
{
xmlNode *xnodedb = xmlNewNode (NULL, "database");
rpt_report_rptprint_set_output_type (xdoc, priv->output_type);
rpt_report_rptprint_set_output_filename (xdoc, priv->output_filename);
rpt_report_rptprint_set_copies (xdoc, priv->copies);
+ if (priv->translation != NULL)
+ {
+ rpt_report_rptprint_set_translation (xdoc, priv->translation);
+ }
if (priv->db != NULL)
{
xmlAddChild (xnodeprop, xnode);
}
+void
+rpt_report_rptprint_set_translation (xmlDoc *xdoc, RptTranslation *translation)
+{
+ xmlNode *xnodeprop;
+ xmlNode *xnode;
+ xmlNode *xroot;
+
+ xnodeprop = rpt_report_rptprint_get_properties_node (xdoc);
+ if (xnodeprop == NULL)
+ {
+ xroot = xmlDocGetRootElement (xdoc);
+ xnodeprop = xmlNewNode (NULL, "properties");
+ xmlAddChild (xroot, xnodeprop);
+ }
+
+ /* TODO
+ * replace eventually already present node */
+ rpt_common_set_translation (xnodeprop, translation);
+}
+
xmlNode
*rpt_report_rptprint_page_new (xmlDoc *xdoc, RptSize *size, RptMargin *margin)
{
priv->unit = g_value_get_int (value);
break;
+ case PROP_TRANSLATION:
+ priv->translation = g_value_get_pointer (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
g_value_set_int (value, priv->unit);
break;
+ case PROP_TRANSLATION:
+ g_value_set_pointer (value, priv->translation);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
void rpt_report_set_output_filename (RptReport *rpt_report, const gchar *output_filename);
void rpt_report_set_copies (RptReport *rpt_report, guint copies);
+void rpt_report_set_translation (RptReport *rpt_report, RptTranslation *translation);
const gchar *rpt_report_database_get_provider (RptReport *rpt_report);
const gchar *rpt_report_database_get_connection_string (RptReport *rpt_report);
void rpt_report_rptprint_set_output_type (xmlDoc *xdoc, eRptOutputType output_type);
void rpt_report_rptprint_set_output_filename (xmlDoc *xdoc, const gchar *output_filename);
void rpt_report_rptprint_set_copies (xmlDoc *xdoc, guint copies);
+void rpt_report_rptprint_set_translation (xmlDoc *xdoc, RptTranslation *translation);
xmlNode *rpt_report_rptprint_page_new (xmlDoc *xdoc, RptSize *size, RptMargin *margin);
void rpt_report_rptprint_page_add_object (xmlNode *xnodepage, RptObject *rpt_object);