I like this patch... and I am sure that several of you won't... Anyway, please have a look.
? src/less ? src/frontends/xforms/FormPreferences.o.lock ? src/frontends/xforms/lyx_forms.h ? src/frontends/xforms/lyx_xpm.h Index: src/BufferView.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.C,v retrieving revision 1.168 diff -u -p -r1.168 BufferView.C --- src/BufferView.C 10 Jul 2003 12:26:31 -0000 1.168 +++ src/BufferView.C 18 Jul 2003 01:11:08 -0000 @@ -51,6 +51,8 @@ extern BufferList bufferlist; using lyx::pos_type; using namespace lyx::support; +using boost::shared_ptr; + using std::pair; using std::endl; using std::ifstream; @@ -74,9 +76,9 @@ BufferView::~BufferView() } -Buffer * BufferView::buffer() const +shared_ptr<Buffer> BufferView::buffer() const { - return pimpl_->buffer_; + return pimpl_->buffer(); } @@ -98,7 +100,7 @@ Painter & BufferView::painter() const } -void BufferView::buffer(Buffer * b) +void BufferView::buffer(shared_ptr<Buffer> b) { pimpl_->buffer(b); } @@ -126,7 +128,7 @@ void BufferView::reload() void BufferView::resize() { - if (pimpl_->buffer_) + if (!pimpl_->buffer_.expired()) pimpl_->resizeCurrentBuffer(); } Index: src/BufferView.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.h,v retrieving revision 1.130 diff -u -p -r1.130 BufferView.h --- src/BufferView.h 7 Jul 2003 08:36:55 -0000 1.130 +++ src/BufferView.h 18 Jul 2003 01:11:09 -0000 @@ -58,9 +58,9 @@ public: ~BufferView(); /// set the buffer we are viewing - void buffer(Buffer * b); + void buffer(boost::shared_ptr<Buffer> b); /// return the buffer being viewed - Buffer * buffer() const; + boost::shared_ptr<Buffer> buffer() const; /// return the painter object for drawing onto the view Painter & painter() const; @@ -81,7 +81,7 @@ public: /// reload the contained buffer void reload(); /// create a new buffer based on template - bool newFile(string const & fname, string const & tname, + bool newFile(string const & fname, string const & tname, bool named = true); /// load a buffer into the view bool loadLyXFile(string const & name, bool tolastfiles = true); Index: src/BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.393 diff -u -p -r1.393 BufferView_pimpl.C --- src/BufferView_pimpl.C 17 Jul 2003 11:48:41 -0000 1.393 +++ src/BufferView_pimpl.C 18 Jul 2003 01:11:09 -0000 @@ -66,6 +66,7 @@ #include <unistd.h> #include <sys/wait.h> +using boost::shared_ptr; using std::vector; using std::find_if; @@ -105,7 +106,7 @@ boost::signals::connection lostcon; BufferView::Pimpl::Pimpl(BufferView * bv, LyXView * owner, int xpos, int ypos, int width, int height) - : bv_(bv), owner_(owner), buffer_(0), cursor_timeout(400), + : bv_(bv), owner_(owner), cursor_timeout(400), using_xterm_cursor(false) { workarea_.reset(WorkAreaFactory::create(xpos, ypos, width, height)); @@ -145,18 +146,17 @@ void BufferView::Pimpl::showReadonly(boo } -void BufferView::Pimpl::connectBuffer(Buffer & buf) +void BufferView::Pimpl::connectBuffer(shared_ptr<Buffer> buf) { if (errorConnection_.connected()) disconnectBuffer(); - errorConnection_ = buf.error.connect(boost::bind(&BufferView::Pimpl::addError, this, _1)); - messageConnection_ = buf.message.connect(boost::bind(&LyXView::message, owner_, _1)); - busyConnection_ = buf.busy.connect(boost::bind(&LyXView::busy, owner_, _1)); - titleConnection_ = buf.updateTitles.connect(boost::bind(&LyXView::updateWindowTitle, owner_)); - timerConnection_ = buf.resetAutosaveTimers.connect(boost::bind(&LyXView::resetAutosaveTimer, owner_)); - readonlyConnection_ = buf.readonly.connect(boost::bind(&BufferView::Pimpl::showReadonly, this, _1)); - closingConnection_ = buf.closing.connect(boost::bind(&BufferView::Pimpl::buffer, this, (Buffer *)0)); + errorConnection_ = buf->error.connect(boost::bind(&BufferView::Pimpl::addError, this, _1)); + messageConnection_ = buf->message.connect(boost::bind(&LyXView::message, owner_, _1)); + busyConnection_ = buf->busy.connect(boost::bind(&LyXView::busy, owner_, _1)); + titleConnection_ = buf->updateTitles.connect(boost::bind(&LyXView::updateWindowTitle, owner_)); + timerConnection_ = buf->resetAutosaveTimers.connect(boost::bind(&LyXView::resetAutosaveTimer, owner_)); + readonlyConnection_ = buf->readonly.connect(boost::bind(&BufferView::Pimpl::showReadonly, this, _1)); } @@ -168,16 +168,14 @@ void BufferView::Pimpl::disconnectBuffer titleConnection_.disconnect(); timerConnection_.disconnect(); readonlyConnection_.disconnect(); - closingConnection_.disconnect(); } -bool BufferView::Pimpl::newFile(string const & filename, +bool BufferView::Pimpl::newFile(string const & filename, string const & tname, bool isNamed) { - Buffer * b = ::newFile(filename, tname, isNamed); - buffer(b); + buffer(::newFile(filename, tname, isNamed)); return true; } @@ -210,9 +208,10 @@ bool BufferView::Pimpl::loadLyXFile(stri // Fall through to new load. (Asger) } } - Buffer * b = bufferlist.newBuffer(s); - connectBuffer(*b); + shared_ptr<Buffer> b = bufferlist.newBuffer(s); + + connectBuffer(b); if (! ::loadLyXFile(b, s)) { bufferlist.release(b); @@ -255,17 +254,23 @@ Painter & BufferView::Pimpl::painter() c } -void BufferView::Pimpl::buffer(Buffer * b) +shared_ptr<Buffer> BufferView::Pimpl::buffer() +{ + return buffer_.lock(); +} + + +void BufferView::Pimpl::buffer(shared_ptr<Buffer> b) { lyxerr[Debug::INFO] << "Setting buffer in BufferView (" << b << ')' << endl; - if (buffer_) { + if (!buffer_.expired()) { disconnectBuffer(); // Put the old text into the TextCache, but // only if the buffer is still loaded. // Also set the owner of the test to 0 // bv_->text->owner(0); - textcache.add(buffer_, workarea().workWidth(), bv_->text); + textcache.add(buffer().get(), workarea().workWidth(), bv_->text); if (lyxerr.debugging()) textcache.show(lyxerr, "BufferView::buffer"); @@ -280,13 +285,13 @@ void BufferView::Pimpl::buffer(Buffer * return; // if we are closing the buffer, use the first buffer as current - if (!buffer_) { + if (buffer_.expired()) { buffer_ = bufferlist.first(); } - if (buffer_) { - lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl; - connectBuffer(*buffer_); + if (!buffer_.expired()) { + lyxerr[Debug::INFO] << "Buffer addr: " << buffer() << endl; + connectBuffer(buffer()); // If we don't have a text object for this, we make one if (bv_->text == 0) { @@ -319,15 +324,15 @@ void BufferView::Pimpl::buffer(Buffer * owner_->updateLayoutChoice(); owner_->updateWindowTitle(); - if (buffer_) { + if (!buffer_.expired()) { // Don't forget to update the Layout string const layoutname = bv_->text->cursor.par()->layout()->name(); owner_->setLayout(layoutname); } - if (grfx::Previews::activated() && buffer_) - grfx::Previews::get().generateBufferPreviews(*buffer_); + if (grfx::Previews::activated() && !buffer_.expired()) + grfx::Previews::get().generateBufferPreviews(*buffer().get()); } @@ -355,7 +360,7 @@ bool BufferView::Pimpl::fitCursor() void BufferView::Pimpl::redoCurrentBuffer() { lyxerr[Debug::INFO] << "BufferView::redoCurrentBuffer" << endl; - if (buffer_ && bv_->text) { + if (!buffer_.expired() && bv_->text) { resizeCurrentBuffer(); updateScrollbar(); owner_->updateLayoutChoice(); @@ -400,12 +405,12 @@ int BufferView::Pimpl::resizeCurrentBuff lyxerr << "text not available!\n"; // See if we have a text in TextCache that fits // the new buffer_ with the correct width. - bv_->text = textcache.findFit(buffer_, workarea().workWidth()); + bv_->text = textcache.findFit(buffer_.lock().get(), workarea().workWidth()); if (bv_->text) { lyxerr << "text in cache!\n"; if (lyxerr.debugging()) { lyxerr << "Found a LyXText that fits:\n"; - textcache.show(lyxerr, make_pair(buffer_, make_pair(workarea().workWidth(), bv_->text))); + textcache.show(lyxerr, make_pair(buffer().get(), make_pair(workarea().workWidth(), bv_->text))); } // Set the owner of the newly found text // bv_->text->owner(bv_); @@ -487,7 +492,7 @@ void BufferView::Pimpl::scrollDocView(in { lyxerr[Debug::GUI] << "scrollDocView of " << value << endl; - if (!buffer_) + if (buffer_.expired()) return; screen().hideCursor(); @@ -514,7 +519,7 @@ void BufferView::Pimpl::scrollDocView(in void BufferView::Pimpl::scroll(int lines) { - if (!buffer_) { + if (buffer_.expired()) { return; } @@ -569,7 +574,7 @@ void BufferView::Pimpl::selectionRequest text->selection.end != bv_->text->xsel_cache.end)) { bv_->text->xsel_cache = text->selection; - sel = text->selectionAsString(bv_->buffer(), false); + sel = text->selectionAsString(bv_->buffer().get(), false); } else if (!text->selection.set()) { sel = string(); bv_->text->xsel_cache.set(false); @@ -603,7 +608,7 @@ void BufferView::Pimpl::workAreaResize() work_area_width = workarea().workWidth(); work_area_height = workarea().workHeight(); - if (buffer_ != 0) { + if (!buffer_.expired()) { if (widthChange) { // The visible LyXView need a resize resizeCurrentBuffer(); @@ -686,7 +691,7 @@ void BufferView::Pimpl::update(BufferVie // Callback for cursor timer void BufferView::Pimpl::cursorToggle() { - if (!buffer_) { + if (buffer_.expired()) { cursor_timeout.restart(); return; } @@ -699,7 +704,7 @@ void BufferView::Pimpl::cursorToggle() bool BufferView::Pimpl::available() const { - if (buffer_ && bv_->text) + if (!buffer_.expired() && bv_->text) return true; return false; } @@ -731,7 +736,7 @@ void BufferView::Pimpl::savePosition(uns { if (i >= saved_positions_num) return; - saved_positions[i] = Position(buffer_->fileName(), + saved_positions[i] = Position(buffer_.lock()->fileName(), bv_->text->cursor.par()->id(), bv_->text->cursor.pos()); if (i > 0) @@ -748,20 +753,20 @@ void BufferView::Pimpl::restorePosition( beforeChange(bv_->text); - if (fname != buffer_->fileName()) { - Buffer * b; + if (fname != buffer_.lock()->fileName()) { + shared_ptr<Buffer> b; if (bufferlist.exists(fname)) b = bufferlist.getBuffer(fname); else { b = bufferlist.newBuffer(fname); ::loadLyXFile(b, fname); // don't ask, just load it } - if (b != 0) + if (b.get()) buffer(b); } - ParIterator par = buffer_->getParFromID(saved_positions[i].par_id); - if (par == buffer_->par_iterator_end()) + ParIterator par = buffer()->getParFromID(saved_positions[i].par_id); + if (par == buffer()->par_iterator_end()) return; bv_->text->setCursor(par.pit(), @@ -880,7 +885,7 @@ Inset * BufferView::Pimpl::getInsetByCod // Ok, this is a little bit too brute force but it // should work for now. Better infrastructure is comming. (Lgb) - Buffer * b = bv_->buffer(); + shared_ptr<Buffer> b = bv_->buffer(); LyXCursor cursor = bv_->getLyXText()->cursor; Buffer::inset_iterator beg = b->inset_iterator_begin(); @@ -960,17 +965,17 @@ void BufferView::Pimpl::MenuInsertLyXFil string const disp_fn = MakeDisplayPath(filename); owner_->message(bformat(_("Inserting document %1$s..."), disp_fn)); if (bv_->insertLyXFile(filename)) - owner_->message(bformat(_("Document %1$s inserted."), + owner_->message(bformat(_("Document %1$s inserted."), disp_fn)); else - owner_->message(bformat(_("Could not insert document %1$s"), + owner_->message(bformat(_("Could not insert document %1$s"), disp_fn)); } void BufferView::Pimpl::trackChanges() { - Buffer * buf(bv_->buffer()); + shared_ptr<Buffer> buf(bv_->buffer()); bool const tracking(buf->params.tracking_changes); if (!tracking) { @@ -1051,7 +1056,7 @@ bool BufferView::Pimpl::dispatch(FuncReq << " button[" << ev.button() << ']' << endl; - LyXTextClass const & tclass = buffer_->params.getLyXTextClass(); + LyXTextClass const & tclass = buffer()->params.getLyXTextClass(); switch (ev.action) { @@ -1292,14 +1297,14 @@ bool BufferView::Pimpl::dispatch(FuncReq string arg = ev.argument; if (arg.empty()) { - arg = bv_->getLyXText()->selectionAsString(buffer_, + arg = bv_->getLyXText()->selectionAsString(buffer().get(), false); // FIXME if (arg.size() > 100 || arg.empty()) { // Get word or selection bv_->getLyXText()->selectWordWhenUnderCursor(lyx::WHOLE_WORD); - arg = bv_->getLyXText()->selectionAsString(buffer_, false); + arg = bv_->getLyXText()->selectionAsString(buffer().get(), false); // FIXME: where is getLyXText()->unselect(bv_) ? } } @@ -1395,7 +1400,7 @@ bool BufferView::Pimpl::insertInset(Inse string lres = lout; LyXTextClass const & tclass = - buffer_->params.getLyXTextClass(); + buffer()->params.getLyXTextClass(); bool hasLayout = tclass.hasLayout(lres); string lay = tclass.defaultLayoutName(); Index: src/BufferView_pimpl.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.h,v retrieving revision 1.93 diff -u -p -r1.93 BufferView_pimpl.h --- src/BufferView_pimpl.h 11 Jul 2003 12:21:30 -0000 1.93 +++ src/BufferView_pimpl.h 18 Jul 2003 01:11:09 -0000 @@ -18,6 +18,7 @@ #include "support/types.h" #include <boost/scoped_ptr.hpp> +#include <boost/weak_ptr.hpp> #include <boost/signals/trackable.hpp> @@ -37,7 +38,9 @@ struct BufferView::Pimpl : public boost: /// return the screen for this bview LyXScreen & screen() const; /// - void buffer(Buffer *); + void buffer(boost::shared_ptr<Buffer>); + /// + boost::shared_ptr<Buffer> buffer(); /// Return true if the cursor was fitted. bool fitCursor(); /// @@ -125,10 +128,8 @@ private: boost::signals::connection timerConnection_; /// buffer readonly status changed signal connection boost::signals::connection readonlyConnection_; - /// buffer closing signal connection - boost::signals::connection closingConnection_; /// connect to signals in the given buffer - void connectBuffer(Buffer & buf); + void connectBuffer(boost::shared_ptr<Buffer> buf); /// disconnect from signals in the given buffer void disconnectBuffer(); /// track changes for the document @@ -144,7 +145,7 @@ private: /// LyXView * owner_; /// - Buffer * buffer_; + boost::weak_ptr<Buffer> buffer_; /// boost::scoped_ptr<LyXScreen> screen_; /// Index: src/MenuBackend.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/MenuBackend.C,v retrieving revision 1.73 diff -u -p -r1.73 MenuBackend.C --- src/MenuBackend.C 30 Jun 2003 23:55:49 -0000 1.73 +++ src/MenuBackend.C 18 Jul 2003 01:11:09 -0000 @@ -429,15 +429,15 @@ void expandFormats(MenuItem::Kind kind, action = LFUN_IMPORT; break; case MenuItem::ViewFormats: - formats = Exporter::GetExportableFormats(view->buffer(), true); + formats = Exporter::GetExportableFormats(view->buffer().get(), true); action = LFUN_PREVIEW; break; case MenuItem::UpdateFormats: - formats = Exporter::GetExportableFormats(view->buffer(), true); + formats = Exporter::GetExportableFormats(view->buffer().get(), true); action = LFUN_UPDATE; break; default: - formats = Exporter::GetExportableFormats(view->buffer(), false); + formats = Exporter::GetExportableFormats(view->buffer().get(), false); action = LFUN_EXPORT; } sort(formats.begin(), formats.end(), compare_format()); @@ -581,7 +581,7 @@ void expandToc(Menu & tomenu, LyXView co return; } - toc::TocList toc_list = toc::getTocList(view->buffer()); + toc::TocList toc_list = toc::getTocList(view->buffer().get()); toc::TocList::const_iterator cit = toc_list.begin(); toc::TocList::const_iterator end = toc_list.end(); for (; cit != end; ++cit) { Index: src/buffer.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v retrieving revision 1.493 diff -u -p -r1.493 buffer.C --- src/buffer.C 11 Jul 2003 12:21:30 -0000 1.493 +++ src/buffer.C 18 Jul 2003 01:11:10 -0000 @@ -87,6 +87,8 @@ using namespace lyx::support; +using boost::shared_ptr; + #ifndef CXX_GLOBAL_CSTD using std::pow; #endif @@ -145,8 +147,6 @@ Buffer::~Buffer() // here the buffer should take care that it is // saved properly, before it goes into the void. - closing(); - if (!tmppath.empty() && destroyDir(tmppath) != 0) { Alert::warning(_("Could not remove temporary directory"), bformat(_("Could not remove the temporary directory %1$s"), tmppath)); @@ -265,7 +265,7 @@ int Buffer::readHeader(LyXLex & lex) "%1$s %2$s\n"), token, lex.getString()); - error(ErrorItem(_("Header error"), s, + error(ErrorItem(_("Header error"), s, -1, 0, 0)); } } @@ -1968,8 +1968,8 @@ void Buffer::getLabelList(std::vector<st /// Use the parent's list instead [ale990407] if (!params.parentname.empty() && bufferlist.exists(params.parentname)) { - Buffer const * tmp = bufferlist.getBuffer(params.parentname); - if (tmp) { + shared_ptr<Buffer> tmp = bufferlist.getBuffer(params.parentname); + if (tmp.get()) { tmp->getLabelList(list); return; } @@ -1988,8 +1988,8 @@ void Buffer::fillWithBibKeys(std::vector /// if this is a child document and the parent is already loaded /// use the parent's list instead [ale990412] if (!params.parentname.empty() && bufferlist.exists(params.parentname)) { - Buffer const * tmp = bufferlist.getBuffer(params.parentname); - if (tmp) { + shared_ptr<Buffer> tmp = bufferlist.getBuffer(params.parentname); + if (tmp.get()) { tmp->fillWithBibKeys(keys); return; } Index: src/buffer.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.h,v retrieving revision 1.149 diff -u -p -r1.149 buffer.h --- src/buffer.h 11 Jul 2003 12:21:31 -0000 1.149 +++ src/buffer.h 18 Jul 2003 01:11:10 -0000 @@ -117,9 +117,6 @@ public: boost::signal0<void> updateTitles; /// Reset autosave timers for all users. boost::signal0<void> resetAutosaveTimers; - /// This signal is emitting if the buffer is being closed. - boost::signal0<void> closing; - /** Save file. Takes care of auto-save files and backup file if requested. Index: src/buffer_funcs.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer_funcs.C,v retrieving revision 1.4 diff -u -p -r1.4 buffer_funcs.C --- src/buffer_funcs.C 7 Jul 2003 08:36:57 -0000 1.4 +++ src/buffer_funcs.C 18 Jul 2003 01:11:10 -0000 @@ -34,10 +34,11 @@ extern BufferList bufferlist; using namespace lyx::support; +using boost::shared_ptr; namespace { -bool readFile(Buffer * b, string const & s) +bool readFile(shared_ptr<Buffer> & b, string const & s) { string ts(s); string e = OnlyPath(s); @@ -117,7 +118,7 @@ bool readFile(Buffer * b, string const & -bool loadLyXFile(Buffer * b, string const & s) +bool loadLyXFile(shared_ptr<Buffer> b, string const & s) { switch (IsFileWriteable(s)) { case 0: @@ -152,11 +153,11 @@ bool loadLyXFile(Buffer * b, string cons } -Buffer * newFile(string const & filename, string const & templatename, +shared_ptr<Buffer> newFile(string const & filename, string const & templatename, bool isNamed) { // get a free buffer - Buffer * b = bufferlist.newBuffer(filename); + shared_ptr<Buffer> b = bufferlist.newBuffer(filename); string tname; // use defaults.lyx as a default template if it exists. @@ -200,7 +201,7 @@ Buffer * newFile(string const & filename } -void bufferErrors(Buffer const & buf, TeXErrors const & terr) +void bufferErrors(Buffer const & buf, TeXErrors const & terr) { TeXErrors::Errors::const_iterator cit = terr.begin(); TeXErrors::Errors::const_iterator end = terr.end(); @@ -219,12 +220,12 @@ void bufferErrors(Buffer const & buf, Te } -void bufferErrors(Buffer const & buf, ErrorList const & el) +void bufferErrors(Buffer const & buf, ErrorList const & el) { ErrorList::const_iterator it = el.begin(); ErrorList::const_iterator end = el.end(); - for (; it != end; ++it) + for (; it != end; ++it) buf.error(*it); } Index: src/buffer_funcs.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer_funcs.h,v retrieving revision 1.4 diff -u -p -r1.4 buffer_funcs.h --- src/buffer_funcs.h 17 Jul 2003 08:23:33 -0000 1.4 +++ src/buffer_funcs.h 18 Jul 2003 01:11:10 -0000 @@ -14,21 +14,24 @@ #include "LString.h" +#include <boost/shared_ptr.hpp> + class Buffer; class TeXErrors; class ErrorList; /** - * Loads a LyX file \c filename into \c Buffer + * Loads a LyX file \c filename into \c Buffer * and \return success status. */ -bool loadLyXFile(Buffer *, string const & filename); +bool loadLyXFile(boost::shared_ptr<Buffer>, string const & filename); /* Make a new file (buffer) with name \c filename based on a template * named \c templatename */ -Buffer * newFile(string const & filename, string const & templatename, - bool isNamed = false); +boost::shared_ptr<Buffer> newFile(string const & filename, + string const & templatename, + bool isNamed = false); ///return the format of the buffer on a string string const BufferFormat(Buffer const & buffer); Index: src/bufferlist.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferlist.C,v retrieving revision 1.119 diff -u -p -r1.119 bufferlist.C --- src/bufferlist.C 30 Jun 2003 23:55:50 -0000 1.119 +++ src/bufferlist.C 18 Jul 2003 01:11:10 -0000 @@ -43,6 +43,8 @@ using namespace lyx::support; +using boost::shared_ptr; + using std::vector; using std::find; using std::endl; @@ -61,7 +63,7 @@ bool BufferList::empty() const } -bool BufferList::quitWriteBuffer(Buffer * buf) +bool BufferList::quitWriteBuffer(shared_ptr<Buffer> const & buf) { string file; if (buf->isUnnamed()) @@ -81,9 +83,9 @@ bool BufferList::quitWriteBuffer(Buffer bool succeeded; if (buf->isUnnamed()) - succeeded = WriteAs(buf); + succeeded = WriteAs(buf.get()); else - succeeded = MenuWrite(buf); + succeeded = MenuWrite(buf.get()); if (!succeeded) return false; @@ -118,25 +120,31 @@ bool BufferList::quitWriteAll() } -void BufferList::release(Buffer * buf) +void BufferList::release(shared_ptr<Buffer> buf) { Assert(buf); - BufferStorage::iterator it = find(bstore.begin(), bstore.end(), buf); - if (it != bstore.end()) { + + BufferStorage::iterator it = bstore.begin(); + BufferStorage::iterator end = bstore.end(); + for (; it != end; ++it) { + if (*it == buf) + break; + } + + if (it != end) { // Make sure that we don't store a LyXText in // the textcache that points to the buffer // we just deleted. - Buffer * tmp = (*it); + shared_ptr<Buffer> tmp = (*it); bstore.erase(it); - textcache.removeAllWithBuffer(tmp); - delete tmp; + textcache.removeAllWithBuffer(tmp.get()); } } -Buffer * BufferList::newBuffer(string const & s, bool ronly) +shared_ptr<Buffer> BufferList::newBuffer(string const & s, bool ronly) { - Buffer * tmpbuf = new Buffer(s, ronly); + shared_ptr<Buffer> tmpbuf(new Buffer(s, ronly)); tmpbuf->params.useClassDefaults(); lyxerr[Debug::INFO] << "Assigning to buffer " << bstore.size() << endl; @@ -157,9 +165,9 @@ void BufferList::closeAll() } -bool BufferList::close(Buffer * buf, bool ask) +bool BufferList::close(shared_ptr<Buffer> buf, bool ask) { - Assert(buf); + Assert(buf.get()); // FIXME: is the quitting check still necessary ? if (!ask || buf->isClean() || quitting || buf->paragraphs.empty()) { @@ -180,7 +188,7 @@ bool BufferList::close(Buffer * buf, boo if (ret == 0) { if (buf->isUnnamed()) { - if (!WriteAs(buf)) + if (!WriteAs(buf.get())) return false; } else if (buf->save()) { lastfiles->newFile(buf->fileName()); @@ -203,24 +211,27 @@ bool BufferList::close(Buffer * buf, boo vector<string> const BufferList::getFileNames() const { vector<string> nvec; - std::copy(bstore.begin(), bstore.end(), - lyx::back_inserter_fun(nvec, &Buffer::fileName)); + BufferStorage::const_iterator cit = bstore.begin(); + BufferStorage::const_iterator end = bstore.end(); + for (; cit != end; ++cit) { + nvec.push_back((*cit)->fileName()); + } return nvec; } -Buffer * BufferList::first() +shared_ptr<Buffer> BufferList::first() { if (bstore.empty()) - return 0; + return shared_ptr<Buffer>(); return bstore.front(); } -Buffer * BufferList::getBuffer(unsigned int choice) +shared_ptr<Buffer> BufferList::getBuffer(unsigned int choice) { if (choice >= bstore.size()) - return 0; + return shared_ptr<Buffer>(); return bstore[choice]; } @@ -250,11 +261,11 @@ void BufferList::emergencyWriteAll() } -void BufferList::emergencyWrite(Buffer * buf) +void BufferList::emergencyWrite(shared_ptr<Buffer> const & buf) { // assert(buf) // this is not good since C assert takes an int // and a pointer is a long (JMarc) - assert(buf != 0); // use c assert to avoid a loop + assert(buf.get()); // use c assert to avoid a loop // No need to save if the buffer has not changed. @@ -310,9 +321,13 @@ void BufferList::emergencyWrite(Buffer * bool BufferList::exists(string const & s) const { - return find_if(bstore.begin(), bstore.end(), - lyx::compare_memfun(&Buffer::fileName, s)) - != bstore.end(); + BufferStorage::const_iterator cit = bstore.begin(); + BufferStorage::const_iterator end = bstore.end(); + for (; cit != end; ++cit) { + if ((*cit)->fileName() == s) + return true; + } + return false; } @@ -320,18 +335,25 @@ bool BufferList::isLoaded(Buffer const * { Assert(b); - BufferStorage::const_iterator cit = - find(bstore.begin(), bstore.end(), b); - return cit != bstore.end(); + BufferStorage::const_iterator cit = bstore.begin(); + BufferStorage::const_iterator end = bstore.end(); + for (; cit != end; ++cit) { + if (cit->get() == b) + return true; + } + return false; } -Buffer * BufferList::getBuffer(string const & s) +shared_ptr<Buffer> BufferList::getBuffer(string const & s) { - BufferStorage::iterator it = - find_if(bstore.begin(), bstore.end(), - lyx::compare_memfun(&Buffer::fileName, s)); - return it != bstore.end() ? (*it) : 0; + BufferStorage::iterator it = bstore.begin(); + BufferStorage::iterator end = bstore.end(); + for (; it != end; ++it) { + if ((*it)->fileName() == s) + break; + } + return it != end ? *it : shared_ptr<Buffer>(); } Index: src/bufferlist.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferlist.h,v retrieving revision 1.41 diff -u -p -r1.41 bufferlist.h --- src/bufferlist.h 28 Jun 2003 01:23:06 -0000 1.41 +++ src/bufferlist.h 18 Jul 2003 01:11:10 -0000 @@ -15,6 +15,7 @@ #include "LString.h" #include <boost/utility.hpp> +#include <boost/shared_ptr.hpp> #include <vector> @@ -33,10 +34,10 @@ public: bool quitWriteAll(); /// create a new buffer - Buffer * newBuffer(string const & s, bool ronly = false); + boost::shared_ptr<Buffer> newBuffer(string const & s, bool ronly = false); /// delete a buffer - void release(Buffer * b); + void release(boost::shared_ptr<Buffer> b); /// Close all open buffers. void closeAll(); @@ -51,13 +52,13 @@ public: void emergencyWriteAll(); /// close buffer. Returns false if cancelled by user - bool close(Buffer * buf, bool ask); + bool close(boost::shared_ptr<Buffer> buf, bool ask); /// return true if no buffers loaded bool empty() const; /// return head of buffer list if any - Buffer * first(); + boost::shared_ptr<Buffer> first(); /// returns true if the buffer exists already bool exists(string const &) const; @@ -66,24 +67,24 @@ public: bool isLoaded(Buffer const * b) const; /// returns a pointer to the buffer with the given name. - Buffer * getBuffer(string const &); + boost::shared_ptr<Buffer> getBuffer(string const &); /// returns a pointer to the buffer with the given number. - Buffer * getBuffer(unsigned int); + boost::shared_ptr<Buffer> getBuffer(unsigned int); /// reset current author for all buffers void setCurrentAuthor(string const & name, string const & email); private: /// ask to save a buffer on quit, returns false if should cancel - bool quitWriteBuffer(Buffer * buf); + bool quitWriteBuffer(boost::shared_ptr<Buffer> const & buf); - typedef std::vector<Buffer *> BufferStorage; + typedef std::vector<boost::shared_ptr<Buffer> > BufferStorage; /// storage of all buffers BufferStorage bstore; /// save emergency file for the given buffer - void emergencyWrite(Buffer * buf); + void emergencyWrite(boost::shared_ptr<Buffer> const & buf); }; #endif // BUFFERLIST_H Index: src/bufferview_funcs.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferview_funcs.C,v retrieving revision 1.86 diff -u -p -r1.86 bufferview_funcs.C --- src/bufferview_funcs.C 15 Jul 2003 06:51:46 -0000 1.86 +++ src/bufferview_funcs.C 18 Jul 2003 01:11:10 -0000 @@ -40,6 +40,8 @@ using namespace lyx::support; +using boost::shared_ptr; + namespace { @@ -307,7 +309,7 @@ string const currentState(BufferView * b ostringstream state; LyXText * text = bv->getLyXText(); - Buffer * buffer = bv->buffer(); + shared_ptr<Buffer> buffer = bv->buffer(); LyXCursor const & c(text->cursor); bool const show_change = buffer->params.tracking_changes @@ -405,9 +407,9 @@ void toggleAndShow(BufferView * bv, LyXF if (font.language() != ignore_language || font.number() != LyXFont::IGNORE) { LyXCursor & cursor = text->cursor; - text->computeBidiTables(bv->buffer(), text->cursorRow()); + text->computeBidiTables(bv->buffer().get(), text->cursorRow()); if (cursor.boundary() != - text->isBoundary(bv->buffer(), *cursor.par(), cursor.pos(), + text->isBoundary(bv->buffer().get(), *cursor.par(), cursor.pos(), text->real_current_font)) text->setCursor(cursor.par(), cursor.pos(), false, !cursor.boundary()); Index: src/factory.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/factory.C,v retrieving revision 1.35 diff -u -p -r1.35 factory.C --- src/factory.C 8 Jul 2003 14:19:24 -0000 1.35 +++ src/factory.C 18 Jul 2003 01:11:10 -0000 @@ -187,7 +187,7 @@ Inset * createInset(FuncRequest const & InsetCommandParams icp; InsetCommandMailer::string2params(cmd.argument, icp); InsetCitation * inset = new InsetCitation(icp); - inset->setLoadingBuffer(bv->buffer(), false); + inset->setLoadingBuffer(bv->buffer().get(), false); return inset; } else if (name == "ert") { @@ -348,9 +348,9 @@ Inset * readInset(LyXLex & lex, Buffer c inset = new InsetFormula; } else if (tmptok == "Graphics") { inset = new InsetGraphics; - } else if (tmptok == "Note" || tmptok == "Comment" + } else if (tmptok == "Note" || tmptok == "Comment" || tmptok == "Greyedout") { - inset = new InsetNote(buf.params, tmptok); + inset = new InsetNote(buf.params, tmptok); } else if (tmptok == "Include") { InsetCommandParams p("Include"); inset = new InsetInclude(p, buf); Index: src/lyx_cb.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_cb.C,v retrieving revision 1.210 diff -u -p -r1.210 lyx_cb.C --- src/lyx_cb.C 7 Jul 2003 08:36:58 -0000 1.210 +++ src/lyx_cb.C 18 Jul 2003 01:11:10 -0000 @@ -430,7 +430,7 @@ string const getPossibleLabel(BufferView lyxrc.label_init_length < 0) text.erase(); - string par_text = pit->asString(bv.buffer(), false); + string par_text = pit->asString(bv.buffer().get(), false); for (int i = 0; i < lyxrc.label_init_length; ++i) { if (par_text.empty()) break; Index: src/lyx_main.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_main.C,v retrieving revision 1.155 diff -u -p -r1.155 lyx_main.C --- src/lyx_main.C 7 Jul 2003 08:36:58 -0000 1.155 +++ src/lyx_main.C 18 Jul 2003 01:11:11 -0000 @@ -50,6 +50,8 @@ using namespace lyx::support; +using boost::shared_ptr; + using std::vector; using std::endl; @@ -145,7 +147,7 @@ LyX::LyX(int & argc, char * argv[]) lyxerr[Debug::INIT] << "About to handle -x '" << batch_command << '\'' << endl; - Buffer * last_loaded = 0; + shared_ptr<Buffer> last_loaded; vector<string>::const_iterator it = files.begin(); vector<string>::const_iterator end = files.end(); Index: src/lyxcursor.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxcursor.h,v retrieving revision 1.34 diff -u -p -r1.34 lyxcursor.h --- src/lyxcursor.h 16 Jul 2003 08:42:24 -0000 1.34 +++ src/lyxcursor.h 18 Jul 2003 01:11:11 -0000 @@ -111,7 +111,7 @@ private: int iy_; }; -/// +/// bool operator==(LyXCursor const & a, LyXCursor const & b); /// bool operator!=(LyXCursor const & a, LyXCursor const & b); Index: src/lyxfind.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfind.C,v retrieving revision 1.42 diff -u -p -r1.42 lyxfind.C --- src/lyxfind.C 30 Jun 2003 23:55:53 -0000 1.42 +++ src/lyxfind.C 18 Jul 2003 01:11:11 -0000 @@ -73,10 +73,10 @@ int LyXReplace(BufferView * bv, string str2; if (casesens) { str1 = searchstr; - str2 = text->selectionAsString(bv->buffer(), false); + str2 = text->selectionAsString(bv->buffer().get(), false); } else { str1 = lowercase(searchstr); - str2 = lowercase(text->selectionAsString(bv->buffer(), false)); + str2 = lowercase(text->selectionAsString(bv->buffer().get(), false)); } if (str1 != str2) { if (!LyXFind(bv, searchstr, fw, casesens, matchwrd) || Index: src/lyxfunc.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v retrieving revision 1.464 diff -u -p -r1.464 lyxfunc.C --- src/lyxfunc.C 16 Jul 2003 08:42:24 -0000 1.464 +++ src/lyxfunc.C 18 Jul 2003 01:11:11 -0000 @@ -80,6 +80,8 @@ using namespace lyx::support; +using boost::shared_ptr; + using std::pair; using std::make_pair; using std::endl; @@ -268,7 +270,7 @@ FuncStatus LyXFunc::getStatus(int ac) co FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const { FuncStatus flag; - Buffer * buf = owner->buffer(); + shared_ptr<Buffer> buf = owner->buffer(); if (ev.action == LFUN_NOACTION) { setStatusMessage(N_("Nothing to do")); @@ -323,7 +325,7 @@ FuncStatus LyXFunc::getStatus(FuncReques switch (ev.action) { case LFUN_EXPORT: disable = ev.argument != "custom" - && !Exporter::IsExportable(buf, ev.argument); + && !Exporter::IsExportable(buf.get(), ev.argument); break; case LFUN_UNDO: disable = buf->undostack.empty(); @@ -349,7 +351,7 @@ FuncStatus LyXFunc::getStatus(FuncReques disable = !buf->isLatex() || lyxrc.chktex_command == "none"; break; case LFUN_BUILDPROG: - disable = !Exporter::IsExportable(buf, "program"); + disable = !Exporter::IsExportable(buf.get(), "program"); break; case LFUN_LAYOUT_TABULAR: @@ -554,7 +556,7 @@ FuncStatus LyXFunc::getStatus(FuncReques } if (name == "print") { - disable = !Exporter::IsExportable(buf, "dvi") || + disable = !Exporter::IsExportable(buf.get(), "dvi") || lyxrc.print_command == "none"; } else if (name == "character") { UpdatableInset * tli = view()->theLockingInset(); @@ -808,16 +810,16 @@ namespace { Buffer & buf = *bv->buffer(); if (buf.isClean()) return true; - + string const file = MakeDisplayPath(buf.fileName(), 30); string text = bformat(_("The document %1$s has unsaved " "changes.\n\nDo you want to save " "the document?"), file); int const ret = Alert::prompt(_("Save changed document?"), - text, 0, 1, _("&Save"), + text, 0, 1, _("&Save"), _("&Cancel")); - if (ret == 0) + if (ret == 0) bv->owner()->dispatch(FuncRequest(LFUN_MENUWRITE)); return buf.isClean(); @@ -1097,14 +1099,14 @@ void LyXFunc::dispatch(FuncRequest const string const str = bformat(_("Saving document %1$s..."), MakeDisplayPath(owner->buffer()->fileName())); owner->message(str); - MenuWrite(owner->buffer()); + MenuWrite(owner->buffer().get()); owner->message(str + _(" done.")); } else - WriteAs(owner->buffer()); + WriteAs(owner->buffer().get()); break; case LFUN_WRITEAS: - WriteAs(owner->buffer(), argument); + WriteAs(owner->buffer().get(), argument); break; case LFUN_MENURELOAD: { @@ -1120,17 +1122,17 @@ void LyXFunc::dispatch(FuncRequest const } case LFUN_UPDATE: - Exporter::Export(owner->buffer(), argument, true); - view()->showErrorList(BufferFormat(*owner->buffer())); + Exporter::Export(owner->buffer().get(), argument, true); + view()->showErrorList(BufferFormat(*owner->buffer().get())); break; case LFUN_PREVIEW: - Exporter::Preview(owner->buffer(), argument); + Exporter::Preview(owner->buffer().get(), argument); view()->showErrorList(BufferFormat(*owner->buffer())); break; case LFUN_BUILDPROG: - Exporter::Export(owner->buffer(), "program", true); + Exporter::Export(owner->buffer().get(), "program", true); view()->showErrorList(_("Build")); break; @@ -1143,8 +1145,8 @@ void LyXFunc::dispatch(FuncRequest const if (argument == "custom") owner->getDialogs().showSendto(); else { - Exporter::Export(owner->buffer(), argument, false); - view()->showErrorList(BufferFormat(*owner->buffer())); + Exporter::Export(owner->buffer().get(), argument, false); + view()->showErrorList(BufferFormat(*owner->buffer().get())); } break; @@ -1914,7 +1916,7 @@ void LyXFunc::closeBuffer() { if (bufferlist.close(owner->buffer(), true) && !quitting) { if (bufferlist.empty()) { - // need this otherwise SEGV may occur while + // need this otherwise SEGV may occur while // trying to set variables that don't exist // since there's no current buffer owner->getDialogs().hideBufferDependent(); Index: src/paragraph_funcs.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph_funcs.C,v retrieving revision 1.48 diff -u -p -r1.48 paragraph_funcs.C --- src/paragraph_funcs.C 7 Jul 2003 08:37:00 -0000 1.48 +++ src/paragraph_funcs.C 18 Jul 2003 01:11:12 -0000 @@ -1009,7 +1009,7 @@ int readParToken(Buffer & buf, Paragraph string const s = bformat(_("Unknown token: %1$s %2$s\n"), token, lex.getString()); - buf.error(ErrorItem(_("Unknown token"), s, + buf.error(ErrorItem(_("Unknown token"), s, par.id(), 0, par.size())); return 1; } Index: src/rowpainter.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v retrieving revision 1.25 diff -u -p -r1.25 rowpainter.C --- src/rowpainter.C 17 Jul 2003 07:43:54 -0000 1.25 +++ src/rowpainter.C 18 Jul 2003 01:11:12 -0000 @@ -37,6 +37,8 @@ using namespace lyx::support; +using boost::shared_ptr; + using std::max; using lyx::pos_type; @@ -138,7 +140,7 @@ RowPainter::RowPainter(BufferView const /// "temporary" LyXFont const RowPainter::getFont(pos_type pos) const { - return text_.getFont(bv_.buffer(), pit_, pos); + return text_.getFont(bv_.buffer().get(), pit_, pos); } @@ -156,7 +158,7 @@ int RowPainter::singleWidth(lyx::pos_typ LyXFont const RowPainter::getLabelFont() const { - return text_.getLabelFont(bv_.buffer(), pit_); + return text_.getLabelFont(bv_.buffer().get(), pit_); } @@ -684,7 +686,7 @@ void RowPainter::paintFirst() y_top += paintLengthMarker(_("Space above"), parparams.spaceTop(), yo_ + y_top); - Buffer const * buffer = bv_.buffer(); + shared_ptr<Buffer> buffer = bv_.buffer(); LyXLayout_ptr const & layout = pit_->layout(); Index: src/text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.381 diff -u -p -r1.381 text.C --- src/text.C 17 Jul 2003 15:04:09 -0000 1.381 +++ src/text.C 18 Jul 2003 01:11:13 -0000 @@ -288,7 +288,7 @@ int LyXText::singleWidth(ParagraphList:: if (pos >= pit->size()) return 0; - LyXFont const font = getFont(bv()->buffer(), pit, pos); + LyXFont const font = getFont(bv()->buffer().get(), pit, pos); // The most common case is handled first (Asger) if (IsPrintable(c)) { @@ -600,7 +600,7 @@ int LyXText::leftMargin(Row const & row) } } - LyXFont const labelfont = getLabelFont(bv()->buffer(), row.par()); + LyXFont const labelfont = getLabelFont(bv()->buffer().get(), row.par()); switch (layout->margintype) { case MARGIN_DYNAMIC: if (!layout->leftmargin.empty()) { @@ -836,7 +836,7 @@ pos_type LyXText::rowBreakPoint(Row cons // add the auto-hfill from label end to the body if (body_pos && i == body_pos) { thiswidth = font_metrics::width(layout->labelsep, - getLabelFont(bv()->buffer(), pit)); + getLabelFont(bv()->buffer().get(), pit)); if (pit->isLineSeparator(i - 1)) thiswidth -= singleWidth(pit, i - 1); int left_margin = labelEnd(row); @@ -942,7 +942,7 @@ int LyXText::fill(RowList::iterator row, while (i <= last) { if (body_pos > 0 && i == body_pos) { - w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), pit)); + w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer().get(), pit)); if (pit->isLineSeparator(i - 1)) w -= singleWidth(pit, i - 1); int left_margin = labelEnd(*row); @@ -953,7 +953,7 @@ int LyXText::fill(RowList::iterator row, ++i; } if (body_pos > 0 && body_pos > last) { - w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), pit)); + w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer().get(), pit)); if (last >= 0 && pit->isLineSeparator(last)) w -= singleWidth(pit, last); int const left_margin = labelEnd(*row); @@ -1007,7 +1007,7 @@ int LyXText::labelFill(Row const & row) int fill = 0; string const & labwidstr = pit->params().labelWidthString(); if (!labwidstr.empty()) { - LyXFont const labfont = getLabelFont(bv()->buffer(), pit); + LyXFont const labfont = getLabelFont(bv()->buffer().get(), pit); int const labwidth = font_metrics::width(labwidstr, labfont); fill = max(labwidth - w, 0); } @@ -1050,13 +1050,13 @@ void LyXText::setHeightOfRow(RowList::it // as max get the first character of this row then it can increase but not // decrease the height. Just some point to start with so we don't have to // do the assignment below too often. - LyXFont font = getFont(bv()->buffer(), pit, rit->pos()); + LyXFont font = getFont(bv()->buffer().get(), pit, rit->pos()); LyXFont::FONT_SIZE const tmpsize = font.size(); - font = getLayoutFont(bv()->buffer(), pit); + font = getLayoutFont(bv()->buffer().get(), pit); LyXFont::FONT_SIZE const size = font.size(); font.setSize(tmpsize); - LyXFont labelfont = getLabelFont(bv()->buffer(), pit); + LyXFont labelfont = getLabelFont(bv()->buffer().get(), pit); float spacing_val = 1.0; if (!pit->params().spacing().isDefault()) { @@ -1081,7 +1081,7 @@ void LyXText::setHeightOfRow(RowList::it // Check if any insets are larger for (pos_type pos = rit->pos(); pos <= pos_end; ++pos) { if (pit->isInset(pos)) { - tmpfont = getFont(bv()->buffer(), pit, pos); + tmpfont = getFont(bv()->buffer().get(), pit, pos); tmpinset = pit->getInset(pos); if (tmpinset) { #if 1 // this is needed for deep update on initialitation @@ -1152,7 +1152,7 @@ void LyXText::setHeightOfRow(RowList::it // there height depends on the font of the nearest character if (pit->params().lineTop()) - maxasc += 2 * font_metrics::ascent('x', getFont(bv()->buffer(), + maxasc += 2 * font_metrics::ascent('x', getFont(bv()->buffer().get(), pit, 0)); // and now the pagebreaks if (pit->params().pagebreakTop()) @@ -1263,7 +1263,7 @@ void LyXText::setHeightOfRow(RowList::it // there height depends on the font of the nearest character if (pit->params().lineBottom()) maxdesc += 2 * font_metrics::ascent('x', - getFont(bv()->buffer(), + getFont(bv()->buffer().get(), pit, max(pos_type(0), pit->size() - 1))); @@ -1504,7 +1504,7 @@ void LyXText::breakParagraph(ParagraphLi // paragraph before or behind and we should react on that one // but we can fix this in 1.3.0 (Jug 20020509) bool const isempty = (cursor.par()->allowEmpty() && cursor.par()->empty()); - ::breakParagraph(bv()->buffer()->params, paragraphs, cursor.par(), + ::breakParagraph(bv()->buffer()->params, paragraphs, cursor.par(), cursor.pos(), keep_layout); // well this is the caption hack since one caption is really enough @@ -1593,10 +1593,10 @@ void LyXText::insertChar(char c) !(contains(number_seperators, c) && cursor.pos() >= 1 && cursor.pos() < cursor.par()->size() && - getFont(bv()->buffer(), + getFont(bv()->buffer().get(), cursor.par(), cursor.pos()).number() == LyXFont::ON && - getFont(bv()->buffer(), + getFont(bv()->buffer().get(), cursor.par(), cursor.pos() - 1).number() == LyXFont::ON) ) @@ -1612,16 +1612,16 @@ void LyXText::insertChar(char c) cursor.par()->isSeparator(cursor.pos() - 2) || cursor.par()->isNewline(cursor.pos() - 2)) ) { - setCharFont(bv()->buffer(), + setCharFont(bv()->buffer().get(), cursor.par(), cursor.pos() - 1, current_font); } else if (contains(number_seperators, c) && cursor.pos() >= 2 && - getFont(bv()->buffer(), + getFont(bv()->buffer().get(), cursor.par(), cursor.pos() - 2).number() == LyXFont::ON) { - setCharFont(bv()->buffer(), + setCharFont(bv()->buffer().get(), cursor.par(), cursor.pos() - 1, current_font); @@ -1690,7 +1690,7 @@ void LyXText::insertChar(char c) // Here case LyXText::InsertInset already inserted the character cursor.par()->insertChar(cursor.pos(), c); } - setCharFont(bv()->buffer(), cursor.par(), cursor.pos(), rawtmpfont); + setCharFont(bv()->buffer().get(), cursor.par(), cursor.pos(), rawtmpfont); if (!jumped_over_space) { // refresh the positions @@ -1779,7 +1779,7 @@ void LyXText::insertChar(char c) setCursor(cursor.par(), cursor.pos() + 1, false, cursor.boundary()); - if (isBoundary(bv()->buffer(), *cursor.par(), cursor.pos()) + if (isBoundary(bv()->buffer().get(), *cursor.par(), cursor.pos()) != cursor.boundary()) setCursor(cursor.par(), cursor.pos(), false, !cursor.boundary()); @@ -1936,7 +1936,7 @@ void LyXText::prepareToPrint(RowList::it if (!bidi) return; - computeBidiTables(bv()->buffer(), rit); + computeBidiTables(bv()->buffer().get(), rit); if (is_rtl) { pos_type body_pos = pit->beginningOfBody(); pos_type last = lastPos(*this, rit); @@ -1945,7 +1945,7 @@ void LyXText::prepareToPrint(RowList::it (body_pos - 1 > last || !pit->isLineSeparator(body_pos - 1))) { x += font_metrics::width(layout->labelsep, - getLabelFont(bv()->buffer(), + getLabelFont(bv()->buffer().get(), pit)); if (body_pos - 1 <= last) x += fill_label_hfill; @@ -2120,7 +2120,7 @@ LyXText::selectNextWordToSpellcheck(floa selection.cursor = cursor; string lang_code( - getFont(bv()->buffer(), cursor.par(), cursor.pos()) + getFont(bv()->buffer().get(), cursor.par(), cursor.pos()) .language()->code()); // and find the end of the word (insets like optional hyphens // and ligature break are part of a word) @@ -2487,7 +2487,7 @@ void LyXText::backspace() if (cursor.pos() < cursor.par()->size() && !cursor.par()->isSeparator(cursor.pos())) { cursor.par()->insertChar(cursor.pos(), ' '); - setCharFont(bv()->buffer(), cursor.par(), + setCharFont(bv()->buffer().get(), cursor.par(), cursor.pos(), current_font); // refresh the positions tmprow = row; @@ -2608,7 +2608,7 @@ void LyXText::backspace() // current_font = rawtmpfont; // real_current_font = realtmpfont; - if (isBoundary(bv()->buffer(), *cursor.par(), cursor.pos()) + if (isBoundary(bv()->buffer().get(), *cursor.par(), cursor.pos()) != cursor.boundary()) setCursor(cursor.par(), cursor.pos(), false, !cursor.boundary()); Index: src/text2.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v retrieving revision 1.391 diff -u -p -r1.391 text2.C --- src/text2.C 17 Jul 2003 15:57:07 -0000 1.391 +++ src/text2.C 18 Jul 2003 01:11:13 -0000 @@ -49,6 +49,8 @@ using namespace lyx::support; +using boost::shared_ptr; + using std::vector; using std::copy; using std::endl; @@ -92,7 +94,7 @@ void LyXText::init(BufferView * bview) ParagraphList::iterator pit = ownerParagraphs().begin(); ParagraphList::iterator end = ownerParagraphs().end(); - current_font = getFont(bview->buffer(), pit, 0); + current_font = getFont(bview->buffer().get(), pit, 0); for (; pit != end; ++pit) insertParagraph(pit, rowlist_.end()); @@ -198,8 +200,8 @@ void LyXText::setCharFont(ParagraphList: pos_type pos, LyXFont const & fnt, bool toggleall) { - Buffer const * buf = bv()->buffer(); - LyXFont font = getFont(buf, pit, pos); + shared_ptr<Buffer> buf = bv()->buffer(); + LyXFont font = getFont(buf.get(), pit, pos); font.update(fnt, buf->params.language, toggleall); // Let the insets convert their font if (pit->isInset(pos)) { @@ -212,7 +214,7 @@ void LyXText::setCharFont(ParagraphList: } // Plug thru to version below: - setCharFont(buf, pit, pos, font); + setCharFont(buf.get(), pit, pos, font); } @@ -551,10 +553,10 @@ void LyXText::setFont(LyXFont const & fo // Determine basis font LyXFont layoutfont; if (cursor.pos() < cursor.par()->beginningOfBody()) { - layoutfont = getLabelFont(bv()->buffer(), + layoutfont = getLabelFont(bv()->buffer().get(), cursor.par()); } else { - layoutfont = getLayoutFont(bv()->buffer(), + layoutfont = getLayoutFont(bv()->buffer().get(), cursor.par()); } // Update current font @@ -852,7 +854,7 @@ string LyXText::getStringToIndex() else if (selection.start.par() != selection.end.par()) bv()->owner()->message(_("Cannot index more than one paragraph!")); else - idxstring = selectionAsString(bv()->buffer(), false); + idxstring = selectionAsString(bv()->buffer().get(), false); // Reset cursors to their original position. cursor = reset_cursor; @@ -1175,7 +1177,7 @@ void LyXText::updateCounters() pit->params().depth(maxdepth); // setCounter can potentially change the labelString. - setCounter(bv()->buffer(), pit); + setCounter(bv()->buffer().get(), pit); string const & newLabel = pit->params().labelString(); @@ -1219,7 +1221,7 @@ void LyXText::cutSelection(bool doclear, // finished. The solution used currently just works, to make it // faster we need to be more clever and probably also have more // calls to stuffClipboard. (Lgb) - bv()->stuffClipboard(selectionAsString(bv()->buffer(), true)); + bv()->stuffClipboard(selectionAsString(bv()->buffer().get(), true)); // This doesn't make sense, if there is no selection if (!selection.set()) @@ -1289,7 +1291,7 @@ void LyXText::cutSelection(bool doclear, void LyXText::copySelection() { // stuff the selection onto the X clipboard, from an explicit copy request - bv()->stuffClipboard(selectionAsString(bv()->buffer(), true)); + bv()->stuffClipboard(selectionAsString(bv()->buffer().get(), true)); // this doesnt make sense, if there is no selection if (!selection.set()) @@ -1651,7 +1653,7 @@ float LyXText::getCursorX(RowList::itera x += fill_label_hfill + font_metrics::width( rit_par->layout()->labelsep, - getLabelFont(bv()->buffer(), rit_par)); + getLabelFont(bv()->buffer().get(), rit_par)); if (rit_par->isLineSeparator(body_pos - 1)) x -= singleWidth(rit_par, body_pos - 1); } @@ -1732,10 +1734,10 @@ void LyXText::setCurrentFont() current_font = pit->getFontSettings(bv()->buffer()->params, pos); - real_current_font = getFont(bv()->buffer(), pit, pos); + real_current_font = getFont(bv()->buffer().get(), pit, pos); if (cursor.pos() == pit->size() && - isBoundary(bv()->buffer(), *pit, cursor.pos()) && + isBoundary(bv()->buffer().get(), *pit, cursor.pos()) && !cursor.boundary()) { Language const * lang = pit->getParLanguage(bv()->buffer()->params); @@ -1789,7 +1791,7 @@ LyXText::getColumnNearX(RowList::iterato if (body_pos > 0 && c == body_pos - 1) { tmpx += fill_label_hfill + font_metrics::width(layout->labelsep, - getLabelFont(bv()->buffer(), rit_par)); + getLabelFont(bv()->buffer().get(), rit_par)); if (rit_par->isLineSeparator(body_pos - 1)) tmpx -= singleWidth(rit_par, body_pos - 1); } @@ -1845,7 +1847,7 @@ LyXText::getColumnNearX(RowList::iterato bool const rtl = (bidi_level(c) % 2 == 1); if (left_side == rtl) { ++c; - boundary = isBoundary(bv()->buffer(), *rit_par, c); + boundary = isBoundary(bv()->buffer().get(), *rit_par, c); } } @@ -1938,7 +1940,7 @@ void LyXText::cursorLeft(bool internal) bool boundary = cursor.boundary(); setCursor(cursor.par(), cursor.pos() - 1, true, false); if (!internal && !boundary && - isBoundary(bv()->buffer(), *cursor.par(), cursor.pos() + 1)) + isBoundary(bv()->buffer().get(), *cursor.par(), cursor.pos() + 1)) setCursor(cursor.par(), cursor.pos() + 1, true, true); } else if (cursor.par() != ownerParagraphs().begin()) { // steps into the above paragraph. ParagraphList::iterator pit = boost::prior(cursor.par()); @@ -1958,7 +1960,7 @@ void LyXText::cursorRight(bool internal) else if (!at_end) { setCursor(cursor.par(), cursor.pos() + 1, true, false); if (!internal && - isBoundary(bv()->buffer(), *cursor.par(), cursor.pos())) + isBoundary(bv()->buffer().get(), *cursor.par(), cursor.pos())) setCursor(cursor.par(), cursor.pos(), true, true); } else if (boost::next(cursor.par()) != ownerParagraphs().end()) setCursor(boost::next(cursor.par()), 0); Index: src/text3.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v retrieving revision 1.89 diff -u -p -r1.89 text3.C --- src/text3.C 15 Jul 2003 16:25:01 -0000 1.89 +++ src/text3.C 18 Jul 2003 01:11:14 -0000 @@ -113,7 +113,7 @@ namespace { // get inset dimensions Assert(par->getInset(pos)); - LyXFont const & font = text.getFont(bv->buffer(), par, pos); + LyXFont const & font = text.getFont(bv->buffer().get(), par, pos); int const width = inset->width(bv, font); int const inset_x = font.isVisibleRightToLeft() @@ -1295,7 +1295,7 @@ Inset::RESULT LyXText::dispatch(FuncRequ if (bv->theLockingInset()) { Inset * tli = bv->theLockingInset(); LyXCursor cursor = bv->text->cursor; - LyXFont font = bv->text->getFont(bv->buffer(), + LyXFont font = bv->text->getFont(bv->buffer().get(), cursor.par(), cursor.pos()); int width = tli->width(bv, font); int inset_x = font.isVisibleRightToLeft() Index: src/textcursor.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/textcursor.h,v retrieving revision 1.3 diff -u -p -r1.3 textcursor.h --- src/textcursor.h 1 Jul 2003 11:51:20 -0000 1.3 +++ src/textcursor.h 18 Jul 2003 01:11:14 -0000 @@ -28,7 +28,7 @@ Since the LyXText now has been moved from Buffer to BufferView it should not be absolutely needed to move the cursor... [even later] - It should neverthe less to keep classes and intedependencies small + It should neverthe less to keep classes and intedependencies small */ // The structure that keeps track of the selections set. Index: src/undo_funcs.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/undo_funcs.C,v retrieving revision 1.75 diff -u -p -r1.75 undo_funcs.C --- src/undo_funcs.C 15 Jul 2003 16:25:01 -0000 1.75 +++ src/undo_funcs.C 18 Jul 2003 01:11:14 -0000 @@ -20,6 +20,7 @@ #include "support/LAssert.h" #include "iterators.h" +using boost::shared_ptr; /// The flag used by FinishUndo(). bool undo_finished; @@ -46,7 +47,7 @@ void finishNoUndo(BufferView * bv) // Returns false if no undo possible. bool textHandleUndo(BufferView * bv, Undo & undo) { - Buffer * buf = bv->buffer(); + shared_ptr<Buffer> buf = bv->buffer(); ParagraphList * plist = &buf->paragraphs; /* @@ -164,7 +165,7 @@ void createUndo(BufferView * bv, Undo::u ParagraphList::iterator first, ParagraphList::iterator last, limited_stack<Undo> & stack) { - Buffer * buf = bv->buffer(); + shared_ptr<Buffer> buf = bv->buffer(); ParagraphList * plist = 0; ParIterator null = buf->par_iterator_end(); @@ -281,7 +282,7 @@ bool textUndoOrRedo(BufferView * bv, if (!undo_frozen) { otherstack.push(undo); otherstack.top().pars.clear(); - Buffer * buf = bv->buffer(); + shared_ptr<Buffer> buf = bv->buffer(); ParagraphList & plist = buf->paragraphs; lyxerr << "\nredo: first: " << undo.first_par_offset << "\n"; lyxerr << "redo: last: " << undo.last_par_offset << "\n"; Index: src/frontends/LyXView.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/LyXView.C,v retrieving revision 1.27 diff -u -p -r1.27 LyXView.C --- src/frontends/LyXView.C 30 Jun 2003 23:56:09 -0000 1.27 +++ src/frontends/LyXView.C 18 Jul 2003 01:11:14 -0000 @@ -40,6 +40,9 @@ #include <unistd.h> using namespace lyx::support; + +using boost::shared_ptr; + using std::endl; string current_layout; @@ -77,7 +80,7 @@ void LyXView::init() } -Buffer * LyXView::buffer() const +shared_ptr<Buffer> LyXView::buffer() const { return bufferview_->buffer(); } Index: src/frontends/LyXView.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/LyXView.h,v retrieving revision 1.21 diff -u -p -r1.21 LyXView.h --- src/frontends/LyXView.h 7 Apr 2003 16:57:37 -0000 1.21 +++ src/frontends/LyXView.h 18 Jul 2003 01:11:14 -0000 @@ -76,7 +76,7 @@ public: boost::shared_ptr<BufferView> const & view() const; /// return the buffer currently shown in this window - Buffer * buffer() const; + boost::shared_ptr<Buffer> buffer() const; /// return the LyX function handler for this view LyXFunc & getLyXFunc() { return *lyxfunc_.get(); } Index: src/frontends/screen.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/screen.C,v retrieving revision 1.50 diff -u -p -r1.50 screen.C --- src/frontends/screen.C 15 Jul 2003 16:25:02 -0000 1.50 +++ src/frontends/screen.C 18 Jul 2003 01:11:14 -0000 @@ -469,4 +469,3 @@ void LyXScreen::drawFromTo(LyXText * tex LColor::bottomarea); } } - Index: src/frontends/controllers/ControlConnections.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlConnections.C,v retrieving revision 1.23 diff -u -p -r1.23 ControlConnections.C --- src/frontends/controllers/ControlConnections.C 25 Feb 2003 14:51:33 -0000 1.23 +++ src/frontends/controllers/ControlConnections.C 18 Jul 2003 01:11:14 -0000 @@ -78,13 +78,7 @@ BufferView const * ControlConnectBase::b } -Buffer * ControlConnectBase::buffer() -{ - return lv_.buffer(); -} - - -Buffer const * ControlConnectBase::buffer() const +boost::shared_ptr<Buffer> ControlConnectBase::buffer() const { return lv_.buffer(); } Index: src/frontends/controllers/ControlConnections.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlConnections.h,v retrieving revision 1.20 diff -u -p -r1.20 ControlConnections.h --- src/frontends/controllers/ControlConnections.h 13 Feb 2003 16:52:47 -0000 1.20 +++ src/frontends/controllers/ControlConnections.h 18 Jul 2003 01:11:14 -0000 @@ -83,9 +83,7 @@ protected: /// BufferView const * bufferview() const; /// a wrapper for LyXView::buffer() - Buffer * buffer(); - /// - Buffer const * buffer() const; + boost::shared_ptr<Buffer> buffer() const; /// a wrapper for LyXView::getLyXFunc() LyXFunc & lyxfunc(); /// Index: src/frontends/controllers/ControlErrorList.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlErrorList.C,v retrieving revision 1.6 diff -u -p -r1.6 ControlErrorList.C --- src/frontends/controllers/ControlErrorList.C 12 Jun 2003 11:09:55 -0000 1.6 +++ src/frontends/controllers/ControlErrorList.C 18 Jul 2003 01:11:14 -0000 @@ -18,6 +18,7 @@ #include "lyxtext.h" #include "debug.h" +using boost::shared_ptr; using std::endl; @@ -59,7 +60,7 @@ void ControlErrorList::goTo(int item) if (err.par_id == -1) return; - Buffer * const buf = kernel().buffer(); + shared_ptr<Buffer> buf = kernel().buffer(); ParIterator pit = buf->getParFromID(err.par_id); if (pit == buf->par_iterator_end()) { Index: src/frontends/controllers/ControlPrint.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlPrint.C,v retrieving revision 1.36 diff -u -p -r1.36 ControlPrint.C --- src/frontends/controllers/ControlPrint.C 17 Jul 2003 08:23:33 -0000 1.36 +++ src/frontends/controllers/ControlPrint.C 18 Jul 2003 01:11:14 -0000 @@ -156,7 +156,7 @@ void ControlPrint::apply() command += buffer()->params.dvips_options() + ' '; - if (!Exporter::Export(buffer(), "dvi", true)) { + if (!Exporter::Export(buffer().get(), "dvi", true)) { showPrintError(buffer()->fileName()); return; } Index: src/frontends/controllers/ControlRef.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlRef.C,v retrieving revision 1.25 diff -u -p -r1.25 ControlRef.C --- src/frontends/controllers/ControlRef.C 30 Jun 2003 23:56:10 -0000 1.25 +++ src/frontends/controllers/ControlRef.C 18 Jul 2003 01:11:14 -0000 @@ -21,6 +21,8 @@ using namespace lyx::support; +using boost::shared_ptr; + using std::vector; extern BufferList bufferlist; @@ -33,7 +35,7 @@ ControlRef::ControlRef(Dialog & d) vector<string> const ControlRef::getLabelList(string const & name) const { - Buffer const * buf = bufferlist.getBuffer(MakeAbsPath(name)); + shared_ptr<Buffer> buf = bufferlist.getBuffer(MakeAbsPath(name)); if (!buf) buf = kernel().buffer(); vector<string> list; Index: src/frontends/controllers/ControlSendto.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlSendto.C,v retrieving revision 1.16 diff -u -p -r1.16 ControlSendto.C --- src/frontends/controllers/ControlSendto.C 30 Jun 2003 23:56:10 -0000 1.16 +++ src/frontends/controllers/ControlSendto.C 18 Jul 2003 01:11:14 -0000 @@ -125,7 +125,7 @@ void ControlSendto::apply() buffer()->writeFile(filename); } else { - Exporter::Export(buffer(), format_->name(), true, filename); + Exporter::Export(buffer().get(), format_->name(), true, filename); } // Substitute $$FName for filename Index: src/frontends/controllers/ControlTabular.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlTabular.C,v retrieving revision 1.12 diff -u -p -r1.12 ControlTabular.C --- src/frontends/controllers/ControlTabular.C 30 Jun 2003 23:56:10 -0000 1.12 +++ src/frontends/controllers/ControlTabular.C 18 Jul 2003 01:11:14 -0000 @@ -19,6 +19,8 @@ using namespace lyx::support; +using boost::shared_ptr; + ControlTabular::ControlTabular(Dialog & parent) : Dialog::Controller(parent), active_cell_(-1) @@ -27,11 +29,11 @@ ControlTabular::ControlTabular(Dialog & bool ControlTabular::initialiseParams(string const & data) { - Buffer * buffer = kernel().buffer(); + shared_ptr<Buffer> buffer = kernel().buffer(); if (!buffer) return false; - InsetTabular tmp(*buffer); + InsetTabular tmp(*buffer.get()); int cell = InsetTabularMailer::string2params(data, tmp); if (cell != -1) { params_.reset(new LyXTabular(tmp.tabular)); Index: src/frontends/controllers/ControlToc.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlToc.C,v retrieving revision 1.24 diff -u -p -r1.24 ControlToc.C --- src/frontends/controllers/ControlToc.C 27 Feb 2003 13:26:06 -0000 1.24 +++ src/frontends/controllers/ControlToc.C 18 Jul 2003 01:11:14 -0000 @@ -31,7 +31,7 @@ void ControlToc::goTo(toc::TocItem const vector<string> const ControlToc::getTypes() const { - return toc::getTypes(kernel().buffer()); + return toc::getTypes(kernel().buffer().get()); } @@ -44,7 +44,7 @@ toc::Toc const ControlToc::getContents(s return empty_list; } - toc::TocList tmp = toc::getTocList(kernel().buffer()); + toc::TocList tmp = toc::getTocList(kernel().buffer().get()); toc::TocList::iterator it = tmp.find(type); if (it == tmp.end()) { return empty_list; Index: src/frontends/controllers/Kernel.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/Kernel.C,v retrieving revision 1.3 diff -u -p -r1.3 Kernel.C --- src/frontends/controllers/Kernel.C 28 Jun 2003 01:23:09 -0000 1.3 +++ src/frontends/controllers/Kernel.C 18 Jul 2003 01:11:14 -0000 @@ -85,13 +85,7 @@ BufferView const * Kernel::bufferview() } -Buffer * Kernel::buffer() -{ - return lyxview_.buffer(); -} - - -Buffer const * Kernel::buffer() const +boost::shared_ptr<Buffer> Kernel::buffer() const { return lyxview_.buffer(); } Index: src/frontends/controllers/Kernel.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/Kernel.h,v retrieving revision 1.4 diff -u -p -r1.4 Kernel.h --- src/frontends/controllers/Kernel.h 16 Jul 2003 20:10:59 -0000 1.4 +++ src/frontends/controllers/Kernel.h 18 Jul 2003 01:11:15 -0000 @@ -15,6 +15,7 @@ #include "LString.h" +#include <boost/shared_ptr.hpp> class Buffer; class BufferView; @@ -87,8 +88,7 @@ public: LyXView & lyxview() { return lyxview_; } LyXView const & lyxview() const { return lyxview_; } - Buffer * buffer(); - Buffer const * buffer() const; + boost::shared_ptr<Buffer> buffer() const; BufferView * bufferview(); BufferView const * bufferview() const; Index: src/graphics/PreviewedInset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/PreviewedInset.C,v retrieving revision 1.15 diff -u -p -r1.15 PreviewedInset.C --- src/graphics/PreviewedInset.C 4 Jul 2003 08:23:20 -0000 1.15 +++ src/graphics/PreviewedInset.C 18 Jul 2003 01:11:15 -0000 @@ -52,7 +52,7 @@ void PreviewedInset::generatePreview() return; Previews & previews = Previews::get(); - PreviewLoader & loader = previews.loader(view()->buffer()); + PreviewLoader & loader = previews.loader(view()->buffer().get()); addPreview(loader); if (!snippet_.empty()) loader.startLoading(); @@ -90,7 +90,7 @@ void PreviewedInset::removePreview() return; Previews & previews = Previews::get(); - PreviewLoader & loader = previews.loader(view()->buffer()); + PreviewLoader & loader = previews.loader(view()->buffer().get()); loader.remove(snippet_); snippet_.erase(); pimage_ = 0; @@ -105,7 +105,7 @@ bool PreviewedInset::previewReady() cons if (!pimage_ || snippet_ != pimage_->snippet()) { PreviewLoader & ploader = - Previews::get().loader(view()->buffer()); + Previews::get().loader(view()->buffer().get()); pimage_ = ploader.preview(snippet_); } Index: src/insets/insetcite.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcite.C,v retrieving revision 1.57 diff -u -p -r1.57 insetcite.C --- src/insets/insetcite.C 30 Jun 2003 23:56:17 -0000 1.57 +++ src/insets/insetcite.C 18 Jul 2003 01:11:15 -0000 @@ -331,7 +331,7 @@ dispatch_result InsetCitation::localDisp case LFUN_INSET_EDIT: // A call to edit indicates that we're no longer loading the // buffer but doing some real work. - setLoadingBuffer(cmd.view()->buffer(), false); + setLoadingBuffer(cmd.view()->buffer().get(), false); InsetCommandMailer("citation", *this).showDialog(cmd.view()); return DISPATCHED; Index: src/insets/insetcommand.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcommand.C,v retrieving revision 1.77 diff -u -p -r1.77 insetcommand.C --- src/insets/insetcommand.C 12 Jun 2003 08:52:36 -0000 1.77 +++ src/insets/insetcommand.C 18 Jul 2003 01:11:15 -0000 @@ -43,7 +43,7 @@ void InsetCommand::metrics(MetricsInfo & { if (!set_label_) { set_label_ = true; - button_.update(getScreenLabel(mi.base.bv->buffer()), + button_.update(getScreenLabel(mi.base.bv->buffer().get()), editable() != NOT_EDITABLE); } button_.metrics(mi, dim); Index: src/insets/insetexternal.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetexternal.C,v retrieving revision 1.83 diff -u -p -r1.83 insetexternal.C --- src/insets/insetexternal.C 4 Jul 2003 08:23:21 -0000 1.83 +++ src/insets/insetexternal.C 18 Jul 2003 01:11:15 -0000 @@ -138,7 +138,7 @@ dispatch_result InsetExternal::localDisp InsetExternal::Params p; InsetExternalMailer::string2params(cmd.argument, p); - editExternal(p, cmd.view()->buffer()); + editExternal(p, cmd.view()->buffer().get()); return DISPATCHED_NOUPDATE; } Index: src/insets/insetinclude.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetinclude.C,v retrieving revision 1.128 diff -u -p -r1.128 insetinclude.C --- src/insets/insetinclude.C 4 Jul 2003 08:23:21 -0000 1.128 +++ src/insets/insetinclude.C 18 Jul 2003 01:11:15 -0000 @@ -45,6 +45,8 @@ using namespace lyx::support; +using boost::shared_ptr; + using std::ostream; using std::endl; using std::vector; @@ -298,7 +300,7 @@ bool InsetInclude::loadIfNeeded() const FileInfo finfo(getFileName()); if (!finfo.isOK()) return false; - return loadLyXFile(bufferlist.newBuffer(getFileName()), + return ::loadLyXFile(bufferlist.newBuffer(getFileName()), getFileName()); } @@ -313,7 +315,7 @@ int InsetInclude::latex(Buffer const * b return 0; if (loadIfNeeded()) { - Buffer * tmp = bufferlist.getBuffer(getFileName()); + shared_ptr<Buffer> tmp = bufferlist.getBuffer(getFileName()); // FIXME: this should be a GUI warning if (tmp->params.textclass != buffer->params.textclass) { @@ -388,7 +390,7 @@ int InsetInclude::linuxdoc(Buffer const return 0; if (loadIfNeeded()) { - Buffer * tmp = bufferlist.getBuffer(getFileName()); + shared_ptr<Buffer> tmp = bufferlist.getBuffer(getFileName()); // write it to a file (so far the complete file) string writefile = ChangeExtension(getFileName(), ".sgml"); @@ -428,7 +430,7 @@ int InsetInclude::docbook(Buffer const * return 0; if (loadIfNeeded()) { - Buffer * tmp = bufferlist.getBuffer(getFileName()); + shared_ptr<Buffer> tmp = bufferlist.getBuffer(getFileName()); // write it to a file (so far the complete file) string writefile = ChangeExtension(getFileName(), ".sgml"); @@ -463,7 +465,7 @@ void InsetInclude::validate(LaTeXFeature string incfile(params_.cparams.getContents()); string writefile; - Buffer const * const b = bufferlist.getBuffer(getMasterFilename()); + shared_ptr<Buffer> b = bufferlist.getBuffer(getMasterFilename()); if (b && !b->tmppath.empty() && !b->niceFile && !isVerbatim()) { incfile = subst(incfile, '/','@'); @@ -484,7 +486,7 @@ void InsetInclude::validate(LaTeXFeature // to be loaded: if (loadIfNeeded()) { // a file got loaded - Buffer * const tmp = bufferlist.getBuffer(getFileName()); + shared_ptr<Buffer> tmp = bufferlist.getBuffer(getFileName()); if (tmp) { if (b) tmp->niceFile = b->niceFile; @@ -497,7 +499,7 @@ void InsetInclude::validate(LaTeXFeature void InsetInclude::getLabelList(std::vector<string> & list) const { if (loadIfNeeded()) { - Buffer * tmp = bufferlist.getBuffer(getFileName()); + shared_ptr<Buffer> tmp = bufferlist.getBuffer(getFileName()); tmp->setParentName(""); tmp->getLabelList(list); tmp->setParentName(getMasterFilename()); @@ -508,7 +510,7 @@ void InsetInclude::getLabelList(std::vec void InsetInclude::fillWithBibKeys(std::vector<std::pair<string,string> > & keys) const { if (loadIfNeeded()) { - Buffer * tmp = bufferlist.getBuffer(getFileName()); + shared_ptr<Buffer> tmp = bufferlist.getBuffer(getFileName()); tmp->setParentName(""); tmp->fillWithBibKeys(keys); tmp->setParentName(getMasterFilename()); @@ -525,7 +527,7 @@ void InsetInclude::metrics(MetricsInfo & } else { if (!set_label_) { set_label_ = true; - button_.update(getScreenLabel(mi.base.bv->buffer()), + button_.update(getScreenLabel(mi.base.bv->buffer().get()), editable() != NOT_EDITABLE); } button_.metrics(mi, dim); @@ -582,7 +584,7 @@ string const InsetInclude::PreviewImpl:: ostringstream os; LatexRunParams runparams; runparams.flavor = LatexRunParams::LATEX; - parent().latex(view()->buffer(), os, runparams); + parent().latex(view()->buffer().get(), os, runparams); return STRCONV(os.str()); } Index: src/insets/insettabular.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v retrieving revision 1.304 diff -u -p -r1.304 insettabular.C --- src/insets/insettabular.C 17 Jul 2003 15:57:07 -0000 1.304 +++ src/insets/insettabular.C 18 Jul 2003 01:11:16 -0000 @@ -262,7 +262,7 @@ void InsetTabular::metrics(MetricsInfo & lyxerr << "InsetTabular::metrics: need bv\n"; Assert(0); } - + calculate_dimensions_of_cells(mi.base.bv); //lyxerr << "InsetTabular::metrics, bv: " << mi.base.bv << endl; for (int i = 0; i < tabular.getNumberOfCells(); ++i) { @@ -280,7 +280,7 @@ void InsetTabular::metrics(MetricsInfo & cell.metrics(m, d); } //lyxerr << endl; - + dim.asc = tabular.getAscentOfRow(0); dim.des = tabular.getHeightOfTabular() - tabular.getAscentOfRow(0) + 1; dim.wid = tabular.getWidthOfTabular() + 2 * ADD_TO_TABULAR_WIDTH; @@ -1937,7 +1937,7 @@ void InsetTabular::tabularFeatures(Buffe tabular.unsetMultiColumn(actcell); updateLocal(bv, INIT); } else { - tabular.setMultiColumn(bv->buffer(), actcell, 1); + tabular.setMultiColumn(bv->buffer().get(), actcell, 1); updateLocal(bv, CELL); } break; @@ -1954,7 +1954,7 @@ void InsetTabular::tabularFeatures(Buffe s_start = sel_cell_start; s_end = sel_cell_end; } - tabular.setMultiColumn(bv->buffer(), s_start, s_end - s_start + 1); + tabular.setMultiColumn(bv->buffer().get(), s_start, s_end - s_start + 1); actcell = s_start; clearSelection(); updateLocal(bv, INIT); @@ -2385,8 +2385,8 @@ bool InsetTabular::copySelection(BufferV true, true); ostringstream sstr; - paste_tabular->ascii(bv->buffer(), sstr, - (int)parOwner()->params().depth(), true, '\t'); + paste_tabular->ascii(bv->buffer().get(), sstr, + parOwner()->params().depth(), true, '\t'); bv->stuffClipboard(STRCONV(sstr.str())); return true; } @@ -2787,7 +2787,7 @@ bool InsetTabular::insertAsciiString(Buf if (cols < columns) { InsetText * ti = loctab->getCellInset(cell); LyXFont const font = ti->getLyXText(bv)-> - getFont(bv->buffer(), ti->paragraphs.begin(), 0); + getFont(bv->buffer().get(), ti->paragraphs.begin(), 0); ti->setText(buf.substr(op, p - op), font); ++cols; ++cell; @@ -2798,7 +2798,7 @@ bool InsetTabular::insertAsciiString(Buf if (cols < columns) { InsetText * ti = loctab->getCellInset(cell); LyXFont const font = ti->getLyXText(bv)-> - getFont(bv->buffer(), ti->paragraphs.begin(), 0); + getFont(bv->buffer().get(), ti->paragraphs.begin(), 0); ti->setText(buf.substr(op, p - op), font); } cols = ocol; @@ -2814,7 +2814,7 @@ bool InsetTabular::insertAsciiString(Buf if ((cell < cells) && (op < len)) { InsetText * ti = loctab->getCellInset(cell); LyXFont const font = ti->getLyXText(bv)-> - getFont(bv->buffer(), ti->paragraphs.begin(), 0); + getFont(bv->buffer().get(), ti->paragraphs.begin(), 0); ti->setText(buf.substr(op, len - op), font); } Index: src/insets/insettext.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v retrieving revision 1.436 diff -u -p -r1.436 insettext.C --- src/insets/insettext.C 17 Jul 2003 15:57:08 -0000 1.436 +++ src/insets/insettext.C 18 Jul 2003 01:11:16 -0000 @@ -1516,7 +1516,7 @@ void InsetText::fitInsetCursor(BufferVie return; } LyXFont const font = - getLyXText(bv)->getFont(bv->buffer(), cpar(), cpos()); + getLyXText(bv)->getFont(bv->buffer().get(), cpar(), cpos()); int const asc = font_metrics::maxAscent(font); int const desc = font_metrics::maxDescent(font); @@ -1863,7 +1863,7 @@ int InsetText::cx(BufferView * bv) const { int x = text_.cursor.x() + top_x + TEXT_TO_INSET_OFFSET; if (the_locking_inset) { - LyXFont font = text_.getFont(bv->buffer(), text_.cursor.par(), + LyXFont font = text_.getFont(bv->buffer().get(), text_.cursor.par(), text_.cursor.pos()); if (font.isVisibleRightToLeft()) x -= the_locking_inset->width(bv, font); @@ -1876,7 +1876,7 @@ int InsetText::cix(BufferView * bv) cons { int x = text_.cursor.ix() + top_x + TEXT_TO_INSET_OFFSET; if (the_locking_inset) { - LyXFont font = text_.getFont(bv->buffer(), text_.cursor.par(), + LyXFont font = text_.getFont(bv->buffer().get(), text_.cursor.par(), text_.cursor.pos()); if (font.isVisibleRightToLeft()) x -= the_locking_inset->width(bv, font); Index: src/mathed/formulabase.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulabase.C,v retrieving revision 1.274 diff -u -p -r1.274 formulabase.C --- src/mathed/formulabase.C 17 Jul 2003 16:55:03 -0000 1.274 +++ src/mathed/formulabase.C 18 Jul 2003 01:11:17 -0000 @@ -900,7 +900,7 @@ void mathDispatchCreation(FuncRequest co // sel = ""; //else - string sel = bv->getLyXText()->selectionAsString(bv->buffer(), false); + string sel = bv->getLyXText()->selectionAsString(bv->buffer().get(), false); if (sel.empty()) { InsetFormula * f = new InsetFormula(bv);
-- Lgb