X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FParagraph.cpp;h=233057e9163ad9058363f378066dbef466f92de7;hb=2098f1d8c20d51e63e670bcdc9da8996068975bf;hp=285fc4b273bfb35c1881534118a5c0461fe4476c;hpb=e5afe8db6669eb2395cbee3761053e38a0d05613;p=lyx.git diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 285fc4b273..233057e916 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -189,9 +189,8 @@ public: FontList fontlist_; /// - unsigned int id_; - /// - static unsigned int paragraph_id; + int id_; + /// ParagraphParameters params_; @@ -208,17 +207,14 @@ public: /// TextContainer text_; - typedef std::set Words; + typedef set Words; /// - Words words_; + map words_; /// Layout const * layout_; }; -// Initialization of the counter for the paragraph id's, -unsigned int Paragraph::Private::paragraph_id = 0; - namespace { struct special_phrase { @@ -240,20 +236,26 @@ size_t const phrases_nr = sizeof(special_phrases)/sizeof(special_phrase); Paragraph::Private::Private(Paragraph * owner, Layout const & layout) - : owner_(owner), inset_owner_(0), begin_of_body_(0), layout_(&layout) + : owner_(owner), inset_owner_(0), id_(-1), begin_of_body_(0), layout_(&layout) { - id_ = paragraph_id++; text_.reserve(100); } +// Initialization of the counter for the paragraph id's, +// +// FIXME: There should be a more intelligent way to generate and use the +// paragraph ids per buffer instead a global static counter for all InsetText +// in the running program. +static int paragraph_id = -1; + Paragraph::Private::Private(Private const & p, Paragraph * owner) : owner_(owner), inset_owner_(p.inset_owner_), fontlist_(p.fontlist_), params_(p.params_), changes_(p.changes_), insetlist_(p.insetlist_), begin_of_body_(p.begin_of_body_), text_(p.text_), words_(p.words_), layout_(p.layout_) { - id_ = paragraph_id++; + id_ = ++paragraph_id; } @@ -265,7 +267,7 @@ Paragraph::Private::Private(Private const & p, Paragraph * owner, begin_of_body_(p.begin_of_body_), words_(p.words_), layout_(p.layout_) { - id_ = paragraph_id++; + id_ = ++paragraph_id; if (beg >= pos_type(p.text_.size())) return; text_ = p.text_.substr(beg, end - beg); @@ -2312,7 +2314,7 @@ pos_type Paragraph::firstWordLyXHTML(XHTMLStream & xs, OutputParams const & runp char_type c = d->text_[i]; if (c == ' ') break; - xs << html::escapeChar(c); + xs << c; } } return i; @@ -2401,14 +2403,12 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf, bool emph_flag = false; bool bold_flag = false; - std::string closing_tag; + string closing_tag; Layout const & style = *d->layout_; - if (!fortoc - && style.toclevel != Layout::NOT_IN_TOC - && style.toclevel <= buf.params().tocdepth) { - // we need to generate a magic label for this paragraph + if (!fortoc) { + // generate a magic label for this paragraph string const attr = "id='" + magicLabel() + "'"; xs << CompTag("a", attr); } @@ -2656,6 +2656,12 @@ int Paragraph::id() const } +void Paragraph::setId(int id) +{ + d->id_ = id; +} + + Layout const & Paragraph::layout() const { return *d->layout_; @@ -3024,10 +3030,13 @@ bool Paragraph::isSeparator(pos_type pos) const void Paragraph::deregisterWords() { + map::const_iterator itl; Private::Words::const_iterator it; - WordList & wl = theWordList(); - for (it = d->words_.begin(); it != d->words_.end(); ++it) - wl.remove(*it); + for (itl = d->words_.begin(); itl != d->words_.end(); ++itl) { + WordList * wl = theWordList(itl->first); + for (it = (itl->second).begin(); it != (itl->second).end(); ++it) + wl->remove(*it); + } d->words_.clear(); } @@ -3079,7 +3088,11 @@ void Paragraph::collectWords() locateWord(from, pos, WHOLE_WORD); if (pos - from >= 6) { docstring word = asString(from, pos, AS_STR_NONE); - d->words_.insert(word); + FontList::const_iterator cit = d->fontlist_.fontIterator(pos); + if (cit == d->fontlist_.end()) + return; + Language const * lang = cit->font().language(); + d->words_[*lang].insert(word); } } } @@ -3087,10 +3100,13 @@ void Paragraph::collectWords() void Paragraph::registerWords() { + map::const_iterator itl; Private::Words::const_iterator it; - WordList & wl = theWordList(); - for (it = d->words_.begin(); it != d->words_.end(); ++it) - wl.insert(*it); + for (itl = d->words_.begin(); itl != d->words_.end(); ++itl) { + WordList * wl = theWordList(itl->first); + for (it = (itl->second).begin(); it != (itl->second).end(); ++it) + wl->insert(*it); + } }