]> saetta.ns0.it Git - reptool/libreptool/commitdiff
Added functions RptCommon::rptpoint_new_with_values, refactor
authorAndrea Zagli <azagli@libero.it>
Sat, 16 Jul 2011 09:44:42 +0000 (11:44 +0200)
committerAndrea Zagli <azagli@libero.it>
Sat, 16 Jul 2011 09:44:42 +0000 (11:44 +0200)
RptCommon::rptsize_new_with_values, RptCommon::rptrotation_new_with_values
and RptCommon::rptmargin_new_with_values.

src/rptcommon.c
src/rptcommon.h

index aa9bbfd4582f2d9f92f24e777345533dd26f09e2..af2ecaf8a1712d221f5fc5bb30526ca5bd9f95c3 100644 (file)
@@ -298,6 +298,25 @@ RptPoint
        return point;
 }
 
+/**
+ * rpt_common_rptpoint_new_with_values:
+ * @x:
+ * @y:
+ *
+ * Returns: an new allocated #RptPoint struct.
+ */
+RptPoint
+*rpt_common_rptpoint_new_with_values (gdouble x, gdouble y)
+{
+       RptPoint *point;
+
+       point = rpt_common_rptpoint_new ();
+       point->x = x;
+       point->y = y;
+
+       return point;
+}
+
 /**
  * rpt_common_get_position:
  * @xnode: an #xmlNode.
@@ -358,6 +377,25 @@ RptSize
        return size;
 }
 
+/**
+ * rpt_common_rptsize_new_with_values:
+ * @width:
+ * @height:
+ *
+ * Returns: an new allocated #RptSize struct.
+ */
+RptSize
+*rpt_common_rptsize_new_with_values (gdouble width, gdouble height)
+{
+       RptSize *size;
+
+       size = rpt_common_rptsize_new ();
+       size->width = width;
+       size->height = height;
+
+       return size;
+}
+
 /**
  * rpt_common_get_size:
  * @xnode: an #xmlNode.
@@ -376,9 +414,8 @@ RptSize
        height = xmlGetProp (xnode, (const xmlChar *)"height");
        if (width != NULL && height != NULL)
                {
-                       size = rpt_common_rptsize_new ();
-                       size->width = strtod (width, NULL);
-                       size->height = strtod (height, NULL);
+                       size = rpt_common_rptsize_new_with_values (g_strtod (width, NULL),
+                                                                  g_strtod (height, NULL));
                }
 
        return size;
@@ -416,6 +453,23 @@ RptRotation
        return rotation;
 }
 
+/**
+ * rpt_common_rptrotation_new_with_values:
+ * @angle:
+ *
+ * Returns: an new allocated #RptRotation struct.
+ */
+RptRotation
+*rpt_common_rptrotation_new_with_values (gdouble angle)
+{
+       RptRotation *rotation;
+
+       rotation = rpt_common_rptrotation_new ();
+       rotation->angle = angle;
+
+       return rotation;
+}
+
 /**
  * rpt_common_get_rotation:
  * @xnode: an #xmlNode.
@@ -473,6 +527,32 @@ RptMargin
        return margin;
 }
 
+/**
+ * rpt_common_rptmargin_new_with_values:
+ * @top:
+ * @right:
+ * @bottom:
+ * @left:
+ *
+ * Returns: an new allocated #RptMargin struct.
+ */
+RptMargin
+*rpt_common_rptmargin_new_with_values (gdouble top,
+                                       gdouble right,
+                                       gdouble bottom,
+                                       gdouble left)
+{
+       RptMargin *margin;
+
+       margin = rpt_common_rptmargin_new ();
+       margin->top = top;
+       margin->right = right;
+       margin->bottom = bottom;
+       margin->left = left;
+
+       return margin;
+}
+
 /**
  * rpt_common_get_margin:
  * @xnode: an #xmlNode.
index ad1d813af48c40ad51d7e2f2bdeb78aee844d4c3..0622d2a5c56271cf7f8effcaf7a737c0dabc2d12 100644 (file)
@@ -194,21 +194,28 @@ 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_rptpoint_new_with_values (gdouble x, gdouble y);
 RptPoint *rpt_common_get_position (xmlNode *xnode);
 void rpt_common_set_position (xmlNode *xnode,
                               const RptPoint *position);
 
 RptSize *rpt_common_rptsize_new (void);
+RptSize *rpt_common_rptsize_new_with_values (gdouble width, gdouble height);
 RptSize *rpt_common_get_size (xmlNode *xnode);
 void rpt_common_set_size (xmlNode *xnode,
                           const RptSize *size);
 
 RptRotation *rpt_common_rptrotation_new (void);
+RptRotation *rpt_common_rptrotation_new_with_values (gdouble angle);
 RptRotation *rpt_common_get_rotation (xmlNode *xnode);
 void rpt_common_set_rotation (xmlNode *xnode,
                               const RptRotation *rotation);
 
 RptMargin *rpt_common_rptmargin_new (void);
+RptMargin *rpt_common_rptmargin_new_with_values (gdouble top,
+                                                 gdouble right,
+                                                 gdouble bottom,
+                                                 gdouble left);
 RptMargin *rpt_common_get_margin (xmlNode *xnode);
 void rpt_common_set_margin (xmlNode *xnode,
                             const RptMargin *margin);