[gnumeric] Fix text wrap inside sheet objects. [#704417]
- From: Jean Bréfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Fix text wrap inside sheet objects. [#704417]
- Date: Wed, 17 Jul 2013 19:54:05 +0000 (UTC)
commit 06c577bb814c5b51ca8002493c64faaa2abb50b8
Author: Jean Brefort <jean brefort normalesup org>
Date: Wed Jul 17 21:51:59 2013 +0200
Fix text wrap inside sheet objects. [#704417]
ChangeLog | 7 +++++++
NEWS | 3 +++
src/gnm-so-filled.c | 36 +++++++++++++++++++++---------------
src/gnm-so-path.c | 39 ++++++++++++++++++++++++++++++++-------
4 files changed, 63 insertions(+), 22 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index db36cef..6759716 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-07-17 Jean Brefort <jean brefort normalesup org>
+
+ * src/gnm-so-filled.c (so_filled_view_set_bounds),
+ (cb_gnm_so_filled_changed): fix text wrap. [#704417]
+ * src/gnm-so-path.c (so_path_view_set_bounds),
+ (cb_gnm_so_path_changed): fix text wrap in paths too.
+
2013-07-16 Morten Welinder <terra gnome org>
* src/sheet.c (sheet_foreach_cell_in_range): Avoid overflow when
diff --git a/NEWS b/NEWS
index 513c08c..028f274 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ Andreas:
* Improve ODF import of cells with links. [#704022]
* Fix import of multi-paragraph text from ODF. [#704391]
+Jean:
+ * Fix text wrap inside sheet objects. [#704417]
+
Morten:
* Fix crazy parsing problem. [#704109] [#704140]
* Fix crashes on corrupted files. [#704102] [#704004] [#704325]
diff --git a/src/gnm-so-filled.c b/src/gnm-so-filled.c
index 577d279..a0f9e76 100644
--- a/src/gnm-so-filled.c
+++ b/src/gnm-so-filled.c
@@ -91,7 +91,7 @@ so_filled_view_set_bounds (SheetObjectView *sov, double const *coords, gboolean
NULL);
- if (fiv->text != NULL && GOC_ITEM (fiv->text)) {
+ if (fiv->text != NULL && GOC_IS_ITEM (fiv->text)) {
w -= (sof->margin_pts.left + sof->margin_pts.right)
/ scale;
w = MAX (w, DBL_MIN);
@@ -196,18 +196,20 @@ cb_gnm_so_filled_changed (GnmSOFilled const *sof,
/* set a font, a very bad solution, but will do until we move to GOString */
PangoFontDescription *desc = pango_font_description_from_string ("Sans 10");
GOStyle *style;
+ double w, h;
+ double scale = goc_canvas_get_pixels_per_unit (GOC_ITEM (group)->canvas);
+ g_object_get (group->bg, "width", &w, "height", &h, NULL);
+ w -= (sof->margin_pts.left + sof->margin_pts.right)
+ / scale;
+ w = MAX (w, DBL_MIN);
+
+ h -= (sof->margin_pts.top + sof->margin_pts.bottom)
+ / scale;
+ h = MAX (h, DBL_MIN);
+printf("w=%g h=%g\n",w,h);
if (group->text == NULL) {
if (sof->is_oval) {
- double w, h;
- double scale = goc_canvas_get_pixels_per_unit (GOC_ITEM (group)->canvas);
- g_object_get (group->bg, "width", &w, "height", &h, NULL);
- w -= (sof->margin_pts.left + sof->margin_pts.right)
- / scale;
- w = MAX (w, DBL_MIN);
-
- h -= (sof->margin_pts.top + sof->margin_pts.bottom)
- / scale;
- h = MAX (h, DBL_MIN);
+puts("oval");
group->text = goc_item_new (GOC_GROUP (group), GOC_TYPE_TEXT,
"anchor", GO_ANCHOR_CENTER,
"clip", TRUE,
@@ -216,20 +218,24 @@ cb_gnm_so_filled_changed (GnmSOFilled const *sof,
"attributes", sof->markup,
NULL);
} else
+ {puts("rectangle");
group->text = goc_item_new (GOC_GROUP (group), GOC_TYPE_TEXT,
"anchor", GO_ANCHOR_NW,
"clip", TRUE,
"x", sof->margin_pts.left,
"y", sof->margin_pts.top,
"attributes", sof->markup,
- NULL);
+ NULL);}
}
style = go_styled_object_get_style (GO_STYLED_OBJECT (group->text));
go_style_set_font_desc (style, desc);
goc_item_set (group->text,
- "text", sof->text,
- "attributes", sof->markup,
- NULL);
+ "text", sof->text,
+ "attributes", sof->markup,
+ "clip-height", h,
+ "clip-width", w,
+ "wrap-width", w,
+ NULL);
} else if (group->text != NULL) {
g_object_unref (group->text);
group->text = NULL;
diff --git a/src/gnm-so-path.c b/src/gnm-so-path.c
index 5360b70..12104b2 100644
--- a/src/gnm-so-path.c
+++ b/src/gnm-so-path.c
@@ -118,14 +118,16 @@ so_path_view_set_bounds (SheetObjectView *sov, double const *coords, gboolean vi
y1 = My;
}
}
- x1 += x0 + (sop->margin_pts.left - sop->margin_pts.right);
- y1 += y0 + (sop->margin_pts.top - sop->margin_pts.bottom);
+ x1 -= x0 + sop->margin_pts.left + sop->margin_pts.right;
+ y1 -= y0 + sop->margin_pts.top + sop->margin_pts.bottom;
+ x0 += x1 / 2.;
+ y0 += y1 / 2.;
x1 = MAX (x1, DBL_MIN);
y1 = MAX (y1, DBL_MIN);
goc_item_set (GOC_ITEM (spv->text),
- "x", x1 / 2.,
- "y", y1 / 2.,
+ "x", x0,
+ "y", y0,
"clip-height", y1,
"clip-width", x1,
"wrap-width", x1,
@@ -212,9 +214,29 @@ cb_gnm_so_path_changed (GnmSOPath const *sop,
GOStyle *style;
if (group->text == NULL) {
double x0, y0, x1, y1;
- goc_item_get_bounds (group->path, &x0, &y0, &x1, &y1);
- x1 += x0 + (sop->margin_pts.left - sop->margin_pts.right);
- y1 += y0 + (sop->margin_pts.top - sop->margin_pts.bottom);
+ if (group->path)
+ goc_item_get_bounds (group->path, &x0, &y0, &x1, &y1);
+ else {
+ unsigned i;
+ double mx, my, Mx, My;
+ x0 = y0 = G_MAXDOUBLE;
+ x1 = y1 = -G_MAXDOUBLE;
+ for (i = 0; i < group->paths->len; i++) {
+ goc_item_get_bounds (GOC_ITEM (g_ptr_array_index (group->paths, i)),
&mx, &my, &Mx, &My);
+ if (mx < x0)
+ x0 = mx;
+ if (my < y0)
+ y0 = my;
+ if (Mx > x1)
+ x1 = Mx;
+ if (My > y1)
+ y1 = My;
+ }
+ }
+ x1 -= x0 + sop->margin_pts.left + sop->margin_pts.right;
+ y1 -= y0 + sop->margin_pts.top + sop->margin_pts.bottom;
+ x0 += x1 / 2.;
+ y0 += y1 / 2.;
x1 = MAX (x1, DBL_MIN);
y1 = MAX (y1, DBL_MIN);
group->text = goc_item_new (GOC_GROUP (group), GOC_TYPE_TEXT,
@@ -222,6 +244,9 @@ cb_gnm_so_path_changed (GnmSOPath const *sop,
"clip", TRUE,
"x", x1 / 2.,
"y", y1 / 2.,
+ "clip-height", y1,
+ "clip-width", x1,
+ "wrap-width", x1,
"attributes", sop->markup,
NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]