Some more code modularization.

This commit is contained in:
slidedraw 2002-10-12 22:49:51 +00:00
parent 4f2cdde40b
commit 117379f7a6
10 changed files with 4308 additions and 4149 deletions

View File

@ -9,7 +9,7 @@ man_MANS = xlhtml.1
bin_SCRIPTS = nsopen nsxlview bin_SCRIPTS = nsopen nsxlview
bin_PROGRAMS = xlhtml bin_PROGRAMS = xlhtml
LDADD = ../cole/libcole.a -lm LDADD = ../cole/libcole.a -lm
xlhtml_SOURCES = support.c xlhtml.c html.c ascii.c xml.c xlhtml_SOURCES = support.c xlhtml.c html.c ascii.c xml.c setupExtraction.c engine.c
xldump_SOURCES = xldump.c xldump_SOURCES = xldump.c
xlcdump_SOURCES = xlcdump.c xlcdump_SOURCES = xlcdump.c
AM_CFLAGS = -Wall -Wshadow -Wcast-align -Wpointer-arith AM_CFLAGS = -Wall -Wshadow -Wcast-align -Wpointer-arith

View File

@ -83,9 +83,10 @@ man_MANS = xlhtml.1
bin_SCRIPTS = nsopen nsxlview bin_SCRIPTS = nsopen nsxlview
bin_PROGRAMS = xlhtml bin_PROGRAMS = xlhtml
LDADD = ../cole/libcole.a -lm LDADD = ../cole/libcole.a -lm
xlhtml_SOURCES = support.c xlhtml.c html.c ascii.c xml.c xlhtml_SOURCES = support.c xlhtml.c html.c ascii.c xml.c setupExtraction.c engine.c
xldump_SOURCES = xldump.c xldump_SOURCES = xldump.c
xlcdump_SOURCES = xlcdump.c xlcdump_SOURCES = xlcdump.c
AM_CFLAGS = -Wall -Wshadow -Wcast-align -Wpointer-arith
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES = CONFIG_CLEAN_FILES =
@ -96,7 +97,8 @@ DEFS = @DEFS@ -I. -I$(srcdir) -I..
CPPFLAGS = @CPPFLAGS@ CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@ LDFLAGS = @LDFLAGS@
LIBS = @LIBS@ LIBS = @LIBS@
xlhtml_OBJECTS = support.o xlhtml.o html.o ascii.o xml.o xlhtml_OBJECTS = support.o xlhtml.o html.o ascii.o xml.o \
setupExtraction.o engine.o
xlhtml_LDADD = $(LDADD) xlhtml_LDADD = $(LDADD)
xlhtml_DEPENDENCIES = ../cole/libcole.a xlhtml_DEPENDENCIES = ../cole/libcole.a
xlhtml_LDFLAGS = xlhtml_LDFLAGS =
@ -109,7 +111,6 @@ xlcdump_LDADD = $(LDADD)
xlcdump_DEPENDENCIES = ../cole/libcole.a xlcdump_DEPENDENCIES = ../cole/libcole.a
xlcdump_LDFLAGS = xlcdump_LDFLAGS =
SCRIPTS = $(bin_SCRIPTS) $(noinst_SCRIPTS) SCRIPTS = $(bin_SCRIPTS) $(noinst_SCRIPTS)
AM_CFLAGS = -Wall -Wshadow -Wcast-align -Wpointer-arith
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@ -384,6 +385,7 @@ install-am install uninstall-am uninstall all-redirect all-am all \
installdirs mostlyclean-generic distclean-generic clean-generic \ installdirs mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean maintainer-clean-generic clean mostlyclean distclean maintainer-clean
doc: doxygen.conf xlhtml.c ascii.c xml.c html.c support.c xlhtml.h tuneable.h doc: doxygen.conf xlhtml.c ascii.c xml.c html.c support.c xlhtml.h tuneable.h
@echo Generating documentation... @echo Generating documentation...
doxygen doxygen.conf doxygen doxygen.conf

View File

@ -26,78 +26,85 @@
void OutputPartialTableAscii(void) void
OutputPartialTableAscii (void)
{ {
int i, j, k; int i, j, k;
SetupExtraction(); SetupExtraction ();
/* Here's where we dump the Html Page out */ /* Here's where we dump the Html Page out */
for (i=first_sheet; i<=last_sheet; i++) /* For each worksheet */ for (i = first_sheet; i <= last_sheet; i++) /* For each worksheet */
{
if (ws_array[i] == 0)
continue;
if ((ws_array[i]->biggest_row == -1)
|| (ws_array[i]->biggest_col == -1))
continue;
if (ws_array[i]->c_array == 0)
continue;
/* Now dump the table */
for (j = ws_array[i]->first_row; j <= ws_array[i]->biggest_row; j++)
{ {
if (ws_array[i] == 0) for (k = ws_array[i]->first_col; k <= ws_array[i]->biggest_col; k++)
continue; {
if ((ws_array[i]->biggest_row == -1)||(ws_array[i]->biggest_col == -1)) int safe, numeric = 0;
continue; cell *c = ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k]; /* This stuff happens for each cell... */
if (ws_array[i]->c_array == 0)
continue;
/* Now dump the table */ if (c)
for (j=ws_array[i]->first_row; j<=ws_array[i]->biggest_row; j++)
{ {
for (k=ws_array[i]->first_col; k<=ws_array[i]->biggest_col; k++) numeric = IsCellNumeric (c);
{ if (!numeric && Csv)
int safe, numeric=0; printf ("\"");
cell *c = ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]; /* This stuff happens for each cell... */ safe = IsCellSafe (c);
if (c) if (c->ustr.str)
{ {
numeric = IsCellNumeric(c); if (safe)
if (!numeric && Csv) output_formatted_data (&(c->ustr),
printf("\""); xf_array[c->xfmt]->fmt_idx,
safe = IsCellSafe(c); numeric, IsCellFormula (c));
else
if (c->ustr.str) OutputString (&(c->ustr));
{ }
if (safe) else if (!Csv)
output_formatted_data(&(c->ustr), xf_array[c->xfmt]->fmt_idx, numeric, IsCellFormula(c)); printf (" "); /* Empty cell... */
else
OutputString(&(c->ustr));
}
else if (!Csv)
printf(" "); /* Empty cell... */
}
else
{ /* Empty cell... */
if (!Csv)
printf(" ");
else
printf("\"");
}
if (ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]) /* Honor Column spanning ? */
{
if (ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]->colspan != 0)
k += ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]->colspan-1;
}
if (!numeric && Csv)
printf("\"");
if (Csv && (k < ws_array[i]->biggest_col))
{ /* big cheat here: quoting everything! */
putchar(','); /* Csv Cell Separator */
}
else
{
if (( !Csv )&&( k != ws_array[i]->biggest_col ))
putchar('\t'); /* Ascii Cell Separator */
}
}
if (Csv)
printf("\r\n");
else
putchar(0x0A); /* Row Separator */
} }
if (!Csv) else
printf("\n\n"); /* End of Table 2 LF-CR */ { /* Empty cell... */
if (!Csv)
printf (" ");
else
printf ("\"");
}
if (ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k]) /* Honor Column spanning ? */
{
if (ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k]->
colspan != 0)
k +=
ws_array[i]->c_array[(j * ws_array[i]->max_cols) +
k]->colspan - 1;
}
if (!numeric && Csv)
printf ("\"");
if (Csv && (k < ws_array[i]->biggest_col))
{ /* big cheat here: quoting everything! */
putchar (','); /* Csv Cell Separator */
}
else
{
if ((!Csv) && (k != ws_array[i]->biggest_col))
putchar ('\t'); /* Ascii Cell Separator */
}
}
if (Csv)
printf ("\r\n");
else
putchar (0x0A); /* Row Separator */
} }
if (!Csv)
printf ("\n\n"); /* End of Table 2 LF-CR */
}
} }

View File

