~ubuntu-branches/ubuntu/trusty/gtkhtml3.14/trusty-proposed

« back to all changes in this revision

Viewing changes to gtkhtml/htmlengine-edit-tablecell.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2010-11-02 14:34:48 UTC
  • mfrom: (1.6.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20101102143448-3cxzy1h4oh5v7igz
Tags: 1:3.32.0-0ubuntu1
* New upstream release 3.32.0
  - Crash after closing inline view of text attachment (LP: #178959, #284060)
  - Translations not working in Emoticons, Find/Replace dialogs (LP: #562633)
* debian/patches/gtkhtml3.14_ftbfs.patch: dropped.
* debian/rules: append API_VER for libgtkhtml-editor chrpath as well
* debian/libgtkhtml-editor-dev.install: append api version to pkgconfig
  file name.
* debian/*.shlibs: update shlibs files for new version with same soname, also
  rename libgtkhtml-editor to libgtkhtml-editor-3.14
* debian/control: Replaces/Conflicts gtkhtml3.14 (<< 3.32.0)
* debian/control: bump libgtk2.0-dev and libgail-dev Build-Depends to 2.20
* debian/rules: disable deprecation warnings so the build completes

Show diffs side-by-side

added added

removed removed

Lines of Context:
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),
172
172
 
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),
214
214
 
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),
252
252
 
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),
291
291
 
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),
331
331
 
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),
449
449
{
450
450
        gint i;
451
451
 
452
 
        for (i = 0; i < undo->rspan*undo->cspan; i ++)
453
 
                if (undo->removed [i])
454
 
                        html_object_destroy (HTML_OBJECT (undo->removed [i]));
 
452
        for (i = 0; i < undo->rspan*undo->cspan; i++)
 
453
                if (undo->removed[i])
 
454
                        html_object_destroy (HTML_OBJECT (undo->removed[i]));
455
455
        g_free (undo->removed);
456
456
        g_free (undo->moved);
457
457
}
466
466
 
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);
473
473
 
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];
478
478
 
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;
482
482
                                        move->rt = nr;
486
486
                                }
487
487
                        } else {
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];
494
494
                                        }
495
 
                                        t->cells [r][c] = NULL;
 
495
                                        t->cells[r][c] = NULL;
496
496
                                }
497
497
                        }
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); */
500
500
                }
501
501
        /* printf ("set  %dx%d --> %dx%d\n", cell->row, cell->col, cell->row + rs, cell->col + cs); */
545
545
static void
546
546
move_cell_rd_undo (HTMLTable *table, struct MoveCellRDUndo *undo)
547
547
{
548
 
        HTMLTableCell *cell = table->cells [undo->move.rt][undo->move.ct];
 
548
        HTMLTableCell *cell = table->cells[undo->move.rt][undo->move.ct];
549
549
        gint r, c;
550
550
 
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];
555
555
 
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;
560
560
                        }
561
561
 
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;
568
568
 
569
569
        html_table_cell_set_position (cell, undo->move.rs, undo->move.cs);
570
570
}
584
584
static void
585
585
expand_cspan_setup_undo (HTMLEngine *e, GSList *slist, gint cspan, guint position_before, HTMLUndoDirection dir)
586
586
{
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;
601
601
 
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);
607
607
 
608
608
        max_move = 0;
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];
612
612
 
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);
617
617
 
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];
622
622
 
623
623
                                if (ccell && ccell->col == c) {
624
624
                                        slist = g_slist_prepend (slist, move_cell_rd (table, ccell, 0, max_move));
629
629
 
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;
635
635
 
636
636
        html_object_change_set (HTML_OBJECT (cell), HTML_CHANGE_ALL);
637
637
}
666
666
static void
667
667
collapse_cspan_setup_undo (HTMLEngine *e, gint cspan, guint position_before, HTMLUndoDirection dir)
668
668
{
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),
681
681
        gint r, c;
682
682
 
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);
689
689
                }
690
690
 
691
691
        collapse_cspan_setup_undo (e, cell->cspan, position_before, dir);
719
719
        gint r, c, *move_cols, max_move;
720
720
 
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);
726
726
 
727
727
        max_move = 0;
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);
732
732
 
733
733
        return max_move;
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);
748
748
 
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];
753
753
 
754
754
                                if (ccell && ccell->row == r) {
755
755
                                        slist = g_slist_prepend (slist, move_cell_rd (table, ccell, max_move, 0));
759
759
        }
760
760
 
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;
765
765
 
766
766
        html_object_change_set (HTML_OBJECT (cell), HTML_CHANGE_ALL);
767
767
}
777
777
static void
778
778
collapse_rspan_setup_undo (HTMLEngine *e, gint rspan, guint position_before, HTMLUndoDirection dir)
779
779
{
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),
792
792
        gint r, c;
793
793
 
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);
800
800
                }
801
801
 
802
802
        collapse_rspan_setup_undo (e, cell->rspan, position_before, dir);