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) if (ws_array[i] == 0)
continue; continue;
if ((ws_array[i]->biggest_row == -1)||(ws_array[i]->biggest_col == -1)) if ((ws_array[i]->biggest_row == -1)
|| (ws_array[i]->biggest_col == -1))
continue; continue;
if (ws_array[i]->c_array == 0) if (ws_array[i]->c_array == 0)
continue; continue;
/* Now dump the table */ /* Now dump the table */
for (j=ws_array[i]->first_row; j<=ws_array[i]->biggest_row; j++) 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++) for (k = ws_array[i]->first_col; k <= ws_array[i]->biggest_col; k++)
{ {
int safe, numeric=0; int safe, numeric = 0;
cell *c = ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]; /* This stuff happens for each cell... */ cell *c = ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k]; /* This stuff happens for each cell... */
if (c) if (c)
{ {
numeric = IsCellNumeric(c); numeric = IsCellNumeric (c);
if (!numeric && Csv) if (!numeric && Csv)
printf("\""); printf ("\"");
safe = IsCellSafe(c); safe = IsCellSafe (c);
if (c->ustr.str) if (c->ustr.str)
{ {
if (safe) if (safe)
output_formatted_data(&(c->ustr), xf_array[c->xfmt]->fmt_idx, numeric, IsCellFormula(c)); output_formatted_data (&(c->ustr),
xf_array[c->xfmt]->fmt_idx,
numeric, IsCellFormula (c));
else else
OutputString(&(c->ustr)); OutputString (&(c->ustr));
} }
else if (!Csv) else if (!Csv)
printf(" "); /* Empty cell... */ printf (" "); /* Empty cell... */
} }
else else
{ /* Empty cell... */ { /* Empty cell... */
if (!Csv) if (!Csv)
printf(" "); printf (" ");
else else
printf("\""); 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]) /* Honor Column spanning ? */
{ {
if (ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]->colspan != 0) if (ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k]->
k += ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]->colspan-1; colspan != 0)
k +=
ws_array[i]->c_array[(j * ws_array[i]->max_cols) +
k]->colspan - 1;
} }
if (!numeric && Csv) if (!numeric && Csv)
printf("\""); printf ("\"");
if (Csv && (k < ws_array[i]->biggest_col)) if (Csv && (k < ws_array[i]->biggest_col))
{ /* big cheat here: quoting everything! */ { /* big cheat here: quoting everything! */
putchar(','); /* Csv Cell Separator */ putchar (','); /* Csv Cell Separator */
} }
else else
{ {
if (( !Csv )&&( k != ws_array[i]->biggest_col )) if ((!Csv) && (k != ws_array[i]->biggest_col))
putchar('\t'); /* Ascii Cell Separator */ putchar ('\t'); /* Ascii Cell Separator */
} }
} }
if (Csv) if (Csv)
printf("\r\n"); printf ("\r\n");
else else
putchar(0x0A); /* Row Separator */ putchar (0x0A); /* Row Separator */
} }
if (!Csv) if (!Csv)
printf("\n\n"); /* End of Table 2 LF-CR */ 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>"); printf ("<CENTER>");
do_cr(); do_cr ();
} }
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 */
{ {
update_default_font(i); update_default_font (i);
if (ws_array[i] == 0) if (ws_array[i] == 0)
continue; continue;
if ((ws_array[i]->biggest_row == -1)||(ws_array[i]->biggest_col == -1)) if ((ws_array[i]->biggest_row == -1)
|| (ws_array[i]->biggest_col == -1))
continue; continue;
if (ws_array[i]->c_array == 0) if (ws_array[i]->c_array == 0)
continue; continue;
trim_sheet_edges(i); trim_sheet_edges (i);
/* Print its name */ /* Print its name */
if (next_ws_title > 0) if (next_ws_title > 0)
{ {
if (ws_array[i]->ws_title.str) if (ws_array[i]->ws_title.str)
{ {
printf("<CENTER><H1>"); printf ("<CENTER><H1>");
OutputString(&ws_array[i]->ws_title); OutputString (&ws_array[i]->ws_title);
printf("</H1></CENTER><br>"); printf ("</H1></CENTER><br>");
do_cr(); do_cr ();
} }
else else
{ {
printf("<H1><CENTER>(Unknown Page)</CENTER></H1><br>"); printf ("<H1><CENTER>(Unknown Page)</CENTER></H1><br>");
do_cr(); do_cr ();
} }
} }
/* Now dump the table */ /* Now dump the table */
printf("<FONT FACE=\""); printf ("<FONT FACE=\"");
OutputString(&default_font); OutputString (&default_font);
if (default_fontsize != 3) if (default_fontsize != 3)
printf("\" SIZE=\"%d", default_fontsize); printf ("\" SIZE=\"%d", default_fontsize);
printf("\">"); printf ("\">");
do_cr(); do_cr ();
printf("<TABLE BORDER=\"1\" CELLSPACING=\"2\">"); printf ("<TABLE BORDER=\"1\" CELLSPACING=\"2\">");
do_cr(); do_cr ();
if (TableHeaders) if (TableHeaders)
{ {
printf("<TR><TH></TH>"); printf ("<TR><TH></TH>");
for (k=ws_array[i]->first_col; k<=ws_array[i]->biggest_col; k++) for (k = ws_array[i]->first_col; k <= ws_array[i]->biggest_col; k++)
{ {
char col_hdr[3]; char col_hdr[3];
if (k < 26) if (k < 26)
{ {
col_hdr[0]='A' + (k % 26); col_hdr[0] = 'A' + (k % 26);
col_hdr[1]='\0'; col_hdr[1] = '\0';
} }
else else
{ {
col_hdr[0]='A' - 1 + (k / 26); col_hdr[0] = 'A' - 1 + (k / 26);
col_hdr[1]='A' + (k % 26); col_hdr[1] = 'A' + (k % 26);
col_hdr[2]='\0'; col_hdr[2] = '\0';
} }
printf("<TH>%s%s",col_hdr,(aggressive ? "" : "</TH>")); printf ("<TH>%s%s", col_hdr, (aggressive ? "" : "</TH>"));
} }
printf("</TR>\n"); printf ("</TR>\n");
} }
for (j=ws_array[i]->first_row; j<=ws_array[i]->biggest_row; j++) for (j = ws_array[i]->first_row; j <= ws_array[i]->biggest_row; j++)
{ {
update_default_alignment(i, j); update_default_alignment (i, j);
printf("<TR"); printf ("<TR");
if (null_string((U8 *)default_alignment)) if (null_string ((U8 *) default_alignment))
printf(">"); printf (">");
else else
{ {
if (strcmp(default_alignment, "left") != 0) if (strcmp (default_alignment, "left") != 0)
printf(" ALIGN=\"%s\"", default_alignment); printf (" ALIGN=\"%s\"", default_alignment);
if (!aggressive) if (!aggressive)
printf(" VALIGN=\"bottom\">\n"); printf (" VALIGN=\"bottom\">\n");
else else
printf(">"); printf (">");
} }
if (TableHeaders) if (TableHeaders)
printf("<TH>%d%s",j+1,(aggressive ? "" : "</TH>")); printf ("<TH>%d%s", j + 1, (aggressive ? "" : "</TH>"));
for (k=ws_array[i]->first_col; k<=ws_array[i]->biggest_col; k++) 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... */ 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])
{ {
if (ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]->colspan != 0) if (ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k]->
k += ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]->colspan-1; colspan != 0)
k +=
ws_array[i]->c_array[(j * ws_array[i]->max_cols) +
k]->colspan - 1;
} }
} }
if (!aggressive) if (!aggressive)
printf("</TR>\n"); printf ("</TR>\n");
} }
printf("</TABLE></FONT><HR>"); printf ("</TABLE></FONT><HR>");
do_cr(); do_cr ();
} }
if (center_tables) if (center_tables)
{ {
printf("</CENTER>"); printf ("</CENTER>");
do_cr(); do_cr ();
} }
/* Print the author's name in itallics... */ /* Print the author's name in itallics... */
if (author.str) if (author.str)
{ {
printf("<FONT SIZE=\"-1\"><I>Spreadsheet's Author:&nbsp;"); printf ("<FONT SIZE=\"-1\"><I>Spreadsheet's Author:&nbsp;");
OutputString(&author); OutputString (&author);
printf("</I></FONT><br>"); printf ("</I></FONT><br>");
do_cr(); do_cr ();
} }
/* Print when & how the file was last updated. */ /* Print when & how the file was last updated. */
printf("<FONT SIZE=\"-1\"><I>Last Updated "); printf ("<FONT SIZE=\"-1\"><I>Last Updated ");
if (lastUpdated) if (lastUpdated)
printf("%s&nbsp; ", lastUpdated); printf ("%s&nbsp; ", lastUpdated);
switch (file_version) switch (file_version)
{ {
case EXCEL95: case EXCEL95:
printf("with Excel 5.0 or 95"); printf ("with Excel 5.0 or 95");
break; break;
case EXCEL97: case EXCEL97:
printf("with Excel 97"); printf ("with Excel 97");
break; break;
default: default:
printf("with Excel ????"); printf ("with Excel ????");
break; break;
} }
printf("</I></FONT><br>"); printf ("</I></FONT><br>");
do_cr(); do_cr ();
/* Next print Disclaimers... */ /* Next print Disclaimers... */
if (NoFormat) if (NoFormat)
{ {
printf("<br>* This cell's format is not supported.<br>"); printf ("<br>* This cell's format is not supported.<br>");
do_cr(); do_cr ();
} }
if ((notAccurate)&&(formula_warnings)) if ((notAccurate) && (formula_warnings))
{ {
printf("<br>** This cell's data may not be accurate.<br>"); printf ("<br>** This cell's data may not be accurate.<br>");
do_cr(); do_cr ();
} }
if (NotImplemented) if (NotImplemented)
{ {
printf("<br>*** This cell's data type will be supported in the future.<br>"); printf
do_cr(); ("<br>*** This cell's data type will be supported in the future.<br>");
do_cr ();
} }
if (Unsupported) if (Unsupported)
{ {
printf("<br>**** This cell's type is unsupported.<br>"); printf ("<br>**** This cell's type is unsupported.<br>");
do_cr(); do_cr ();
} }
/* Now out exceeded capacity warnings... */ /* Now out exceeded capacity warnings... */
if (MaxWorksheetsExceeded || MaxRowExceeded || MaxColExceeded || MaxStringsExceeded || if (MaxWorksheetsExceeded || MaxRowExceeded || MaxColExceeded
MaxFontsExceeded || MaxPalExceeded || MaxXFExceeded || MaxFormatsExceeded ) || MaxStringsExceeded || MaxFontsExceeded || MaxPalExceeded
printf("<FONT COLOR=\"%s\">", colorTab[0x0A]); || MaxXFExceeded || MaxFormatsExceeded)
printf ("<FONT COLOR=\"%s\">", colorTab[0x0A]);
if (MaxWorksheetsExceeded) if (MaxWorksheetsExceeded)
{ {
printf("The Maximum Number of Worksheets was exceeded, you might want to increase it.<br>"); printf
do_cr(); ("The Maximum Number of Worksheets was exceeded, you might want to increase it.<br>");
do_cr ();
} }
if (MaxRowExceeded) if (MaxRowExceeded)
{ {
printf("The Maximum Number of Rows was exceeded, you might want to increase it.<br>"); printf
do_cr(); ("The Maximum Number of Rows was exceeded, you might want to increase it.<br>");
do_cr ();
} }
if (MaxColExceeded) if (MaxColExceeded)
{ {
printf("The Maximum Number of Columns was exceeded, you might want to increase it.<br>"); printf
do_cr(); ("The Maximum Number of Columns was exceeded, you might want to increase it.<br>");
do_cr ();
} }
if (MaxStringsExceeded) if (MaxStringsExceeded)
{ {
printf("The Maximum Number of Strings was exceeded, you might want to increase it.<br>"); printf
do_cr(); ("The Maximum Number of Strings was exceeded, you might want to increase it.<br>");
do_cr ();
} }
if (MaxFontsExceeded) if (MaxFontsExceeded)
{ {
printf("The Maximum Number of Fonts was exceeded, you might want to increase it.<br>"); printf
do_cr(); ("The Maximum Number of Fonts was exceeded, you might want to increase it.<br>");
do_cr ();
} }
if (MaxPalExceeded) if (MaxPalExceeded)
{ {
printf("The Maximum Number of Color Palettes was exceeded, you might want to increase it.<br>"); printf
do_cr(); ("The Maximum Number of Color Palettes was exceeded, you might want to increase it.<br>");
do_cr ();
} }
if (MaxXFExceeded) if (MaxXFExceeded)
{ {
printf("The Maximum Number of Extended Formats was exceeded, you might want to increase it.<br>"); printf
do_cr(); ("The Maximum Number of Extended Formats was exceeded, you might want to increase it.<br>");
do_cr ();
} }
if (MaxFormatsExceeded) if (MaxFormatsExceeded)
{ {
printf("The Maximum Number of Formats was exceeded, you might want to increase it.<br>"); printf
do_cr(); ("The Maximum Number of Formats was exceeded, you might want to increase it.<br>");
do_cr ();
} }
if (MaxWorksheetsExceeded || MaxRowExceeded || MaxColExceeded || MaxStringsExceeded || if (MaxWorksheetsExceeded || MaxRowExceeded || MaxColExceeded
MaxFontsExceeded || MaxPalExceeded || MaxXFExceeded || MaxFormatsExceeded ) || MaxStringsExceeded || MaxFontsExceeded || MaxPalExceeded
printf("</FONT>"); || MaxXFExceeded || MaxFormatsExceeded)
printf ("</FONT>");
printf("&nbsp;<br>"); printf ("&nbsp;<br>");
do_cr(); do_cr ();
/* Output Credit */ /* Output Credit */
printf("<hr><FONT SIZE=\"-1\">Created with <a href=\"http://chicago.sf.net/xlhtml\">xlhtml %s</a></FONT><br>", VERSION); printf
do_cr(); ("<hr><FONT SIZE=\"-1\">Created with <a href=\"http://chicago.sf.net/xlhtml\">xlhtml %s</a></FONT><br>",
VERSION);
do_cr ();
/* Output Tail */ /* Output Tail */
output_footer(); output_footer ();
} }
void output_header(void) void
output_header (void)
{ /* Ouput Header */ { /* Ouput Header */
if (NoHeaders) if (NoHeaders)
return; return;
if (!aggressive) if (!aggressive)
{ {
printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML Transitional//EN\""); printf ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML Transitional//EN\"");
do_cr(); do_cr ();
printf("\"http://www.w3.org/TR/REC-html40/loose.dtd\">"); printf ("\"http://www.w3.org/TR/REC-html40/loose.dtd\">");
do_cr(); do_cr ();
} }
printf("<HTML>\n"); printf ("<HTML>\n");
printf("<HEAD>\n"); printf ("<HEAD>\n");
do_cr(); do_cr ();
printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="); printf ("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=");
if ((UnicodeStrings <= 1)&&CodePage&&(CodePage != 1252)) if ((UnicodeStrings <= 1) && CodePage && (CodePage != 1252))
printf("windows-%d\">", CodePage); printf ("windows-%d\">", CodePage);
else else
{ {
switch (UnicodeStrings) switch (UnicodeStrings)
{ {
case 0: case 0:
printf("iso-8859-1\">"); /* Latin-1 */ printf ("iso-8859-1\">"); /* Latin-1 */
break; break;
case 1: case 1:
printf("windows-1252\">"); /* Microsoft */ printf ("windows-1252\">"); /* Microsoft */
break; break;
default: default:
printf("utf-8\">"); /* Unicode */ printf ("utf-8\">"); /* Unicode */
break; break;
} }
} }
do_cr(); 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>"); printf ("<U>");
h->uflag = 1; h->uflag = 1;
} }
if (font_array[fnt_idx]->bold >= 0x02BC) if (font_array[fnt_idx]->bold >= 0x02BC)
{ {
h->bflag = 1; h->bflag = 1;
printf("<B>"); printf ("<B>");
} }
if (font_array[fnt_idx]->attr & 0x0002) if (font_array[fnt_idx]->attr & 0x0002)
{ {
h->iflag = 1; h->iflag = 1;
printf("<I>"); printf ("<I>");
} }
if (font_array[fnt_idx]->attr & 0x0008) if (font_array[fnt_idx]->attr & 0x0008)
{ {
h->sflag = 1; h->sflag = 1;
printf("<S>"); printf ("<S>");
} }
if ((font_array[fnt_idx]->super & 0x0003) == 0x0001) if ((font_array[fnt_idx]->super & 0x0003) == 0x0001)
{ {
h->spflag = 1; h->spflag = 1;
printf("<SUP>"); printf ("<SUP>");
} }
else if ((font_array[fnt_idx]->super & 0x0003) == 0x0002) else if ((font_array[fnt_idx]->super & 0x0003) == 0x0002)
{ {
h->sbflag = 1; h->sbflag = 1;
printf("<SUB>"); 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

@ -30,18 +30,20 @@
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"
@ -60,81 +62,89 @@ fprintf(stderr, "\nxlhtml converts excel files (.xls) to Html.\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
null_string (U8 * str)
{ /* FIXME: This function may not be unicode safe */ { /* FIXME: This function may not be unicode safe */
U8 *ptr; U8 *ptr;
if ((str == NULL)||(*str == 0)) if ((str == NULL) || (*str == 0))
return 1; return 1;
ptr = str; ptr = str;
@ -146,27 +156,28 @@ int null_string(U8 *str)
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)
@ -178,24 +189,25 @@ void FracToTime(U8 *cnum, int *hr, int *minut, int *sec, int *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]) if (t <= ldays[i])
break; break;
@ -204,7 +216,7 @@ void NumToDate(long num, int *year, int *month, int *day)
} }
else else
{ {
for (i=0; i<12; i++) for (i = 0; i < 12; i++)
{ {
if (t <= ndays[i]) if (t <= ndays[i])
break; break;
@ -212,7 +224,7 @@ void NumToDate(long num, int *year, int *month, int *day)
} }
} }
/* Some fixups... */ /* Some fixups... */
*month = 1+i; *month = 1 + i;
if (t == 0) if (t == 0)
t = 1; t = 1;
*day = t; *day = t;
@ -227,27 +239,31 @@ typedef S32 swords[2];
#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

@ -40,7 +40,7 @@ static char FileName[2][12] = /* The section of the Excel Spreadsheet we read
/* 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,21 +48,22 @@ 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" fprintf (stderr, "dump - Outputs excel chart records for analysis.\n"
"Usage: "PRGNAME" <FILE>\n"); "Usage: " PRGNAME " <FILE>\n");
exit (1); exit (1);
} }
else else
{ {
strncpy(filename, argv[1], 124); strncpy (filename, argv[1], 124);
cfs = cole_mount (filename, &colerrno); cfs = cole_mount (filename, &colerrno);
if (cfs == NULL) if (cfs == NULL)
{ {
@ -71,7 +72,8 @@ int main (int argc, char **argv)
} }
} }
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)
{ {
@ -92,27 +94,27 @@ int main (int argc, char **argv)
} }
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 */ /* Ouput Header */
printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n"); printf ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n");
printf("<HTML><HEAD><TITLE>%s", filename); printf ("<HTML><HEAD><TITLE>%s", filename);
printf("</TITLE></HEAD><BODY>\n"); 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)
@ -120,251 +122,257 @@ void dump_file(COLEDIRENT *cde, void *_info)
if (count == 0) if (count == 0)
{ {
length = 0; length = 0;
opcode = (unsigned)buf[0]; opcode = (unsigned) buf[0];
target = 80; /* ficticious number */ target = 80; /* ficticious number */
printf("<br>"); printf ("<br>");
} }
else if (count == 1) else if (count == 1)
opcode |= (buf[0]<<8)&0x0000FFFFL; opcode |= (buf[0] << 8) & 0x0000FFFFL;
else if (count == 2) else if (count == 2)
length = (unsigned)buf[0]; length = (unsigned) buf[0];
else if (count == 3) else if (count == 3)
{ {
length |= (buf[0]<<8); length |= (buf[0] << 8);
target = length; target = length;
printf("<br>\nLength:%04X Opcode:%04X - ", length, opcode); printf ("<br>\nLength:%04X Opcode:%04X - ", length, opcode);
output_opcode_string(opcode); output_opcode_string (opcode);
puts("<br>\n"); puts ("<br>\n");
} }
if (count > 3) if (count > 3)
{ /* Here is where we want to process the data */ { /* Here is where we want to process the data */
/* based on the opcode... */ /* 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 */ else /* mode >= 1 */
{ {
printf("%02x %02x %02x %02x %02x %02x %02x %02x &nbsp; &nbsp; &nbsp; &nbsp; ", printf
(unsigned)buf[0], (unsigned)buf[1], (unsigned)buf[2], (unsigned)buf[3], ("%02x %02x %02x %02x %02x %02x %02x %02x &nbsp; &nbsp; &nbsp; &nbsp; ",
(unsigned)buf[4], (unsigned)buf[5], (unsigned)buf[6], (unsigned)buf[7]); (unsigned) buf[0], (unsigned) buf[1], (unsigned) buf[2],
putchar(buf[0]); putchar(buf[1]); (unsigned) buf[3], (unsigned) buf[4], (unsigned) buf[5],
putchar(buf[2]); putchar(buf[3]); (unsigned) buf[6], (unsigned) buf[7]);
putchar(buf[4]); putchar(buf[5]); putchar (buf[0]);
putchar(buf[6]); putchar(buf[7]); putchar (buf[1]);
printf("<br>\n"); 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;
} }
} }

