~ubuntu-branches/ubuntu/precise/inkscape/precise-updates

« back to all changes in this revision

Viewing changes to src/text-editing.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alex Valavanis
  • Date: 2010-09-12 19:44:58 UTC
  • mfrom: (1.1.12 upstream) (45.1.3 maverick)
  • Revision ID: james.westby@ubuntu.com-20100912194458-4sjwmbl7dlsrk5dc
Tags: 0.48.0-1ubuntu1
* Merge with Debian unstable (LP: #628048, LP: #401567, LP: #456248, 
  LP: #463602, LP: #591986)
* debian/control: 
  - Ubuntu maintainers
  - Promote python-lxml, python-numpy, python-uniconvertor to Recommends.
  - Demote pstoedit to Suggests (universe package).
  - Suggests ttf-dejavu instead of ttf-bitstream-vera (LP: #513319)
* debian/rules:
  - Run intltool-update on build (Ubuntu-specific).
  - Add translation domain to .desktop files (Ubuntu-specific).
* debian/dirs:
  - Add usr/share/pixmaps.  Allow inkscape.xpm installation
* drop 50-poppler-API.dpatch (now upstream)
* drop 51-paste-in-unwritable-directory.dpatch (now upstream) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
928
928
 
929
929
/** Returns the attributes block and the character index within that block
930
930
which represents the iterator \a position. */
931
 
static TextTagAttributes*
 
931
TextTagAttributes*
932
932
text_tag_attributes_at_position(SPItem *item, Inkscape::Text::Layout::iterator const &position, unsigned *char_index)
933
933
{
934
934
    if (item == NULL || char_index == NULL || !SP_IS_TEXT(item))
973
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)
 
977
{
 
978
    unsigned char_index;
 
979
    TextTagAttributes *attributes = text_tag_attributes_at_position(item, std::min(start, end), &char_index);
 
980
    if (attributes) attributes->addToDx(char_index, delta);
 
981
    if (start != end) {
 
982
        attributes = text_tag_attributes_at_position(item, std::max(start, end), &char_index);
 
983
        if (attributes) attributes->addToDx(char_index, -delta);
 
984
    }
 
985
 
 
986
    item->updateRepr();
 
987
    item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
 
988
}
 
989
 
 
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)
 
992
{
 
993
    unsigned char_index;
 
994
    TextTagAttributes *attributes = text_tag_attributes_at_position(item, std::min(start, end), &char_index);
 
995
    if (attributes) attributes->addToDy(char_index, delta);
 
996
    if (start != end) {
 
997
        attributes = text_tag_attributes_at_position(item, std::max(start, end), &char_index);
 
998
        if (attributes) attributes->addToDy(char_index, -delta);
 
999
    }
 
1000
 
 
1001
    item->updateRepr();
 
1002
    item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
 
1003
}
 
1004
 
 
1005
void
976
1006
sp_te_adjust_rotation_screen(SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *desktop, gdouble pixels)
977
1007
{
978
1008
    // divide increment by zoom
1012
1042
}
1013
1043
 
1014
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)
 
1046
{
 
1047
    unsigned char_index;
 
1048
    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
        }
 
1056
    } else
 
1057
        attributes->setRotate(char_index, degrees);
 
1058
 
 
1059
    text->updateRepr();
 
1060
    text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
 
1061
}
 
1062
 
 
1063
void
1015
1064
sp_te_adjust_tspan_letterspacing_screen(SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *desktop, gdouble by)
1016
1065
{
1017
1066
    g_return_if_fail (text != NULL);
1843
1892
    text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
1844
1893
}
1845
1894
 
 
1895
bool is_part_of_text_subtree (SPObject *obj)
 
1896
{
 
1897
    return (SP_IS_TSPAN(obj) 
 
1898
            || SP_IS_TEXT(obj) 
 
1899
            || SP_IS_FLOWTEXT(obj)
 
1900
            || SP_IS_FLOWTSPAN(obj)
 
1901
            || SP_IS_FLOWDIV(obj)
 
1902
            || SP_IS_FLOWPARA(obj)
 
1903
            || SP_IS_FLOWLINE(obj)
 
1904
            || SP_IS_FLOWREGIONBREAK(obj));
 
1905
}
 
1906
 
 
1907
bool is_top_level_text_object (SPObject *obj)
 
1908
{
 
1909
    return (SP_IS_TEXT(obj) 
 
1910
            || SP_IS_FLOWTEXT(obj));
 
1911
}
 
1912
 
 
1913
bool has_visible_text (SPObject *obj)
 
1914
{
 
1915
    if (SP_IS_STRING(obj) && !SP_STRING(obj)->string.empty()) 
 
1916
        return true; // maybe we should also check that it's not all whitespace?
 
1917
 
 
1918
    for (SPObject const *child = obj->firstChild() ; child ; child = SP_OBJECT_NEXT(child)) {
 
1919
        if (has_visible_text((SPObject *) child))
 
1920
            return true;
 
1921
    }
 
1922
 
 
1923
    return false;
 
1924
}
 
1925
 
1846
1926
/*
1847
1927
  Local Variables:
1848
1928
  mode:c++