Commit 663f8876 authored by Michael Meeks's avatar Michael Meeks

fn-misc removed, excel image loading started.

fn-misc removed,
excel image loading started.
parent 7484ad05
1999-09-16 Michael Meeks <michael@nuclecu.unam.mx>
* src/func.c (functions_init): Remove misc_init.
* src/functions/fn-misc.c: Removed, empty & redundant.
* src/functions/Makefile.am: remove fn-misc.c
* src/func.h: ditto.
* src/sheet-object-container.c (sheet_object_container_load): Implement
cleaner & simpler load method
* NEWS (Michael): doh, move it into the correct version.
1999-09-16 Michael Meeks <michael@nuclecu.unam.mx>
* src/print.c (sheet_print): Update to use gnumeric_porinter_dialog_run.
......
......@@ -7,15 +7,6 @@ Jukka:
* Major clean up to the documentation of functions.
* Added tons of examples to functions.
--------------------------------------------------------------------------
Gnumeric 0.33, 0.34, 0.35
Jukka:
* Implemented ACCRINT, ACCRINTM, DISC, FVSCHEDULE, INTRATE,
ISPMT, RECEIVED, PRICEDISC, PRICEMAT, TBILLEQ, TBILLPRICE,
and TBILLYIELD functions
Michael:
* Re-implemented sheet objects,
* Implemented drop filename -> Bonobo component conversion,
......@@ -26,6 +17,15 @@ Michael:
* Functions MATCH & INDEX started.
* Array input parser.
--------------------------------------------------------------------------
Gnumeric 0.33, 0.34, 0.35
Jukka:
* Implemented ACCRINT, ACCRINTM, DISC, FVSCHEDULE, INTRATE,
ISPMT, RECEIVED, PRICEDISC, PRICEMAT, TBILLEQ, TBILLPRICE,
and TBILLYIELD functions
Miguel:
* Implemented Print Preview
......
1999-09-16 Michael Meeks <michael@nuclecu.unam.mx>
* src/func.c (functions_init): Remove misc_init.
* src/functions/fn-misc.c: Removed, empty & redundant.
* src/functions/Makefile.am: remove fn-misc.c
* src/func.h: ditto.
* src/sheet-object-container.c (sheet_object_container_load): Implement
cleaner & simpler load method
* NEWS (Michael): doh, move it into the correct version.
1999-09-16 Michael Meeks <michael@nuclecu.unam.mx>
* src/print.c (sheet_print): Update to use gnumeric_porinter_dialog_run.
......
1999-09-16 Michael Meeks <michael@nuclecu.unam.mx>
* ms-excel-read.c (ms_excel_read_sheet): add sheet param to _get_drawing
(ms_excel_read_workbook): ditto & init 'eschers' to NULL.
* ms-obj.c (ms_obj_read_text): add sheet param to _get_drawing
* ms-chart.c (BC_W): ditto.
* ms-escher.c (ms_escher_hack_get_drawing): Add Sheet param.
(escher_record_new_blip, escher_record_destroy, ms_escher_read_Blip),
(ms_escher_read_ClientAnchor): Hack up image loading.
include config.h
* ms-excel-read.h (_ExcelWorkbook): Add eschers list.
1999-09-16 Jody Goldberg <jgoldberg@home.com>
* ms-escher.c (ms_escher_read_CLSID, ms_escher_read_ColorMRU,
......
......@@ -858,7 +858,7 @@ static gboolean
BC_R(gelframe)(ExcelChartHandler const *handle,
ExcelChartState *s, BiffQuery *q)
{
ms_escher_hack_get_drawing (q, s->wb);
ms_escher_hack_get_drawing (q, s->wb, NULL);
return FALSE;
}
static gboolean
......
......@@ -8,21 +8,32 @@
* See S59FD6.HTM for an overview...
**/
#include <stdio.h>
#include "config.h"
#include "ms-escher.h"
#include "escher-types.h"
#include "biff-types.h"
#include "ms-excel-read.h"
#include "ms-obj.h"
#include <stdio.h>
#include "sheet-object.h"
#ifdef ENABLE_BONOBO
# include <bonobo/gnome-stream.h>
# include <bonobo/gnome-stream-memory.h>
# include "sheet-object-container.h"
#endif
/* A storage accumulator for common state information */
typedef struct
{
ExcelWorkbook *wb;
BiffQuery *q;
ExcelWorkbook *wb;
ExcelSheet *sheet;
BiffQuery *q;
int depth;
int depth;
} MSEscherState;
typedef struct
......@@ -41,6 +52,59 @@ typedef struct
} MSEscherCommonHeader;
#define common_header_len 8
#ifdef ENABLE_BONOBO
typedef enum { ESCHER_BLIP } EscherType;
typedef struct {
EscherType type;
union {
struct {
GnomeStream *stream;
const char *reproid;
} blip;
} v;
} EscherRecord;
static EscherRecord *
escher_record_new_blip (guint8 *data, guint32 len, const char *reproid)
{
EscherRecord *er = g_new (EscherRecord, 1);
guint8 *mem;
g_return_val_if_fail (len > 0, NULL);
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (reproid != NULL, NULL);
mem = g_malloc (len);
memcpy (mem, data, len);
er->type = ESCHER_BLIP;
er->v.blip.stream = gnome_stream_mem_create (mem, len, TRUE);
er->v.blip.reproid = reproid;
return er;
}
/* OK it probably leaks / doesn't get called for now :-) */
static void
escher_record_destroy (EscherRecord *er)
{
if (!er)
return;
switch (er->type) {
case ESCHER_BLIP:
if (er->v.blip.stream)
gnome_object_destroy (GNOME_OBJECT (er->v.blip.stream));
er->v.blip.stream = NULL;
er->v.blip.reproid = NULL;
break;
default:
g_warning ("Internal escher type error");
break;
}
}
#endif
static gboolean
ms_escher_next_record (MSEscherState * state,
MSEscherCommonHeader *h);
......@@ -238,6 +302,16 @@ ms_escher_read_Blip (MSEscherState * state,
case 0x542 : /* compressed PICT, with Metafile header */
break;
case 0x6e0 : /* PNG data, with 1 byte header */
#ifdef ENABLE_BONOBO
{
int const header = 17 + primary_uid_size + common_header_len;
EscherRecord *er = escher_record_new_blip (h->data + header,
h->len - header,
"bonobo-object:image-x-png");
state->wb->eschers = g_list_append (state->wb->eschers, er);
break;
}
#endif
case 0x46a : /* JPEG data, with 1 byte header */
case 0x7a8 : /* DIB data, with 1 byte header */
{
......@@ -531,6 +605,31 @@ ms_escher_read_ClientAnchor (MSEscherState * state,
#if 0
dump (h->data+common_header_len, h->len-common_header_len);
#endif
#ifdef ENABLE_BONOBO
{ /* In the anals of ugly hacks, this is well up there :-) */
GList *l = state->wb->eschers;
EscherRecord *er;
SheetObject *so;
g_return_if_fail (l != NULL);
er = l->data;
g_return_if_fail (er != NULL);
g_return_if_fail (state->sheet != NULL);
g_return_if_fail (er->type == ESCHER_BLIP);
g_return_if_fail (er->v.blip.stream != NULL);
/* And lo, objects appeared always in the TLC */
so = sheet_object_container_new (state->sheet->gnum_sheet,
10.0, 10.0, 110.0, 110.0,
er->v.blip.reproid);
if (!sheet_object_container_load (so, er->v.blip.stream, TRUE))
g_warning ("Failed to load '%s' from stream",
er->v.blip.reproid);
escher_record_destroy (er);
state->wb->eschers = g_list_remove (state->wb->eschers, l->data);
}
#endif
}
static void
ms_escher_read_ClientData (MSEscherState * state,
......@@ -810,7 +909,6 @@ ms_escher_next_record (MSEscherState * state,
char const * fbt_name = NULL;
void (*handler)(MSEscherState * state,
MSEscherCommonHeader * containing_header) = NULL;
int required_space = 0;
/* Lets be really really anal */
g_return_val_if_fail (h->data_len >= h->len, FALSE);
......@@ -996,8 +1094,19 @@ biff_to_flat_data (BiffQuery *q, guint32 *length, gboolean * needs_to_be_free)
return data;
}
/**
* ms_escher_hack_get_drawing:
* @q: Biff context.
* @wb: required workbook argument
* @sheet: optional sheet argument
*
* This function parses an escher stream, and stores relevant data in the
* workbook.
*
**/
void
ms_escher_hack_get_drawing (BiffQuery *q, ExcelWorkbook *wb)
ms_escher_hack_get_drawing (BiffQuery *q, ExcelWorkbook *wb, ExcelSheet *sheet)
{
MSEscherState state;
MSEscherCommonHeader h, fake_container;
......@@ -1019,8 +1128,9 @@ ms_escher_hack_get_drawing (BiffQuery *q, ExcelWorkbook *wb)
if (ms_excel_read_debug <= 0)
return;
state.wb = wb;
state.q = q;
state.wb = wb;
state.sheet = sheet;
state.q = q;
state.depth = 0;
fake_container.data = biff_to_flat_data (q, &fake_container.len, &needs_to_be_free);
......
......@@ -9,6 +9,8 @@
**/
#include "ms-excel-read.h"
extern void ms_escher_hack_get_drawing (BiffQuery *q, ExcelWorkbook *wb);
extern void ms_escher_hack_get_drawing (BiffQuery *q,
ExcelWorkbook *wb,
ExcelSheet *sheet);
#endif /* GNUMERIC_MS_OFFICE_ESCHER_H */
......@@ -1744,6 +1744,7 @@ ms_excel_workbook_new (eBiff_version ver)
(GCompareFunc)biff_guint16_equal);
ans->palette = ms_excel_default_palette ();
ans->ver = ver;
ans->eschers = NULL;
ans->global_strings = NULL;
ans->global_string_max = 0;
ans->read_drawing_group = 0;
......@@ -2433,7 +2434,7 @@ ms_excel_read_sheet (ExcelSheet *sheet, BiffQuery *q, ExcelWorkbook *wb)
case BIFF_MS_O_DRAWING:
case BIFF_MS_O_DRAWING_GROUP:
case BIFF_MS_O_DRAWING_SELECTION:
ms_escher_hack_get_drawing (q, wb);
ms_escher_hack_get_drawing (q, wb, sheet);
break;
case BIFF_NOTE: /* See: S59DAB.HTM */
......@@ -3212,7 +3213,7 @@ ms_excel_read_workbook (Workbook *workbook, MsOle *file)
case BIFF_MS_O_DRAWING:
case BIFF_MS_O_DRAWING_GROUP:
case BIFF_MS_O_DRAWING_SELECTION:
ms_escher_hack_get_drawing (q, wb);
ms_escher_hack_get_drawing (q, wb, NULL);
break;
case BIFF_ADDMENU :
......
......@@ -80,27 +80,27 @@ typedef struct _BiffFormatData {
typedef struct _ExcelWorkbook
{
GHashTable *boundsheet_data_by_stream;
GHashTable *boundsheet_data_by_index;
GPtrArray *XF_cell_records;
GHashTable *font_data;
GHashTable *format_data; /* leave as a hash */
GPtrArray *name_data;
int read_drawing_group;
GPtrArray *excel_sheets;
GPtrArray *excel_sheets;
GHashTable *boundsheet_data_by_stream;
GHashTable *boundsheet_data_by_index;
GPtrArray *XF_cell_records;
GHashTable *font_data;
GHashTable *format_data; /* leave as a hash */
GPtrArray *name_data;
int read_drawing_group;
BiffExternSheetData *extern_sheets;
guint16 num_extern_sheets;
ExcelPalette *palette;
char **global_strings;
int global_string_max;
eBiff_version ver;
GPtrArray *charts;
guint16 num_extern_sheets;
ExcelPalette *palette;
char **global_strings;
int global_string_max;
eBiff_version ver;
GList *eschers;
GPtrArray *charts;
/**
* Gnumeric parallel workbook
**/
Workbook *gnum_wb;
Workbook *gnum_wb;
} ExcelWorkbook;
extern Sheet* biff_get_externsheet_name (ExcelWorkbook *wb, guint16 idx, gboolean get_first);
......
......@@ -148,7 +148,7 @@ ms_obj_read_text (BiffQuery *q, ExcelWorkbook * wb, int const id)
{
/* next record must be a DRAWING, it will load the TXO records */
g_return_if_fail (ms_biff_query_next (q));
ms_escher_hack_get_drawing (q, wb);
ms_escher_hack_get_drawing (q, wb, NULL);
}
static void
......
1999-09-17 Michael Meeks <michael@nuclecu.unam.mx>
* POTFILES.in: remove fn-misc.ccd ..
1999-09-14 Karl Eichwalder <ke@suse.de>
* de.po: Update.
......
......@@ -51,7 +51,6 @@ src/functions/fn-information.c
src/functions/fn-logical.c
src/functions/fn-lookup.c
src/functions/fn-math.c
src/functions/fn-misc.c
src/functions/fn-sheet.c
src/functions/fn-stat.c
src/functions/fn-string.c
......
......@@ -440,7 +440,6 @@ functions_init (void)
{
math_functions_init();
sheet_functions_init();
misc_functions_init();
date_functions_init();
string_functions_init();
stat_functions_init();
......
......@@ -6,7 +6,6 @@
extern void math_functions_init (void);
extern void sheet_functions_init (void);
extern void misc_functions_init (void);
extern void date_functions_init (void);
extern void string_functions_init (void);
extern void stat_functions_init (void);
......
......@@ -19,7 +19,6 @@ libfunctions_a_SOURCES = \
fn-logical.c \
fn-lookup.c \
fn-math.c \
fn-misc.c \
fn-sheet.c \
fn-stat.c \
fn-string.c
/*
* fn-misc.c: Miscelaneous built-in functions
*
* Author:
* Miguel de Icaza (miguel@gnu.org)
*
*/
#include <config.h>
#include "gnumeric.h"
#include "utils.h"
#include "func.h"
/***************************************************************************/
void
misc_functions_init (void)
{
FunctionCategory *cat = function_get_category (_("Miscellaneous"));
}
......@@ -4,6 +4,7 @@
*
* Author:
* Miguel de Icaza (miguel@kernel.org)
* Michael Meeks (mmeeks@gnu.org)
*/
#include <config.h>
#include <gnome.h>
......@@ -156,6 +157,8 @@ get_file_name (void)
return filename;
}
/**
* sheet_object_container_land:
* @so: Sheet Object
......@@ -318,6 +321,95 @@ sheet_object_container_land (SheetObject *so, const gchar *fname,
return TRUE;
}
gboolean
sheet_object_container_load (SheetObject *so,
GnomeStream *stream,
gboolean own_size)
{
SheetObjectContainer *soc;
GList *l;
CORBA_Environment ev;
GNOME_PersistStream ret;
g_return_val_if_fail (so != NULL, FALSE);
g_return_val_if_fail (IS_SHEET_OBJECT (so), FALSE);
soc = SHEET_OBJECT_CONTAINER (so);
g_return_val_if_fail (soc->client_site == NULL, FALSE);
soc->client_site = gnome_client_site_new (so->sheet->workbook->gnome_container);
if (!soc->repoid)
return NULL;
soc->object_server = gnome_object_activate_with_goad_id (NULL, soc->repoid, 0, NULL);
if (!soc->object_server)
return FALSE;
if (!gnome_client_site_bind_embeddable (soc->client_site, soc->object_server))
return FALSE;
CORBA_exception_init (&ev);
ret = GNOME_Unknown_query_interface (
gnome_object_corba_objref (GNOME_OBJECT (soc->object_server)),
"IDL:GNOME/PersistStream:1.0", &ev);
if (ev._major == CORBA_NO_EXCEPTION) {
if (ret != CORBA_OBJECT_NIL) {
if (stream) {
GNOME_PersistStream_load ( ret,
(GNOME_Stream) gnome_object_corba_objref (
GNOME_OBJECT (stream)), &ev);
}
GNOME_Unknown_unref ((GNOME_Unknown) ret, &ev);
CORBA_Object_release (ret, &ev);
}
} else {
CORBA_exception_free (&ev);
return FALSE;
}
CORBA_exception_free (&ev);
/*
* Instatiate the views of the object across the sheet views
*/
for (l = so->sheet->sheet_views; l; l = l->next) {
GnomeCanvasItem *item;
SheetView *sheet_view = l->data;
GnomeViewFrame *view_frame;
GtkWidget *view_widget;
view_frame = gnome_client_site_new_view (
soc->client_site);
gnome_view_frame_set_ui_handler (
view_frame,
so->sheet->workbook->uih);
gtk_signal_connect (GTK_OBJECT (view_frame), "user_activate",
GTK_SIGNAL_FUNC (user_activation_request_cb), so);
gtk_signal_connect (GTK_OBJECT (view_frame), "view_activated",
GTK_SIGNAL_FUNC (view_activated_cb), so);
if (own_size) {
int dx = -1, dy = -1;
gnome_view_frame_size_request (view_frame, &dx, &dy);
if (dx > 0 && dy > 0) {
double tlx, tly, brx, bry;
sheet_object_get_bounds (so, &tlx, &tly, &brx, &bry);
sheet_object_set_bounds (so, tlx, tly, tlx + dx, tly + dy);
}
}
view_widget = gnome_view_frame_get_wrapper (view_frame);
item = make_container_item (so, sheet_view, view_widget);
so->realized_list = g_list_prepend (so->realized_list, item);
}
return TRUE;
}
static GnomeCanvasItem *
sheet_object_container_realize (SheetObject *so, SheetView *sheet_view)
{
......
......@@ -46,6 +46,9 @@ SheetObject *sheet_object_container_new (Sheet *sheet,
gboolean sheet_object_container_land (SheetObject *so,
const gchar *fname,
gboolean own_size);
gboolean sheet_object_container_load (SheetObject *so,
GnomeStream *stream,
gboolean own_size);
/*
* Graphics
*/
......
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