[goffice] Fix build.



commit c4e595d7be7f917ecb736064ed531eba4d4f57e9
Author: Jean Brefort <jean brefort normalesup org>
Date:   Sat Jun 22 15:43:38 2013 +0200

    Fix build.

 ChangeLog                  |    6 ++++++
 goffice/graph/gog-label.c  |   42 ++++++++++++++++++++++++++++++++++++++++++
 goffice/utils/go-pattern.c |    2 +-
 3 files changed, 49 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 36102a3..70e93f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2013-06-22  Jean Brefort  <jean brefort normalesup org>
 
+       * goffice/graph/gog-label.c (gog_text_view_natural_size),
+       (gog_text_view_class_init): implement natural_size().
+       * goffice/utils/go-pattern.c (go_pattern_create_cairo_pattern): fix build.
+
+2013-06-22  Jean Brefort  <jean brefort normalesup org>
+
        * goffice/utils/go-pattern.c (go_pattern_get_pattern),
        (go_pattern_create_cairo_pattern): don't use an invalid pattern.
        [see #702833]
diff --git a/goffice/graph/gog-label.c b/goffice/graph/gog-label.c
index 952c17c..469c1cc 100644
--- a/goffice/graph/gog-label.c
+++ b/goffice/graph/gog-label.c
@@ -647,6 +647,47 @@ typedef GogOutlinedViewClass       GogTextViewClass;
 static GogViewClass *text_view_parent_klass;
 
 static void
+gog_text_view_natural_size (GogView *view, GogViewRequisition *req)
+{
+       GogText *text = GOG_TEXT (view->model);
+       char *str = gog_text_get_str (text);
+       PangoAttrList *pl = gog_text_get_markup (text);
+       GOGeometryAABR aabr;
+
+       req->w = req->h = 0.;
+       if (str != NULL) {
+               GOString *gostr = pl
+                       ? go_string_new_rich (str, -1,
+                                             gog_text_get_markup (text),
+                                             NULL)
+                       : NULL;
+               GOStyle *style = go_style_dup (text->base.base.style);
+               double rot = fabs (style->text_layout.angle / 180 * M_PI);
+               if (rot > M_PI / 2.)
+                       rot = M_PI - rot;
+           if (text->rotate_frame)
+                       style->text_layout.angle = 0.;
+               gog_renderer_push_style (view->renderer, style);
+               /* for natural size, we never force wrapping so use -1 as max width */
+               if (gostr) {
+                       gog_renderer_get_gostring_AABR (view->renderer, gostr, &aabr, -1);
+                       go_string_unref (gostr);
+               } else
+                       gog_renderer_get_text_AABR (view->renderer, str, text->allow_markup, &aabr, -1);
+               gog_renderer_pop_style (view->renderer);
+               g_object_unref (style);
+               if (text->rotate_frame) {
+                       req->w = aabr.w * cos (rot) + aabr.h * sin (rot);
+                       req->h = aabr.w * sin (rot) + aabr.h * cos (rot);
+               } else {
+                       req->w = aabr.w;
+                       req->h = aabr.h;
+               }
+               g_free (str);
+       }
+}
+
+static void
 gog_text_view_size_request (GogView *v,
                            GogViewRequisition const *available,
                            GogViewRequisition *req)
@@ -771,6 +812,7 @@ gog_text_view_class_init (GogTextViewClass *gview_klass)
        GogViewClass *view_klass    = (GogViewClass *) gview_klass;
 
        text_view_parent_klass = g_type_class_peek_parent (gview_klass);
+       view_klass->natural_size    = gog_text_view_natural_size;
        view_klass->size_request    = gog_text_view_size_request;
        view_klass->render          = gog_text_view_render;
 }
diff --git a/goffice/utils/go-pattern.c b/goffice/utils/go-pattern.c
index 108acb2..ee4b41f 100644
--- a/goffice/utils/go-pattern.c
+++ b/goffice/utils/go-pattern.c
@@ -272,7 +272,7 @@ go_pattern_create_cairo_pattern (GOPattern const *pattern, cairo_t *cr)
        cairo_pattern_t *cr_pattern;
        GOColor color;
 
-       g_return_val_if_fail (pat != NULL && pat->pattern < GO_PATTERN_MAX, NULL);
+       g_return_val_if_fail (pattern != NULL && pattern->pattern < GO_PATTERN_MAX, NULL);
        if (go_pattern_is_solid (pattern, &color)) {
                cr_pattern = cairo_pattern_create_rgba (GO_COLOR_TO_CAIRO (color));
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]