Commit 098d1f56 authored by Chyla Zbigniew's avatar Chyla Zbigniew

Building excel plugin as shared library, added plugin.xml.


* Makefile.am:
Building excel plugin as shared library, added plugin.xml.

* boot.[ch]:
xxx_debug variables from src/main.c moved here.
Converted to real plugin with file_opener and file_saver services.

* plugin.xml: New file.

* gnumeric/plugins/excel/excel.h, plugins/excel/ms-chart.c,
plugins/excel/ms-escher.c, plugins/excel/ms-excel-read.c,
plugins/excel/ms-excel-read.h, plugins/excel/ms-excel-util.c,
plugins/excel/ms-excel-write.c, plugins/excel/ms-excel-write.h,
plugins/excel/ms-formula-read.c, plugins/excel/ms-formula-write.c,
plugins/excel/ms-obj.c:
Adjusted function signatures, don't return TRUE/FALSE if using
IOContext (we don't need boolean value as IOContext now sets
"error_occurred" flag).
parent 99ad3568
2001-03-20 Zbigniew Chyla <cyba@gnome.pl>
* Makefile.am:
Building excel plugin as shared library, added plugin.xml.
* boot.[ch]:
xxx_debug variables from src/main.c moved here.
Converted to real plugin with file_opener and file_saver services.
* plugin.xml: New file.
* gnumeric/plugins/excel/excel.h, plugins/excel/ms-chart.c,
plugins/excel/ms-escher.c, plugins/excel/ms-excel-read.c,
plugins/excel/ms-excel-read.h, plugins/excel/ms-excel-util.c,
plugins/excel/ms-excel-write.c, plugins/excel/ms-excel-write.h,
plugins/excel/ms-formula-read.c, plugins/excel/ms-formula-write.c,
plugins/excel/ms-obj.c:
Adjusted function signatures, don't return TRUE/FALSE if using
IOContext (we don't need boolean value as IOContext now sets
"error_occurred" flag).
2001-03-15 Jody Goldberg <jgoldberg@home.com>
* ms-excel-read.c (ms_excel_read_row) : Handle outline mode.
......
INCLUDES = \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-I$(includedir) \
-I$(top_srcdir)/src \
$(GNOME_INCLUDEDIR)
INCLUDES = -I$(includedir) -I$(top_srcdir)/src $(GNOME_INCLUDEDIR)
noinst_LIBRARIES = libexcel.a
libexcel_a_SOURCES = \
gnumeric_plugin_exceldir = $(gnumeric_plugindir)/excel
gnumeric_plugin_excel_DATA = plugin.xml
gnumeric_plugin_excel_LTLIBRARIES = excel.la
excel_la_LDFLAGS = -module -avoid-version
excel_la_SOURCES = \
boot.c \
boot.h \
excel.h \
......@@ -39,3 +37,5 @@ libexcel_a_SOURCES = \
ms-chart.c \
ms-summary.c \
ms-summary.h
EXTRA_DIST = $(gnumeric_plugin_excel_DATA)
......@@ -19,22 +19,43 @@
#include "workbook-view.h"
#include "workbook.h"
#include "plugin-util.h"
#include "module-plugin-defs.h"
#include "excel.h"
#include "ms-summary.h"
#include "boot.h"
extern int ms_excel_read_debug;
MsExcelReadGbFn ms_excel_read_gb = NULL;
GNUMERIC_MODULE_PLUGIN_INFO_DECL;
static FileOpener *excel_opener;
static FileSaver *excel95_saver, *excel98_saver;
/* Used to toggle debug messages on & off */
/*
* As a convention
* 0 = quiet, no experimental features.
* 1 = enable experimental features
* >1 increasing levels of detail.
*/
/* Enables debugging mesgs while reading excel workbooks */
gint ms_excel_read_debug = 0;
/* Enables debugging mesgs while reading excel functions */
gint ms_excel_formula_debug = 0;
/* Enables debugging mesgs while reading excel colors & patterns */
gint ms_excel_color_debug = 0;
/* Enables debugging mesgs while reading excel charts */
gint ms_excel_chart_debug = 0;
/* Enables debugging mesgs while writing excel workbooks */
gint ms_excel_write_debug = 0;
/* Enables debugging mesgs while reading excel objects */
gint ms_excel_object_debug = 0;
MsExcelReadGbFn ms_excel_read_gb = NULL;
static gboolean
excel_save_95 (FileSaver const *fs, IOContext *context, WorkbookView *wb_view, const char *filename);
gboolean excel_file_probe (FileOpener const *fo, const char *filename);
void excel_file_open (FileOpener const *fo, IOContext *context, WorkbookView *new_wb_view, const char *filename);
void excel98_file_save (FileSaver const *fs, IOContext *context, WorkbookView *wb_view, const char *filename);
void excel95_file_save (FileSaver const *fs, IOContext *context, WorkbookView *wb_view, const char *filename);
static gboolean
excel_probe (FileOpener const *fo, const char *filename)
gboolean
excel_file_probe (FileOpener const *fo, const char *filename)
{
MsOle *file;
......@@ -59,22 +80,20 @@ excel_probe (FileOpener const *fo, const char *filename)
}
/*
* excel_load
* excel_file_open
* @context: Command context
* @wb: Workbook
* @filename: File name
* @user_data: ignored
*
* Load en excel workbook.
* Returns TRUE on success, FALSE on failure.
*/
static gboolean
excel_load (FileOpener const *fo, IOContext *context,
WorkbookView *new_wb_view, const char *filename)
void
excel_file_open (FileOpener const *fo, IOContext *context,
WorkbookView *new_wb_view, const char *filename)
{
MsOleErr ole_error;
MsOle *f;
gboolean success;
ole_error = ms_ole_open (&f, filename);
if (ole_error != MS_OLE_ERR_OK) {
......@@ -82,12 +101,12 @@ excel_load (FileOpener const *fo, IOContext *context,
/* FIXME : We need a more detailed message from
* ole_open */
gnumeric_io_error_read (context, "");
return FALSE;
return;
}
puts (filename);
success = ms_excel_read_workbook (context, new_wb_view, f) == 0 ? TRUE : FALSE;
if (success) {
ms_excel_read_workbook (context, new_wb_view, f);
if (!gnumeric_io_error_occurred (context)) {
Workbook *wb = wb_view_workbook (new_wb_view);
ms_summary_read (f, wb->summary_info);
......@@ -98,13 +117,9 @@ excel_load (FileOpener const *fo, IOContext *context,
if (!ms_excel_read_gb (context, wb, f))
g_warning ("Failed to read Basic scripts");
}
workbook_set_saveinfo (wb, filename, FILE_FL_MANUAL, excel95_saver);
}
ms_ole_destroy (&f);
return success;
}
/*
......@@ -114,25 +129,25 @@ excel_load (FileOpener const *fo, IOContext *context,
* import that definition here: There's a different definition of
* ExcelWorkbook in ms-excel-read.h.
*/
static gboolean
static void
excel_save (IOContext *context, WorkbookView *wb_view, const char *filename,
MsBiffVersion ver)
MsBiffVersion ver)
{
Workbook *wb = wb_view_workbook (wb_view);
MsOle *f;
gboolean ans;
struct stat s;
MsOleErr result;
void *state = NULL;
if ((stat (filename, &s) != -1)) {
if (g_file_exists (filename)) {
gnumeric_io_error_save (context,
_("Saving over old files disabled for safety"));
return FALSE;
return;
}
if (ms_excel_check_write (context, &state, wb_view, ver) != 0)
return FALSE;
if (ms_excel_check_write (context, &state, wb_view, ver) != 0) {
gnumeric_io_error_unknown (context);
return;
}
result = ms_ole_create (&f, filename);
......@@ -145,55 +160,26 @@ excel_save (IOContext *context, WorkbookView *wb_view, const char *filename,
ms_ole_destroy (&f);
ms_excel_write_free_state (state);
g_free (str);
return FALSE;
return;
}
ans = ms_excel_write_workbook (context, f, state, ver) == 0 ? TRUE : FALSE;
ms_excel_write_workbook (context, f, state, ver);
ms_summary_write (f, wb->summary_info);
ms_summary_write (f, wb->summary_info);
ms_ole_destroy (&f);
if (ans)
printf ("Written successfully\n");
else
printf ("Error whilst writing\n");
return ans;
}
static gboolean
excel_save_98 (FileSaver const *fs, IOContext *context,
WorkbookView *wb_view, const char *filename)
{
return excel_save (context, wb_view, filename, MS_BIFF_V8);
}
static gboolean
excel_save_95 (FileSaver const *fs, IOContext *context,
WorkbookView *wb_view, const char *filename)
{
return excel_save (context, wb_view, filename, MS_BIFF_V7);
}
void
excel_init (void)
excel98_file_save (FileSaver const *fs, IOContext *context,
WorkbookView *wb_view, const char *filename)
{
/* We register Excel format with a precendence of 100 */
excel_opener = file_format_register_open (
100, _("Microsoft(R) Excel file format"),
&excel_probe, &excel_load);
if (gnumeric_debugging > 0) {
excel98_saver = file_format_register_save (
"xls", _("Excel(R) 97 file format"),
FILE_FL_MANUAL_REMEMBER, &excel_save_98);
}
excel95_saver = file_format_register_save (
"xls", _("Excel(R) 95 file format"),
FILE_FL_MANUAL_REMEMBER, &excel_save_95);
excel_save (context, wb_view, filename, MS_BIFF_V8);
}
void
excel_shutdown (void)
excel95_file_save (FileSaver const *fs, IOContext *context,
WorkbookView *wb_view, const char *filename)
{
excel_save (context, wb_view, filename, MS_BIFF_V7);
}
......@@ -6,5 +6,17 @@
*
* (C) 1998, 1999, 2000 Michael Meeks
**/
extern void excel_init (void);
extern void excel_shutdown (void);
#ifndef GNUMERIC_BOOT_H
#define GNUMERIC_BOOT_H
#include <glib.h>
extern gint ms_excel_read_debug;
extern gint ms_excel_formula_debug;
extern gint ms_excel_color_debug;
extern gint ms_excel_chart_debug;
extern gint ms_excel_write_debug;
extern gint ms_excel_object_debug;
#endif /* GNUMERIC_BOOT_H */
......@@ -24,8 +24,8 @@ typedef enum { MS_BIFF_V2 = 2,
MS_BIFF_V8 = 8, /* Excel 97 */
MS_BIFF_V_UNKNOWN = 0} MsBiffVersion ;
extern int ms_excel_read_workbook (IOContext *context,
WorkbookView *new_wb, MsOle *file);
extern void ms_excel_read_workbook (IOContext *context,
WorkbookView *new_wb, MsOle *file);
/*
* Here's why the state which is carried from excel_check_write to
* ms_excel_write_workbook is void *: The state is actually an
......@@ -34,9 +34,9 @@ extern int ms_excel_read_workbook (IOContext *context,
* ExcelWorkbook in ms-excel-read.h.
*/
extern int ms_excel_check_write (IOContext *context, void **state,
WorkbookView *wb, MsBiffVersion ver);
extern int ms_excel_write_workbook (IOContext *context, MsOle *file,
void *state, MsBiffVersion ver);
WorkbookView *wb, MsBiffVersion ver);
extern void ms_excel_write_workbook (IOContext *context, MsOle *file,
void *state, MsBiffVersion ver);
void ms_excel_write_free_state (void *state);
......
......@@ -10,6 +10,7 @@
#include <stdio.h>
#include <config.h>
#include "boot.h"
#include "excel.h"
#include "ms-chart.h"
#include "ms-formula-read.h"
......@@ -23,7 +24,6 @@
#include "gnumeric-chart.h"
/* #define NO_DEBUG_EXCEL */
extern int ms_excel_chart_debug;
typedef struct
{
......
......@@ -13,6 +13,7 @@
#include <stdio.h>
#include <config.h>
#include "boot.h"
#include "ms-escher.h"
#include "escher-types.h"
#include "biff-types.h"
......
......@@ -10,6 +10,7 @@
#include <config.h>
#include "boot.h"
#include "ms-formula-read.h"
#include "ms-excel-read.h"
#include "ms-obj.h"
......@@ -41,21 +42,6 @@
/* #define NO_DEBUG_EXCEL */
/* Used in src/main.c to toggle debug messages on & off */
/*
* As a convention
* 0 = quiet, no experimental features.
* 1 = enable experimental features
* >1 increasing levels of detail.
*/
int ms_excel_read_debug = 0;
int ms_excel_write_debug = 0;
int ms_excel_formula_debug = 0;
int ms_excel_color_debug = 0;
int ms_excel_chart_debug = 0;
extern int ms_excel_object_debug;
extern int gnumeric_debugging;
/* Forward references */
static ExcelSheet *ms_excel_sheet_new (ExcelWorkbook *wb,
const char *name);
......@@ -3891,9 +3877,9 @@ ms_excel_read_window1 (BiffQuery *q, WorkbookView *wb_view)
}
}
int
void
ms_excel_read_workbook (IOContext *context, WorkbookView *wb_view,
MsOle *file)
MsOle *file)
{
ExcelWorkbook *wb = NULL;
MsOleStream *stream;
......@@ -3915,7 +3901,7 @@ ms_excel_read_workbook (IOContext *context, WorkbookView *wb_view,
ms_ole_stream_close (&stream);
gnumeric_io_error_read (context,
_("No book or workbook streams found."));
return -1;
return;
}
}
......@@ -4324,11 +4310,9 @@ ms_excel_read_workbook (IOContext *context, WorkbookView *wb_view,
/* If we were forced to stop then the load failed */
if (problem_loading != NULL) {
gnumeric_io_error_read (context, problem_loading);
return -1;
}
return 0;
return;
}
gnumeric_io_error_read (context, _("Unable to locate valid MS Excel workbook"));
return -1;
}
......@@ -127,9 +127,4 @@ extern void ms_excel_unexpected_biff (BiffQuery *q,
char const *state,
int debug_level);
extern int ms_excel_read_debug;
extern int ms_excel_formula_debug;
extern int ms_excel_color_debug;
extern int ms_excel_chart_debug;
#endif
......@@ -10,13 +10,12 @@
#include "config.h"
#include <glib.h>
#include "boot.h"
#include "style.h"
#include "ms-excel-util.h"
#include <stdio.h>
extern int ms_excel_read_debug;
/*
* TwoWayTable
*
......
......@@ -29,6 +29,7 @@
#include <gnome.h>
#include "boot.h"
#include "gnumeric.h"
#include "gnumeric-util.h"
#include "format.h"
......@@ -3560,9 +3561,9 @@ cleanup:
return ret;
}
int
void
ms_excel_write_workbook (IOContext *context, MsOle *file, void *state,
MsBiffVersion ver)
MsBiffVersion ver)
{
MsOleErr result;
char *strname;
......@@ -3570,7 +3571,7 @@ ms_excel_write_workbook (IOContext *context, MsOle *file, void *state,
BiffPut *bp;
ExcelWorkbook *wb = state;
g_return_val_if_fail (file != NULL, -1);
g_return_if_fail (file != NULL);
if (ver >= MS_BIFF_V8)
strname = "Workbook";
......@@ -3583,7 +3584,7 @@ ms_excel_write_workbook (IOContext *context, MsOle *file, void *state,
free_workbook (wb);
gnumeric_io_error_save (context,
_("Can't open stream for writing\n"));
return -1;
return;
}
bp = ms_biff_put_new (str);
......@@ -3606,8 +3607,6 @@ ms_excel_write_workbook (IOContext *context, MsOle *file, void *state,
fflush (stdout);
}
#endif
return 0;
}
......
......@@ -124,5 +124,4 @@ extern int ms_excel_write_get_externsheet_idx (ExcelWorkbook *wb,
extern int
ms_excel_write_map_errcode (Value const * const v);
extern int ms_excel_write_debug;
#endif
......@@ -13,6 +13,7 @@
#include <config.h>
#include <gnome.h>
#include "boot.h"
#include "gnumeric.h"
#include "func.h"
#include "value.h"
......@@ -27,8 +28,6 @@
/* #define NO_DEBUG_EXCEL */
extern int ms_excel_formula_debug;
/**
* Various bits of data for operators
* see S59E2B.HTM for formula_ptg values
......
......@@ -15,6 +15,7 @@
#include <config.h>
#include <gnome.h>
#include "boot.h"
#include "gnumeric.h"
#include "gutils.h"
#include "func.h"
......@@ -28,7 +29,6 @@
#include "formula-types.h"
#define FORMULA_DEBUG 0
extern int ms_excel_formula_debug;
/*#define DO_IT (ms_excel_formula_debug > 0)*/
#define DO_IT (1)
......
......@@ -10,6 +10,7 @@
#include <config.h>
#include "boot.h"
#include "ms-obj.h"
#include "ms-chart.h"
#include "ms-escher.h"
......@@ -17,8 +18,6 @@
#include "sheet-object-widget.h"
#include "sheet-object-graphic.h"
int ms_excel_object_debug;
#define GR_END 0x00
#define GR_MACRO 0x04
#define GR_COMMAND_BUTTON 0x05
......
<?xml version="1.0"?>
<gnumeric_plugin_group>
<plugin id="Gnumeric_Excel">
<information name="Microsoft(R) Excel" description="Imports/Exports Microsoft(R) Excel files"/>
<loader type="g_module">
<attribute name="module_file" value="excel.so"/>
</loader>
<services>
<service type="file_opener" id="excel" priority="100" probe="TRUE">
<information description="Microsoft(R) Excel file format"/>
<file_patterns>
<file_pattern type="shell_pattern" value="*.xls"/>
</file_patterns>
<save_info saver_id="excel95" format_level="manual_remember"/>
</service>
<service type="file_saver" id="excel95" file_extension="xls" format_level="manual_remember">
<information description="Excel(R) 95 file format"/>
</service>
<service type="file_saver" id="excel97" file_extension="xls" format_level="manual_remember">
<information description="Excel(R) 97 file format"/>
</service>
</services>
</plugin>
</gnumeric_plugin_group>
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