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_PROGRAMS = xlhtml
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
xlcdump_SOURCES = xlcdump.c
AM_CFLAGS = -Wall -Wshadow -Wcast-align -Wpointer-arith

View File

@ -83,9 +83,10 @@ man_MANS = xlhtml.1
bin_SCRIPTS = nsopen nsxlview
bin_PROGRAMS = xlhtml
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
xlcdump_SOURCES = xlcdump.c
AM_CFLAGS = -Wall -Wshadow -Wcast-align -Wpointer-arith
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =
@ -96,7 +97,8 @@ DEFS = @DEFS@ -I. -I$(srcdir) -I..
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
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_DEPENDENCIES = ../cole/libcole.a
xlhtml_LDFLAGS =
@ -109,7 +111,6 @@ xlcdump_LDADD = $(LDADD)
xlcdump_DEPENDENCIES = ../cole/libcole.a
xlcdump_LDFLAGS =
SCRIPTS = $(bin_SCRIPTS) $(noinst_SCRIPTS)
AM_CFLAGS = -Wall -Wshadow -Wcast-align -Wpointer-arith
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 \
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
@echo Generating documentation...
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 */
for (i=first_sheet; i<=last_sheet; i++) /* For each worksheet */
/* Here's where we dump the Html Page out */
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)
continue;
if ((ws_array[i]->biggest_row == -1)||(ws_array[i]->biggest_col == -1))
continue;
if (ws_array[i]->c_array == 0)
continue;
for (k = ws_array[i]->first_col; k <= ws_array[i]->biggest_col; k++)
{
int safe, numeric = 0;
cell *c = ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k]; /* This stuff happens for each cell... */
/* Now dump the table */
for (j=ws_array[i]->first_row; j<=ws_array[i]->biggest_row; j++)
if (c)
{
for (k=ws_array[i]->first_col; k<=ws_array[i]->biggest_col; k++)
{
int safe, numeric=0;
cell *c = ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]; /* This stuff happens for each cell... */
numeric = IsCellNumeric (c);
if (!numeric && Csv)
printf ("\"");
safe = IsCellSafe (c);
if (c)
{
numeric = IsCellNumeric(c);
if (!numeric && Csv)
printf("\"");
safe = IsCellSafe(c);
if (c->ustr.str)
{
if (safe)
output_formatted_data(&(c->ustr), xf_array[c->xfmt]->fmt_idx, numeric, IsCellFormula(c));
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 (c->ustr.str)
{
if (safe)
output_formatted_data (&(c->ustr),
xf_array[c->xfmt]->fmt_idx,
numeric, IsCellFormula (c));
else
OutputString (&(c->ustr));
}
else if (!Csv)
printf (" "); /* Empty cell... */
}
if (!Csv)
printf("\n\n"); /* End of Table 2 LF-CR */
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)
printf ("\n\n"); /* End of Table 2 LF-CR */
}
}

View File

