Commit 563646db authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

merge excel_write_PANE into here and fix export of H or V only freezes.

2006-04-29  Jody Goldberg <jody@gnome.org>

	* ms-excel-write.c (excel_write_WINDOW2) : merge excel_write_PANE into
	  here and fix export of H or V only freezes.

2006-04-23  Jody Goldberg <jody@gnome.org>

	* xlsx-write.c : new.  Basic export and some code that will move to
	  libgsf for 'Open Package' support.
	* plugin.xml.in : Add xlsx export.
	* Makefile.am : ditto.

2006-04-23  Jody Goldberg <jody@gnome.org>

	* ms-excel-read.c (excel_read_EXTERNSHEET_v7) : patch
	  tweak to import broken quoted sheetname from gnumeric-1.0.x eg
	  Libro1.xls.

2006-04-23  Jody Goldberg <jody@gnome.org>

	* ms-chart.c (ms_excel_chart_read) : Don't set the graph and chart
	  styles to blank unless this is a full sheet object.  Fixes the
	  import of older charts that are not wrapped in BOF records eg
	  ms699.xls.

2006-04-29  Jody Goldberg <jody@gnome.org>

	* src/workbook-view.c (wb_view_get_index_in_wb) : new for xlsx export.

	* src/selection.h (sv_selection_foreach) : renamed from
	  selection_foreach_range.  All callers changed.
	* src/selection.c (sv_selection_add_full) : renamed from
	  sv_selection_add_range to be clearer.
	(sv_selection_add_range) : new utility that takes a ... GnmRange.

	* src/sheet-view.h : SheetView::selections make this a GSList, no need
	  for a GList.  This makes the api more homogeneous.

	* src/cell.c (cell_get_style) : constify the result and rename from
	  cell_get_mstyle.

	* src/ranges.c (range_as_string) : renamed from range_name.  All
	  callers fixed.

	* src/style-conditions.c (gnm_style_conditions_eval) : tack on hooks
	  for some of the new condition types in office 12.