@ -28,372 +28,395 @@
/* prototypes for functions in this file */ /* prototypes for functions in this file */
void output_header(void); void output_header (void);
void output_footer(void); void output_footer (void);
void OutputTableHTML(void) void
OutputTableHTML (void)
{ {
int i, j, k; int i, j, k;
output_header(); output_header ();
if (center_tables) if (center_tables)
{
printf ("<CENTER>");
do_cr ();
}
SetupExtraction ();
/* Here's where we dump the Html Page out */
for (i = first_sheet; i <= last_sheet; i++) /* For each worksheet */
{
update_default_font (i);
if (ws_array[i] == 0)
continue;
if ((ws_array[i]->biggest_row == -1)
|| (ws_array[i]->biggest_col == -1))
continue;
if (ws_array[i]->c_array == 0)
continue;
trim_sheet_edges (i);
/* Print its name */
if (next_ws_title > 0)
{ {
printf("<CENTER>"); if (ws_array[i]->ws_title.str)
do_cr(); {
printf ("<CENTER><H1>");
OutputString (&ws_array[i]->ws_title);
printf ("</H1></CENTER><br>");
do_cr ();
}
else
{
printf ("<H1><CENTER>(Unknown Page)</CENTER></H1><br>");
do_cr ();
}
} }
SetupExtraction(); /* Now dump the table */
printf ("<FONT FACE=\"");
/* Here's where we dump the Html Page out */ OutputString (&default_font);
for (i=first_sheet; i<=last_sheet; i++) /* For each worksheet */ if (default_fontsize != 3)
printf ("\" SIZE=\"%d", default_fontsize);
printf ("\">");
do_cr ();
printf ("<TABLE BORDER=\"1\" CELLSPACING=\"2\">");
do_cr ();
if (TableHeaders)
{ {
update_default_font(i); printf ("<TR><TH></TH>");
if (ws_array[i] == 0) for (k = ws_array[i]->first_col; k <= ws_array[i]->biggest_col; k++)
continue; {
if ((ws_array[i]->biggest_row == -1)||(ws_array[i]->biggest_col == -1)) char col_hdr[3];
continue; if (k < 26)
if (ws_array[i]->c_array == 0)
continue;
trim_sheet_edges(i);
/* Print its name */
if (next_ws_title > 0)
{ {
if (ws_array[i]->ws_title.str) col_hdr[0] = 'A' + (k % 26);
{ col_hdr[1] = '\0';
printf("<CENTER><H1>");
OutputString(&ws_array[i]->ws_title);
printf("</H1></CENTER><br>");
do_cr();
}
else
{
printf("<H1><CENTER>(Unknown Page)</CENTER></H1><br>");
do_cr();
}
} }
else
/* Now dump the table */
printf("<FONT FACE=\"");
OutputString(&default_font);
if (default_fontsize != 3)
printf("\" SIZE=\"%d", default_fontsize);
printf("\">");
do_cr();
printf("<TABLE BORDER=\"1\" CELLSPACING=\"2\">");
do_cr();
if (TableHeaders)
{ {
printf("<TR><TH></TH>"); col_hdr[0] = 'A' - 1 + (k / 26);
for (k=ws_array[i]->first_col; k<=ws_array[i]->biggest_col; k++) col_hdr[1] = 'A' + (k % 26);
{ col_hdr[2] = '\0';
char col_hdr[3];
if (k < 26)
{
col_hdr[0]='A' + (k % 26);
col_hdr[1]='\0';
}
else
{
col_hdr[0]='A' - 1 + (k / 26);
col_hdr[1]='A' + (k % 26);
col_hdr[2]='\0';
}
printf("<TH>%s%s",col_hdr,(aggressive ? "" : "</TH>"));
}
printf("</TR>\n");
} }
for (j=ws_array[i]->first_row; j<=ws_array[i]->biggest_row; j++) printf ("<TH>%s%s", col_hdr, (aggressive ? "" : "</TH>"));
}
printf ("</TR>\n");
}
for (j = ws_array[i]->first_row; j <= ws_array[i]->biggest_row; j++)
{
update_default_alignment (i, j);
printf ("<TR");
if (null_string ((U8 *) default_alignment))
printf (">");
else
{
if (strcmp (default_alignment, "left") != 0)
printf (" ALIGN=\"%s\"", default_alignment);
if (!aggressive)
printf (" VALIGN=\"bottom\">\n");
else
printf (">");
}
if (TableHeaders)
printf ("<TH>%d%s", j + 1, (aggressive ? "" : "</TH>"));
for (k = ws_array[i]->first_col; k <= ws_array[i]->biggest_col; k++)
{
output_cell (ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k], 0); /* This stuff happens for each cell... */
if (ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k])
{ {
update_default_alignment(i, j); if (ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k]->
printf("<TR"); colspan != 0)
if (null_string((U8 *)default_alignment)) k +=
printf(">"); ws_array[i]->c_array[(j * ws_array[i]->max_cols) +
else k]->colspan - 1;
{
if (strcmp(default_alignment, "left") != 0)
printf(" ALIGN=\"%s\"", default_alignment);
if (!aggressive)
printf(" VALIGN=\"bottom\">\n");
else
printf(">");
}
if (TableHeaders)
printf("<TH>%d%s",j+1,(aggressive ? "" : "</TH>"));
for (k=ws_array[i]->first_col; k<=ws_array[i]->biggest_col; k++)
{
output_cell(ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k],0); /* This stuff happens for each cell... */
if (ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k])
{
if (ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]->colspan != 0)
k += ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]->colspan-1;
}
}
if (!aggressive)
printf("</TR>\n");
} }
printf("</TABLE></FONT><HR>"); }
do_cr();
}
if (center_tables) if (!aggressive)
{ printf ("</TR>\n");
printf("</CENTER>");
do_cr();
} }
printf ("</TABLE></FONT><HR>");
do_cr ();
}
/* Print the author's name in itallics... */ if (center_tables)
if (author.str) {
{ printf ("</CENTER>");
printf("<FONT SIZE=\"-1\"><I>Spreadsheet's Author:&nbsp;"); do_cr ();
OutputString(&author); }
printf("</I></FONT><br>");
do_cr();
}
/* Print when & how the file was last updated. */ /* Print the author's name in itallics... */
printf("<FONT SIZE=\"-1\"><I>Last Updated "); if (author.str)
if (lastUpdated) {
printf("%s&nbsp; ", lastUpdated); printf ("<FONT SIZE=\"-1\"><I>Spreadsheet's Author:&nbsp;");
switch (file_version) OutputString (&author);
{ printf ("</I></FONT><br>");
case EXCEL95: do_cr ();
printf("with Excel 5.0 or 95"); }
break;
case EXCEL97:
printf("with Excel 97");
break;
default:
printf("with Excel ????");
break;
}
printf("</I></FONT><br>");
do_cr();
/* Next print Disclaimers... */ /* Print when & how the file was last updated. */
if (NoFormat) printf ("<FONT SIZE=\"-1\"><I>Last Updated ");
{ if (lastUpdated)
printf("<br>* This cell's format is not supported.<br>"); printf ("%s&nbsp; ", lastUpdated);
do_cr(); switch (file_version)
} {
if ((notAccurate)&&(formula_warnings)) case EXCEL95:
{ printf ("with Excel 5.0 or 95");
printf("<br>** This cell's data may not be accurate.<br>"); break;
do_cr(); case EXCEL97:
} printf ("with Excel 97");
if (NotImplemented) break;
{ default:
printf("<br>*** This cell's data type will be supported in the future.<br>"); printf ("with Excel ????");
do_cr(); break;
} }
if (Unsupported) printf ("</I></FONT><br>");
{ do_cr ();
printf("<br>**** This cell's type is unsupported.<br>");
do_cr();
}
/* Now out exceeded capacity warnings... */ /* Next print Disclaimers... */
if (MaxWorksheetsExceeded || MaxRowExceeded || MaxColExceeded || MaxStringsExceeded || if (NoFormat)
MaxFontsExceeded || MaxPalExceeded || MaxXFExceeded || MaxFormatsExceeded ) {
printf("<FONT COLOR=\"%s\">", colorTab[0x0A]); printf ("<br>* This cell's format is not supported.<br>");
if (MaxWorksheetsExceeded) do_cr ();
{ }
printf("The Maximum Number of Worksheets was exceeded, you might want to increase it.<br>"); if ((notAccurate) && (formula_warnings))
do_cr(); {
} printf ("<br>** This cell's data may not be accurate.<br>");
if (MaxRowExceeded) do_cr ();
{ }
printf("The Maximum Number of Rows was exceeded, you might want to increase it.<br>"); if (NotImplemented)
do_cr(); {
} printf
if (MaxColExceeded) ("<br>*** This cell's data type will be supported in the future.<br>");
{ do_cr ();
printf("The Maximum Number of Columns was exceeded, you might want to increase it.<br>"); }
do_cr(); if (Unsupported)
} {
if (MaxStringsExceeded) printf ("<br>**** This cell's type is unsupported.<br>");
{ do_cr ();
printf("The Maximum Number of Strings was exceeded, you might want to increase it.<br>"); }
do_cr();
}
if (MaxFontsExceeded)
{
printf("The Maximum Number of Fonts was exceeded, you might want to increase it.<br>");
do_cr();
}
if (MaxPalExceeded)
{
printf("The Maximum Number of Color Palettes was exceeded, you might want to increase it.<br>");
do_cr();
}
if (MaxXFExceeded)
{
printf("The Maximum Number of Extended Formats was exceeded, you might want to increase it.<br>");
do_cr();
}
if (MaxFormatsExceeded)
{
printf("The Maximum Number of Formats was exceeded, you might want to increase it.<br>");
do_cr();
}
if (MaxWorksheetsExceeded || MaxRowExceeded || MaxColExceeded || MaxStringsExceeded ||
MaxFontsExceeded || MaxPalExceeded || MaxXFExceeded || MaxFormatsExceeded )
printf("</FONT>");
printf("&nbsp;<br>"); /* Now out exceeded capacity warnings... */
do_cr(); if (MaxWorksheetsExceeded || MaxRowExceeded || MaxColExceeded
|| MaxStringsExceeded || MaxFontsExceeded || MaxPalExceeded
|| MaxXFExceeded || MaxFormatsExceeded)
printf ("<FONT COLOR=\"%s\">", colorTab[0x0A]);
if (MaxWorksheetsExceeded)
{
printf
("The Maximum Number of Worksheets was exceeded, you might want to increase it.<br>");
do_cr ();
}
if (MaxRowExceeded)
{
printf
("The Maximum Number of Rows was exceeded, you might want to increase it.<br>");
do_cr ();
}
if (MaxColExceeded)
{
printf
("The Maximum Number of Columns was exceeded, you might want to increase it.<br>");
do_cr ();
}
if (MaxStringsExceeded)
{
printf
("The Maximum Number of Strings was exceeded, you might want to increase it.<br>");
do_cr ();
}
if (MaxFontsExceeded)
{
printf
("The Maximum Number of Fonts was exceeded, you might want to increase it.<br>");
do_cr ();
}
if (MaxPalExceeded)
{
printf
("The Maximum Number of Color Palettes was exceeded, you might want to increase it.<br>");
do_cr ();
}
if (MaxXFExceeded)
{
printf
("The Maximum Number of Extended Formats was exceeded, you might want to increase it.<br>");
do_cr ();
}
if (MaxFormatsExceeded)
{
printf
("The Maximum Number of Formats was exceeded, you might want to increase it.<br>");
do_cr ();
}
if (MaxWorksheetsExceeded || MaxRowExceeded || MaxColExceeded
|| MaxStringsExceeded || MaxFontsExceeded || MaxPalExceeded
|| MaxXFExceeded || MaxFormatsExceeded)
printf ("</FONT>");
/* Output Credit */ printf ("&nbsp;<br>");
printf("<hr><FONT SIZE=\"-1\">Created with <a href=\"http://chicago.sf.net/xlhtml\">xlhtml %s</a></FONT><br>", VERSION); do_cr ();
do_cr();
/* Output Tail */ /* Output Credit */
output_footer(); printf
("<hr><FONT SIZE=\"-1\">Created with <a href=\"http://chicago.sf.net/xlhtml\">xlhtml %s</a></FONT><br>",
VERSION);
do_cr ();
/* Output Tail */
output_footer ();
} }
void output_header(void) void
{ /* Ouput Header */ output_header (void)
if (NoHeaders) { /* Ouput Header */
return; if (NoHeaders)
if (!aggressive) return;
if (!aggressive)
{
printf ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML Transitional//EN\"");
do_cr ();
printf ("\"http://www.w3.org/TR/REC-html40/loose.dtd\">");
do_cr ();
}
printf ("<HTML>\n");
printf ("<HEAD>\n");
do_cr ();
printf ("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=");
if ((UnicodeStrings <= 1) && CodePage && (CodePage != 1252))
printf ("windows-%d\">", CodePage);
else
{
switch (UnicodeStrings)
{ {
printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML Transitional//EN\""); case 0:
do_cr(); printf ("iso-8859-1\">"); /* Latin-1 */
printf("\"http://www.w3.org/TR/REC-html40/loose.dtd\">"); break;
do_cr(); case 1:
printf ("windows-1252\">"); /* Microsoft */
break;
default:
printf ("utf-8\">"); /* Unicode */
break;
} }
printf("<HTML>\n"); }
printf("<HEAD>\n"); do_cr ();
do_cr();
printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=");
if ((UnicodeStrings <= 1)&&CodePage&&(CodePage != 1252))
printf("windows-%d\">", CodePage);
else
{
switch (UnicodeStrings)
{
case 0:
printf("iso-8859-1\">"); /* Latin-1 */
break;
case 1:
printf("windows-1252\">"); /* Microsoft */
break;
default:
printf("utf-8\">"); /* Unicode */
break;
}
}
do_cr();
if (!aggressive) if (!aggressive)
{ {
printf("<meta name=\"GENERATOR\" content=\"xlhtml\">"); printf ("<meta name=\"GENERATOR\" content=\"xlhtml\">");
do_cr(); do_cr ();
} }
printf("<TITLE>"); printf ("<TITLE>");
if (title) if (title)
printf("%s", title); printf ("%s", title);
else else
printf("%s", filename); printf ("%s", filename);
printf("</TITLE>"); printf ("</TITLE>");
do_cr(); do_cr ();
printf("</HEAD>"); printf ("</HEAD>");
do_cr(); do_cr ();
do_cr(); do_cr ();
printf("<BODY TEXT=\"#%s\" BGCOLOR=\"#%s\"", printf ("<BODY TEXT=\"#%s\" BGCOLOR=\"#%s\"",
default_text_color, default_background_color); default_text_color, default_background_color);
if (default_image) if (default_image)
printf("BACKGROUND=\"%s\"", default_image); printf ("BACKGROUND=\"%s\"", default_image);
printf("><br>"); printf ("><br>");
do_cr(); do_cr ();
} }
void output_footer(void) void
output_footer (void)
{ {
if (NoHeaders) if (NoHeaders)
return; return;
printf("</BODY></HTML>"); printf ("</BODY></HTML>");
do_cr(); do_cr ();
fflush(stdout); fflush (stdout);
} }
void output_start_html_attr(html_attr *h, unsigned int fnt_idx, int do_underlines) void
output_start_html_attr (html_attr * h, unsigned int fnt_idx,
int do_underlines)
{ {
if (fnt_idx < next_font) if (fnt_idx < next_font)
{
if (((font_array[fnt_idx]->underline & 0x0023) > 0) && (do_underlines))
{ {
if (((font_array[fnt_idx]->underline&0x0023) > 0)&&(do_underlines)) printf ("<U>");
{ h->uflag = 1;
printf("<U>");
h->uflag = 1;
}
if (font_array[fnt_idx]->bold >= 0x02BC)
{
h->bflag = 1;
printf("<B>");
}
if (font_array[fnt_idx]->attr & 0x0002)
{
h->iflag = 1;
printf("<I>");
}
if (font_array[fnt_idx]->attr & 0x0008)
{
h->sflag = 1;
printf("<S>");
}
if ((font_array[fnt_idx]->super & 0x0003) == 0x0001)
{
h->spflag = 1;
printf("<SUP>");
}
else if ((font_array[fnt_idx]->super & 0x0003) == 0x0002)
{
h->sbflag = 1;
printf("<SUB>");
}
} }
if (font_array[fnt_idx]->bold >= 0x02BC)
{
h->bflag = 1;
printf ("<B>");
}
if (font_array[fnt_idx]->attr & 0x0002)
{
h->iflag = 1;
printf ("<I>");
}
if (font_array[fnt_idx]->attr & 0x0008)
{
h->sflag = 1;
printf ("<S>");
}
if ((font_array[fnt_idx]->super & 0x0003) == 0x0001)
{
h->spflag = 1;
printf ("<SUP>");
}
else if ((font_array[fnt_idx]->super & 0x0003) == 0x0002)
{
h->sbflag = 1;
printf ("<SUB>");
}
}
} }
void output_end_html_attr(html_attr *h) void
output_end_html_attr (html_attr * h)
{ {
if (h->sbflag) if (h->sbflag)
{ {
printf("</SUB>"); printf ("</SUB>");
h->sbflag = 0; h->sbflag = 0;
} }
else if (h->spflag) else if (h->spflag)
{ {
printf("</SUP>"); printf ("</SUP>");
h->spflag = 0; h->spflag = 0;
} }
if (h->sflag) if (h->sflag)
{ {
printf("</S>"); printf ("</S>");
h->sflag = 0; h->sflag = 0;
} }
if (h->iflag) if (h->iflag)
{ {
printf("</I>"); printf ("</I>");
h->iflag = 0; h->iflag = 0;
} }
if (h->bflag) if (h->bflag)
{ {
printf("</B>"); printf ("</B>");
h->bflag = 0; h->bflag = 0;
} }
if (h->uflag) if (h->uflag)
{ {
if (h->uflag == 1) if (h->uflag == 1)
printf("</U>"); printf ("</U>");
else else
printf("</A>"); printf ("</A>");
h->uflag = 0; h->uflag = 0;
} }
if (h->fflag) if (h->fflag)
{ {
printf("</FONT>"); printf ("</FONT>");
h->fflag = 0; h->fflag = 0;
} }
} }

