Commit 221a65d2 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

A bunch of little fixes that get us closer to parsing the XL2k expense report

template.  There is a still a nagging problem with odd continue records in
escher streams but they seem rare enough that we can ignore until a more
illuminating test case shows up.

2001-03-30  Jody Goldberg <jgoldberg@home.com>

	* boot.c (excel_save) : clarify message.

2001-03-29  Jody Goldberg <jgoldberg@home.com>

	* ms-escher.c (ms_escher_read_Blip) : Fix leak plug.

2001-03-29  Jody Goldberg <jgoldberg@home.com>

	* ms-obj.c (ms_obj_read_biff8_obj) : It seems certain that the MS docs
	  are wrong about list boxes.  I hope they don't do the same thing for
	  other records too.

	* ms-escher.c : s/ms_excel_read_debug/ms_excel_escher_debug/
	(ms_escher_read_OPT) : Add missing OPT records and cleanup docs.
	(ms_escher_read_BSE) : Document the record size and don't attempt to
	  treat this as a container if its content is of size 0.

2001-03-28  Jody Goldberg <jgoldberg@home.com>

	* ms-obj.c (ms_read_TXO) : Fix the minor memory overrun morton found.

2001-03-18  Jody Goldberg <jgoldberg@home.com>

	* ms-excel-util.c (init_xl_font_widths) : recalculate the size of Geneva
	  for the default case of Geneva not being available.
