GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit 8b6eab8c authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa

Incorporated the HTML plugin as well.



Incorporated the HTML plugin as well.

1999-07-07  Miguel de Icaza  <miguel@gnu.org>

	* src/Gnumeric.idl: Small typo fixes.

	* Killed liblgade from here, it is now a requirement.
parent cdc39c09
......@@ -6,6 +6,10 @@ Miguel:
Imported Alan's libCSV and rewrwite ff-csv so that it actually works.
Add import feature. Drop some normal loaders and make them importers
Fixed lots of print stuff.
Rasca Gmelch:
HTML import plugin
Jukka:
* Started the implementation of Data Analysis tools
- Implemented Correlation and Covariance tools
......
1999-07-07 Miguel de Icaza <miguel@gnu.org>
* src/Gnumeric.idl: Small typo fixes.
* Killed liblgade from here, it is now a requirement.
1999-07-07 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/dialog-analysis-tools.c: Cleaned up `groupped by' radio
......
1999-07-07 Miguel de Icaza <miguel@gnu.org>
* src/Gnumeric.idl: Small typo fixes.
* Killed liblgade from here, it is now a requirement.
1999-07-07 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/dialog-analysis-tools.c: Cleaned up `groupped by' radio
......
SUBDIRS = intl po macros libglade plugins src doc
SUBDIRS = intl po macros libglade plugins src doc corba-test
EXTRA_DIST = \
gnumeric.desktop README HACKING gnumeric.spec.in \
......
1999-07-07 Miguel de Icaza <miguel@gnu.org>
* src/Gnumeric.idl: Small typo fixes.
* Killed liblgade from here, it is now a requirement.
1999-07-07 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/dialog-analysis-tools.c: Cleaned up `groupped by' radio
......
1999-07-07 Miguel de Icaza <miguel@gnu.org>
* src/Gnumeric.idl: Small typo fixes.
* Killed liblgade from here, it is now a requirement.
1999-07-07 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/dialog-analysis-tools.c: Cleaned up `groupped by' radio
......
......@@ -6,15 +6,6 @@ test -z "$srcdir" && srcdir=.
PKG_NAME="Gnumeric"
if test -d ${srcdir}/libglade; then
> ${srcdir}/libglade/NO-AUTO-GEN
> ${srcdir}/libglade/libglade.spec
> ${srcdir}/libglade/libgladeConf.sh
else
echo you need to checkout gnumeric again
exit 1
fi
(test -f $srcdir/configure.in \
&& test -d $srcdir/src \
&& test -f $srcdir/src/gnumeric.h) || {
......
......@@ -138,24 +138,7 @@ GNOME_PRINT_CFLAGS=`gnome-config --cflags print`
AC_SUBST(GNOME_PRINT_LIBS)
AC_SUBST(GNOME_PRINT_CFLAGS)
dnl ******************************************
dnl LibGlade tests:
dnl These duplicate the things
dnl that are in libglade's configure.in
dnl so that we can include it in gnumeric.
dnl ******************************************
AC_PROG_AWK
GDK_KEYSYMS="`$GTK_CONFIG --prefix`/include/gdk/gdkkeysyms.h"
AC_SUBST(GDK_KEYSYMS)
AC_DEFINE(ENABLE_GNOME)
AM_CONDITIONAL(GNOME_SUPPORT, true)
AM_CONDITIONAL(LIBGLADE_FULLDIST, false)
XML_LIBS=`gnome-config --libs xml`
XML_CFLAGS=`gnome-config --cflags xml`/gnome-xml
AM_CONDITIONAL(HAVE_GTK_DOC, false)
AC_SUBST(XML_LIBS)
AC_SUBST(XML_CFLAGS)
AM_PATH_LIBGLADE
AC_OUTPUT([
gnumeric.spec
......@@ -164,10 +147,6 @@ icons/Makefile
src/Makefile
wizards/Makefile
wizards/graphics/Makefile
libglade/Makefile
libglade/glade/Makefile
libglade/doc/Makefile
libglade/macros/Makefile
doc/Makefile
doc/C/Makefile
doc/es/Makefile
......@@ -184,6 +163,7 @@ plugins/guile/Makefile
plugins/ff-csv/Makefile
plugins/text/Makefile
plugins/xbase/Makefile
plugins/html/Makefile
intl/Makefile
po/Makefile.in
macros/Makefile
......
......@@ -19,4 +19,4 @@ endif
#SUBDIRS = sample stat excel ff-csv text $(PYTHON) $(PERL) $(GUILE_DIR) xbase
SUBDIRS = sample stat excel ff-csv text xbase
\ No newline at end of file
SUBDIRS = sample stat excel ff-csv text xbase html
\ No newline at end of file
07/07/99 (rasca)
- added first latex export code
- minor code clean ups
- import horizontal cell alignment (right and center)
- support for exporting fore- and background colors
- correct email address in README
- added file_format_unregister_open()
- reading now honors italic and bold
07/07/99 (rasca)
- minor changes to the writing code, so that the cell could
also have values like "<hello>"
- simple html read function which does not recognize alignment
or bold/italic ..
06/07/99 (rasca)
- right and left alignment, bold and italic seems to work :)
- started to write a html plugin to save a sheet as a raw html file
#
# Makefile for the html Gnumeric plugin.
#
# Where can we find the Gnumeric include files.
#
GNUMERIC_SRC_DIR = $(top_srcdir)/src
#
# Where to install the plugin
#
plugindir = $(libdir)/gnumeric/plugins
plugin_LTLIBRARIES = libhtml.la
libhtml_la_SOURCES = boot.h boot.c html.h html.c latex.h latex.c
INCLUDES = \
-I$(GNUMERIC_SRC_DIR) \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-I$(includedir) \
$(GNOME_INCLUDEDIR)
EXTRA_DIST = README ChangeLog
This is a small and simple plugin to export and import HTML files.
It is published under the GNU GPL..
Features of the export/import functions:
- exporting tables
* all tables are written in one file, but every sheet
gets it's own TABLE-tag
* beside the content of the cells it self the following
attributes are exported:
- center and right horizontal alignment
- vertical top alignment
- background color
- foreground color
- bold font setting
- italic font setting
* the characters "<" and ">" are 7bit encoded
- importing tables
* this is just a dirty hack which will in the most
cases only work while reading html files which were
created by this plugin!
* while reading the html file the following attributes
are imported:
- bold font setting
- italic font setting
- horizontal center and right aligment
* the 7bit presentation of "<" and ">" are decoded
There is also an experimental LaTeX mode for exporting tables.
It does not support colors and can not align to the center .. :-(
Author: rasca (thron@gmx.de)
-
/*
* boot.c
*
* Copyright (C) 1999 Rasca, Berlin
* EMail: thron@gmx.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <gnome.h>
#include "config.h"
#include "boot.h"
#include "html.h"
#include "latex.h"
#include "file.h"
/*
* Q: what's that for?
*/
static int
html_can_unload (PluginData *pd)
{
return TRUE;
}
/*
* called when unloading the plugin
*/
static void
html_cleanup_plugin (PluginData *pd)
{
file_format_unregister_save (html_write_wb_html32);
file_format_unregister_save (html_write_wb_html40);
file_format_unregister_open (NULL, html_read);
}
/*
* register all file formats
*/
static void
html_init (void)
{
char *desc;
desc = _("HTML 3.2 file format");
file_format_register_save (".html", desc, html_write_wb_html32);
desc = _("HTML 4.0 file format");
file_format_register_save (".html", desc, html_write_wb_html40);
desc = _("HTML file made by gnumeric");
/* Q: what does the '100' mean? */
file_format_register_open (100, desc, NULL, html_read);
desc = _("LaTeX file format");
file_format_register_save (".tex", desc, html_write_wb_latex);
}
/*
* called by gnumeric to load the plugin
*/
int
init_plugin (PluginData *pd)
{
html_init ();
pd->can_unload = html_can_unload;
pd->cleanup_plugin = html_cleanup_plugin;
pd->title = g_strdup (_("HTML (simple html export/import plugin)"));
return 0;
}
/*
* boot.h
*
* Copyright (C) 1999 Rasca, Berlin
* EMail: thron@gmx.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef GNUMERIC_HTML_BOOT_H
#define GNUMERIC_HTML_BOOT_H
#include "gnumeric.h"
#include "gnumeric-util.h"
#include "../../src/plugin.h"
int init_plugin (PluginData *pd);
#endif
/*
* html.c
*
* Copyright (C) 1999 Rasca, Berlin
* EMail: thron@gmx.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <gnome.h>
#include "config.h"
#include "html.h"
/*
* escape special characters
*/
static int
html_fprintf (FILE *fp, const char *s)
{
int len, i;
const char *p;
if (!s)
return 0;
len = strlen (s);
if (!len)
return 0;
p = s;
for (i = 0; i < len; i++) {
switch (*p) {
case '<':
fprintf (fp, "&lt;");
break;
case '>':
fprintf (fp, "&gt;");
break;
default:
fprintf (fp, "%c", *p);
break;
}
p++;
}
return len;
}
/*
* write every sheet of the workbook to a html 3.2 table
*/
int
html_write_wb_html32 (Workbook *wb, const char *filename)
{
FILE *fp;
GList *sheet_list;
Sheet *sheet;
Cell *cell;
Style *style;
int row, col;
unsigned char r,g,b;
g_return_val_if_fail (wb != NULL, -1);
g_return_val_if_fail (filename != NULL, -1);
fp = fopen (filename, "w");
if (!fp)
return -1;
fprintf (fp, "<!DOCTYPE HTML PUBLIC \"-//W3C/DTD HTML 3.2/EN\">\n");
fprintf (fp, "<HTML>\n");
fprintf (fp, "<!-- "G_PLUGIN_FOR_HTML" -->\n");
sheet_list = workbook_sheets (wb);
while (sheet_list) {
sheet = sheet_list->data;
fprintf (fp, "<TABLE border=1>\n");
for (row = 0; row < (sheet->max_row_used+1); row++) {
fprintf (fp, "<TR>\n");
for (col = 0; col < (sheet->max_col_used+1); col++) {
cell = sheet_cell_get (sheet, col, row);
if (!cell) {
fprintf (fp, "\t<TD?>\n");
} else {
style = cell->style;
if (!style) {
/* is this case posible? */
fprintf (fp, "\t<TD>");
html_fprintf (fp, cell->text->str);
fprintf (fp, "\n");
} else {
fprintf (fp, "\t<TD");
if (style->halign & HALIGN_RIGHT)
fprintf (fp, " align=right");
if (style->halign & HALIGN_CENTER)
fprintf (fp, " align=center");
if (style->valign & VALIGN_TOP)
fprintf (fp, " valign=top");
r = style->back_color->color.red >> 8;
g = style->back_color->color.green >> 8;
b = style->back_color->color.blue >> 8;
if (r != 255 || g != 255 || b != 255)
fprintf (fp, " bgcolor=\"#%02X%02X%02X\"", r, g, b);
fprintf (fp, ">");
r = style->fore_color->color.red >> 8;
g = style->fore_color->color.green >> 8;
b = style->fore_color->color.blue >> 8;
if (r != 0 || g != 0 || b != 0)
fprintf (fp, "<FONT color=\"#%02X%02X%02X\">",
r, g, b);
if (style->font->hint_is_bold)
fprintf (fp, "<B>");
if (style->font->hint_is_italic)
fprintf (fp, "<I>");
html_fprintf (fp, cell->text->str);
if (style->font->hint_is_bold)
fprintf (fp, "</B>");
if (style->font->hint_is_italic)
fprintf (fp, "</I>");
if (r != 0 || g != 0 || b != 0)
fprintf (fp, "</FONT>");
fprintf (fp, "\n");
}
}
}
fprintf (fp, "</TR>\n");
}
fprintf (fp, "</TABLE>\n<P>\n\n");
sheet_list = sheet_list->next;
}
fprintf (fp, "</HTML>\n");
fclose (fp);
return 0; /* what do we have to return here?? */
}
/*
* write every sheet of the workbook to a html 4.0 table
*/
int
html_write_wb_html40 (Workbook *wb, const char *filename)
{
FILE *fp;
GList *sheet_list;
Sheet *sheet;
Cell *cell;
Style *style;
int row, col;
unsigned char r,g,b;
g_return_val_if_fail (wb != NULL, -1);
g_return_val_if_fail (filename != NULL, -1);
fp = fopen (filename, "w");
if (!fp)
return -1;
fprintf (fp, "<!DOCTYPE HTML PUBLIC \"-//W3C/DTD HTML 4.0/EN\">\n");
fprintf (fp, "<HTML>\n");
fprintf (fp, "<!-- "G_PLUGIN_FOR_HTML" -->\n");
sheet_list = workbook_sheets (wb);
while (sheet_list) {
sheet = sheet_list->data;
fprintf (fp, "<TABLE border=1>\n");
for (row = 0; row < (sheet->max_row_used+1); row++) {
fprintf (fp, "<TR>\n");
for (col = 0; col < (sheet->max_col_used+1); col++) {
cell = sheet_cell_get (sheet, col, row);
if (!cell) {
fprintf (fp, "\t<TD?>\n");
} else {
style = cell->style;
if (!style) {
/* is this case posible? */
fprintf (fp, "\t<TD>");
html_fprintf (fp, cell->text->str);
fprintf (fp, "\n");
} else {
fprintf (fp, "\t<TD");
if (style->halign & HALIGN_RIGHT)
fprintf (fp, " halign=right");
if (style->halign & HALIGN_CENTER)
fprintf (fp, " halign=center");
if (style->valign & VALIGN_TOP)
fprintf (fp, " valign=top");
r = style->back_color->color.red >> 8;
g = style->back_color->color.green >> 8;
b = style->back_color->color.blue >> 8;
if (r != 255 || g != 255 || b != 255)
fprintf (fp, " bgcolor=\"#%02X%02X%02X\"", r, g, b);
fprintf (fp, ">");
r = style->fore_color->color.red >> 8;
g = style->fore_color->color.green >> 8;
b = style->fore_color->color.blue >> 8;
if (r != 0 || g != 0 || b != 0)
fprintf (fp, "<FONT color=\"#%02X%02X%02X\">",
r, g, b);
if (style->font->hint_is_bold)
fprintf (fp, "<B>");
if (style->font->hint_is_italic)
fprintf (fp, "<I>");
html_fprintf (fp, cell->text->str);
if (style->font->hint_is_bold)
fprintf (fp, "</B>");
if (style->font->hint_is_italic)
fprintf (fp, "</I>");
if (r != 0 || g != 0 || b != 0)
fprintf (fp, "</FONT>");
fprintf (fp, "\n");
}
}
}
fprintf (fp, "</TR>\n");
}
fprintf (fp, "</TABLE>\n<P>\n\n");
sheet_list = sheet_list->next;
}
fprintf (fp, "</HTML>\n");
fclose (fp);
return 0; /* Q: what do we have to return here?? */
}
#define HTML_BOLD 1
#define HTML_ITALIC 2
#define HTML_RIGHT 4
#define HTML_CENTER 8
/*
*/
static char *
html_get_string (char *s, int *flags)
{
#define LINESIZE 1024
static char buf[LINESIZE];
char *p, *q;
buf[0] = buf[LINESIZE-1] = '\0';
if (!s)
return NULL;
q = buf;
p = s;
while (*p) {
if (*p == '<') {
if ((((*(p+1) == 'I') || (*(p+1) == 'i'))) && (*(p+2) == '>'))
*flags |= HTML_ITALIC;
if ((((*(p+1) == 'B') || (*(p+1) == 'b'))) && (*(p+2) == '>'))
*flags |= HTML_BOLD;
/* needs more work.. */
while ((*p) && (*p != '>')) {
p++;
}
if (!(*p))
break;
} else if (*p == '&') {
if (strstr (p, "&lt;")) {
*q++ = '<';
p += 3;
} else if (strstr (p, "&gt;")) {
*q++ = '>';
p += 3;
} else {
*q++ = *p;
}
} else if (*p == '\n') {
break;
} else {
*q++ = *p;
}
p++;
}
*q = '\0';
return buf;
}
/*
* change the font of a cell to bold
*/
static void
html_cell_bold (Cell *cell)
{
char *old_name, *new_name;
Style *style;
char *name[] = { "bold", "demibold", "extrabold", "heavy", NULL };
int i;
StyleFont *sf;
if (!cell)
return;
style = cell->style;
if (!style)
return;
for (i = 0; name[i]; i++) {
old_name = style->font->font_name;
new_name = font_change_component (old_name, 2, name[i]);
sf = style_font_new_simple (new_name, style->font->units);
g_free (new_name);
if (sf) {
cell_set_font_from_style (cell, sf);
break;
}
}
}
/*
* change the font of a cell to italic
*/
static void
html_cell_italic (Cell *cell)
{
char *old_name, *new_name;
Style *style;
char *name[] = { "i", "o", NULL };
int i;
StyleFont *sf;
if (!cell)
return;
style = cell->style;
if (!style)
return;
for (i = 0; name[i]; i++) {
old_name = style->font->font_name;
new_name = font_change_component (old_name, 3, name[i]);
sf = style_font_new_simple (new_name, style->font->units);
g_free (new_name);
if (sf) {
cell_set_font_from_style (cell, sf);
break;
}
}
}
/*
* try at least to read back what we have written before..
*/
Workbook *
html_read (const char *filename)
{
FILE *fp;
Workbook *wb;
Sheet *sheet;
Cell *cell;
int num, row, col, flags;
char *p, *str;
char name[64];
char buf[LINESIZE];
if (!filename)
return NULL;
wb = workbook_new();
if (!wb)
return NULL;
workbook_set_filename (wb, filename);
fp = fopen (filename, "r");
if (!fp) {
/* Q: how to free the "wb"? */
return NULL;
}
sheet = NULL;
col = 0;
row = -1;
num = 0;
while (fgets (buf, LINESIZE, fp) != NULL) {
if (strstr (buf, "<TABLE")) {