94
xlhtml/setupExtraction.c Normal file
View File

@ -0,0 +1,94 @@
#include <stdio.h>
#include "xlhtml.h"
#include "support.h"
extern int Xtract;
extern int xp;
extern int sheet_count;
extern int xr1 ;
extern int xr2 ;
extern int xc1 ;
extern int xc2 ;
extern int Ascii;
void
SetupExtraction (void)
{
if (Xtract)
{ /* Revise the page settings... */
/* printf("-%d %d %d %d %d<br>\n", xp, xr1, xr2, xc1, xc2); */
if ((xp >= first_sheet) && (xp <= last_sheet) && (xp <= sheet_count))
{
first_sheet = xp;
last_sheet = xp;
if (xr1 < 0)
{
xr1 = (S16) ws_array[xp]->first_row;
xr2 = (S16) ws_array[xp]->biggest_row;
}
else if ((xr1 >= ws_array[xp]->first_row)
&& (xr1 <= ws_array[xp]->biggest_row)
&& (xr2 >= ws_array[xp]->first_row)
&& (xr2 <= ws_array[xp]->biggest_row))
{
ws_array[xp]->first_row = xr1;
ws_array[xp]->biggest_row = xr2;
}
else
{
if (Ascii)
fprintf (stderr, "Error - Row not in range during extraction"
" (%d or %d not in [%ld..%ld])\n", xr1, xr2,
(long) ws_array[xp]->first_row,
(long) ws_array[xp]->biggest_row);
else
{
printf ("Error - Row not in range during extraction.");
output_footer ();
}
return;
}
if (xc1 < 0)
{
xc1 = ws_array[xp]->first_col;
xc2 = ws_array[xp]->biggest_col;
}
else if ((xc1 >= ws_array[xp]->first_col)
&& (xc1 <= ws_array[xp]->biggest_col)
&& (xc2 >= ws_array[xp]->first_col)
&& (xc2 <= ws_array[xp]->biggest_col))
{
ws_array[xp]->first_col = xc1;
ws_array[xp]->biggest_col = xc2;
}
else
{
if (Ascii)
fprintf (stderr, "Error - Col not in range during extraction"
" (%d or %d not in [%d..%d])\n", xc1, xc2,
ws_array[xp]->first_col, ws_array[xp]->biggest_col);
else
{
printf ("Error - Col not in range during extraction.\n");
output_footer ();
}
return;
}
}
else
{
if (Ascii)
fprintf (stderr, "Error - Page not in range during extraction.");
else
{
printf ("Error - Page not in range during extraction.");
output_footer ();
}
return;
}
}
}