View File

@ -41,7 +41,7 @@ static char FileName[2][12] = /* The section of the Excel Spreadsheet we read
/* Function Prototypes */ /* Function Prototypes */
COLE_LOCATE_ACTION_FUNC dump_file; COLE_LOCATE_ACTION_FUNC dump_file;
/*static void main_line_processor(int opcode, char data);*/ /*static void main_line_processor(int opcode, char data);*/
static void output_opcode_string(int); static void output_opcode_string (int);
/* Global data */ /* Global data */
static char filename[128]; static char filename[128];
@ -49,21 +49,22 @@ 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 file records for analysis.\n" fprintf (stderr, "dump - Outputs excel file records for analysis.\n"
"Usage: "PRGNAME" <FILE>\n"); "Usage: " PRGNAME " <FILE>\n");
exit (1); exit (1);
} }
else else
{ {
strncpy(filename, argv[1], 124); strncpy (filename, argv[1], 124);
cfs = cole_mount (filename, &colerrno); cfs = cole_mount (filename, &colerrno);
if (cfs == NULL) if (cfs == NULL)
{ {
@ -72,7 +73,8 @@ int main (int argc, char **argv)
} }
} }
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)
{ {
@ -93,27 +95,27 @@ int main (int argc, char **argv)
} }
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 */ /* Ouput Header */
printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n"); printf ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n");
printf("<HTML><HEAD><TITLE>%s", filename); printf ("<HTML><HEAD><TITLE>%s", filename);
printf("</TITLE></HEAD><BODY>\n"); 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)
@ -121,55 +123,61 @@ void dump_file(COLEDIRENT *cde, void *_info)
if (count == 0) if (count == 0)
{ {
length = 0; length = 0;
opcode = (unsigned)buf[0]; opcode = (unsigned) buf[0];
target = 80; /* ficticious number */ target = 80; /* ficticious number */
printf("<br>"); printf ("<br>");
} }
else if (count == 1) else if (count == 1)
opcode |= (buf[0]<<8)&0x0000FFFFL; opcode |= (buf[0] << 8) & 0x0000FFFFL;
else if (count == 2) else if (count == 2)
length = (unsigned)buf[0]; length = (unsigned) buf[0];
else if (count == 3) else if (count == 3)
{ {
length |= (buf[0]<<8); length |= (buf[0] << 8);
target = length; target = length;
printf("<br>\nLength:%04X Opcode:%04X - ", length, opcode); printf ("<br>\nLength:%04X Opcode:%04X - ", length, opcode);
output_opcode_string(opcode); output_opcode_string (opcode);
puts("<br>\n"); puts ("<br>\n");
} }
if (count > 3) if (count > 3)
{ /* Here is where we want to process the data */ { /* Here is where we want to process the data */
/* based on the opcode... */ /* 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 */ else /* mode >= 1 */
{ {
printf("%02x %02x %02x %02x %02x %02x %02x %02x &nbsp; &nbsp; &nbsp; &nbsp; ", printf
(unsigned)buf[0], (unsigned)buf[1], (unsigned)buf[2], (unsigned)buf[3], ("%02x %02x %02x %02x %02x %02x %02x %02x &nbsp; &nbsp; &nbsp; &nbsp; ",
(unsigned)buf[4], (unsigned)buf[5], (unsigned)buf[6], (unsigned)buf[7]); (unsigned) buf[0], (unsigned) buf[1], (unsigned) buf[2],
putchar(buf[0]); putchar(buf[1]); (unsigned) buf[3], (unsigned) buf[4], (unsigned) buf[5],
putchar(buf[2]); putchar(buf[3]); (unsigned) buf[6], (unsigned) buf[7]);
putchar(buf[4]); putchar(buf[5]); putchar (buf[0]);
putchar(buf[6]); putchar(buf[7]); putchar (buf[1]);
printf("<br>\n"); 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 main_line_processor(int opcode, char data) /*static void main_line_processor(int opcode, char data)
@ -177,330 +185,331 @@ void dump_file(COLEDIRENT *cde, void *_info)
} }
*/ */
static void output_opcode_string(int opcode) static void
output_opcode_string (int opcode)
{ {
switch (opcode&0x00FF) switch (opcode & 0x00FF)
{ {
/* start of documented general opcodes */ /* start of documented general opcodes */
case 0x0A: case 0x0A:
puts("\nEOF: End of File"); puts ("\nEOF: End of File");
break; break;
case 0x0C: case 0x0C:
puts("CALCCOUNT: Iteration count"); puts ("CALCCOUNT: Iteration count");
break; break;
case 0x0D: case 0x0D:
puts("CalcMode: Calculation mode"); puts ("CalcMode: Calculation mode");
break; break;
case 0x0E: case 0x0E:
puts("Precision"); puts ("Precision");
break; break;
case 0x0F: case 0x0F:
puts("Reference Mode"); puts ("Reference Mode");
break; break;
case 0x10: case 0x10:
puts("Delta: Iteration Increment"); puts ("Delta: Iteration Increment");
break; break;
case 0x11: case 0x11:
puts("Iteration Mode"); puts ("Iteration Mode");
break; break;
case 0x12: case 0x12:
puts("Protection Flag"); puts ("Protection Flag");
break; break;
case 0x13: case 0x13:
puts("Protection Password"); puts ("Protection Password");
break; break;
case 0x14: case 0x14:
puts("Print Header on each page"); puts ("Print Header on each page");
break; break;
case 0x15: case 0x15:
puts("Print Footer on each page"); puts ("Print Footer on each page");
break; break;
case 0x16: case 0x16:
puts("External Count: Number of external references"); puts ("External Count: Number of external references");
break; break;
case 0x17: case 0x17:
puts("External reference"); puts ("External reference");
break; break;
case 0x18: case 0x18:
puts("NAME"); puts ("NAME");
break; break;
case 0x19: case 0x19:
puts("Windows are Protected"); puts ("Windows are Protected");
break; break;
case 0x1A: case 0x1A:
puts("Vertical Page Breaks"); puts ("Vertical Page Breaks");
break; break;
case 0x1B: case 0x1B:
puts("Horizontal Page Breaks"); puts ("Horizontal Page Breaks");
break; break;
case 0x1C: case 0x1C:
puts("Cell Note"); puts ("Cell Note");
break; break;
case 0x1D: case 0x1D:
puts("Selection"); puts ("Selection");
break; break;
case 0x22: case 0x22:
puts("1904 date system"); puts ("1904 date system");
break; break;
case 0x26: case 0x26:
puts("Left Margin Measurement"); puts ("Left Margin Measurement");
break; break;
case 0x27: case 0x27:
puts("Right Margin Measurement"); puts ("Right Margin Measurement");
break; break;
case 0x28: case 0x28:
puts("Top Margin Measurement"); puts ("Top Margin Measurement");
break; break;
case 0x29: case 0x29:
puts("Bottom Margin Measurement"); puts ("Bottom Margin Measurement");
break; break;
case 0x2A: case 0x2A:
puts("Print Row/Column Labels"); puts ("Print Row/Column Labels");
break; break;
case 0x2B: case 0x2B:
puts("Print Gridlines Flag"); puts ("Print Gridlines Flag");
break; break;
case 0x2F: case 0x2F:
puts("File is Password protected"); puts ("File is Password protected");
break; break;
case 0x31: case 0x31:
puts("FONT"); puts ("FONT");
break; break;
case 0x3C: case 0x3C:
puts("Continues long records"); puts ("Continues long records");
break; break;
case 0x3D: case 0x3D:
puts("Window1"); puts ("Window1");
break; break;
case 0x40: case 0x40:
puts("BACKUP: Save Backup Version of the File"); puts ("BACKUP: Save Backup Version of the File");
break; break;
case 0x41: case 0x41:
puts("Number of Panes and their position"); puts ("Number of Panes and their position");
break; break;
case 0x42: case 0x42:
puts("CODEPAGE: Default code page"); puts ("CODEPAGE: Default code page");
break; break;
case 0x4D: case 0x4D:
puts("PLS: Environment specific print record"); puts ("PLS: Environment specific print record");
break; break;
case 0x50: case 0x50:
puts("DCON: Data consolidation information"); puts ("DCON: Data consolidation information");
break; break;
case 0x51: case 0x51:
puts("DCONREF: Data consolidation references"); puts ("DCONREF: Data consolidation references");
break; break;
case 0x52: case 0x52:
puts("DCONNAME: Data Consolidation Named References"); puts ("DCONNAME: Data Consolidation Named References");
break; break;
case 0x55: case 0x55:
puts("DEFCOLWIDTH: Default Column Width"); puts ("DEFCOLWIDTH: Default Column Width");
break; break;
case 0x59: case 0x59:
puts("XCT: CRN Record Count"); puts ("XCT: CRN Record Count");
break; break;
case 0x5A: case 0x5A:
puts("CRN: Nonresident operands"); puts ("CRN: Nonresident operands");
break; break;
case 0x5B: case 0x5B:
puts("FILESHARING:File-sharing information"); puts ("FILESHARING:File-sharing information");
break; break;
case 0x5C: case 0x5C:
puts("Write Access"); puts ("Write Access");
break; break;
case 0x5D: case 0x5D:
puts("OBJ: Describes a Graphic object"); puts ("OBJ: Describes a Graphic object");
break; break;
case 0x5E: case 0x5E:
puts("UNCALCED: Recalculation Status"); puts ("UNCALCED: Recalculation Status");
break; break;
case 0x5F: case 0x5F:
puts("SAVERECALC: Recalculate before save"); puts ("SAVERECALC: Recalculate before save");
break; break;
case 0x60: case 0x60:
puts("TEMPLATE: Workbook is a template"); puts ("TEMPLATE: Workbook is a template");
break; break;
case 0x63: case 0x63:
puts("OBJPROTECT: Objects are protected"); puts ("OBJPROTECT: Objects are protected");
break; break;
case 0x7D: case 0x7D:
puts("COLINFO: Column formatting information"); puts ("COLINFO: Column formatting information");
break; break;
case 0x7E: case 0x7E:
puts("RK Number"); puts ("RK Number");
break; break;
case 0x7F: case 0x7F:
puts("IMDATA: Image data"); puts ("IMDATA: Image data");
break; break;
case 0x80: case 0x80:
puts("GUTS: Size of row and column gutters"); puts ("GUTS: Size of row and column gutters");
break; break;
case 0x81: case 0x81:
puts("WSBOOL: Additional workspace information"); puts ("WSBOOL: Additional workspace information");
break; break;
case 0x82: case 0x82:
puts("GRIDSET: State change of gridlines option"); puts ("GRIDSET: State change of gridlines option");
break; break;
case 0x83: case 0x83:
puts("HCENTER: Center between horizontal margins"); puts ("HCENTER: Center between horizontal margins");
break; break;
case 0x84: case 0x84:
puts("VCENTER: Center between vertical margins"); puts ("VCENTER: Center between vertical margins");
break; break;
case 0x85: case 0x85:
puts("BoundSheet"); puts ("BoundSheet");
break; break;
case 0x86: case 0x86:
puts("WRITEPROT: Workbook is Write-protected"); puts ("WRITEPROT: Workbook is Write-protected");
break; break;
case 0x87: case 0x87:
puts("ADDIN: Workbook is add-in macro"); puts ("ADDIN: Workbook is add-in macro");
break; break;
case 0x88: case 0x88:
puts("EDG: Edition globals"); puts ("EDG: Edition globals");
break; break;
case 0x89: case 0x89:
puts("PUB: Publisher"); puts ("PUB: Publisher");
break; break;
case 0x8C: case 0x8C:
puts("COUNTRY: Default country and WIN.INI Country"); puts ("COUNTRY: Default country and WIN.INI Country");
break; break;
case 0x8D: case 0x8D:
puts("HIDEOBJ: Object display options"); puts ("HIDEOBJ: Object display options");
break; break;
case 0x90: case 0x90:
puts("SORT: Sorting options"); puts ("SORT: Sorting options");
break; break;
case 0x91: case 0x91:
puts("SUB: Subscriber"); puts ("SUB: Subscriber");
break; break;
case 0x92: case 0x92:
puts("Palette Info"); puts ("Palette Info");
break; break;
case 0x94: case 0x94:
puts("LHRECORD: .WK? File Conversion Information"); puts ("LHRECORD: .WK? File Conversion Information");
break; break;
case 0x95: case 0x95:
puts("LHNGRAPH: Named Graph Information"); puts ("LHNGRAPH: Named Graph Information");
break; break;
case 0x96: case 0x96:
puts("SOUND: Sound note"); puts ("SOUND: Sound note");
break; break;
case 0x98: case 0x98:
puts("LPR: Sheet was printed using LINE.PRINT()"); puts ("LPR: Sheet was printed using LINE.PRINT()");
break; break;
case 0x99: case 0x99:
puts("STANDARDWIDTH: Standard column width"); puts ("STANDARDWIDTH: Standard column width");
break; break;
case 0x9A: case 0x9A:
puts("FNGROUPNAME: Function Group name"); puts ("FNGROUPNAME: Function Group name");
break; break;
case 0x9B: case 0x9B:
puts("FILTERMODE: Sheet contains filtered list"); puts ("FILTERMODE: Sheet contains filtered list");
break; break;
case 0x9C: case 0x9C:
puts("FNGROUPCOUNT: Built-in function group count"); puts ("FNGROUPCOUNT: Built-in function group count");
break; break;
case 0x9D: case 0x9D:
puts("AUTOFILTERINFO: Drop Down Arrow Count"); puts ("AUTOFILTERINFO: Drop Down Arrow Count");
break; break;
case 0x9E: case 0x9E:
puts("AUTOFILTER: AutoFilter data"); puts ("AUTOFILTER: AutoFilter data");
break; break;
case 0xA0: case 0xA0:
puts("SCL: Window Zoom magnification"); puts ("SCL: Window Zoom magnification");
break; break;
case 0xA1: case 0xA1:
puts("Page Setup"); puts ("Page Setup");
break; break;
case 0xA9: case 0xA9:
puts("COORDLIST: Polygon Object Vertex coordinates"); puts ("COORDLIST: Polygon Object Vertex coordinates");
break; break;
case 0xAB: case 0xAB:
puts("GCW: Global Column-Wdith flags"); puts ("GCW: Global Column-Wdith flags");
break; break;
case 0xAE: case 0xAE:
puts("SCENMAN: Scenario Output data"); puts ("SCENMAN: Scenario Output data");
break; break;
case 0xAF: case 0xAF:
puts("PROT4REV: Shared Workbook protection flag"); puts ("PROT4REV: Shared Workbook protection flag");
break; break;
case 0xB0: case 0xB0:
puts("SXVIEW: View Definition"); puts ("SXVIEW: View Definition");
break; break;
case 0xB1: case 0xB1:
puts("SXVD: View Fields"); puts ("SXVD: View Fields");
break; break;
case 0xB2: case 0xB2:
puts("SXVI: View Item"); puts ("SXVI: View Item");
break; break;
case 0xB4: case 0xB4:
puts("SXIVD: Row/Column Field Ids"); puts ("SXIVD: Row/Column Field Ids");
break; break;
case 0xB5: case 0xB5:
puts("SXLI: Line item array"); puts ("SXLI: Line item array");
break; break;
case 0xB6: case 0xB6:
puts("SXPI: Page item"); puts ("SXPI: Page item");
break; break;
case 0xB8: case 0xB8:
puts("DOCROUTE: Routing slip information"); puts ("DOCROUTE: Routing slip information");
break; break;
case 0xB9: case 0xB9:
puts("RECIPNAME: Recipient name"); puts ("RECIPNAME: Recipient name");
break; break;
case 0xBC: case 0xBC:
puts("SHRFMLA: Shared formula"); puts ("SHRFMLA: Shared formula");
break; break;
case 0xBD: case 0xBD:
puts("MULRK: Multiple RK cells"); puts ("MULRK: Multiple RK cells");
break; break;
case 0xBE: case 0xBE:
puts("Multiple Blanks"); puts ("Multiple Blanks");
break; break;
case 0xC1: case 0xC1:
puts("MMS: ADDMENU/DELMENU Record Group count"); puts ("MMS: ADDMENU/DELMENU Record Group count");
break; break;
case 0xC2: case 0xC2:
puts("ADDMENU: Menu Addition"); puts ("ADDMENU: Menu Addition");
break; break;
case 0xC3: case 0xC3:
puts("DELMENU: Menu Deletion"); puts ("DELMENU: Menu Deletion");
break; break;
case 0xC5: case 0xC5:
puts("SXDI: Data Item"); puts ("SXDI: Data Item");
break; break;
case 0xC6: case 0xC6:
puts("SXDB: PivtoTable Cache Data"); puts ("SXDB: PivtoTable Cache Data");
break; break;
case 0xCD: case 0xCD:
puts("SXSTRING: String"); puts ("SXSTRING: String");
break; break;
case 0xD0: case 0xD0:
puts("SXTBL: Multiple Consolidation Source Info"); puts ("SXTBL: Multiple Consolidation Source Info");
break; break;
case 0xD1: case 0xD1:
puts("SXTBRGIITM: Page Item Name Count"); puts ("SXTBRGIITM: Page Item Name Count");
break; break;
case 0xD2: case 0xD2:
puts("SXTBPG: Page Item Indexes"); puts ("SXTBPG: Page Item Indexes");
break; break;
case 0xD3: case 0xD3:
puts("OBPROJ: Visual Basic Project"); puts ("OBPROJ: Visual Basic Project");
break; break;
case 0xD5: case 0xD5:
puts("SXIDSTM: Stream ID"); puts ("SXIDSTM: Stream ID");
break; break;
case 0xD6: case 0xD6:
puts("RString"); puts ("RString");
break; break;
case 0xD7: case 0xD7:
puts("DBCELL: Stream offsets"); puts ("DBCELL: Stream offsets");
break; break;
case 0xDA: case 0xDA:
puts("BOOKBOOL: Workbook option flag"); puts ("BOOKBOOL: Workbook option flag");
break; break;
/* error in ms docs /* error in ms docs
@ -513,76 +522,75 @@ static void output_opcode_string(int opcode)
*/ */
case 0xDD: case 0xDD:
puts("SCENPROTECT: Scenario protection"); puts ("SCENPROTECT: Scenario protection");
break; break;
case 0xDE: case 0xDE:
puts("OLESIZE: Size of an OLE object"); puts ("OLESIZE: Size of an OLE object");
break; break;
case 0xDF: case 0xDF:
puts("UDDESC: Description string for chart autoformat"); puts ("UDDESC: Description string for chart autoformat");
break; break;
case 0xE0: case 0xE0:
puts("Extended Format"); puts ("Extended Format");
break; break;
case 0xE1: case 0xE1:
puts("INTERFACEHDR: Beginning of User Interface Records"); puts ("INTERFACEHDR: Beginning of User Interface Records");
break; break;
case 0xE2: case 0xE2:
puts("INTERFACEEND: End of User interface records"); puts ("INTERFACEEND: End of User interface records");
break; break;
case 0xE3: case 0xE3:
puts("SXVS: View source"); puts ("SXVS: View source");
break; break;
case 0xEA: case 0xEA:
puts("TABIDCONF: Sheet tab ID of Conflict history"); puts ("TABIDCONF: Sheet tab ID of Conflict history");
break; break;
case 0xEB: case 0xEB:
puts("MSODRAWINGGROUP: MS Office Drawing Group"); puts ("MSODRAWINGGROUP: MS Office Drawing Group");
break; break;
case 0xEC: case 0xEC:
puts("MSODRAWING: MS Office Drawing"); puts ("MSODRAWING: MS Office Drawing");
break; break;
case 0xED: case 0xED:
puts("MS Office Drawing Selection"); puts ("MS Office Drawing Selection");
break; break;
case 0xF0: case 0xF0:
puts("SXRULE: PivotTable Rule data"); puts ("SXRULE: PivotTable Rule data");
break; break;
case 0xF1: case 0xF1:
puts("SXEX: PivotTable Extended information"); puts ("SXEX: PivotTable Extended information");
break; break;
case 0xF2: case 0xF2:
puts("SXFILT: PivotTable Rule Filter"); puts ("SXFILT: PivotTable Rule Filter");
break; break;
case 0xF6: case 0xF6:
puts("SXNAME: PivotTable Name"); puts ("SXNAME: PivotTable Name");
break; break;
case 0xF7: case 0xF7:
puts("SXSELECT: PivotTable Selection Information"); puts ("SXSELECT: PivotTable Selection Information");
break; break;
case 0xF8: case 0xF8:
puts("PivotTable Name Pair"); puts ("PivotTable Name Pair");
break; break;
case 0xF9: case 0xF9:
puts("PivotTable Parsed Expression"); puts ("PivotTable Parsed Expression");
break; break;
case 0xFB: case 0xFB:
puts("PivotTable Format Record"); puts ("PivotTable Format Record");
break; break;
case 0xFC: case 0xFC:
puts("Shared String Table"); puts ("Shared String Table");
break; break;
case 0xFD: case 0xFD:
puts("Cell Value, String Constant/SST"); puts ("Cell Value, String Constant/SST");
break; break;
case 0xFF: case 0xFF:
puts("Extended Shared String Table"); puts ("Extended Shared String Table");
break; break;
default: default:
puts("Unknown Opcode"); puts ("Unknown Opcode");
break; break;
} }
} }

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: case 0:
printf("iso-8859-1\" ?>\n"); /* Latin-1 */ printf ("iso-8859-1\" ?>\n"); /* Latin-1 */
break; break;
case 1: case 1:
printf("windows-1252\"?>\n"); /* Microsoft */ printf ("windows-1252\"?>\n"); /* Microsoft */
break; break;
default: default:
printf("utf-8\"?>\n"); /* Unicode */ printf ("utf-8\"?>\n"); /* Unicode */
break; break;
} }
SetupExtraction(); SetupExtraction ();
printf( "<excel_workbook>\n" ); printf ("<excel_workbook>\n");
printf( "\t<sheets>\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 */ /* 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 */
{ {
trim_sheet_edges(i); trim_sheet_edges (i);
update_default_font(i); update_default_font (i);
if (ws_array[i] == 0) if (ws_array[i] == 0)
continue; continue;
if ((ws_array[i]->biggest_row == -1)||(ws_array[i]->biggest_col == -1)) if ((ws_array[i]->biggest_row == -1)
|| (ws_array[i]->biggest_col == -1))
continue; continue;
if (ws_array[i]->c_array == 0) if (ws_array[i]->c_array == 0)
continue; continue;
printf( "\t\t<sheet>\n" ); printf ("\t\t<sheet>\n");
printf( "\t\t\t<page>%d</page>\n", i ); printf ("\t\t\t<page>%d</page>\n", i);
/* Print its name */ /* Print its name */
if (next_ws_title > 0) if (next_ws_title > 0)
{ {
if (ws_array[i]->ws_title.str) if (ws_array[i]->ws_title.str)
{ {
printf("\t\t\t<pagetitle>"); printf ("\t\t\t<pagetitle>");
OutputString(&ws_array[i]->ws_title); OutputString (&ws_array[i]->ws_title);
printf("</pagetitle>\n"); printf ("</pagetitle>\n");
} }
else else
printf("\t\t\t<pagetitle>(Unknown Page)</pagetitle>\n"); 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<firstrow>%ld</firstrow>\n",
printf( "\t\t\t<lastrow>%d</lastrow>\n", (int) ws_array[i]->biggest_row ); (unsigned long) ws_array[i]->first_row);
printf( "\t\t\t<firstcol>%ld</firstcol>\n", (long) ws_array[i]->first_col ); printf ("\t\t\t<lastrow>%d</lastrow>\n",
printf( "\t\t\t<lastcol>%d</lastcol>\n", (int)ws_array[i]->biggest_col ); (int) ws_array[i]->biggest_row);
printf( "\t\t\t<rows>\n" ); 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++) for (j = ws_array[i]->first_row; j <= ws_array[i]->biggest_row; j++)
{ {
update_default_alignment(i, j); update_default_alignment (i, j);
printf("\t\t\t\t<row>\n"); printf ("\t\t\t\t<row>\n");
for (k=ws_array[i]->first_col; k<=ws_array[i]->biggest_col; k++) 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 ); 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... */ output_cell (ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k], 1); /* This stuff happens for each cell... */
printf("</cell>\n" ); 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])
{ {
if (ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]->colspan != 0) if (ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k]->
k += ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]->colspan-1; 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\t</row>\n");
} }
printf( "\t\t\t</rows>\n" ); printf ("\t\t\t</rows>\n");
printf("\t\t</sheet>\n"); printf ("\t\t</sheet>\n");
} }
printf( "\t</sheets>\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
("\t<MaxWorksheetsExceeded>The Maximum Number of Worksheets were exceeded, you might want to increase it.</MaxWorksheetsExceeded>\n ");
if (MaxRowExceeded) if (MaxRowExceeded)
printf("\t<MaxRowExceeded>The Maximum Number of Rows were exceeded, you might want to increase it.</MaxRowExceeded>\n "); printf
("\t<MaxRowExceeded>The Maximum Number of Rows were exceeded, you might want to increase it.</MaxRowExceeded>\n ");
if (MaxColExceeded) if (MaxColExceeded)
printf("\t<MaxColExceeded>The Maximum Number of Columns were exceeded, you might want to increase it.</MaxColExceeded>\n"); printf
("\t<MaxColExceeded>The Maximum Number of Columns were exceeded, you might want to increase it.</MaxColExceeded>\n");
if (MaxStringsExceeded) if (MaxStringsExceeded)
printf("\t<MaxStringsExceeded>The Maximum Number of Strings were exceeded, you might want to increase it.</MaxStringsExceeded>\n"); printf
("\t<MaxStringsExceeded>The Maximum Number of Strings were exceeded, you might want to increase it.</MaxStringsExceeded>\n");
if (MaxFontsExceeded) if (MaxFontsExceeded)
printf("\t<MaxFontsExceeded>The Maximum Number of Fonts were exceeded, you might want to increase it.</MaxFontsExceeded>\n"); printf
("\t<MaxFontsExceeded>The Maximum Number of Fonts were exceeded, you might want to increase it.</MaxFontsExceeded>\n");
if (MaxPalExceeded) if (MaxPalExceeded)
printf("\t<MaxPalExceeded>The Maximum Number of Color Palettes were exceeded, you might want to increase it.</MaxPalExceeded>\n"); printf
("\t<MaxPalExceeded>The Maximum Number of Color Palettes were exceeded, you might want to increase it.</MaxPalExceeded>\n");
if (MaxXFExceeded) if (MaxXFExceeded)
printf("\t<MaxXFExceeded>The Maximum Number of Extended Formats were exceeded, you might want to increase it.</MaxXFExceeded>\n"); printf
("\t<MaxXFExceeded>The Maximum Number of Extended Formats were exceeded, you might want to increase it.</MaxXFExceeded>\n");
if (MaxFormatsExceeded) if (MaxFormatsExceeded)
printf("\t<MaxFormatsExceeded>The Maximum Number of Formats were exceeded, you might want to increase it.</MaxFormatsExceeded>\n"); 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");
} }