/* xls2xml: Converts from Microsoft Excel files to XML. Copyright 1999 Roberto Arturo Tena Sanchez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* Roberto Arturo Tena Sanchez */ #include #include #include #include #include #include #include /* BOF-BIFF5/7/8 - Beginning of File */ int p809 (void) { xmlNodePtr build; char number [10]; U32 flags; assert_return (xls2xml, parameters->record.opcode == 0x809, 19); test (parameters->record.size >= 0x02, 15); parameters->dont_care_end = parameters->jump_to_next_substream = 0; /* save biff version info, just the Workbook globals one */ if (parameters->biff_version == 0) { parameters->biff_version = fil_sreadU16 (parameters->record.info); verboseU16 (parameters->biff_version); } else verbose ("first biff version wins"); switch (parameters->biff_version) { case BIFF_5_7: case BIFF_8: if (parameters->biff_version == BIFF_5_7) test (parameters->record.size >= 0x08, 15) else if (parameters->biff_version == BIFF_8) test (parameters->record.size >= 0x10, 15) else assert_return (xls2xml, 1==2, 19); switch (fil_sreadU16 (parameters->record.info+2)) { case 0x0005: /* Workbook globals */ test (parameters->xml_tree_shortcuts.defaults != NULL, 19); switch (parameters->options.extract_level) { case EXTRACT_ALL: build = xmlNewChild(parameters->xml_tree_shortcuts.defaults, NULL, (unsigned char *)"building", NULL); test (build != NULL, 10); sprintf (number, "%d", fil_sreadU16 (parameters->record.info+4)); test (xmlNewChild (build, NULL, (unsigned char *)"appid", (unsigned char *)number) != NULL, 10); sprintf (number, "%d", fil_sreadU16 (parameters->record.info+6)); test (xmlNewChild (build, NULL, (unsigned char *)"appyear", (unsigned char *)number) != NULL, 10); /* until here runs BIFF5/7 Workbook globals information */ if (fil_sreadU16 (parameters->record.info) == BIFF_5_7) break; flags = fil_sreadU32 (parameters->record.info+8); if (flags & 0x00000001UL) test (xmlNewChild (build, NULL, (unsigned char *)"lasteditedWin", NULL) != NULL, 10); if (flags & 0x00000002UL) test (xmlNewChild (build, NULL, (unsigned char *)"lasteditedRISC", NULL) != NULL, 10); if (flags & 0x00000004UL) test (xmlNewChild (build, NULL, (unsigned char *)"lasteditedBeta", NULL) != NULL, 10); if (flags & 0x00000008UL) test (xmlNewChild (build, NULL, (unsigned char *)"evereditedWin", NULL) != NULL, 10); if (flags & 0x00000010UL) test (xmlNewChild (build, NULL, (unsigned char *)"evereditedMac", NULL) != NULL, 10); if (flags & 0x00000020UL) test (xmlNewChild (build, NULL, (unsigned char *)"evereditedBeta", NULL) != NULL, 10); if (flags & 0x00000100UL) test (xmlNewChild (build, NULL, (unsigned char *)"evereditedRISC", NULL) != NULL, 10); verbose ("FIXME: 809: should save in a variable or in xml tree the lowest biff version?"); break; default: break; } break; case 0x0006: /* Visual Basic module */ verbose ("FIXME: 809: Visual Basic substream"); parameters->dont_care_end = parameters->jump_to_next_substream = 1; break; case 0x0010: /* Worksheet or dialog sheet */ verbose ("FIXME: 809: Worksheet or dialog sheet substream"); if (parameters->this_sheet == NULL) { /* choose next sheet as first sheet only the first time */ parameters->this_sheet = parameters->xml_tree_shortcuts.first_sheet; assert_return (xls2xml, parameters->this_sheet != NULL, 19); } else { parameters->this_sheet = parameters->this_sheet->next; if (parameters->this_sheet == NULL) /* if there are no more sheets in xml tree... well the file is somekind broken, but we just add one more sheet and continue! */ test_call (create_new_sheet (¶meters->this_sheet), int); } parameters->this_cells = search_child ("cells", parameters->this_sheet); assert_return (xls2xml, parameters->this_cells != NULL, 19); parameters->this_refmode = parameters->options.refmode; if (parameters->this_refmode == REFMODE_AS_IS) parameters->this_refmode = REFMODE_R1C1; /* MAGIC CONSTANT */ break; case 0x0020: /* Chart */ verbose ("FIXME: 809: Chart substream"); parameters->dont_care_end = parameters->jump_to_next_substream = 1; break; case 0x0040: /* Microsoft Excel 4.0 macro sheet */ verbose ("FIXME: 809: Microsoft Excel 4.0 macro sheet substream"); parameters->dont_care_end = parameters->jump_to_next_substream = 1; break; case 0x0100: /* Workspace file */ verbose ("FIXME: 809: Microsoft Excel 4.0 macro sheet substream"); parameters->dont_care_end = parameters->jump_to_next_substream = 1; break; default: /* Unknown */ return 15; } break; default: /* Unknown */ return 15; } return 0; }