Commit 392a27a4 authored by Michael Meeks's avatar Michael Meeks
Browse files

Stupid freeze bug fixed.

Deep freeze/thaw of cell redraws implemented.
XML-io now freezes / thaws for speed on load.
parent 7de12d38
1999-05-06 Michael Meeks <michael@imaginator.com>
* src/cell.h: Added deep freeze prototypes.
* src/cell.c (cell_deep_freeze_redraws): Added
(cell_deep_thaw_redraws): Added,
(cell_queue_redraw): Updated to use deep_freeze
effectively ignore redraw requests.
* src/xml-io.c (readXmlCell): Added deep freeze/thaw
redraws for clean and easy speedup.
1999-05-06 Michael Meeks <michael@imaginator.com>
* src/workbook.c: Moved 'Sort' to the tools menu.
* HACKING: Pedantic clean.
......
1999-05-06 Michael Meeks <michael@imaginator.com>
* src/cell.h: Added deep freeze prototypes.
* src/cell.c (cell_deep_freeze_redraws): Added
(cell_deep_thaw_redraws): Added,
(cell_queue_redraw): Updated to use deep_freeze
effectively ignore redraw requests.
* src/xml-io.c (readXmlCell): Added deep freeze/thaw
redraws for clean and easy speedup.
1999-05-06 Michael Meeks <michael@imaginator.com>
* src/workbook.c: Moved 'Sort' to the tools menu.
* HACKING: Pedantic clean.
......
1999-05-06 Michael Meeks <michael@imaginator.com>
* src/cell.h: Added deep freeze prototypes.
* src/cell.c (cell_deep_freeze_redraws): Added
(cell_deep_thaw_redraws): Added,
(cell_queue_redraw): Updated to use deep_freeze
effectively ignore redraw requests.
* src/xml-io.c (readXmlCell): Added deep freeze/thaw
redraws for clean and easy speedup.
1999-05-06 Michael Meeks <michael@imaginator.com>
* src/workbook.c: Moved 'Sort' to the tools menu.
* HACKING: Pedantic clean.
......
1999-05-06 Michael Meeks <michael@imaginator.com>
* src/cell.h: Added deep freeze prototypes.
* src/cell.c (cell_deep_freeze_redraws): Added
(cell_deep_thaw_redraws): Added,
(cell_queue_redraw): Updated to use deep_freeze
effectively ignore redraw requests.
* src/xml-io.c (readXmlCell): Added deep freeze/thaw
redraws for clean and easy speedup.
1999-05-06 Michael Meeks <michael@imaginator.com>
* src/workbook.c: Moved 'Sort' to the tools menu.
* HACKING: Pedantic clean.
......
1999-05-06 Michael Meeks <michael@imaginator.com>
* ms-ole.c (ms_biff_query_new, ms_biff_merge_continues)
Better merge support.
* ms-biff.h (_BIFF_QUERY): Added merge count
1999-05-06 Michael Meeks <michael@imaginator.com>
* ms-excel.c (ms_excelReadWorkbook): Added freeze /
......
......@@ -8,10 +8,10 @@
#define GNUMERIC_BIFF_H
#include "ms-ole.h"
typedef guint8 BYTE ;
typedef guint16 WORD ;
typedef guint32 LONG ;
typedef guint64 DLONG ;
typedef guint8 BYTE;
typedef guint16 WORD;
typedef guint32 LONG;
typedef guint64 DLONG;
#define BIFF_GETBYTE(p) (*((const BYTE *)(p)+0))
#define BIFF_GETWORD(p) (guint16)(*((const BYTE *)(p)+0) | (*((const BYTE *)(p)+1)<<8))
......@@ -40,20 +40,24 @@ typedef struct _BIFF_QUERY
guint32 length; /* NB. can be extended by a continue opcode */
guint8 *data;
guint32 streamPos;
guint16 num_merges;
int data_malloced; /* is *data a copy ? */
MS_OLE_STREAM *pos;
} BIFF_QUERY ;
} BIFF_QUERY;
/* Sets up a query on a stream */
extern BIFF_QUERY *ms_biff_query_new (MS_OLE_STREAM *) ;
extern BIFF_QUERY *ms_biff_query_new (MS_OLE_STREAM *);
/* Duplicates this query, so chaining can re-commence here */
extern BIFF_QUERY *ms_biff_query_copy (const BIFF_QUERY *p) ;
extern BIFF_QUERY *ms_biff_query_copy (const BIFF_QUERY *p);
/**
* Updates the BIFF_QUERY structure with the next BIFF record
* returns: 1 for succes, and 0 for EOS(tream)
**/
extern int ms_biff_query_next (BIFF_QUERY *) ;
extern void ms_biff_query_destroy (BIFF_QUERY *) ;
extern int ms_biff_query_next (BIFF_QUERY *);
extern int ms_biff_query_next_merge (BIFF_QUERY *, gboolean do_merge);
/* Converts a merged query to the un-merged equivalent */
extern void ms_biff_query_unmerge (BIFF_QUERY *);
extern void ms_biff_query_destroy (BIFF_QUERY *);
/* Returns a stream which contains the data in the BIFF record. */
extern MS_OLE_STREAM *ms_biff_query_data_to_stream (BIFF_QUERY *);
#endif
......@@ -2048,7 +2048,7 @@ ms_excelReadWorkbook (MS_OLE * file)
MS_EXCEL_WORKBOOK *wb = NULL;
xmlNodePtr child;
cell_freeze_redraws ();
cell_deep_freeze_redraws ();
if (1){ /* ? */
MS_OLE_STREAM *stream;
......@@ -2286,7 +2286,7 @@ ms_excelReadWorkbook (MS_OLE * file)
ms_ole_stream_close (stream);
}
cell_thaw_redraws ();
cell_deep_thaw_redraws ();
if (wb)
{
......
......@@ -2048,7 +2048,7 @@ ms_excelReadWorkbook (MS_OLE * file)
MS_EXCEL_WORKBOOK *wb = NULL;
xmlNodePtr child;
cell_freeze_redraws ();
cell_deep_freeze_redraws ();
if (1){ /* ? */
MS_OLE_STREAM *stream;
......@@ -2286,7 +2286,7 @@ ms_excelReadWorkbook (MS_OLE * file)
ms_ole_stream_close (stream);
}
cell_thaw_redraws ();
cell_deep_thaw_redraws ();
if (wb)
{
......
......@@ -1459,6 +1459,7 @@ ms_biff_query_new (MS_OLE_STREAM *ptr)
bq->length = 0;
bq->data_malloced = 0;
bq->pos = ptr;
bq->num_merges = 0;
#if OLE_DEBUG > 0
dump_biff(bq);
#endif
......@@ -1523,6 +1524,7 @@ ms_biff_merge_continues (BIFF_QUERY *bq, guint32 len)
g_array_append_val (contin, chunk);
chunk.length = BIFF_GETWORD (tmp+2);
bq->num_merges++;
} while ((BIFF_GETWORD(tmp) & 0xff) == BIFF_CONTINUE);
bq->pos->lseek (bq->pos, -4, MS_OLE_SEEK_CUR); /* back back off */
......@@ -1552,12 +1554,31 @@ ms_biff_merge_continues (BIFF_QUERY *bq, guint32 len)
return 1;
}
void
ms_biff_query_unmerge (BIFF_QUERY *bq)
{
if (!bq || !bq->num_merges)
return;
bq->pos->lseek (bq->pos, -(4*(bq->num_merges+1)
+ bq->length), MS_OLE_SEEK_CUR);
ms_biff_query_next_merge (bq, FALSE);
}
/**
* Returns 0 if has hit end
* NB. if this crashes obscurely, array is being extended over the stack !
**/
int
ms_biff_query_next (BIFF_QUERY *bq)
{
return ms_biff_query_next_merge (bq, TRUE);
}
/**
* Returns 0 if has hit end
**/
int
ms_biff_query_next_merge (BIFF_QUERY *bq, gboolean do_merge)
{
guint8 tmp[4];
int ans=1;
......@@ -1565,6 +1586,7 @@ ms_biff_query_next (BIFF_QUERY *bq)
if (!bq || bq->pos->position >= bq->pos->size)
return 0;
if (bq->data_malloced) {
bq->num_merges = 0;
g_free (bq->data);
bq->data_malloced = 0;
}
......@@ -1585,7 +1607,7 @@ ms_biff_query_next (BIFF_QUERY *bq)
} else
bq->data_malloced = 1;
}
if (ans &&
if (ans && do_merge &&
bq->pos->read_copy (bq->pos, tmp, 4)) {
if ((BIFF_GETWORD(tmp) & 0xff) == BIFF_CONTINUE)
return ms_biff_merge_continues (bq, BIFF_GETWORD(tmp+2));
......
......@@ -2,8 +2,8 @@
* fn-stat.c: Built in statistical functions and functions registration
*
* Authors:
* Michael Meeks <michael@imaginator.com>
* Jukka-Pekka Iivonen <iivonen@iki.fi>
* Michael Meeks <michael@imaginator.com>
* Morten Welinder <terra@diku.dk>
*/
#include <config.h>
......
......@@ -15,7 +15,8 @@
#include "cursors.h"
#include "utils.h"
static int redraws_frozen = 0;
static int redraws_frozen = 0;
static int redraws_deep_frozen = 0;
static GHashTable *cell_hash_queue;
void
......@@ -896,6 +897,19 @@ cell_thaw_redraws (void)
cell_hash_queue = NULL;
}
}
void
cell_deep_freeze_redraws (void)
{
redraws_deep_frozen++;
}
void
cell_deep_thaw_redraws (void)
{
redraws_deep_frozen--;
if (redraws_frozen < 0)
g_warning ("unbalanced deep freeze/thaw\n");
}
static void
queue_cell (Cell *cell)
......@@ -908,6 +922,10 @@ queue_cell (Cell *cell)
void
cell_queue_redraw (Cell *cell)
{
/* You wake up dead after a deep freeze */
if (redraws_deep_frozen>0)
return;
g_return_if_fail (cell != NULL);
if (redraws_frozen){
......
......@@ -176,6 +176,12 @@ void cell_unrealize (Cell *cell);
void cell_thaw_redraws (void);
void cell_freeze_redraws (void);
/*
* Optimizations to stop any queueing of redraws.
*/
void cell_deep_thaw_redraws (void);
void cell_deep_freeze_redraws (void);
/*
* Routines used to lookup which cells displays on a given column
*
......
......@@ -2,8 +2,8 @@
* fn-stat.c: Built in statistical functions and functions registration
*
* Authors:
* Michael Meeks <michael@imaginator.com>
* Jukka-Pekka Iivonen <iivonen@iki.fi>
* Michael Meeks <michael@imaginator.com>
* Morten Welinder <terra@diku.dk>
*/
#include <config.h>
......
......@@ -2,8 +2,8 @@
* fn-stat.c: Built in statistical functions and functions registration
*
* Authors:
* Michael Meeks <michael@imaginator.com>
* Jukka-Pekka Iivonen <iivonen@iki.fi>
* Michael Meeks <michael@imaginator.com>
* Morten Welinder <terra@diku.dk>
*/
#include <config.h>
......
......@@ -1234,6 +1234,8 @@ readXmlCell (parseXmlContextPtr ctxt, xmlNodePtr tree)
int row = 0, col = 0;
char *content = NULL;
cell_deep_freeze_redraws ();
if (strcmp (tree->name, "Cell")){
fprintf (stderr,
"readXmlCell: invalid element type %s, 'Cell' expected`\n",
......@@ -1280,6 +1282,8 @@ readXmlCell (parseXmlContextPtr ctxt, xmlNodePtr tree)
} else
cell_set_text_simple (ret, "");
cell_deep_thaw_redraws ();
return ret;
}
......
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