~ubuntu-branches/ubuntu/oneiric/inkscape/oneiric-updates

« back to all changes in this revision

Viewing changes to src/text-editing.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Valavanis
  • Date: 2011-02-01 12:53:34 UTC
  • Revision ID: james.westby@ubuntu.com-20110201125334-xezweqxp3tvekidu
Tags: 0.48.1-0ubuntu1
* New upstream version (LP: #710619).  Fixes several Ubuntu bugs:
  - Node editing causes segmentation fault (LP: #544599)
  - Cursor position markers are not cleared from rulers (LP: #627134)
  - Crashes when opening document properties (LP: #658055)
  - Export to XCF error with default template (LP: #485032)
  - Editing a connector in a transformed group returns it to original
    position (LP: #533897)
  - Ungrouping objects changes position of arrow lines (LP: #552289)
  - Will not save XCF file (LP: #642417)
  - XCF export fails when exporting from unsaved document (LP: #650890)
* Drop all patches: Applied upstream
* debian/rules: Disable chmod on debian/patches/* in clean rule (no patches used)

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
        SP_TEXT(item)->rebuildLayout();
58
58
    else if (SP_IS_FLOWTEXT (item))
59
59
        SP_FLOWTEXT(item)->rebuildLayout();
 
60
    item->updateRepr();
60
61
}
61
62
 
62
63
/** Returns true if there are no visible characters on the canvas */
972
973
    item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
973
974
}
974
975
 
975
 
void
976
 
sp_te_adjust_dx (SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *desktop, double delta)
 
976
void sp_te_adjust_dx(SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop * /*desktop*/, double delta)
977
977
{
978
 
    unsigned char_index;
 
978
    unsigned char_index = 0;
979
979
    TextTagAttributes *attributes = text_tag_attributes_at_position(item, std::min(start, end), &char_index);
980
 
    if (attributes) attributes->addToDx(char_index, delta);
 
980
    if (attributes) {
 
981
        attributes->addToDx(char_index, delta);
 
982
    }
981
983
    if (start != end) {
982
984
        attributes = text_tag_attributes_at_position(item, std::max(start, end), &char_index);
983
 
        if (attributes) attributes->addToDx(char_index, -delta);
 
985
        if (attributes) {
 
986
            attributes->addToDx(char_index, -delta);
 
987
        }
984
988
    }
985
989
 
986
990
    item->updateRepr();
987
991
    item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
988
992
}
989
993
 
990
 
void
991
 
sp_te_adjust_dy (SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *desktop, double delta)
 
994
void sp_te_adjust_dy(SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop * /*desktop*/, double delta)
992
995
{
993
 
    unsigned char_index;
 
996
    unsigned char_index = 0;
994
997
    TextTagAttributes *attributes = text_tag_attributes_at_position(item, std::min(start, end), &char_index);
995
 
    if (attributes) attributes->addToDy(char_index, delta);
 
998
    if (attributes) {
 
999
        attributes->addToDy(char_index, delta);
 
1000
    }
996
1001
    if (start != end) {
997
1002
        attributes = text_tag_attributes_at_position(item, std::max(start, end), &char_index);
998
 
        if (attributes) attributes->addToDy(char_index, -delta);
 
1003
        if (attributes) {
 
1004
            attributes->addToDy(char_index, -delta);
 
1005
        }
999
1006
    }
1000
1007
 
1001
1008
    item->updateRepr();
1041
1048
    text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
1042
1049
}
1043
1050
 
1044
 
void
1045
 
sp_te_set_rotation(SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop */*desktop*/, gdouble degrees)
 
1051
void sp_te_set_rotation(SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop */*desktop*/, gdouble degrees)
1046
1052
{
1047
 
    unsigned char_index;
 
1053
    unsigned char_index = 0;
1048
1054
    TextTagAttributes *attributes = text_tag_attributes_at_position(text, std::min(start, end), &char_index);
1049
 
    if (attributes == NULL) return;
1050
 
 
1051
 
    if (start != end) {
1052
 
        for (Inkscape::Text::Layout::iterator it = std::min(start, end) ; it != std::max(start, end) ; it.nextCharacter()) {
1053
 
            attributes = text_tag_attributes_at_position(text, it, &char_index);
1054
 
            if (attributes) attributes->setRotate(char_index, degrees);
 
1055
    if (attributes != NULL) {
 
1056
        if (start != end) {
 
1057
            for (Inkscape::Text::Layout::iterator it = std::min(start, end) ; it != std::max(start, end) ; it.nextCharacter()) {
 
1058
                attributes = text_tag_attributes_at_position(text, it, &char_index);
 
1059
                if (attributes) {
 
1060
                    attributes->setRotate(char_index, degrees);
 
1061
                }
 
1062
            }
 
1063
        } else {
 
1064
            attributes->setRotate(char_index, degrees);
1055
1065
        }
1056
 
    } else
1057
 
        attributes->setRotate(char_index, degrees);
1058
1066
 
1059
 
    text->updateRepr();
1060
 
    text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
 
1067
        text->updateRepr();
 
1068
        text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
 
1069
    }
1061
1070
}
1062
1071
 
1063
1072
void
1283
1292
    parent_style = sp_style_write_string(parent_spstyle, SP_STYLE_FLAG_ALWAYS);
1284
1293
    sp_style_unref(parent_spstyle);
1285
1294
 
1286
 
    Glib::ustring child_style_construction(parent_style);
 
1295
    Glib::ustring child_style_construction;
1287
1296
    while (child != parent) {
1288
1297
        // FIXME: this assumes that child's style is only in style= whereas it can also be in css attributes!
1289
1298
        char const *style_text = SP_OBJECT_REPR(child)->attribute("style");
1290
1299
        if (style_text && *style_text) {
1291
 
            child_style_construction += ';';
1292
 
            child_style_construction += style_text;
 
1300
            child_style_construction.insert(0, style_text);
 
1301
            child_style_construction.insert(0, 1, ';');
1293
1302
        }
1294
1303
        child = SP_OBJECT_PARENT(child);
1295
1304
    }
 
1305
    child_style_construction.insert(0, parent_style);
1296
1306
    SPStyle *child_spstyle = sp_style_new(SP_OBJECT_DOCUMENT(parent));
1297
1307
    sp_style_merge_from_style_string(child_spstyle, child_style_construction.c_str());
1298
1308
    gchar *child_style = sp_style_write_string(child_spstyle, SP_STYLE_FLAG_ALWAYS);
1646
1656
 
1647
1657
    SPCSSAttr *css_child_and_item = sp_repr_css_attr_new();
1648
1658
    SPCSSAttr *css_child_only = sp_repr_css_attr_new();
 
1659
    gchar const *item_style = SP_OBJECT_REPR(*item)->attribute("style");
 
1660
    if (item_style && *item_style) {
 
1661
        sp_repr_css_attr_add_from_string(css_child_and_item, item_style);
 
1662
    }
1649
1663
    gchar const *child_style = SP_OBJECT_REPR(child)->attribute("style");
1650
1664
    if (child_style && *child_style) {
1651
1665
        sp_repr_css_attr_add_from_string(css_child_and_item, child_style);
1652
1666
        sp_repr_css_attr_add_from_string(css_child_only, child_style);
1653
1667
    }
1654
 
    gchar const *item_style = SP_OBJECT_REPR(*item)->attribute("style");
1655
 
    if (item_style && *item_style) {
1656
 
        sp_repr_css_attr_add_from_string(css_child_and_item, item_style);
1657
 
    }
1658
1668
    bool equal = css_attrs_are_equal(css_child_only, css_child_and_item);
1659
1669
    sp_repr_css_attr_unref(css_child_and_item);
1660
1670
    sp_repr_css_attr_unref(css_child_only);