@ -28,372 +28,395 @@
/* prototypes for functions in this file */
void output_header(void);
void output_footer(void);
void output_header (void);
void output_footer (void);
void OutputTableHTML(void)
void
OutputTableHTML (void)
{
int i, j, k;
int i, j, k;
output_header();
if (center_tables)
output_header ();
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>");
do_cr();
if (ws_array[i]->ws_title.str)
{
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();
/* Here's where we dump the Html Page out */
for (i=first_sheet; i<=last_sheet; i++) /* For each worksheet */
/* 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)
{
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 ("<TR><TH></TH>");
for (k = ws_array[i]->first_col; k <= ws_array[i]->biggest_col; k++)
{
char col_hdr[3];
if (k < 26)
{
if (ws_array[i]->ws_title.str)
{
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();
}
col_hdr[0] = 'A' + (k % 26);
col_hdr[1] = '\0';
}
/* 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)
else
{
printf("<TR><TH></TH>");
for (k=ws_array[i]->first_col; k<=ws_array[i]->biggest_col; k++)
{
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");
col_hdr[0] = 'A' - 1 + (k / 26);
col_hdr[1] = 'A' + (k % 26);
col_hdr[2] = '\0';
}
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);
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])
{
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");
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("</TABLE></FONT><HR>");
do_cr();
}
}
if (center_tables)
{
printf("</CENTER>");
do_cr();
if (!aggressive)
printf ("</TR>\n");
}
printf ("</TABLE></FONT><HR>");
do_cr ();
}
/* Print the author's name in itallics... */
if (author.str)
{
printf("<FONT SIZE=\"-1\"><I>Spreadsheet's Author:&nbsp;");
OutputString(&author);
printf("</I></FONT><br>");
do_cr();
}
if (center_tables)
{
printf ("</CENTER>");
do_cr ();
}
/* Print when & how the file was last updated. */
printf("<FONT SIZE=\"-1\"><I>Last Updated ");
if (lastUpdated)
printf("%s&nbsp; ", lastUpdated);
switch (file_version)
{
case EXCEL95:
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();
/* Print the author's name in itallics... */
if (author.str)
{
printf ("<FONT SIZE=\"-1\"><I>Spreadsheet's Author:&nbsp;");
OutputString (&author);
printf ("</I></FONT><br>");
do_cr ();
}
/* Next print Disclaimers... */
if (NoFormat)
{
printf("<br>* This cell's format is not supported.<br>");
do_cr();
}
if ((notAccurate)&&(formula_warnings))
{
printf("<br>** This cell's data may not be accurate.<br>");
do_cr();
}
if (NotImplemented)
{
printf("<br>*** This cell's data type will be supported in the future.<br>");
do_cr();
}
if (Unsupported)
{
printf("<br>**** This cell's type is unsupported.<br>");
do_cr();
}
/* Print when & how the file was last updated. */
printf ("<FONT SIZE=\"-1\"><I>Last Updated ");
if (lastUpdated)
printf ("%s&nbsp; ", lastUpdated);
switch (file_version)
{
case EXCEL95:
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 ();
/* Now out exceeded capacity warnings... */
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>");
/* Next print Disclaimers... */
if (NoFormat)
{
printf ("<br>* This cell's format is not supported.<br>");
do_cr ();
}
if ((notAccurate) && (formula_warnings))
{
printf ("<br>** This cell's data may not be accurate.<br>");
do_cr ();
}
if (NotImplemented)
{
printf
("<br>*** This cell's data type will be supported in the future.<br>");
do_cr ();
}
if (Unsupported)
{
printf ("<br>**** This cell's type is unsupported.<br>");
do_cr ();
}
printf("&nbsp;<br>");
do_cr();
/* Now out exceeded capacity warnings... */
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("<hr><FONT SIZE=\"-1\">Created with <a href=\"http://chicago.sf.net/xlhtml\">xlhtml %s</a></FONT><br>", VERSION);
do_cr();
printf ("&nbsp;<br>");
do_cr ();
/* Output Tail */
output_footer();
/* Output Credit */
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)
{ /* Ouput Header */
if (NoHeaders)
return;
if (!aggressive)
void
output_header (void)
{ /* Ouput Header */
if (NoHeaders)
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\"");
do_cr();
printf("\"http://www.w3.org/TR/REC-html40/loose.dtd\">");
do_cr();
case 0:
printf ("iso-8859-1\">"); /* Latin-1 */
break;
case 1:
printf ("windows-1252\">"); /* Microsoft */
break;
default:
printf ("utf-8\">"); /* Unicode */
break;
}
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)
{
case 0:
printf("iso-8859-1\">"); /* Latin-1 */
break;
case 1:
printf("windows-1252\">"); /* Microsoft */
break;
default:
printf("utf-8\">"); /* Unicode */
break;
}
}
do_cr();
}
do_cr ();
if (!aggressive)
{
printf("<meta name=\"GENERATOR\" content=\"xlhtml\">");
do_cr();
}
printf("<TITLE>");
if (title)
printf("%s", title);
else
printf("%s", filename);
printf("</TITLE>");
do_cr();
printf("</HEAD>");
do_cr();
do_cr();
printf("<BODY TEXT=\"#%s\" BGCOLOR=\"#%s\"",
default_text_color, default_background_color);
if (default_image)
printf("BACKGROUND=\"%s\"", default_image);
printf("><br>");
do_cr();
if (!aggressive)
{
printf ("<meta name=\"GENERATOR\" content=\"xlhtml\">");
do_cr ();
}
printf ("<TITLE>");
if (title)
printf ("%s", title);
else
printf ("%s", filename);
printf ("</TITLE>");
do_cr ();
printf ("</HEAD>");
do_cr ();
do_cr ();
printf ("<BODY TEXT=\"#%s\" BGCOLOR=\"#%s\"",
default_text_color, default_background_color);
if (default_image)
printf ("BACKGROUND=\"%s\"", default_image);
printf ("><br>");
do_cr ();
}
void output_footer(void)
void
output_footer (void)
{
if (NoHeaders)
return;
printf("</BODY></HTML>");
do_cr();
fflush(stdout);
if (NoHeaders)
return;
printf ("</BODY></HTML>");
do_cr ();
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;
}
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>");
}
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>");
}
}
}
void output_end_html_attr(html_attr *h)
void
output_end_html_attr (html_attr * h)
{
if (h->sbflag)
{
printf("</SUB>");
h->sbflag = 0;
}
else if (h->spflag)
{
printf("</SUP>");
h->spflag = 0;
}
if (h->sflag)
{
printf("</S>");
h->sflag = 0;
}
if (h->iflag)
{
printf("</I>");
h->iflag = 0;
}
if (h->bflag)
{
printf("</B>");
h->bflag = 0;
}
if (h->uflag)
{
if (h->uflag == 1)
printf("</U>");
else
printf("</A>");
h->uflag = 0;
}
if (h->fflag)
{
printf("</FONT>");
h->fflag = 0;
}
if (h->sbflag)
{
printf ("</SUB>");
h->sbflag = 0;
}
else if (h->spflag)
{
printf ("</SUP>");
h->spflag = 0;
}
if (h->sflag)
{
printf ("</S>");
h->sflag = 0;
}
if (h->iflag)
{
printf ("</I>");
h->iflag = 0;
}
if (h->bflag)
{
printf ("</B>");
h->bflag = 0;
}
if (h->uflag)
{
if (h->uflag == 1)
printf ("</U>");
else
printf ("</A>");
h->uflag = 0;
}
if (h->fflag)
{
printf ("</FONT>");
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>
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"
"Released under GPL.\n", VERSION );
exit(0);
printf ("xlhtml %s \nCopyright (c) 1999-2002, Charles Wyble\n"
"Released under GPL.\n", VERSION);
exit (0);
}
void display_usage(void)
void
display_usage (void)
{
fprintf(stderr, "\nxlhtml converts excel files (.xls) to Html.\n"
"Copyright (c) 1999-2001, Charles Wyble. Released under GPL.\n"
"Usage: xlhtml [-xp:# -xc:#-# -xr:#-# -bc###### -bi???????? -tc######] <FILE>\n"
"\t-a: aggressive html optimization\n"
"\t-asc ascii output for -dp & -x? options\n"
"\t-csv comma separated value output for -dp & -x? options\n"
"\t-xml XML output\n"
"\t-bc: Set default background color - default white\n"
"\t-bi: Set background image path\n"
"\t-c: Center justify tables\n"
"\t-dp: Dumps page count and max rows & colums per page\n"
"\t-v: Prints program version number\n"
"\t-fw: Suppress formula warnings\n"
"\t-m: No encoding for multibyte\n"
"\t-nc: No Colors - black & white\n"
"\t-nh: No Html Headers\n"
"\t-tc: Set default text color - default black\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-xp: Page 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");
exit (1);
fprintf (stderr, "\nxlhtml converts excel files (.xls) to Html.\n"
"Copyright (c) 1999-2001, Charles Wyble. Released under GPL.\n"
"Usage: xlhtml [-xp:# -xc:#-# -xr:#-# -bc###### -bi???????? -tc######] <FILE>\n"
"\t-a: aggressive html optimization\n"
"\t-asc ascii output for -dp & -x? options\n"
"\t-csv comma separated value output for -dp & -x? options\n"
"\t-xml XML output\n"
"\t-bc: Set default background color - default white\n"
"\t-bi: Set background image path\n"
"\t-c: Center justify tables\n"
"\t-dp: Dumps page count and max rows & colums per page\n"
"\t-v: Prints program version number\n"
"\t-fw: Suppress formula warnings\n"
"\t-m: No encoding for multibyte\n"
"\t-nc: No Colors - black & white\n"
"\t-nh: No Html Headers\n"
"\t-tc: Set default text color - default black\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-xp: Page 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");
exit (1);
}
void do_cr(void)
void
do_cr (void)
{
extern int aggressive;
if (!aggressive)
putchar('\n');
extern int aggressive;
if (!aggressive)
putchar ('\n');
}
U16 getShort(U8 *ptr)
U16
getShort (U8 * ptr)
{
if (ptr == 0)
return (U16)0;
if (ptr == 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 */
S32 getLong(U8 *ptr)
S32
getLong (U8 * ptr)
{
if (ptr == 0)
return (S32)0;
if (ptr == 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__
/* cross-endian doubles in little endian ARM */
void getDouble(U8 *ptr, F64 *d)
void
getDouble (U8 * ptr, F64 * d)
{
size_t i;
F64 dd;
U8 *t = (U8 *)&dd;
size_t i;
F64 dd;
U8 *t = (U8 *) & dd;
for (i=0; i<sizeof(F64); i++)
*(t+i) = *(ptr+(i^4));
for (i = 0; i < sizeof (F64); i++)
*(t + i) = *(ptr + (i ^ 4));
*d = (F64)dd;
*d = (F64) dd;
}
#else
/*! Little Endian - 0x86 family */
void getDouble(U8 *ptr, F64 *d)
void
getDouble (U8 * ptr, F64 * d)
{
size_t i;
F64 dd;
U8 *t = (U8 *)&dd;
size_t i;
F64 dd;
U8 *t = (U8 *) & dd;
for (i=0; i<sizeof(F64); i++)
*(t+i) = *(ptr+i);
for (i = 0; i < sizeof (F64); i++)
*(t + i) = *(ptr + i);
*d = (F64)dd;
*d = (F64) dd;
}
#endif
#else
/*! Big Endian version - UltraSparc's, etc. */
void getDouble (U8 *ptr, F64 *d)
void
getDouble (U8 * ptr, F64 * d)
{
size_t i;
F64 dd;
U8 *t = (U8 *)&dd;
size_t i;
F64 dd;
U8 *t = (U8 *) & dd;
for (i=0; i<sizeof(F64); i++)
*(t+i) = *(ptr+sizeof(F64) - 1 - i);
for (i = 0; i < sizeof (F64); i++)
*(t + i) = *(ptr + sizeof (F64) - 1 - i);
*d = (F64)dd;
*d = (F64) dd;
}
#endif
int null_string(U8 *str)
{ /* FIXME: This function may not be unicode safe */
U8 *ptr;
if ((str == NULL)||(*str == 0))
return 1;
int
null_string (U8 * str)
{ /* FIXME: This function may not be unicode safe */
U8 *ptr;
if ((str == NULL) || (*str == 0))
return 1;
ptr = str;
while (*ptr != 0)
{
if (*ptr++ != ' ')
return 0;
}
return 1;
ptr = str;
while (*ptr != 0)
{
if (*ptr++ != ' ')
return 0;
}
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;
F64 fnum, tHr, tMin, tSec, tMsec;
int Hr, Min, Sec, Msec;
F64 fnum, tHr, tMin, tSec, tMsec;
if (msec)
fnum = atof((char *)&cnum[0])+(0.05 / 86400.0); /* Round off to 1/10th seconds */
else if (sec)
fnum = atof((char *)&cnum[0])+(0.5 / 86400.0); /* Round off to seconds */
else
fnum = atof((char *)&cnum[0])+(30 / 86400.0); /* Round off to minutes */
tHr = 24.0 * fnum;
Hr = (int)tHr;
tMin = (tHr - (F64)Hr) * 60.0;
Min = (int)tMin;
tSec = (tMin - (F64)Min) * 60.0;
Sec = (int)tSec;
tMsec = (tSec - (F64)Sec) * 10.0;
Msec = (int)tMsec;
if (msec)
fnum = atof ((char *) &cnum[0]) + (0.05 / 86400.0); /* Round off to 1/10th seconds */
else if (sec)
fnum = atof ((char *) &cnum[0]) + (0.5 / 86400.0); /* Round off to seconds */
else
fnum = atof ((char *) &cnum[0]) + (30 / 86400.0); /* Round off to minutes */
tHr = 24.0 * fnum;
Hr = (int) tHr;
tMin = (tHr - (F64) Hr) * 60.0;
Min = (int) tMin;
tSec = (tMin - (F64) Min) * 60.0;
Sec = (int) tSec;
tMsec = (tSec - (F64) Sec) * 10.0;
Msec = (int) tMsec;
Hr = Hr%24; /* Fix roll-overs */
if (hr)
*hr = Hr;
if (minut)
*minut = Min;
if (sec)
*sec = Sec;
if (msec)
*msec = Msec;
Hr = Hr % 24; /* Fix roll-overs */
if (hr)
*hr = Hr;
if (minut)
*minut = Min;
if (sec)
*sec = Sec;
if (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 ndays[]={31, 28, 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 };
int t, i, y = 0;
int t, i, y = 0;
num = num%36525L; /* Trim century */
while (num > (((y%4) == 0) ? 366 : 365))
num -= ((y++%4) == 0) ? 366 : 365;
num = num % 36525L; /* Trim century */
while (num > (((y % 4) == 0) ? 366 : 365))
num -= ((y++ % 4) == 0) ? 366 : 365;
*year = y;
t = num;
if (DatesR1904)
*year += 4; /* Adjust for McIntosh... */
if ((*year%4) == 0)
{ /* Leap Year */
for (i=0; i<12; i++)
{
if (t <= ldays[i])
break;
t -= ldays[i];
}
}
else
*year = y;
t = num;
if (DatesR1904)
*year += 4; /* Adjust for McIntosh... */
if ((*year % 4) == 0)
{ /* Leap Year */
for (i = 0; i < 12; i++)
{
for (i=0; i<12; i++)
{
if (t <= ndays[i])
break;
t -= ndays[i];
}
if (t <= ldays[i])
break;
t -= ldays[i];
}
/* Some fixups... */
*month = 1+i;
if (t == 0)
t = 1;
*day = t;
*year = *year % 100;
}
else
{
for (i = 0; i < 12; i++)
{
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];
@ -224,30 +236,34 @@ typedef S32 swords[2];
#define noaliasdub(type,ptr) \
(((union{swords sw; F64 dub;} *)(ptr))->sw)
#ifndef WORDS_BIGENDIAN /*! Defined in <config.h> */
#ifndef WORDS_BIGENDIAN /*! Defined in <config.h> */
#ifdef __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)[1] = 0;
noaliasdub (swords, d)[0] = n << 2;
noaliasdub (swords, d)[1] = 0;
}
#else
/*! Little Endian - 0x86 family */
void RKtoDouble(S32 n, F64 *d)
void
RKtoDouble (S32 n, F64 * d)
{
noaliasdub(swords,d)[0] = 0;
noaliasdub(swords,d)[1] = n << 2;
noaliasdub (swords, d)[0] = 0;
noaliasdub (swords, d)[1] = n << 2;
}
#endif
#else
/*! 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)[0] =
((*(ptr+0)<<24)+(*(ptr+1)<<16)+(*(ptr+2)<<8)+(*(ptr+3))) << 2;
noaliasdub (swords, d)[1] = 0;
noaliasdub (swords, d)[0] =
((*(ptr + 0) << 24) + (*(ptr + 1) << 16) + (*(ptr + 2) << 8) +
(*(ptr + 3))) << 2;
}
#endif

View File

@ -25,22 +25,22 @@
#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 PRGNAME "xlcdump"
#define MAX_COLS 64
#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 */
"/Book" /* Everything else ? */
"/Workbook", /* Office 97 */
"/Book" /* Everything else ? */
};
/* Function Prototypes */
COLE_LOCATE_ACTION_FUNC dump_file;
static void output_opcode_string(int);
static void output_opcode_string (int);
/* Global data */
static char filename[128];
@ -48,323 +48,331 @@ static char filename[128];
int aggressive = 0; /*!< Aggressive html optimization */
int main (int argc, char **argv)
int
main (int argc, char **argv)
{
int f_ptr = 0;
COLEFS * cfs;
COLERRNO colerrno;
int f_ptr = 0;
COLEFS *cfs;
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"
"Usage: "PRGNAME" <FILE>\n");
exit (1);
}
else
{
strncpy(filename, argv[1], 124);
cfs = cole_mount (filename, &colerrno);
if (cfs == NULL)
{
cole_perror (PRGNAME, colerrno);
exit (1);
}
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;
}
else
f_ptr++;
cole_perror (PRGNAME, colerrno);
break;
}
else
f_ptr++;
}
if (cole_umount (cfs, &colerrno))
{
cole_perror ("travel", colerrno);
exit (1);
}
if (cole_umount (cfs, &colerrno))
{
cole_perror ("travel", colerrno);
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 char buf[16];
COLEFILE *cf;
COLERRNO err;
unsigned int length = 0, opcode = 0, target = 0, count = 0;
unsigned char buf[16];
COLEFILE *cf;
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");
printf("<HTML><HEAD><TITLE>%s", filename);
printf("</TITLE></HEAD><BODY>\n");
/* Ouput Header */
printf ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n");
printf ("<HTML><HEAD><TITLE>%s", filename);
printf ("</TITLE></HEAD><BODY>\n");
/* Output body */
#if (MODE == 1)
while (cole_fread(cf, buf, 8, &err)) /* For mode >= 1 */
while (cole_fread (cf, buf, 8, &err)) /* For mode >= 1 */
#else
while (cole_fread(cf, buf, 1, &err))
while (cole_fread (cf, buf, 1, &err))
#endif
{
if (MODE == 0)
{
if (MODE == 0)
{
if (count == 0)
{
length = 0;
opcode = (unsigned)buf[0];
target = 80; /* ficticious number */
printf("<br>");
}
else if (count == 1)
opcode |= (buf[0]<<8)&0x0000FFFFL;
else if (count == 2)
length = (unsigned)buf[0];
else if (count == 3)
{
length |= (buf[0]<<8);
target = length;
printf("<br>\nLength:%04X Opcode:%04X - ", length, opcode);
output_opcode_string(opcode);
puts("<br>\n");
}
if (count > 3)
{ /* Here is where we want to process the data */
/* based on the opcode... */
if (count == 0)
{
length = 0;
opcode = (unsigned) buf[0];
target = 80; /* ficticious number */
printf ("<br>");
}
else if (count == 1)
opcode |= (buf[0] << 8) & 0x0000FFFFL;
else if (count == 2)
length = (unsigned) buf[0];
else if (count == 3)
{
length |= (buf[0] << 8);
target = length;
printf ("<br>\nLength:%04X Opcode:%04X - ", length, opcode);
output_opcode_string (opcode);
puts ("<br>\n");
}
if (count > 3)
{ /* Here is where we want to process the data */
/* based on the opcode... */
#if (TEXT == 0)
if (isprint(buf[0]))
putc(buf[0], stdout);
if (isprint (buf[0]))
putc (buf[0], stdout);
#else
printf("%02X ", buf[0]);
if (((count-3) % 8) == 0)
printf("<br>\n");
printf ("%02X ", buf[0]);
if (((count - 3) % 8) == 0)
printf ("<br>\n");
#endif
}
if (count == (target+3))
count = 0;
else
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");
}
}
if (count == (target + 3))
count = 0;
else
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");
}
}
/* Output Tail */
printf("</BODY></HTML>\n");
cole_fclose(cf, &err);
printf ("</BODY></HTML>\n");
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 0x01:
puts("UNITS: Chart Units");
break;
case 0x02:
puts("CHART: Location and overall chart dimensions");
break;
case 0x03:
puts("SERIES: Series Definition");
break;
case 0x06:
puts("DATAFORMAT: Series and Data Point Numbers");
break;
case 0x07:
puts("LINEFORMAT: Style of a line or border");
break;
case 0x09:
puts("MARKERFORMAT: Style of a line marker");
break;
case 0x0A:
puts("AREAFORMAT: Colors and patterns for an area");
break;
case 0x0B:
puts("PIEFORMAT: Position of the pie slice");
break;
case 0x0C:
puts("ATTACHEDLABEL: Series data/value labels");
break;
case 0x0D:
puts("SERIESTEXT: Legend/category/value text");
break;
case 0x14:
puts("CHARTFORMAT: Parent record for chart group");
break;
case 0x15:
puts("LEGEND: Legend type and position");
break;
case 0x16:
puts("SERIESLIST: Specifies the series in an overlay chart");
break;
case 0x17:
puts("BAR: Chart group is a bar or column chart group");
break;
case 0x18:
puts("LINE: Chart group is a line chart group");
break;
case 0x19:
puts("PIE: Chart group is a pie chart group");
break;
case 0x1A:
puts("AREA: Chart group is an area chart group");
break;
case 0x1B:
puts("SCATTER: Chart group is a scatter chart group");
break;
case 0x1C:
puts("CHARTLINE: Drop/Hi-Lo/Series Lines on a line chart");
break;
case 0x1D:
puts("AXIS: Axis Type");
break;
case 0x1E:
puts("TICK: Tick marks and labels format");
break;
case 0x1F:
puts("VALUERANGE: Defines value axis scale");
break;
case 0x20:
puts("CATSERRANGE: Defines a category or series axis");
break;
case 0x21:
puts("AXISLINEFORMAT: Defines a line that spans an axis");
break;
case 0x22:
puts("CHARTFORMTLINK: Not Used");
break;
case 0x24:
puts("DEFAULTTEXT: Default data label text properties");
break;
case 0x25:
puts("TEXT: Defines display of text fields");
break;
case 0x26:
puts("FONTX: Font Index");
break;
case 0x27:
puts("OBJECTLINK: Attaches Text to chart or chart item");
break;
case 0x32:
puts("FRAME: Defines border shape around displayed text");
break;
case 0x33:
puts("BEGIN: Defines the beginning of an object");
break;
case 0x34:
puts("END: Defines the end of an object");
break;
case 0x35:
puts("PLOTAREA: Frame belongs to ploat area");
break;
case 0x3A:
puts("3d Chart group");
break;
case 0x3C:
puts("PICF: Picture Format");
break;
case 0x3D:
puts("DROPBAR: Defines drop bars");
break;
case 0x3E:
puts("RADAR: Chart group is a radar chart group");
break;
case 0x3F:
puts("SURFACE: Chart group is a surface chart group");
break;
case 0x40:
puts("RADARAREA: Chart group is a radar area chart group");
break;
case 0x41:
puts("AXISPARENT: Axis size and location");
break;
case 0x43:
puts("LEGENDXN: Legend Exception");
break;
case 0x44:
puts("SHTPROPS: Sheet Properties");
break;
case 0x45:
puts("SERTOCRT: Series chart-group index");
break;
case 0x46:
puts("AXESUSED: Number of axes sets");
break;
case 0x48:
puts("SBASEREF: PivotTable Reference");
break;
case 0x4A:
puts("SERPARENT: Trendline or Errorbar series index");
break;
case 0x4B:
puts("SERAUXTREND: Series trendline");
break;
case 0x4E:
puts("IFMT: Number-Format Index");
break;
case 0x4F:
puts("POS: Position information");
break;
case 0x50:
puts("ALRUNS: Text formatting");
break;
case 0x51:
puts("AI: Linked data");
break;
case 0x5B:
puts("Series ErrorBar");
break;
case 0x5D:
puts("SERFMT: Series Format");
break;
case 0x60:
puts("FBI: Font Basis");
break;
case 0x61:
puts("BOPPOP: Bar of pie/pie of pie chart options");
break;
case 0x62:
puts("AXCEXT: Axis options");
break;
case 0x63:
puts("DAT: Data Table Options");
break;
case 0x64:
puts("PLOTGROWTH: Font scale factors");
break;
case 0x65:
puts("SIINDEX: Series Index");
break;
case 0x66:
puts("GELFRAME: Fill data");
break;
case 0x67:
puts("Custom bar of pie/ pie of pie chart options");
break;
default:
puts("Unknown Chart Opcode");
break;
}
case 0x10:
case 0x01:
puts ("UNITS: Chart Units");
break;
case 0x02:
puts ("CHART: Location and overall chart dimensions");
break;
case 0x03:
puts ("SERIES: Series Definition");
break;
case 0x06:
puts ("DATAFORMAT: Series and Data Point Numbers");
break;
case 0x07:
puts ("LINEFORMAT: Style of a line or border");
break;
case 0x09:
puts ("MARKERFORMAT: Style of a line marker");
break;
case 0x0A:
puts ("AREAFORMAT: Colors and patterns for an area");
break;
case 0x0B:
puts ("PIEFORMAT: Position of the pie slice");
break;
case 0x0C:
puts ("ATTACHEDLABEL: Series data/value labels");
break;
case 0x0D:
puts ("SERIESTEXT: Legend/category/value text");
break;
case 0x14:
puts ("CHARTFORMAT: Parent record for chart group");
break;
case 0x15:
puts ("LEGEND: Legend type and position");
break;
case 0x16:
puts ("SERIESLIST: Specifies the series in an overlay chart");
break;
case 0x17:
puts ("BAR: Chart group is a bar or column chart group");
break;
case 0x18:
puts ("LINE: Chart group is a line chart group");
break;
case 0x19:
puts ("PIE: Chart group is a pie chart group");
break;
case 0x1A:
puts ("AREA: Chart group is an area chart group");
break;
case 0x1B:
puts ("SCATTER: Chart group is a scatter chart group");
break;
case 0x1C:
puts ("CHARTLINE: Drop/Hi-Lo/Series Lines on a line chart");
break;
case 0x1D:
puts ("AXIS: Axis Type");
break;
case 0x1E:
puts ("TICK: Tick marks and labels format");
break;
case 0x1F:
puts ("VALUERANGE: Defines value axis scale");
break;
case 0x20:
puts ("CATSERRANGE: Defines a category or series axis");
break;
case 0x21:
puts ("AXISLINEFORMAT: Defines a line that spans an axis");
break;
case 0x22:
puts ("CHARTFORMTLINK: Not Used");
break;
case 0x24:
puts ("DEFAULTTEXT: Default data label text properties");
break;
case 0x25:
puts ("TEXT: Defines display of text fields");
break;
case 0x26:
puts ("FONTX: Font Index");
break;
case 0x27:
puts ("OBJECTLINK: Attaches Text to chart or chart item");
break;
case 0x32:
puts ("FRAME: Defines border shape around displayed text");
break;
case 0x33:
puts ("BEGIN: Defines the beginning of an object");
break;
case 0x34:
puts ("END: Defines the end of an object");
break;
case 0x35:
puts ("PLOTAREA: Frame belongs to ploat area");
break;
case 0x3A:
puts ("3d Chart group");
break;
case 0x3C:
puts ("PICF: Picture Format");
break;
case 0x3D:
puts ("DROPBAR: Defines drop bars");
break;
case 0x3E:
puts ("RADAR: Chart group is a radar chart group");
break;
case 0x3F:
puts ("SURFACE: Chart group is a surface chart group");
break;
case 0x40:
puts ("RADARAREA: Chart group is a radar area chart group");
break;
case 0x41:
puts ("AXISPARENT: Axis size and location");
break;
case 0x43:
puts ("LEGENDXN: Legend Exception");
break;
case 0x44:
puts ("SHTPROPS: Sheet Properties");
break;
case 0x45:
puts ("SERTOCRT: Series chart-group index");
break;
case 0x46:
puts ("AXESUSED: Number of axes sets");
break;
case 0x48:
puts ("SBASEREF: PivotTable Reference");
break;
case 0x4A:
puts ("SERPARENT: Trendline or Errorbar series index");
break;
case 0x4B:
puts ("SERAUXTREND: Series trendline");
break;
case 0x4E:
puts ("IFMT: Number-Format Index");
break;
case 0x4F:
puts ("POS: Position information");
break;
case 0x50:
puts ("ALRUNS: Text formatting");
break;
case 0x51:
puts ("AI: Linked data");
break;
case 0x5B:
puts ("Series ErrorBar");
break;
case 0x5D:
puts ("SERFMT: Series Format");
break;
case 0x60:
puts ("FBI: Font Basis");
break;
case 0x61:
puts ("BOPPOP: Bar of pie/pie of pie chart options");
break;
case 0x62:
puts ("AXCEXT: Axis options");
break;
case 0x63:
puts ("DAT: Data Table Options");
break;
case 0x64:
puts ("PLOTGROWTH: Font scale factors");
break;
case 0x65:
puts ("SIINDEX: Series Index");
break;
case 0x66:
puts ("GELFRAME: Fill data");
break;
case 0x67:
puts ("Custom bar of pie/ pie of pie chart options");
break;
default:
puts ("Unknown Chart Opcode");
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=\"" );
switch (UnicodeStrings)
printf ("<?xml version=\"1.0\" encoding=\"");
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:
printf("iso-8859-1\" ?>\n"); /* Latin-1 */
break;
case 1:
printf("windows-1252\"?>\n"); /* Microsoft */
break;
default:
printf("utf-8\"?>\n"); /* Unicode */
break;
if (ws_array[i]->ws_title.str)
{
printf ("\t\t\t<pagetitle>");
OutputString (&ws_array[i]->ws_title);
printf ("</pagetitle>\n");
}
else
printf ("\t\t\t<pagetitle>(Unknown Page)</pagetitle>\n");
}
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" );
printf( "\t<sheets>\n" );
/* Here's where we dump the Html Page out */
for (i=first_sheet; i<=last_sheet; i++) /* For each worksheet */
for (j = ws_array[i]->first_row; j <= ws_array[i]->biggest_row; j++)
{
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)
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]->ws_title.str)
{
printf("\t\t\t<pagetitle>");
OutputString(&ws_array[i]->ws_title);
printf("</pagetitle>\n");
}
else
printf("\t\t\t<pagetitle>(Unknown Page)</pagetitle>\n");
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<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++)
{
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\t\t\t</row>\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... */
if (author.str)
{
printf("\t<author>");
OutputString(&author);
printf("</author>\n");
}
/* Print the author's name in itallics... */
if (author.str)
{
printf ("\t<author>");
OutputString (&author);
printf ("</author>\n");
}
/* Print when & how the file was last updated. */
if (lastUpdated)
printf("\t<lastwrite>%s</lastwrite>", lastUpdated);
printf( "\t<excelversion>" );
switch (file_version)
{
case EXCEL95:
printf("using Excel 5.0 or 95");
break;
case EXCEL97:
printf("using Excel 97/2000");
break;
default:
printf("using Excel ????");
break;
}
printf("</excelversion>\n");
/* Print when & how the file was last updated. */
if (lastUpdated)
printf ("\t<lastwrite>%s</lastwrite>", lastUpdated);
printf ("\t<excelversion>");
switch (file_version)
{
case EXCEL95:
printf ("using Excel 5.0 or 95");
break;
case EXCEL97:
printf ("using Excel 97/2000");
break;
default:
printf ("using Excel ????");
break;
}
printf ("</excelversion>\n");
/* Next print Disclaimers... */
if (NoFormat)
printf("\t<noformat>%d</noformat>\n", NoFormat );
if ((notAccurate)&&(formula_warnings))
printf("\t<accuracy>%d</accuracy>\n", notAccurate );
if (NotImplemented)
printf("\t<notimplemented>%d</notimplemented>\n", NotImplemented );
if (Unsupported)
printf("\t<unsupported>%d</unsupported>\n", Unsupported );
/* Next print Disclaimers... */
if (NoFormat)
printf ("\t<noformat>%d</noformat>\n", NoFormat);
if ((notAccurate) && (formula_warnings))
printf ("\t<accuracy>%d</accuracy>\n", notAccurate);
if (NotImplemented)
printf ("\t<notimplemented>%d</notimplemented>\n", NotImplemented);
if (Unsupported)
printf ("\t<unsupported>%d</unsupported>\n", Unsupported);
/* Now out exceeded capacity warnings... */
if (MaxWorksheetsExceeded)
printf("\t<MaxWorksheetsExceeded>The Maximum Number of Worksheets were exceeded, you might want to increase it.</MaxWorksheetsExceeded>\n ");
if (MaxRowExceeded)
printf("\t<MaxRowExceeded>The Maximum Number of Rows were exceeded, you might want to increase it.</MaxRowExceeded>\n ");
if (MaxColExceeded)
printf("\t<MaxColExceeded>The Maximum Number of Columns were exceeded, you might want to increase it.</MaxColExceeded>\n");
if (MaxStringsExceeded)
printf("\t<MaxStringsExceeded>The Maximum Number of Strings were exceeded, you might want to increase it.</MaxStringsExceeded>\n");
if (MaxFontsExceeded)
printf("\t<MaxFontsExceeded>The Maximum Number of Fonts were exceeded, you might want to increase it.</MaxFontsExceeded>\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");
/* Now out exceeded capacity warnings... */
if (MaxWorksheetsExceeded)
printf
("\t<MaxWorksheetsExceeded>The Maximum Number of Worksheets were exceeded, you might want to increase it.</MaxWorksheetsExceeded>\n ");
if (MaxRowExceeded)
printf
("\t<MaxRowExceeded>The Maximum Number of Rows were exceeded, you might want to increase it.</MaxRowExceeded>\n ");
if (MaxColExceeded)
printf
("\t<MaxColExceeded>The Maximum Number of Columns were exceeded, you might want to increase it.</MaxColExceeded>\n");
if (MaxStringsExceeded)
printf
("\t<MaxStringsExceeded>The Maximum Number of Strings were exceeded, you might want to increase it.</MaxStringsExceeded>\n");
if (MaxFontsExceeded)
printf
("\t<MaxFontsExceeded>The Maximum Number of Fonts were exceeded, you might want to increase it.</MaxFontsExceeded>\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 */
printf("\t<tool>Created with xlhtml %s</tool>\n", VERSION);
printf("\t<toollink>http://chicago.sf.net/xlhtml/</toollink>\n");
printf( "</excel_workbook>\n" );
/* Output Credit */
printf ("\t<tool>Created with xlhtml %s</tool>\n", VERSION);
printf ("\t<toollink>http://chicago.sf.net/xlhtml/</toollink>\n");
printf ("</excel_workbook>\n");
}