// After we have read a file, we must ensure that the buffer
// language is set and used in the gui.
// If you know of a better place to put this, please tell me. (Lgb)
- messages_.reset(new Messages(params.language->code(),
- "/usr/local/share/locale"));
-
+ updateDocLang(params.language);
+
return ret;
}
texrow.reset();
// The starting paragraph of the coming rows is the
// first paragraph of the document. (Asger)
- texrow.start(&*(paragraphs.begin()), 0);
+ texrow.start(paragraphs.begin()->id(), 0);
if (!only_body && nice) {
os << "%% " << lyx_docversion << " created this file. "
break;
}
- simpleLinuxDocOnePar(ofs, &*pit, depth);
+ simpleLinuxDocOnePar(ofs, pit, depth);
ofs << "\n";
// write closing SGML tags
// Handle internal paragraph parsing -- layout already processed.
void Buffer::simpleLinuxDocOnePar(ostream & os,
- Paragraph * par,
- Paragraph::depth_type /*depth*/)
+ ParagraphList::iterator par,
+ Paragraph::depth_type /*depth*/) const
{
LyXLayout_ptr const & style = par->layout();
void Buffer::changeLanguage(Language const * from, Language const * to)
{
+ lyxerr << "Changing Language!" << endl;
+
// Take care of l10n/i18n
- messages_.reset(new Messages(to->code(), "/usr/local/share/locale"));
+ updateDocLang(to);
ParIterator end = par_iterator_end();
for (ParIterator it = par_iterator_begin(); it != end; ++it)
}
+void Buffer::updateDocLang(Language const * nlang)
+{
+ messages_.reset(new Messages(nlang->code()));
+}
+
+
bool Buffer::isMultiLingual()
{
ParIterator end = par_iterator_end();
}
-Paragraph * Buffer::getParFromID(int id) const
+ParagraphList::iterator Buffer::getParFromID(int id) const
{
- if (id < 0)
- return 0;
-
- // why should we allow < 0 ??
- //lyx::Assert(id >= 0);
+#warning FIXME: const correctness! (Andre)
+ ParIterator it(const_cast<Buffer*>(this)->par_iterator_begin());
+ ParIterator end(const_cast<Buffer*>(this)->par_iterator_end());
- ParConstIterator it(par_iterator_begin());
- ParConstIterator end(par_iterator_end());
+#warning FIXME, perhaps this func should return a ParIterator? (Lgb)
+ if (id < 0) {
+ // John says this is called with id == -1 from undo
+ lyxerr << "getParFromID(), id: " << id << endl;
+ return 0;
+ }
for (; it != end; ++it) {
// go on then, show me how to remove
// the cast
if ((*it)->id() == id) {
- return const_cast<Paragraph*>(*it);
+ return *it;
}
}
}
+bool Buffer::hasParWithID(int id) const
+{
+ ParIterator it(const_cast<Buffer*>(this)->par_iterator_begin());
+ ParIterator end(const_cast<Buffer*>(this)->par_iterator_end());
+
+ if (id < 0) {
+ // John says this is called with id == -1 from undo
+ lyxerr << "hasParWithID(), id: " << id << endl;
+ return 0;
+ }
+
+ for (; it != end; ++it)
+ if ((*it)->id() == id)
+ return true;
+
+ return false;
+}
+
+
ParIterator Buffer::par_iterator_begin()
{
return ParIterator(&*(paragraphs.begin()));
if (messages_.get()) {
return messages_->get(l10n);
}
-
+
return _(l10n);
}
}
-Paragraph * Buffer::inset_iterator::getPar()
+ParagraphList::iterator Buffer::inset_iterator::getPar() const
{
- return &(*pit);
+ return pit;
}