parent bdacb10e
2001-03-30 Jody Goldberg <jgoldberg@home.com>
* boot.c (excel_save) : clarify message.
2001-03-29 Jody Goldberg <jgoldberg@home.com>
* ms-escher.c (ms_escher_read_Blip) : Fix leak plug.
2001-03-29 Jody Goldberg <jgoldberg@home.com>
* ms-obj.c (ms_obj_read_biff8_obj) : It seems certain that the MS docs
are wrong about list boxes. I hope they don't do the same thing for
other records too.
* ms-escher.c : s/ms_excel_read_debug/ms_excel_escher_debug/
(ms_escher_read_OPT) : Add missing OPT records and cleanup docs.
(ms_escher_read_BSE) : Document the record size and don't attempt to
treat this as a container if its content is of size 0.
2001-03-28 Jody Goldberg <jgoldberg@home.com>
* ms-obj.c (ms_read_TXO) : Fix the minor memory overrun morton found.
2001-03-18 Jody Goldberg <jgoldberg@home.com>
* ms-excel-util.c (init_xl_font_widths) : recalculate the size of Geneva
for the default case of Geneva not being available.
2001-03-27 Morten Welinder <terra@diku.dk>
* ms-escher.c (ms_escher_read_Blip): Plug leak.
......
......@@ -36,6 +36,8 @@ GNUMERIC_MODULE_PLUGIN_INFO_DECL;
*/
/* Enables debugging mesgs while reading excel workbooks */
gint ms_excel_read_debug = 0;
/* Enables debugging mesgs while reading parsing escher streams */
gint ms_excel_escher_debug = 0;
/* Enables debugging mesgs while reading excel functions */
gint ms_excel_formula_debug = 0;
/* Enables debugging mesgs while reading excel colors & patterns */
......@@ -140,7 +142,7 @@ excel_save (IOContext *context, WorkbookView *wb_view, const char *filename,
if (g_file_exists (filename)) {
gnumeric_io_error_save (context,
_("Saving over old files disabled for safety"));
_("Saving over old Excel files disabled for safety"));
return;
}
......@@ -171,7 +173,7 @@ excel_save (IOContext *context, WorkbookView *wb_view, const char *filename,
}
void
excel98_file_save (FileSaver const *fs, IOContext *context,
excel97_file_save (FileSaver const *fs, IOContext *context,
WorkbookView *wb_view, const char *filename)
{
excel_save (context, wb_view, filename, MS_BIFF_V8);
......
......@@ -13,6 +13,7 @@
#include <glib.h>
extern gint ms_excel_read_debug;
extern gint ms_excel_escher_debug;
extern gint ms_excel_formula_debug;
extern gint ms_excel_color_debug;
extern gint ms_excel_chart_debug;
......
......@@ -128,7 +128,7 @@ ms_escher_get_data (MSEscherState * state,
state->segment_len = q->length;
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 1)
if (ms_excel_escher_debug > 1)
printf ("Target is 0x%x bytes at 0x%x, current = 0x%x..0x%x;\n"
"Adding biff-0x%x of length 0x%x;\n",
num_bytes, offset,
......@@ -148,14 +148,14 @@ ms_escher_get_data (MSEscherState * state,
int counter = 0;
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 1)
if (ms_excel_escher_debug > 1)
printf ("MERGE needed (%d+%d) >= %d;\n",
offset, num_bytes, state->end_offset);
#endif
do {
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 1)
if (ms_excel_escher_debug > 1)
printf ("record %d) add %d bytes;\n", ++counter, len);
#endif
/* copy necessary portion of current record */
......@@ -189,7 +189,7 @@ ms_escher_get_data (MSEscherState * state,
/* Copy back stub */
memcpy (tmp, res, num_bytes - (tmp-buffer));
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 1)
if (ms_excel_escher_debug > 1)
printf ("record %d) add %d bytes;\n", ++counter, num_bytes - (tmp-buffer));
#endif
return buffer;
......@@ -246,7 +246,7 @@ ms_escher_read_SplitMenuColors (MSEscherState * state, MSEscherHeader * h)
guint32 const threeD = MS_OLE_GET_GUINT32(data + 12);
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 0)
if (ms_excel_escher_debug > 0)
printf ("top_level_fill = 0x%x;\nline = 0x%x;\nshadow = 0x%x;\nthreeD = 0x%x;\n",
top_level_fill, line, shadow, threeD);
#endif
......@@ -291,7 +291,7 @@ write_file (gchar const * const name, const guint8 * data,
if (f) {
fwrite (data, len, 1, f);
fclose (f);
if (ms_excel_read_debug > 0)
if (ms_excel_escher_debug > 0)
printf ("written 0x%x bytes to '%s';\n",
len, file_name->str);
} else
......@@ -307,15 +307,16 @@ ms_escher_read_BSE (MSEscherState * state, MSEscherHeader * h)
/* read the header */
gboolean needs_free;
const guint8 * data =
ms_escher_get_data (state, h->offset, 34,
ms_escher_get_data (state, h->offset, 36,
common_header_len, &needs_free);
const guint8 win_type = MS_OLE_GET_GUINT8 (data + 0);
const guint8 mac_type = MS_OLE_GET_GUINT8 (data + 1);
guint32 const size = MS_OLE_GET_GUINT32(data + 20);
guint32 const ref_count = MS_OLE_GET_GUINT32(data + 24);
gint32 const del_offset = MS_OLE_GET_GUINT32(data + 28);
const guint8 is_texture = MS_OLE_GET_GUINT8 (data + 32);
const guint8 name_len = MS_OLE_GET_GUINT8 (data + 33);
guint8 const win_type = MS_OLE_GET_GUINT8 (data + 0);
guint8 const mac_type = MS_OLE_GET_GUINT8 (data + 1);
/*guint16 const tag = MS_OLE_GET_GUINT16 (data + 18);*/
guint32 const size = MS_OLE_GET_GUINT32 (data + 20);
guint32 const ref_count = MS_OLE_GET_GUINT32 (data + 24);
gint32 const del_offset = MS_OLE_GET_GUINT32 (data + 28);
const guint8 is_texture = MS_OLE_GET_GUINT8 (data + 32);
const guint8 name_len = MS_OLE_GET_GUINT8 (data + 33);
guint8 checksum[16]; /* RSA Data Security, Inc. MD4 Message-Digest Algorithm */
char *name = "unknown";
int i;
......@@ -323,7 +324,7 @@ ms_escher_read_BSE (MSEscherState * state, MSEscherHeader * h)
checksum[i] = MS_OLE_GET_GUINT8 (data + 2 + i);
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 0) {
if (ms_excel_escher_debug > 0) {
printf ("Win type = %s;\n", bliptype_name (win_type));
printf ("Mac type = %s;\n", bliptype_name (mac_type));
printf ("Size = 0x%x(=%d) RefCount = 0x%x DelayOffset = 0x%x '%s';\n",
......@@ -348,7 +349,10 @@ ms_escher_read_BSE (MSEscherState * state, MSEscherHeader * h)
/* name = biff_get_text (data+36, name_len, &txt_byte_len); */
}
return ms_escher_read_container (state, h, 36);
/* Ignore empties */
if (h->len > 36 + common_header_len)
return ms_escher_read_container (state, h, 36);
return FALSE;
}
static gboolean
......@@ -393,19 +397,19 @@ ms_escher_read_Blip (MSEscherState * state, MSEscherHeader * h)
{
int const header = 17 + primary_uid_size + common_header_len;
gboolean needs_free;
const char *repoid;
const guint8 *data =
ms_escher_get_data (state, h->offset, h->len,
header, &needs_free);
char const *repoid;
guint8 const *data = ms_escher_get_data (state, h->offset,
h->len, header, &needs_free);
repoid = "OAFIID:GNOME_EOG_Embeddable";
ms_escher_blip_new (data, h->len - header, repoid, state->container);
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 1)
if (ms_excel_escher_debug > 1)
write_file ("unknown", data, h->len - header, h->fbt - Blip_START);
#endif
g_free (data);
if (needs_free)
g_free ((guint8*)data);
break;
}
......@@ -581,7 +585,7 @@ ms_escher_read_Spgr (MSEscherState * state, MSEscherHeader * h)
g_return_val_if_fail (h->instance <= 202, TRUE);
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 0)
if (ms_excel_escher_debug > 0)
printf ("%s (0x%x);\n", shape_names[h->instance],
h->instance);
#endif
......@@ -600,7 +604,7 @@ ms_escher_read_Sp (MSEscherState * state, MSEscherHeader * h)
guint32 const spid = MS_OLE_GET_GUINT32 (data+0);
guint32 const flags = MS_OLE_GET_GUINT32 (data+4);
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 0)
if (ms_excel_escher_debug > 0)
printf ("SPID %d, Type %d,%s%s%s%s%s%s%s%s%s%s%s;\n",
spid, h->instance,
(flags&0x01) ? " Group": "",
......@@ -1075,9 +1079,31 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
prev_pid = pid;
switch (pid) {
/* Transofrmation */
/* 0 : fixed point: 16.16 degrees */
case 4 : name = "long rotation"; break;
/* Protection */
/* FALSE : */
case 119 : name = "bool LockRotation"; break;
/* FALSE : */
case 120 : name = "bool LockAspectRatio"; break;
/* FALSE : */
case 121 : name = "bool LockPosition"; break;
/* FALSE : */
case 122 : name = "bool LockAgainstSelect"; break;
/* FALSE : */
case 123 : name = "bool LockCropping"; break;
/* FALSE : */
case 124 : name = "bool LockVertices"; break;
/* FALSE : */
case 125 : name = "bool LockText"; break;
/* FALSE : */
case 126 : name = "bool LockAdjustHandles"; break;
/* FALSE : */
case 127 : name = "bool LockAgainstGrouping"; break;
/* Text */
/* 0 : id for the text, value determined by the host */
case 128 : name = "long Txid"; break;
/* 1/10" : margins relative to shape's inscribed text rectangle (in EMUs) */
......@@ -1113,6 +1139,7 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
/* FALSE : Size text to fit shape size */
case 191 : name = "bool fFitTextToShape"; break;
/* GeoText */
/* NULL : UNICODE text string */
case 192 : name = "wchar* gtextUNICODE"; break;
/* NULL : RTF text string */
......@@ -1158,69 +1185,53 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
/* FALSE : Strike through font */
case 255 : name = "bool gtextFStrikethrough"; break;
/* Blip */
/* 0 : 16.16 fraction times total image width or height, as appropriate. */
case 256 : name = "fixed16_16 cropFromTop"; break;
case 257 : name = "fixed16_16 cropFromBottom"; break;
case 258 : name = "fixed16_16 cropFromLeft"; break;
case 259 : name = "fixed16_16 cropFromRight"; break;
/* NULL : Blip to display */
case 260 : name = "Blip * pib";
h->blip_id = (int)val - 1;
break;
/* NULL : Blip file name */
case 261 : name = "wchar * pibName"; break;
/* What are BlipFlags ? */
/* Comment Blip flags */
case 262 : name = "BlipType pibFlags"; break;
/* ~0 : transparent color (none if ~0UL) */
case 263 : name = "long pictureTransparent"; break;
/* 1<<16 : contrast setting */
case 264 : name = "long pictureContrast"; break;
/* 0 : brightness setting */
case 265 : name = "long pictureBrightness"; break;
/* 0 : 16.16 gamma */
case 266 : name = "fixed16_16 pictureGamma"; break;
/* 0 : Host-defined ID for OLE objects (usually a pointer) */
case 267 : name = "Long pictureId"; break;
/* undefined : Double shadow Colour */
case 268 : name = "Colour pictureDblCrMod"; break;
/* undefined : */
case 269 : name = "Colour pictureFillCrMod"; break;
/* undefined : */
case 270 : name = "Colour pictureLineCrMod"; break;
/* NULL : Blip to display when printing */
case 271 : name = "Blip * pibPrint"; break;
/* NULL : Blip file name */
case 272 : name = "wchar * pibPrintName"; break;
/* Comment Blip flags */
case 273 : name = "BlipType pibPrintFlags"; break;
/* FALSE : Do not hit test the picture */
case 316 : name = "bool fNoHitTestPicture"; break;
/* FALSE : grayscale display */
case 317 : name = "bool pictureGray"; break;
/* FALSE : bi-level display */
case 318 : name = "bool pictureBiLevel"; break;
/* FALSE : Server is active (OLE objects only) */
case 319 : name = "bool pictureActive"; break;
/* Geometry */
/* 0 : Defines the G (geometry) coordinate space. */
case 320 : name = "long geoLeft"; break;
/* 0 : */
......@@ -1271,6 +1282,7 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
/* TRUE : OK to fill the shape through the UI or VBA? */
case 383 : name = "bool fFillOK"; break;
/* FillStyle */
/* Solid : Type of fill */
case 384 : name = "FillType fillType"; break;
/* white : Foreground color */
......@@ -1342,6 +1354,7 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
/* FALSE : Hit test a shape as though filled */
case 447 : name = "bool fNoFillHitTest"; break;
/* LineStyle */
/* black : Color of line */
case 448 : name = "Colour lineColor"; break;
/* 1<<16 : Not implemented */
......@@ -1401,6 +1414,7 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
/* FALSE : Draw a dashed line if no line */
case 511 : name = "bool fNoLineDrawDash"; break;
/* ShadowStyle */
/* Offset : Type of effect */
case 512 : name = "Shadow shadowType"; break;
/* 0x808080 : Foreground color */
......@@ -1442,6 +1456,7 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
/* FALSE : Excel5-style shadow */
case 575 : name = "bool fshadowObscured"; break;
/* PerspectiveStyle */
/* Shape : Where transform applies */
case 576 : name = "Transform perspectiveType"; break;
/* 0 : The long values define a transformation matrix,
......@@ -1471,6 +1486,7 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
/* FALSE : On/off */
case 639 : name = "bool fPerspective"; break;
/* 3D Object */
/* 0 : Fixed-point 16.16 */
case 640 : name = "long DSpecularAmt"; break;
/* 65536 : Fixed-point 16.16 */
......@@ -1500,6 +1516,7 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
/* TRUE : */
case 703 : name = "bool fc3DLightFace"; break;
/* 3D Style */
/* 0 : degrees (16.16) about y axis */
case 704 : name = "long c3DYRotationAngle"; break;
/* 0 : degrees (16.16) about x axis */
......@@ -1565,6 +1582,7 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
/* 0 : Is fill lighting harsh?` */
case 767 : name = "bool fc3DFillHarsh"; break;
/* Shape */
/* NULL : master shape */
case 769 : name = "MSOHSP pMaster"; break;
/* None : Type of connector */
......@@ -1587,91 +1605,66 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
/* FALSE : If TRUE, this is the background shape. */
case 831 : name = "bool fBackground"; break;
/* CallOut */
/* TwoSegment : CalloutType */
case 832 : name = "CalloutType spcot"; break;
/* 1/12" : Distance from box to first point.(EMUs) */
case 833 : name = "long dxyCalloutGap"; break;
/* Any : Callout angle */
case 834 : name = "CallOutAngle spcoa"; break;
/* Specified : Callout drop type */
case 835 : name = "CalloutDrop spcod"; break;
/* 9 points : if msospcodSpecified, the actual drop distance */
case 836 : name = "long dxyCalloutDropSpecified"; break;
/* 0 : if fCalloutLengthSpecified, the actual distance */
case 837 : name = "long dxyCalloutLengthSpecified"; break;
/* FALSE : Is the shape a callout? */
case 889 : name = "bool fCallout"; break;
/* FALSE : does callout have accent bar */
case 890 : name = "bool fCalloutAccentBar"; break;
/* TRUE : does callout have a text border */
case 891 : name = "bool fCalloutTextBorder"; break;
/* FALSE : */
case 892 : name = "bool fCalloutMinusX"; break;
/* FALSE : */
case 893 : name = "bool fCalloutMinusY"; break;
/* FALSE : If true, then we occasionally invert the drop distance */
case 894 : name = "bool fCalloutDropAuto"; break;
/* GroupShape */
/* FALSE : if true, we look at dxyCalloutLengthSpecified */
case 895 : name = "bool fCalloutLengthSpecified"; break;
/* NULL : Shape Name (present only if explicitly set) */
case 896 : name = "wchar* wzName"; break;
/* NULL : alternate text */
case 897 : name = "wchar* wzDescription"; break;
/* NULL : The hyperlink in the shape. */
case 898 : name = "IHlink* pihlShape"; break;
/* NULL : The polygon that text will be wrapped around (Word) */
case 899 : name = "IMsoArray pWrapPolygonVertices"; break;
/* 1/8" : Left wrapping distance from text (Word) */
case 900 : name = "long dxWrapDistLeft"; break;
/* 0 : Top wrapping distance from text (Word) */
case 901 : name = "long dyWrapDistTop"; break;
/* 1/8" : Right wrapping distance from text (Word) */
case 902 : name = "long dxWrapDistRight"; break;
/* 0 : Bottom wrapping distance from text (Word) */
case 903 : name = "long dyWrapDistBottom"; break;
/* 0 : Regroup ID */
case 904 : name = "long lidRegroup"; break;
/* FALSE : Has the wrap polygon been edited? */
case 953 : name = "bool fEditedWrap"; break;
/* FALSE : Word-only (shape is behind text) */
case 954 : name = "bool fBehindDocument"; break;
/* FALSE : Notify client on a double click */
case 955 : name = "bool fOnDblClickNotify"; break;
/* FALSE : A button shape (i.e., clicking performs an action).
* Set for shapes with attached hyperlinks or macros. */
case 956 : name = "bool fIsButton"; break;
/* FALSE : 1D adjustment */
case 957 : name = "bool fOneD"; break;
/* FALSE : Do not display */
case 958 : name = "bool fHidden"; break;
/* TRUE : Print this shape */
case 959 : name = "bool fPrint"; break;
......@@ -1679,7 +1672,7 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
};
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 0)
if (ms_excel_escher_debug > 0)
printf ("%s %d = 0x%x (=%d) %s%s;\n", name, pid, val, val,
is_blip ? " is blip" : "",
is_complex ? " is complex" : "");
......@@ -1827,9 +1820,9 @@ ms_escher_read_container (MSEscherState *state, MSEscherHeader *container,
h.instance = (tmp >> 4) & 0xfff;
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 0) {
printf ("length 0x%x(=%d), ver 0x%x, instance 0x%x, offset = 0x%x;\n",
h.len, h.len, h.ver, h.instance, h.offset);
if (ms_excel_escher_debug > 0) {
printf ("length 0x%x(=%d), ver 0x%x, instance 0x%x, offset = 0x%x(=%d);\n",
h.len, h.len, h.ver, h.instance, h.offset, h.offset);
}
#endif
/*
......@@ -1837,7 +1830,7 @@ ms_escher_read_container (MSEscherState *state, MSEscherHeader *container,
* If problems arise in the next tests it probably indicates that
* the PRECEDING record length was invalid. Check that it included the header */
if ((h.fbt & (~0x1ff)) != 0xf000) {
printf ("WARNING EXCEL : Invalid fbt = %x\n", h.fbt);
printf ("EXCEL : Invalid fbt = 0x%x\n", h.fbt);
return TRUE;
}
......@@ -1883,13 +1876,13 @@ ms_escher_read_container (MSEscherState *state, MSEscherHeader *container,
g_return_val_if_fail (handler != NULL, TRUE);
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 0)
if (ms_excel_escher_debug > 0)
printf ("{ /* %s */\n", fbt_name);
#endif
res = (*handler)(state, &h);
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 0)
if (ms_excel_escher_debug > 0)
printf ("}; /* %s */\n", fbt_name);
#endif
if (res) {
......@@ -1934,6 +1927,7 @@ ms_escher_parse (BiffQuery *q, MSContainer *container)
return;
}
/*ms_excel_escher_debug = 2; */
state.container = container;
state.q = q;
state.segment_len = q->length;
......@@ -1945,14 +1939,14 @@ ms_escher_parse (BiffQuery *q, MSContainer *container)
fake_header.offset = 0;
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 0)
if (ms_excel_escher_debug > 0)
printf ("{ /* Escher '%s'*/\n", drawing_record_name);
#endif
ms_escher_read_container (&state, &fake_header, -common_header_len);
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 0)
if (ms_excel_escher_debug > 0)
printf ("}; /* Escher '%s'*/\n", drawing_record_name);
#endif
}
......@@ -207,7 +207,8 @@ init_xl_font_widths ()
{ 103, 110, "Courier New" },
{ 103, 110, "Fixedsys" },
{ 80, 86, "Garamond" },
{ 115, 122, "Geneva" },
/* { 115, 122, "Geneva" }, These are the real numbers */
{ 95, 102, "Geneva" }, /* These are the defaults when Geneva is not available */
{ 95, 102, "Haettenscheiler" },
{ 103, 110, "HE_TERMINAL" },
{ 95, 102, "Helvetica" },
......
......@@ -444,47 +444,6 @@ expr_tree_string (const char *str)
{
return expr_tree_new_constant (value_new_string (str));
}
#if 0
{
const UINT16 ExcelToSc::nRowMask = 0x3FFF;
if( bName )
{
if( nRow & 0x4000 ) {
rSRD.SetColRel( TRUE );
rSRD.nRelCol = *( ( sal_Char * ) &nCol );
} else
{
rSRD.SetColRel( FALSE );
rSRD.nCol = nCol;
}
if( nRow & 0x8000 )
{
rSRD.SetRowRel( TRUE );
if( nRow & 0x2000 ) // Bit 13 gesetzt?
rSRD.nRelRow = *( ( INT16 * ) &nRow ) | 0xC000;
else
rSRD.nRelRow = nRow & nRowMask;
} else
{
rSRD.SetRowRel( FALSE );
rSRD.nRow = nRow & nRowMask;
}
} else
{
rSRD.SetColRel( ( nRow & 0x4000 ) > 0 );
rSRD.nCol = nCol;
rSRD.SetRowRel( ( nRow & 0x8000 ) > 0 );
rSRD.nRow = nRow & nRowMask;
if ( rSRD.IsColRel() )
rSRD.nRelCol = rSRD.nCol - aEingPos.Col();
if ( rSRD.IsRowRel() )
rSRD.nRelRow = rSRD.nRow - aEingPos.Row();
}
}
#endif
/**
* A useful routine for extracting data from a common
......
......@@ -53,18 +53,18 @@ char *
ms_read_TXO (BiffQuery *q)
{
static char const * const orientations [] = {
"Left to right",
"Top to Bottom",
"Bottom to Top on Side",
"Top to Bottom on Side"
"Left to right",
"Top to Bottom",
"Bottom to Top on Side",
"Top to Bottom on Side"
};
static char const * const haligns [] = {
"At left", "Horizontaly centered",
"At right", "Horizontaly justified"
"At left", "Horizontaly centered",
"At right", "Horizontaly justified"
};
static char const * const valigns [] = {
"At top", "Verticaly centered",
"At bottom", "Verticaly justified"
"At top", "Verticaly centered",
"At bottom", "Verticaly justified"
};
guint16 const options = MS_OLE_GET_GUINT16 (q->data);
......@@ -74,7 +74,6 @@ ms_read_TXO (BiffQuery *q)
int const halign = (options >> 1) & 0x7;
int const valign = (options >> 4) & 0x7;
char *text = g_new (char, text_len + 1);
guint8 const unicode_flag = MS_OLE_GET_GUINT8 (q->data + 18);
guint16 peek_op;
g_return_val_if_fail (orient <= 3, NULL);
......@@ -88,12 +87,8 @@ ms_read_TXO (BiffQuery *q)
int i, increment = 1;
ms_biff_query_next (q);
data = q->data;
if (unicode_flag) {
increment = 2;
data++;
}
increment = (MS_OLE_GET_GUINT8 (q->data)) ? 2 : 1;
data = q->data + 1;
/*
* FIXME: Use biff_get_text or something ?
......@@ -128,14 +123,19 @@ ms_read_TXO (BiffQuery *q)
}
static void
ms_obj_dump (guint8 const * const data, int const len, char const * const name)
ms_obj_dump (guint8 const *data, int len, int data_left, char const *name)
{
#ifndef NO_DEBUG_EXCEL
if (ms_excel_object_debug < 2)
return;
printf ("{ %s \n", name);
ms_ole_dump (data+4, len);
if (len+4 > data_left) {
printf ("/* invalid length %d (0x%x) > %d(0x%x)*/\n",
len+4, len+4, data_left, data_left);
len = data_left - 4;
}
ms_ole_dump (data, len+4);
printf ("}; /* %s */\n", name);
#endif
}
......@@ -179,12 +179,20 @@ ms_obj_read_biff8_obj (BiffQuery *q, MSContainer *container, MSObj *obj)
data = q->data;
data_len_left = q->length;
#if 0
dump_biff (q);
#endif
/* Scan through the pseudo BIFF substream */
while (data_len_left > 0 && !hit_end) {
guint16 const record_type = MS_OLE_GET_GUINT16(data);
/* All the sub-records seem to have this layout */
guint16 const len = MS_OLE_GET_GUINT16(data+2);
/* All the sub-records seem to have this layout
* 2001/Mar/29 JEG : liars. Ok not all records have this
* layout. Create a list box. It seems to do something
* unique. It acts like an end, and has no length specified.
*/
guint16 len = MS_OLE_GET_GUINT16(data+2);
/* 1st record must be COMMON_OBJ*/
g_return_val_if_fail (obj->excel_type >= 0 ||
......@@ -194,24 +202,24 @@ ms_obj_read_biff8_obj (BiffQuery *q, MSContainer *container, MSObj *obj)
switch (record_type) {
case GR_END:
g_return_val_if_fail (len == 0, TRUE);
ms_obj_dump (data, len, "ObjEnd");
ms_obj_dump (data, len, data_len_left, "ObjEnd");
hit_end = TRUE;
break;
case GR_MACRO :
ms_obj_dump (data, len, "MacroObject");
ms_obj_dump (data, len, data_len_left, "MacroObject");
break;
case GR_COMMAND_BUTTON :
ms_obj_dump (data, len, "CommandButton");
ms_obj_dump (data, len, data_len_left, "CommandButton");
break;
case GR_GROUP_BUTTON :
ms_obj_dump (data, len, "GroupButton");
ms_obj_dump (data, len, data_len_left, "GroupButton");
break;
case GR_CLIPBOARD_FORMAT:
ms_obj_dump (data, len, "ClipboardFmt");
ms_obj_dump (data, len, data_len_left, "ClipboardFmt");
break;
case GR_PICTURE_OPTIONS:
......@@ -234,23 +242,23 @@ ms_obj_read_biff8_obj (BiffQuery *q, MSContainer *container, MSObj *obj)
}
case GR_PICTURE_FORMULA:
ms_obj_dump (data, len, "PictFormula");
ms_obj_dump (data, len, data_len_left, "PictFormula");
break;
case GR_CHECKBOX_LINK :
ms_obj_dump (data, len, "CheckboxLink");
ms_obj_dump (data, len, data_len_left, "CheckboxLink");
break;
case GR_RADIO_BUTTON :
ms_obj_dump (data, len, "RadioButton");
ms_obj_dump (data, len, data_len_left, "RadioButton");
break;
case GR_SCROLLBAR :
ms_obj_dump (data, len, "ScrollBar");
ms_obj_dump (data, len, data_len_left, "ScrollBar");
break;
case GR_NOTE_STRUCTURE :
ms_obj_dump (data, len, "Note");
ms_obj_dump (data, len, data_len_left, "Note");
break;
case GR_SCROLLBAR_FORMULA :
......@@ -259,28 +267,35 @@ ms_obj_read_biff8_obj (BiffQuery *q, MSContainer *container, MSObj *obj)
* 0x12 uint16 == number of elements
* 0x14 uint16 == current element (1 based)
*/
ms_obj_dump (data, len, "ScrollbarFmla");
ms_obj_dump (data, len, data_len_left, "ScrollbarFmla");