Commit 186ac28d authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Some improvements to blip loading.

and some tuning that greatly improves startup time.

2001-03-30  Jody Goldberg <jgoldberg@home.com>

	* ms-container.c (ms_container_init) : Take a parent container.
	(ms_container_finalize) : handle NULL blips smoothly.
	(ms_container_get_blip) : check the container if we are empty.

	* ms-escher.c (ms_escher_read_Blip) : always register a blip, even if
	  it is NULL, otherwise the index gets confused.  Move the
	  registration here.
	(ms_escher_blip_new) : from here.
	(ms_escher_read_ClientData) : replace blips we can't understand with
	  rectangles.

	* ms-chart.c (ms_excel_chart) : Pass in the charts container.

	* ms-excel-read.c (ms_excel_workbook_new) : workbook have no parents.
	(ms_excel_sheet_new) : Sheets are contained by workbooks.

2001-03-30  Jody Goldberg <jgoldberg@home.com>

	* src/workbook-control-gui.c (wbcg_sheet_remove_all) : clear the
	  notebook BEFORE deleting it to avoid updating during destuction.

	* src/cellspan.c (cell_calc_span) : Cells in hidden columns can not
	  have spans.

	* src/file.c (file_finish_load) : no need to manually respan this will
	  happen via sheet_update.  This gives us a nice speed up.

	* src/sheet.c (sheet_cell_calc_span) : don't reregister spans that
	  have not changed.
	(sheet_new) : init all flags to true to ensure things get updated.
