#include <boost/bind.hpp>
+#include <functional>
+
using lyx::pos_type;
using lyx::support::AddPath;
using std::make_pair;
using std::min;
using std::string;
+using std::mem_fun_ref;
extern BufferList bufferlist;
if (buffer_)
disconnectBuffer();
- // set current buffer
- buffer_ = b;
+ // if we are closing current buffer, switch to the first in
+ // buffer list.
+ if (!b) {
+ lyxerr[Debug::INFO] << " No Buffer!" << endl;
+ // we are closing the buffer, use the first buffer as current
+ buffer_ = bufferlist.first();
+ owner_->getDialogs().hideBufferDependent();
+ } else {
+ // set current buffer
+ buffer_ = b;
+ }
// reset old cursor
top_y_ = 0;
// hidden. This should go here because some dialogs (eg ToC)
// require bv_->text.
owner_->getDialogs().updateBufferDependent(true);
- } else {
- lyxerr[Debug::INFO] << " No Buffer!" << endl;
- // we are closing the buffer, use the first buffer as current
- buffer_ = bufferlist.first();
- owner_->getDialogs().hideBufferDependent();
}
update();
bool const res = bv_->buffer()->readFile(fname, bv_->cursor().par());
bv_->resize();
- string s = res ? _("Document %1$s inserted.")
+ string s = res ? _("Document %1$s inserted.")
: _("Could not insert document %1$s");
owner_->message(bformat(s, disp_fn));
}
bool const tracking = buf->params().tracking_changes;
if (!tracking) {
- ParIterator const end = buf->par_iterator_end();
- for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
- it->trackChanges();
+ for_each(buf->par_iterator_begin(),
+ buf->par_iterator_end(),
+ bind(&Paragraph::trackChanges, _1, Change::UNCHANGED));
buf->params().tracking_changes = true;
// we cannot allow undos beyond the freeze point
return;
}
- ParIterator const end = buf->par_iterator_end();
- for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
- it->untrackChanges();
+ for_each(buf->par_iterator_begin(),
+ buf->par_iterator_end(),
+ mem_fun_ref(&Paragraph::untrackChanges));
+
buf->params().tracking_changes = false;
}