~ubuntu-branches/ubuntu/utopic/inkscape/utopic-proposed

« back to all changes in this revision

Viewing changes to src/text-editing.cpp

Tags: upstream-0.48.0
ImportĀ upstreamĀ versionĀ 0.48.0

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