[gnumeric] Introspection fixes
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Introspection fixes
- Date: Fri, 13 Apr 2018 17:59:18 +0000 (UTC)
commit 49128525b2f0bf480083bc5d1866989f0625eda9
Author: Morten Welinder <terra gnome org>
Date: Fri Apr 13 13:58:32 2018 -0400
Introspection fixes
README-introspection | 30 +++++++++++++++++++++++++++++-
src/sheet-style.c | 2 +-
src/sheet.c | 21 ++++++++++++++++++++-
src/sheet.h | 1 +
test/t3001-introspection-simple.pl | 5 ++++-
test/t3001-introspection-simple.py | 22 ++++++++++++++++++----
6 files changed, 73 insertions(+), 8 deletions(-)
---
diff --git a/README-introspection b/README-introspection
index 6f3203f..c363309 100644
--- a/README-introspection
+++ b/README-introspection
@@ -42,7 +42,7 @@ Sheet: [GObject]
cells(range)
cells_count()
is_cell_empty(col,row)
- style_apply_range(range,style)
+ apply_style(range,style) [1]
style_get(col,row)
props.name
props.workbook
@@ -208,6 +208,34 @@ GnmStyle: [Boxed structure]
get_effective_text_wrap()
visible_in_blank()
+
+GOFormat: [Boxed structure]
+ new_from_XL(string)
+ as_XL()
+ general
+ empty
+ default_date
+ default_time
+ default_date_time
+ default_percentage
+ default_money
+ default_accounting
+ is_invalid
+ is_general
+ is_markup
+ is_text
+ is_var_width
+ is_date
+ is_time
+ month_before_day
+ has_hour
+ has_minute
+ inc_precision
+ dec_precision
+ toggle_1000sep
+
+
+
Gnm (i.e., not in a class):
clipboard_copy_range(sheet,range)
diff --git a/src/sheet-style.c b/src/sheet-style.c
index 101f687..71edcbe 100644
--- a/src/sheet-style.c
+++ b/src/sheet-style.c
@@ -1783,7 +1783,7 @@ sheet_style_apply_range (Sheet *sheet, GnmRange const *range, GnmStyle *pstyle)
}
/**
- * sheet_style_apply_range2: (rename-to sheet_style_apply_range)
+ * sheet_style_apply_range2: (skip)
* @sheet: #Sheet
* @range: #GnmRange to apply over
* @pstyle: A partial style to apply
diff --git a/src/sheet.c b/src/sheet.c
index 06b699c..8bace9f 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -1706,7 +1706,7 @@ sheet_cell_calc_span (GnmCell *cell, GnmSpanCalcFlags flags)
}
/**
- * sheet_apply_style:
+ * sheet_apply_style: (skip)
* @sheet: the sheet in which can be found
* @range: the range to which should be applied
* @mstyle: (transfer full): A #GnmStyle partial style
@@ -1725,6 +1725,25 @@ sheet_apply_style (Sheet *sheet,
sheet_range_calc_spans (sheet, range, spanflags);
}
+/**
+ * sheet_apply_style_gi: (rename-to sheet_apply_style)
+ * @sheet: the sheet in which can be found
+ * @range: the range to which should be applied
+ * @mstyle: A #GnmStyle partial style
+ *
+ * A mid level routine that applies the supplied partial style @style to the
+ * target @range and performs the necessary respanning and redrawing.
+ **/
+void
+sheet_apply_style_gi (Sheet *sheet, GnmRange const *range, GnmStyle *style)
+{
+ GnmSpanCalcFlags spanflags = gnm_style_required_spanflags (style);
+ gnm_style_ref (style);
+ sheet_style_apply_range (sheet, range, style);
+ /* This also redraws the range: */
+ sheet_range_calc_spans (sheet, range, spanflags);
+}
+
static void
sheet_apply_style_cb (GnmSheetRange *sr,
GnmStyle *style)
diff --git a/src/sheet.h b/src/sheet.h
index 942222b..2e6f987 100644
--- a/src/sheet.h
+++ b/src/sheet.h
@@ -389,6 +389,7 @@ SheetView *sheet_get_view (Sheet const *sheet, WorkbookView const *wbv);
// Introspection support
void sheet_cell_set_value_gi (Sheet *sheet, int col, int row, GnmValue *v);
void sheet_cell_set_text_gi (Sheet *sheet, int col, int row, char const *str);
+void sheet_apply_style_gi (Sheet *sheet, GnmRange const *range, GnmStyle *style);
#define SHEET_FOREACH_VIEW(sheet, view, code) \
diff --git a/test/t3001-introspection-simple.pl b/test/t3001-introspection-simple.pl
index faba82e..f78cd77 100755
--- a/test/t3001-introspection-simple.pl
+++ b/test/t3001-introspection-simple.pl
@@ -36,10 +36,13 @@ As int:
0
1
+Formatted value:
+Value: 101.25 Format: 0.0000 Rendered: 101.2500
+
List of cells in sheet:
A1: 10 [bold]
C1: 10
-A2: 101.25 [bold]
+A2: 101.2500 [bold]
C2: 101.25
A3: =A1+A2
C3: =C1+C2
diff --git a/test/t3001-introspection-simple.py b/test/t3001-introspection-simple.py
index 24edc79..db9795d 100755
--- a/test/t3001-introspection-simple.py
+++ b/test/t3001-introspection-simple.py
@@ -11,9 +11,9 @@ wb = Gnm.Workbook.new_with_sheets(1)
# Get sheet. Index starts at 0
sheet = wb.sheet_by_index(0)
-print("Name:", sheet.props.name)
-print("Number of columns:", sheet.props.columns)
-print("Number of rows:", sheet.props.rows)
+print("Name: {}".format(sheet.props.name))
+print("Number of columns: {}".format (sheet.props.columns))
+print("Number of rows: {}".format (sheet.props.rows))
# Store values and expressions is some cells. Coordinates are (col,row)
# both starting at 0. (So what the gui sees as row 1 is 0 here.)
@@ -40,7 +40,14 @@ st = Gnm.Style.new()
st.set_font_bold(1)
r = Gnm.Range()
r.init(0,0,0,1)
-sheet.style_apply_range(r,st)
+sheet.apply_style(r,st)
+
+# Set a format for A2
+st = Gnm.Style.new()
+st.set_format_text("0.0000")
+r = Gnm.Range()
+r.init(0,1,0,1)
+sheet.apply_style(r,st)
# Recalculate all cells that need it
wb.recalc()
@@ -53,6 +60,13 @@ print("\nAs int:")
for i in range(7):
print(sheet.cell_get_value(0,i).get_as_int())
+print("\nFormatted value:")
+c = sheet.cell_fetch(0,1)
+print("Value: {} Format: {} Rendered: {}".format (c.get_value().get_as_string(),
+ c.get_format().as_XL(),
+ c.get_rendered_text()))
+
+
print("\nList of cells in sheet:")
for c in sheet.cells(None):
st = sheet.style_get (c.pos.col,c.pos.row)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]