From 5425c53fd132644ae615d3d03efcb1ee23e69ea0 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sun, 9 Aug 2009 15:29:34 +0000 Subject: [PATCH] Now that Text knows its owner, use the associated Buffer access. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30941 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 4 +-- src/Text.cpp | 34 ++++++++++----------- src/Text.h | 25 +++++++++------- src/Text2.cpp | 29 ++++++++++-------- src/Text3.cpp | 9 +++--- src/TextMetrics.cpp | 53 +++++++++++++++------------------ src/insets/InsetCaption.cpp | 2 +- src/insets/InsetCollapsable.cpp | 2 +- src/insets/InsetTabular.cpp | 2 +- src/insets/InsetText.cpp | 4 +-- src/mathed/InsetMathMBox.cpp | 2 +- src/output_latex.cpp | 4 +-- src/rowpainter.cpp | 10 +++---- 13 files changed, 89 insertions(+), 91 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 8dd228b5b9..48c528fde4 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -690,7 +690,7 @@ bool Buffer::readDocument(Lexer & lex) } // read main text - bool const res = text().read(*this, lex, errorList, d->inset); + bool const res = text().read(lex, errorList, d->inset); updateMacros(); updateMacroInstances(); @@ -1028,7 +1028,7 @@ bool Buffer::write(ostream & ofs) const // write the text ofs << "\n\\begin_body\n"; - text().write(*this, ofs); + text().write(ofs); ofs << "\n\\end_body\n"; // Write marker that shows file is complete diff --git a/src/Text.cpp b/src/Text.cpp index 73c16f1d77..1eb35ad138 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -79,11 +79,10 @@ namespace lyx { using cap::cutSelection; using cap::pasteParagraphList; -namespace { - -void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex, +void Text::readParToken(Paragraph & par, Lexer & lex, string const & token, Font & font, Change & change, ErrorList & errorList) { + Buffer const & buf = owner_->buffer(); BufferParams const & bp = buf.params(); if (token[0] != '\\') { @@ -102,7 +101,7 @@ void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex, if (layoutname.empty()) layoutname = tclass.defaultLayoutName(); - if (par.forcePlainLayout()) { + if (owner_->forcePlainLayout()) { // in this case only the empty layout is allowed layoutname = tclass.plainLayoutName(); } else if (par.usePlainLayout()) { @@ -246,7 +245,7 @@ void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex, } -void readParagraph(Buffer const & buf, Paragraph & par, Lexer & lex, +void Text::readParagraph(Paragraph & par, Lexer & lex, ErrorList & errorList) { lex.nextToken(); @@ -255,7 +254,7 @@ void readParagraph(Buffer const & buf, Paragraph & par, Lexer & lex, Change change(Change::UNCHANGED); while (lex.isOK()) { - readParToken(buf, par, lex, token, font, change, errorList); + readParToken(par, lex, token, font, change, errorList); lex.nextToken(); token = lex.getString(); @@ -287,8 +286,6 @@ void readParagraph(Buffer const & buf, Paragraph & par, Lexer & lex, } -} // namespace anon - class TextCompletionList : public CompletionList { public: @@ -328,10 +325,10 @@ bool Text::empty() const } -double Text::spacing(Buffer const & buffer, Paragraph const & par) const +double Text::spacing(Paragraph const & par) const { if (par.params().spacing().isDefault()) - return buffer.params().spacing().getValue(); + return owner_->buffer().params().spacing().getValue(); return par.params().spacing().getValue(); } @@ -453,12 +450,12 @@ void Text::insertChar(Cursor & cur, char_type c) || par.isSeparator(cur.pos() - 2) || par.isNewline(cur.pos() - 2)) ) { - setCharFont(buffer, pit, cur.pos() - 1, cur.current_font, + setCharFont(pit, cur.pos() - 1, cur.current_font, tm.font_); } else if (contains(number_seperators, c) && cur.pos() >= 2 && tm.displayFont(pit, cur.pos() - 2).fontInfo().number() == FONT_ON) { - setCharFont(buffer, pit, cur.pos() - 1, cur.current_font, + setCharFont(pit, cur.pos() - 1, cur.current_font, tm.font_); } } @@ -1208,7 +1205,7 @@ bool Text::dissolveInset(Cursor & cur) { LASSERT(this == cur.text(), return false); - if (isMainText(cur.bv().buffer()) || cur.inset().nargs() != 1) + if (isMainText() || cur.inset().nargs() != 1) return false; cur.recordUndoInset(); @@ -1259,8 +1256,9 @@ void Text::getWord(CursorSlice & from, CursorSlice & to, } -void Text::write(Buffer const & buf, ostream & os) const +void Text::write(ostream & os) const { + Buffer const & buf = owner_->buffer(); ParagraphList::const_iterator pit = paragraphs().begin(); ParagraphList::const_iterator end = paragraphs().end(); depth_type dth = 0; @@ -1273,9 +1271,10 @@ void Text::write(Buffer const & buf, ostream & os) const } -bool Text::read(Buffer const & buf, Lexer & lex, +bool Text::read(Lexer & lex, ErrorList & errorList, InsetText * insetPtr) { + Buffer const & buf = owner_->buffer(); depth_type depth = 0; bool res = true; @@ -1308,10 +1307,7 @@ bool Text::read(Buffer const & buf, Lexer & lex, par.params().depth(depth); par.setFont(0, Font(inherit_font, buf.params().language)); pars_.push_back(par); - - // FIXME: goddamn InsetTabular makes us pass a Buffer - // not BufferParams - lyx::readParagraph(buf, pars_.back(), lex, errorList); + readParagraph(pars_.back(), lex, errorList); // register the words in the global word list CursorSlice sl = CursorSlice(*insetPtr); diff --git a/src/Text.h b/src/Text.h index 1ec93b006a..39cffceade 100644 --- a/src/Text.h +++ b/src/Text.h @@ -19,7 +19,6 @@ namespace lyx { -class Buffer; class BufferParams; class BufferView; class CompletionList; @@ -53,15 +52,14 @@ public: InsetText const * inset() { return owner_; } /// - FontInfo layoutFont(Buffer const & buffer, pit_type pit) const; + FontInfo layoutFont(pit_type pit) const; /// - FontInfo labelFont(Buffer const & buffer, - Paragraph const & par) const; + FontInfo labelFont(Paragraph const & par) const; /** Set font of character at position \p pos in paragraph \p pit. * Must not be called if \p pos denotes an inset with text contents, * and the inset is not allowed inside a font change (see below). */ - void setCharFont(Buffer const & buffer, pit_type pit, pos_type pos, + void setCharFont(pit_type pit, pos_type pos, Font const & font, Font const & display_font); /** Needed to propagate font changes to all text cells of insets @@ -78,7 +76,7 @@ public: void breakParagraph(Cursor & cur, bool inverse_logic = false); /// set layout over selection - void setLayout(Buffer const & buffer, pit_type start, pit_type end, + void setLayout(pit_type start, pit_type end, docstring const & layout); /// Set given layout to current cursor position. /// FIXME: replace Cursor with DocIterator. @@ -265,15 +263,15 @@ public: ParagraphList const & paragraphs() const { return pars_; } ParagraphList & paragraphs() { return pars_; } /// return true if this is the main text - bool isMainText(Buffer const &) const; + bool isMainText() const; /// - double spacing(Buffer const & buffer, Paragraph const & par) const; + double spacing(Paragraph const & par) const; /// make a suggestion for a label /// FIXME: replace Cursor with DocIterator. docstring getPossibleLabel(Cursor const & cur) const; /// is this paragraph right-to-left? - bool isRTL(Buffer const &, Paragraph const & par) const; + bool isRTL(Paragraph const & par) const; /// bool checkAndActivateInset(Cursor & cur, bool front); @@ -281,10 +279,10 @@ public: bool checkAndActivateInsetVisual(Cursor & cur, bool movingForward, bool movingLeft); /// - void write(Buffer const & buf, std::ostream & os) const; + void write(std::ostream & os) const; /// returns true if \end_document has not been read /// insetPtr is the containing Inset - bool read(Buffer const & buf, Lexer & lex, ErrorList & errorList, + bool read(Lexer & lex, ErrorList & errorList, InsetText * insetPtr); /// delete double spaces, leading spaces, and empty paragraphs around old cursor. @@ -347,6 +345,11 @@ private: /// \param asParagraphs whether to paste as paragraphs or as lines void pasteString(Cursor & cur, docstring const & str, bool asParagraphs); + /// + void readParToken(Paragraph & par, Lexer & lex, std::string const & token, + Font & font, Change & change, ErrorList & errorList); + /// + void readParagraph(Paragraph & par, Lexer & lex, ErrorList & errorList); /// Owner Inset. InsetText * owner_; diff --git a/src/Text2.cpp b/src/Text2.cpp index 98999c92b0..c55b9e2a42 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -63,14 +63,14 @@ using namespace std; namespace lyx { -bool Text::isMainText(Buffer const & buffer) const +bool Text::isMainText() const { - return &buffer.text() == this; + return &owner_->buffer().text() == this; } // Note that this is supposed to return a fully realized font. -FontInfo Text::layoutFont(Buffer const & buffer, pit_type const pit) const +FontInfo Text::layoutFont(pit_type const pit) const { Layout const & layout = pars_[pit].layout(); @@ -78,7 +78,7 @@ FontInfo Text::layoutFont(Buffer const & buffer, pit_type const pit) const FontInfo lf = layout.resfont; // In case the default family has been customized if (layout.font.family() == INHERIT_FAMILY) - lf.setFamily(buffer.params().getFont().fontInfo().family()); + lf.setFamily(owner_->buffer().params().getFont().fontInfo().family()); // FIXME // It ought to be possible here just to use Inset::getLayout() and skip // the asInsetCollapsable() bit. Unfortunatley, that doesn't work right @@ -96,15 +96,16 @@ FontInfo Text::layoutFont(Buffer const & buffer, pit_type const pit) const FontInfo font = layout.font; // Realize with the fonts of lesser depth. //font.realize(outerFont(pit, paragraphs())); - font.realize(buffer.params().getFont().fontInfo()); + font.realize(owner_->buffer().params().getFont().fontInfo()); return font; } // Note that this is supposed to return a fully realized font. -FontInfo Text::labelFont(Buffer const & buffer, Paragraph const & par) const +FontInfo Text::labelFont(Paragraph const & par) const { + Buffer const & buffer = owner_->buffer(); Layout const & layout = par.layout(); if (!par.getDepth()) { @@ -123,9 +124,10 @@ FontInfo Text::labelFont(Buffer const & buffer, Paragraph const & par) const } -void Text::setCharFont(Buffer const & buffer, pit_type pit, +void Text::setCharFont(pit_type pit, pos_type pos, Font const & fnt, Font const & display_font) { + Buffer const & buffer = owner_->buffer(); Font font = fnt; Layout const & layout = pars_[pit].layout(); @@ -151,7 +153,7 @@ void Text::setCharFont(Buffer const & buffer, pit_type pit, // Inside inset, apply the inset's font attributes if any // (charstyle!) - if (!isMainText(buffer)) + if (!isMainText()) layoutfont.realize(display_font.fontInfo()); layoutfont.realize(buffer.params().getFont().fontInfo()); @@ -202,11 +204,12 @@ pit_type Text::undoSpan(pit_type pit) } -void Text::setLayout(Buffer const & buffer, pit_type start, pit_type end, +void Text::setLayout(pit_type start, pit_type end, docstring const & layout) { LASSERT(start != end, /**/); + Buffer const & buffer = owner_->buffer(); BufferParams const & bp = buffer.params(); Layout const & lyxlayout = bp.documentClass()[layout]; @@ -228,7 +231,7 @@ void Text::setLayout(Cursor & cur, docstring const & layout) pit_type end = cur.selEnd().pit() + 1; pit_type undopit = undoSpan(end - 1); recUndo(cur, start, undopit - 1); - setLayout(*cur.buffer(), start, end, layout); + setLayout(start, end, layout); cur.buffer()->updateLabels(); } @@ -300,9 +303,9 @@ void Text::setFont(Cursor & cur, Font const & font, bool toggleall) FontInfo layoutfont; pit_type pit = cur.pit(); if (cur.pos() < pars_[pit].beginOfBody()) - layoutfont = labelFont(*cur.buffer(), pars_[pit]); + layoutfont = labelFont(pars_[pit]); else - layoutfont = layoutFont(*cur.buffer(), pit); + layoutfont = layoutFont(pit); // Update current font cur.real_current_font.update(font, @@ -354,7 +357,7 @@ void Text::setFont(BufferView const & bv, CursorSlice const & begin, TextMetrics const & tm = bv.textMetrics(this); Font f = tm.displayFont(pit, pos); f.update(font, language, toggleall); - setCharFont(buffer, pit, pos, f, tm.font_); + setCharFont(pit, pos, f, tm.font_); } } diff --git a/src/Text3.cpp b/src/Text3.cpp index 617a3ef6d7..008d66c100 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -507,8 +507,9 @@ void Text::number(Cursor & cur) } -bool Text::isRTL(Buffer const & buffer, Paragraph const & par) const +bool Text::isRTL(Paragraph const & par) const { + Buffer const & buffer = owner_->buffer(); return par.isRTL(buffer.params()); } @@ -1287,7 +1288,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) if (layout.empty()) layout = tclass.defaultLayoutName(); - if (para.forcePlainLayout()) + if (owner_->forcePlainLayout()) // in this case only the empty layout is allowed layout = tclass.plainLayoutName(); else if (para.usePlainLayout()) { @@ -2543,7 +2544,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, enable = cur.inset().lyxCode() == FLEX_CODE && il.lyxtype() == type; } else { - enable = ((!isMainText(cur.bv().buffer()) + enable = ((!isMainText() && cur.inset().nargs() == 1) || (cur.nextInset() && cur.nextInset()->nargs() == 1)); @@ -2571,7 +2572,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_OUTLINE_OUT: case LFUN_OUTLINE_DRAGMOVE: // FIXME: LyX is not ready for outlining within inset. - enable = isMainText(cur.bv().buffer()) + enable = isMainText() && cur.paragraph().layout().toclevel != Layout::NOT_IN_TOC; break; diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 702c068061..dcc9744f07 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -263,7 +263,7 @@ Font TextMetrics::displayFont(pit_type pit, pos_type pos) const // We specialize the 95% common case: if (!par.getDepth()) { Font f = par.getFontSettings(params, pos); - if (!text_->isMainText(buffer)) + if (!text_->isMainText()) applyOuterFont(f); bool lab = layout.labeltype == LABEL_MANUAL && pos < body_pos; @@ -284,7 +284,7 @@ Font TextMetrics::displayFont(pit_type pit, pos_type pos) const Font font = par.getFontSettings(params, pos); font.fontInfo().realize(layoutfont); - if (!text_->isMainText(buffer)) + if (!text_->isMainText()) applyOuterFont(font); // Realize against environment font information @@ -520,7 +520,6 @@ void TextMetrics::computeRowMetrics(pit_type const pit, row.label_hfill = 0; row.separator = 0; - Buffer & buffer = bv_->buffer(); Paragraph const & par = text_->getPar(pit); double w = width - row.width(); @@ -531,7 +530,7 @@ void TextMetrics::computeRowMetrics(pit_type const pit, //lyxerr << "row.width() " << row.width() << endl; //lyxerr << "w " << w << endl; - bool const is_rtl = text_->isRTL(buffer, par); + bool const is_rtl = text_->isRTL(par); if (is_rtl) row.x = rightMargin(pit); else @@ -648,7 +647,7 @@ void TextMetrics::computeRowMetrics(pit_type const pit, if (body_pos > 0 && (body_pos > end || !par.isLineSeparator(body_pos - 1))) { - row.x += theFontMetrics(text_->labelFont(buffer, par)). + row.x += theFontMetrics(text_->labelFont(par)). width(layout.labelsep); if (body_pos <= end) row.x += row.label_hfill; @@ -684,7 +683,6 @@ void TextMetrics::computeRowMetrics(pit_type const pit, int TextMetrics::labelFill(pit_type const pit, Row const & row) const { - Buffer & buffer = bv_->buffer(); Paragraph const & par = text_->getPar(pit); pos_type last = par.beginOfBody(); @@ -706,7 +704,7 @@ int TextMetrics::labelFill(pit_type const pit, Row const & row) const return 0; FontMetrics const & fm - = theFontMetrics(text_->labelFont(buffer, par)); + = theFontMetrics(text_->labelFont(par)); return max(0, fm.width(label) - w); } @@ -795,7 +793,6 @@ private: pit_type TextMetrics::rowBreakPoint(int width, pit_type const pit, pit_type pos) const { - Buffer & buffer = bv_->buffer(); ParagraphMetrics const & pm = par_metrics_[pit]; Paragraph const & par = text_->getPar(pit); pos_type const end = par.size(); @@ -846,7 +843,7 @@ pit_type TextMetrics::rowBreakPoint(int width, pit_type const pit, // add the auto-hfill from label end to the body if (body_pos && i == body_pos) { FontMetrics const & fm = theFontMetrics( - text_->labelFont(buffer, par)); + text_->labelFont(par)); int add = fm.width(layout.labelsep); if (par.isLineSeparator(i - 1)) add -= singleWidth(pit, i - 1); @@ -918,7 +915,6 @@ pit_type TextMetrics::rowBreakPoint(int width, pit_type const pit, int TextMetrics::rowWidth(int right_margin, pit_type const pit, pos_type const first, pos_type const end) const { - Buffer & buffer = bv_->buffer(); // get the pure distance ParagraphMetrics const & pm = par_metrics_[pit]; Paragraph const & par = text_->getPar(pit); @@ -943,7 +939,7 @@ int TextMetrics::rowWidth(int right_margin, pit_type const pit, for ( ; i < end; ++i, ++fi) { if (body_pos > 0 && i == body_pos) { FontMetrics const & fm = theFontMetrics( - text_->labelFont(buffer, par)); + text_->labelFont(par)); w += fm.width(par.layout().labelsep); if (par.isLineSeparator(i - 1)) w -= singleWidth(pit, i - 1); @@ -962,7 +958,7 @@ int TextMetrics::rowWidth(int right_margin, pit_type const pit, if (body_pos > 0 && body_pos >= end) { FontMetrics const & fm = theFontMetrics( - text_->labelFont(buffer, par)); + text_->labelFont(par)); w += fm.width(par.layout().labelsep); if (end > 0 && par.isLineSeparator(end - 1)) w -= singleWidth(pit, end - 1); @@ -994,18 +990,18 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first, Buffer const & buffer = bv_->buffer(); Font font = displayFont(pit, first); FontSize const tmpsize = font.fontInfo().size(); - font.fontInfo() = text_->layoutFont(buffer, pit); + font.fontInfo() = text_->layoutFont(pit); FontSize const size = font.fontInfo().size(); font.fontInfo().setSize(tmpsize); - FontInfo labelfont = text_->labelFont(buffer, par); + FontInfo labelfont = text_->labelFont(par); FontMetrics const & labelfont_metrics = theFontMetrics(labelfont); FontMetrics const & fontmetrics = theFontMetrics(font); // these are minimum values double const spacing_val = layout.spacing.getValue() - * text_->spacing(buffer, par); + * text_->spacing(par); //lyxerr << "spacing_val = " << spacing_val << endl; int maxasc = int(fontmetrics.maxAscent() * spacing_val); int maxdesc = int(fontmetrics.maxDescent() * spacing_val); @@ -1070,7 +1066,7 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first, && !par.params().labelString().empty()) { labeladdon = int(labelfont_metrics.maxHeight() * layout.spacing.getValue() - * text_->spacing(buffer, par)); + * text_->spacing(par)); } // special code for the top label @@ -1083,7 +1079,7 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first, labeladdon = int( labelfont_metrics.maxHeight() * layout.spacing.getValue() - * text_->spacing(buffer, par) + * text_->spacing(par) + (layout.topsep + layout.labelbottomsep) * dh); } @@ -1209,7 +1205,7 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit, last_tmpx = tmpx; if (body_pos > 0 && c == body_pos - 1) { FontMetrics const & fm = theFontMetrics( - text_->labelFont(buffer, par)); + text_->labelFont(par)); tmpx += row.label_hfill + fm.width(layout.labelsep); if (par.isLineSeparator(body_pos - 1)) tmpx -= singleWidth(pit, body_pos - 1); @@ -1235,7 +1231,7 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit, // If lastrow is false, we don't need to compute // the value of rtl. - bool const rtl = lastrow ? text_->isRTL(buffer, par) : false; + bool const rtl = lastrow ? text_->isRTL(par) : false; if (lastrow && ((rtl && left_side && vc == row.pos() && x < tmpx - 5) || (!rtl && !left_side && vc == end && x > tmpx + 5))) { @@ -1618,7 +1614,7 @@ int TextMetrics::cursorX(CursorSlice const & sl, if (end <= row_pos) cursor_vpos = row_pos; else if (ppos >= end) - cursor_vpos = text_->isRTL(buffer, par) ? row_pos : end; + cursor_vpos = text_->isRTL(par) ? row_pos : end; else if (ppos > row_pos && ppos >= end) // Place cursor after char at (logical) position pos - 1 cursor_vpos = (bidi.level(ppos - 1) % 2 == 0) @@ -1670,7 +1666,7 @@ int TextMetrics::cursorX(CursorSlice const & sl, pos_type pos = bidi.vis2log(vpos); if (body_pos > 0 && pos == body_pos - 1) { FontMetrics const & labelfm = theFontMetrics( - text_->labelFont(buffer, par)); + text_->labelFont(par)); x += row.label_hfill + labelfm.width(par.layout().labelsep); if (par.isLineSeparator(body_pos - 1)) x -= singleWidth(pit, body_pos - 1); @@ -1839,7 +1835,7 @@ int TextMetrics::leftMargin(int max_width, int l_margin = 0; - if (text_->isMainText(buffer)) + if (text_->isMainText()) l_margin += bv_->leftMargin(); l_margin += theFontMetrics(buffer.params().getFont()).signedWidth( @@ -1869,7 +1865,7 @@ int TextMetrics::leftMargin(int max_width, && pit > 0 && pars[pit - 1].layout().nextnoindent) parindent.erase(); - FontInfo const labelfont = text_->labelFont(buffer, par); + FontInfo const labelfont = text_->labelFont(par); FontMetrics const & labelfont_metrics = theFontMetrics(labelfont); switch (layout.margintype) { @@ -2115,7 +2111,7 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type pit, int x, int y) co // 12 lines lower): if (lyxerr.debugging(Debug::PAINTING) && inside && (row.selection() || pi.full_repaint || row_has_changed)) { - string const foreword = text_->isMainText(bv_->buffer()) ? + string const foreword = text_->isMainText() ? "main text redraw " : "inset text redraw: "; LYXERR(Debug::PAINTING, foreword << "pit=" << pit << " row=" << i << " row_selection=" << row.selection() @@ -2160,7 +2156,6 @@ void TextMetrics::drawRowSelection(PainterInfo & pi, int x, Row const & row, bool const begin_boundary = beg.pos() >= row.endpos(); bool const end_boundary = row.sel_end == row.endpos(); - Buffer & buffer = bv_->buffer(); DocIterator cur = beg; cur.boundary(begin_boundary); int x1 = cursorX(beg.top(), begin_boundary); @@ -2168,12 +2163,12 @@ void TextMetrics::drawRowSelection(PainterInfo & pi, int x, Row const & row, int const y1 = bv_->getPos(cur, cur.boundary()).y_ - row.ascent(); int const y2 = y1 + row.height(); - int const rm = text_->isMainText(buffer) ? bv_->rightMargin() : 0; - int const lm = text_->isMainText(buffer) ? bv_->leftMargin() : 0; + int const rm = text_->isMainText() ? bv_->rightMargin() : 0; + int const lm = text_->isMainText() ? bv_->leftMargin() : 0; // draw the margins if (row.begin_margin_sel) { - if (text_->isRTL(buffer, beg.paragraph())) { + if (text_->isRTL(beg.paragraph())) { pi.pain.fillRectangle(x + x1, y1, width() - rm - x1, y2 - y1, Color_selection); } else { @@ -2183,7 +2178,7 @@ void TextMetrics::drawRowSelection(PainterInfo & pi, int x, Row const & row, } if (row.end_margin_sel) { - if (text_->isRTL(buffer, beg.paragraph())) { + if (text_->isRTL(beg.paragraph())) { pi.pain.fillRectangle(x + lm, y1, x2 - lm, y2 - y1, Color_selection); } else { diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp index 87888c0fdf..4b19a6d3bf 100644 --- a/src/insets/InsetCaption.cpp +++ b/src/insets/InsetCaption.cpp @@ -60,7 +60,7 @@ InsetCaption::InsetCaption(Buffer const & buf) void InsetCaption::write(ostream & os) const { os << "Caption\n"; - text().write(buffer(), os); + text().write(os); } diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index f6afbbc2c8..6358e06e52 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -148,7 +148,7 @@ void InsetCollapsable::write(ostream & os) const break; } os << "\n"; - text().write(buffer(), os); + text().write(os); } diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 8ebfeb8110..a576d2685a 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -1030,7 +1030,7 @@ void toggleFixedWidth(Cursor & cur, InsetTableCell * inset, bool fixedWidth) // 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(0, cur.lastpit() + 1, bp.documentClass().plainLayoutName()); cur.pop(); } diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 8247d57d89..5448f65329 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -153,7 +153,7 @@ Dimension const InsetText::dimension(BufferView const & bv) const void InsetText::write(ostream & os) const { os << "Text\n"; - text_.write(buffer(), os); + text_.write(os); } @@ -166,7 +166,7 @@ void InsetText::read(Lexer & lex) paragraphs().clear(); ErrorList errorList; lex.setContext("InsetText::read"); - bool res = text_.read(buffer(), lex, errorList, this); + bool res = text_.read(lex, errorList, this); if (!res) lex.printError("Missing \\end_inset at this point. "); diff --git a/src/mathed/InsetMathMBox.cpp b/src/mathed/InsetMathMBox.cpp index f7d7d1b07c..d7ae3d760c 100644 --- a/src/mathed/InsetMathMBox.cpp +++ b/src/mathed/InsetMathMBox.cpp @@ -81,7 +81,7 @@ void InsetMathMBox::write(WriteStream & ws) const } else { ws << "\\mbox{\n"; ostringstream os; - text_.text().write(buffer(), os); + text_.text().write(os); ws.os() << from_utf8(os.str()); ws << "}"; } diff --git a/src/output_latex.cpp b/src/output_latex.cpp index 1aa55e3018..f336e37048 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -333,7 +333,7 @@ ParagraphList::const_iterator TeXOnePar(Buffer const & buf, runparams.moving_arg |= style.needprotect; - bool const maintext = text.isMainText(buf); + bool const maintext = text.isMainText(); // we are at the beginning of an inset and CJK is already open; // we count inheritation levels to get the inset nesting right. if (pit == paragraphs.begin() && !maintext @@ -798,7 +798,7 @@ void latexParagraphs(Buffer const & buf, const_cast(runparams).par_end = 0; } - bool const maintext = text.isMainText(buf); + bool const maintext = text.isMainText(); bool const is_child = buf.masterBuffer() != &buf; // Open a CJK environment at the beginning of the main buffer diff --git a/src/rowpainter.cpp b/src/rowpainter.cpp index e1109504be..930c44cd69 100644 --- a/src/rowpainter.cpp +++ b/src/rowpainter.cpp @@ -76,7 +76,7 @@ RowPainter::RowPainter(PainterInfo & pi, FontInfo RowPainter::labelFont() const { - return text_.labelFont(pi_.base.bv->buffer(), par_); + return text_.labelFont(par_); } @@ -393,7 +393,7 @@ void RowPainter::paintChangeBar() void RowPainter::paintAppendix() { // only draw the appendix frame once (for the main text) - if (!par_.params().appendix() || !text_.isMainText(pi_.base.bv->buffer())) + if (!par_.params().appendix() || !text_.isMainText()) return; int y = yo_ - row_.ascent(); @@ -433,7 +433,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(pi_.base.bv->buffer())) + if (text_.isMainText()) x += changebarMargin(); int const starty = yo_ - row_.ascent(); @@ -503,7 +503,7 @@ void RowPainter::paintFirst() } } - bool const is_rtl = text_.isRTL(buffer, par_); + bool const is_rtl = text_.isRTL(par_); bool const is_seq = isFirstInSequence(pit_, text_.paragraphs()); //lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << endl; @@ -596,7 +596,7 @@ void RowPainter::paintFirst() void RowPainter::paintLast() { - bool const is_rtl = text_.isRTL(pi_.base.bv->buffer(), par_); + bool const is_rtl = text_.isRTL(par_); int const endlabel = getEndLabel(pit_, text_.paragraphs()); // paint imaginary end-of-paragraph character -- 2.39.2