Commit e0447f85 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

:types) : simplfy to remove the vector 'type' the offsets are now always

2006-12-19  Jody Goldberg <jody@gnome.org>

	* src/sheet-object.h (SheetObjectAnchor::types) : simplfy to remove
	  the vector 'type' the offsets are now always as percentages of cell
	  size relative to the cell_bound.  The parent, GODrawingAnchor will
	  eventually have the absolute positions, and the sheet object itself
	  will specify how which set of coords in normative.
parent ab82e865
2006-12-19 Jody Goldberg <jody@gnome.org>
* src/sheet-object.h (SheetObjectAnchor::types) : simplfy to remove
the vector 'type' the offsets are now always as percentages of cell
size relative to the cell_bound. The parent, GODrawingAnchor will
eventually have the absolute positions, and the sheet object itself
will specify how which set of coords in normative.
2006-12-18 Jody Goldberg <jody@gnome.org>
* src/format-template.c (xml_read_format_template_members) : revert
......
......@@ -335,35 +335,9 @@ go_gnm_component_print (GOComponent *component, GnomePrintContext *gpc,
cell_height = sheet_row_get_distance_pts (so->sheet,
anchor->cell_bound.start.row,
anchor->cell_bound.start.row + 1);
switch (anchor->type[0]) {
case SO_ANCHOR_UNKNOWN:
case SO_ANCHOR_PERCENTAGE_FROM_COLROW_START:
x = cell_width * anchor->offset[0];
break;
case SO_ANCHOR_PTS_FROM_COLROW_START:
x = anchor->offset[0];
break;
case SO_ANCHOR_PTS_FROM_COLROW_END:
x = cell_width - anchor->offset[0];
break;
default:
break;
}
x = cell_width * anchor->offset[0];
width -= x;
switch (anchor->type[1]) {
case SO_ANCHOR_UNKNOWN:
case SO_ANCHOR_PERCENTAGE_FROM_COLROW_START:
y = cell_height * anchor->offset[1];
break;
case SO_ANCHOR_PTS_FROM_COLROW_START:
y = anchor->offset[1];
break;
case SO_ANCHOR_PTS_FROM_COLROW_END:
y = cell_height - anchor->offset[1];
break;
default:
break;
}
y = cell_height * anchor->offset[1];
height -= y;
cell_width = sheet_col_get_distance_pts (so->sheet,
anchor->cell_bound.end.col,
......@@ -371,40 +345,9 @@ go_gnm_component_print (GOComponent *component, GnomePrintContext *gpc,
cell_height = sheet_row_get_distance_pts (so->sheet,
anchor->cell_bound.end.row,
anchor->cell_bound.end.row + 1);
switch (anchor->type[2]) {
case SO_ANCHOR_UNKNOWN:
case SO_ANCHOR_PERCENTAGE_FROM_COLROW_START:
width -= cell_width * (1. - anchor->offset[2]);
break;
case SO_ANCHOR_PTS_FROM_COLROW_START:
width -= cell_width - anchor->offset[2];
break;
case SO_ANCHOR_PTS_FROM_COLROW_END:
width -= anchor->offset[2];
break;
case SO_ANCHOR_PTS_ABSOLUTE:
width = anchor->offset[2];
break;
default:
break;
}
switch (anchor->type[3]) {
case SO_ANCHOR_UNKNOWN:
case SO_ANCHOR_PERCENTAGE_FROM_COLROW_START:
height -= cell_height * (1 - anchor->offset[3]);
break;
case SO_ANCHOR_PTS_FROM_COLROW_START:
height -= cell_height - anchor->offset[3];
break;
case SO_ANCHOR_PTS_FROM_COLROW_END:
height -= anchor->offset[3];
break;
case SO_ANCHOR_PTS_ABSOLUTE:
height = anchor->offset[3];
break;
default:
break;
}
width -= cell_width * (1. - anchor->offset[2]);
height -= cell_height * (1 - anchor->offset[3]);
gnome_print_gsave (gpc);
gnome_print_translate (gpc, xoffset + x, - yoffset - y);
sheet_object_print (so, gpc, width, height);
......
......@@ -573,7 +573,7 @@
<xsd:attributeGroup name="ObjectAnchor">
<xsd:attribute name="ObjectBound" type="xsd:string" use="required"/>
<xsd:attribute name="ObjectOffset" type="gnm:offsets" use="required"/>
<xsd:attribute name="ObjectAnchorType" type="gnm:anchor_type" use="required"/>
<xsd:attribute name="ObjectAnchorType" type="gnm:anchor_type" use="optional"/>
<xsd:attribute name="Direction" type="gnm:direction" use="required"/>
</xsd:attributeGroup>
......@@ -707,6 +707,7 @@
</xsd:restriction>
</xsd:simpleType>
<!-- As of 1.7.7 this is deprecated -->
<xsd:simpleType name="anchor_type">
<xsd:restriction base="xsd:string">
<!-- if this seems hard to read, it purportedly describes 4
......
2006-12-19 Jody Goldberg <jody@gnome.org>
* ms-excel-write.c (excel_write_autofilter_objs) : minor
simplification.
2006-12-19 Jody Goldberg <jody@gnome.org>
* xlsx-read.c (xlsx_get_num_fmt) : handle the standard builtins
......
......@@ -3292,8 +3292,8 @@ ms_excel_chart_read (BiffQuery *q, MSContainer *container,
if (full_page != NULL) {
static GnmRange const fixed_size = { { 1, 1 }, { 12, 32 } };
SheetObjectAnchor anchor;
sheet_object_anchor_init (&anchor,
&fixed_size, NULL, NULL, GOD_ANCHOR_DIR_DOWN_RIGHT);
sheet_object_anchor_init (&anchor, &fixed_size, NULL,
GOD_ANCHOR_DIR_DOWN_RIGHT);
sheet_object_set_anchor (sog, &anchor);
sheet_object_set_sheet (sog, full_page);
g_object_unref (sog);
......
......@@ -409,8 +409,7 @@ ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
((flip_h == NULL) ? GOD_ANCHOR_DIR_RIGHT : 0) |
((flip_v == NULL) ? GOD_ANCHOR_DIR_DOWN : 0);
sheet_object_anchor_init (&anchor, &range,
offsets, NULL, direction);
sheet_object_anchor_init (&anchor, &range, offsets, direction);
sheet_object_set_anchor (so, &anchor);
sheet_object_set_sheet (so, esheet->sheet);
......@@ -3633,7 +3632,7 @@ excel_read_COLINFO (BiffQuery *q, ExcelReadSheet *esheet)
guint16 const xf = GSF_LE_GET_GUINT16 (q->data + 6);
guint16 const options = GSF_LE_GET_GUINT16 (q->data + 8);
gboolean hidden = (options & 0x0001) != 0;
/*gboolean const customWidth= (options & 0x0002) != 0; /* undocumented */
/*gboolean const customWidth= (options & 0x0002) != 0; undocumented */
gboolean const bestFit = (options & 0x0004) != 0; /* undocumented */
gboolean const collapsed = (options & 0x1000) != 0;
unsigned const outline_level = (unsigned)((options >> 8) & 0x7);
......@@ -3678,7 +3677,7 @@ excel_read_COLINFO (BiffQuery *q, ExcelReadSheet *esheet)
for (i = firstcol; i <= lastcol; i++) {
/* Kludge : we should really use
* hard_size == customWidth && !bestFit
* but these flags are undocumented and gnumeric < 1.75 && OOo
* but these flags are undocumented and gnumeric < 1.7.5 && OOo
* export them as 0. So we are reduced to using */
sheet_col_set_size_pts (esheet->sheet, i, width, !bestFit);
if (outline_level > 0 || collapsed)
......
......@@ -3682,12 +3682,6 @@ excel_write_autofilter_objs (ExcelWriteSheet *esheet)
0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
/* ClientData */ 0, 0, 0x11, 0xf0, 0, 0, 0, 0
};
static SheetObjectAnchorType const anchor_types[] = {
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START,
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START,
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START,
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START
};
static float offsets[] = { 0., 0., 0., 0. };
guint8 *data, buf [sizeof obj_v8];
......@@ -3708,7 +3702,7 @@ excel_write_autofilter_objs (ExcelWriteSheet *esheet)
cond = gnm_filter_get_condition (filter, i);
r.end.col = 1 + (r.start.col = filter->r.start.col + i);
sheet_object_anchor_init (&anchor, &r, offsets, anchor_types,
sheet_object_anchor_init (&anchor, &r, offsets,
GOD_ANCHOR_DIR_DOWN_RIGHT);
if (bp->version >= MS_BIFF_V8) {
guint32 id = excel_write_start_drawing (esheet);
......
......@@ -1565,8 +1565,8 @@ od_draw_frame (GsfXMLIn *xin, xmlChar const **attrs)
frame_offset[1] = (y/row->size_pts);
frame_offset[2] = (width/col->size_pts);
frame_offset[3] = (height/row->size_pts);
sheet_object_anchor_init (&state->cur_frame.anchor, &cell_base, frame_offset, NULL, GOD_ANCHOR_DIR_DOWN_RIGHT);
sheet_object_anchor_init (&state->cur_frame.anchor, &cell_base, frame_offset,
GOD_ANCHOR_DIR_DOWN_RIGHT);
}
static void
......
......@@ -767,7 +767,7 @@ ig_obj_create_begin (ItemGrid *ig, GdkEventButton *event)
coords[0] = coords[2] = event->x;
coords[1] = coords[3] = event->y;
sheet_object_anchor_init (&anchor, NULL, NULL, NULL, GOD_ANCHOR_DIR_DOWN_RIGHT);
sheet_object_anchor_init (&anchor, NULL, NULL, GOD_ANCHOR_DIR_DOWN_RIGHT);
scg_object_coords_to_anchor (ig->scg, coords, &anchor);
sheet_object_set_anchor (so, &anchor);
sheet_object_set_sheet (so, scg_sheet (ig->scg));
......
......@@ -1985,7 +1985,7 @@ scg_mode_create_object (SheetControlGUI *scg, SheetObject *so)
static int
calc_obj_place (GnmCanvas *gcanvas, int canvas_coord, gboolean is_col,
SheetObjectAnchorType anchor_type, float *offset)
float *offset)
{
int origin, colrow;
ColRowInfo const *cri;
......@@ -2376,21 +2376,19 @@ scg_object_coords_to_anchor (SheetControlGUI const *scg,
tmp[2], tmp[3],
pixels + 2, pixels + 3);
in_out->cell_bound.start.col = calc_obj_place (gcanvas, pixels[0], TRUE,
in_out->type[0], in_out->offset + 0);
in_out->offset + 0);
in_out->cell_bound.start.row = calc_obj_place (gcanvas, pixels[1], FALSE,
in_out->type[1], in_out->offset + 1);
in_out->offset + 1);
in_out->cell_bound.end.col = calc_obj_place (gcanvas, pixels[2], TRUE,
in_out->type[2], in_out->offset + 2);
in_out->offset + 2);
in_out->cell_bound.end.row = calc_obj_place (gcanvas, pixels[3], FALSE,
in_out->type[3], in_out->offset + 3);
in_out->offset + 3);
}
static double
cell_offset_calc_pixel (Sheet const *sheet, int i, gboolean is_col,
SheetObjectAnchorType anchor_type, float offset)
cell_offset_calc_pixel (Sheet const *sheet, int i, gboolean is_col, float offset)
{
ColRowInfo const *cri = sheet_colrow_get_info (sheet, i, is_col);
/* TODO : handle other anchor types */
return offset * cri->size_pixels;
}
......@@ -2417,13 +2415,13 @@ scg_object_anchor_to_coords (SheetControlGUI const *scg,
pixels[3] = pixels[1] + scg_colrow_distance_get (scg, FALSE,
r->start.row, r->end.row);
pixels[0] += cell_offset_calc_pixel (sheet, r->start.col,
TRUE, anchor->type[0], anchor->offset[0]);
TRUE, anchor->offset[0]);
pixels[1] += cell_offset_calc_pixel (sheet, r->start.row,
FALSE, anchor->type[1], anchor->offset[1]);
FALSE, anchor->offset[1]);
pixels[2] += cell_offset_calc_pixel (sheet, r->end.col,
TRUE, anchor->type[2], anchor->offset[2]);
TRUE, anchor->offset[2]);
pixels[3] += cell_offset_calc_pixel (sheet, r->end.row,
FALSE, anchor->type[3], anchor->offset[3]);
FALSE, anchor->offset[3]);
direction = anchor->base.direction;
if (direction == GOD_ANCHOR_DIR_UNKNOWN)
......@@ -3183,8 +3181,8 @@ scg_paste_image (SheetControlGUI *scg, GnmRange *where,
{
SheetObjectAnchor anchor;
sheet_object_anchor_init (&anchor, where, NULL, NULL,
GOD_ANCHOR_DIR_DOWN_RIGHT);
sheet_object_anchor_init (&anchor, where, NULL,
GOD_ANCHOR_DIR_DOWN_RIGHT);
scg_image_create (scg, &anchor, data, len);
}
......@@ -3192,11 +3190,11 @@ static void
scg_drag_receive_img_data (SheetControlGUI *scg, double x, double y,
guint8 const *data, unsigned len)
{
SheetObjectAnchor anchor;
double coords[4];
SheetObjectAnchor anchor;
sheet_object_anchor_init (&anchor, NULL, NULL, NULL,
GOD_ANCHOR_DIR_DOWN_RIGHT);
sheet_object_anchor_init (&anchor, NULL, NULL,
GOD_ANCHOR_DIR_DOWN_RIGHT);
coords[0] = coords[2] = x;
coords[1] = coords[3] = y;
scg_object_coords_to_anchor (scg, coords, &anchor);
......@@ -3263,8 +3261,8 @@ scg_paste_cellregion (SheetControlGUI *scg, double x, double y,
SheetObjectAnchor anchor;
double coords[4];
sheet_object_anchor_init (&anchor, NULL, NULL, NULL,
GOD_ANCHOR_DIR_DOWN_RIGHT);
sheet_object_anchor_init (&anchor, NULL, NULL,
GOD_ANCHOR_DIR_DOWN_RIGHT);
coords[0] = coords[2] = x;
coords[1] = coords[3] = y;
scg_object_coords_to_anchor (scg, coords, &anchor);
......
......@@ -516,7 +516,7 @@ gnm_filter_add_field (GnmFilter *filter, int i)
fcombo->filter = filter;
tmp.start.row = tmp.end.row = filter->r.start.row;
tmp.start.col = tmp.end.col = filter->r.start.col + i;
sheet_object_anchor_init (&anchor, &tmp, a_offsets, NULL,
sheet_object_anchor_init (&anchor, &tmp, a_offsets,
GOD_ANCHOR_DIR_DOWN_RIGHT);
sheet_object_set_anchor (SHEET_OBJECT (fcombo), &anchor);
sheet_object_set_sheet (SHEET_OBJECT (fcombo), filter->sheet);
......
......@@ -416,7 +416,7 @@ cell_comment_set_cell (GnmComment *cc, GnmCellPos const *pos)
r.start = r.end = *pos;
sheet_object_anchor_init (&anchor, &r, a_offsets,
NULL, GOD_ANCHOR_DIR_DOWN_RIGHT);
GOD_ANCHOR_DIR_DOWN_RIGHT);
sheet_object_set_anchor (SHEET_OBJECT (cc), &anchor);
}
......
......@@ -195,10 +195,8 @@ sheet_object_init (GObject *object)
so->anchor.cell_bound.end.col = so->anchor.cell_bound.end.row = 1;
so->anchor.base.direction = GOD_ANCHOR_DIR_UNKNOWN;
for (i = 4; i-- > 0 ;) {
for (i = 4; i-- > 0 ;)
so->anchor.offset [i] = 0.;
so->anchor.type [i] = SO_ANCHOR_UNKNOWN;
}
}
static void
......@@ -511,35 +509,10 @@ sheet_object_draw_cairo (SheetObject const *so, gpointer *data)
cell_height = sheet_row_get_distance_pts (so->sheet,
anchor->cell_bound.start.row,
anchor->cell_bound.start.row + 1);
switch (anchor->type[0]) {
case SO_ANCHOR_UNKNOWN:
case SO_ANCHOR_PERCENTAGE_FROM_COLROW_START:
x = cell_width * anchor->offset[0];
break;
case SO_ANCHOR_PTS_FROM_COLROW_START:
x = anchor->offset[0];
break;
case SO_ANCHOR_PTS_FROM_COLROW_END:
x = cell_width - anchor->offset[0];
break;
default:
break;
}
x = cell_width * anchor->offset[0];
width -= x;
switch (anchor->type[1]) {
case SO_ANCHOR_UNKNOWN:
case SO_ANCHOR_PERCENTAGE_FROM_COLROW_START:
y = cell_height * anchor->offset[1];
break;
case SO_ANCHOR_PTS_FROM_COLROW_START:
y = anchor->offset[1];
break;
case SO_ANCHOR_PTS_FROM_COLROW_END:
y = cell_height - anchor->offset[1];
break;
default:
break;
}
y = cell_height * anchor->offset[1];
height -= y;
cell_width = sheet_col_get_distance_pts (so->sheet,
anchor->cell_bound.end.col,
......@@ -547,40 +520,9 @@ sheet_object_draw_cairo (SheetObject const *so, gpointer *data)
cell_height = sheet_row_get_distance_pts (so->sheet,
anchor->cell_bound.end.row,
anchor->cell_bound.end.row + 1);
switch (anchor->type[2]) {
case SO_ANCHOR_UNKNOWN:
case SO_ANCHOR_PERCENTAGE_FROM_COLROW_START:
width -= cell_width * (1. - anchor->offset[2]);
break;
case SO_ANCHOR_PTS_FROM_COLROW_START:
width -= cell_width - anchor->offset[2];
break;
case SO_ANCHOR_PTS_FROM_COLROW_END:
width -= anchor->offset[2];
break;
case SO_ANCHOR_PTS_ABSOLUTE:
width = anchor->offset[2];
break;
default:
break;
}
switch (anchor->type[3]) {
case SO_ANCHOR_UNKNOWN:
case SO_ANCHOR_PERCENTAGE_FROM_COLROW_START:
height -= cell_height * (1 - anchor->offset[3]);
break;
case SO_ANCHOR_PTS_FROM_COLROW_START:
height -= cell_height - anchor->offset[3];
break;
case SO_ANCHOR_PTS_FROM_COLROW_END:
height -= anchor->offset[3];
break;
case SO_ANCHOR_PTS_ABSOLUTE:
height = anchor->offset[3];
break;
default:
break;
}
width -= cell_width * (1. - anchor->offset[2]);
height -= cell_height * (1 - anchor->offset[3]);
/* we don't need to save/restore cairo, the caller must do it */
cairo_translate (cairo, x, y);
SO_CLASS (so)->draw_cairo (so, cairo, width, height);
......@@ -627,10 +569,9 @@ sheet_object_anchor_cpy (SheetObjectAnchor *dst, SheetObjectAnchor const *src)
static double
cell_offset_calc_pt (Sheet const *sheet, int i, gboolean is_col,
SheetObjectAnchorType anchor_type, float offset)
float offset)
{
ColRowInfo const *cri = sheet_colrow_get_info (sheet, i, is_col);
/* TODO : handle other anchor types */
return offset * cri->size_pts;
}
......@@ -688,13 +629,13 @@ sheet_object_anchor_to_pts (SheetObjectAnchor const *anchor,
r->start.row, r->end.row);
res_pts [0] += cell_offset_calc_pt (sheet, r->start.col,
TRUE, anchor->type [0], anchor->offset [0]);
TRUE, anchor->offset [0]);
res_pts [1] += cell_offset_calc_pt (sheet, r->start.row,
FALSE, anchor->type [1], anchor->offset [1]);
FALSE, anchor->offset [1]);
res_pts [2] += cell_offset_calc_pt (sheet, r->end.col,
TRUE, anchor->type [2], anchor->offset [2]);
TRUE, anchor->offset [2]);
res_pts [3] += cell_offset_calc_pt (sheet, r->end.row,
FALSE, anchor->type [3], anchor->offset [3]);
FALSE, anchor->offset [3]);
}
/**
......@@ -937,14 +878,17 @@ sheet_object_rubber_band_directly (SheetObject const *so)
/**
* sheet_object_anchor_init :
* @anchor : #SheetObjectAnchor
* @r : #GnmRange
* @offsets : float[4]
* @direction : #GODrawingAnchorDir
*
* A utility routine to initialize an anchor. Useful in case we add
* fields in the future and want to ensure that everything is initialized.
* A utility routine to initialize an anchor. Useful in case we change fields
* in the future and want to ensure that everything is initialized.
**/
void
sheet_object_anchor_init (SheetObjectAnchor *anchor,
GnmRange const *r, float const *offsets,
SheetObjectAnchorType const *types,
GODrawingAnchorDir direction)
{
int i;
......@@ -962,18 +906,6 @@ sheet_object_anchor_init (SheetObjectAnchor *anchor,
for (i = 4; i-- > 0 ; )
anchor->offset [i] = offsets [i];
if (types == NULL) {
static SheetObjectAnchorType const defaultVal [4] = {
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START,
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START,
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START,
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START
};
types = defaultVal;
}
for (i = 4; i-- > 0 ; )
anchor->type [i] = types [i];
anchor->base.direction = direction;
/* TODO : add sanity checking to handle offsets past edges of col/row */
}
......
......@@ -32,23 +32,11 @@ typedef struct _GODrawingAnchor {
} GODrawingAnchor;
/***********************************************************/
typedef enum {
SO_ANCHOR_UNKNOWN = 0x00,
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START = 0x10,
/* TODO : implement these */
SO_ANCHOR_PTS_FROM_COLROW_START = 0x20,
SO_ANCHOR_PTS_FROM_COLROW_END = 0x21,
/* only allowed for Anchors 2-3 to support fixed size */
SO_ANCHOR_PTS_ABSOLUTE = 0x30
} SheetObjectAnchorType;
struct _SheetObjectAnchor {
GODrawingAnchor base;
GnmRange cell_bound; /* cellpos containg corners */
float offset [4];
SheetObjectAnchorType type [4];
GnmRange cell_bound; /* cellpos containing corners */
float offset [4]; /* offsets from the top left (in LTR of cell_bound) */
};
#define SHEET_OBJECT_TYPE (sheet_object_get_type ())
......@@ -118,7 +106,6 @@ void sheet_object_anchor_to_pts (SheetObjectAnchor const *anchor,
void sheet_object_anchor_init (SheetObjectAnchor *anchor,
GnmRange const *cell_bound,
float const offset [4],
SheetObjectAnchorType const type [4],
GODrawingAnchorDir direction);
void sheet_object_anchor_cpy (SheetObjectAnchor *dst,
SheetObjectAnchor const *src);
......
......@@ -280,7 +280,7 @@ wb_view_style_feedback (WorkbookView *wbv)
range_init_cellpos_size (&r, &sv->edit_pos, 1, 1);
wbv->validation_combo = gnm_validation_combo_new (val, sv);
sheet_object_anchor_init (&anchor, &r, a_offsets, NULL,
sheet_object_anchor_init (&anchor, &r, a_offsets,
GOD_ANCHOR_DIR_DOWN_RIGHT);
sheet_object_set_anchor (wbv->validation_combo, &anchor);
sheet_object_set_sheet (wbv->validation_combo, sv_sheet (sv));
......
......@@ -17,9 +17,10 @@ typedef enum
GNM_XML_V10, /* >= 1.0.3 remove useless Content node in cells */
GNM_XML_V11, /* >= 1.7.0 jump to sax exporter */
GNM_XML_V12, /* >= 1.7.3 Fix swapping of Value and ValueType in sax exporter */
GNM_XML_V13, /* >= 1.7.7 Deprecate ObjectAnchorType */
/* NOTE : Keep this up to date (and in sync with the schema) */
GNM_XML_LATEST = GNM_XML_V12
GNM_XML_LATEST = GNM_XML_V13
} GnumericXMLVersion;
#endif /* GNUMERIC_XML_IO_VERSION_H */
......@@ -1697,6 +1697,8 @@ xml_read_sheet_object (XmlParseContext const *ctxt, xmlNodePtr tree)
xmlFree (tmp);
}
/* DEPRECATED : There was once an 'AnchorType' but it is now ignored */
#if 0
tmp = (char *) xmlGetProp (tree, (xmlChar *)"ObjectAnchorType");
if (tmp != NULL) {
int i[4], count;
......@@ -1706,6 +1708,7 @@ xml_read_sheet_object (XmlParseContext const *ctxt, xmlNodePtr tree)
so->anchor.type[count] = i[count];
xmlFree (tmp);
}
#endif
if (xml_node_get_int (tree, "Direction", &tmp_int))
so->anchor.base.direction = tmp_int;
......
......@@ -1611,6 +1611,10 @@ xml_sax_read_obj (GsfXMLIn *xin, gboolean needs_cleanup,
int tmp_int, i;
SheetObject *so;
SheetObjectClass *klass;
GnmRange anchor_r;
GODrawingAnchorDir anchor_dir;
SheetObjectAnchor anchor;
float f_tmp[4], *anchor_offset = NULL;
g_return_if_fail (state->so == NULL);
......@@ -1662,29 +1666,26 @@ xml_sax_read_obj (GsfXMLIn *xin, gboolean needs_cleanup,
state->so = so;
so->anchor.base.direction = GOD_ANCHOR_DIR_UNKNOWN;
anchor_dir = GOD_ANCHOR_DIR_UNKNOWN;
for (i = 0; attrs != NULL && attrs[i] && attrs[i+1] ; i += 2) {
if (!strcmp (attrs[i], "ObjectBound")) {
GnmRange r;
if (range_parse (&r, attrs[i+1]))
so->anchor.cell_bound = r;
} else if (!strcmp (attrs[i], "ObjectOffset")) {
sscanf (attrs[i+1], "%g %g %g %g",
so->anchor.offset +0, so->anchor.offset +1,
so->anchor.offset +2, so->anchor.offset +3);
} else if (!strcmp (attrs[i], "ObjectAnchorType")) {
int n[4], count;
sscanf (attrs[i+1], "%d %d %d %d", n+0, n+1, n+2, n+3);
for (count = 4; count-- > 0 ; )
so->anchor.type[count] = n[count];
} else if (gnm_xml_attr_int (attrs+i, "Direction", &tmp_int))
so->anchor.base.direction = tmp_int;
#if 0 /* There may be extra attributes that are handled by the objects */
if (!strcmp (attrs[i], "ObjectBound"))
range_parse (&anchor_r, attrs[i+1]);
else if (!strcmp (attrs[i], "ObjectOffset") &&
4 == sscanf (attrs[i+1], "%g %g %g %g",
f_tmp + 0, f_tmp + 1, f_tmp + 2, f_tmp + 3))
anchor_offset = f_tmp;
else if (gnm_xml_attr_int (attrs+i, "Direction", &tmp_int))
anchor_dir = tmp_int;
#if 0
/* Deprecated in 1.7.7 */
else if (!strcmp (attrs[i], "ObjectAnchorType"))
/* There may be extra attributes that are handled by the objects */
else
unknown_attr (xin, attrs+i);
#endif
}
sheet_object_anchor_init (&anchor, &anchor_r, anchor_offset, anchor_dir);
sheet_object_set_anchor (so, &anchor);
if (NULL != klass->prep_sax_parser)
(klass->prep_sax_parser) (so, xin, attrs);
......
......@@ -1032,10 +1032,6 @@ xml_write_objects (GnmOutputXML *state, GSList *ptr)
so->anchor.offset [0], so->anchor.offset [1],
so->anchor.offset [2], so->anchor.offset [3]);
gsf_xml_out_add_cstr (state->output, "ObjectOffset", buffer);
snprintf (buffer, sizeof (buffer), "%d %d %d %d",
so->anchor.type [0], so->anchor.type [1],
so->anchor.type [2], so->anchor.type [3]);
gsf_xml_out_add_cstr (state->output, "ObjectAnchorType", buffer);
gsf_xml_out_add_int (state->output, "Direction",
so->anchor.base.direction);
......
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