133
133
undo = attr_undo_new (HTML_TABLE_CELL_BGCOLOR);
134
134
undo->attr.color.color = cell->bg;
135
135
undo->attr.color.has_bg_color = cell->have_bg;
136
html_undo_add_action (e->undo,
136
html_undo_add_action (e->undo, e,
137
137
html_undo_action_new ("Set cell background color", table_cell_set_bg_color_undo_action,
138
138
HTML_UNDO_DATA (undo),
139
139
html_cursor_get_position (e->cursor),
173
173
undo = attr_undo_new (HTML_TABLE_CELL_BGPIXMAP);
174
174
undo->attr.pixmap = cell->have_bgPixmap ? g_strdup (cell->bgPixmap->url) : NULL;
175
html_undo_add_action (e->undo,
175
html_undo_add_action (e->undo, e,
176
176
html_undo_action_new ("Set cell background pixmap", table_cell_set_bg_pixmap_undo_action,
177
177
HTML_UNDO_DATA (undo),
178
178
html_cursor_get_position (e->cursor),
215
215
undo = attr_undo_new (HTML_TABLE_CELL_HALIGN);
216
216
undo->attr.halign = HTML_CLUE (cell)->halign;
217
html_undo_add_action (e->undo,
217
html_undo_add_action (e->undo, e,
218
218
html_undo_action_new ("Set cell horizontal align", table_cell_set_halign_undo_action,
219
219
HTML_UNDO_DATA (undo),
220
220
html_cursor_get_position (e->cursor),
253
253
undo = attr_undo_new (HTML_TABLE_CELL_VALIGN);
254
254
undo->attr.valign = HTML_CLUE (cell)->valign;
255
html_undo_add_action (e->undo,
255
html_undo_add_action (e->undo, e,
256
256
html_undo_action_new ("Set cell vertical align", table_cell_set_valign_undo_action,
257
257
HTML_UNDO_DATA (undo),
258
258
html_cursor_get_position (e->cursor),
292
292
undo = attr_undo_new (HTML_TABLE_CELL_NOWRAP);
293
293
undo->attr.no_wrap = cell->no_wrap;
294
html_undo_add_action (e->undo,
294
html_undo_add_action (e->undo, e,
295
295
html_undo_action_new ("Set cell wrapping", table_cell_set_no_wrap_undo_action,
296
296
HTML_UNDO_DATA (undo),
297
297
html_cursor_get_position (e->cursor),
332
332
undo = attr_undo_new (HTML_TABLE_CELL_HEADING);
333
333
undo->attr.heading = cell->heading;
334
html_undo_add_action (e->undo,
334
html_undo_add_action (e->undo, e,
335
335
html_undo_action_new ("Set cell style", table_cell_set_heading_undo_action,
336
336
HTML_UNDO_DATA (undo),
337
337
html_cursor_get_position (e->cursor),
374
374
undo = attr_undo_new (HTML_TABLE_CELL_WIDTH);
375
375
undo->attr.width.width = cell->fixed_width;
376
376
undo->attr.width.percent = cell->percent_width;
377
html_undo_add_action (e->undo,
377
html_undo_add_action (e->undo, e,
378
378
html_undo_action_new ("Set cell style", table_cell_set_width_undo_action,
379
379
HTML_UNDO_DATA (undo),
380
380
html_cursor_get_position (e->cursor),
467
467
undo = move_cell_rd_undo_new (cell->rspan, cell->cspan);
468
468
/* printf ("move %dx%d --> %dx%d\n", cell->row, cell->col, cell->row + rs, cell->col + cs); */
469
for (r = cell->row + cell->rspan - 1; r >= cell->row; r --)
470
for (c = cell->col + cell->cspan - 1; c >= cell->col; c --) {
469
for (r = cell->row + cell->rspan - 1; r >= cell->row; r--)
470
for (c = cell->col + cell->cspan - 1; c >= cell->col; c--) {
471
471
if (r > cell->row + cell->rspan - 1 - rs || c > cell->col + cell->cspan - 1 - cs) {
472
472
gint nr = rs + r - (rs ? cell->rspan : 0), nc = cs + c - (cs ? cell->cspan : 0);
474
474
/* printf ("exchange: %dx%d <--> %dx%d (%p)\n", rs + r, cs + c, nr, nc, t->cells [rs][nc]); */
475
t->cells [nr][nc] = t->cells [rs + r][cs + c];
476
if (t->cells [nr][nc]) {
477
struct Move *move = &undo->moved [(r - cell->row)*cell->cspan + c - cell->col];
475
t->cells[nr][nc] = t->cells[rs + r][cs + c];
476
if (t->cells[nr][nc]) {
477
struct Move *move = &undo->moved[(r - cell->row)*cell->cspan + c - cell->col];
479
html_table_cell_set_position (t->cells [nr][nc], nr, nc);
479
html_table_cell_set_position (t->cells[nr][nc], nr, nc);
480
480
move->rs = rs + r;
481
481
move->cs = cs + c;
488
488
if (r >= cell->row + rs && c >= cell->col + cs) {
489
if (t->cells [rs + r][cs + c] && t->cells [rs + r][cs + c]->col == cs + c && t->cells [rs + r][cs + c]->row == rs + r) {
489
if (t->cells[rs + r][cs + c] && t->cells[rs + r][cs + c]->col == cs + c && t->cells[rs + r][cs + c]->row == rs + r) {
490
490
/* printf ("move destroy: %dx%d\n", rs + r, cs + c); */
491
491
/* html_object_destroy (HTML_OBJECT (t->cells [rs + r][cs + c])); */
492
492
/* printf ("removed: %dx%d (%d, %d)\n", rs + r, cs + c, r - cell->row, c - cell->col); */
493
undo->removed [(r - cell->row)*cell->cspan + c - cell->col] = t->cells [r][c];
493
undo->removed[(r - cell->row)*cell->cspan + c - cell->col] = t->cells[r][c];
495
t->cells [r][c] = NULL;
495
t->cells[r][c] = NULL;
498
t->cells [rs + r][cs + c] = cell;
498
t->cells[rs + r][cs + c] = cell;
499
499
/* printf ("cell %dx%d <--\n", rs + r, cs + c); */
501
501
/* printf ("set %dx%d --> %dx%d\n", cell->row, cell->col, cell->row + rs, cell->col + cs); */
546
546
move_cell_rd_undo (HTMLTable *table, struct MoveCellRDUndo *undo)
548
HTMLTableCell *cell = table->cells [undo->move.rt][undo->move.ct];
548
HTMLTableCell *cell = table->cells[undo->move.rt][undo->move.ct];
551
for (r = 0; r < undo->rspan; r ++)
552
for (c = 0; c < undo->cspan; c ++)
553
if (undo->moved [r*undo->cspan + c].move) {
554
struct Move *move = &undo->moved [r*undo->cspan + c];
551
for (r = 0; r < undo->rspan; r++)
552
for (c = 0; c < undo->cspan; c++)
553
if (undo->moved[r*undo->cspan + c].move) {
554
struct Move *move = &undo->moved[r*undo->cspan + c];
556
556
/* printf ("move back: %dx%d --> %dx%d (%d, %d) %p\n", move->rt, move->ct, move->rs, move->cs, r, c, table->cells [move->rt][move->ct]); */
557
table->cells [move->rs][move->cs] = table->cells [move->rt][move->ct];
558
html_table_cell_set_position (table->cells [move->rs][move->cs], move->rs, move->cs);
559
table->cells [move->rt][move->ct] = NULL;
557
table->cells[move->rs][move->cs] = table->cells[move->rt][move->ct];
558
html_table_cell_set_position (table->cells[move->rs][move->cs], move->rs, move->cs);
559
table->cells[move->rt][move->ct] = NULL;
562
for (r = 0; r < cell->rspan; r ++)
563
for (c = 0; c < cell->cspan; c ++)
564
table->cells [undo->move.rt + r][undo->move.ct + c] = NULL;
565
for (r = 0; r < cell->rspan; r ++)
566
for (c = 0; c < cell->cspan; c ++)
567
table->cells [undo->move.rs + r][undo->move.cs + c] = cell;
562
for (r = 0; r < cell->rspan; r++)
563
for (c = 0; c < cell->cspan; c++)
564
table->cells[undo->move.rt + r][undo->move.ct + c] = NULL;
565
for (r = 0; r < cell->rspan; r++)
566
for (c = 0; c < cell->cspan; c++)
567
table->cells[undo->move.rs + r][undo->move.cs + c] = cell;
569
569
html_table_cell_set_position (cell, undo->move.rs, undo->move.cs);
585
585
expand_cspan_setup_undo (HTMLEngine *e, GSList *slist, gint cspan, guint position_before, HTMLUndoDirection dir)
587
html_undo_add_action (e->undo,
587
html_undo_add_action (e->undo, e,
588
588
html_undo_action_new ("Expand Column Span", expand_cspan_undo_action,
589
589
expand_undo_data_new (cspan, slist), html_cursor_get_position (e->cursor),
590
590
position_before),
600
600
gint r, c, *move_rows, max_move, add_cols;
602
602
move_rows = g_new0 (gint, cell->rspan);
603
for (r = cell->row; r < cell->row + cell->rspan; r ++)
604
for (c = cell->col + cell->cspan; c < MIN (cell->col + cspan, table->totalCols); c ++)
605
if (table->cells [r][c] && !html_clue_is_empty (HTML_CLUE (table->cells [r][c])) && move_rows [r - cell->row] == 0)
606
move_rows [r - cell->row] = cspan - (c - cell->col);
603
for (r = cell->row; r < cell->row + cell->rspan; r++)
604
for (c = cell->col + cell->cspan; c < MIN (cell->col + cspan, table->totalCols); c++)
605
if (table->cells[r][c] && !html_clue_is_empty (HTML_CLUE (table->cells[r][c])) && move_rows[r - cell->row] == 0)
606
move_rows[r - cell->row] = cspan - (c - cell->col);
609
for (r = 0; r < cell->rspan; r ++)
610
if (move_rows [r] > max_move)
611
max_move = move_rows [r];
609
for (r = 0; r < cell->rspan; r++)
610
if (move_rows[r] > max_move)
611
max_move = move_rows[r];
613
613
add_cols = MAX (max_move, cspan - (table->totalCols - cell->col));
614
614
/* printf ("max move: %d add: %d\n", max_move, add_cols); */
615
for (c = 0; c < add_cols; c ++)
615
for (c = 0; c < add_cols; c++)
616
616
html_table_insert_column (table, e, table->totalCols, NULL, dir);
618
618
if (max_move > 0) {
619
for (c = table->totalCols - max_move - 1; c >= cell->col + cspan - max_move; c --)
620
for (r = cell->row; r < cell->row + cell->rspan; r ++) {
621
HTMLTableCell *ccell = table->cells [r][c];
619
for (c = table->totalCols - max_move - 1; c >= cell->col + cspan - max_move; c--)
620
for (r = cell->row; r < cell->row + cell->rspan; r++) {
621
HTMLTableCell *ccell = table->cells[r][c];
623
623
if (ccell && ccell->col == c) {
624
624
slist = g_slist_prepend (slist, move_cell_rd (table, ccell, 0, max_move));
630
630
expand_cspan_setup_undo (e, slist, cell->cspan, position_before, dir);
631
631
cell->cspan = cspan;
632
for (r = cell->row; r < cell->row + cell->rspan; r ++)
633
for (c = cell->col; c < cell->col + cell->cspan; c ++)
634
table->cells [r][c] = cell;
632
for (r = cell->row; r < cell->row + cell->rspan; r++)
633
for (c = cell->col; c < cell->col + cell->cspan; c++)
634
table->cells[r][c] = cell;
636
636
html_object_change_set (HTML_OBJECT (cell), HTML_CHANGE_ALL);
667
667
collapse_cspan_setup_undo (HTMLEngine *e, gint cspan, guint position_before, HTMLUndoDirection dir)
669
html_undo_add_action (e->undo,
669
html_undo_add_action (e->undo, e,
670
670
html_undo_action_new ("Collapse Column Span", collapse_cspan_undo_action,
671
671
collapse_undo_data_new (cspan), html_cursor_get_position (e->cursor),
672
672
position_before),
683
683
table = HTML_TABLE (HTML_OBJECT (cell)->parent);
684
for (c = cell->col + cspan; c < cell->col + cell->cspan; c ++)
685
for (r = cell->row; r < cell->row + cell->rspan; r ++) {
686
table->cells [r][c] = NULL;
684
for (c = cell->col + cspan; c < cell->col + cell->cspan; c++)
685
for (r = cell->row; r < cell->row + cell->rspan; r++) {
686
table->cells[r][c] = NULL;
687
687
html_table_set_cell (table, r, c, html_engine_new_cell (e, table));
688
html_table_cell_set_position (table->cells [r][c], r, c);
688
html_table_cell_set_position (table->cells[r][c], r, c);
691
691
collapse_cspan_setup_undo (e, cell->cspan, position_before, dir);
719
719
gint r, c, *move_cols, max_move;
721
721
move_cols = g_new0 (gint, cell->cspan);
722
for (c = cell->col; c < cell->col + cell->cspan; c ++)
723
for (r = cell->row + cell->rspan; r < MIN (cell->row + rspan, table->totalRows); r ++)
724
if (table->cells [r][c] && !html_clue_is_empty (HTML_CLUE (table->cells [r][c])) && move_cols [c - cell->col] == 0)
725
move_cols [c - cell->col] = rspan - (r - cell->row);
722
for (c = cell->col; c < cell->col + cell->cspan; c++)
723
for (r = cell->row + cell->rspan; r < MIN (cell->row + rspan, table->totalRows); r++)
724
if (table->cells[r][c] && !html_clue_is_empty (HTML_CLUE (table->cells[r][c])) && move_cols[c - cell->col] == 0)
725
move_cols[c - cell->col] = rspan - (r - cell->row);
728
for (c = 0; c < cell->cspan; c ++)
729
if (move_cols [c] > max_move)
730
max_move = move_cols [c];
728
for (c = 0; c < cell->cspan; c++)
729
if (move_cols[c] > max_move)
730
max_move = move_cols[c];
731
731
g_free (move_cols);
743
743
max_move = calc_rspan_max_move (cell, rspan);
744
744
add_rows = MAX (max_move, rspan - (table->totalRows - cell->row));
745
745
/* printf ("max move: %d add: %d\n", max_move, add_rows); */
746
for (r = 0; r < add_rows; r ++)
746
for (r = 0; r < add_rows; r++)
747
747
html_table_insert_row (table, e, table->totalRows, NULL, dir);
749
749
if (max_move > 0) {
750
for (r = table->totalRows - max_move - 1; r >= cell->row + rspan - max_move; r --)
751
for (c = cell->col; c < cell->col + cell->cspan; c ++) {
752
HTMLTableCell *ccell = table->cells [r][c];
750
for (r = table->totalRows - max_move - 1; r >= cell->row + rspan - max_move; r--)
751
for (c = cell->col; c < cell->col + cell->cspan; c++) {
752
HTMLTableCell *ccell = table->cells[r][c];
754
754
if (ccell && ccell->row == r) {
755
755
slist = g_slist_prepend (slist, move_cell_rd (table, ccell, max_move, 0));
761
761
cell->rspan = rspan;
762
for (r = cell->row; r < cell->row + cell->rspan; r ++)
763
for (c = cell->col; c < cell->col + cell->cspan; c ++)
764
table->cells [r][c] = cell;
762
for (r = cell->row; r < cell->row + cell->rspan; r++)
763
for (c = cell->col; c < cell->col + cell->cspan; c++)
764
table->cells[r][c] = cell;
766
766
html_object_change_set (HTML_OBJECT (cell), HTML_CHANGE_ALL);
778
778
collapse_rspan_setup_undo (HTMLEngine *e, gint rspan, guint position_before, HTMLUndoDirection dir)
780
html_undo_add_action (e->undo,
780
html_undo_add_action (e->undo, e,
781
781
html_undo_action_new ("Collapse Row Span", collapse_rspan_undo_action,
782
782
collapse_undo_data_new (rspan), html_cursor_get_position (e->cursor),
783
783
position_before),
794
794
table = HTML_TABLE (HTML_OBJECT (cell)->parent);
795
for (r = cell->row + rspan; r < cell->row + cell->rspan; r ++)
796
for (c = cell->col; c < cell->col + cell->cspan; c ++) {
797
table->cells [r][c] = NULL;
795
for (r = cell->row + rspan; r < cell->row + cell->rspan; r++)
796
for (c = cell->col; c < cell->col + cell->cspan; c++) {
797
table->cells[r][c] = NULL;
798
798
html_table_set_cell (table, r, c, html_engine_new_cell (e, table));
799
html_table_cell_set_position (table->cells [r][c], r, c);
799
html_table_cell_set_position (table->cells[r][c], r, c);
802
802
collapse_rspan_setup_undo (e, cell->rspan, position_before, dir);