try to pass a Buffer & to inset construction if some buffer(param)

access is needed


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23465 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2008-03-04 22:28:18 +00:00
parent bddf480792
commit a694476ac6
44 changed files with 137 additions and 159 deletions

View File

@ -167,9 +167,6 @@ public:
*/ */
bool file_fully_loaded; bool file_fully_loaded;
/// our Text that should be wrapped in an InsetText
InsetText inset;
/// ///
mutable TocBackend toc_backend; mutable TocBackend toc_backend;
@ -209,6 +206,9 @@ public:
mutable EmbeddedFileList bibfilesCache_; mutable EmbeddedFileList bibfilesCache_;
mutable RefCache ref_cache_; mutable RefCache ref_cache_;
/// our Text that should be wrapped in an InsetText
InsetText inset;
}; };
/// Creates the per buffer temporary directory /// Creates the per buffer temporary directory
@ -233,13 +233,11 @@ static FileName createBufferTmpDir()
Buffer::Impl::Impl(Buffer & parent, FileName const & file, bool readonly_) Buffer::Impl::Impl(Buffer & parent, FileName const & file, bool readonly_)
: parent_buffer(0), lyx_clean(true), bak_clean(true), unnamed(false), : parent_buffer(0), lyx_clean(true), bak_clean(true), unnamed(false),
read_only(readonly_), filename(file), file_fully_loaded(false), read_only(readonly_), filename(file), file_fully_loaded(false),
inset(params), toc_backend(&parent), macro_lock(false), toc_backend(&parent), macro_lock(false),
embedded_files(), timestamp_(0), checksum_(0), wa_(0), embedded_files(), timestamp_(0), checksum_(0), wa_(0),
undo_(parent) undo_(parent)
{ {
temppath = createBufferTmpDir(); temppath = createBufferTmpDir();
inset.setBuffer(parent);
inset.setAutoBreakRows(true);
lyxvc.setBuffer(&parent); lyxvc.setBuffer(&parent);
if (use_gui) if (use_gui)
wa_ = new frontend::WorkAreaManager; wa_ = new frontend::WorkAreaManager;
@ -251,6 +249,9 @@ Buffer::Buffer(string const & file, bool readonly)
{ {
LYXERR(Debug::INFO, "Buffer::Buffer()"); LYXERR(Debug::INFO, "Buffer::Buffer()");
d->inset.setBuffer(*this);
d->inset.initParagraphs(*this);
d->inset.setAutoBreakRows(true);
d->inset.getText(0)->setMacrocontextPosition(par_iterator_begin()); d->inset.getText(0)->setMacrocontextPosition(par_iterator_begin());
} }

View File

@ -225,7 +225,7 @@ void Text::setLayout(Cursor & cur, docstring const & layout)
lyx::dispatch(FuncRequest(LFUN_LINE_BEGIN)); lyx::dispatch(FuncRequest(LFUN_LINE_BEGIN));
lyx::dispatch(FuncRequest(LFUN_LINE_END_SELECT)); lyx::dispatch(FuncRequest(LFUN_LINE_END_SELECT));
lyx::dispatch(FuncRequest(LFUN_CUT)); lyx::dispatch(FuncRequest(LFUN_CUT));
Inset * inset = new InsetEnvironment(params, layout); Inset * inset = new InsetEnvironment(bv.buffer(), layout);
insertInset(cur, inset); insertInset(cur, inset);
//inset->edit(cur, true); //inset->edit(cur, true);
//lyx::dispatch(FuncRequest(LFUN_PASTE)); //lyx::dispatch(FuncRequest(LFUN_PASTE));

View File

@ -102,44 +102,44 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
case LFUN_FLEX_INSERT: { case LFUN_FLEX_INSERT: {
string s = cmd.getArg(0); string s = cmd.getArg(0);
return new InsetFlex(params, params.documentClassPtr(), s); return new InsetFlex(buf, buf.params().documentClassPtr(), s);
} }
case LFUN_NOTE_INSERT: { case LFUN_NOTE_INSERT: {
string arg = cmd.getArg(0); string arg = cmd.getArg(0);
if (arg.empty()) if (arg.empty())
arg = "Note"; arg = "Note";
return new InsetNote(params, arg); return new InsetNote(buf, arg);
} }
case LFUN_BOX_INSERT: { case LFUN_BOX_INSERT: {
string arg = cmd.getArg(0); string arg = cmd.getArg(0);
if (arg.empty()) if (arg.empty())
arg = "Boxed"; arg = "Boxed";
return new InsetBox(params, arg); return new InsetBox(buf, arg);
} }
case LFUN_BRANCH_INSERT: { case LFUN_BRANCH_INSERT: {
docstring arg = cmd.argument(); docstring arg = cmd.argument();
if (arg.empty()) if (arg.empty())
arg = from_ascii("none"); arg = from_ascii("none");
return new InsetBranch(params, InsetBranchParams(arg)); return new InsetBranch(buf, InsetBranchParams(arg));
} }
case LFUN_ERT_INSERT: case LFUN_ERT_INSERT:
return new InsetERT(params); return new InsetERT(buf);
case LFUN_LISTING_INSERT: case LFUN_LISTING_INSERT:
return new InsetListings(params); return new InsetListings(buf);
case LFUN_FOOTNOTE_INSERT: case LFUN_FOOTNOTE_INSERT:
return new InsetFoot(params); return new InsetFoot(buf);
case LFUN_MARGINALNOTE_INSERT: case LFUN_MARGINALNOTE_INSERT:
return new InsetMarginal(params); return new InsetMarginal(buf);
case LFUN_OPTIONAL_INSERT: case LFUN_OPTIONAL_INSERT:
return new InsetOptArg(params); return new InsetOptArg(buf);
case LFUN_BIBITEM_INSERT: case LFUN_BIBITEM_INSERT:
return new InsetBibitem(InsetCommandParams(BIBITEM_CODE)); return new InsetBibitem(InsetCommandParams(BIBITEM_CODE));
@ -147,8 +147,8 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
case LFUN_FLOAT_INSERT: { case LFUN_FLOAT_INSERT: {
// check if the float type exists // check if the float type exists
string const argument = to_utf8(cmd.argument()); string const argument = to_utf8(cmd.argument());
if (params.documentClass().floats().typeExist(argument)) if (buf.params().documentClass().floats().typeExist(argument))
return new InsetFloat(params, argument); return new InsetFloat(buf, argument);
lyxerr << "Non-existent float type: " << argument << endl; lyxerr << "Non-existent float type: " << argument << endl;
} }
@ -156,7 +156,7 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
// check if the float type exists // check if the float type exists
string const argument = to_utf8(cmd.argument()); string const argument = to_utf8(cmd.argument());
if (params.documentClass().floats().typeExist(argument)) { if (params.documentClass().floats().typeExist(argument)) {
auto_ptr<InsetFloat> p(new InsetFloat(params, argument)); auto_ptr<InsetFloat> p(new InsetFloat(buf, argument));
p->wide(true, params); p->wide(true, params);
return p.release(); return p.release();
} }
@ -167,13 +167,13 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
case LFUN_WRAP_INSERT: { case LFUN_WRAP_INSERT: {
string const argument = to_utf8(cmd.argument()); string const argument = to_utf8(cmd.argument());
if (argument == "figure" || argument == "table") if (argument == "figure" || argument == "table")
return new InsetWrap(params, argument); return new InsetWrap(buf, argument);
lyxerr << "Non-existent wrapfig type: " << argument << endl; lyxerr << "Non-existent wrapfig type: " << argument << endl;
return 0; return 0;
} }
case LFUN_INDEX_INSERT: case LFUN_INDEX_INSERT:
return new InsetIndex(params); return new InsetIndex(buf);
case LFUN_NOMENCL_INSERT: { case LFUN_NOMENCL_INSERT: {
InsetCommandParams icp(NOMENCL_CODE); InsetCommandParams icp(NOMENCL_CODE);
@ -195,7 +195,7 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
} }
case LFUN_CAPTION_INSERT: { case LFUN_CAPTION_INSERT: {
auto_ptr<InsetCaption> inset(new InsetCaption(params)); auto_ptr<InsetCaption> inset(new InsetCaption(buf));
inset->setAutoBreakRows(true); inset->setAutoBreakRows(true);
inset->setDrawFrame(true); inset->setDrawFrame(true);
inset->setFrameColor(Color_captionframe); inset->setFrameColor(Color_captionframe);
@ -212,10 +212,10 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
return new InsetTOC(InsetCommandParams(TOC_CODE)); return new InsetTOC(InsetCommandParams(TOC_CODE));
case LFUN_ENVIRONMENT_INSERT: case LFUN_ENVIRONMENT_INSERT:
return new InsetEnvironment(params, cmd.argument()); return new InsetEnvironment(buf, cmd.argument());
case LFUN_INFO_INSERT: case LFUN_INFO_INSERT:
return new InsetInfo(params, to_utf8(cmd.argument())); return new InsetInfo(buf, to_utf8(cmd.argument()));
#if 0 #if 0
case LFUN_THEOREM_INSERT: case LFUN_THEOREM_INSERT:
return new InsetTheorem; return new InsetTheorem;
@ -250,13 +250,13 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
case ERT_CODE: { case ERT_CODE: {
InsetCollapsable::CollapseStatus st; InsetCollapsable::CollapseStatus st;
InsetERTMailer::string2params(to_utf8(cmd.argument()), st); InsetERTMailer::string2params(to_utf8(cmd.argument()), st);
return new InsetERT(params, st); return new InsetERT(buf, st);
} }
case LISTINGS_CODE: { case LISTINGS_CODE: {
InsetListingsParams par; InsetListingsParams par;
InsetListingsMailer::string2params(to_utf8(cmd.argument()), par); InsetListingsMailer::string2params(to_utf8(cmd.argument()), par);
return new InsetListings(params, par); return new InsetListings(buf, par);
} }
case EXTERNAL_CODE: { case EXTERNAL_CODE: {
@ -288,7 +288,7 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
} }
case INDEX_CODE: case INDEX_CODE:
return new InsetIndex(params); return new InsetIndex(buf);
case NOMENCL_CODE: { case NOMENCL_CODE: {
InsetCommandParams icp(code); InsetCommandParams icp(code);
@ -305,7 +305,7 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
case REF_CODE: { case REF_CODE: {
InsetCommandParams icp(code); InsetCommandParams icp(code);
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp); InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp);
return new InsetRef(icp, buf); return new InsetRef(buf, icp);
} }
case TOC_CODE: { case TOC_CODE: {
@ -446,7 +446,7 @@ Inset * readInset(Lexer & lex, Buffer const & buf)
break; break;
case REF_CODE: case REF_CODE:
if (!inscmd["name"].empty() || !inscmd["reference"].empty()) if (!inscmd["name"].empty() || !inscmd["reference"].empty())
inset.reset(new InsetRef(inscmd, buf)); inset.reset(new InsetRef(buf, inscmd));
break; break;
case TOC_CODE: case TOC_CODE:
inset.reset(new InsetTOC(inscmd)); inset.reset(new InsetTOC(inscmd));
@ -478,58 +478,58 @@ Inset * readInset(Lexer & lex, Buffer const & buf)
} else if (tmptok == "Graphics") { } else if (tmptok == "Graphics") {
inset.reset(new InsetGraphics); inset.reset(new InsetGraphics);
} else if (tmptok == "Note") { } else if (tmptok == "Note") {
inset.reset(new InsetNote(buf.params(), tmptok)); inset.reset(new InsetNote(buf, tmptok));
} else if (tmptok == "Box") { } else if (tmptok == "Box") {
inset.reset(new InsetBox(buf.params(), tmptok)); inset.reset(new InsetBox(buf, tmptok));
} else if (tmptok == "Flex") { } else if (tmptok == "Flex") {
lex.next(); lex.next();
string s = lex.getString(); string s = lex.getString();
inset.reset(new InsetFlex(buf.params(), inset.reset(new InsetFlex(buf,
buf.params().documentClassPtr(), s)); buf.params().documentClassPtr(), s));
} else if (tmptok == "Branch") { } else if (tmptok == "Branch") {
inset.reset(new InsetBranch(buf.params(), inset.reset(new InsetBranch(buf,
InsetBranchParams())); InsetBranchParams()));
} else if (tmptok == "Environment") { } else if (tmptok == "Environment") {
lex.next(); lex.next();
inset.reset(new InsetEnvironment(buf.params(), lex.getDocString())); inset.reset(new InsetEnvironment(buf, lex.getDocString()));
} else if (tmptok == "ERT") { } else if (tmptok == "ERT") {
inset.reset(new InsetERT(buf.params())); inset.reset(new InsetERT(buf));
} else if (tmptok == "listings") { } else if (tmptok == "listings") {
inset.reset(new InsetListings(buf.params())); inset.reset(new InsetListings(buf));
} else if (tmptok == "InsetSpace") { } else if (tmptok == "InsetSpace") {
inset.reset(new InsetSpace); inset.reset(new InsetSpace);
} else if (tmptok == "Tabular") { } else if (tmptok == "Tabular") {
inset.reset(new InsetTabular(buf)); inset.reset(new InsetTabular(buf));
} else if (tmptok == "Text") { } else if (tmptok == "Text") {
inset.reset(new InsetText(buf.params())); inset.reset(new InsetText(buf));
} else if (tmptok == "VSpace") { } else if (tmptok == "VSpace") {
inset.reset(new InsetVSpace); inset.reset(new InsetVSpace);
} else if (tmptok == "Foot") { } else if (tmptok == "Foot") {
inset.reset(new InsetFoot(buf.params())); inset.reset(new InsetFoot(buf));
} else if (tmptok == "Marginal") { } else if (tmptok == "Marginal") {
inset.reset(new InsetMarginal(buf.params())); inset.reset(new InsetMarginal(buf));
} else if (tmptok == "OptArg") { } else if (tmptok == "OptArg") {
inset.reset(new InsetOptArg(buf.params())); inset.reset(new InsetOptArg(buf));
} else if (tmptok == "Float") { } else if (tmptok == "Float") {
lex.next(); lex.next();
string tmptok = lex.getString(); string tmptok = lex.getString();
inset.reset(new InsetFloat(buf.params(), tmptok)); inset.reset(new InsetFloat(buf, tmptok));
} else if (tmptok == "Wrap") { } else if (tmptok == "Wrap") {
lex.next(); lex.next();
string tmptok = lex.getString(); string tmptok = lex.getString();
inset.reset(new InsetWrap(buf.params(), tmptok)); inset.reset(new InsetWrap(buf, tmptok));
#if 0 #if 0
} else if (tmptok == "Theorem") { } else if (tmptok == "Theorem") {
inset.reset(new InsetList); inset.reset(new InsetList);
#endif #endif
} else if (tmptok == "Caption") { } else if (tmptok == "Caption") {
inset.reset(new InsetCaption(buf.params())); inset.reset(new InsetCaption(buf));
} else if (tmptok == "Index") { } else if (tmptok == "Index") {
inset.reset(new InsetIndex(buf.params())); inset.reset(new InsetIndex(buf));
} else if (tmptok == "FloatList") { } else if (tmptok == "FloatList") {
inset.reset(new InsetFloatList); inset.reset(new InsetFloatList);
} else if (tmptok == "Info") { } else if (tmptok == "Info") {
inset.reset(new InsetInfo(buf.params())); inset.reset(new InsetInfo(buf));
} else { } else {
lyxerr << "unknown Inset type '" << tmptok lyxerr << "unknown Inset type '" << tmptok
<< "'" << endl; << "'" << endl;

View File

@ -85,11 +85,11 @@ BoxTranslatorLoc const & boxtranslator_loc()
} // anon } // anon
InsetBox::InsetBox(BufferParams const & bp, string const & label) InsetBox::InsetBox(Buffer const & buffer, string const & label)
: InsetCollapsable(bp), params_(label) : InsetCollapsable(buffer), params_(label)
{ {
if (forceEmptyLayout()) if (forceEmptyLayout())
paragraphs().back().setLayout(bp.documentClass().emptyLayout()); paragraphs().back().setLayout(buffer.params().documentClass().emptyLayout());
} }

View File

@ -58,7 +58,7 @@ public:
class InsetBox : public InsetCollapsable { class InsetBox : public InsetCollapsable {
public: public:
/// ///
InsetBox(BufferParams const &, std::string const &); InsetBox(Buffer const &, std::string const &);
/// ///
~InsetBox(); ~InsetBox();
/// ///

View File

@ -33,14 +33,8 @@ using namespace std;
namespace lyx { namespace lyx {
InsetBranch::InsetBranch(BufferParams const & bp, InsetBranch::InsetBranch(Buffer const & buf, InsetBranchParams const & params)
InsetBranchParams const & params) : InsetCollapsable(buf), params_(params)
: InsetCollapsable(bp), params_(params)
{}
InsetBranch::InsetBranch(InsetBranch const & in)
: InsetCollapsable(in), params_(in.params_)
{} {}
@ -50,12 +44,6 @@ InsetBranch::~InsetBranch()
} }
Inset * InsetBranch::clone() const
{
return new InsetBranch(*this);
}
docstring InsetBranch::editMessage() const docstring InsetBranch::editMessage() const
{ {
return _("Opened Branch Inset"); return _("Opened Branch Inset");

View File

@ -37,7 +37,7 @@ public:
class InsetBranch : public InsetCollapsable { class InsetBranch : public InsetCollapsable {
public: public:
/// ///
InsetBranch(BufferParams const &, InsetBranchParams const &); InsetBranch(Buffer const &, InsetBranchParams const &);
/// ///
~InsetBranch(); ~InsetBranch();
/// ///
@ -83,16 +83,14 @@ public:
docstring toolTip(BufferView const & bv, int x, int y) const; docstring toolTip(BufferView const & bv, int x, int y) const;
protected: protected:
/// ///
InsetBranch(InsetBranch const &); void doDispatch(Cursor & cur, FuncRequest & cmd);
///
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
/// ///
docstring name() const { return from_ascii("Branch"); } docstring name() const { return from_ascii("Branch"); }
private: private:
///
friend class InsetBranchParams; friend class InsetBranchParams;
///
virtual Inset * clone() const; Inset * clone() const { return new InsetBranch(*this); }
/// ///
InsetBranchParams params_; InsetBranchParams params_;
}; };

View File

@ -56,15 +56,14 @@ InsetCaption::InsetCaption(InsetCaption const & ic)
} }
InsetCaption::InsetCaption(BufferParams const & bp) InsetCaption::InsetCaption(Buffer const & buf)
: InsetText(bp) : InsetText(buf)
{ {
setAutoBreakRows(true); setAutoBreakRows(true);
setDrawFrame(true); setDrawFrame(true);
setFrameColor(Color_captionframe); setFrameColor(Color_captionframe);
//FIXME Do we need to set all paragraphs here? or will there // There will always be only one
//always only be one? paragraphs().back().setLayout(buf.params().documentClass().emptyLayout());
paragraphs().back().setLayout(bp.documentClass().emptyLayout());
} }

View File

@ -22,7 +22,7 @@ class InsetCaption : public InsetText {
public: public:
/// ///
InsetCaption(InsetCaption const &); InsetCaption(InsetCaption const &);
InsetCaption(BufferParams const &); InsetCaption(Buffer const &);
/// ///
virtual ~InsetCaption() {} virtual ~InsetCaption() {}
/// ///

View File

@ -77,16 +77,16 @@ InsetCollapsable::Geometry InsetCollapsable::geometry() const
} }
InsetCollapsable::InsetCollapsable(BufferParams const & bp, InsetCollapsable::InsetCollapsable(Buffer const & buf,
CollapseStatus status, DocumentClass * dc) CollapseStatus status, DocumentClass * dc)
: InsetText(bp), status_(status), : InsetText(buf), status_(status),
openinlined_(false), autoOpen_(false), mouse_hover_(false) openinlined_(false), autoOpen_(false), mouse_hover_(false)
{ {
setLayout(dc); setLayout(dc);
setAutoBreakRows(true); setAutoBreakRows(true);
setDrawFrame(true); setDrawFrame(true);
setFrameColor(Color_collapsableframe); setFrameColor(Color_collapsableframe);
paragraphs().back().setLayout(bp.documentClass().emptyLayout()); paragraphs().back().setLayout(buf.params().documentClass().emptyLayout());
} }

View File

@ -38,7 +38,7 @@ namespace frontend { class Painter; }
class InsetCollapsable : public InsetText { class InsetCollapsable : public InsetText {
public: public:
/// ///
InsetCollapsable(BufferParams const &, InsetCollapsable(Buffer const &,
CollapseStatus status = Inset::Open, DocumentClass * tc = 0); CollapseStatus status = Inset::Open, DocumentClass * tc = 0);
/// ///
InsetCollapsable(InsetCollapsable const & rhs); InsetCollapsable(InsetCollapsable const & rhs);

View File

@ -43,8 +43,8 @@ using namespace lyx::support;
namespace lyx { namespace lyx {
InsetERT::InsetERT(BufferParams const & bp, CollapseStatus status) InsetERT::InsetERT(Buffer const & buf, CollapseStatus status)
: InsetCollapsable(bp, status) : InsetCollapsable(buf, status)
{} {}

View File

@ -33,7 +33,7 @@ class Language;
class InsetERT : public InsetCollapsable { class InsetERT : public InsetCollapsable {
public: public:
/// ///
InsetERT(BufferParams const &, CollapseStatus status = Open); InsetERT(Buffer const &, CollapseStatus status = Open);
#if 0 #if 0
/// ///
InsetERT(BufferParams const &, InsetERT(BufferParams const &,

View File

@ -12,22 +12,23 @@
#include "InsetEnvironment.h" #include "InsetEnvironment.h"
#include "Buffer.h"
#include "BufferParams.h" #include "BufferParams.h"
#include "support/gettext.h"
#include "Layout.h" #include "Layout.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "output_latex.h" #include "output_latex.h"
#include "TexRow.h" #include "TexRow.h"
#include "TextClass.h" #include "TextClass.h"
#include "support/gettext.h"
using namespace std; using namespace std;
namespace lyx { namespace lyx {
InsetEnvironment::InsetEnvironment InsetEnvironment::InsetEnvironment(Buffer const & buf, docstring const & name)
(BufferParams const & bp, docstring const & name) : InsetText(buf), layout_(buf.params().documentClass()[name]), name_(name)
: InsetText(bp), layout_(bp.documentClass()[name]), name_(name)
{ {
setAutoBreakRows(true); setAutoBreakRows(true);
setDrawFrame(true); setDrawFrame(true);
@ -39,12 +40,6 @@ InsetEnvironment::InsetEnvironment(InsetEnvironment const & in)
{} {}
Inset * InsetEnvironment::clone() const
{
return new InsetEnvironment(*this);
}
void InsetEnvironment::write(ostream & os) const void InsetEnvironment::write(ostream & os) const
{ {
os << "Environment " << to_utf8(name()) << "\n"; os << "Environment " << to_utf8(name()) << "\n";

View File

@ -21,7 +21,7 @@ namespace lyx {
class InsetEnvironment : public InsetText { class InsetEnvironment : public InsetText {
public: public:
/// ///
InsetEnvironment(BufferParams const &, docstring const & name); InsetEnvironment(Buffer const &, docstring const & name);
/// ///
docstring name() const { return name_; } docstring name() const { return name_; }
/// ///
@ -48,7 +48,7 @@ protected:
InsetEnvironment(InsetEnvironment const &); InsetEnvironment(InsetEnvironment const &);
private: private:
/// ///
Inset * clone() const; Inset * clone() const { return new InsetEnvironment(*this); }
/// the layout /// the layout
LayoutPtr layout_; LayoutPtr layout_;
/// ///

View File

@ -39,9 +39,9 @@ using namespace std;
namespace lyx { namespace lyx {
InsetFlex::InsetFlex(BufferParams const & bp, InsetFlex::InsetFlex(Buffer const & buf,
DocumentClass * dc, string const & layoutName) DocumentClass * dc, string const & layoutName)
: InsetCollapsable(bp, Collapsed, dc), : InsetCollapsable(buf, Collapsed, dc),
name_(layoutName) name_(layoutName)
{ {
setLayout(dc); // again, because now the name is initialized setLayout(dc); // again, because now the name is initialized
@ -55,12 +55,6 @@ InsetFlex::InsetFlex(InsetFlex const & in)
{} {}
Inset * InsetFlex::clone() const
{
return new InsetFlex(*this);
}
docstring InsetFlex::editMessage() const docstring InsetFlex::editMessage() const
{ {
return _("Opened Flex Inset"); return _("Opened Flex Inset");

View File

@ -23,7 +23,7 @@ namespace lyx {
class InsetFlex : public InsetCollapsable { class InsetFlex : public InsetCollapsable {
public: public:
/// ///
InsetFlex(BufferParams const &, DocumentClass * dc, InsetFlex(Buffer const &, DocumentClass * dc,
std::string const & layoutName); std::string const & layoutName);
/// ///
docstring name() const { return from_utf8(name_); } docstring name() const { return from_utf8(name_); }
@ -55,7 +55,7 @@ protected:
InsetFlex(InsetFlex const &); InsetFlex(InsetFlex const &);
private: private:
virtual Inset * clone() const; Inset * clone() const { return new InsetFlex(*this); }
/// ///
std::string name_; std::string name_;

View File

@ -111,10 +111,10 @@ namespace lyx {
// Lgb // Lgb
InsetFloat::InsetFloat(BufferParams const & bp, string const & type) InsetFloat::InsetFloat(Buffer const & buf, string const & type)
: InsetCollapsable(bp), name_(from_utf8(type)) : InsetCollapsable(buf), name_(from_utf8(type))
{ {
setLabel(_("float: ") + floatName(type, bp)); setLabel(_("float: ") + floatName(type, buf.params()));
params_.type = type; params_.type = type;
} }

View File

@ -47,7 +47,7 @@ public:
class InsetFloat : public InsetCollapsable { class InsetFloat : public InsetCollapsable {
public: public:
/// ///
InsetFloat(BufferParams const &, std::string const &); InsetFloat(Buffer const &, std::string const &);
/// ///
~InsetFloat(); ~InsetFloat();
/// ///

View File

@ -35,8 +35,8 @@ using namespace std;
namespace lyx { namespace lyx {
InsetFoot::InsetFoot(BufferParams const & bp) InsetFoot::InsetFoot(Buffer const & buf)
: InsetFootlike(bp) : InsetFootlike(buf)
{} {}
@ -45,12 +45,6 @@ InsetFoot::InsetFoot(InsetFoot const & in)
{} {}
Inset * InsetFoot::clone() const
{
return new InsetFoot(*this);
}
docstring InsetFoot::editMessage() const docstring InsetFoot::editMessage() const
{ {
return _("Opened Footnote Inset"); return _("Opened Footnote Inset");

View File

@ -24,7 +24,7 @@ namespace lyx {
class InsetFoot : public InsetFootlike { class InsetFoot : public InsetFootlike {
public: public:
/// ///
InsetFoot(BufferParams const &); InsetFoot(Buffer const &);
/// ///
InsetCode lyxCode() const { return FOOT_CODE; } InsetCode lyxCode() const { return FOOT_CODE; }
/// ///
@ -45,7 +45,7 @@ public:
protected: protected:
InsetFoot(InsetFoot const &); InsetFoot(InsetFoot const &);
private: private:
Inset * clone() const; Inset * clone() const { return new InsetFoot(*this); }
}; };

View File

@ -24,8 +24,8 @@ using namespace std;
namespace lyx { namespace lyx {
InsetFootlike::InsetFootlike(BufferParams const & bp) InsetFootlike::InsetFootlike(Buffer const & buf)
: InsetCollapsable(bp) : InsetCollapsable(buf)
{} {}

View File

@ -23,7 +23,7 @@ namespace lyx {
class InsetFootlike : public InsetCollapsable { class InsetFootlike : public InsetCollapsable {
public: public:
/// ///
InsetFootlike(BufferParams const &); InsetFootlike(Buffer const &);
/// ///
InsetFootlike(InsetFootlike const &); InsetFootlike(InsetFootlike const &);
/// ///

View File

@ -29,8 +29,8 @@ using namespace std;
namespace lyx { namespace lyx {
InsetIndex::InsetIndex(BufferParams const & bp) InsetIndex::InsetIndex(Buffer const & buf)
: InsetCollapsable(bp) : InsetCollapsable(buf)
{} {}

View File

@ -26,7 +26,7 @@ class LaTeXFeatures;
class InsetIndex : public InsetCollapsable { class InsetIndex : public InsetCollapsable {
public: public:
/// ///
InsetIndex(BufferParams const &); InsetIndex(Buffer const &);
/// ///
InsetIndex(InsetIndex const &); InsetIndex(InsetIndex const &);
/// ///

View File

@ -44,8 +44,8 @@ using namespace lyx::support;
namespace lyx { namespace lyx {
InsetInfo::InsetInfo(BufferParams const & bp, string const & name) InsetInfo::InsetInfo(Buffer const & buf, string const & name)
: InsetText(bp), type_(UNKNOWN_INFO), name_(), : InsetText(buf), type_(UNKNOWN_INFO), name_(),
mouse_hover_(false) mouse_hover_(false)
{ {
setAutoBreakRows(true); setAutoBreakRows(true);

View File

@ -84,7 +84,7 @@ public:
}; };
/// ///
InsetInfo(BufferParams const & bp, std::string const & info = std::string()); InsetInfo(Buffer const & buf, std::string const & info = std::string());
/// ///
Inset * editXY(Cursor & cur, int x, int y); Inset * editXY(Cursor & cur, int x, int y);
/// ///

View File

@ -41,8 +41,8 @@ namespace lyx {
char const lstinline_delimiters[] = char const lstinline_delimiters[] =
"!*()-=+|;:'\"`,<.>/?QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm"; "!*()-=+|;:'\"`,<.>/?QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm";
InsetListings::InsetListings(BufferParams const & bp, InsetListingsParams const & par) InsetListings::InsetListings(Buffer const & buf, InsetListingsParams const & par)
: InsetCollapsable(bp, par.status()) : InsetCollapsable(buf, par.status())
{} {}

View File

@ -27,7 +27,7 @@ namespace lyx {
class InsetListings : public InsetCollapsable { class InsetListings : public InsetCollapsable {
public: public:
/// ///
InsetListings(BufferParams const &, InsetListingsParams const & par = InsetListingsParams()); InsetListings(Buffer const &, InsetListingsParams const & par = InsetListingsParams());
/// ///
~InsetListings(); ~InsetListings();
/// ///

View File

@ -25,8 +25,8 @@
namespace lyx { namespace lyx {
InsetMarginal::InsetMarginal(BufferParams const & bp) InsetMarginal::InsetMarginal(Buffer const & buf)
: InsetFootlike(bp) : InsetFootlike(buf)
{} {}

View File

@ -25,7 +25,7 @@ namespace lyx {
class InsetMarginal : public InsetFootlike { class InsetMarginal : public InsetFootlike {
public: public:
/// ///
InsetMarginal(BufferParams const &); InsetMarginal(Buffer const &);
/// ///
InsetCode lyxCode() const { return MARGIN_CODE; } InsetCode lyxCode() const { return MARGIN_CODE; }
/// ///

View File

@ -106,8 +106,8 @@ void InsetNoteParams::read(Lexer & lex)
} }
InsetNote::InsetNote(BufferParams const & bp, string const & label) InsetNote::InsetNote(Buffer const & buf, string const & label)
: InsetCollapsable(bp) : InsetCollapsable(buf)
{ {
params_.type = notetranslator().find(label); params_.type = notetranslator().find(label);
} }

View File

@ -42,7 +42,7 @@ public:
class InsetNote : public InsetCollapsable { class InsetNote : public InsetCollapsable {
public: public:
/// ///
InsetNote(BufferParams const &, std::string const &); InsetNote(Buffer const &, std::string const &);
/// ///
~InsetNote(); ~InsetNote();
/// ///

View File

@ -21,8 +21,8 @@ using namespace std;
namespace lyx { namespace lyx {
InsetOptArg::InsetOptArg(BufferParams const & ins) InsetOptArg::InsetOptArg(Buffer const & buf)
: InsetCollapsable(ins) : InsetCollapsable(buf)
{} {}

View File

@ -25,7 +25,7 @@ namespace lyx {
*/ */
class InsetOptArg : public InsetCollapsable { class InsetOptArg : public InsetCollapsable {
public: public:
InsetOptArg(BufferParams const &); InsetOptArg(Buffer const &);
/// code of the inset /// code of the inset
InsetCode lyxCode() const { return OPTARG_CODE; } InsetCode lyxCode() const { return OPTARG_CODE; }

View File

@ -94,8 +94,8 @@ InsetQuotes::InsetQuotes(quote_language l, quote_side s, quote_times t)
} }
InsetQuotes::InsetQuotes(char_type c, BufferParams const & params) InsetQuotes::InsetQuotes(Buffer const & buf, char_type c)
: language_(params.quotes_language), times_(params.quotes_times) : language_(buf.params().quotes_language), times_(buf.params().quotes_times)
{ {
getPosition(c); getPosition(c);
} }

View File

@ -69,7 +69,7 @@ public:
*/ */
explicit InsetQuotes(std::string const & str = "eld"); explicit InsetQuotes(std::string const & str = "eld");
/// Create the right quote inset after character c /// Create the right quote inset after character c
InsetQuotes(char_type c, BufferParams const & params); InsetQuotes(Buffer const & buffer, char_type c);
/// Direct access to inner/outer quotation marks /// Direct access to inner/outer quotation marks
InsetQuotes(char_type c, quote_language l, quote_times t); InsetQuotes(char_type c, quote_language l, quote_times t);
/// ///

View File

@ -33,7 +33,7 @@ using namespace std;
namespace lyx { namespace lyx {
InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf) InsetRef::InsetRef(Buffer const & buf, InsetCommandParams const & p)
: InsetCommand(p, "ref"), isLatex(buf.isLatex()) : InsetCommand(p, "ref"), isLatex(buf.isLatex())
{} {}

View File

@ -36,7 +36,7 @@ public:
static std::string const & getName(int type); static std::string const & getName(int type);
InsetRef(InsetCommandParams const &, Buffer const &); InsetRef(Buffer const & buffer, InsetCommandParams const &);
/// verify label and reference. /// verify label and reference.
/** /**

View File

@ -472,7 +472,7 @@ string const featureAsString(Tabular::Feature feature)
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
Tabular::CellData::CellData(Buffer const & buffer) Tabular::CellData::CellData(Buffer const & buf)
: cellno(0), : cellno(0),
width(0), width(0),
multicolumn(Tabular::CELL_NORMAL), multicolumn(Tabular::CELL_NORMAL),
@ -484,10 +484,10 @@ Tabular::CellData::CellData(Buffer const & buffer)
right_line(false), right_line(false),
usebox(BOX_NONE), usebox(BOX_NONE),
rotate(false), rotate(false),
inset(new InsetText(buffer.params())) inset(new InsetText(buf))
{ {
inset->setBuffer(const_cast<Buffer &>(buffer)); inset->setBuffer(const_cast<Buffer &>(buf));
inset->paragraphs().back().setLayout(buffer.params().documentClass().emptyLayout()); inset->paragraphs().back().setLayout(buf.params().documentClass().emptyLayout());
} }

View File

@ -98,13 +98,10 @@ private:
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
InsetText::InsetText(BufferParams const & bp) InsetText::InsetText(Buffer const & buf)
: drawFrame_(false), frame_color_(Color_insetframe) : drawFrame_(false), frame_color_(Color_insetframe)
{ {
paragraphs().push_back(Paragraph()); initParagraphs(buf);
Paragraph & ourpar = paragraphs().back();
ourpar.setEmptyOrDefaultLayout(bp.documentClass());
ourpar.setInsetOwner(this);
} }
@ -123,6 +120,16 @@ InsetText::InsetText()
{} {}
void InsetText::initParagraphs(Buffer const & buf)
{
BOOST_ASSERT(paragraphs().empty());
buffer_ = const_cast<Buffer *>(&buf);
paragraphs().push_back(Paragraph());
Paragraph & ourpar = paragraphs().back();
ourpar.setEmptyOrDefaultLayout(buf.params().documentClass());
ourpar.setInsetOwner(this);
}
void InsetText::setParagraphOwner() void InsetText::setParagraphOwner()
{ {
for_each(paragraphs().begin(), paragraphs().end(), for_each(paragraphs().begin(), paragraphs().end(),

View File

@ -34,11 +34,13 @@ class InsetTabular;
class InsetText : public Inset { class InsetText : public Inset {
public: public:
/// ///
explicit InsetText(BufferParams const &); explicit InsetText(Buffer const & buffer);
/// ///
InsetText(); InsetText();
/// ///
InsetText(InsetText const &); InsetText(InsetText const &);
///
void initParagraphs(Buffer const & buffer);
/// ///
Dimension const dimension(BufferView const &) const; Dimension const dimension(BufferView const &) const;

View File

@ -39,10 +39,10 @@ using namespace std;
namespace lyx { namespace lyx {
InsetWrap::InsetWrap(BufferParams const & bp, string const & type) InsetWrap::InsetWrap(Buffer const & buf, string const & type)
: InsetCollapsable(bp), name_(from_utf8(type)) : InsetCollapsable(buf), name_(from_utf8(type))
{ {
setLabel(_("wrap: ") + floatName(type, bp)); setLabel(_("wrap: ") + floatName(type, buf.params()));
params_.type = type; params_.type = type;
params_.lines = 0; params_.lines = 0;
params_.placement = "o"; params_.placement = "o";

View File

@ -45,7 +45,7 @@ public:
class InsetWrap : public InsetCollapsable { class InsetWrap : public InsetCollapsable {
public: public:
/// ///
InsetWrap(BufferParams const &, std::string const &); InsetWrap(Buffer const &, std::string const &);
/// ///
~InsetWrap(); ~InsetWrap();
/// ///