Commit 3e43f06e authored by Jody Goldberg's avatar Jody Goldberg

- Minor ratio adjustments.

- PictOpt ==2 has an IMDATA.  not all of them
- Apply zoom when parsing an anchor, not later.
parent 3107c955
1999-10-08 Jody Goldberg <jgoldberg@home.com>
* ms-excel-read.c : More minor tweaking of adjustment ratios.
We need some real documentation on this stuff.
* ms-escher.c (ms_escher_get_data) : Use printf instead of
g_return_if_fail. It makes it easier to debug when the messages ar
in line.
......@@ -8,6 +11,9 @@
possible.
(ms_obj_read_biff8_obj) : Looks like a PictOpt record in an object
signifies that the next BIFF record after the OBJ must be an IMDATA.
(ms_obj_parse_anchor) : Move the zoom application back here until we
split the anchors into distance and cell pairs. The old code was
zooming the col/row distances twice.
1999-10-08 Morten Welinder <terra@diku.dk>
......
......@@ -919,21 +919,18 @@ typedef enum
/* LengthMeasure - the type of a (length) measurement */
typedef enum
{
msodztypeMin = 0,
msodztypeDefault = 0, /* Default size, ignore the values */
msodztypeA = 1, /* Values are in EMUs */
msodztypeV = 2, /* Values are in pixels */
msodztypeShape = 3, /* Values are 16.16 fractions of shape size */
msodztypeFixedAspect = 4, /* Aspect ratio is fixed */
msodztypeAFixed = 5, /* EMUs, fixed aspect ratio */
msodztypeVFixed = 6, /* Pixels, fixed aspect ratio */
msodztypeShapeFixed = 7, /* Proportion of shape, fixed aspect ratio */
msodztypeFixedAspectEnlarge
= 8, /* Aspect ratio is fixed, favor larger size */
msodztypeAFixedBig = 9, /* EMUs, fixed aspect ratio */
msodztypeVFixedBig = 10, /* Pixels, fixed aspect ratio */
msodztypeShapeFixedBig= 11, /* Proportion of shape, fixed aspect ratio */
msodztypeMax = 11
measure_Default = 0, /* Default size, ignore the values */
measure_A = 1, /* Values are in EMUs */
measure_V = 2, /* Values are in pixels */
measure_Shape = 3, /* Values are 16.16 fractions of shape size */
measure_FixedAspect = 4, /* Aspect ratio is fixed */
measure_AFixed = 5, /* EMUs, fixed aspect ratio */
measure_VFixed = 6, /* Pixels, fixed aspect ratio */
measure_ShapeFixed = 7, /* Proportion of shape, fixed aspect ratio */
measure_FixedAspectEnlarge = 8, /* Aspect ratio is fixed, favor larger size */
measure_AFixedBig = 9, /* EMUs, fixed aspect ratio */
measure_VFixedBig = 10, /* Pixels, fixed aspect ratio */
measure_ShapeFixedBig= 11, /* Proportion of shape, fixed aspect ratio */
} LengthMeasure;
typedef enum
......@@ -955,23 +952,19 @@ typedef enum
/* Colours in a shaded fill. */
typedef enum
{
msoshadeNone = 0, /* Interpolate without correction between RGBs */
msoshadeGamma = 1, /* Apply gamma correction to colors */
msoshadeSigma = 2, /* Apply a sigma transfer function to position */
msoshadeBand = 4, /* Add a flat band at the start of the shade */
msoshadeOneColor = 8, /* This is a one color shade */
/* A parameter for the band or sigma function can be stored in the top
16 bits of the value - this is a proportion of *each* band of the
shade to make flat (or the approximate equal value for a sigma
function). NOTE: the parameter is not used for the sigma function,
instead a built in value is used. This value should not be changed
from the default! */
msoshadeParameterShift = 16,
msoshadeParameterMask = 0xffff0000,
msoshadeDefault = (msoshadeGamma|msoshadeSigma|
(16384<<msoshadeParameterShift))
shade_None = 0, /* Interpolate without correction between RGBs */
shade_Gamma = 1, /* Apply gamma correction to colors */
shade_Sigma = 2, /* Apply a sigma transfer function to position */
shade_Band = 4, /* Add a flat band at the start of the shade */
shade_OneColor = 8, /* This is a one color shade */
/* It looks like the top 16 bits of the val can be used as a parameter.
* The Sigma shade style seems to hard code that to be 0x4000 ??
*/
shade_ParamShift = 16,
shade_ParamMask = 0xffff0000,
shade_Default = (shade_Gamma|shade_Sigma|(0x4000<<shade_ParamShift))
} ShadeType;
/* LineStyle - compound line style */
......@@ -1322,7 +1315,7 @@ ms_escher_read_OPT (MSEscherState * state, MSEscherHeader * h)
case 403 : name = "long fillRectRight"; break;
/* 0 : */
case 404 : name = "long fillRectBottom"; break;
/* Default : */
/* measure_Default : */
case 405 : name = "LengthMeasure fillDztype"; break;
/* 0 : Special shades */
case 406 : name = "long fillShadePreset"; break;
......@@ -1336,7 +1329,7 @@ ms_escher_read_OPT (MSEscherState * state, MSEscherHeader * h)
case 410 : name = "long fillShapeOriginX"; break;
/* 0 : */
case 411 : name = "long fillShapeOriginY"; break;
/* Default : Type of shading, if a shaded (gradient) fill. */
/* shade_Default : Type of shading, if a shaded (gradient) fill. */
case 412 : name = "ShadeType fillShadeType"; break;
/* TRUE : Is shape filled? */
case 443 : name = "bool fFilled"; break;
......@@ -1369,7 +1362,7 @@ ms_escher_read_OPT (MSEscherState * state, MSEscherHeader * h)
case 456 : name = "long lineFillWidth"; break;
/* 0 : */
case 457 : name = "long lineFillHeight"; break;
/* Default : How to interpret fillWidth/Height numbers. */
/* measure_Default : How to interpret fillWidth/Height numbers. */
case 458 : name = "LengthMeasure lineFillDztype"; break;
/* 9525 : A units; 1pt == 12700 EMUs */
case 459 : name = "long lineWidth"; break;
......
......@@ -2175,12 +2175,12 @@ ms_excel_read_cell (BiffQuery *q, ExcelSheet *sheet)
#endif
/* FIXME : the height is specified in 1/20 of a point.
* but we can not assume that 1pt = 1pixel.
* MS seems to assume that it is closer to 1point = .7 pixels
* MS seems to assume that it is closer to 1point = .75 pixels
* verticaly.
*/
if ((height&0x8000) == 0)
sheet_row_set_height (sheet->gnum_sheet, row,
height/(20 * .7), TRUE);
height/(20 * .75), TRUE);
if (flags & 0x80) {
#ifndef NO_DEBUG_EXCEL
......@@ -2225,11 +2225,12 @@ ms_excel_read_cell (BiffQuery *q, ExcelSheet *sheet)
* FIXME FIXME FIXME
* 1) As a default 12 seems seems to match the sheet I
* calibrated against.
* 2) the docs say charwidth not height. Is this correct ?
* 2) the docs say charwidth not height. Assume that
* width = 1.2 * height ?
*/
if ((xf = ms_excel_get_xf (sheet, cols_xf)) != NULL &&
(fd = ms_excel_get_font (sheet, xf->font_idx)))
char_width = fd->height / 20.;
char_width = 1.2 *fd->height / 20.;
else
char_width = 12.;
......
......@@ -37,14 +37,12 @@ extern int ms_excel_read_debug;
#define GR_COMMON_OBJ_DATA 0x15
/*
* Attempt to install ab object in supplied work book.
* NOTE : The MSObj is freed by this routine
* Attempt to install an object in supplied work book.
*/
gboolean
ms_obj_realize (MSObj *obj, ExcelWorkbook *wb, ExcelSheet *sheet)
{
int *anchor = NULL, i;
float zoom;
int *anchor = NULL;
g_return_val_if_fail (sheet != NULL, TRUE);
......@@ -53,10 +51,6 @@ ms_obj_realize (MSObj *obj, ExcelWorkbook *wb, ExcelSheet *sheet)
anchor = obj->anchor;
zoom = sheet->gnum_sheet->last_zoom_factor_used;
for (i = 0; i < 4; i++)
anchor[i] *= zoom;
switch (obj->gnumeric_type) {
case SHEET_OBJECT_BUTTON :
sheet_object_create_button (sheet->gnum_sheet,
......@@ -165,6 +159,7 @@ ms_parse_object_anchor (int anchor[4],
/* Words 0, 4, 8, 12 : The row/col of the corners */
/* Words 2, 6, 10, 14 : distance from cell edge measured in 1/1024 of an inch */
int i;
float const zoom = sheet->last_zoom_factor_used;
/* FIXME : How to handle objects not in sheets ?? */
g_return_val_if_fail (sheet != NULL, TRUE);
......@@ -173,26 +168,32 @@ ms_parse_object_anchor (int anchor[4],
guint16 const pos = MS_OLE_GET_GUINT16 (data + 4 * i);
/* FIXME : we are slightly off. Tweak the pixels/inch ratio
* to make this come out on my screen for pic.xls.
* 66 pixels/inch seems correct ???
* See BIFF_COLINFO or BIFF_ROW for more info
*
* This constant should be made into a std routine somewhere.
*/
float margin = (MS_OLE_GET_GUINT16 (data + 4 * i + 2) / (1024. / 66.));
float const tmp = (i&1) /* odds are rows */
? sheet_row_get_unit_distance (sheet, 0, pos)
: sheet_col_get_unit_distance (sheet, 0, pos);
float margin = (MS_OLE_GET_GUINT16 (data + 4 * i + 2) / (1024. / 72.));
int tmp;
if (i&1) { /* odds are rows */
tmp = sheet_row_get_unit_distance (sheet, 0, pos);
margin /= .75;
} else {
tmp = sheet_col_get_unit_distance (sheet, 0, pos);
margin *= .75;
}
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 1) {
printf ("%f units (%d pixels) from ",
margin, (int)(margin));
if (i & 1)
printf ("row %d;\n", pos + 1);
else
printf ("col %s (%d);\n", col_name(pos), pos);
if (ms_excel_read_debug > 1) {
}
#endif
margin *= zoom;
margin += tmp;
anchor[i] = (int)margin;
......@@ -370,10 +371,24 @@ ms_obj_read_biff8_obj (BiffQuery *q, ExcelWorkbook * wb, Sheet * sheet, MSObj *
break;
case GR_PICTURE_OPTIONS:
ms_obj_dump (data, len, "PictOpt");
{
guint16 pict_opt;
g_return_val_if_fail (len == 2, TRUE);
next_biff_record_is_imdata = TRUE;
pict_opt = MS_OLE_GET_GUINT16(data+4);
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug >= 1) {
printf ("{ /* PictOpt */\n");
printf ("value = %d;\n", pict_opt);
printf ("}; /* PictOpt */\n");
}
#endif
/* A value of 2 seems to indicate an IMDATA follows */
next_biff_record_is_imdata = (pict_opt == 2);
break;
}
case GR_PICTURE_FORMULA:
ms_obj_dump (data, len, "PictFormula");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment