Logo Search packages:      
Sourcecode: inkscape version File versions

void Inkscape::Text::Layout::getSourceOfCharacter ( iterator const &  it,
void **  source_cookie,
Glib::ustring::iterator *  text_iterator = NULL 
) const

Discovers where the character pointed to by it came from, by retrieving the cookie that was passed to the call to appendText() or appendControlCode() which generated that output. If it == end() then NULL is returned as the cookie. If the character was generated from a call to appendText() then the optional text_iterator parameter is set to point to the actual character, otherwise text_iterator is unaltered.

Definition at line 467 of file Layout-TNG-OutIter.cpp.

References Inkscape::Text::Layout::iterator::_char_index, _input_stream, Inkscape::Text::Layout::InputStreamTextSource::text, and Inkscape::Text::Layout::InputStreamTextSource::text_begin.

Referenced by characterAt().

    if (it._char_index == _characters.size()) {
        *source_cookie = NULL;
    InputStreamItem *stream_item = _input_stream[_spans[_characters[it._char_index].in_span].in_input_stream_item];
    *source_cookie = stream_item->source_cookie;
    if (text_iterator && stream_item->Type() == TEXT_SOURCE) {
        InputStreamTextSource const *text_source = static_cast<InputStreamTextSource const *>(stream_item);
        Glib::ustring::const_iterator text_iter_const = text_source->text_begin;
        unsigned char_index = it._char_index;
        unsigned original_input_source_index = _spans[_characters[char_index].in_span].in_input_stream_item;
        // confusing algorithm because the iterator goes forwards while the index goes backwards.
        // It's just that it's faster doing it that way
        while (char_index && _spans[_characters[char_index - 1].in_span].in_input_stream_item == original_input_source_index) {
        text_source->text->begin().base() + (text_iter_const.base() - text_source->text->begin().base());
        *text_iterator = Glib::ustring::iterator(std::string::iterator(const_cast<char*>(&*text_source->text->begin().base() + (text_iter_const.base() - text_source->text->begin().base()))));
             // the caller owns the string, so they're going to want a non-const iterator

Generated by  Doxygen 1.6.0   Back to index