mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
* Inset: ensure that the Buffer pointer is not copied. This was the cause of very weird bugs with copy and paste within table.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25837 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
794aa69fc7
commit
4bc7feaa96
@ -202,7 +202,7 @@ void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex,
|
||||
} else if (token == "\\backslash") {
|
||||
par.appendChar('\\', font, change);
|
||||
} else if (token == "\\LyXTable") {
|
||||
auto_ptr<Inset> inset(new InsetTabular(buf));
|
||||
auto_ptr<Inset> inset(new InsetTabular(const_cast<Buffer &>(buf)));
|
||||
inset->read(lex);
|
||||
par.insertInset(par.size(), inset.release(), font, change);
|
||||
} else if (token == "\\lyxline") {
|
||||
|
@ -467,6 +467,7 @@ void updateLabels(Buffer const & buf, ParIterator & parit)
|
||||
InsetList::const_iterator end = parit->insetList().end();
|
||||
for (; iit != end; ++iit) {
|
||||
parit.pos() = iit->pos;
|
||||
iit->inset->setBuffer(const_cast<Buffer &>(buf));
|
||||
iit->inset->updateLabels(parit);
|
||||
}
|
||||
}
|
||||
|
@ -521,7 +521,7 @@ Inset * readInset(Lexer & lex, Buffer const & buf)
|
||||
} else if (tmptok == "space") {
|
||||
inset.reset(new InsetSpace);
|
||||
} else if (tmptok == "Tabular") {
|
||||
inset.reset(new InsetTabular(buf));
|
||||
inset.reset(new InsetTabular(const_cast<Buffer &>(buf)));
|
||||
} else if (tmptok == "Text") {
|
||||
inset.reset(new InsetText(buf));
|
||||
} else if (tmptok == "VSpace") {
|
||||
|
@ -150,7 +150,7 @@ Buffer const & Inset::buffer() const
|
||||
|
||||
bool Inset::isBufferValid() const
|
||||
{
|
||||
return theBufferList().isLoaded(buffer_);
|
||||
return buffer_ && theBufferList().isLoaded(buffer_);
|
||||
}
|
||||
|
||||
|
||||
|
@ -492,8 +492,9 @@ public:
|
||||
enum { TEXT_TO_INSET_OFFSET = 4 };
|
||||
|
||||
protected:
|
||||
/// Constructor
|
||||
explicit Inset() : buffer_(0) {}
|
||||
/// Constructors
|
||||
Inset() : buffer_(0) {}
|
||||
Inset(Inset const &) : buffer_(0) {}
|
||||
|
||||
/// replicate ourselves
|
||||
friend class InsetList;
|
||||
|
@ -472,7 +472,7 @@ string const featureAsString(Tabular::Feature feature)
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Tabular::CellData::CellData(Buffer const & buf)
|
||||
Tabular::CellData::CellData(Buffer & buf)
|
||||
: cellno(0),
|
||||
width(0),
|
||||
multicolumn(Tabular::CELL_NORMAL),
|
||||
@ -506,7 +506,8 @@ Tabular::CellData::CellData(CellData const & cs)
|
||||
align_special(cs.align_special),
|
||||
p_width(cs.p_width),
|
||||
inset(dynamic_cast<InsetTableCell *>(cs.inset->clone()))
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
Tabular::CellData & Tabular::CellData::operator=(CellData cs)
|
||||
{
|
||||
@ -563,14 +564,26 @@ Tabular::ltType::ltType()
|
||||
{}
|
||||
|
||||
|
||||
Tabular::Tabular(Buffer const & buffer, row_type rows_arg, col_type columns_arg)
|
||||
Tabular::Tabular(Buffer & buffer, row_type rows_arg, col_type columns_arg)
|
||||
{
|
||||
init(buffer, rows_arg, columns_arg);
|
||||
}
|
||||
|
||||
|
||||
void Tabular::setBuffer(Buffer & buffer)
|
||||
{
|
||||
buffer_ = &buffer;
|
||||
size_t row_count = row_info.size();
|
||||
size_t column_count = column_info.size();
|
||||
// set silly default lines
|
||||
for (row_type i = 0; i < row_count; ++i)
|
||||
for (col_type j = 0; j < column_count; ++j)
|
||||
cell_info[i][j].inset->setBuffer(*buffer_);
|
||||
}
|
||||
|
||||
|
||||
// activates all lines and sets all widths to 0
|
||||
void Tabular::init(Buffer const & buf, row_type rows_arg,
|
||||
void Tabular::init(Buffer & buf, row_type rows_arg,
|
||||
col_type columns_arg)
|
||||
{
|
||||
buffer_ = &buf;
|
||||
@ -589,6 +602,7 @@ void Tabular::init(Buffer const & buf, row_type rows_arg,
|
||||
// set silly default lines
|
||||
for (row_type i = 0; i < row_count; ++i)
|
||||
for (col_type j = 0; j < column_count; ++j) {
|
||||
cell_info[i][j].inset->setBuffer(*buffer_);
|
||||
cell_info[i][j].top_line = true;
|
||||
cell_info[i][j].left_line = true;
|
||||
cell_info[i][j].bottom_line = i == 0 || i == row_count - 1;
|
||||
@ -1421,6 +1435,7 @@ void Tabular::read(Lexer & lex)
|
||||
getTokenValue(line, "special", cell_info[i][j].align_special);
|
||||
l_getline(is, line);
|
||||
if (prefixIs(line, "\\begin_inset")) {
|
||||
cell_info[i][j].inset->setBuffer(*buffer_);
|
||||
cell_info[i][j].inset->read(lex);
|
||||
l_getline(is, line);
|
||||
}
|
||||
@ -2694,7 +2709,7 @@ Tabular::BoxType Tabular::useParbox(idx_type cell) const
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
InsetTableCell::InsetTableCell(Buffer const & buf)
|
||||
InsetTableCell::InsetTableCell(Buffer & buf)
|
||||
: InsetText(buf), isFixedWidth(false)
|
||||
{}
|
||||
|
||||
@ -2733,19 +2748,18 @@ bool InsetTableCell::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
InsetTabular::InsetTabular(Buffer const & buf, row_type rows,
|
||||
InsetTabular::InsetTabular(Buffer & buf, row_type rows,
|
||||
col_type columns)
|
||||
: tabular(buf, max(rows, row_type(1)), max(columns, col_type(1))), scx_(0),
|
||||
rowselect_(false), colselect_(false)
|
||||
{
|
||||
setBuffer(const_cast<Buffer &>(buf)); // FIXME: remove later
|
||||
setBuffer(buf); // FIXME: remove later
|
||||
}
|
||||
|
||||
|
||||
InsetTabular::InsetTabular(InsetTabular const & tab)
|
||||
: Inset(tab), tabular(tab.tabular), scx_(0)
|
||||
{
|
||||
setBuffer(const_cast<Buffer &>(tab.buffer())); // FIXME: remove later
|
||||
}
|
||||
|
||||
|
||||
@ -4520,6 +4534,8 @@ bool InsetTabular::copySelection(Cursor & cur)
|
||||
while (paste_tabular->column_info.size() > columns)
|
||||
paste_tabular->deleteColumn(columns);
|
||||
|
||||
paste_tabular->setBuffer(tabular.buffer());
|
||||
|
||||
odocstringstream os;
|
||||
OutputParams const runparams(0);
|
||||
paste_tabular->plaintext(os, runparams, 0, true, '\t');
|
||||
|
@ -235,7 +235,7 @@ public:
|
||||
static const idx_type npos = static_cast<idx_type>(-1);
|
||||
|
||||
/// constructor
|
||||
Tabular(Buffer const &, col_type columns_arg, row_type rows_arg);
|
||||
Tabular(Buffer &, col_type columns_arg, row_type rows_arg);
|
||||
|
||||
/// Returns true if there is a topline, returns false if not
|
||||
bool topLine(idx_type cell) const;
|
||||
@ -442,7 +442,7 @@ public:
|
||||
class CellData {
|
||||
public:
|
||||
///
|
||||
CellData(Buffer const &);
|
||||
CellData(Buffer &);
|
||||
///
|
||||
CellData(CellData const &);
|
||||
///
|
||||
@ -571,7 +571,7 @@ public:
|
||||
ltType endlastfoot;
|
||||
|
||||
///
|
||||
void init(Buffer const &, row_type rows_arg,
|
||||
void init(Buffer &, row_type rows_arg,
|
||||
col_type columns_arg);
|
||||
///
|
||||
void updateIndexes();
|
||||
@ -618,12 +618,12 @@ public:
|
||||
int docbookRow(odocstream & os, row_type, OutputParams const &) const;
|
||||
|
||||
/// change associated Buffer
|
||||
void setBuffer(Buffer const & buffer) { buffer_ = &buffer; }
|
||||
void setBuffer(Buffer & buffer);
|
||||
/// retrieve associated Buffer
|
||||
Buffer const & buffer() const { return *buffer_; }
|
||||
Buffer & buffer() const { return *buffer_; }
|
||||
|
||||
private:
|
||||
Buffer const * buffer_;
|
||||
Buffer * buffer_;
|
||||
|
||||
}; // Tabular
|
||||
|
||||
@ -633,7 +633,7 @@ class InsetTableCell : public InsetText
|
||||
{
|
||||
public:
|
||||
///
|
||||
InsetTableCell(Buffer const & buf);
|
||||
InsetTableCell(Buffer & buf);
|
||||
///
|
||||
InsetCode lyxCode() const { return CELL_CODE; }
|
||||
///
|
||||
@ -690,7 +690,7 @@ class InsetTabular : public Inset
|
||||
{
|
||||
public:
|
||||
///
|
||||
InsetTabular(Buffer const &, row_type rows = 1,
|
||||
InsetTabular(Buffer &, row_type rows = 1,
|
||||
col_type columns = 1);
|
||||
///
|
||||
~InsetTabular();
|
||||
|
Loading…
Reference in New Issue
Block a user