parent c10dadbb
......@@ -39,13 +39,8 @@ Worries
: eg tc45 issue sheet
: bugreport0401.xls
- transparent background to xl95 charts
: ms699.xls
- Reading /local/info/test-xls/Desktop\ \&\ Collaboration\ Products\ Weekly\ Invoice.xls
: getpivotdata
- Libro.xls
: check sheetnames
: check idx>0 warning
- TestForBiffConsumer : #REF ??
- accrint-test.xls : why fail ?
- BAHT functions
......@@ -54,6 +49,8 @@ Worries
- div0-xp.xls
- edward~1.xls
- eng.xls
- XL returns real numbers as strings from complex functions
- Check difference in besseli
- errors.xls
: calc of interest
: #REF on sheet2
......@@ -67,6 +64,9 @@ Worries
- hidding col/row headers should not hide outline symbols
- with frozen panes that have topleft != A1 there are a few extra pixels
between col header and grid.
- xml persistence of grid colour
- store and persist view modes
- fix bogosity of 'ant' cursors being in sheet_view and having the app contact them.
Pending Patches
---------------
......@@ -85,6 +85,7 @@ Architecture Changes
--------------------
- Merge wb_control_init_state and wb_control_set_view
- Use gtk_window_group_new to keep wbcg's distinct
1) things to move into libgoffice
1.1) plugin-manager dialog
......
2006-04-29 Jody Goldberg <jody@gnome.org>
* src/workbook-view.c (wb_view_get_index_in_wb) : new for xlsx export.
* src/selection.h (sv_selection_foreach) : renamed from
selection_foreach_range. All callers changed.
* src/selection.c (sv_selection_add_full) : renamed from
sv_selection_add_range to be clearer.
(sv_selection_add_range) : new utility that takes a ... GnmRange.
* src/sheet-view.h : SheetView::selections make this a GSList, no need
for a GList. This makes the api more homogeneous.
* src/cell.c (cell_get_style) : constify the result and rename from
cell_get_mstyle.
* src/ranges.c (range_as_string) : renamed from range_name. All
callers fixed.
* src/style-conditions.c (gnm_style_conditions_eval) : tack on hooks
for some of the new condition types in office 12.
2006-04-27 Morten Welinder <terra@gnome.org>
* src/commands.c (cmd_clone_sheet): Remove.
......
......@@ -33,7 +33,9 @@ Jody:
* Handle canceling object drag motion. [#314866]
* Fix image drags with previously selected objects.
* Handle oddness in xls files generated by 'miniCalc' [#336858]
* Basic importer for MS Office 12 (beta1) files
* Do not make backgrounds for xl95 charts transparent.
* Basic import and export for MS Office 12 (beta1) files
* xls import optimization for shared strings.
Klokan Pridal:
* Implement xml saving/loading of "protected" attribute. [#334257]
......
2006-04-29 Jody Goldberg <jody@gnome.org>
* src/workbook-view.c (wb_view_get_index_in_wb) : new for xlsx export.
* src/selection.h (sv_selection_foreach) : renamed from
selection_foreach_range. All callers changed.
* src/selection.c (sv_selection_add_full) : renamed from
sv_selection_add_range to be clearer.
(sv_selection_add_range) : new utility that takes a ... GnmRange.
* src/sheet-view.h : SheetView::selections make this a GSList, no need
for a GList. This makes the api more homogeneous.
* src/cell.c (cell_get_style) : constify the result and rename from
cell_get_mstyle.
* src/ranges.c (range_as_string) : renamed from range_name. All
callers fixed.
* src/style-conditions.c (gnm_style_conditions_eval) : tack on hooks
for some of the new condition types in office 12.
2006-04-27 Morten Welinder <terra@gnome.org>
* src/commands.c (cmd_clone_sheet): Remove.
......
......@@ -25,7 +25,7 @@ to build upon the experience of and pitfalls of the Michael's work.
b) Set elements:
gnm_style_set_font_name (mstyle, "Dingbats");
gnm_style_set_font_name (style, "Dingbats");
The passed const font name in this case is hashed and ref-counted
internally for efficiency. The only case in which it is necessary to do
......@@ -50,13 +50,13 @@ to build upon the experience of and pitfalls of the Michael's work.
/* Use the fully specified style in place of the current style
sheet_style_set_range (sheet, range, style);
sheet_style_set_pos (sheet, col, row, mstyle);
sheet_style_set_pos (sheet, col, row, style);
1.1.2 Getting a style
GnmStyle *mstyle = sheet_style_get (sheet, col, row);
GnmStyle const *style = sheet_style_get (sheet, col, row);
or
GnmStyle *mstyle = cell_get_mstyle (cell);
GnmStyle const *style = cell_get_style (cell);
Neither of these adds a reference to the style. If you intend to store
the style for later use you will need to ref/unref it.
......@@ -66,8 +66,8 @@ to build upon the experience of and pitfalls of the Michael's work.
sheet_style_attach ie.
BAD BAD BAD
GnmStyle *mstyle = cell_get_mstyle (cell);
gnm_style_set_font_size (mstyle, 12.0);
GnmStyle const *style = cell_get_style (cell);
gnm_style_set_font_size (style, 12.0);
BAD BAD BAD
Do _not_ even think of doing the above, it will produce wacky
......@@ -77,12 +77,12 @@ to build upon the experience of and pitfalls of the Michael's work.
If you do the following:
GnmStyle *mstyle = gnm_style_new ();
gnm_style_set_font_name (mstyle, "dingbats");
cell_set_style (cell, mstyle);
mstyle = gnm_style_new ();
gnm_style_set_font_bold (mstyle, TRUE);
cell_set_style (cell, mstyle);
GnmStyle *style = gnm_style_new ();
gnm_style_set_font_name (style, "dingbats");
cell_set_style (cell, style);
style = gnm_style_new ();
gnm_style_set_font_bold (style, TRUE);
cell_set_style (cell, style);
Then you needlessly create two style regions ( for the same cell )
where one would have sufficed. This is a degenerate case clearly,
......@@ -96,11 +96,11 @@ to build upon the experience of and pitfalls of the Michael's work.
to reference count them the followings ( standard ) conventions are
used namely:
GnmStyle *mstyle = gnm_style_new ();
GnmStyle *style = gnm_style_new ();
Creating an mstyle in this way hands you a single reference.
Creating an style in this way hands you a single reference.
sheet_style_set_pos (sheet, col, row, mstyle)
sheet_style_set_pos (sheet, col, row, style)
Attaching a style passes that reference on to the style code.
The way to ascertain whether a style reference has been handed on is
......@@ -143,7 +143,7 @@ to build upon the experience of and pitfalls of the Michael's work.
Conflicts are marked in the final GnmStyle result and can be tested for
using:
gnm_style_element_is_conflict (mstyle, GnmStyleElement);
gnm_style_element_is_conflict (style, GnmStyleElement);
2.3.1 Unique borders
......
2006-04-29 Jody Goldberg <jody@gnome.org>
* ms-excel-write.c (excel_write_WINDOW2) : merge excel_write_PANE into
here and fix export of H or V only freezes.
2006-04-23 Jody Goldberg <jody@gnome.org>
* xlsx-write.c : new. Basic export and some code that will move to
libgsf for 'Open Package' support.
* plugin.xml.in : Add xlsx export.
* Makefile.am : ditto.
2006-04-23 Jody Goldberg <jody@gnome.org>
* ms-excel-read.c (excel_read_EXTERNSHEET_v7) : patch
tweak to import broken quoted sheetname from gnumeric-1.0.x eg
Libro1.xls.
2006-04-23 Jody Goldberg <jody@gnome.org>
* ms-chart.c (ms_excel_chart_read) : Don't set the graph and chart
styles to blank unless this is a full sheet object. Fixes the
import of older charts that are not wrapped in BOF records eg
ms699.xls.
2006-04-18 Morten Welinder <terra@gnome.org>
* boot.c (excel_file_open): Don't leak the meta_data object.
......
......@@ -60,7 +60,10 @@ excel_la_SOURCES = \
excel-xml-read.c \
excel-xml-read.h \
\
xlsx-read.c
xlsx-utils.h \
xlsx-utils.c \
xlsx-read.c \
xlsx-write.c
xml_in_files = plugin.xml.in
xml_DATA = $(xml_in_files:.xml.in=.xml)
......
......@@ -62,7 +62,7 @@ gint ms_excel_read_debug = 0;
gint ms_excel_pivot_debug = 0;
gint ms_excel_escher_debug = 0;
gint ms_excel_formula_debug = 0;
gint ms_excel_chart_debug = 10;
gint ms_excel_chart_debug = 0;
gint ms_excel_write_debug = 0;
gint ms_excel_object_debug = 0;
......
......@@ -861,9 +861,7 @@ xl_xml_selection (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
end = rangeref_parse (&rr, ptr, &pp, gnm_expr_conventions_r1c1);
if (end != ptr) {
range_init_rangeref (&r, &rr);
fprintf (stderr, "%s = ", ptr);
range_dump (&r, "\n");
sv_selection_add_range (sv,
sv_selection_add_full (sv,
state->pos.col, state->pos.row,
r.start.col, r.start.row,
r.end.col, r.end.row);
......
......@@ -3048,17 +3048,18 @@ ms_excel_chart_read (BiffQuery *q, MSContainer *container,
state.has_extra_dataformat = FALSE;
if (NULL != (state.sog = sog)) {
GogStyle *style = gog_style_new ();
style->outline.width = 0;
style->outline.dash_type = GO_LINE_NONE;
style->fill.type = GOG_FILL_STYLE_NONE;
state.graph = sheet_object_graph_get_gog (sog);
state.chart = GOG_CHART (gog_object_add_by_name (GOG_OBJECT (state.graph), "Chart", NULL));
g_object_set (G_OBJECT (state.graph), "style", style, NULL);
g_object_set (G_OBJECT (state.chart), "style", style, NULL);
g_object_unref (style);
if (NULL != full_page) {
GogStyle *style = gog_style_new ();
style->outline.width = 0;
style->outline.dash_type = GO_LINE_NONE;
style->fill.type = GOG_FILL_STYLE_NONE;
g_object_set (G_OBJECT (state.graph), "style", style, NULL);
g_object_set (G_OBJECT (state.chart), "style", style, NULL);
g_object_unref (style);
}
} else {
state.graph = NULL;
state.chart = NULL;
......
......@@ -958,7 +958,7 @@ sst_read_string (BiffQuery *q, MSContainer const *c,
guint32 get_len, chars_left, total_len, total_end_len = 0;
unsigned i, post_data_len, n_markup, total_n_markup = 0;
gboolean use_utf16, has_extended;
char *str;
char *str, *old_res, *res_str = NULL;
offset = ms_biff_query_bound_check (q, offset, 2);
total_len = GSF_LE_GET_GUINT16 (q->data + offset);
......@@ -980,13 +980,13 @@ sst_read_string (BiffQuery *q, MSContainer const *c,
q->data + offset, get_len, use_utf16);
offset += get_len * (use_utf16 ? 2 : 1);
if (res->str != NULL) {
char *old_res = res->str;
res->str = g_strconcat (old_res, str, NULL);
if (res_str != NULL) {
old_res = res_str;
res_str = g_strconcat (old_res, str, NULL);
g_free (str);
g_free (old_res);
} else
res->str = str;
res_str = str;
} while (total_len > 0);
if (total_n_markup > 0) {
......@@ -998,8 +998,8 @@ sst_read_string (BiffQuery *q, MSContainer const *c,
for (i = total_n_markup ; i-- > 0 ; offset += 4) {
offset = ms_biff_query_bound_check (q, offset, 4);
if ((q->length - offset) >= 4) {
txo_run.last = g_utf8_offset_to_pointer (res->str,
GSF_LE_GET_GUINT16 (q->data+offset)) - res->str;
txo_run.last = g_utf8_offset_to_pointer (res_str,
GSF_LE_GET_GUINT16 (q->data+offset)) - res_str;
if (prev_markup != NULL)
pango_attr_list_filter (prev_markup,
(PangoAttrFilterFunc) append_markup, &txo_run);
......@@ -1017,6 +1017,7 @@ sst_read_string (BiffQuery *q, MSContainer const *c,
total_end_len -= 4*total_n_markup;
}
res->content = gnm_string_get_nocopy (res_str);
return offset + total_end_len;
}
......@@ -1040,11 +1041,11 @@ excel_read_SST (BiffQuery *q, GnmXLImporter *importer)
for (i = 0; i < importer->sst_len; i++) {
offset = sst_read_string (q, &importer->container, importer->sst + i, offset);
if (importer->sst[i].str == NULL)
if (importer->sst[i].content == NULL)
d (4, fprintf (stderr,"Blank string in table at 0x%x.\n", i););
#ifndef NO_DEBUG_EXCEL
else if (ms_excel_read_debug > 4)
puts (importer->sst[i].str);
puts (importer->sst[i].content->str);
#endif
}
}
......@@ -2362,7 +2363,7 @@ excel_formula_shared (BiffQuery *q, ExcelReadSheet *esheet, GnmCell *cell)
sf->data = data_len > 0 ? g_memdup (data, data_len) : NULL;
sf->data_len = data_len;
d (1, fprintf (stderr,"Shared formula, extent %s\n", range_name (&r)););
d (1, fprintf (stderr,"Shared formula, extent %s\n", range_as_string (&r)););
g_hash_table_insert (esheet->shared_formulae, &sf->key, sf);
......@@ -2911,7 +2912,7 @@ gnm_xl_importer_free (GnmXLImporter *importer)
if (importer->sst != NULL) {
unsigned i = importer->sst_len;
while (i-- > 0) {
g_free (importer->sst[i].str);
gnm_string_unref (importer->sst[i].content);
if (importer->sst[i].markup != NULL)
go_format_unref (importer->sst[i].markup);
}
......@@ -3814,10 +3815,10 @@ excel_read_SELECTION (BiffQuery *q, ExcelReadSheet *esheet)
r.start.col = GSF_LE_GET_GUINT8 (refs + 4);
r.end.col = GSF_LE_GET_GUINT8 (refs + 5);
d (5, fprintf (stderr,"Ref %d = %s\n", i-1, range_name (&r)););
d (5, fprintf (stderr,"Ref %d = %s\n", i-1, range_as_string (&r)););
tmp = (i == num_refs) ? edit_pos : r.start;
sv_selection_add_range (sv,
sv_selection_add_full (sv,
tmp.col, tmp.row,
r.start.col, r.start.row,
r.end.col, r.end.row);
......@@ -4219,7 +4220,7 @@ excel_read_DIMENSIONS (BiffQuery *q, GnmXLImporter *importer)
excel_read_range (&r, q->data);
}
d (1, fprintf (stderr,"Dimension = %s\n", range_name (&r)););
d (1, fprintf (stderr,"Dimension = %s\n", range_as_string (&r)););
}
static MSContainer *
......@@ -5329,18 +5330,16 @@ excel_read_EXTERNSHEET_v7 (BiffQuery const *q, MSContainer *container)
if (name != NULL) {
sheet = workbook_sheet_by_name (container->importer->wb, name);
if (sheet == NULL) {
/* There was a bug in 1.0.x export that spewed the quoted name */
/* There was a bug in 1.0.x export that spewed the quoted name
* includling internal backquoting */
if (name[0] == '\'') {
int tmp_len = strlen (name);
if (tmp_len >= 3 && name[tmp_len-1] == '\'') {
char *tmp = g_strndup (name+1, tmp_len - 2);
sheet = workbook_sheet_by_name (container->importer->wb, tmp);
if (sheet != NULL) {
g_free (name);
name = tmp;
} else
g_free (tmp);
}
GString *fixed = g_string_new (NULL);
if (NULL != go_strunescape (fixed, name) &&
NULL != (sheet = workbook_sheet_by_name (container->importer->wb, fixed->str))) {
g_free (name);
name = g_string_free (fixed, FALSE);
} else
g_string_free (fixed, TRUE);
}
if (sheet == NULL) {
......@@ -5744,9 +5743,13 @@ excel_read_sheet (BiffQuery *q, GnmXLImporter *importer,
i = GSF_LE_GET_GUINT32 (q->data + 6);
if (esheet->container.importer->sst && i < esheet->container.importer->sst_len) {
char const *str = esheet->container.importer->sst[i].str;
/* FIXME FIXME FIXME: Why would there be a NULL? */
v = value_new_string ((str != NULL) ? str : "");
GnmString *str = esheet->container.importer->sst[i].content;
/* ? Why would there be a NULL ? */
if (NULL != str) {
gnm_string_ref (str);
v = value_new_string_str (str);
} else
v = value_new_string ("");
if (esheet->container.importer->sst[i].markup != NULL)
value_set_fmt (v, esheet->container.importer->sst[i].markup);
excel_sheet_insert_val (esheet, q, v);
......
......@@ -93,7 +93,7 @@ typedef struct {
} BiffFormatData;
typedef struct {
char *str;
GnmString *content;
GOFormat *markup;
} ExcelStringEntry;
......
......@@ -181,6 +181,44 @@ map_color_to_palette (ExcelWriteState const *ewb,
return palette_get_index (ewb, gnm_color_to_bgr (c));
}
void
excel_sheet_extent (Sheet const *sheet, GnmRange *extent, GnmStyle **col_styles,
int maxcols, int maxrows, IOContext *io_context)
{
int i;
/* Ignore spans and merges past the bound */
*extent = sheet_get_extent (sheet, FALSE);
if (extent->end.col >= maxcols) {
gnm_io_warning (io_context,
_("Some content will be lost when saving. This format only supports %u cols, and this workbook has %d"),
maxcols, extent->end.col);
extent->end.col = maxcols;
}
if (extent->end.row >= maxrows) {
gnm_io_warning (io_context,
_("Some content will be lost when saving. This format only supports %u rows, and this workbook has %d"),
maxrows, extent->end.row);
extent->end.row = maxrows;
}
sheet_style_get_extent (sheet, extent, col_styles);
/* include collapsed or hidden rows */
for (i = maxrows ; i-- > extent->end.row ; )
if (!colrow_is_empty (sheet_row_get (sheet, i))) {
extent->end.row = i;
break;
}
/* include collapsed or hidden rows */
for (i = 256 ; i-- > extent->end.col ; )
if (!colrow_is_empty (sheet_col_get (sheet, i))) {
extent->end.col = i;
break;
}
}
/**
* excel_write_string_len :
* @str : The utf8 encoded string in question
......@@ -605,8 +643,7 @@ excel_write_WINDOW1 (BiffPut *bp, WorkbookView const *wb_view)
ms_biff_put_commit (bp);
}
/* returns TRUE if a PANE record is necessary. */
static gboolean
static void
excel_write_WINDOW2 (BiffPut *bp, ExcelWriteSheet *esheet, SheetView *sv)
{
/* 1 0x020 grids are the colour of the normal style */
......@@ -614,11 +651,31 @@ excel_write_WINDOW2 (BiffPut *bp, ExcelWriteSheet *esheet, SheetView *sv)
/* 0 0x800 (biff8 only) no page break mode*/
guint16 options = 0x0A0;
guint8 *data;
GnmCellPos top_left;
GnmCellPos topLeft, frozen_topLeft;
Sheet const *sheet = esheet->gnum_sheet;
GnmColor *sheet_auto = sheet_style_get_auto_pattern_color (sheet);
GnmColor *default_auto = style_color_auto_pattern ();
guint32 biff_pat_col = 0x40; /* default grid color index == auto */
int const frozen_height = sv->unfrozen_top_left.row -
sv->frozen_top_left.row;
int const frozen_width = sv->unfrozen_top_left.col -
sv->frozen_top_left.col;
guint16 freeze_type; /* NOTE docs lie, this is not 'active pane' */
if (frozen_width > 0) {
topLeft.col = sv->frozen_top_left.col;
frozen_topLeft.col = sv->initial_top_left.col;
} else {
topLeft.col = sv->initial_top_left.col;
frozen_topLeft.col = sv->frozen_top_left.col;
}
if (frozen_height > 0) {
topLeft.row = sv->frozen_top_left.row;
frozen_topLeft.row = sv->initial_top_left.row;
} else {
topLeft.row = sv->initial_top_left.row;
frozen_topLeft.row = sv->frozen_top_left.row;
}
if (sheet->display_formulas)
options |= 0x0001;
......@@ -626,11 +683,8 @@ excel_write_WINDOW2 (BiffPut *bp, ExcelWriteSheet *esheet, SheetView *sv)
options |= 0x0002;
if (!sheet->hide_col_header || !sheet->hide_row_header)
options |= 0x0004;
if (sv_is_frozen (sv)) {
if (sv_is_frozen (sv))
options |= 0x0108;
top_left = sv->frozen_top_left;
} else
top_left = sv->initial_top_left;
if (!sheet->hide_zero)
options |= 0x0010;
if (sheet->text_is_rtl)
......@@ -650,15 +704,15 @@ excel_write_WINDOW2 (BiffPut *bp, ExcelWriteSheet *esheet, SheetView *sv)
data = ms_biff_put_len_next (bp, BIFF_WINDOW2_v2, 10);
GSF_LE_SET_GUINT16 (data + 0, options);
GSF_LE_SET_GUINT16 (data + 2, top_left.row);
GSF_LE_SET_GUINT16 (data + 4, top_left.col);
GSF_LE_SET_GUINT16 (data + 2, topLeft.row);
GSF_LE_SET_GUINT16 (data + 4, topLeft.col);
GSF_LE_SET_GUINT32 (data + 6, biff_pat_col);
} else {
data = ms_biff_put_len_next (bp, BIFF_WINDOW2_v2, 18);
GSF_LE_SET_GUINT16 (data + 0, options);
GSF_LE_SET_GUINT16 (data + 2, top_left.row);
GSF_LE_SET_GUINT16 (data + 4, top_left.col);
GSF_LE_SET_GUINT16 (data + 2, topLeft.row);
GSF_LE_SET_GUINT16 (data + 4, topLeft.col);
GSF_LE_SET_GUINT32 (data + 6, biff_pat_col);
GSF_LE_SET_GUINT16 (data + 10, 0x1); /* print preview 100% */
GSF_LE_SET_GUINT16 (data + 12, 0x0); /* FIXME : why 0? */
......@@ -668,31 +722,23 @@ excel_write_WINDOW2 (BiffPut *bp, ExcelWriteSheet *esheet, SheetView *sv)
style_color_unref (sheet_auto);
style_color_unref (default_auto);
return (options & 0x0008);
}
static void
excel_write_PANE (BiffPut *bp, ExcelWriteSheet *esheet, SheetView *sv)
{
guint8 *data = ms_biff_put_len_next (bp, BIFF_PANE, 10);
int const frozen_height = sv->unfrozen_top_left.row -
sv->frozen_top_left.row;
int const frozen_width = sv->unfrozen_top_left.col -
sv->frozen_top_left.col;
guint16 freeze_type; /* NOTE docs lie, this is not 'active pane' */
if (sv_is_frozen (sv)) {
data = ms_biff_put_len_next (bp, BIFF_PANE, 10);
if (sv->unfrozen_top_left.col > 0)
freeze_type = (sv->unfrozen_top_left.row > 0) ? 0 : 1;
else
freeze_type = (sv->unfrozen_top_left.row > 0) ? 2 : 3;
if (sv->unfrozen_top_left.col > 0)
freeze_type = (sv->unfrozen_top_left.row > 0) ? 0 : 1;
else
freeze_type = (sv->unfrozen_top_left.row > 0) ? 2 : 3;
GSF_LE_SET_GUINT16 (data + 0, frozen_width);
GSF_LE_SET_GUINT16 (data + 2, frozen_height);
GSF_LE_SET_GUINT16 (data + 4, sv->initial_top_left.row);
GSF_LE_SET_GUINT16 (data + 6, sv->initial_top_left.col);
GSF_LE_SET_GUINT16 (data + 8, freeze_type);
GSF_LE_SET_GUINT16 (data + 0, frozen_width);
GSF_LE_SET_GUINT16 (data + 2, frozen_height);
GSF_LE_SET_GUINT16 (data + 4, frozen_topLeft.row);
GSF_LE_SET_GUINT16 (data + 6, frozen_topLeft.col);
GSF_LE_SET_GUINT16 (data + 8, freeze_type);
ms_biff_put_commit (bp);
ms_biff_put_commit (bp);
}
}
/*
......@@ -2200,7 +2246,7 @@ cb_cell_pre_pass (gpointer ignored, GnmCell const *cell, ExcelWriteState *ewb)
return;
if ((fmt = VALUE_FMT (cell->value)) != NULL) {
style = cell_get_mstyle (cell);
style = cell_get_style (cell);
/* Collect unique fonts in rich text */
if (VALUE_IS_STRING (cell->value) &&
......@@ -4116,11 +4162,11 @@ excel_write_SCL (BiffPut *bp, double zoom, gboolean force)
}
static void
excel_write_SELECTION (BiffPut *bp, GList *selections,
excel_write_SELECTION (BiffPut *bp, GSList *selections,
GnmCellPos const *pos, int pane)
{
int n = g_list_length (selections);
GList *ptr;
int n = g_slist_length (selections);
GSList *ptr;
guint8 *data;
data = ms_biff_put_len_next (bp, BIFF_SELECTION, 9 + 6*n);
......@@ -4145,7 +4191,7 @@ excel_write_selections (BiffPut *bp, ExcelWriteSheet *esheet, SheetView *sv)
{
GnmRange r;
GnmCellPos pos;
GList *tmp;
GSList *tmp;
excel_write_SELECTION (bp, sv->selections, &sv->edit_pos, 3);
......@@ -4153,26 +4199,26 @@ excel_write_selections (BiffPut *bp, ExcelWriteSheet *esheet, SheetView *sv)
pos = sv->edit_pos;
if (pos.col < sv->unfrozen_top_left.col)
pos.col = sv->unfrozen_top_left.col;
tmp = g_list_prepend (NULL,
tmp = g_slist_prepend (NULL,
range_init_cellpos (&r, &pos, &pos));
excel_write_SELECTION (bp, tmp, &pos, 1);
g_list_free (tmp);
g_slist_free (tmp);
}
if (sv->unfrozen_top_left.row > 0) {
pos = sv->edit_pos;
if (pos.row < sv->unfrozen_top_left.row)
pos.row = sv->unfrozen_top_left.row;
tmp = g_list_prepend (NULL,
tmp = g_slist_prepend (NULL,
range_init_cellpos (&r, &pos, &pos));
excel_write_SELECTION (bp, tmp, &pos, 2);
g_list_free (tmp);
g_slist_free (tmp);
}
if (sv->unfrozen_top_left.col > 0 && sv->unfrozen_top_left.row > 0) {
pos = sv->edit_pos; /* apparently no bounds check needed */
tmp = g_list_prepend (NULL,
tmp = g_slist_prepend (NULL,
range_init_cellpos (&r, &pos, &pos));
excel_write_SELECTION (bp, tmp, &pos, 0);
g_list_free (tmp);
g_slist_free (tmp);
}
}
......@@ -4473,8 +4519,8 @@ excel_write_sheet (ExcelWriteState *ewb, ExcelWriteSheet *esheet)
guint32 block_end;
gint32 y;
int rows_in_block = ROW_BLOCK_MAX_LEN;
unsigned index_off;
MsBiffFileType type;
unsigned index_off;
MsBiffFileType type;
/* No. of blocks of rows. Only correct as long as all rows
* _including empties_ have row info records
......@@ -4536,8 +4582,7 @@ excel_write_sheet (ExcelWriteState *ewb, ExcelWriteSheet *esheet)
excel_write_objs_v8 (esheet);
SHEET_FOREACH_VIEW (esheet->gnum_sheet, view, {
if (excel_write_WINDOW2 (ewb->bp, esheet, view))
excel_write_PANE (ewb->bp, esheet, view);
excel_write_WINDOW2 (ewb->bp, esheet, view);
excel_write_SCL (ewb->bp, /* zoom will move to view eentually */
esheet->gnum_sheet->last_zoom_factor_used, FALSE);
excel_write_selections (ewb->bp, esheet, view);
......@@ -4575,43 +4620,12 @@ excel_sheet_new (ExcelWriteState *ewb, Sheet *sheet,
ExcelWriteSheet *esheet = g_new (ExcelWriteSheet, 1);
GnmRange extent;
GSList *objs, *img;
int i;
g_return_val_if_fail (sheet, NULL);
g_return_val_if_fail (ewb, NULL);
/* Ignore spans and merges past the bound */
extent = sheet_get_extent (sheet, FALSE);
if (extent.end.row >= maxrows) {
gnm_io_warning (ewb->io_context,
_("Some content will be lost when saving as MS Excel (tm) 95. "
"It only supports %d rows, and this workbook has %d"),
maxrows, extent.end.row);
extent.end.row = maxrows;
}
if (extent.end.col >= 256) {
gnm_io_warning (ewb->io_context,
_("Some content will be lost when saving as MS Excel (tm). "
"It only supports %d rows, and this workbook has %d"),
256, extent.end.col);
extent.end.col = 256;
}
sheet_style_get_extent (sheet, &extent, esheet->col_style);
/* include collapsed or hidden rows */
for (i = maxrows ; i-- > extent.end.row ; )
if (!colrow_is_empty (sheet_row_get (sheet, i))) {
extent.end.row = i;
break;