From a694476ac68fd56c23eace194e9e6ac5b2a5cac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Tue, 4 Mar 2008 22:28:18 +0000 Subject: [PATCH] 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 --- src/Buffer.cpp | 13 +++--- src/Text2.cpp | 2 +- src/factory.cpp | 76 ++++++++++++++++----------------- src/insets/InsetBox.cpp | 6 +-- src/insets/InsetBox.h | 2 +- src/insets/InsetBranch.cpp | 16 +------ src/insets/InsetBranch.h | 12 +++--- src/insets/InsetCaption.cpp | 9 ++-- src/insets/InsetCaption.h | 2 +- src/insets/InsetCollapsable.cpp | 6 +-- src/insets/InsetCollapsable.h | 2 +- src/insets/InsetERT.cpp | 4 +- src/insets/InsetERT.h | 2 +- src/insets/InsetEnvironment.cpp | 15 +++---- src/insets/InsetEnvironment.h | 4 +- src/insets/InsetFlex.cpp | 10 +---- src/insets/InsetFlex.h | 4 +- src/insets/InsetFloat.cpp | 6 +-- src/insets/InsetFloat.h | 2 +- src/insets/InsetFoot.cpp | 10 +---- src/insets/InsetFoot.h | 4 +- src/insets/InsetFootlike.cpp | 4 +- src/insets/InsetFootlike.h | 2 +- src/insets/InsetIndex.cpp | 4 +- src/insets/InsetIndex.h | 2 +- src/insets/InsetInfo.cpp | 4 +- src/insets/InsetInfo.h | 2 +- src/insets/InsetListings.cpp | 4 +- src/insets/InsetListings.h | 2 +- src/insets/InsetMarginal.cpp | 4 +- src/insets/InsetMarginal.h | 2 +- src/insets/InsetNote.cpp | 4 +- src/insets/InsetNote.h | 2 +- src/insets/InsetOptArg.cpp | 4 +- src/insets/InsetOptArg.h | 2 +- src/insets/InsetQuotes.cpp | 4 +- src/insets/InsetQuotes.h | 2 +- src/insets/InsetRef.cpp | 2 +- src/insets/InsetRef.h | 2 +- src/insets/InsetTabular.cpp | 8 ++-- src/insets/InsetText.cpp | 17 +++++--- src/insets/InsetText.h | 4 +- src/insets/InsetWrap.cpp | 6 +-- src/insets/InsetWrap.h | 2 +- 44 files changed, 137 insertions(+), 159 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index f7f962141e..dc7343677e 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -167,9 +167,6 @@ public: */ bool file_fully_loaded; - /// our Text that should be wrapped in an InsetText - InsetText inset; - /// mutable TocBackend toc_backend; @@ -209,6 +206,9 @@ public: mutable EmbeddedFileList bibfilesCache_; mutable RefCache ref_cache_; + + /// our Text that should be wrapped in an InsetText + InsetText inset; }; /// Creates the per buffer temporary directory @@ -233,13 +233,11 @@ static FileName createBufferTmpDir() Buffer::Impl::Impl(Buffer & parent, FileName const & file, bool readonly_) : parent_buffer(0), lyx_clean(true), bak_clean(true), unnamed(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), undo_(parent) { temppath = createBufferTmpDir(); - inset.setBuffer(parent); - inset.setAutoBreakRows(true); lyxvc.setBuffer(&parent); if (use_gui) wa_ = new frontend::WorkAreaManager; @@ -251,6 +249,9 @@ Buffer::Buffer(string const & file, bool readonly) { 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()); } diff --git a/src/Text2.cpp b/src/Text2.cpp index fa0ed179b3..c8fc4e70bf 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -225,7 +225,7 @@ void Text::setLayout(Cursor & cur, docstring const & layout) lyx::dispatch(FuncRequest(LFUN_LINE_BEGIN)); lyx::dispatch(FuncRequest(LFUN_LINE_END_SELECT)); lyx::dispatch(FuncRequest(LFUN_CUT)); - Inset * inset = new InsetEnvironment(params, layout); + Inset * inset = new InsetEnvironment(bv.buffer(), layout); insertInset(cur, inset); //inset->edit(cur, true); //lyx::dispatch(FuncRequest(LFUN_PASTE)); diff --git a/src/factory.cpp b/src/factory.cpp index fd6c8c1a45..300345d913 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -102,44 +102,44 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) case LFUN_FLEX_INSERT: { string s = cmd.getArg(0); - return new InsetFlex(params, params.documentClassPtr(), s); + return new InsetFlex(buf, buf.params().documentClassPtr(), s); } case LFUN_NOTE_INSERT: { string arg = cmd.getArg(0); if (arg.empty()) arg = "Note"; - return new InsetNote(params, arg); + return new InsetNote(buf, arg); } case LFUN_BOX_INSERT: { string arg = cmd.getArg(0); if (arg.empty()) arg = "Boxed"; - return new InsetBox(params, arg); + return new InsetBox(buf, arg); } case LFUN_BRANCH_INSERT: { docstring arg = cmd.argument(); if (arg.empty()) arg = from_ascii("none"); - return new InsetBranch(params, InsetBranchParams(arg)); + return new InsetBranch(buf, InsetBranchParams(arg)); } case LFUN_ERT_INSERT: - return new InsetERT(params); + return new InsetERT(buf); case LFUN_LISTING_INSERT: - return new InsetListings(params); + return new InsetListings(buf); case LFUN_FOOTNOTE_INSERT: - return new InsetFoot(params); + return new InsetFoot(buf); case LFUN_MARGINALNOTE_INSERT: - return new InsetMarginal(params); + return new InsetMarginal(buf); case LFUN_OPTIONAL_INSERT: - return new InsetOptArg(params); + return new InsetOptArg(buf); case LFUN_BIBITEM_INSERT: return new InsetBibitem(InsetCommandParams(BIBITEM_CODE)); @@ -147,8 +147,8 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) case LFUN_FLOAT_INSERT: { // check if the float type exists string const argument = to_utf8(cmd.argument()); - if (params.documentClass().floats().typeExist(argument)) - return new InsetFloat(params, argument); + if (buf.params().documentClass().floats().typeExist(argument)) + return new InsetFloat(buf, argument); lyxerr << "Non-existent float type: " << argument << endl; } @@ -156,7 +156,7 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) // check if the float type exists string const argument = to_utf8(cmd.argument()); if (params.documentClass().floats().typeExist(argument)) { - auto_ptr p(new InsetFloat(params, argument)); + auto_ptr p(new InsetFloat(buf, argument)); p->wide(true, params); return p.release(); } @@ -167,13 +167,13 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) case LFUN_WRAP_INSERT: { string const argument = to_utf8(cmd.argument()); if (argument == "figure" || argument == "table") - return new InsetWrap(params, argument); + return new InsetWrap(buf, argument); lyxerr << "Non-existent wrapfig type: " << argument << endl; return 0; } case LFUN_INDEX_INSERT: - return new InsetIndex(params); + return new InsetIndex(buf); case LFUN_NOMENCL_INSERT: { InsetCommandParams icp(NOMENCL_CODE); @@ -195,7 +195,7 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) } case LFUN_CAPTION_INSERT: { - auto_ptr inset(new InsetCaption(params)); + auto_ptr inset(new InsetCaption(buf)); inset->setAutoBreakRows(true); inset->setDrawFrame(true); inset->setFrameColor(Color_captionframe); @@ -212,10 +212,10 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) return new InsetTOC(InsetCommandParams(TOC_CODE)); case LFUN_ENVIRONMENT_INSERT: - return new InsetEnvironment(params, cmd.argument()); + return new InsetEnvironment(buf, cmd.argument()); case LFUN_INFO_INSERT: - return new InsetInfo(params, to_utf8(cmd.argument())); + return new InsetInfo(buf, to_utf8(cmd.argument())); #if 0 case LFUN_THEOREM_INSERT: return new InsetTheorem; @@ -250,13 +250,13 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) case ERT_CODE: { InsetCollapsable::CollapseStatus st; InsetERTMailer::string2params(to_utf8(cmd.argument()), st); - return new InsetERT(params, st); + return new InsetERT(buf, st); } case LISTINGS_CODE: { InsetListingsParams par; InsetListingsMailer::string2params(to_utf8(cmd.argument()), par); - return new InsetListings(params, par); + return new InsetListings(buf, par); } case EXTERNAL_CODE: { @@ -288,7 +288,7 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) } case INDEX_CODE: - return new InsetIndex(params); + return new InsetIndex(buf); case NOMENCL_CODE: { InsetCommandParams icp(code); @@ -305,7 +305,7 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) case REF_CODE: { InsetCommandParams icp(code); InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp); - return new InsetRef(icp, buf); + return new InsetRef(buf, icp); } case TOC_CODE: { @@ -446,7 +446,7 @@ Inset * readInset(Lexer & lex, Buffer const & buf) break; case REF_CODE: if (!inscmd["name"].empty() || !inscmd["reference"].empty()) - inset.reset(new InsetRef(inscmd, buf)); + inset.reset(new InsetRef(buf, inscmd)); break; case TOC_CODE: inset.reset(new InsetTOC(inscmd)); @@ -478,58 +478,58 @@ Inset * readInset(Lexer & lex, Buffer const & buf) } else if (tmptok == "Graphics") { inset.reset(new InsetGraphics); } else if (tmptok == "Note") { - inset.reset(new InsetNote(buf.params(), tmptok)); + inset.reset(new InsetNote(buf, tmptok)); } else if (tmptok == "Box") { - inset.reset(new InsetBox(buf.params(), tmptok)); + inset.reset(new InsetBox(buf, tmptok)); } else if (tmptok == "Flex") { lex.next(); string s = lex.getString(); - inset.reset(new InsetFlex(buf.params(), + inset.reset(new InsetFlex(buf, buf.params().documentClassPtr(), s)); } else if (tmptok == "Branch") { - inset.reset(new InsetBranch(buf.params(), + inset.reset(new InsetBranch(buf, InsetBranchParams())); } else if (tmptok == "Environment") { lex.next(); - inset.reset(new InsetEnvironment(buf.params(), lex.getDocString())); + inset.reset(new InsetEnvironment(buf, lex.getDocString())); } else if (tmptok == "ERT") { - inset.reset(new InsetERT(buf.params())); + inset.reset(new InsetERT(buf)); } else if (tmptok == "listings") { - inset.reset(new InsetListings(buf.params())); + inset.reset(new InsetListings(buf)); } else if (tmptok == "InsetSpace") { inset.reset(new InsetSpace); } else if (tmptok == "Tabular") { inset.reset(new InsetTabular(buf)); } else if (tmptok == "Text") { - inset.reset(new InsetText(buf.params())); + inset.reset(new InsetText(buf)); } else if (tmptok == "VSpace") { inset.reset(new InsetVSpace); } else if (tmptok == "Foot") { - inset.reset(new InsetFoot(buf.params())); + inset.reset(new InsetFoot(buf)); } else if (tmptok == "Marginal") { - inset.reset(new InsetMarginal(buf.params())); + inset.reset(new InsetMarginal(buf)); } else if (tmptok == "OptArg") { - inset.reset(new InsetOptArg(buf.params())); + inset.reset(new InsetOptArg(buf)); } else if (tmptok == "Float") { lex.next(); string tmptok = lex.getString(); - inset.reset(new InsetFloat(buf.params(), tmptok)); + inset.reset(new InsetFloat(buf, tmptok)); } else if (tmptok == "Wrap") { lex.next(); string tmptok = lex.getString(); - inset.reset(new InsetWrap(buf.params(), tmptok)); + inset.reset(new InsetWrap(buf, tmptok)); #if 0 } else if (tmptok == "Theorem") { inset.reset(new InsetList); #endif } else if (tmptok == "Caption") { - inset.reset(new InsetCaption(buf.params())); + inset.reset(new InsetCaption(buf)); } else if (tmptok == "Index") { - inset.reset(new InsetIndex(buf.params())); + inset.reset(new InsetIndex(buf)); } else if (tmptok == "FloatList") { inset.reset(new InsetFloatList); } else if (tmptok == "Info") { - inset.reset(new InsetInfo(buf.params())); + inset.reset(new InsetInfo(buf)); } else { lyxerr << "unknown Inset type '" << tmptok << "'" << endl; diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index 9744ccd3f0..44638964f8 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -85,11 +85,11 @@ BoxTranslatorLoc const & boxtranslator_loc() } // anon -InsetBox::InsetBox(BufferParams const & bp, string const & label) - : InsetCollapsable(bp), params_(label) +InsetBox::InsetBox(Buffer const & buffer, string const & label) + : InsetCollapsable(buffer), params_(label) { if (forceEmptyLayout()) - paragraphs().back().setLayout(bp.documentClass().emptyLayout()); + paragraphs().back().setLayout(buffer.params().documentClass().emptyLayout()); } diff --git a/src/insets/InsetBox.h b/src/insets/InsetBox.h index d74c68cc9f..4aa9336c68 100644 --- a/src/insets/InsetBox.h +++ b/src/insets/InsetBox.h @@ -58,7 +58,7 @@ public: class InsetBox : public InsetCollapsable { public: /// - InsetBox(BufferParams const &, std::string const &); + InsetBox(Buffer const &, std::string const &); /// ~InsetBox(); /// diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index 3da72ae1d1..852b04fc0c 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -33,14 +33,8 @@ using namespace std; namespace lyx { -InsetBranch::InsetBranch(BufferParams const & bp, - InsetBranchParams const & params) - : InsetCollapsable(bp), params_(params) -{} - - -InsetBranch::InsetBranch(InsetBranch const & in) - : InsetCollapsable(in), params_(in.params_) +InsetBranch::InsetBranch(Buffer const & buf, InsetBranchParams const & params) + : InsetCollapsable(buf), params_(params) {} @@ -50,12 +44,6 @@ InsetBranch::~InsetBranch() } -Inset * InsetBranch::clone() const -{ - return new InsetBranch(*this); -} - - docstring InsetBranch::editMessage() const { return _("Opened Branch Inset"); diff --git a/src/insets/InsetBranch.h b/src/insets/InsetBranch.h index a214ef9e73..09e9dbc11a 100644 --- a/src/insets/InsetBranch.h +++ b/src/insets/InsetBranch.h @@ -37,7 +37,7 @@ public: class InsetBranch : public InsetCollapsable { public: /// - InsetBranch(BufferParams const &, InsetBranchParams const &); + InsetBranch(Buffer const &, InsetBranchParams const &); /// ~InsetBranch(); /// @@ -83,16 +83,14 @@ public: docstring toolTip(BufferView const & bv, int x, int y) const; protected: /// - InsetBranch(InsetBranch const &); - /// - virtual void doDispatch(Cursor & cur, FuncRequest & cmd); + void doDispatch(Cursor & cur, FuncRequest & cmd); /// docstring name() const { return from_ascii("Branch"); } private: + /// friend class InsetBranchParams; - - virtual Inset * clone() const; - + /// + Inset * clone() const { return new InsetBranch(*this); } /// InsetBranchParams params_; }; diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp index 5c7a9753b8..afdcd8c6e0 100644 --- a/src/insets/InsetCaption.cpp +++ b/src/insets/InsetCaption.cpp @@ -56,15 +56,14 @@ InsetCaption::InsetCaption(InsetCaption const & ic) } -InsetCaption::InsetCaption(BufferParams const & bp) - : InsetText(bp) +InsetCaption::InsetCaption(Buffer const & buf) + : InsetText(buf) { setAutoBreakRows(true); setDrawFrame(true); setFrameColor(Color_captionframe); - //FIXME Do we need to set all paragraphs here? or will there - //always only be one? - paragraphs().back().setLayout(bp.documentClass().emptyLayout()); + // There will always be only one + paragraphs().back().setLayout(buf.params().documentClass().emptyLayout()); } diff --git a/src/insets/InsetCaption.h b/src/insets/InsetCaption.h index cbfba828da..631181b922 100644 --- a/src/insets/InsetCaption.h +++ b/src/insets/InsetCaption.h @@ -22,7 +22,7 @@ class InsetCaption : public InsetText { public: /// InsetCaption(InsetCaption const &); - InsetCaption(BufferParams const &); + InsetCaption(Buffer const &); /// virtual ~InsetCaption() {} /// diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index a0cae01244..7c6d49dc6a 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -77,16 +77,16 @@ InsetCollapsable::Geometry InsetCollapsable::geometry() const } -InsetCollapsable::InsetCollapsable(BufferParams const & bp, +InsetCollapsable::InsetCollapsable(Buffer const & buf, CollapseStatus status, DocumentClass * dc) - : InsetText(bp), status_(status), + : InsetText(buf), status_(status), openinlined_(false), autoOpen_(false), mouse_hover_(false) { setLayout(dc); setAutoBreakRows(true); setDrawFrame(true); setFrameColor(Color_collapsableframe); - paragraphs().back().setLayout(bp.documentClass().emptyLayout()); + paragraphs().back().setLayout(buf.params().documentClass().emptyLayout()); } diff --git a/src/insets/InsetCollapsable.h b/src/insets/InsetCollapsable.h index c137579635..0085431dc9 100644 --- a/src/insets/InsetCollapsable.h +++ b/src/insets/InsetCollapsable.h @@ -38,7 +38,7 @@ namespace frontend { class Painter; } class InsetCollapsable : public InsetText { public: /// - InsetCollapsable(BufferParams const &, + InsetCollapsable(Buffer const &, CollapseStatus status = Inset::Open, DocumentClass * tc = 0); /// InsetCollapsable(InsetCollapsable const & rhs); diff --git a/src/insets/InsetERT.cpp b/src/insets/InsetERT.cpp index 937696f058..e53c90ffb8 100644 --- a/src/insets/InsetERT.cpp +++ b/src/insets/InsetERT.cpp @@ -43,8 +43,8 @@ using namespace lyx::support; namespace lyx { -InsetERT::InsetERT(BufferParams const & bp, CollapseStatus status) - : InsetCollapsable(bp, status) +InsetERT::InsetERT(Buffer const & buf, CollapseStatus status) + : InsetCollapsable(buf, status) {} diff --git a/src/insets/InsetERT.h b/src/insets/InsetERT.h index 176c412fd9..f6a3497f59 100644 --- a/src/insets/InsetERT.h +++ b/src/insets/InsetERT.h @@ -33,7 +33,7 @@ class Language; class InsetERT : public InsetCollapsable { public: /// - InsetERT(BufferParams const &, CollapseStatus status = Open); + InsetERT(Buffer const &, CollapseStatus status = Open); #if 0 /// InsetERT(BufferParams const &, diff --git a/src/insets/InsetEnvironment.cpp b/src/insets/InsetEnvironment.cpp index 69b33e7254..48ee8539aa 100644 --- a/src/insets/InsetEnvironment.cpp +++ b/src/insets/InsetEnvironment.cpp @@ -12,22 +12,23 @@ #include "InsetEnvironment.h" +#include "Buffer.h" #include "BufferParams.h" -#include "support/gettext.h" #include "Layout.h" #include "OutputParams.h" #include "output_latex.h" #include "TexRow.h" #include "TextClass.h" +#include "support/gettext.h" + using namespace std; namespace lyx { -InsetEnvironment::InsetEnvironment - (BufferParams const & bp, docstring const & name) - : InsetText(bp), layout_(bp.documentClass()[name]), name_(name) +InsetEnvironment::InsetEnvironment(Buffer const & buf, docstring const & name) + : InsetText(buf), layout_(buf.params().documentClass()[name]), name_(name) { setAutoBreakRows(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 { os << "Environment " << to_utf8(name()) << "\n"; diff --git a/src/insets/InsetEnvironment.h b/src/insets/InsetEnvironment.h index 46ae2bea8e..c853492a26 100644 --- a/src/insets/InsetEnvironment.h +++ b/src/insets/InsetEnvironment.h @@ -21,7 +21,7 @@ namespace lyx { class InsetEnvironment : public InsetText { public: /// - InsetEnvironment(BufferParams const &, docstring const & name); + InsetEnvironment(Buffer const &, docstring const & name); /// docstring name() const { return name_; } /// @@ -48,7 +48,7 @@ protected: InsetEnvironment(InsetEnvironment const &); private: /// - Inset * clone() const; + Inset * clone() const { return new InsetEnvironment(*this); } /// the layout LayoutPtr layout_; /// diff --git a/src/insets/InsetFlex.cpp b/src/insets/InsetFlex.cpp index 70679bf78d..d61346d342 100644 --- a/src/insets/InsetFlex.cpp +++ b/src/insets/InsetFlex.cpp @@ -39,9 +39,9 @@ using namespace std; namespace lyx { -InsetFlex::InsetFlex(BufferParams const & bp, +InsetFlex::InsetFlex(Buffer const & buf, DocumentClass * dc, string const & layoutName) - : InsetCollapsable(bp, Collapsed, dc), + : InsetCollapsable(buf, Collapsed, dc), name_(layoutName) { 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 { return _("Opened Flex Inset"); diff --git a/src/insets/InsetFlex.h b/src/insets/InsetFlex.h index 4250617eb4..eb827f8bd7 100644 --- a/src/insets/InsetFlex.h +++ b/src/insets/InsetFlex.h @@ -23,7 +23,7 @@ namespace lyx { class InsetFlex : public InsetCollapsable { public: /// - InsetFlex(BufferParams const &, DocumentClass * dc, + InsetFlex(Buffer const &, DocumentClass * dc, std::string const & layoutName); /// docstring name() const { return from_utf8(name_); } @@ -55,7 +55,7 @@ protected: InsetFlex(InsetFlex const &); private: - virtual Inset * clone() const; + Inset * clone() const { return new InsetFlex(*this); } /// std::string name_; diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index 370a29d16d..7c44325ebf 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -111,10 +111,10 @@ namespace lyx { // Lgb -InsetFloat::InsetFloat(BufferParams const & bp, string const & type) - : InsetCollapsable(bp), name_(from_utf8(type)) +InsetFloat::InsetFloat(Buffer const & buf, string const & type) + : InsetCollapsable(buf), name_(from_utf8(type)) { - setLabel(_("float: ") + floatName(type, bp)); + setLabel(_("float: ") + floatName(type, buf.params())); params_.type = type; } diff --git a/src/insets/InsetFloat.h b/src/insets/InsetFloat.h index cf50e2a53c..34c5a28020 100644 --- a/src/insets/InsetFloat.h +++ b/src/insets/InsetFloat.h @@ -47,7 +47,7 @@ public: class InsetFloat : public InsetCollapsable { public: /// - InsetFloat(BufferParams const &, std::string const &); + InsetFloat(Buffer const &, std::string const &); /// ~InsetFloat(); /// diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp index 5a97a3c8df..98ab7bcd99 100644 --- a/src/insets/InsetFoot.cpp +++ b/src/insets/InsetFoot.cpp @@ -35,8 +35,8 @@ using namespace std; namespace lyx { -InsetFoot::InsetFoot(BufferParams const & bp) - : InsetFootlike(bp) +InsetFoot::InsetFoot(Buffer const & buf) + : InsetFootlike(buf) {} @@ -45,12 +45,6 @@ InsetFoot::InsetFoot(InsetFoot const & in) {} -Inset * InsetFoot::clone() const -{ - return new InsetFoot(*this); -} - - docstring InsetFoot::editMessage() const { return _("Opened Footnote Inset"); diff --git a/src/insets/InsetFoot.h b/src/insets/InsetFoot.h index 36c20c1aeb..6514d13363 100644 --- a/src/insets/InsetFoot.h +++ b/src/insets/InsetFoot.h @@ -24,7 +24,7 @@ namespace lyx { class InsetFoot : public InsetFootlike { public: /// - InsetFoot(BufferParams const &); + InsetFoot(Buffer const &); /// InsetCode lyxCode() const { return FOOT_CODE; } /// @@ -45,7 +45,7 @@ public: protected: InsetFoot(InsetFoot const &); private: - Inset * clone() const; + Inset * clone() const { return new InsetFoot(*this); } }; diff --git a/src/insets/InsetFootlike.cpp b/src/insets/InsetFootlike.cpp index 872c8b19ee..ce82e6461a 100644 --- a/src/insets/InsetFootlike.cpp +++ b/src/insets/InsetFootlike.cpp @@ -24,8 +24,8 @@ using namespace std; namespace lyx { -InsetFootlike::InsetFootlike(BufferParams const & bp) - : InsetCollapsable(bp) +InsetFootlike::InsetFootlike(Buffer const & buf) + : InsetCollapsable(buf) {} diff --git a/src/insets/InsetFootlike.h b/src/insets/InsetFootlike.h index 217b1f2025..0283e06461 100644 --- a/src/insets/InsetFootlike.h +++ b/src/insets/InsetFootlike.h @@ -23,7 +23,7 @@ namespace lyx { class InsetFootlike : public InsetCollapsable { public: /// - InsetFootlike(BufferParams const &); + InsetFootlike(Buffer const &); /// InsetFootlike(InsetFootlike const &); /// diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index 0effcfc7d3..7489f7ce90 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -29,8 +29,8 @@ using namespace std; namespace lyx { -InsetIndex::InsetIndex(BufferParams const & bp) - : InsetCollapsable(bp) +InsetIndex::InsetIndex(Buffer const & buf) + : InsetCollapsable(buf) {} diff --git a/src/insets/InsetIndex.h b/src/insets/InsetIndex.h index 4f7fb9130d..d25657e674 100644 --- a/src/insets/InsetIndex.h +++ b/src/insets/InsetIndex.h @@ -26,7 +26,7 @@ class LaTeXFeatures; class InsetIndex : public InsetCollapsable { public: /// - InsetIndex(BufferParams const &); + InsetIndex(Buffer const &); /// InsetIndex(InsetIndex const &); /// diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp index 44d3b5e0a7..dd4afdeafb 100644 --- a/src/insets/InsetInfo.cpp +++ b/src/insets/InsetInfo.cpp @@ -44,8 +44,8 @@ using namespace lyx::support; namespace lyx { -InsetInfo::InsetInfo(BufferParams const & bp, string const & name) - : InsetText(bp), type_(UNKNOWN_INFO), name_(), +InsetInfo::InsetInfo(Buffer const & buf, string const & name) + : InsetText(buf), type_(UNKNOWN_INFO), name_(), mouse_hover_(false) { setAutoBreakRows(true); diff --git a/src/insets/InsetInfo.h b/src/insets/InsetInfo.h index 6b62e44386..9a82e13d72 100644 --- a/src/insets/InsetInfo.h +++ b/src/insets/InsetInfo.h @@ -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); /// diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index c4497ded2f..0b63ec28e6 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -41,8 +41,8 @@ namespace lyx { char const lstinline_delimiters[] = "!*()-=+|;:'\"`,<.>/?QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm"; -InsetListings::InsetListings(BufferParams const & bp, InsetListingsParams const & par) - : InsetCollapsable(bp, par.status()) +InsetListings::InsetListings(Buffer const & buf, InsetListingsParams const & par) + : InsetCollapsable(buf, par.status()) {} diff --git a/src/insets/InsetListings.h b/src/insets/InsetListings.h index c761c4c6f8..0e4482bc28 100644 --- a/src/insets/InsetListings.h +++ b/src/insets/InsetListings.h @@ -27,7 +27,7 @@ namespace lyx { class InsetListings : public InsetCollapsable { public: /// - InsetListings(BufferParams const &, InsetListingsParams const & par = InsetListingsParams()); + InsetListings(Buffer const &, InsetListingsParams const & par = InsetListingsParams()); /// ~InsetListings(); /// diff --git a/src/insets/InsetMarginal.cpp b/src/insets/InsetMarginal.cpp index d96653ca2b..820abddc9c 100644 --- a/src/insets/InsetMarginal.cpp +++ b/src/insets/InsetMarginal.cpp @@ -25,8 +25,8 @@ namespace lyx { -InsetMarginal::InsetMarginal(BufferParams const & bp) - : InsetFootlike(bp) +InsetMarginal::InsetMarginal(Buffer const & buf) + : InsetFootlike(buf) {} diff --git a/src/insets/InsetMarginal.h b/src/insets/InsetMarginal.h index 19a8c07928..ee249f3361 100644 --- a/src/insets/InsetMarginal.h +++ b/src/insets/InsetMarginal.h @@ -25,7 +25,7 @@ namespace lyx { class InsetMarginal : public InsetFootlike { public: /// - InsetMarginal(BufferParams const &); + InsetMarginal(Buffer const &); /// InsetCode lyxCode() const { return MARGIN_CODE; } /// diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index 4c11a1e89e..9ffd68e8d4 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -106,8 +106,8 @@ void InsetNoteParams::read(Lexer & lex) } -InsetNote::InsetNote(BufferParams const & bp, string const & label) - : InsetCollapsable(bp) +InsetNote::InsetNote(Buffer const & buf, string const & label) + : InsetCollapsable(buf) { params_.type = notetranslator().find(label); } diff --git a/src/insets/InsetNote.h b/src/insets/InsetNote.h index 65cc2ce2ee..050ee435b9 100644 --- a/src/insets/InsetNote.h +++ b/src/insets/InsetNote.h @@ -42,7 +42,7 @@ public: class InsetNote : public InsetCollapsable { public: /// - InsetNote(BufferParams const &, std::string const &); + InsetNote(Buffer const &, std::string const &); /// ~InsetNote(); /// diff --git a/src/insets/InsetOptArg.cpp b/src/insets/InsetOptArg.cpp index d05902bfaf..03d1da6206 100644 --- a/src/insets/InsetOptArg.cpp +++ b/src/insets/InsetOptArg.cpp @@ -21,8 +21,8 @@ using namespace std; namespace lyx { -InsetOptArg::InsetOptArg(BufferParams const & ins) - : InsetCollapsable(ins) +InsetOptArg::InsetOptArg(Buffer const & buf) + : InsetCollapsable(buf) {} diff --git a/src/insets/InsetOptArg.h b/src/insets/InsetOptArg.h index 38e92d9f3d..ebf52a86e3 100644 --- a/src/insets/InsetOptArg.h +++ b/src/insets/InsetOptArg.h @@ -25,7 +25,7 @@ namespace lyx { */ class InsetOptArg : public InsetCollapsable { public: - InsetOptArg(BufferParams const &); + InsetOptArg(Buffer const &); /// code of the inset InsetCode lyxCode() const { return OPTARG_CODE; } diff --git a/src/insets/InsetQuotes.cpp b/src/insets/InsetQuotes.cpp index 35c1358e50..96a6047d80 100644 --- a/src/insets/InsetQuotes.cpp +++ b/src/insets/InsetQuotes.cpp @@ -94,8 +94,8 @@ InsetQuotes::InsetQuotes(quote_language l, quote_side s, quote_times t) } -InsetQuotes::InsetQuotes(char_type c, BufferParams const & params) - : language_(params.quotes_language), times_(params.quotes_times) +InsetQuotes::InsetQuotes(Buffer const & buf, char_type c) + : language_(buf.params().quotes_language), times_(buf.params().quotes_times) { getPosition(c); } diff --git a/src/insets/InsetQuotes.h b/src/insets/InsetQuotes.h index 55bd794f18..b4cbcc290f 100644 --- a/src/insets/InsetQuotes.h +++ b/src/insets/InsetQuotes.h @@ -69,7 +69,7 @@ public: */ explicit InsetQuotes(std::string const & str = "eld"); /// 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 InsetQuotes(char_type c, quote_language l, quote_times t); /// diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 0b36a7f7c7..c2c3358ddd 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -33,7 +33,7 @@ using namespace std; namespace lyx { -InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf) +InsetRef::InsetRef(Buffer const & buf, InsetCommandParams const & p) : InsetCommand(p, "ref"), isLatex(buf.isLatex()) {} diff --git a/src/insets/InsetRef.h b/src/insets/InsetRef.h index 9ba7895d86..9bb4521aa2 100644 --- a/src/insets/InsetRef.h +++ b/src/insets/InsetRef.h @@ -36,7 +36,7 @@ public: static std::string const & getName(int type); - InsetRef(InsetCommandParams const &, Buffer const &); + InsetRef(Buffer const & buffer, InsetCommandParams const &); /// verify label and reference. /** diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 20dbba81d9..cf3d046f48 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -472,7 +472,7 @@ string const featureAsString(Tabular::Feature feature) ///////////////////////////////////////////////////////////////////// -Tabular::CellData::CellData(Buffer const & buffer) +Tabular::CellData::CellData(Buffer const & buf) : cellno(0), width(0), multicolumn(Tabular::CELL_NORMAL), @@ -484,10 +484,10 @@ Tabular::CellData::CellData(Buffer const & buffer) right_line(false), usebox(BOX_NONE), rotate(false), - inset(new InsetText(buffer.params())) + inset(new InsetText(buf)) { - inset->setBuffer(const_cast(buffer)); - inset->paragraphs().back().setLayout(buffer.params().documentClass().emptyLayout()); + inset->setBuffer(const_cast(buf)); + inset->paragraphs().back().setLayout(buf.params().documentClass().emptyLayout()); } diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 9d188de26d..45eb41688e 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -98,13 +98,10 @@ private: ///////////////////////////////////////////////////////////////////// -InsetText::InsetText(BufferParams const & bp) +InsetText::InsetText(Buffer const & buf) : drawFrame_(false), frame_color_(Color_insetframe) { - paragraphs().push_back(Paragraph()); - Paragraph & ourpar = paragraphs().back(); - ourpar.setEmptyOrDefaultLayout(bp.documentClass()); - ourpar.setInsetOwner(this); + initParagraphs(buf); } @@ -123,6 +120,16 @@ InsetText::InsetText() {} +void InsetText::initParagraphs(Buffer const & buf) +{ + BOOST_ASSERT(paragraphs().empty()); + buffer_ = const_cast(&buf); + paragraphs().push_back(Paragraph()); + Paragraph & ourpar = paragraphs().back(); + ourpar.setEmptyOrDefaultLayout(buf.params().documentClass()); + ourpar.setInsetOwner(this); +} + void InsetText::setParagraphOwner() { for_each(paragraphs().begin(), paragraphs().end(), diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index e9f7c6b7c5..9c9165e951 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -34,11 +34,13 @@ class InsetTabular; class InsetText : public Inset { public: /// - explicit InsetText(BufferParams const &); + explicit InsetText(Buffer const & buffer); /// InsetText(); /// InsetText(InsetText const &); + /// + void initParagraphs(Buffer const & buffer); /// Dimension const dimension(BufferView const &) const; diff --git a/src/insets/InsetWrap.cpp b/src/insets/InsetWrap.cpp index 0b0ab1f388..152146ac54 100644 --- a/src/insets/InsetWrap.cpp +++ b/src/insets/InsetWrap.cpp @@ -39,10 +39,10 @@ using namespace std; namespace lyx { -InsetWrap::InsetWrap(BufferParams const & bp, string const & type) - : InsetCollapsable(bp), name_(from_utf8(type)) +InsetWrap::InsetWrap(Buffer const & buf, string const & type) + : InsetCollapsable(buf), name_(from_utf8(type)) { - setLabel(_("wrap: ") + floatName(type, bp)); + setLabel(_("wrap: ") + floatName(type, buf.params())); params_.type = type; params_.lines = 0; params_.placement = "o"; diff --git a/src/insets/InsetWrap.h b/src/insets/InsetWrap.h index 789774241d..9bf5a551c3 100644 --- a/src/insets/InsetWrap.h +++ b/src/insets/InsetWrap.h @@ -45,7 +45,7 @@ public: class InsetWrap : public InsetCollapsable { public: /// - InsetWrap(BufferParams const &, std::string const &); + InsetWrap(Buffer const &, std::string const &); /// ~InsetWrap(); ///