454
479
SO_CLASS (so)->print (so, ctx, width, height);
483
* sheet_object_draw_cairo :
485
* Draw a sheet object using cairo.
488
sheet_object_draw_cairo (SheetObject const *so, gpointer *data)
490
#ifdef GOFFICE_WITH_CAIRO
491
if (SO_CLASS (so)->draw_cairo) {
492
cairo_t *cairo = (cairo_t*) data;
493
SheetObjectAnchor const *anchor;
494
double x = 0., y = 0., width, height, cell_width, cell_height;
495
anchor = sheet_object_get_anchor (so);
496
width = sheet_col_get_distance_pts (so->sheet,
497
anchor->cell_bound.start.col,
498
anchor->cell_bound.end.col + 1);
499
height = sheet_row_get_distance_pts (so->sheet,
500
anchor->cell_bound.start.row,
501
anchor->cell_bound.end.row + 1);
502
cell_width = sheet_col_get_distance_pts (so->sheet,
503
anchor->cell_bound.start.col,
504
anchor->cell_bound.start.col + 1);
505
cell_height = sheet_row_get_distance_pts (so->sheet,
506
anchor->cell_bound.start.row,
507
anchor->cell_bound.start.row + 1);
508
switch (anchor->type[0]) {
509
case SO_ANCHOR_UNKNOWN:
510
case SO_ANCHOR_PERCENTAGE_FROM_COLROW_START:
511
x = cell_width * anchor->offset[0];
513
case SO_ANCHOR_PERCENTAGE_FROM_COLROW_END:
514
x = cell_width * (1. - anchor->offset[0]);
516
case SO_ANCHOR_PTS_FROM_COLROW_START:
517
x = anchor->offset[0];
519
case SO_ANCHOR_PTS_FROM_COLROW_END:
520
x = cell_width - anchor->offset[0];
526
switch (anchor->type[1]) {
527
case SO_ANCHOR_UNKNOWN:
528
case SO_ANCHOR_PERCENTAGE_FROM_COLROW_START:
529
y = cell_height * anchor->offset[1];
531
case SO_ANCHOR_PERCENTAGE_FROM_COLROW_END:
532
y = cell_height * (1 - anchor->offset[1]);
534
case SO_ANCHOR_PTS_FROM_COLROW_START:
535
y = anchor->offset[1];
537
case SO_ANCHOR_PTS_FROM_COLROW_END:
538
y = cell_height - anchor->offset[1];
544
cell_width = sheet_col_get_distance_pts (so->sheet,
545
anchor->cell_bound.end.col,
546
anchor->cell_bound.end.col + 1);
547
cell_height = sheet_row_get_distance_pts (so->sheet,
548
anchor->cell_bound.end.row,
549
anchor->cell_bound.end.row + 1);
550
switch (anchor->type[2]) {
551
case SO_ANCHOR_UNKNOWN:
552
case SO_ANCHOR_PERCENTAGE_FROM_COLROW_START:
553
width -= cell_width * (1. - anchor->offset[2]);
555
case SO_ANCHOR_PERCENTAGE_FROM_COLROW_END:
556
width -= cell_width * anchor->offset[2];
558
case SO_ANCHOR_PTS_FROM_COLROW_START:
559
width -= cell_width - anchor->offset[2];
561
case SO_ANCHOR_PTS_FROM_COLROW_END:
562
width -= anchor->offset[2];
564
case SO_ANCHOR_PTS_ABSOLUTE:
565
width = anchor->offset[2];
570
switch (anchor->type[3]) {
571
case SO_ANCHOR_UNKNOWN:
572
case SO_ANCHOR_PERCENTAGE_FROM_COLROW_START:
573
height -= cell_height * (1 - anchor->offset[3]);
575
case SO_ANCHOR_PERCENTAGE_FROM_COLROW_END:
576
height -= cell_height * anchor->offset[3];
578
case SO_ANCHOR_PTS_FROM_COLROW_START:
579
height -= cell_height - anchor->offset[3];
581
case SO_ANCHOR_PTS_FROM_COLROW_END:
582
height -= anchor->offset[3];
584
case SO_ANCHOR_PTS_ABSOLUTE:
585
height = anchor->offset[3];
590
/* we don't need to save/restore cairo, the caller must do it */
591
cairo_translate (cairo, x, y);
592
SO_CLASS (so)->draw_cairo (so, cairo, width, height);
458
598
sheet_object_get_range (SheetObject const *so)