View File

@ -28,195 +28,207 @@
#include <stdlib.h> #include <stdlib.h>
int DatesR1904 = 0; /*!< Flag that the dates are based on McIntosh Dates system */ int DatesR1904 = 0; /*!< Flag that the dates are based on McIntosh Dates system */
void print_version(void) void
print_version (void)
{ {
printf("xlhtml %s \nCopyright (c) 1999-2002, Charles Wyble\n" printf ("xlhtml %s \nCopyright (c) 1999-2002, Charles Wyble\n"
"Released under GPL.\n", VERSION ); "Released under GPL.\n", VERSION);
exit(0); exit (0);
} }
void display_usage(void) void
display_usage (void)
{ {
fprintf(stderr, "\nxlhtml converts excel files (.xls) to Html.\n" fprintf (stderr, "\nxlhtml converts excel files (.xls) to Html.\n"
"Copyright (c) 1999-2001, Charles Wyble. Released under GPL.\n" "Copyright (c) 1999-2001, Charles Wyble. Released under GPL.\n"
"Usage: xlhtml [-xp:# -xc:#-# -xr:#-# -bc###### -bi???????? -tc######] <FILE>\n" "Usage: xlhtml [-xp:# -xc:#-# -xr:#-# -bc###### -bi???????? -tc######] <FILE>\n"
"\t-a: aggressive html optimization\n" "\t-a: aggressive html optimization\n"
"\t-asc ascii output for -dp & -x? options\n" "\t-asc ascii output for -dp & -x? options\n"
"\t-csv comma separated value output for -dp & -x? options\n" "\t-csv comma separated value output for -dp & -x? options\n"
"\t-xml XML output\n" "\t-xml XML output\n"
"\t-bc: Set default background color - default white\n" "\t-bc: Set default background color - default white\n"
"\t-bi: Set background image path\n" "\t-bi: Set background image path\n"
"\t-c: Center justify tables\n" "\t-c: Center justify tables\n"
"\t-dp: Dumps page count and max rows & colums per page\n" "\t-dp: Dumps page count and max rows & colums per page\n"
"\t-v: Prints program version number\n" "\t-v: Prints program version number\n"
"\t-fw: Suppress formula warnings\n" "\t-fw: Suppress formula warnings\n"
"\t-m: No encoding for multibyte\n" "\t-m: No encoding for multibyte\n"
"\t-nc: No Colors - black & white\n" "\t-nc: No Colors - black & white\n"
"\t-nh: No Html Headers\n" "\t-nh: No Html Headers\n"
"\t-tc: Set default text color - default black\n" "\t-tc: Set default text color - default black\n"
"\t-te: Trims empty rows & columns at the edges of a worksheet\n" "\t-te: Trims empty rows & columns at the edges of a worksheet\n"
"\t-xc: Columns (separated by a dash) for extraction (zero based)\n" "\t-xc: Columns (separated by a dash) for extraction (zero based)\n"
"\t-xp: Page extracted (zero based)\n" "\t-xp: Page extracted (zero based)\n"
"\t-xr: Rows (separated by a dash) to be extracted (zero based)\n"); "\t-xr: Rows (separated by a dash) to be extracted (zero based)\n");
fprintf(stderr, "\nReport bugs to jackshck@thewybles.com\n"); fprintf (stderr, "\nReport bugs to jackshck@thewybles.com\n");
exit (1); exit (1);
} }
void do_cr(void) void
do_cr (void)
{ {
extern int aggressive; extern int aggressive;
if (!aggressive) if (!aggressive)
putchar('\n'); putchar ('\n');
} }
U16 getShort(U8 *ptr) U16
getShort (U8 * ptr)
{ {
if (ptr == 0) if (ptr == 0)
return (U16)0; return (U16) 0;
return (U16)((*(ptr+1)<<8)+*ptr); return (U16) ((*(ptr + 1) << 8) + *ptr);
} }
/*! This is used in the RK number, so signedness counts */ /*! This is used in the RK number, so signedness counts */
S32 getLong(U8 *ptr) S32
getLong (U8 * ptr)
{ {
if (ptr == 0) if (ptr == 0)
return (S32)0; return (S32) 0;
return (S32)(*(ptr+3)<<24)+(*(ptr+2)<<16)+(*(ptr+1)<<8)+*ptr; return (S32) (*(ptr + 3) << 24) + (*(ptr + 2) << 16) + (*(ptr + 1) << 8) +
*ptr;
} }
#ifndef WORDS_BIGENDIAN /* Defined in <config.h> */ #ifndef WORDS_BIGENDIAN /* Defined in <config.h> */
#ifdef __arm__ #ifdef __arm__
/* cross-endian doubles in little endian ARM */ /* cross-endian doubles in little endian ARM */
void getDouble(U8 *ptr, F64 *d) void
getDouble (U8 * ptr, F64 * d)
{ {
size_t i; size_t i;
F64 dd; F64 dd;
U8 *t = (U8 *)&dd; U8 *t = (U8 *) & dd;
for (i=0; i<sizeof(F64); i++) for (i = 0; i < sizeof (F64); i++)
*(t+i) = *(ptr+(i^4)); *(t + i) = *(ptr + (i ^ 4));
*d = (F64)dd; *d = (F64) dd;
} }
#else #else
/*! Little Endian - 0x86 family */ /*! Little Endian - 0x86 family */
void getDouble(U8 *ptr, F64 *d) void
getDouble (U8 * ptr, F64 * d)
{ {
size_t i; size_t i;
F64 dd; F64 dd;
U8 *t = (U8 *)&dd; U8 *t = (U8 *) & dd;
for (i=0; i<sizeof(F64); i++) for (i = 0; i < sizeof (F64); i++)
*(t+i) = *(ptr+i); *(t + i) = *(ptr + i);
*d = (F64)dd; *d = (F64) dd;
} }
#endif #endif
#else #else
/*! Big Endian version - UltraSparc's, etc. */ /*! Big Endian version - UltraSparc's, etc. */
void getDouble (U8 *ptr, F64 *d) void
getDouble (U8 * ptr, F64 * d)
{ {
size_t i; size_t i;
F64 dd; F64 dd;
U8 *t = (U8 *)&dd; U8 *t = (U8 *) & dd;
for (i=0; i<sizeof(F64); i++) for (i = 0; i < sizeof (F64); i++)
*(t+i) = *(ptr+sizeof(F64) - 1 - i); *(t + i) = *(ptr + sizeof (F64) - 1 - i);
*d = (F64)dd; *d = (F64) dd;
} }
#endif #endif
int null_string(U8 *str) int
{ /* FIXME: This function may not be unicode safe */ null_string (U8 * str)
U8 *ptr; { /* FIXME: This function may not be unicode safe */
if ((str == NULL)||(*str == 0)) U8 *ptr;
return 1; if ((str == NULL) || (*str == 0))
return 1;
ptr = str; ptr = str;
while (*ptr != 0) while (*ptr != 0)
{ {
if (*ptr++ != ' ') if (*ptr++ != ' ')
return 0; return 0;
} }
return 1; return 1;
} }
void FracToTime(U8 *cnum, int *hr, int *minut, int *sec, int *msec) void
FracToTime (U8 * cnum, int *hr, int *minut, int *sec, int *msec)
{ {
int Hr, Min, Sec, Msec; int Hr, Min, Sec, Msec;
F64 fnum, tHr, tMin, tSec, tMsec; F64 fnum, tHr, tMin, tSec, tMsec;
if (msec) if (msec)
fnum = atof((char *)&cnum[0])+(0.05 / 86400.0); /* Round off to 1/10th seconds */ fnum = atof ((char *) &cnum[0]) + (0.05 / 86400.0); /* Round off to 1/10th seconds */
else if (sec) else if (sec)
fnum = atof((char *)&cnum[0])+(0.5 / 86400.0); /* Round off to seconds */ fnum = atof ((char *) &cnum[0]) + (0.5 / 86400.0); /* Round off to seconds */
else else
fnum = atof((char *)&cnum[0])+(30 / 86400.0); /* Round off to minutes */ fnum = atof ((char *) &cnum[0]) + (30 / 86400.0); /* Round off to minutes */
tHr = 24.0 * fnum; tHr = 24.0 * fnum;
Hr = (int)tHr; Hr = (int) tHr;
tMin = (tHr - (F64)Hr) * 60.0; tMin = (tHr - (F64) Hr) * 60.0;
Min = (int)tMin; Min = (int) tMin;
tSec = (tMin - (F64)Min) * 60.0; tSec = (tMin - (F64) Min) * 60.0;
Sec = (int)tSec; Sec = (int) tSec;
tMsec = (tSec - (F64)Sec) * 10.0; tMsec = (tSec - (F64) Sec) * 10.0;
Msec = (int)tMsec; Msec = (int) tMsec;
Hr = Hr%24; /* Fix roll-overs */ Hr = Hr % 24; /* Fix roll-overs */
if (hr) if (hr)
*hr = Hr; *hr = Hr;
if (minut) if (minut)
*minut = Min; *minut = Min;
if (sec) if (sec)
*sec = Sec; *sec = Sec;
if (msec) if (msec)
*msec = Msec; *msec = Msec;
} }
void NumToDate(long num, int *year, int *month, int *day) void
NumToDate (long num, int *year, int *month, int *day)
{ {
const int ldays[]={31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const int ldays[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
const int ndays[]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const int ndays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int t, i, y = 0; int t, i, y = 0;
num = num%36525L; /* Trim century */ num = num % 36525L; /* Trim century */
while (num > (((y%4) == 0) ? 366 : 365)) while (num > (((y % 4) == 0) ? 366 : 365))
num -= ((y++%4) == 0) ? 366 : 365; num -= ((y++ % 4) == 0) ? 366 : 365;
*year = y; *year = y;
t = num; t = num;
if (DatesR1904) if (DatesR1904)
*year += 4; /* Adjust for McIntosh... */ *year += 4; /* Adjust for McIntosh... */
if ((*year%4) == 0) if ((*year % 4) == 0)
{ /* Leap Year */ { /* Leap Year */
for (i=0; i<12; i++) for (i = 0; i < 12; i++)
{
if (t <= ldays[i])
break;
t -= ldays[i];
}
}
else
{ {
for (i=0; i<12; i++) if (t <= ldays[i])
{ break;
if (t <= ndays[i]) t -= ldays[i];
break;
t -= ndays[i];
}
} }
/* Some fixups... */ }
*month = 1+i; else
if (t == 0) {
t = 1; for (i = 0; i < 12; i++)
*day = t; {
*year = *year % 100; if (t <= ndays[i])
break;
t -= ndays[i];
}
}
/* Some fixups... */
*month = 1 + i;
if (t == 0)
t = 1;
*day = t;
*year = *year % 100;
} }
typedef S32 swords[2]; typedef S32 swords[2];
@ -224,30 +236,34 @@ typedef S32 swords[2];
#define noaliasdub(type,ptr) \ #define noaliasdub(type,ptr) \
(((union{swords sw; F64 dub;} *)(ptr))->sw) (((union{swords sw; F64 dub;} *)(ptr))->sw)
#ifndef WORDS_BIGENDIAN /*! Defined in <config.h> */ #ifndef WORDS_BIGENDIAN /*! Defined in <config.h> */
#ifdef __arm__ #ifdef __arm__
/* cross-endian doubles in little endian ARM */ /* cross-endian doubles in little endian ARM */
void RKtoDouble(S32 n, F64 *d) void
RKtoDouble (S32 n, F64 * d)
{ {
noaliasdub(swords,d)[0] = n << 2; noaliasdub (swords, d)[0] = n << 2;
noaliasdub(swords,d)[1] = 0; noaliasdub (swords, d)[1] = 0;
} }
#else #else
/*! Little Endian - 0x86 family */ /*! Little Endian - 0x86 family */
void RKtoDouble(S32 n, F64 *d) void
RKtoDouble (S32 n, F64 * d)
{ {
noaliasdub(swords,d)[0] = 0; noaliasdub (swords, d)[0] = 0;
noaliasdub(swords,d)[1] = n << 2; noaliasdub (swords, d)[1] = n << 2;
} }
#endif #endif
#else #else
/*! Big Endian version - UltraSparc's, etc. */ /*! Big Endian version - UltraSparc's, etc. */
void RKtoDouble(S32 n, F64 *d) void
RKtoDouble (S32 n, F64 * d)
{ {
U8 *ptr = (U8 *)&n; U8 *ptr = (U8 *) & n;
noaliasdub(swords,d)[1] = 0; noaliasdub (swords, d)[1] = 0;
noaliasdub(swords,d)[0] = noaliasdub (swords, d)[0] =
((*(ptr+0)<<24)+(*(ptr+1)<<16)+(*(ptr+2)<<8)+(*(ptr+3))) << 2; ((*(ptr + 0) << 24) + (*(ptr + 1) << 16) + (*(ptr + 2) << 8) +
(*(ptr + 3))) << 2;
} }
#endif #endif

View File

@ -25,22 +25,22 @@
#include <ctype.h> /* For isprint */ #include <ctype.h> /* For isprint */
#define MODE 0 /* 0 - ascii; 1 - hex */ #define MODE 0 /* 0 - ascii; 1 - hex */
#define TEXT 0 /* In ascii mode, 0 - ascii, 1 - hex */ #define TEXT 0 /* In ascii mode, 0 - ascii, 1 - hex */
#define PRGNAME "xlcdump" #define PRGNAME "xlcdump"
#define MAX_COLS 64 #define MAX_COLS 64
#define MAX_ROWS 512 #define MAX_ROWS 512
static char FileName[2][12] = /* The section of the Excel Spreadsheet we read in */ static char FileName[2][12] = /* The section of the Excel Spreadsheet we read in */
{ {
"/Workbook", /* Office 97 */ "/Workbook", /* Office 97 */
"/Book" /* Everything else ? */ "/Book" /* Everything else ? */
}; };
/* Function Prototypes */ /* Function Prototypes */
COLE_LOCATE_ACTION_FUNC dump_file; COLE_LOCATE_ACTION_FUNC dump_file;
static void output_opcode_string(int); static void output_opcode_string (int);
/* Global data */ /* Global data */
static char filename[128]; static char filename[128];
@ -48,323 +48,331 @@ static char filename[128];
int aggressive = 0; /*!< Aggressive html optimization */ int aggressive = 0; /*!< Aggressive html optimization */
int main (int argc, char **argv) int
main (int argc, char **argv)
{ {
int f_ptr = 0; int f_ptr = 0;
COLEFS * cfs; COLEFS *cfs;
COLERRNO colerrno; COLERRNO colerrno;
if (argc < 2) if (argc < 2)
{
fprintf (stderr, "dump - Outputs excel chart records for analysis.\n"
"Usage: " PRGNAME " <FILE>\n");
exit (1);
}
else
{
strncpy (filename, argv[1], 124);
cfs = cole_mount (filename, &colerrno);
if (cfs == NULL)
{ {
fprintf (stderr, "dump - Outputs excel chart records for analysis.\n" cole_perror (PRGNAME, colerrno);
"Usage: "PRGNAME" <FILE>\n"); exit (1);
exit (1);
}
else
{
strncpy(filename, argv[1], 124);
cfs = cole_mount (filename, &colerrno);
if (cfs == NULL)
{
cole_perror (PRGNAME, colerrno);
exit (1);
}
} }
}
while (cole_locate_filename (cfs, FileName[f_ptr], NULL, dump_file, &colerrno)) while (cole_locate_filename
(cfs, FileName[f_ptr], NULL, dump_file, &colerrno))
{
if (f_ptr)
{ {
if (f_ptr) cole_perror (PRGNAME, colerrno);
{ break;
cole_perror (PRGNAME, colerrno);
break;
}
else
f_ptr++;
} }
else
f_ptr++;
}
if (cole_umount (cfs, &colerrno)) if (cole_umount (cfs, &colerrno))
{ {
cole_perror ("travel", colerrno); cole_perror ("travel", colerrno);
exit (1); exit (1);
} }
return 0; return 0;
} }
void dump_file(COLEDIRENT *cde, void *_info) void
dump_file (COLEDIRENT * cde, void *_info)
{ {
unsigned int length=0, opcode=0, target=0, count = 0; unsigned int length = 0, opcode = 0, target = 0, count = 0;
unsigned char buf[16]; unsigned char buf[16];
COLEFILE *cf; COLEFILE *cf;
COLERRNO err; COLERRNO err;
(void) _info; /*UNUSED*/ (void) _info;
/*UNUSED*/ cf = cole_fopen_direntry (cde, &err);
cf = cole_fopen_direntry(cde, &err); /* Ouput Header */
printf ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n");
/* Ouput Header */ printf ("<HTML><HEAD><TITLE>%s", filename);
printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n"); printf ("</TITLE></HEAD><BODY>\n");
printf("<HTML><HEAD><TITLE>%s", filename);
printf("</TITLE></HEAD><BODY>\n");
/* Output body */ /* Output body */
#if (MODE == 1) #if (MODE == 1)
while (cole_fread(cf, buf, 8, &err)) /* For mode >= 1 */ while (cole_fread (cf, buf, 8, &err)) /* For mode >= 1 */
#else #else
while (cole_fread(cf, buf, 1, &err)) while (cole_fread (cf, buf, 1, &err))
#endif #endif
{
if (MODE == 0)
{ {
if (MODE == 0) if (count == 0)
{ {
if (count == 0) length = 0;
{ opcode = (unsigned) buf[0];
length = 0; target = 80; /* ficticious number */
opcode = (unsigned)buf[0]; printf ("<br>");
target = 80; /* ficticious number */ }
printf("<br>"); else if (count == 1)
} opcode |= (buf[0] << 8) & 0x0000FFFFL;
else if (count == 1) else if (count == 2)
opcode |= (buf[0]<<8)&0x0000FFFFL; length = (unsigned) buf[0];
else if (count == 2) else if (count == 3)
length = (unsigned)buf[0]; {
else if (count == 3) length |= (buf[0] << 8);
{ target = length;
length |= (buf[0]<<8); printf ("<br>\nLength:%04X Opcode:%04X - ", length, opcode);
target = length; output_opcode_string (opcode);
printf("<br>\nLength:%04X Opcode:%04X - ", length, opcode); puts ("<br>\n");
output_opcode_string(opcode); }
puts("<br>\n"); if (count > 3)
} { /* Here is where we want to process the data */
if (count > 3) /* based on the opcode... */
{ /* Here is where we want to process the data */
/* based on the opcode... */
#if (TEXT == 0) #if (TEXT == 0)
if (isprint(buf[0])) if (isprint (buf[0]))
putc(buf[0], stdout); putc (buf[0], stdout);
#else #else
printf("%02X ", buf[0]); printf ("%02X ", buf[0]);
if (((count-3) % 8) == 0) if (((count - 3) % 8) == 0)
printf("<br>\n"); printf ("<br>\n");
#endif #endif
} }
if (count == (target+3)) if (count == (target + 3))
count = 0; count = 0;
else else
count++; count++;
}
else /* mode >= 1 */
{
printf("%02x %02x %02x %02x %02x %02x %02x %02x &nbsp; &nbsp; &nbsp; &nbsp; ",
(unsigned)buf[0], (unsigned)buf[1], (unsigned)buf[2], (unsigned)buf[3],
(unsigned)buf[4], (unsigned)buf[5], (unsigned)buf[6], (unsigned)buf[7]);
putchar(buf[0]); putchar(buf[1]);
putchar(buf[2]); putchar(buf[3]);
putchar(buf[4]); putchar(buf[5]);
putchar(buf[6]); putchar(buf[7]);
printf("<br>\n");
}
} }
else /* mode >= 1 */
{
printf
("%02x %02x %02x %02x %02x %02x %02x %02x &nbsp; &nbsp; &nbsp; &nbsp; ",
(unsigned) buf[0], (unsigned) buf[1], (unsigned) buf[2],
(unsigned) buf[3], (unsigned) buf[4], (unsigned) buf[5],
(unsigned) buf[6], (unsigned) buf[7]);
putchar (buf[0]);
putchar (buf[1]);
putchar (buf[2]);
putchar (buf[3]);
putchar (buf[4]);
putchar (buf[5]);
putchar (buf[6]);
putchar (buf[7]);
printf ("<br>\n");
}
}
/* Output Tail */ /* Output Tail */
printf("</BODY></HTML>\n"); printf ("</BODY></HTML>\n");
cole_fclose(cf, &err); cole_fclose (cf, &err);
} }
static void output_opcode_string(int opcode) static void
output_opcode_string (int opcode)
{ {
switch (opcode&0x00FF) switch (opcode & 0x00FF)
{ {
case 0x10: case 0x10:
case 0x01: case 0x01:
puts("UNITS: Chart Units"); puts ("UNITS: Chart Units");
break; break;
case 0x02: case 0x02:
puts("CHART: Location and overall chart dimensions"); puts ("CHART: Location and overall chart dimensions");
break; break;
case 0x03: case 0x03:
puts("SERIES: Series Definition"); puts ("SERIES: Series Definition");
break; break;
case 0x06: case 0x06:
puts("DATAFORMAT: Series and Data Point Numbers"); puts ("DATAFORMAT: Series and Data Point Numbers");
break; break;
case 0x07: case 0x07:
puts("LINEFORMAT: Style of a line or border"); puts ("LINEFORMAT: Style of a line or border");
break; break;
case 0x09: case 0x09:
puts("MARKERFORMAT: Style of a line marker"); puts ("MARKERFORMAT: Style of a line marker");
break; break;
case 0x0A: case 0x0A:
puts("AREAFORMAT: Colors and patterns for an area"); puts ("AREAFORMAT: Colors and patterns for an area");
break; break;
case 0x0B: case 0x0B:
puts("PIEFORMAT: Position of the pie slice"); puts ("PIEFORMAT: Position of the pie slice");
break; break;
case 0x0C: case 0x0C:
puts("ATTACHEDLABEL: Series data/value labels"); puts ("ATTACHEDLABEL: Series data/value labels");
break; break;
case 0x0D: case 0x0D:
puts("SERIESTEXT: Legend/category/value text"); puts ("SERIESTEXT: Legend/category/value text");
break; break;
case 0x14: case 0x14:
puts("CHARTFORMAT: Parent record for chart group"); puts ("CHARTFORMAT: Parent record for chart group");
break; break;
case 0x15: case 0x15:
puts("LEGEND: Legend type and position"); puts ("LEGEND: Legend type and position");
break; break;
case 0x16: case 0x16:
puts("SERIESLIST: Specifies the series in an overlay chart"); puts ("SERIESLIST: Specifies the series in an overlay chart");
break; break;
case 0x17: case 0x17:
puts("BAR: Chart group is a bar or column chart group"); puts ("BAR: Chart group is a bar or column chart group");
break; break;
case 0x18: case 0x18:
puts("LINE: Chart group is a line chart group"); puts ("LINE: Chart group is a line chart group");
break; break;
case 0x19: case 0x19:
puts("PIE: Chart group is a pie chart group"); puts ("PIE: Chart group is a pie chart group");
break; break;
case 0x1A: case 0x1A:
puts("AREA: Chart group is an area chart group"); puts ("AREA: Chart group is an area chart group");
break; break;
case 0x1B: case 0x1B:
puts("SCATTER: Chart group is a scatter chart group"); puts ("SCATTER: Chart group is a scatter chart group");
break; break;
case 0x1C: case 0x1C:
puts("CHARTLINE: Drop/Hi-Lo/Series Lines on a line chart"); puts ("CHARTLINE: Drop/Hi-Lo/Series Lines on a line chart");
break; break;
case 0x1D: case 0x1D:
puts("AXIS: Axis Type"); puts ("AXIS: Axis Type");
break; break;
case 0x1E: case 0x1E:
puts("TICK: Tick marks and labels format"); puts ("TICK: Tick marks and labels format");
break; break;
case 0x1F: case 0x1F:
puts("VALUERANGE: Defines value axis scale"); puts ("VALUERANGE: Defines value axis scale");
break; break;
case 0x20: case 0x20:
puts("CATSERRANGE: Defines a category or series axis"); puts ("CATSERRANGE: Defines a category or series axis");
break; break;
case 0x21: case 0x21:
puts("AXISLINEFORMAT: Defines a line that spans an axis"); puts ("AXISLINEFORMAT: Defines a line that spans an axis");
break; break;
case 0x22: case 0x22:
puts("CHARTFORMTLINK: Not Used"); puts ("CHARTFORMTLINK: Not Used");
break; break;
case 0x24: case 0x24:
puts("DEFAULTTEXT: Default data label text properties"); puts ("DEFAULTTEXT: Default data label text properties");
break; break;
case 0x25: case 0x25:
puts("TEXT: Defines display of text fields"); puts ("TEXT: Defines display of text fields");
break; break;
case 0x26: case 0x26:
puts("FONTX: Font Index"); puts ("FONTX: Font Index");
break; break;
case 0x27: case 0x27:
puts("OBJECTLINK: Attaches Text to chart or chart item"); puts ("OBJECTLINK: Attaches Text to chart or chart item");
break; break;
case 0x32: case 0x32:
puts("FRAME: Defines border shape around displayed text"); puts ("FRAME: Defines border shape around displayed text");
break; break;
case 0x33: case 0x33:
puts("BEGIN: Defines the beginning of an object"); puts ("BEGIN: Defines the beginning of an object");
break; break;
case 0x34: case 0x34:
puts("END: Defines the end of an object"); puts ("END: Defines the end of an object");
break; break;
case 0x35: case 0x35:
puts("PLOTAREA: Frame belongs to ploat area"); puts ("PLOTAREA: Frame belongs to ploat area");
break; break;
case 0x3A: case 0x3A:
puts("3d Chart group"); puts ("3d Chart group");
break; break;
case 0x3C: case 0x3C:
puts("PICF: Picture Format"); puts ("PICF: Picture Format");
break; break;
case 0x3D: case 0x3D:
puts("DROPBAR: Defines drop bars"); puts ("DROPBAR: Defines drop bars");
break; break;
case 0x3E: case 0x3E:
puts("RADAR: Chart group is a radar chart group"); puts ("RADAR: Chart group is a radar chart group");
break; break;
case 0x3F: case 0x3F:
puts("SURFACE: Chart group is a surface chart group"); puts ("SURFACE: Chart group is a surface chart group");
break; break;
case 0x40: case 0x40:
puts("RADARAREA: Chart group is a radar area chart group"); puts ("RADARAREA: Chart group is a radar area chart group");
break; break;
case 0x41: case 0x41:
puts("AXISPARENT: Axis size and location"); puts ("AXISPARENT: Axis size and location");
break; break;
case 0x43: case 0x43:
puts("LEGENDXN: Legend Exception"); puts ("LEGENDXN: Legend Exception");
break; break;
case 0x44: case 0x44:
puts("SHTPROPS: Sheet Properties"); puts ("SHTPROPS: Sheet Properties");
break; break;
case 0x45: case 0x45:
puts("SERTOCRT: Series chart-group index"); puts ("SERTOCRT: Series chart-group index");
break; break;
case 0x46: case 0x46:
puts("AXESUSED: Number of axes sets"); puts ("AXESUSED: Number of axes sets");
break; break;
case 0x48: case 0x48:
puts("SBASEREF: PivotTable Reference"); puts ("SBASEREF: PivotTable Reference");
break; break;
case 0x4A: case 0x4A:
puts("SERPARENT: Trendline or Errorbar series index"); puts ("SERPARENT: Trendline or Errorbar series index");
break; break;
case 0x4B: case 0x4B:
puts("SERAUXTREND: Series trendline"); puts ("SERAUXTREND: Series trendline");
break; break;
case 0x4E: case 0x4E:
puts("IFMT: Number-Format Index"); puts ("IFMT: Number-Format Index");
break; break;
case 0x4F: case 0x4F:
puts("POS: Position information"); puts ("POS: Position information");
break; break;
case 0x50: case 0x50:
puts("ALRUNS: Text formatting"); puts ("ALRUNS: Text formatting");
break; break;
case 0x51: case 0x51:
puts("AI: Linked data"); puts ("AI: Linked data");
break; break;
case 0x5B: case 0x5B:
puts("Series ErrorBar"); puts ("Series ErrorBar");
break; break;
case 0x5D: case 0x5D:
puts("SERFMT: Series Format"); puts ("SERFMT: Series Format");
break; break;
case 0x60: case 0x60:
puts("FBI: Font Basis"); puts ("FBI: Font Basis");
break; break;
case 0x61: case 0x61:
puts("BOPPOP: Bar of pie/pie of pie chart options"); puts ("BOPPOP: Bar of pie/pie of pie chart options");
break; break;
case 0x62: case 0x62:
puts("AXCEXT: Axis options"); puts ("AXCEXT: Axis options");
break; break;
case 0x63: case 0x63:
puts("DAT: Data Table Options"); puts ("DAT: Data Table Options");
break; break;
case 0x64: case 0x64:
puts("PLOTGROWTH: Font scale factors"); puts ("PLOTGROWTH: Font scale factors");
break; break;
case 0x65: case 0x65:
puts("SIINDEX: Series Index"); puts ("SIINDEX: Series Index");
break; break;
case 0x66: case 0x66:
puts("GELFRAME: Fill data"); puts ("GELFRAME: Fill data");
break; break;
case 0x67: case 0x67:
puts("Custom bar of pie/ pie of pie chart options"); puts ("Custom bar of pie/ pie of pie chart options");
break; break;
default: default:
puts("Unknown Chart Opcode"); puts ("Unknown Chart Opcode");
break; break;
} }
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -25,143 +25,168 @@
void OutputTableXML(void) void
OutputTableXML (void)
{ {
int i, j, k; int i, j, k;
printf( "<?xml version=\"1.0\" encoding=\"" ); printf ("<?xml version=\"1.0\" encoding=\"");
switch (UnicodeStrings) switch (UnicodeStrings)
{
case 0:
printf ("iso-8859-1\" ?>\n"); /* Latin-1 */
break;
case 1:
printf ("windows-1252\"?>\n"); /* Microsoft */
break;
default:
printf ("utf-8\"?>\n"); /* Unicode */
break;
}
SetupExtraction ();
printf ("<excel_workbook>\n");
printf ("<workbook_title>");
if (title)
printf ("%s", title);
else
printf ("%s", filename);
printf ("</workbook_title>\n");
printf ("\t<sheets>\n");
/* Here's where we dump the Html Page out */
for (i = first_sheet; i <= last_sheet; i++) /* For each worksheet */
{
trim_sheet_edges (i);
update_default_font (i);
if (ws_array[i] == 0)
continue;
if ((ws_array[i]->biggest_row == -1)
|| (ws_array[i]->biggest_col == -1))
continue;
if (ws_array[i]->c_array == 0)
continue;
printf ("\t\t<sheet>\n");
printf ("\t\t\t<page>%d</page>\n", i);
/* Print its name */
if (next_ws_title > 0)
{ {
case 0: if (ws_array[i]->ws_title.str)
printf("iso-8859-1\" ?>\n"); /* Latin-1 */ {
break; printf ("\t\t\t<pagetitle>");
case 1: OutputString (&ws_array[i]->ws_title);
printf("windows-1252\"?>\n"); /* Microsoft */ printf ("</pagetitle>\n");
break; }
default: else
printf("utf-8\"?>\n"); /* Unicode */ printf ("\t\t\t<pagetitle>(Unknown Page)</pagetitle>\n");
break;
} }
SetupExtraction(); printf ("\t\t\t<firstrow>%ld</firstrow>\n",
(unsigned long) ws_array[i]->first_row);
printf ("\t\t\t<lastrow>%d</lastrow>\n",
(int) ws_array[i]->biggest_row);
printf ("\t\t\t<firstcol>%ld</firstcol>\n",
(long) ws_array[i]->first_col);
printf ("\t\t\t<lastcol>%d</lastcol>\n",
(int) ws_array[i]->biggest_col);
printf ("\t\t\t<rows>\n");
printf( "<excel_workbook>\n" ); for (j = ws_array[i]->first_row; j <= ws_array[i]->biggest_row; j++)
printf( "\t<sheets>\n" );
/* Here's where we dump the Html Page out */
for (i=first_sheet; i<=last_sheet; i++) /* For each worksheet */
{ {
trim_sheet_edges(i); update_default_alignment (i, j);
update_default_font(i); printf ("\t\t\t\t<row>\n");
if (ws_array[i] == 0) for (k = ws_array[i]->first_col; k <= ws_array[i]->biggest_col; k++)
continue; {
if ((ws_array[i]->biggest_row == -1)||(ws_array[i]->biggest_col == -1)) printf ("\t\t\t\t\t<cell row=\"%d\" col=\"%d\"", j, k);
continue; output_cell (ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k], 1); /* This stuff happens for each cell... */
if (ws_array[i]->c_array == 0) printf ("</cell>\n");
continue; if (ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k])
printf( "\t\t<sheet>\n" );
printf( "\t\t\t<page>%d</page>\n", i );
/* Print its name */
if (next_ws_title > 0)
{ {
if (ws_array[i]->ws_title.str) if (ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k]->
{ colspan != 0)
printf("\t\t\t<pagetitle>"); k +=
OutputString(&ws_array[i]->ws_title); ws_array[i]->c_array[(j * ws_array[i]->max_cols) +
printf("</pagetitle>\n"); k]->colspan - 1;
}
else
printf("\t\t\t<pagetitle>(Unknown Page)</pagetitle>\n");
} }
printf( "\t\t\t<firstrow>%ld</firstrow>\n", (unsigned long)ws_array[i]->first_row ); }
printf( "\t\t\t<lastrow>%d</lastrow>\n", (int) ws_array[i]->biggest_row );
printf( "\t\t\t<firstcol>%ld</firstcol>\n", (long) ws_array[i]->first_col );
printf( "\t\t\t<lastcol>%d</lastcol>\n", (int)ws_array[i]->biggest_col );
printf( "\t\t\t<rows>\n" );
for (j=ws_array[i]->first_row; j<=ws_array[i]->biggest_row; j++) printf ("\t\t\t\t</row>\n");
{
update_default_alignment(i, j);
printf("\t\t\t\t<row>\n");
for (k=ws_array[i]->first_col; k<=ws_array[i]->biggest_col; k++)
{
printf("\t\t\t\t\t<cell row=\"%d\" col=\"%d\"", j, k );
output_cell(ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k], 1); /* This stuff happens for each cell... */
printf("</cell>\n" );
if (ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k])
{
if (ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]->colspan != 0)
k += ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]->colspan-1;
}
}
printf("\t\t\t\t</row>\n");
}
printf( "\t\t\t</rows>\n" );
printf("\t\t</sheet>\n");
} }
printf( "\t</sheets>\n" ); printf ("\t\t\t</rows>\n");
printf ("\t\t</sheet>\n");
}
printf ("\t</sheets>\n");
/* Print the author's name in itallics... */ /* Print the author's name in itallics... */
if (author.str) if (author.str)
{ {
printf("\t<author>"); printf ("\t<author>");
OutputString(&author); OutputString (&author);
printf("</author>\n"); printf ("</author>\n");
} }
/* Print when & how the file was last updated. */ /* Print when & how the file was last updated. */
if (lastUpdated) if (lastUpdated)
printf("\t<lastwrite>%s</lastwrite>", lastUpdated); printf ("\t<lastwrite>%s</lastwrite>", lastUpdated);
printf( "\t<excelversion>" ); printf ("\t<excelversion>");
switch (file_version) switch (file_version)
{ {
case EXCEL95: case EXCEL95:
printf("using Excel 5.0 or 95"); printf ("using Excel 5.0 or 95");
break; break;
case EXCEL97: case EXCEL97:
printf("using Excel 97/2000"); printf ("using Excel 97/2000");
break; break;
default: default:
printf("using Excel ????"); printf ("using Excel ????");
break; break;
} }
printf("</excelversion>\n"); printf ("</excelversion>\n");
/* Next print Disclaimers... */ /* Next print Disclaimers... */
if (NoFormat) if (NoFormat)
printf("\t<noformat>%d</noformat>\n", NoFormat ); printf ("\t<noformat>%d</noformat>\n", NoFormat);
if ((notAccurate)&&(formula_warnings)) if ((notAccurate) && (formula_warnings))
printf("\t<accuracy>%d</accuracy>\n", notAccurate ); printf ("\t<accuracy>%d</accuracy>\n", notAccurate);
if (NotImplemented) if (NotImplemented)
printf("\t<notimplemented>%d</notimplemented>\n", NotImplemented ); printf ("\t<notimplemented>%d</notimplemented>\n", NotImplemented);
if (Unsupported) if (Unsupported)
printf("\t<unsupported>%d</unsupported>\n", Unsupported ); printf ("\t<unsupported>%d</unsupported>\n", Unsupported);
/* Now out exceeded capacity warnings... */ /* Now out exceeded capacity warnings... */
if (MaxWorksheetsExceeded) if (MaxWorksheetsExceeded)
printf("\t<MaxWorksheetsExceeded>The Maximum Number of Worksheets were exceeded, you might want to increase it.</MaxWorksheetsExceeded>\n "); printf
if (MaxRowExceeded) ("\t<MaxWorksheetsExceeded>The Maximum Number of Worksheets were exceeded, you might want to increase it.</MaxWorksheetsExceeded>\n ");
printf("\t<MaxRowExceeded>The Maximum Number of Rows were exceeded, you might want to increase it.</MaxRowExceeded>\n "); if (MaxRowExceeded)
if (MaxColExceeded) printf
printf("\t<MaxColExceeded>The Maximum Number of Columns were exceeded, you might want to increase it.</MaxColExceeded>\n"); ("\t<MaxRowExceeded>The Maximum Number of Rows were exceeded, you might want to increase it.</MaxRowExceeded>\n ");
if (MaxStringsExceeded) if (MaxColExceeded)
printf("\t<MaxStringsExceeded>The Maximum Number of Strings were exceeded, you might want to increase it.</MaxStringsExceeded>\n"); printf
if (MaxFontsExceeded) ("\t<MaxColExceeded>The Maximum Number of Columns were exceeded, you might want to increase it.</MaxColExceeded>\n");
printf("\t<MaxFontsExceeded>The Maximum Number of Fonts were exceeded, you might want to increase it.</MaxFontsExceeded>\n"); if (MaxStringsExceeded)
if (MaxPalExceeded) printf
printf("\t<MaxPalExceeded>The Maximum Number of Color Palettes were exceeded, you might want to increase it.</MaxPalExceeded>\n"); ("\t<MaxStringsExceeded>The Maximum Number of Strings were exceeded, you might want to increase it.</MaxStringsExceeded>\n");
if (MaxXFExceeded) if (MaxFontsExceeded)
printf("\t<MaxXFExceeded>The Maximum Number of Extended Formats were exceeded, you might want to increase it.</MaxXFExceeded>\n"); printf
if (MaxFormatsExceeded) ("\t<MaxFontsExceeded>The Maximum Number of Fonts were exceeded, you might want to increase it.</MaxFontsExceeded>\n");
printf("\t<MaxFormatsExceeded>The Maximum Number of Formats were exceeded, you might want to increase it.</MaxFormatsExceeded>\n"); if (MaxPalExceeded)
printf
("\t<MaxPalExceeded>The Maximum Number of Color Palettes were exceeded, you might want to increase it.</MaxPalExceeded>\n");
if (MaxXFExceeded)
printf
("\t<MaxXFExceeded>The Maximum Number of Extended Formats were exceeded, you might want to increase it.</MaxXFExceeded>\n");
if (MaxFormatsExceeded)
printf
("\t<MaxFormatsExceeded>The Maximum Number of Formats were exceeded, you might want to increase it.</MaxFormatsExceeded>\n");
/* Output Credit */ /* Output Credit */
printf("\t<tool>Created with xlhtml %s</tool>\n", VERSION); printf ("\t<tool>Created with xlhtml %s</tool>\n", VERSION);
printf("\t<toollink>http://chicago.sf.net/xlhtml/</toollink>\n"); printf ("\t<toollink>http://chicago.sf.net/xlhtml/</toollink>\n");
printf( "</excel_workbook>\n" ); printf ("</excel_workbook>\n");
} }