From 0fcae6cc10640f2d5a591152d59d252bb6dc0757 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Tue, 21 Aug 2007 13:03:55 +0000 Subject: [PATCH] * BufferView::buffer() returns a reference instead of a pointer. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19691 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Bidi.cpp | 4 +- src/BufferView.cpp | 8 +-- src/BufferView.h | 4 +- src/Cursor.cpp | 13 ++--- src/LyXFunc.cpp | 2 +- src/Text.cpp | 6 +-- src/Text2.cpp | 2 +- src/Text3.cpp | 28 +++++------ src/TextMetrics.cpp | 24 ++++----- src/Undo.cpp | 50 +++++++++---------- src/VSpace.cpp | 2 +- src/bufferview_funcs.cpp | 4 +- src/callback.cpp | 29 ++++------- src/factory.cpp | 10 ++-- src/frontends/LyXView.cpp | 6 +-- src/frontends/WorkArea.cpp | 4 +- .../controllers/ControlErrorList.cpp | 6 +-- .../controllers/ControlSpellchecker.cpp | 2 +- .../controllers/ControlViewSource.cpp | 8 +-- src/frontends/controllers/Kernel.cpp | 4 +- src/frontends/qt4/GuiView.cpp | 6 +-- src/insets/InsetBibitem.cpp | 2 +- src/insets/InsetCollapsable.cpp | 2 +- src/insets/InsetCommand.cpp | 2 +- src/insets/InsetFootlike.cpp | 4 +- src/insets/InsetGraphics.cpp | 2 +- src/insets/InsetInclude.cpp | 8 +-- src/insets/InsetLabel.cpp | 2 +- src/insets/InsetTabular.cpp | 20 ++++---- src/insets/MailInset.cpp | 4 +- src/insets/RenderPreview.cpp | 12 ++--- src/lyxfind.cpp | 20 +++----- src/mathed/InsetMathHull.cpp | 6 +-- src/mathed/MathData.cpp | 2 +- src/rowpainter.cpp | 39 +++++++-------- src/toc.cpp | 8 +-- 36 files changed, 169 insertions(+), 186 deletions(-) diff --git a/src/Bidi.cpp b/src/Bidi.cpp index 37cb87520a..1688fca15a 100644 --- a/src/Bidi.cpp +++ b/src/Bidi.cpp @@ -227,14 +227,14 @@ bool reverseDirectionNeeded(Cursor const & cur) * cursor gets stuck. */ return cur.bottom().paragraph().isRightToLeftPar( - cur.bv().buffer()->params()); + cur.bv().buffer().params()); } bool isWithinRtlParagraph(Cursor const & cur) { return cur.innerParagraph().isRightToLeftPar( - cur.bv().buffer()->params()); + cur.bv().buffer().params()); } } // namespace lyx diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 75566e54e0..b7776050cd 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -145,15 +145,15 @@ BufferView::~BufferView() } -Buffer * BufferView::buffer() +Buffer & BufferView::buffer() { - return &buffer_; + return buffer_; } -Buffer const * BufferView::buffer() const +Buffer const & BufferView::buffer() const { - return &buffer_; + return buffer_; } diff --git a/src/BufferView.h b/src/BufferView.h index ea51376a78..21d49f91e9 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -85,8 +85,8 @@ public: ~BufferView(); /// return the buffer being viewed. - Buffer * buffer(); - Buffer const * buffer() const; + Buffer & buffer(); + Buffer const & buffer() const; /// perform pending metrics updates. /** \c Update::FitCursor means first to do a FitCursor, and to diff --git a/src/Cursor.cpp b/src/Cursor.cpp index e6cea1ff95..111434b6c8 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -206,7 +206,7 @@ namespace { // << " xlow: " << xlow << " xhigh: " << xhigh // << " ylow: " << ylow << " yhigh: " << yhigh // << endl; - Inset & inset = bv.buffer()->inset(); + Inset & inset = bv.buffer().inset(); DocIterator it = doc_iterator_begin(inset); it.pit() = from; DocIterator et = doc_iterator_end(inset); @@ -351,8 +351,7 @@ BufferView & Cursor::bv() const Buffer & Cursor::buffer() const { BOOST_ASSERT(bv_); - BOOST_ASSERT(bv_->buffer()); - return *bv_->buffer(); + return bv_->buffer(); } @@ -1336,7 +1335,7 @@ docstring Cursor::selectionAsString(bool label) const return docstring(); if (inTexted()) { - Buffer const & buffer = *bv().buffer(); + Buffer const & buffer = bv().buffer(); ParagraphList const & pars = text()->paragraphs(); // should be const ... @@ -1398,8 +1397,6 @@ Encoding const * Cursor::getEncoding() const { if (empty()) return 0; - if (!bv().buffer()) - return 0; int s = 0; // go up until first non-0 text is hit // (innermost text is 0 in mathed) @@ -1409,7 +1406,7 @@ Encoding const * Cursor::getEncoding() const CursorSlice const & sl = operator[](s); Text const & text = *sl.text(); Font font = text.getPar(sl.pit()).getFont( - bv().buffer()->params(), sl.pos(), outerFont(sl.pit(), text.paragraphs())); + bv().buffer().params(), sl.pos(), outerFont(sl.pit(), text.paragraphs())); return font.language()->encoding(); } @@ -1469,7 +1466,7 @@ Font Cursor::getFont() const } // get font at the position - Font font = par.getFont(bv().buffer()->params(), pos, + Font font = par.getFont(bv().buffer().params(), pos, outerFont(sl.pit(), text.paragraphs())); return font; diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index fea925ab58..3961a39c6d 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -764,7 +764,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const bool LyXFunc::ensureBufferClean(BufferView * bv) { - Buffer & buf = *bv->buffer(); + Buffer & buf = bv->buffer(); if (buf.isClean()) return true; diff --git a/src/Text.cpp b/src/Text.cpp index d03cf5bffa..61467dc207 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -1313,7 +1313,7 @@ bool Text::backspace(Cursor & cur) bool Text::dissolveInset(Cursor & cur) { BOOST_ASSERT(this == cur.text()); - if (isMainText(*cur.bv().buffer()) || cur.inset().nargs() != 1) + if (isMainText(cur.bv().buffer()) || cur.inset().nargs() != 1) return false; recordUndoInset(cur); @@ -1449,7 +1449,7 @@ void Text::drawRowSelection(PainterInfo & pi, int x, Row const & row, bool drawOnBegMargin, bool drawOnEndMargin) const { BufferView & bv = *pi.base.bv; - Buffer & buffer = *bv.buffer(); + Buffer & buffer = bv.buffer(); TextMetrics const & tm = bv.textMetrics(this); DocIterator cur = beg; int x1 = cursorX(bv, beg.top(), beg.boundary()); @@ -1662,7 +1662,7 @@ int Text::cursorX(BufferView const & bv, CursorSlice const & sl, pos_type cursor_vpos = 0; - Buffer const & buffer = *bv.buffer(); + Buffer const & buffer = bv.buffer(); RowMetrics const m = tm.computeRowMetrics(pit, row); double x = m.x; Bidi bidi; diff --git a/src/Text2.cpp b/src/Text2.cpp index dcabce00ed..92eaba739b 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -371,7 +371,7 @@ void Text::setLayout(Cursor & cur, docstring const & layout) BOOST_ASSERT(this == cur.text()); // special handling of new environment insets BufferView & bv = cur.bv(); - BufferParams const & params = bv.buffer()->params(); + BufferParams const & params = bv.buffer().params(); Layout_ptr const & lyxlayout = params.getTextClass()[layout]; if (lyxlayout->is_environment) { // move everything in a new environment inset diff --git a/src/Text3.cpp b/src/Text3.cpp index ee0e7b1fc9..e730e268a1 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -820,15 +820,15 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cur.message(_("Paste")); cap::replaceSelection(cur); if (cmd.argument().empty() && !theClipboard().isInternal()) - pasteClipboard(cur, bv->buffer()->errorList("Paste")); + pasteClipboard(cur, bv->buffer().errorList("Paste")); else { string const arg(to_utf8(cmd.argument())); - pasteFromStack(cur, bv->buffer()->errorList("Paste"), + pasteFromStack(cur, bv->buffer().errorList("Paste"), isStrUnsignedInt(arg) ? convert(arg) : 0); } - bv->buffer()->errors("Paste"); + bv->buffer().errors("Paste"); cur.clearSelection(); // bug 393 finishUndo(); break; @@ -881,7 +881,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) // Derive layout number from given argument (string) // and current buffer's textclass (number) - TextClass const & tclass = bv->buffer()->params().getTextClass(); + TextClass const & tclass = bv->buffer().params().getTextClass(); if (layout.empty()) layout = tclass.defaultLayoutName(); bool hasLayout = tclass.hasLayout(layout); @@ -925,9 +925,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_CLIPBOARD_PASTE: cur.clearSelection(); - pasteClipboard(cur, bv->buffer()->errorList("Paste"), + pasteClipboard(cur, bv->buffer().errorList("Paste"), cmd.argument() == "paragraph"); - bv->buffer()->errors("Paste"); + bv->buffer().errors("Paste"); break; case LFUN_PRIMARY_SELECTION_PASTE: @@ -953,7 +953,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_QUOTE_INSERT: { Paragraph & par = cur.paragraph(); pos_type pos = cur.pos(); - BufferParams const & bufparams = bv->buffer()->params(); + BufferParams const & bufparams = bv->buffer().params(); Layout_ptr const & style = par.layout(); if (!style->pass_thru && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") { @@ -1031,9 +1031,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cap::copySelectionToStack(); cap::pasteSelection(bv->cursor(), - bv->buffer()->errorList("Paste")); - bv->buffer()->errors("Paste"); - bv->buffer()->markDirty(); + bv->buffer().errorList("Paste")); + bv->buffer().errors("Paste"); + bv->buffer().markDirty(); finishUndo(); } else { lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph")); @@ -1212,7 +1212,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) // inside it. doInsertInset(cur, this, cmd, true, true); cur.posRight(); - updateLabels(*bv->buffer()); + updateLabels(bv->buffer()); break; case LFUN_NOTE_INSERT: case LFUN_CHARSTYLE_INSERT: @@ -1249,7 +1249,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cur.posRight(); ParagraphList & pars = cur.text()->paragraphs(); - TextClass const & tclass = bv->buffer()->params().getTextClass(); + TextClass const & tclass = bv->buffer().params().getTextClass(); // add a separate paragraph for the caption inset pars.push_back(Paragraph()); @@ -1516,7 +1516,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) break; case LFUN_FLOAT_LIST: { - TextClass const & tclass = bv->buffer()->params().getTextClass(); + TextClass const & tclass = bv->buffer().params().getTextClass(); if (tclass.floats().typeExist(to_utf8(cmd.argument()))) { recordUndo(cur); if (cur.selection()) @@ -1896,7 +1896,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, break; case LFUN_INSET_DISSOLVE: - enable = !isMainText(*cur.bv().buffer()) && cur.inset().nargs() == 1; + enable = !isMainText(cur.bv().buffer()) && cur.inset().nargs() == 1; break; case LFUN_CHANGE_ACCEPT: diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 7b10179f24..7aae097c88 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -115,7 +115,7 @@ TextMetrics::TextMetrics(BufferView * bv, Text * text) dim_.asc = 10; dim_.des = 10; - //text_->updateLabels(*bv->buffer()); + //text_->updateLabels(bv->buffer()); } @@ -172,13 +172,13 @@ bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim) int TextMetrics::rightMargin(ParagraphMetrics const & pm) const { - return main_text_? pm.rightMargin(*bv_->buffer()) : 0; + return main_text_? pm.rightMargin(bv_->buffer()) : 0; } int TextMetrics::rightMargin(pit_type const pit) const { - return main_text_? par_metrics_[pit].rightMargin(*bv_->buffer()) : 0; + return main_text_? par_metrics_[pit].rightMargin(bv_->buffer()) : 0; } @@ -191,7 +191,7 @@ bool TextMetrics::redoParagraph(pit_type const pit) // reinitialize paragraph dimension. pm.dim() = Dimension(); Paragraph & par = text_->getPar(pit); - Buffer & buffer = *bv_->buffer(); + Buffer & buffer = bv_->buffer(); main_text_ = (text_ == &buffer.text()); bool changed = false; @@ -275,7 +275,7 @@ RowMetrics TextMetrics::computeRowMetrics(pit_type const pit, Row const & row) const { RowMetrics result; - Buffer & buffer = *bv_->buffer(); + Buffer & buffer = bv_->buffer(); Paragraph const & par = text_->getPar(pit); double w = dim_.wid - row.width(); @@ -397,7 +397,7 @@ RowMetrics TextMetrics::computeRowMetrics(pit_type const pit, int TextMetrics::labelFill(pit_type const pit, Row const & row) const { - Buffer & buffer = *bv_->buffer(); + Buffer & buffer = bv_->buffer(); Paragraph const & par = text_->getPar(pit); pos_type last = par.beginOfBody(); @@ -448,14 +448,14 @@ int TextMetrics::labelEnd(pit_type const pit) const if (text_->getPar(pit).layout()->margintype != MARGIN_MANUAL) return 0; // return the beginning of the body - return text_->leftMargin(*bv_->buffer(), max_width_, pit); + return text_->leftMargin(bv_->buffer(), max_width_, pit); } void TextMetrics::rowBreakPoint(int width, pit_type const pit, Row & row) const { - Buffer & buffer = *bv_->buffer(); + Buffer & buffer = bv_->buffer(); ParagraphMetrics const & pm = par_metrics_[pit]; Paragraph const & par = text_->getPar(pit); pos_type const end = par.size(); @@ -571,7 +571,7 @@ void TextMetrics::rowBreakPoint(int width, pit_type const pit, void TextMetrics::setRowWidth(int right_margin, pit_type const pit, Row & row) const { - Buffer & buffer = *bv_->buffer(); + Buffer & buffer = bv_->buffer(); // get the pure distance pos_type const end = row.endpos(); ParagraphMetrics const & pm = par_metrics_[pit]; @@ -628,7 +628,7 @@ void TextMetrics::setHeightOfRow(pit_type const pit, // increase but not decrease the height. Just some point to // start with so we don't have to do the assignment below too // often. - Buffer const & buffer = *bv_->buffer(); + Buffer const & buffer = bv_->buffer(); Font font = text_->getFont(buffer, par, row.pos()); Font::FONT_SIZE const tmpsize = font.size(); font = text_->getLayoutFont(buffer, pit); @@ -808,7 +808,7 @@ void TextMetrics::setHeightOfRow(pit_type const pit, pos_type TextMetrics::getColumnNearX(pit_type const pit, Row const & row, int & x, bool & boundary) const { - Buffer const & buffer = *bv_->buffer(); + Buffer const & buffer = bv_->buffer(); /// For the main Text, it is possible that this pit is not /// yet in the CoordCache when moving cursor up. @@ -957,7 +957,7 @@ pos_type TextMetrics::x2pos(pit_type pit, int row, int x) const int TextMetrics::singleWidth(pit_type pit, pos_type pos) const { - Buffer const & buffer = *bv_->buffer(); + Buffer const & buffer = bv_->buffer(); ParagraphMetrics const & pm = par_metrics_[pit]; return pm.singleWidth(pos, text_->getFont(buffer, text_->getPar(pit), pos)); diff --git a/src/Undo.cpp b/src/Undo.cpp index 20c76462e3..8b6af36301 100644 --- a/src/Undo.cpp +++ b/src/Undo.cpp @@ -133,7 +133,7 @@ void recordUndo(Undo::undo_kind kind, BOOST_ASSERT(last_pit <= cur.lastpit()); doRecordUndo(kind, cur, first_pit, last_pit, cur, - cur.bv().buffer()->params(), false, stack); + cur.bv().buffer().params(), false, stack); } @@ -154,8 +154,8 @@ bool textUndoOrRedo(BufferView & bv, stack.pop(); // We will store in otherstack the part of the document under 'undo' - Buffer * buf = bv.buffer(); - DocIterator cell_dit = undo.cell.asDocIterator(&buf->inset()); + Buffer & buf = bv.buffer(); + DocIterator cell_dit = undo.cell.asDocIterator(&buf.inset()); doRecordUndo(Undo::ATOMIC, cell_dit, undo.from, cell_dit.lastpit() - undo.end, bv.cursor(), @@ -165,13 +165,13 @@ bool textUndoOrRedo(BufferView & bv, // This does the actual undo/redo. //lyxerr << "undo, performing: " << undo << std::endl; bool labelsUpdateNeeded = false; - DocIterator dit = undo.cell.asDocIterator(&buf->inset()); + DocIterator dit = undo.cell.asDocIterator(&buf.inset()); if (undo.isFullBuffer) { BOOST_ASSERT(undo.pars); // This is a full document - otherstack.top().bparams = buf->params(); - buf->params() = undo.bparams; - std::swap(buf->paragraphs(), *undo.pars); + otherstack.top().bparams = buf.params(); + buf.params() = undo.bparams; + std::swap(buf.paragraphs(), *undo.pars); delete undo.pars; undo.pars = 0; } else if (dit.inMathed()) { @@ -217,13 +217,13 @@ bool textUndoOrRedo(BufferView & bv, // Set cursor Cursor & cur = bv.cursor(); - cur.setCursor(undo.cursor.asDocIterator(&buf->inset())); + cur.setCursor(undo.cursor.asDocIterator(&buf.inset())); cur.selection() = false; cur.resetAnchor(); cur.fixIfBroken(); if (labelsUpdateNeeded) - updateLabels(*buf); + updateLabels(buf); finishUndo(); return true; } @@ -240,27 +240,27 @@ void finishUndo() bool textUndo(BufferView & bv) { - return textUndoOrRedo(bv, bv.buffer()->undostack(), - bv.buffer()->redostack()); + return textUndoOrRedo(bv, bv.buffer().undostack(), + bv.buffer().redostack()); } bool textRedo(BufferView & bv) { - return textUndoOrRedo(bv, bv.buffer()->redostack(), - bv.buffer()->undostack()); + return textUndoOrRedo(bv, bv.buffer().redostack(), + bv.buffer().undostack()); } void recordUndo(Undo::undo_kind kind, Cursor & cur, pit_type first, pit_type last) { - Buffer * buf = cur.bv().buffer(); - recordUndo(kind, cur, first, last, buf->undostack()); - buf->redostack().clear(); + Buffer & buf = cur.bv().buffer(); + recordUndo(kind, cur, first, last, buf.undostack()); + buf.redostack().clear(); //lyxerr << "undostack:\n"; - //for (size_t i = 0, n = buf->undostack().size(); i != n && i < 6; ++i) - // lyxerr << " " << i << ": " << buf->undostack()[i] << std::endl; + //for (size_t i = 0, n = buf.undostack().size(); i != n && i < 6; ++i) + // lyxerr << " " << i << ": " << buf.undostack()[i] << std::endl; } @@ -274,9 +274,9 @@ void recordUndoInset(Cursor & cur, Undo::undo_kind kind) { Cursor c = cur; c.pop(); - Buffer * buf = cur.bv().buffer(); + Buffer & buf = cur.bv().buffer(); doRecordUndo(kind, c, c.pit(), c.pit(), cur, - buf->params(), false, buf->undostack()); + buf.params(), false, buf.undostack()); } @@ -301,15 +301,15 @@ void recordUndo(Cursor & cur, Undo::undo_kind kind, void recordUndoFullDocument(BufferView * bv) { - Buffer * buf = bv->buffer(); + Buffer & buf = bv->buffer(); doRecordUndo( Undo::ATOMIC, - doc_iterator_begin(buf->inset()), - 0, buf->paragraphs().size() - 1, + doc_iterator_begin(buf.inset()), + 0, buf.paragraphs().size() - 1, bv->cursor(), - buf->params(), + buf.params(), true, - buf->undostack() + buf.undostack() ); undo_finished = false; } diff --git a/src/VSpace.cpp b/src/VSpace.cpp index bae4c799e5..0b5929d3bf 100644 --- a/src/VSpace.cpp +++ b/src/VSpace.cpp @@ -519,7 +519,7 @@ int VSpace::inPixels(BufferView const & bv) const switch (kind_) { case DEFSKIP: - return bv.buffer()->params().getDefSkip().inPixels(bv); + return bv.buffer().params().getDefSkip().inPixels(bv); // This is how the skips are normally defined by LateX. // But there should be some way to change this per document. diff --git a/src/bufferview_funcs.cpp b/src/bufferview_funcs.cpp index f109326899..fff484cd48 100644 --- a/src/bufferview_funcs.cpp +++ b/src/bufferview_funcs.cpp @@ -175,7 +175,7 @@ Point coordOffset(BufferView const & bv, DocIterator const & dit, // of xx:yy if (sl.text()) { bool boundary_i = boundary && i + 1 == dit.depth(); - bool rtl = sl.text()->isRTL(*bv.buffer(), sl, boundary_i); + bool rtl = sl.text()->isRTL(bv.buffer(), sl, boundary_i); if (rtl) x -= lastw; } @@ -217,7 +217,7 @@ Point coordOffset(BufferView const & bv, DocIterator const & dit, // In the RTL case place the nested inset at the left of the cursor in // the outer paragraph bool boundary_1 = boundary && 1 == dit.depth(); - bool rtl = dit.bottom().text()->isRTL(*bv.buffer(), dit.bottom(), boundary_1); + bool rtl = dit.bottom().text()->isRTL(bv.buffer(), dit.bottom(), boundary_1); if (rtl) x -= lastw; diff --git a/src/callback.cpp b/src/callback.cpp index d0ee831216..87da777504 100644 --- a/src/callback.cpp +++ b/src/callback.cpp @@ -253,7 +253,7 @@ int AutoSaveBuffer::generateChild() FileName const tmp_ret(tempName(FileName(), "lyxauto")); if (!tmp_ret.empty()) { - bv_.buffer()->writeFile(tmp_ret); + bv_.buffer().writeFile(tmp_ret); // assume successful write of tmp_ret if (!rename(tmp_ret, fname_)) { failed = true; @@ -269,12 +269,11 @@ int AutoSaveBuffer::generateChild() if (failed) { // failed to write/rename tmp_ret so try writing direct - if (!bv_.buffer()->writeFile(fname_)) { + if (!bv_.buffer().writeFile(fname_)) { // It is dangerous to do this in the child, // but safe in the parent, so... if (pid == -1) // emit message signal. - bv_.buffer() - ->message(_("Autosave failed!")); + bv_.buffer().message(_("Autosave failed!")); } } if (pid == 0) { // we are the child so... @@ -291,29 +290,26 @@ void autoSave(BufferView * bv) // should probably be moved into BufferList (Lgb) // Perfect target for a thread... { - if (!bv->buffer()) - return; - - if (bv->buffer()->isBakClean() || bv->buffer()->isReadonly()) { + if (bv->buffer().isBakClean() || bv->buffer().isReadonly()) { // We don't save now, but we'll try again later - bv->buffer()->resetAutosaveTimers(); + bv->buffer().resetAutosaveTimers(); return; } // emit message signal. - bv->buffer()->message(_("Autosaving current document...")); + bv->buffer().message(_("Autosaving current document...")); // create autosave filename - string fname = bv->buffer()->filePath(); + string fname = bv->buffer().filePath(); fname += '#'; - fname += onlyFilename(bv->buffer()->fileName()); + fname += onlyFilename(bv->buffer().fileName()); fname += '#'; AutoSaveBuffer autosave(*bv, FileName(fname)); autosave.start(); - bv->buffer()->markBakClean(); - bv->buffer()->resetAutosaveTimers(); + bv->buffer().markBakClean(); + bv->buffer().resetAutosaveTimers(); } @@ -342,9 +338,6 @@ void newFile(LyXView & lv, string const & filename) // Insert plain text file (if filename is empty, prompt for one) void insertPlaintextFile(BufferView * bv, string const & f, bool asParagraph) { - if (!bv->buffer()) - return; - docstring const tmpstr = getContentsOfPlaintextFile(bv, f, asParagraph); @@ -373,7 +366,7 @@ docstring const getContentsOfPlaintextFile(BufferView * bv, string const & f, : LFUN_FILE_INSERT_PLAINTEXT) ); FileDialog::Result result = - fileDlg.open(from_utf8(bv->buffer()->filePath()), + fileDlg.open(from_utf8(bv->buffer().filePath()), FileFilterList(), docstring()); if (result.first == FileDialog::Later) diff --git a/src/factory.cpp b/src/factory.cpp index fc6468056b..c790a37703 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -82,7 +82,7 @@ using support::compare_ascii_no_case; Inset * createInset(BufferView * bv, FuncRequest const & cmd) { - BufferParams const & params = bv->buffer()->params(); + BufferParams const & params = bv->buffer().params(); try { @@ -207,7 +207,7 @@ Inset * createInset(BufferView * bv, FuncRequest const & cmd) r = 2; if (c <= 0) c = 2; - return new InsetTabular(*bv->buffer(), r, c); + return new InsetTabular(bv->buffer(), r, c); } case LFUN_CAPTION_INSERT: { @@ -270,7 +270,7 @@ Inset * createInset(BufferView * bv, FuncRequest const & cmd) return new InsetListings(params, par); } else if (name == "external") { - Buffer const & buffer = *bv->buffer(); + Buffer const & buffer = bv->buffer(); InsetExternalParams iep; InsetExternalMailer::string2params(to_utf8(cmd.argument()), buffer, iep); @@ -279,7 +279,7 @@ Inset * createInset(BufferView * bv, FuncRequest const & cmd) return inset.release(); } else if (name == "graphics") { - Buffer const & buffer = *bv->buffer(); + Buffer const & buffer = bv->buffer(); InsetGraphicsParams igp; InsetGraphicsMailer::string2params(to_utf8(cmd.argument()), buffer, igp); @@ -314,7 +314,7 @@ Inset * createInset(BufferView * bv, FuncRequest const & cmd) InsetCommandParams icp(name); InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp); - return new InsetRef(icp, *bv->buffer()); + return new InsetRef(icp, bv->buffer()); } else if (name == "toc") { InsetCommandParams icp("tableofcontents"); diff --git a/src/frontends/LyXView.cpp b/src/frontends/LyXView.cpp index bf83d3cc46..a70655dc8c 100644 --- a/src/frontends/LyXView.cpp +++ b/src/frontends/LyXView.cpp @@ -95,7 +95,7 @@ Buffer * LyXView::buffer() { WorkArea * work_area = currentWorkArea(); if (work_area) - return work_area->bufferView().buffer(); + return &work_area->bufferView().buffer(); return 0; } @@ -104,7 +104,7 @@ Buffer const * LyXView::buffer() const { WorkArea const * work_area = currentWorkArea(); if (work_area) - return work_area->bufferView().buffer(); + return &work_area->bufferView().buffer(); return 0; } @@ -445,7 +445,7 @@ Buffer const * const LyXView::updateInset(Inset const * inset) BOOST_ASSERT(work_area); work_area->scheduleRedraw(); } - return work_area->bufferView().buffer(); + return &work_area->bufferView().buffer(); } } // namespace frontend diff --git a/src/frontends/WorkArea.cpp b/src/frontends/WorkArea.cpp index cb13604e99..037831ab08 100644 --- a/src/frontends/WorkArea.cpp +++ b/src/frontends/WorkArea.cpp @@ -97,7 +97,7 @@ WorkArea::~WorkArea() // restore to the left of the top level inset. Cursor & cur = buffer_view_->cursor(); LyX::ref().session().lastFilePos().save( - support::FileName(buffer_view_->buffer()->fileName()), + support::FileName(buffer_view_->buffer().fileName()), boost::tie(cur.bottom().pit(), cur.bottom().pos()) ); delete buffer_view_; @@ -291,7 +291,7 @@ void WorkArea::showCursor() Text const & text = *buffer_view_->cursor().innerText(); Font const & realfont = text.real_current_font; - BufferParams const & bp = buffer_view_->buffer()->params(); + BufferParams const & bp = buffer_view_->buffer().params(); bool const samelang = realfont.language() == bp.language; bool const isrtl = realfont.isVisibleRightToLeft(); diff --git a/src/frontends/controllers/ControlErrorList.cpp b/src/frontends/controllers/ControlErrorList.cpp index 372218262d..8686dab62c 100644 --- a/src/frontends/controllers/ControlErrorList.cpp +++ b/src/frontends/controllers/ControlErrorList.cpp @@ -44,18 +44,18 @@ void ControlErrorList::clearParams() ErrorList const & ControlErrorList::errorList() const { - return kernel().bufferview()->buffer()->errorList(error_type_); + return kernel().bufferview()->buffer().errorList(error_type_); } bool ControlErrorList::initialiseParams(string const & error_type) { error_type_ = error_type; - Buffer * buf = kernel().bufferview()->buffer(); + Buffer const & buf = kernel().bufferview()->buffer(); // FIXME UNICODE docstring const title = bformat(_("%1$s Errors (%2$s)"), _(error_type), - lyx::from_utf8(buf->fileName())); + lyx::from_utf8(buf.fileName())); name_ = lyx::to_utf8(title); return true; } diff --git a/src/frontends/controllers/ControlSpellchecker.cpp b/src/frontends/controllers/ControlSpellchecker.cpp index e62bb01959..d1954c8498 100644 --- a/src/frontends/controllers/ControlSpellchecker.cpp +++ b/src/frontends/controllers/ControlSpellchecker.cpp @@ -148,7 +148,7 @@ bool isLetter(DocIterator const & dit) WordLangTuple nextWord(Cursor & cur, ptrdiff_t & progress) { - BufferParams const & bp = cur.bv().buffer()->params(); + BufferParams const & bp = cur.bv().buffer().params(); bool inword = false; bool ignoreword = false; cur.resetAnchor(); diff --git a/src/frontends/controllers/ControlViewSource.cpp b/src/frontends/controllers/ControlViewSource.cpp index d3b9b6c33b..e0e4946ce5 100644 --- a/src/frontends/controllers/ControlViewSource.cpp +++ b/src/frontends/controllers/ControlViewSource.cpp @@ -54,7 +54,7 @@ docstring const ControlViewSource::updateContent(bool fullSource) if (par_begin > par_end) std::swap(par_begin, par_end); lyx::odocstringstream ostr; - view->buffer()->getSourceCode(ostr, par_begin, par_end + 1, fullSource); + view->buffer().getSourceCode(ostr, par_begin, par_end + 1, fullSource); return ostr.str(); } @@ -65,11 +65,11 @@ std::pair ControlViewSource::getRows() const CursorSlice beg = view->cursor().selectionBegin().bottom(); CursorSlice end = view->cursor().selectionEnd().bottom(); - int begrow = view->buffer()->texrow(). + int begrow = view->buffer().texrow(). getRowFromIdPos(beg.paragraph().id(), beg.pos()); - int endrow = view->buffer()->texrow(). + int endrow = view->buffer().texrow(). getRowFromIdPos(end.paragraph().id(), end.pos()); - int nextendrow = view->buffer()->texrow(). + int nextendrow = view->buffer().texrow(). getRowFromIdPos(end.paragraph().id(), end.pos() + 1); return std::make_pair(begrow, endrow == nextendrow ? endrow : (nextendrow - 1)); } diff --git a/src/frontends/controllers/Kernel.cpp b/src/frontends/controllers/Kernel.cpp index f9b189ac11..8fef84232f 100644 --- a/src/frontends/controllers/Kernel.cpp +++ b/src/frontends/controllers/Kernel.cpp @@ -49,9 +49,7 @@ void Kernel::disconnect(string const & name) const bool Kernel::isBufferAvailable() const { - if (!lyxview_.view()) - return false; - return lyxview_.view()->buffer() != 0; + return lyxview_.buffer() != 0; } diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index ab114f783e..60bc88455f 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -647,7 +647,7 @@ void GuiView::currentTabChanged(int i) BOOST_ASSERT(wa); BufferView & bv = wa->bufferView(); connectBufferView(bv); - connectBuffer(*bv.buffer()); + connectBuffer(bv.buffer()); bv.updateMetrics(false); bv.cursor().fixIfBroken(); wa->setUpdatesEnabled(true); @@ -666,7 +666,7 @@ void GuiView::currentTabChanged(int i) updateStatusBar(); lyxerr << "currentTabChanged " << i - << "File" << wa->bufferView().buffer()->fileName() << endl; + << "File" << bv.buffer().fileName() << endl; } @@ -846,7 +846,7 @@ WorkArea * GuiView::workArea(Buffer & buffer) for (int i = 0; i != d.tab_widget_->count(); ++i) { GuiWorkArea * wa = dynamic_cast(d.tab_widget_->widget(i)); BOOST_ASSERT(wa); - if (wa->bufferView().buffer() == &buffer) + if (&wa->bufferView().buffer() == &buffer) return wa; } return 0; diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index a9d5dee14e..b0beb594ac 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -69,7 +69,7 @@ void InsetBibitem::doDispatch(Cursor & cur, FuncRequest & cmd) break; } if (p["key"] != params()["key"]) - cur.bv().buffer()->changeRefsIfUnique(params()["key"], + cur.bv().buffer().changeRefsIfUnique(params()["key"], p["key"], Inset::CITE_CODE); setParams(p); } diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index 314ec4bada..4108be2393 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -600,7 +600,7 @@ void InsetCollapsable::setStatus(Cursor & cur, CollapseStatus status) // Because the collapse status is part of the inset and thus an // integral part of the Buffer contents a changed status must be // signaled to all views of current buffer. - cur.bv().buffer()->changed(); + cur.bv().buffer().changed(); } diff --git a/src/insets/InsetCommand.cpp b/src/insets/InsetCommand.cpp index ea52598dc1..61afc712be 100644 --- a/src/insets/InsetCommand.cpp +++ b/src/insets/InsetCommand.cpp @@ -53,7 +53,7 @@ bool InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const { if (updateButtonLabel_) { updateButtonLabel_ = false; - button_.update(getScreenLabel(*mi.base.bv->buffer()), + button_.update(getScreenLabel(mi.base.bv->buffer()), editable() != NOT_EDITABLE); } button_.metrics(mi, dim); diff --git a/src/insets/InsetFootlike.cpp b/src/insets/InsetFootlike.cpp index fff8555d90..c42ee1dba2 100644 --- a/src/insets/InsetFootlike.cpp +++ b/src/insets/InsetFootlike.cpp @@ -32,7 +32,7 @@ InsetFootlike::InsetFootlike(InsetFootlike const & in) bool InsetFootlike::metrics(MetricsInfo & mi, Dimension & dim) const { Font tmpfont = mi.base.font; - mi.base.font = mi.base.bv->buffer()->params().getFont(); + mi.base.font = mi.base.bv->buffer().params().getFont(); InsetCollapsable::metrics(mi, dim); mi.base.font = tmpfont; bool const changed = dim_ != dim; @@ -44,7 +44,7 @@ bool InsetFootlike::metrics(MetricsInfo & mi, Dimension & dim) const void InsetFootlike::draw(PainterInfo & pi, int x, int y) const { Font tmpfont = pi.base.font; - pi.base.font = pi.base.bv->buffer()->params().getFont(); + pi.base.font = pi.base.bv->buffer().params().getFont(); InsetCollapsable::draw(pi, x, y); pi.base.font = tmpfont; } diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp index 1203d27188..318bd55708 100644 --- a/src/insets/InsetGraphics.cpp +++ b/src/insets/InsetGraphics.cpp @@ -181,7 +181,7 @@ void InsetGraphics::doDispatch(Cursor & cur, FuncRequest & cmd) { switch (cmd.action) { case LFUN_GRAPHICS_EDIT: { - Buffer const & buffer = *cur.bv().buffer(); + Buffer const & buffer = cur.bv().buffer(); InsetGraphicsParams p; InsetGraphicsMailer::string2params(to_utf8(cmd.argument()), buffer, p); editGraphics(p, buffer); diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 4276e4455e..d2bd3652ef 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -148,7 +148,7 @@ void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd) if (par_old.getParamValue("label") != par_new.getParamValue("label") && !par_new.getParamValue("label").empty()) - cur.bv().buffer()->changeRefsIfUnique( + cur.bv().buffer().changeRefsIfUnique( from_utf8(par_old.getParamValue("label")), from_utf8(par_new.getParamValue("label")), Inset::REF_CODE); @@ -770,7 +770,7 @@ bool InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const bool use_preview = false; if (RenderPreview::status() != LyXRC::PREVIEW_OFF) { graphics::PreviewImage const * pimage = - preview_->getPreviewImage(*mi.base.bv->buffer()); + preview_->getPreviewImage(mi.base.bv->buffer()); use_preview = pimage && pimage->image(); } @@ -779,7 +779,7 @@ bool InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const } else { if (!set_label_) { set_label_ = true; - button_.update(getScreenLabel(*mi.base.bv->buffer()), + button_.update(getScreenLabel(mi.base.bv->buffer()), true); } button_.metrics(mi, dim); @@ -803,7 +803,7 @@ void InsetInclude::draw(PainterInfo & pi, int x, int y) const bool use_preview = false; if (RenderPreview::status() != LyXRC::PREVIEW_OFF) { graphics::PreviewImage const * pimage = - preview_->getPreviewImage(*pi.base.bv->buffer()); + preview_->getPreviewImage(pi.base.bv->buffer()); use_preview = pimage && pimage->image(); } diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index bca76ee44c..d1d582b7c0 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -67,7 +67,7 @@ void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd) break; } if (p["name"] != params()["name"]) - cur.bv().buffer()->changeRefsIfUnique(params()["name"], + cur.bv().buffer().changeRefsIfUnique(params()["name"], p["name"], Inset::REF_CODE); setParams(p); break; diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index b4fef42542..eabacc1e12 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -1098,14 +1098,14 @@ void toggleFixedWidth(Cursor & cur, InsetText * inset, bool fixedWidth) return; // merge all paragraphs to one - BufferParams const & bp = cur.bv().buffer()->params(); + BufferParams const & bp = cur.bv().buffer().params(); while (inset->paragraphs().size() > 1) mergeParagraph(bp, inset->paragraphs(), 0); // reset layout cur.push(*inset); // undo information has already been recorded - inset->getText(0)->setLayout(*cur.bv().buffer(), 0, cur.lastpit() + 1, + inset->getText(0)->setLayout(cur.bv().buffer(), 0, cur.lastpit() + 1, bp.getTextClass().defaultLayoutName()); cur.pop(); } @@ -4167,12 +4167,12 @@ void InsetTabular::tabularFeatures(Cursor & cur, case Tabular::APPEND_ROW: // append the row into the tabular - tabular.appendRow(bv.buffer()->params(), cur.idx()); + tabular.appendRow(bv.buffer().params(), cur.idx()); break; case Tabular::APPEND_COLUMN: // append the column into the tabular - tabular.appendColumn(bv.buffer()->params(), cur.idx()); + tabular.appendColumn(bv.buffer().params(), cur.idx()); cur.idx() = tabular.getCellNumber(row, column); break; @@ -4199,11 +4199,11 @@ void InsetTabular::tabularFeatures(Cursor & cur, break; case Tabular::COPY_ROW: - tabular.copyRow(bv.buffer()->params(), row); + tabular.copyRow(bv.buffer().params(), row); break; case Tabular::COPY_COLUMN: - tabular.copyColumn(bv.buffer()->params(), column); + tabular.copyColumn(bv.buffer().params(), column); cur.idx() = tabular.getCellNumber(row, column); break; @@ -4302,14 +4302,14 @@ void InsetTabular::tabularFeatures(Cursor & cur, if (tabular.isMultiColumn(cur.idx())) tabular.unsetMultiColumn(cur.idx()); else - tabular.setMultiColumn(bv.buffer(), cur.idx(), 1); + tabular.setMultiColumn(&bv.buffer(), cur.idx(), 1); break; } // we have a selection so this means we just add all this // cells to form a multicolumn cell idx_type const s_start = cur.selBegin().idx(); idx_type const s_end = cur.selEnd().idx(); - tabular.setMultiColumn(bv.buffer(), s_start, s_end - s_start + 1); + tabular.setMultiColumn(&bv.buffer(), s_start, s_end - s_start + 1); cur.idx() = s_start; cur.pit() = 0; cur.pos() = 0; @@ -4619,7 +4619,7 @@ bool InsetTabular::isRightToLeft(Cursor & cur) const BOOST_ASSERT(cur.depth() > 1); Paragraph const & parentpar = cur[cur.depth() - 2].paragraph(); pos_type const parentpos = cur[cur.depth() - 2].pos(); - return parentpar.getFontSettings(cur.bv().buffer()->params(), + return parentpar.getFontSettings(cur.bv().buffer().params(), parentpos).language()->rightToLeft(); } @@ -4684,7 +4684,7 @@ bool InsetTabular::insertPlaintextString(BufferView & bv, docstring const & buf, if (buf.length() <= 0) return true; - Buffer const & buffer = *bv.buffer(); + Buffer const & buffer = bv.buffer(); col_type cols = 1; row_type rows = 1; diff --git a/src/insets/MailInset.cpp b/src/insets/MailInset.cpp index 6a7d09edd2..d5a7a5bf1a 100644 --- a/src/insets/MailInset.cpp +++ b/src/insets/MailInset.cpp @@ -25,7 +25,7 @@ using std::string; void MailInset::showDialog(BufferView * bv) const { BOOST_ASSERT(bv); - bv->showInsetDialog(name(), inset2string(*bv->buffer()), + bv->showInsetDialog(name(), inset2string(bv->buffer()), &inset()); } @@ -33,7 +33,7 @@ void MailInset::showDialog(BufferView * bv) const void MailInset::updateDialog(BufferView * bv) const { BOOST_ASSERT(bv); - bv->updateDialog(name(), inset2string(*bv->buffer())); + bv->updateDialog(name(), inset2string(bv->buffer())); } diff --git a/src/insets/RenderPreview.cpp b/src/insets/RenderPreview.cpp index 199c5a766b..4afbe8d500 100644 --- a/src/insets/RenderPreview.cpp +++ b/src/insets/RenderPreview.cpp @@ -86,9 +86,9 @@ graphics::PreviewLoader & getPreviewLoader(Buffer const & buffer) docstring const statusMessage(BufferView const * bv, string const & snippet) { - BOOST_ASSERT(bv && bv->buffer()); + BOOST_ASSERT(bv); - Buffer const & buffer = *bv->buffer(); + Buffer const & buffer = bv->buffer(); graphics::PreviewLoader const & loader = getPreviewLoader(buffer); graphics::PreviewLoader::Status const status = loader.status(snippet); @@ -122,10 +122,10 @@ RenderPreview::getPreviewImage(Buffer const & buffer) const bool RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const { - BOOST_ASSERT(mi.base.bv && mi.base.bv->buffer()); + BOOST_ASSERT(mi.base.bv); graphics::PreviewImage const * const pimage = - getPreviewImage(*mi.base.bv->buffer()); + getPreviewImage(mi.base.bv->buffer()); if (pimage) { dim.asc = pimage->ascent(); @@ -150,10 +150,10 @@ bool RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const void RenderPreview::draw(PainterInfo & pi, int x, int y) const { - BOOST_ASSERT(pi.base.bv && pi.base.bv->buffer()); + BOOST_ASSERT(pi.base.bv); graphics::PreviewImage const * const pimage = - getPreviewImage(*pi.base.bv->buffer()); + getPreviewImage(pi.base.bv->buffer()); graphics::Image const * const image = pimage ? pimage->image() : 0; if (image) { diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 92dcfa8a09..14760d0e33 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -144,7 +144,7 @@ bool searchAllowed(BufferView * bv, docstring const & str) _("Search string is empty")); return false; } - return bv->buffer(); + return true; } @@ -172,7 +172,7 @@ int replaceAll(BufferView * bv, docstring const & searchstr, docstring const & replacestr, bool cs, bool mw) { - Buffer & buf = *bv->buffer(); + Buffer & buf = bv->buffer(); if (!searchAllowed(bv, searchstr) || buf.isReadonly()) return 0; @@ -227,7 +227,7 @@ bool stringSelected(BufferView * bv, docstring const & searchstr, int replace(BufferView * bv, docstring const & searchstr, docstring const & replacestr, bool cs, bool mw, bool fw) { - if (!searchAllowed(bv, searchstr) || bv->buffer()->isReadonly()) + if (!searchAllowed(bv, searchstr) || bv->buffer().isReadonly()) return 0; if (!stringSelected(bv, searchstr, cs, mw, fw)) @@ -235,7 +235,7 @@ int replace(BufferView * bv, docstring const & searchstr, Cursor & cur = bv->cursor(); cap::replaceSelectionWithString(cur, replacestr, fw); - bv->buffer()->markDirty(); + bv->buffer().markDirty(); find(bv, searchstr, cs, mw, fw, false); bv->update(); @@ -317,25 +317,24 @@ void replace(BufferView * bv, FuncRequest const & ev, bool has_deleted) bool all = parse_bool(howto); bool forward = parse_bool(howto); - Buffer * buf = bv->buffer(); - if (!has_deleted) { int const replace_count = all ? replaceAll(bv, search, rplc, casesensitive, matchword) : replace(bv, search, rplc, casesensitive, matchword, forward); + Buffer & buf = bv->buffer(); if (replace_count == 0) { // emit message signal. - buf->message(_("String not found!")); + buf.message(_("String not found!")); } else { if (replace_count == 1) { // emit message signal. - buf->message(_("String has been replaced.")); + buf.message(_("String has been replaced.")); } else { docstring str = convert(replace_count); str += _(" strings have been replaced."); // emit message signal. - buf->message(str); + buf.message(str); } } } else { @@ -353,9 +352,6 @@ void replace(BufferView * bv, FuncRequest const & ev, bool has_deleted) bool findNextChange(BufferView * bv) { - if (!bv->buffer()) - return false; - DocIterator cur = bv->cursor(); if (!findChange(cur)) diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 38d6c7a305..a4ff0eaada 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -277,7 +277,7 @@ bool InsetMathHull::previewState(BufferView * bv) const { if (!editing(bv) && RenderPreview::status() == LyXRC::PREVIEW_ON) { graphics::PreviewImage const * pimage = - preview_->getPreviewImage(*bv->buffer()); + preview_->getPreviewImage(bv->buffer()); return pimage && pimage->image(); } return false; @@ -1060,7 +1060,7 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd) if (type_ == hullSimple || type_ == hullEquation) { recordUndoInset(cur); bool const align = - cur.bv().buffer()->params().use_amsmath == BufferParams::package_on; + cur.bv().buffer().params().use_amsmath == BufferParams::package_on; mutate(align ? hullAlign : hullEqnArray); cur.idx() = 0; cur.pos() = cur.lastpos(); @@ -1129,7 +1129,7 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd) numbered(r, true); docstring old = label(r); if (str != old) { - cur.bv().buffer()->changeRefsIfUnique(old, str, + cur.bv().buffer().changeRefsIfUnique(old, str, Inset::REF_CODE); label(r, str); } diff --git a/src/mathed/MathData.cpp b/src/mathed/MathData.cpp index 67be300ef9..e9bdfdaecd 100644 --- a/src/mathed/MathData.cpp +++ b/src/mathed/MathData.cpp @@ -258,7 +258,7 @@ void MathData::metrics(MetricsInfo & mi) const dim_.wid = 0; Dimension d; //BufferView & bv = *mi.base.bv; - //Buffer const & buf = *bv.buffer(); + //Buffer const & buf = bv.buffer(); for (size_t i = 0, n = size(); i != n; ++i) { MathAtom const & at = operator[](i); #if 0 diff --git a/src/rowpainter.cpp b/src/rowpainter.cpp index c1402e1c25..ca3a07ef4b 100644 --- a/src/rowpainter.cpp +++ b/src/rowpainter.cpp @@ -145,7 +145,7 @@ RowPainter::RowPainter(PainterInfo & pi, xo_(x), yo_(y), width_(text_metrics_.width()) { RowMetrics m = text_metrics_.computeRowMetrics(pit_, row_); - bidi_.computeTables(par_, *bv_.buffer(), row_); + bidi_.computeTables(par_, bv_.buffer(), row_); x_ = m.x + xo_; //lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl; @@ -162,13 +162,13 @@ RowPainter::RowPainter(PainterInfo & pi, Font const RowPainter::getLabelFont() const { - return text_.getLabelFont(*bv_.buffer(), par_); + return text_.getLabelFont(bv_.buffer(), par_); } int RowPainter::leftMargin() const { - return text_.leftMargin(*bv_.buffer(), max_width_, pit_, row_.pos()); + return text_.leftMargin(bv_.buffer(), max_width_, pit_, row_.pos()); } @@ -185,7 +185,7 @@ void RowPainter::paintInset(pos_type const pos, Font const & font) // FIXME: We should always use font, see documentation of // noFontChange() in Inset.h. pi.base.font = inset->noFontChange() ? - bv_.buffer()->params().getFont() : + bv_.buffer().params().getFont() : font; pi.ltr_pos = (bidi_.level(pos) % 2 == 0); pi.erased_ = erased_ || par_.isDeleted(pos); @@ -257,7 +257,7 @@ void RowPainter::paintHebrewComposeChar(pos_type & vpos, Font const & font) if (!Encodings::isComposeChar_hebrew(c)) { if (isPrintableNonspace(c)) { int const width2 = pm_.singleWidth(i, - text_.getFont(*bv_.buffer(), par_, i)); + text_.getFont(bv_.buffer(), par_, i)); dx = (c == 0x05e8 || // resh c == 0x05d3) // dalet ? width2 - width @@ -291,7 +291,7 @@ void RowPainter::paintArabicComposeChar(pos_type & vpos, Font const & font) if (!Encodings::isComposeChar_arabic(c)) { if (isPrintableNonspace(c)) { int const width2 = pm_.singleWidth(i, - text_.getFont(*bv_.buffer(), par_, i)); + text_.getFont(bv_.buffer(), par_, i)); dx = (width2 - width) / 2; } break; @@ -400,7 +400,7 @@ void RowPainter::paintForeignMark(double orig_x, Font const & font, int desc) return; if (font.language() == latex_language) return; - if (font.language() == bv_.buffer()->params().language) + if (font.language() == bv_.buffer().params().language) return; int const y = yo_ + 1 + desc; @@ -411,7 +411,7 @@ void RowPainter::paintForeignMark(double orig_x, Font const & font, int desc) void RowPainter::paintFromPos(pos_type & vpos) { pos_type const pos = bidi_.vis2log(vpos); - Font orig_font = text_.getFont(*bv_.buffer(), par_, pos); + Font orig_font = text_.getFont(bv_.buffer(), par_, pos); double const orig_x = x_; @@ -472,7 +472,7 @@ void RowPainter::paintChangeBar() void RowPainter::paintAppendix() { // only draw the appendix frame once (for the main text) - if (!par_.params().appendix() || !text_.isMainText(*bv_.buffer())) + if (!par_.params().appendix() || !text_.isMainText(bv_.buffer())) return; int y = yo_ - row_.ascent(); @@ -512,7 +512,7 @@ void RowPainter::paintDepthBar() int const w = nestMargin() / 5; int x = int(xo_) + w * i; // only consider the changebar space if we're drawing outermost text - if (text_.isMainText(*bv_.buffer())) + if (text_.isMainText(bv_.buffer())) x += changebarMargin(); int const starty = yo_ - row_.ascent(); @@ -563,7 +563,7 @@ void RowPainter::paintFirst() if (parparams.startOfAppendix()) y_top += paintAppendixStart(yo_ - row_.ascent() + 2 * defaultRowHeight()); - Buffer const & buffer = *bv_.buffer(); + Buffer const & buffer = bv_.buffer(); Layout_ptr const & layout = par_.layout(); @@ -676,13 +676,13 @@ void RowPainter::paintFirst() void RowPainter::paintLast() { - bool const is_rtl = text_.isRTL(*bv_.buffer(), par_); + bool const is_rtl = text_.isRTL(bv_.buffer(), par_); int const endlabel = getEndLabel(pit_, text_.paragraphs()); // paint imaginary end-of-paragraph character if (par_.isInserted(par_.size()) || par_.isDeleted(par_.size())) { - FontMetrics const & fm = theFontMetrics(bv_.buffer()->params().getFont()); + FontMetrics const & fm = theFontMetrics(bv_.buffer().params().getFont()); int const length = fm.maxAscent() / 2; Color::color col = par_.isInserted(par_.size()) ? Color::addedtext : Color::deletedtext; @@ -754,7 +754,7 @@ void RowPainter::paintText() // Use font span to speed things up, see below FontSpan font_span; Font font; - Buffer const & buffer = *bv_.buffer(); + Buffer const & buffer = bv_.buffer(); // If the last logical character is a separator, don't paint it, unless // it's in the last row of a paragraph; see skipped_sep_vpos declaration @@ -807,7 +807,7 @@ void RowPainter::paintText() if (running_strikeout && (highly_editable_inset || !is_struckout)) { // Calculate 1/3 height of the buffer's default font FontMetrics const & fm - = theFontMetrics(bv_.buffer()->params().getFont()); + = theFontMetrics(bv_.buffer().params().getFont()); int const middle = yo_ - fm.maxAscent() / 3; pain_.line(last_strikeout_x, middle, int(x_), middle, Color::deletedtext, Painter::line_solid, Painter::line_thin); @@ -848,7 +848,7 @@ void RowPainter::paintText() x_ += 2; ++vpos; } else if (par_.isSeparator(pos)) { - Font orig_font = text_.getFont(*bv_.buffer(), par_, pos); + Font orig_font = text_.getFont(bv_.buffer(), par_, pos); double const orig_x = x_; x_ += width_pos; if (pos >= body_pos) @@ -864,7 +864,7 @@ void RowPainter::paintText() if (running_strikeout) { // calculate 1/3 height of the buffer's default font FontMetrics const & fm - = theFontMetrics(bv_.buffer()->params().getFont()); + = theFontMetrics(bv_.buffer().params().getFont()); int const middle = yo_ - fm.maxAscent() / 3; pain_.line(last_strikeout_x, middle, int(x_), middle, Color::deletedtext, Painter::line_solid, Painter::line_thin); @@ -1018,7 +1018,7 @@ void paintPar // Instrumentation for testing row cache (see also // 12 lines lower): if (lyxerr.debugging(Debug::PAINTING)) { - if (text.isMainText(*pi.base.bv->buffer())) + if (text.isMainText(pi.base.bv->buffer())) LYXERR(Debug::PAINTING) << "#"; else LYXERR(Debug::PAINTING) << "[" << @@ -1050,8 +1050,7 @@ void paintPar void paintText(BufferView & bv, Painter & pain) { - BOOST_ASSERT(bv.buffer()); - Buffer const & buffer = *bv.buffer(); + Buffer const & buffer = bv.buffer(); Text & text = buffer.text(); bool const select = bv.cursor().selection(); ViewMetricsInfo const & vi = bv.viewMetricsInfo(); diff --git a/src/toc.cpp b/src/toc.cpp index 1cb974941e..cca7c72610 100644 --- a/src/toc.cpp +++ b/src/toc.cpp @@ -31,9 +31,9 @@ namespace toc { void outline(OutlineOp mode, Cursor & cur) { - Buffer * buf = & cur.buffer(); + Buffer & buf = cur.buffer(); pit_type & pit = cur.pit(); - ParagraphList & pars = buf->text().paragraphs(); + ParagraphList & pars = buf.text().paragraphs(); ParagraphList::iterator bgn = pars.begin(); // The first paragraph of the area to be copied: ParagraphList::iterator start = boost::next(bgn, pit); @@ -42,9 +42,9 @@ void outline(OutlineOp mode, Cursor & cur) ParagraphList::iterator end = pars.end(); TextClass::const_iterator lit = - buf->params().getTextClass().begin(); + buf.params().getTextClass().begin(); TextClass::const_iterator const lend = - buf->params().getTextClass().end(); + buf.params().getTextClass().end(); int const thistoclevel = start->layout()->toclevel; int toclevel; -- 2.39.2