#include <config.h>
#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 <fstream>
-#include <algorithm>
-#include <cstdlib>
+#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 {
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
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;
}
-Buffer const * InsetTabular::buffer() const
+Buffer const & InsetTabular::buffer() const
{
- return buffer_;
+ return *buffer_;
}
}
-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");
void InsetTabular::updateLocal(BufferView * bv) const
{
- bv->updateInset();
+ bv->updateInset(this);
if (locked)
resetPos(bv);
}
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;
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
// no break here!
case LFUN_DELETE:
recordUndo(bv, Undo::DELETE);
- cutSelection(bv->buffer()->params);
+ cutSelection(bv->buffer()->params());
updateLocal(bv);
break;
case LFUN_COPY:
}
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;
}
-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;
}
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);
}
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);
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;
}
-void InsetTabular::deleteLyXText(BufferView * bv, bool recursive) const
+void InsetTabular::deleteLyXText(BufferView * /*bv*/, bool /*recursive*/) const
{
//resizeLyXText(bv, recursive);
}
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);
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;
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;
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.
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';