FontList fontlist_;
///
- unsigned int id_;
- ///
- static unsigned int paragraph_id;
+ int id_;
+
///
ParagraphParameters params_;
///
TextContainer text_;
- typedef std::set<docstring> Words;
+ typedef set<docstring> Words;
///
- Words words_;
+ map<Language, Words> words_;
///
Layout const * layout_;
};
-// Initialization of the counter for the paragraph id's,
-unsigned int Paragraph::Private::paragraph_id = 0;
-
namespace {
struct 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);
}
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_),
+ id_(p.id_), 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++;
}
begin_of_body_(p.begin_of_body_), words_(p.words_),
layout_(p.layout_)
{
- id_ = paragraph_id++;
if (beg >= pos_type(p.text_.size()))
return;
text_ = p.text_.substr(beg, end - beg);
char_type c = d->text_[i];
if (c == ' ')
break;
- xs << html::escapeChar(c);
+ xs << c;
}
}
return i;
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);
}
}
+void Paragraph::setId(int id)
+{
+ d->id_ = id;
+}
+
+
Layout const & Paragraph::layout() const
{
return *d->layout_;
void Paragraph::deregisterWords()
{
+ map<Language, Private::Words>::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();
}
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);
}
}
}
void Paragraph::registerWords()
{
+ map<Language, Private::Words>::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);
+ }
}