X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsettabular.C;h=bbc4f28e2b3f849429b02fb1bc33ca30e900df3d;hb=fd36f5ad7612a4034c21c3162e29c3bca42e353e;hp=69a1f91c08bbda95090a476b7ea61d3b0c081b3b;hpb=407c8f08bc5608d5997b014131d4aba99cae0802;p=lyx.git diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 69a1f91c08..bbc4f28e2b 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -11,54 +11,43 @@ #include #include "insettabular.h" -#include "insettext.h" #include "buffer.h" #include "BufferView.h" -#include "lfuns.h" #include "debug.h" -#include "dimension.h" #include "funcrequest.h" +#include "FuncStatus.h" #include "gettext.h" #include "language.h" -#include "LaTeXFeatures.h" -#include "Lsstream.h" #include "lyx_cb.h" -#include "lyxfunc.h" -#include "lyxlength.h" #include "lyxlex.h" -#include "lyxtext.h" +#include "metricsinfo.h" +#include "paragraph.h" +#include "paragraph_funcs.h" #include "ParagraphParameters.h" #include "undo_funcs.h" #include "WordLangTuple.h" -#include "metricsinfo.h" -#include "paragraph_funcs.h" #include "frontends/Alert.h" -#include "frontends/Dialogs.h" #include "frontends/font_metrics.h" #include "frontends/LyXView.h" #include "frontends/Painter.h" #include "support/LAssert.h" -#include "support/lstrings.h" - -#include -#include -#include +#include "support/std_sstream.h" using namespace lyx::support; using namespace lyx::graphics; -using std::vector; -using std::ostream; -using std::ifstream; -using std::max; using std::endl; -using std::swap; using std::max; +using std::swap; + using std::auto_ptr; +using std::istringstream; +using std::ostream; +using std::ostringstream; namespace { @@ -155,7 +144,7 @@ bool InsetTabular::hasPasteBuffer() const InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns) - : tabular(buf.params, this, max(rows, 1), max(columns, 1)), + : tabular(buf.params(), this, max(rows, 1), max(columns, 1)), buffer_(&buf), cursorx_(0), cursory_(0) { // for now make it always display as display() inset @@ -174,7 +163,7 @@ InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns) InsetTabular::InsetTabular(InsetTabular const & tab) : UpdatableInset(tab), - tabular(tab.buffer_->params, this, tab.tabular), + tabular(tab.buffer_->params(), this, tab.tabular), buffer_(tab.buffer_), cursorx_(0), cursory_(0) { the_locking_inset = 0; @@ -201,9 +190,9 @@ auto_ptr InsetTabular::clone() const } -Buffer const * InsetTabular::buffer() const +Buffer const & InsetTabular::buffer() const { - return buffer_; + return *buffer_; } @@ -220,14 +209,14 @@ void InsetTabular::buffer(Buffer * b) } -void InsetTabular::write(Buffer const * buf, ostream & os) const +void InsetTabular::write(Buffer const & buf, ostream & os) const { os << "Tabular" << endl; tabular.write(buf, os); } -void InsetTabular::read(Buffer const * buf, LyXLex & lex) +void InsetTabular::read(Buffer const & buf, LyXLex & lex) { bool const old_format = (lex.getString() == "\\LyXTable"); @@ -422,7 +411,7 @@ void InsetTabular::insetUnlock(BufferView * bv) void InsetTabular::updateLocal(BufferView * bv) const { - bv->updateInset(); + bv->updateInset(this); if (locked) resetPos(bv); } @@ -856,14 +845,14 @@ InsetOld::RESULT InsetTabular::localDispatch(FuncRequest const & cmd) updateLocal(bv); break; case LFUN_NEXT: { - if (hs) + if (hs) clearSelection(); int column = actcol; unlockInsetInInset(bv, the_locking_inset); - if (bv->text->top_y() + bv->painter().paperHeight() < + if (bv->top_y() + bv->painter().paperHeight() < top_baseline + tabular.getHeightOfTabular()) { - bv->scrollDocView(bv->text->top_y() + bv->painter().paperHeight()); + bv->scrollDocView(bv->top_y() + bv->painter().paperHeight()); actcell = tabular.getCellBelow(first_visible_cell) + column; } else { actcell = tabular.getFirstCellInRow(tabular.rows() - 1) + column; @@ -878,7 +867,7 @@ InsetOld::RESULT InsetTabular::localDispatch(FuncRequest const & cmd) int column = actcol; unlockInsetInInset(bv, the_locking_inset); if (top_baseline < 0) { - bv->scrollDocView(bv->text->top_y() - bv->painter().paperHeight()); + bv->scrollDocView(bv->top_y() - bv->painter().paperHeight()); if (top_baseline > 0) actcell = column; else @@ -946,7 +935,7 @@ InsetOld::RESULT InsetTabular::localDispatch(FuncRequest const & cmd) // no break here! case LFUN_DELETE: recordUndo(bv, Undo::DELETE); - cutSelection(bv->buffer()->params); + cutSelection(bv->buffer()->params()); updateLocal(bv); break; case LFUN_COPY: @@ -985,7 +974,7 @@ InsetOld::RESULT InsetTabular::localDispatch(FuncRequest const & cmd) } maxCols = max(cols, maxCols); delete paste_tabular; - paste_tabular = new LyXTabular(bv->buffer()->params, + paste_tabular = new LyXTabular(bv->buffer()->params(), this, rows, maxCols); string::size_type op = 0; int cell = 0; @@ -1085,29 +1074,29 @@ InsetOld::RESULT InsetTabular::localDispatch(FuncRequest const & cmd) } -int InsetTabular::latex(Buffer const * buf, ostream & os, +int InsetTabular::latex(Buffer const & buf, ostream & os, LatexRunParams const & runparams) const { return tabular.latex(buf, os, runparams); } -int InsetTabular::ascii(Buffer const * buf, ostream & os, int ll) const +int InsetTabular::ascii(Buffer const & buf, ostream & os, int ll) const { if (ll > 0) - return tabular.ascii(buf, os, ownerPar(*buf, this).params().depth(), + return tabular.ascii(buf, os, ownerPar(buf, this).params().depth(), false, 0); return tabular.ascii(buf, os, 0, false, 0); } -int InsetTabular::linuxdoc(Buffer const * buf, ostream & os) const +int InsetTabular::linuxdoc(Buffer const & buf, ostream & os) const { return tabular.linuxdoc(buf,os); } -int InsetTabular::docbook(Buffer const * buf, ostream & os, bool mixcont) const +int InsetTabular::docbook(Buffer const & buf, ostream & os, bool mixcont) const { int ret = 0; InsetOld * master; @@ -1455,7 +1444,7 @@ bool InsetTabular::moveNextCell(BufferView * bv, bool lock) } if (lock) { bool rtl = tabular.getCellInset(actcell).paragraphs.begin()-> - isRightToLeftPar(bv->buffer()->params); + isRightToLeftPar(bv->buffer()->params()); activateCellInset(bv, 0, 0, mouse_button::none, !rtl); } resetPos(bv); @@ -1484,7 +1473,7 @@ bool InsetTabular::movePrevCell(BufferView * bv, bool lock) } if (lock) { bool rtl = tabular.getCellInset(actcell).paragraphs.begin()-> - isRightToLeftPar(bv->buffer()->params); + isRightToLeftPar(bv->buffer()->params()); activateCellInset(bv, 0, 0, mouse_button::none, !rtl); } resetPos(bv); @@ -1686,13 +1675,13 @@ void InsetTabular::tabularFeatures(BufferView * bv, case LyXTabular::APPEND_ROW: // append the row into the tabular unlockInsetInInset(bv, the_locking_inset); - tabular.appendRow(bv->buffer()->params, actcell); + tabular.appendRow(bv->buffer()->params(), actcell); updateLocal(bv); break; case LyXTabular::APPEND_COLUMN: // append the column into the tabular unlockInsetInInset(bv, the_locking_inset); - tabular.appendColumn(bv->buffer()->params, actcell); + tabular.appendColumn(bv->buffer()->params(), actcell); actcell = tabular.getCellNumber(row, column); updateLocal(bv); break; @@ -1980,7 +1969,7 @@ bool InsetTabular::insetHit(BufferView *, int x, int) const } -void InsetTabular::deleteLyXText(BufferView * bv, bool recursive) const +void InsetTabular::deleteLyXText(BufferView * /*bv*/, bool /*recursive*/) const { //resizeLyXText(bv, recursive); } @@ -2220,7 +2209,7 @@ bool InsetTabular::copySelection(BufferView * bv) swap(sel_row_start, sel_row_end); delete paste_tabular; - paste_tabular = new LyXTabular(bv->buffer()->params, this, tabular); + paste_tabular = new LyXTabular(bv->buffer()->params(), this, tabular); for (int i = 0; i < sel_row_start; ++i) paste_tabular->deleteRow(0); @@ -2245,7 +2234,7 @@ bool InsetTabular::copySelection(BufferView * bv) true, true); ostringstream os; - paste_tabular->ascii(bv->buffer(), os, + paste_tabular->ascii(*bv->buffer(), os, ownerPar(*bv->buffer(), this).params().depth(), true, '\t'); bv->stuffClipboard(STRCONV(os.str())); return true; @@ -2586,7 +2575,7 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf, int row = 0; if (usePaste) { delete paste_tabular; - paste_tabular = new LyXTabular(bv->buffer()->params, + paste_tabular = new LyXTabular(bv->buffer()->params(), this, rows, maxCols); loctab = paste_tabular; cols = 0; @@ -2712,9 +2701,8 @@ int InsetTabularMailer::string2params(string const & in, InsetTabular & inset) if (!lex.isOK()) return -1; - Buffer const * const buffer = inset.buffer(); - if (buffer) - inset.read(buffer, lex); + Buffer const & buffer = inset.buffer(); + inset.read(buffer, lex); // We can't set the active cell, but we can tell the frontend // what it is. @@ -2724,9 +2712,7 @@ int InsetTabularMailer::string2params(string const & in, InsetTabular & inset) string const InsetTabularMailer::params2string(InsetTabular const & inset) { - Buffer const * const buffer = inset.buffer(); - if (!buffer) - return string(); + Buffer const & buffer = inset.buffer(); ostringstream data; data << name_ << " \\active_cell " << inset.getActCell() << '\n';