(temporarily) add a Buffer * Inset::buffer_ membert

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23170 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2008-02-23 22:32:33 +00:00
parent 30fff63257
commit e05e2b6b19
5 changed files with 33 additions and 43 deletions

View File

@ -217,21 +217,10 @@ pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
ParIterator fend = par_iterator_end(in); ParIterator fend = par_iterator_end(in);
for (; fpit != fend; ++fpit) { for (; fpit != fend; ++fpit) {
InsetList::const_iterator lit = fpit->insetList().begin(); InsetList::const_iterator it = fpit->insetList().begin();
InsetList::const_iterator eit = fpit->insetList().end(); InsetList::const_iterator et = fpit->insetList().end();
for (; it != et; ++it)
for (; lit != eit; ++lit) { it->inset->setBuffer(const_cast<Buffer *>(&buffer));
switch (lit->inset->lyxCode()) {
case TABULAR_CODE: {
InsetTabular * it = static_cast<InsetTabular*>(lit->inset);
it->buffer(&buffer);
break;
}
default:
break; // nothing
}
}
} }
insertion.swap(in.paragraphs()); insertion.swap(in.paragraphs());

View File

@ -75,7 +75,7 @@ namespace lyx {
namespace Alert = frontend::Alert; namespace Alert = frontend::Alert;
Inset * createInset(Buffer & buf, FuncRequest const & cmd) Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
{ {
BufferParams const & params = buf.params(); BufferParams const & params = buf.params();
@ -372,6 +372,13 @@ Inset * createInset(Buffer & buf, FuncRequest const & cmd)
return 0; return 0;
} }
Inset * createInset(Buffer & buf, FuncRequest const & cmd)
{
Inset * inset = createInsetHelper(buf, cmd);
if (inset)
inset->setBuffer(&buf);
return inset;
}
Inset * readInset(Lexer & lex, Buffer const & buf) Inset * readInset(Lexer & lex, Buffer const & buf)
{ {

View File

@ -90,6 +90,13 @@ public:
/// virtual base class destructor /// virtual base class destructor
virtual ~Inset() {} virtual ~Inset() {}
/// change associated Buffer
virtual void setBuffer(Buffer * buffer) { buffer_ = buffer; }
virtual void setBufferRecursively(Buffer *) {}
/// retrieve associated Buffer
virtual Buffer * buffer() { return buffer_; }
virtual Buffer const * buffer() const { return buffer_; }
/// identification as math inset /// identification as math inset
virtual InsetMath * asInsetMath() { return 0; } virtual InsetMath * asInsetMath() { return 0; }
/// true for 'math' math inset, but not for e.g. mbox /// true for 'math' math inset, but not for e.g. mbox
@ -477,7 +484,8 @@ public:
enum { TEXT_TO_INSET_OFFSET = 4 }; enum { TEXT_TO_INSET_OFFSET = 4 };
protected: protected:
Inset() {} /// Constructor
explicit Inset() : buffer_(0) {}
/// replicate ourselves /// replicate ourselves
friend class InsetList; friend class InsetList;
@ -496,6 +504,8 @@ protected:
* \sa getStatus * \sa getStatus
*/ */
virtual void doDispatch(Cursor & cur, FuncRequest & cmd); virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
Buffer * buffer_;
}; };
} // namespace lyx } // namespace lyx

View File

@ -2869,14 +2869,17 @@ Tabular::BoxType Tabular::useParbox(idx_type cell) const
InsetTabular::InsetTabular(Buffer const & buf, row_type rows, InsetTabular::InsetTabular(Buffer const & buf, row_type rows,
col_type columns) col_type columns)
: tabular(buf.params(), max(rows, row_type(1)), : tabular(buf.params(), max(rows, row_type(1)),
max(columns, col_type(1))), buffer_(&buf), scx_(0) max(columns, col_type(1))), scx_(0)
{} {
setBuffer(const_cast<Buffer *>(&buf)); // FIXME: remove later
}
InsetTabular::InsetTabular(InsetTabular const & tab) InsetTabular::InsetTabular(InsetTabular const & tab)
: Inset(tab), tabular(tab.tabular), : Inset(tab), tabular(tab.tabular), scx_(0)
buffer_(tab.buffer_), scx_(0) {
{} setBuffer(const_cast<Buffer *>(tab.buffer())); // FIXME: remove later
}
InsetTabular::~InsetTabular() InsetTabular::~InsetTabular()
@ -2891,18 +2894,6 @@ Inset * InsetTabular::clone() const
} }
Buffer const & InsetTabular::buffer() const
{
return *buffer_;
}
void InsetTabular::buffer(Buffer const * b)
{
buffer_ = b;
}
bool InsetTabular::insetAllowed(InsetCode code) const bool InsetTabular::insetAllowed(InsetCode code) const
{ {
if (code == MATHMACRO_CODE) if (code == MATHMACRO_CODE)
@ -4867,7 +4858,7 @@ void InsetTabularMailer::string2params(string const & in, InsetTabular & inset)
return print_mailer_error("InsetTabularMailer", in, 2, return print_mailer_error("InsetTabularMailer", in, 2,
"Tabular"); "Tabular");
Buffer const & buffer = inset.buffer(); Buffer const & buffer = *inset.buffer();
inset.read(buffer, lex); inset.read(buffer, lex);
} }
@ -4876,7 +4867,7 @@ string const InsetTabularMailer::params2string(InsetTabular const & inset)
{ {
ostringstream data; ostringstream data;
data << name_ << ' '; data << name_ << ' ';
inset.write(inset.buffer(), data); inset.write(*inset.buffer(), data);
data << "\\end_inset\n"; data << "\\end_inset\n";
return data.str(); return data.str();
} }

View File

@ -740,11 +740,6 @@ public:
/// ///
void addPreview(graphics::PreviewLoader &) const; void addPreview(graphics::PreviewLoader &) const;
///
Buffer const & buffer() const;
/// set the owning buffer
void buffer(Buffer const * buf);
/// lock cell with given index /// lock cell with given index
void edit(Cursor & cur, bool front, EntryDirection entry_from); void edit(Cursor & cur, bool front, EntryDirection entry_from);
/// ///
@ -814,8 +809,6 @@ private:
row_type row_start, row_type row_end, row_type row_start, row_type row_end,
col_type col_start, col_type col_end) const; col_type col_start, col_type col_end) const;
/// ///
Buffer const * buffer_;
///
mutable idx_type first_visible_cell; mutable idx_type first_visible_cell;
/// ///
mutable int scx_; mutable int scx_;