parent 3dd3f587
......@@ -8,22 +8,6 @@ release, and longer term bugs.
Release Critical
----------------
- While *loading* Vlad's e95 sheet, I get...
UMR: Uninitialized memory read
ms_excel_get_style_from_xf [ms-excel-read.c:1200]
ms_excel_set_xf [ms-excel-read.c:1385]
ms_excel_sheet_insert [ms-excel-read.c:1773]
ms_excel_read_cell [ms-excel-read.c:3131]
ms_excel_read_sheet [ms-excel-read.c:3756]
ms_excel_read_workbook [ms-excel-read.c:4004]
...allocated from...
biff_xf_data_new [ms-excel-read.c:1481]
ms_excel_read_workbook [ms-excel-read.c:4083]
excel_file_open [boot.c:108]
Long term breakage
------------------
......@@ -115,7 +99,7 @@ Long term breakage
- should scale with font size. (Say, max (1, font->descent/4?)
gnome-print has a function we could use for printing which returns the
underline thickness.
- Should be visible in the edit-item
- Should be visible in the edit-item (should edit item use cell_draw ?)
- Functions like SUMPRODUCT need to have better support for sparse ranges.
We should probably create synchronously_walk_ranges. (XL goes kaboom on
......
2001-03-30 Jody Goldberg <jgoldberg@home.com>
* src/workbook-control-gui.c (wbcg_sheet_remove_all) : clear the
notebook BEFORE deleting it to avoid updating during destuction.
* src/cellspan.c (cell_calc_span) : Cells in hidden columns can not
have spans.
* src/file.c (file_finish_load) : no need to manually respan this will
happen via sheet_update. This gives us a nice speed up.
* src/sheet.c (sheet_cell_calc_span) : don't reregister spans that
have not changed.
(sheet_new) : init all flags to true to ensure things get updated.
* src/main.c : remove style_debug option tha was unused.
* src/mstyle.c (mstyle_elements_equal) : It was only mostly unused :-)
......
2001-03-30 Jody Goldberg <jgoldberg@home.com>
* src/workbook-control-gui.c (wbcg_sheet_remove_all) : clear the
notebook BEFORE deleting it to avoid updating during destuction.
* src/cellspan.c (cell_calc_span) : Cells in hidden columns can not
have spans.
* src/file.c (file_finish_load) : no need to manually respan this will
happen via sheet_update. This gives us a nice speed up.
* src/sheet.c (sheet_cell_calc_span) : don't reregister spans that
have not changed.
(sheet_new) : init all flags to true to ensure things get updated.
* src/main.c : remove style_debug option tha was unused.
* src/mstyle.c (mstyle_elements_equal) : It was only mostly unused :-)
......
2001-03-30 Jody Goldberg <jgoldberg@home.com>
* src/workbook-control-gui.c (wbcg_sheet_remove_all) : clear the
notebook BEFORE deleting it to avoid updating during destuction.
* src/cellspan.c (cell_calc_span) : Cells in hidden columns can not
have spans.
* src/file.c (file_finish_load) : no need to manually respan this will
happen via sheet_update. This gives us a nice speed up.
* src/sheet.c (sheet_cell_calc_span) : don't reregister spans that
have not changed.
(sheet_new) : init all flags to true to ensure things get updated.
* src/main.c : remove style_debug option tha was unused.
* src/mstyle.c (mstyle_elements_equal) : It was only mostly unused :-)
......
2001-03-30 Jody Goldberg <jgoldberg@home.com>
* src/workbook-control-gui.c (wbcg_sheet_remove_all) : clear the
notebook BEFORE deleting it to avoid updating during destuction.
* src/cellspan.c (cell_calc_span) : Cells in hidden columns can not
have spans.
* src/file.c (file_finish_load) : no need to manually respan this will
happen via sheet_update. This gives us a nice speed up.
* src/sheet.c (sheet_cell_calc_span) : don't reregister spans that
have not changed.
(sheet_new) : init all flags to true to ensure things get updated.
* src/main.c : remove style_debug option tha was unused.
* src/mstyle.c (mstyle_elements_equal) : It was only mostly unused :-)
......
2001-03-30 Jody Goldberg <jgoldberg@home.com>
* src/workbook-control-gui.c (wbcg_sheet_remove_all) : clear the
notebook BEFORE deleting it to avoid updating during destuction.
* src/cellspan.c (cell_calc_span) : Cells in hidden columns can not
have spans.
* src/file.c (file_finish_load) : no need to manually respan this will
happen via sheet_update. This gives us a nice speed up.
* src/sheet.c (sheet_cell_calc_span) : don't reregister spans that
have not changed.
(sheet_new) : init all flags to true to ensure things get updated.
* src/main.c : remove style_debug option tha was unused.
* src/mstyle.c (mstyle_elements_equal) : It was only mostly unused :-)
......
This diff is collapsed.
......@@ -2017,7 +2017,7 @@ ms_excel_chart (BiffQuery *q, MSContainer *container, MsBiffVersion ver)
BC(register_handlers)();
/* FIXME : create an anchor parser for charts */
ms_container_init (&state.container, NULL);
ms_container_init (&state.container, NULL, container);
state.container.ver = ver;
state.depth = 0;
......
......@@ -16,12 +16,14 @@
#include "ms-obj.h"
void
ms_container_init (MSContainer *container, MSContainerClass const *vtbl)
ms_container_init (MSContainer *container, MSContainerClass const *vtbl,
MSContainer *parent_container)
{
container->vtbl = vtbl;
container->free_blips = TRUE;
container->blips = NULL;
container->obj_queue = NULL;
container->parent_container = parent_container;
}
void
......@@ -32,8 +34,11 @@ ms_container_finalize (MSContainer *container)
g_return_if_fail (container != NULL);
if (container->free_blips && container->blips != NULL) {
for (i = container->blips->len; i-- > 0 ; )
ms_escher_blip_destroy (g_ptr_array_index (container->blips, i));
for (i = container->blips->len; i-- > 0 ; ) {
MSEscherBlip *blip = g_ptr_array_index (container->blips, i);
if (blip != NULL)
ms_escher_blip_destroy (blip);
}
g_ptr_array_free (container->blips, TRUE);
container->blips = NULL;
......@@ -61,8 +66,13 @@ MSEscherBlip const *
ms_container_get_blip (MSContainer *container, int blip_id)
{
g_return_val_if_fail (container != NULL, NULL);
g_return_val_if_fail (container->blips != NULL, NULL);
g_return_val_if_fail (blip_id >= 0, NULL);
if (container->parent_container != NULL &&
(container->blips == NULL || container->blips->len == 0))
return ms_container_get_blip (container->parent_container,
blip_id);
g_return_val_if_fail (blip_id < container->blips->len, NULL);
return g_ptr_array_index (container->blips, blip_id);
......
......@@ -24,9 +24,13 @@ struct _MSContainer
gboolean free_blips;
GPtrArray *blips;
GList *obj_queue;
/* This is the container containing this container */
MSContainer *parent_container;
};
void ms_container_init (MSContainer *container, MSContainerClass const *vtbl);
void ms_container_init (MSContainer *container, MSContainerClass const *vtbl,
MSContainer *parent_container);
void ms_container_finalize (MSContainer *container);
void ms_container_add_blip (MSContainer *c, MSEscherBlip *blip);
......
......@@ -20,6 +20,13 @@
#include "ms-excel-read.h"
#include "ms-obj.h"
#ifdef ENABLE_BONOBO
# include <bonobo/bonobo-stream.h>
# include <bonobo/bonobo-stream-memory.h>
# include "sheet-object-container.h"
# include "sheet-object-graphic.h"
#endif
/* A storage accumulator for common state information */
typedef struct
{
......@@ -51,9 +58,8 @@ typedef struct _MSEscherHeader
} MSEscherHeader;
#define common_header_len 8
static void
ms_escher_blip_new (const guint8 *data, guint32 len, char const *repoid,
MSContainer *container)
static MSEscherBlip *
ms_escher_blip_new (guint8 const *data, guint32 len, char const *repoid)
{
MSEscherBlip *blip = g_new (MSEscherBlip, 1);
......@@ -65,7 +71,7 @@ ms_escher_blip_new (const guint8 *data, guint32 len, char const *repoid,
blip->stream = bonobo_stream_mem_create (data, len, TRUE, FALSE);
#endif
blip->obj_id = repoid;
ms_container_add_blip (container, blip);
return blip;
}
void
......@@ -92,7 +98,7 @@ ms_escher_blip_destroy (MSEscherBlip *blip)
* drawing record size seems to only count the draw records. When we only add
* those the sizes match perfectly.
*/
static const guint8 *
static guint8 const *
ms_escher_get_data (MSEscherState * state,
gint offset, /* bytes from logical start of the stream */
guint num_bytes, /* how many bytes we want, incl prefix */
......@@ -233,7 +239,7 @@ static gboolean
ms_escher_read_SplitMenuColors (MSEscherState * state, MSEscherHeader * h)
{
gboolean needs_free;
const guint8 * data;
guint8 const * data;
g_return_val_if_fail (h->instance == 4, TRUE);
g_return_val_if_fail (h->len == 24, TRUE); /* header + 4*4 */
......@@ -277,7 +283,7 @@ bliptype_name (int const type)
#ifndef NO_DEBUG_EXCEL
static void
write_file (gchar const * const name, const guint8 * data,
write_file (gchar const * const name, guint8 const * data,
gint len, int stored_type)
{
static int num = 0;
......@@ -306,7 +312,7 @@ ms_escher_read_BSE (MSEscherState * state, MSEscherHeader * h)
{
/* read the header */
gboolean needs_free;
const guint8 * data =
guint8 const * data =
ms_escher_get_data (state, h->offset, 36,
common_header_len, &needs_free);
guint8 const win_type = MS_OLE_GET_GUINT8 (data + 0);
......@@ -315,8 +321,8 @@ ms_escher_read_BSE (MSEscherState * state, MSEscherHeader * h)
guint32 const size = MS_OLE_GET_GUINT32 (data + 20);
guint32 const ref_count = MS_OLE_GET_GUINT32 (data + 24);
gint32 const del_offset = MS_OLE_GET_GUINT32 (data + 28);
const guint8 is_texture = MS_OLE_GET_GUINT8 (data + 32);
const guint8 name_len = MS_OLE_GET_GUINT8 (data + 33);
guint8 const is_texture = MS_OLE_GET_GUINT8 (data + 32);
guint8 const name_len = MS_OLE_GET_GUINT8 (data + 33);
guint8 checksum[16]; /* RSA Data Security, Inc. MD4 Message-Digest Algorithm */
char *name = "unknown";
int i;
......@@ -352,6 +358,9 @@ ms_escher_read_BSE (MSEscherState * state, MSEscherHeader * h)
/* Ignore empties */
if (h->len > 36 + common_header_len)
return ms_escher_read_container (state, h, 36);
/* Store a blank */
ms_container_add_blip (state->container, NULL);
return FALSE;
}
......@@ -360,6 +369,8 @@ ms_escher_read_Blip (MSEscherState * state, MSEscherHeader * h)
{
int primary_uid_size = 0;
guint32 blip_instance = h->instance;
gboolean res = FALSE;
MSEscherBlip *blip = NULL;
/* This doesn't make alot of sense.
* Which is the normative indicator of what type the blip is ?
......@@ -402,7 +413,7 @@ ms_escher_read_Blip (MSEscherState * state, MSEscherHeader * h)
h->len, header, &needs_free);
repoid = "OAFIID:GNOME_EOG_Embeddable";
ms_escher_blip_new (data, h->len - header, repoid, state->container);
blip = ms_escher_blip_new (data, h->len - header, repoid);
#ifndef NO_DEBUG_EXCEL
if (ms_excel_escher_debug > 1)
......@@ -418,9 +429,10 @@ ms_escher_read_Blip (MSEscherState * state, MSEscherHeader * h)
default:
g_warning ("Don't know what to do with this image %x\n", h->instance);
return TRUE;
res = TRUE;
};
return FALSE;
ms_container_add_blip (state->container, blip);
return res;
}
static gboolean
......@@ -596,7 +608,7 @@ static gboolean
ms_escher_read_Sp (MSEscherState * state, MSEscherHeader * h)
{
gboolean needs_free;
const guint8 *data =
guint8 const *data =
ms_escher_get_data (state, h->offset, 8,
common_header_len, &needs_free);
......@@ -655,7 +667,7 @@ static gboolean
ms_escher_read_ClientAnchor (MSEscherState *state, MSEscherHeader *h)
{
gboolean needs_free;
const guint8 *data;
guint8 const *data;
g_return_val_if_fail (!h->anchor_set, TRUE);
g_return_val_if_fail (state != NULL, TRUE);
......@@ -753,7 +765,7 @@ ms_escher_read_Dgg (MSEscherState *state, MSEscherHeader *h)
FDGG fd;
guint32 lp;
const guint8 *data = h->data + common_header_len;
guint8 const *data = h->data + common_header_len;
fd.id_clusts = g_array_new (1, 1, sizeof(ID_CLUST));
fd.max_spid = MS_OLE_GET_GUINT32(data+ 0);
fd.num_id_clust = MS_OLE_GET_GUINT32(data+ 4);
......@@ -1050,11 +1062,11 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
{
int const num_properties = h->instance;
gboolean needs_free;
const guint8 * const data =
guint8 const * const data =
ms_escher_get_data (state, h->offset, h->len,
common_header_len, &needs_free);
const guint8 *fopte = data;
const guint8 *extra = fopte + 6*num_properties;
guint8 const *fopte = data;
guint8 const *extra = fopte + 6*num_properties;
guint prev_pid = 0; /* A debug tool */
char const *name;
int i;
......@@ -1761,11 +1773,14 @@ ms_escher_read_ClientData (MSEscherState *state, MSEscherHeader *h)
MSEscherBlip const *blip = ms_container_get_blip (
state->container, h->blip_id);
g_return_val_if_fail (blip != NULL, FALSE);
g_return_val_if_fail (sob != NULL, FALSE);
if (!sheet_object_bonobo_set_object_iid (sob, blip->obj_id) ||
!sheet_object_bonobo_load_stream (sob, blip->stream))
/* replace blips we don't know how to handle with rectangles */
if (blip == NULL) {
gtk_object_destroy (obj->gnum_obj);
obj->gnum_obj = GTK_OBJECT (sheet_object_box_new (FALSE));
} else if (!sheet_object_bonobo_set_object_iid (sob, blip->obj_id) ||
!sheet_object_bonobo_load_stream (sob, blip->stream))
g_warning ("Failed to load '%s' from stream",
blip->obj_id);
}
......@@ -1804,7 +1819,7 @@ ms_escher_read_container (MSEscherState *state, MSEscherHeader *container,
MSEscherHeader *container) = NULL;
gboolean needs_free;
const guint8 *data =
guint8 const *data =
ms_escher_get_data (state, h.offset, common_header_len,
0, &needs_free);
......
......@@ -39,6 +39,9 @@
#include "ms-excel-xf.h"
#include "sheet-object-widget.h"
#include "sheet-object-graphic.h"
#ifdef ENABLE_BONOBO
# include "sheet-object-container.h"
#endif
/* #define NO_DEBUG_EXCEL */
......@@ -1622,8 +1625,10 @@ biff_xf_data_new (ExcelWorkbook *wb, BiffQuery *q, MsBiffVersion ver)
printf ("Unknown location %d\n", subdata);
break;
}
}
if (ver == MS_BIFF_V8) { /*
} else
xf->indent = 0;
if (ver == MS_BIFF_V8) {/*
* Very different
*/
int has_diagonals, diagonal_style;
......@@ -2311,7 +2316,7 @@ ms_excel_sheet_new (ExcelWorkbook *wb, const char *name)
ans->gnum_sheet = sheet_new (wb->gnum_wb, name);
ms_container_init (&ans->container, &vtbl);
ms_container_init (&ans->container, &vtbl, &wb->container);
ans->wb = wb;
......@@ -2452,7 +2457,7 @@ ms_excel_workbook_new (MsBiffVersion ver)
ExcelWorkbook *ans = (ExcelWorkbook *) g_malloc (sizeof (ExcelWorkbook));
ms_container_init (&ans->container, &vtbl);
ms_container_init (&ans->container, &vtbl, NULL);
ans->container.ver = ver;
ans->extern_sheets = NULL;
......
......@@ -12,14 +12,6 @@
**/
#include "config.h"
#ifdef ENABLE_BONOBO
# include <bonobo/bonobo-stream.h>
# include <bonobo/bonobo-stream-memory.h>
# include "sheet-object-container.h"
#else
# include "sheet-object.h"
#endif
#include "ms-excel-read.h"
#define MS_ANCHOR_SIZE 18
......@@ -27,7 +19,7 @@
struct _MSObj
{
/* In pixels */
guint8 raw_anchor[MS_ANCHOR_SIZE];
guint8 raw_anchor [MS_ANCHOR_SIZE];
gboolean anchor_set;
int id;
......
......@@ -87,6 +87,7 @@ cell_register_span (Cell const * const cell, int left, int right)
spaninfo->left = left;
spaninfo->right = right;
g_return_if_fail (row_span_get (ri, i) == NULL);
g_hash_table_insert (ri->spans, GINT_TO_POINTER(i), spaninfo);
}
}
......@@ -199,7 +200,8 @@ cell_calc_span (Cell const * const cell, int * const col1, int * const col2)
/*
* Report only one column is used if
* - Cell is going to re recalculated
* - Cell is going to be recalculated
* - Cell is in a hidden col
* - Cell is a number
* - Cell is the top left of a merged cell
* - The text fits inside column (for non center across selection)
......@@ -220,6 +222,7 @@ cell_calc_span (Cell const * const cell, int * const col1, int * const col2)
indented_w += cell_rendered_offset (cell);
if (cell_needs_recalc (cell) ||
!cell->col_info->visible ||
((indented_w <= COL_INTERNAL_WIDTH (cell->col_info)) &&
align != HALIGN_CENTER_ACROSS_SELECTION) ||
align == HALIGN_JUSTIFY ||
......
......@@ -387,13 +387,6 @@ file_finish_load (WorkbookControl *wbc, WorkbookView *new_wbv)
workbook_recalc (wb_view_workbook (new_wbv));
/*
* render and calc size of unrendered cells, then calc spans
* for everything
*/
workbook_calc_spans (wb_view_workbook (new_wbv),
SPANCALC_RENDER|SPANCALC_RESIZE);
/* FIXME : This should not be needed */
workbook_set_dirty (wb_view_workbook (new_wbv), FALSE);
......
......@@ -2,6 +2,7 @@
#define PRINT_INFO_H
#include "gnumeric.h"
#include <libgnome/gnome-paper.h> /* for typedef of GnomePaper */
typedef enum {
PRINT_ORIENT_HORIZONTAL,
......
......@@ -122,14 +122,14 @@ sheet_new (Workbook *wb, char const *name)
#endif
/* Init, focus, and load handle setting these if/when necessary */
sheet->priv->edit_pos.location_changed = FALSE;
sheet->priv->edit_pos.content_changed = FALSE;
sheet->priv->edit_pos.format_changed = FALSE;
sheet->priv->selection_content_changed = FALSE;
sheet->priv->reposition_selection = FALSE;
sheet->priv->recompute_visibility = FALSE;
sheet->priv->recompute_spans = FALSE;
sheet->priv->edit_pos.location_changed = TRUE;
sheet->priv->edit_pos.content_changed = TRUE;
sheet->priv->edit_pos.format_changed = TRUE;
sheet->priv->selection_content_changed = TRUE;
sheet->priv->reposition_selection = TRUE;
sheet->priv->recompute_visibility = TRUE;
sheet->priv->recompute_spans = TRUE;
sheet->priv->reposition_objects.row = SHEET_MAX_ROWS;
sheet->priv->reposition_objects.col = SHEET_MAX_COLS;
......@@ -347,8 +347,14 @@ sheet_cell_calc_span (Cell const *cell, SpanCalcFlags flags)
max_col = right;
/* This cell already had an existing span */
if (existing && (left != span->left || right != span->right))
cell_unregister_span (cell);
if (existing) {
/* If it changed, remove the old one */
if (left != span->left || right != span->right)
cell_unregister_span (cell);
else
/* unchaged, short curcuit adding the span again */
left = right;
}
if (left != right)
cell_register_span (cell, left, right);
......
......@@ -593,9 +593,13 @@ wbcg_sheet_remove_all (WorkbookControl *wbc)
WorkbookControlGUI *wbcg = (WorkbookControlGUI *)wbc;
if (wbcg->notebook != NULL) {
gtk_container_remove (GTK_CONTAINER (wbcg->table),
GTK_WIDGET (wbcg->notebook));
GtkWidget *tmp = GTK_WIDGET (wbcg->notebook);
/* Clear notebook to disable updates as focus changes for pages
* during destruction
*/
wbcg->notebook = NULL;
gtk_container_remove (GTK_CONTAINER (wbcg->table), tmp);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment