From 882e2eeb7bcea230c24eaa69cd6a3e274369adde Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sun, 8 Nov 2009 16:10:34 +0000 Subject: [PATCH] InsetCommand ctor: Pass 'Buffer *' git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31902 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Text3.cpp | 2 +- src/factory.cpp | 40 +++++++++++++++++------------------ src/insets/InsetBibitem.cpp | 3 +-- src/insets/InsetBibtex.cpp | 2 +- src/insets/InsetCitation.cpp | 4 ++-- src/insets/InsetCitation.h | 2 +- src/insets/InsetCommand.cpp | 2 +- src/insets/InsetCommand.h | 5 +++-- src/insets/InsetFloatList.cpp | 8 +++---- src/insets/InsetFloatList.h | 4 ++-- src/insets/InsetHyperlink.cpp | 4 ++-- src/insets/InsetHyperlink.h | 2 +- src/insets/InsetInclude.cpp | 12 +++++------ src/insets/InsetInclude.h | 2 +- src/insets/InsetIndex.cpp | 4 ++-- src/insets/InsetIndex.h | 2 +- src/insets/InsetLabel.cpp | 4 ++-- src/insets/InsetLabel.h | 2 +- src/insets/InsetNomencl.cpp | 8 +++---- src/insets/InsetNomencl.h | 4 ++-- src/insets/InsetRef.cpp | 2 +- src/insets/InsetTOC.cpp | 4 ++-- src/insets/InsetTOC.h | 2 +- src/mathed/InsetMathHull.cpp | 2 +- 24 files changed, 63 insertions(+), 63 deletions(-) diff --git a/src/Text3.cpp b/src/Text3.cpp index 93812f370e..18adc7d431 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -2008,7 +2008,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) setParagraphs(cur, p); // FIXME This should be simplified when InsetFloatList takes a // Buffer in its constructor. - InsetFloatList * ifl = new InsetFloatList(to_utf8(cmd.argument())); + InsetFloatList * ifl = new InsetFloatList(cur.buffer(), to_utf8(cmd.argument())); ifl->setBuffer(bv->buffer()); insertInset(cur, ifl); cur.posForward(); diff --git a/src/factory.cpp b/src/factory.cpp index 5ca2e69272..91bce06e94 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -184,7 +184,7 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd) case LFUN_NOMENCL_INSERT: { InsetCommandParams icp(NOMENCL_CODE); icp["symbol"] = cmd.argument(); - return new InsetNomencl(icp); + return new InsetNomencl(buf, icp); } case LFUN_TABULAR_INSERT: { @@ -206,17 +206,17 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd) case LFUN_INDEX_PRINT: { InsetCommandParams icp(INDEX_PRINT_CODE); icp["type"] = cmd.argument(); - return new InsetPrintIndex(icp); + return new InsetPrintIndex(buf, icp); } case LFUN_NOMENCL_PRINT: { InsetCommandParams icp(NOMENCL_PRINT_CODE); icp["set_width"] = from_ascii("auto"); - return new InsetPrintNomencl(icp); + return new InsetPrintNomencl(buf, icp); } case LFUN_TOC_INSERT: - return new InsetTOC(InsetCommandParams(TOC_CODE)); + return new InsetTOC(buf, InsetCommandParams(TOC_CODE)); case LFUN_INFO_INSERT: { InsetInfo * inset = new InsetInfo(buf, to_utf8(cmd.argument())); @@ -247,7 +247,7 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd) case CITE_CODE: { InsetCommandParams icp(code); InsetCommand::string2params(name, to_utf8(cmd.argument()), icp); - return new InsetCitation(icp); + return new InsetCitation(buf, icp); } case ERT_CODE: { @@ -281,13 +281,13 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd) case HYPERLINK_CODE: { InsetCommandParams icp(code); InsetCommand::string2params(name, to_utf8(cmd.argument()), icp); - return new InsetHyperlink(icp); + return new InsetHyperlink(buf, icp); } case INCLUDE_CODE: { InsetCommandParams icp(code); InsetCommand::string2params(name, to_utf8(cmd.argument()), icp); - return new InsetInclude(icp); + return new InsetInclude(buf, icp); } case INDEX_CODE: { @@ -298,19 +298,19 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd) case INDEX_PRINT_CODE: { InsetCommandParams icp(code); InsetCommand::string2params(name, to_utf8(cmd.argument()), icp); - return new InsetPrintIndex(icp); + return new InsetPrintIndex(buf, icp); } case NOMENCL_CODE: { InsetCommandParams icp(code); InsetCommand::string2params(name, to_utf8(cmd.argument()), icp); - return new InsetNomencl(icp); + return new InsetNomencl(buf, icp); } case LABEL_CODE: { InsetCommandParams icp(code); InsetCommand::string2params(name, to_utf8(cmd.argument()), icp); - return new InsetLabel(icp); + return new InsetLabel(buf, icp); } case REF_CODE: { @@ -328,7 +328,7 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd) case TOC_CODE: { InsetCommandParams icp(code); InsetCommand::string2params(name, to_utf8(cmd.argument()), icp); - return new InsetTOC(icp); + return new InsetTOC(buf, icp); } case VSPACE_CODE: { @@ -482,25 +482,25 @@ Inset * readInset(Lexer & lex, Buffer * buf) inset.reset(new InsetBibtex(buf, inscmd)); break; case CITE_CODE: - inset.reset(new InsetCitation(inscmd)); + inset.reset(new InsetCitation(buf, inscmd)); break; case HYPERLINK_CODE: - inset.reset(new InsetHyperlink(inscmd)); + inset.reset(new InsetHyperlink(buf, inscmd)); break; case INCLUDE_CODE: - inset.reset(new InsetInclude(inscmd)); + inset.reset(new InsetInclude(buf, inscmd)); break; case INDEX_PRINT_CODE: - inset.reset(new InsetPrintIndex(inscmd)); + inset.reset(new InsetPrintIndex(buf, inscmd)); break; case LABEL_CODE: - inset.reset(new InsetLabel(inscmd)); + inset.reset(new InsetLabel(buf, inscmd)); break; case NOMENCL_CODE: - inset.reset(new InsetNomencl(inscmd)); + inset.reset(new InsetNomencl(buf, inscmd)); break; case NOMENCL_PRINT_CODE: - inset.reset(new InsetPrintNomencl(inscmd)); + inset.reset(new InsetPrintNomencl(buf, inscmd)); break; case REF_CODE: if (inscmd["name"].empty() && inscmd["reference"].empty()) @@ -508,7 +508,7 @@ Inset * readInset(Lexer & lex, Buffer * buf) inset.reset(new InsetRef(buf, inscmd)); break; case TOC_CODE: - inset.reset(new InsetTOC(inscmd)); + inset.reset(new InsetTOC(buf, inscmd)); break; case NO_CODE: default: @@ -583,7 +583,7 @@ Inset * readInset(Lexer & lex, Buffer * buf) } else if (tmptok == "Index") { inset.reset(new InsetIndex(buf, InsetIndexParams())); } else if (tmptok == "FloatList") { - inset.reset(new InsetFloatList); + inset.reset(new InsetFloatList(buf)); } else if (tmptok == "Info") { inset.reset(new InsetInfo(buf)); } else { diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index d79cb9b663..0de432b377 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -49,9 +49,8 @@ docstring const key_prefix = from_ascii("key-"); InsetBibitem::InsetBibitem(Buffer * buf, InsetCommandParams const & p) - : InsetCommand(p, "bibitem") + : InsetCommand(buf, p, "bibitem") { - Inset::setBuffer(*buf); buffer_->invalidateBibinfoCache(); if (getParam("key").empty()) setParam("key", key_prefix + convert(++key_counter)); diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index 9a6450f561..e886c221f6 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -52,7 +52,7 @@ namespace os = support::os; InsetBibtex::InsetBibtex(Buffer * buf, InsetCommandParams const & p) - : InsetCommand(p, "bibtex") + : InsetCommand(buf, p, "bibtex") { Inset::setBuffer(const_cast(*buf)); buffer_->invalidateBibinfoCache(); diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp index 3abb9a6b2e..5cc3768ef9 100644 --- a/src/insets/InsetCitation.cpp +++ b/src/insets/InsetCitation.cpp @@ -355,8 +355,8 @@ docstring basicLabel(docstring const & keyList, docstring const & after) ParamInfo InsetCitation::param_info_; -InsetCitation::InsetCitation(InsetCommandParams const & p) - : InsetCommand(p, "citation") +InsetCitation::InsetCitation(Buffer * buf, InsetCommandParams const & p) + : InsetCommand(buf, p, "citation") {} diff --git a/src/insets/InsetCitation.h b/src/insets/InsetCitation.h index caab062659..1ead91b5d0 100644 --- a/src/insets/InsetCitation.h +++ b/src/insets/InsetCitation.h @@ -32,7 +32,7 @@ class InsetCitation : public InsetCommand { public: /// - explicit InsetCitation(InsetCommandParams const &); + explicit InsetCitation(Buffer * buf, InsetCommandParams const &); /// bool isLabeled() const { return true; } /// diff --git a/src/insets/InsetCommand.cpp b/src/insets/InsetCommand.cpp index eeb3582c78..f412985be5 100644 --- a/src/insets/InsetCommand.cpp +++ b/src/insets/InsetCommand.cpp @@ -51,7 +51,7 @@ namespace lyx { // FIXME Would it now be possible to use the InsetCode in // place of the mailer name and recover that information? -InsetCommand::InsetCommand(InsetCommandParams const & p, +InsetCommand::InsetCommand(Buffer *, InsetCommandParams const & p, string const & mailer_name) : Inset(0), p_(p), mailer_name_(mailer_name), diff --git a/src/insets/InsetCommand.h b/src/insets/InsetCommand.h index d62eb31f32..090a85abbb 100644 --- a/src/insets/InsetCommand.h +++ b/src/insets/InsetCommand.h @@ -34,8 +34,9 @@ namespace lyx { class InsetCommand : public Inset { public: - /// FIXME: pass Buffer here! - InsetCommand(InsetCommandParams const &, std::string const & mailer_name); + /// + InsetCommand(Buffer *, InsetCommandParams const &, + std::string const & mailer_name); /// ~InsetCommand(); diff --git a/src/insets/InsetFloatList.cpp b/src/insets/InsetFloatList.cpp index a476e23908..a62d02053b 100644 --- a/src/insets/InsetFloatList.cpp +++ b/src/insets/InsetFloatList.cpp @@ -36,13 +36,13 @@ using namespace lyx::support; namespace lyx { -InsetFloatList::InsetFloatList() - : InsetCommand(InsetCommandParams(FLOAT_LIST_CODE), "toc") +InsetFloatList::InsetFloatList(Buffer * buf) + : InsetCommand(buf, InsetCommandParams(FLOAT_LIST_CODE), "toc") {} -InsetFloatList::InsetFloatList(string const & type) - : InsetCommand(InsetCommandParams(FLOAT_LIST_CODE), "toc") +InsetFloatList::InsetFloatList(Buffer * buf, string const & type) + : InsetCommand(buf, InsetCommandParams(FLOAT_LIST_CODE), "toc") { setParam("type", from_ascii(type)); } diff --git a/src/insets/InsetFloatList.h b/src/insets/InsetFloatList.h index c15f0eb61f..6cb03196f6 100644 --- a/src/insets/InsetFloatList.h +++ b/src/insets/InsetFloatList.h @@ -23,9 +23,9 @@ namespace lyx { class InsetFloatList : public InsetCommand { public: /// - InsetFloatList(); + InsetFloatList(Buffer *); /// - InsetFloatList(std::string const & type); + InsetFloatList(Buffer *, std::string const & type); /// docstring screenLabel() const; /// diff --git a/src/insets/InsetHyperlink.cpp b/src/insets/InsetHyperlink.cpp index aa4ff3af7d..7338141ba8 100644 --- a/src/insets/InsetHyperlink.cpp +++ b/src/insets/InsetHyperlink.cpp @@ -28,8 +28,8 @@ using namespace lyx::support; namespace lyx { -InsetHyperlink::InsetHyperlink(InsetCommandParams const & p) - : InsetCommand(p, "href") +InsetHyperlink::InsetHyperlink(Buffer * buf, InsetCommandParams const & p) + : InsetCommand(buf, p, "href") {} diff --git a/src/insets/InsetHyperlink.h b/src/insets/InsetHyperlink.h index 3835c1755d..bbcd6f9fe7 100644 --- a/src/insets/InsetHyperlink.h +++ b/src/insets/InsetHyperlink.h @@ -23,7 +23,7 @@ class InsetHyperlink : public InsetCommand { public: /// - explicit InsetHyperlink(InsetCommandParams const &); + explicit InsetHyperlink(Buffer * buf, InsetCommandParams const &); /// InsetCode lyxCode() const { return HYPERLINK_CODE; } /// diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 4a41f523a8..2c2b230ba6 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -147,20 +147,20 @@ FileName const includedFilename(Buffer const & buffer, } -InsetLabel * createLabel(docstring const & label_str) +InsetLabel * createLabel(Buffer * buf, docstring const & label_str) { if (label_str.empty()) return 0; InsetCommandParams icp(LABEL_CODE); icp["name"] = label_str; - return new InsetLabel(icp); + return new InsetLabel(buf, icp); } } // namespace anon -InsetInclude::InsetInclude(InsetCommandParams const & p) - : InsetCommand(p, "include"), include_label(uniqueID()), +InsetInclude::InsetInclude(Buffer * buf, InsetCommandParams const & p) + : InsetCommand(buf, p, "include"), include_label(uniqueID()), preview_(new RenderMonitoredPreview(this)), failedtoload_(false), set_label_(false), label_(0), child_buffer_(0) { @@ -168,7 +168,7 @@ InsetInclude::InsetInclude(InsetCommandParams const & p) if (isListings(params())) { InsetListingsParams listing_params(to_utf8(p["lstparams"])); - label_ = createLabel(from_utf8(listing_params.getParamValue("label"))); + label_ = createLabel(buffer_, from_utf8(listing_params.getParamValue("label"))); } } @@ -252,7 +252,7 @@ void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd) if (label_) old_label = label_->getParam("name"); else { - label_ = createLabel(new_label); + label_ = createLabel(buffer_, new_label); label_->setBuffer(buffer()); } diff --git a/src/insets/InsetInclude.h b/src/insets/InsetInclude.h index b302a9e31b..11e5ac2389 100644 --- a/src/insets/InsetInclude.h +++ b/src/insets/InsetInclude.h @@ -36,7 +36,7 @@ class RenderMonitoredPreview; class InsetInclude : public InsetCommand { public: /// - InsetInclude(InsetCommandParams const &); + InsetInclude(Buffer * buf, InsetCommandParams const &); ~InsetInclude(); void setBuffer(Buffer & buffer); diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index 27ed354e41..a3a52f1f23 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -396,8 +396,8 @@ void InsetIndexParams::read(Lexer & lex) // /////////////////////////////////////////////////////////////////////// -InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p) - : InsetCommand(p, "index_print") +InsetPrintIndex::InsetPrintIndex(Buffer * buf, InsetCommandParams const & p) + : InsetCommand(buf, p, "index_print") {} diff --git a/src/insets/InsetIndex.h b/src/insets/InsetIndex.h index 14c77d057c..642d3ee0dc 100644 --- a/src/insets/InsetIndex.h +++ b/src/insets/InsetIndex.h @@ -94,7 +94,7 @@ private: class InsetPrintIndex : public InsetCommand { public: /// - InsetPrintIndex(InsetCommandParams const &); + InsetPrintIndex(Buffer * buf, InsetCommandParams const &); /// InsetCode lyxCode() const { return INDEX_PRINT_CODE; } diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index 8b36e787f7..38e8509a22 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -42,8 +42,8 @@ using namespace lyx::support; namespace lyx { -InsetLabel::InsetLabel(InsetCommandParams const & p) - : InsetCommand(p, "label") +InsetLabel::InsetLabel(Buffer * buf, InsetCommandParams const & p) + : InsetCommand(buf, p, "label") {} diff --git a/src/insets/InsetLabel.h b/src/insets/InsetLabel.h index ac22bfca95..af2b9adb87 100644 --- a/src/insets/InsetLabel.h +++ b/src/insets/InsetLabel.h @@ -20,7 +20,7 @@ namespace lyx { class InsetLabel : public InsetCommand { public: /// - InsetLabel(InsetCommandParams const &); + InsetLabel(Buffer * buf, InsetCommandParams const &); /// verify label and update references. /** diff --git a/src/insets/InsetNomencl.cpp b/src/insets/InsetNomencl.cpp index ca233b972d..7c043fa4c0 100644 --- a/src/insets/InsetNomencl.cpp +++ b/src/insets/InsetNomencl.cpp @@ -46,8 +46,8 @@ namespace lyx { // ///////////////////////////////////////////////////////////////////// -InsetNomencl::InsetNomencl(InsetCommandParams const & p) - : InsetCommand(p, "nomenclature"), +InsetNomencl::InsetNomencl(Buffer * buf, InsetCommandParams const & p) + : InsetCommand(buf, p, "nomenclature"), nomenclature_entry_id(sgml::uniqueID(from_ascii("nomen"))) {} @@ -130,8 +130,8 @@ void InsetNomencl::validate(LaTeXFeatures & features) const // ///////////////////////////////////////////////////////////////////// -InsetPrintNomencl::InsetPrintNomencl(InsetCommandParams const & p) - : InsetCommand(p, "nomencl_print") +InsetPrintNomencl::InsetPrintNomencl(Buffer * buf, InsetCommandParams const & p) + : InsetCommand(buf, p, "nomencl_print") {} diff --git a/src/insets/InsetNomencl.h b/src/insets/InsetNomencl.h index b53984756b..4f8e9d79bc 100644 --- a/src/insets/InsetNomencl.h +++ b/src/insets/InsetNomencl.h @@ -26,7 +26,7 @@ class LaTeXFeatures; class InsetNomencl : public InsetCommand { public: /// - InsetNomencl(InsetCommandParams const &); + InsetNomencl(Buffer * buf, InsetCommandParams const &); /// docstring screenLabel() const; /// @@ -60,7 +60,7 @@ private: class InsetPrintNomencl : public InsetCommand { public: /// - InsetPrintNomencl(InsetCommandParams const &); + InsetPrintNomencl(Buffer * buf, InsetCommandParams const &); /// Updates needed features for this inset. void validate(LaTeXFeatures & features) const; /// diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 20e98dc3d4..e24bd4f012 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -33,7 +33,7 @@ namespace lyx { InsetRef::InsetRef(Buffer * buf, InsetCommandParams const & p) - : InsetCommand(p, "ref"), isLatex(buf->isLatex()) + : InsetCommand(buf, p, "ref"), isLatex(buf->isLatex()) {} diff --git a/src/insets/InsetTOC.cpp b/src/insets/InsetTOC.cpp index 723d539d5b..565fce3d6f 100644 --- a/src/insets/InsetTOC.cpp +++ b/src/insets/InsetTOC.cpp @@ -28,8 +28,8 @@ using namespace std; namespace lyx { -InsetTOC::InsetTOC(InsetCommandParams const & p) - : InsetCommand(p, "toc") +InsetTOC::InsetTOC(Buffer * buf, InsetCommandParams const & p) + : InsetCommand(buf, p, "toc") {} diff --git a/src/insets/InsetTOC.h b/src/insets/InsetTOC.h index b95c9c4ebb..dc65b97ffb 100644 --- a/src/insets/InsetTOC.h +++ b/src/insets/InsetTOC.h @@ -22,7 +22,7 @@ namespace lyx { class InsetTOC : public InsetCommand { public: /// - explicit InsetTOC(InsetCommandParams const &); + InsetTOC(Buffer * buf, InsetCommandParams const &); /// docstring screenLabel() const; /// diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 84f2738341..c1b17b85a1 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -508,7 +508,7 @@ void InsetMathHull::label(row_type row, docstring const & label) } InsetCommandParams p(LABEL_CODE); p["name"] = label; - label_[row] = new InsetLabel(p); + label_[row] = new InsetLabel(buffer_, p); if (buffer_) label_[row]->setBuffer(buffer()); }