]> saetta.ns0.it Git - reptool/libreptool/commitdiff
Bugfix on PangoFontDescription creation (font-size is float not int).
authorAndrea Zagli <azagli@libero.it>
Mon, 6 Sep 2010 14:25:49 +0000 (16:25 +0200)
committerAndrea Zagli <azagli@libero.it>
Mon, 6 Sep 2010 14:25:49 +0000 (16:25 +0200)
Added some output on error.

src/libreptool.h
src/rptprint.c

index 80fd1e7c16ec2fd0205ca4ecbbb0e260bbc916aa..d8bb5320d517f0b531e2b1229f8ff77ceeae6546 100644 (file)
 #ifndef __LIBREPTOOL_H__
 #define __LIBREPTOOL_H__
 
-#include <rptreport.h>
-#include <rptcommon.h>
-#include <rptobject.h>
-#include <rptobjectellipse.h>
-#include <rptobjectimage.h>
-#include <rptobjectline.h>
-#include <rptobjectrect.h>
-#include <rptobjecttext.h>
-#include <rptprint.h>
+#include <libreptool/rptreport.h>
+#include <libreptool/rptcommon.h>
+#include <libreptool/rptobject.h>
+#include <libreptool/rptobjectellipse.h>
+#include <libreptool/rptobjectimage.h>
+#include <libreptool/rptobjectline.h>
+#include <libreptool/rptobjectrect.h>
+#include <libreptool/rptobjecttext.h>
+#include <libreptool/rptprint.h>
 
 #endif /* __LIBREPTOOL_H__ */
index e2eddcbe1daefc232794150ce183aaa07a3babdd..0fb19acea9abb8570ac7aac4a8e2871115e9a14b 100644 (file)
@@ -367,6 +367,7 @@ rpt_print_print (RptPrint *rpt_print)
                                        if (fout == NULL)
                                                {
                                                        /* TO DO */
+                                                       g_warning ("Unable to write to the output file.");
                                                        return;
                                                }
                                }
@@ -398,6 +399,7 @@ rpt_print_print (RptPrint *rpt_print)
                                                                                        if (fout == NULL)
                                                                                                {
                                                                                                        /* TO DO */
+                                                                                                       g_warning ("Unable to write to the output file.");
                                                                                                        return;
                                                                                                }
                
@@ -647,7 +649,7 @@ rpt_print_text_xml (RptPrint *rpt_print, xmlNode *xnode)
 
        if (position == NULL)
                {
-                       /* TO DO */
+                       g_warning ("Text node position is mandatory.");
                        return;
                }
 
@@ -696,9 +698,9 @@ rpt_print_text_xml (RptPrint *rpt_print, xmlNode *xnode)
                {
                        str_font = g_strconcat (str_font, " italic", NULL);
                }
-       if (font->size > 0)
+       if (font->size > 0.0f)
                {
-                       str_font = g_strconcat (str_font, g_strdup_printf (" %d", font->size), NULL);
+                       str_font = g_strconcat (str_font, g_strdup_printf (" %f", font->size), NULL);
                }
        else
                {
@@ -707,6 +709,12 @@ rpt_print_text_xml (RptPrint *rpt_print, xmlNode *xnode)
 
        /* creating pango font description */
        pfdesc = pango_font_description_from_string (str_font);
+       if (pfdesc == NULL)
+               {
+                       g_warning ("Unable to create a PangoFontDescription from the string: %s", str_font);
+                       return;
+               }
+
        pango_layout_set_font_description (playout, pfdesc);
        pango_font_description_free (pfdesc);
 
@@ -874,6 +882,7 @@ rpt_print_rect_xml (RptPrint *rpt_print, xmlNode *xnode)
 
        if (position == NULL || size == NULL)
                {
+                       g_warning ("Rect node position and size are mandatories.");
                        return;
                }
        if (stroke == NULL)
@@ -936,6 +945,7 @@ rpt_print_ellipse_xml (RptPrint *rpt_print, xmlNode *xnode)
 
        if (position == NULL || size == NULL)
                {
+                       g_warning ("Ellipse node position and size are mandatories.");
                        return;
                }
        if (stroke == NULL)
@@ -991,6 +1001,7 @@ rpt_print_image_xml (RptPrint *rpt_print, xmlNode *xnode)
        gchar *filename= xmlGetProp (xnode, (const xmlChar *)"source");
        if (filename == NULL)
                {
+                       g_warning ("Image node source is mandatory.");
                        return;
                }
 
@@ -1010,6 +1021,11 @@ rpt_print_image_xml (RptPrint *rpt_print, xmlNode *xnode)
        border = rpt_common_get_border (xnode);
 
        image = cairo_image_surface_create_from_png (filename);
+       if (cairo_surface_status (image) != CAIRO_STATUS_SUCCESS)
+               {
+                       g_warning ("Unable to create the cairo surface from the image «%s».", filename);
+                       return;
+               }
 
        pattern = cairo_pattern_create_for_surface (image);
 
@@ -1053,7 +1069,11 @@ rpt_print_line (RptPrint *rpt_print, const RptPoint *from_p, const RptPoint *to_
 {
        RptPrintPrivate *priv = RPT_PRINT_GET_PRIVATE (rpt_print);
 
-       if (from_p == NULL || to_p == NULL) return;
+       if (from_p == NULL || to_p == NULL)
+               {
+                       g_warning ("Line node from point and to point are mandatories.");
+                       return;
+               }
 
        if (stroke != NULL)
                {
@@ -1103,7 +1123,11 @@ rpt_print_border (RptPrint *rpt_print, const RptPoint *position, const RptSize *
 {
        RptPrintPrivate *priv = RPT_PRINT_GET_PRIVATE (rpt_print);
 
-       if (position == NULL || size == NULL || border == NULL) return;
+       if (position == NULL || size == NULL || border == NULL)
+               {
+                       g_warning ("Border position and size are mandatories.");
+                       return;
+               }
 
        RptPoint *from_p = (RptPoint *)g_malloc0 (sizeof (RptPoint));
        RptPoint *to_p = (RptPoint *)g_malloc0 (sizeof (RptPoint));