From: Jürgen Vigna Date: Tue, 10 Oct 2000 11:50:43 +0000 (+0000) Subject: Inset patch from Angus. X-Git-Tag: 1.6.10~21925 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=71f8ac34a96741c40c876c66ae199f9677559a5c;p=features.git Inset patch from Angus. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1095 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/ChangeLog b/ChangeLog index 254b6f1666..dbb2a87832 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,33 @@ +2000-10-10 Angus Leeming + + * src/BufferView_pimpl.C (buffer): cleaned up a little. + + * src/insets/figinset.[Ch]: + * src/insets/insetinclude.[Ch]: + * src/insets/insetinclude.[Ch]: + * src/insets/insetparent.[Ch]: + * src/insets/insetref.[Ch]: + * src/insets/insettabular.[Ch] (c-tor): Buffer passed as const &. + + * src/insets/*.[Ch]: + * src/mathed/formula.[Ch]: + * src/mathed/formulamacro.C (Clone): passed Buffer const &. + + * src/buffer.C (parseSingleLyXformat2Token, readInset): + * src/lyx_cb.C (FigureApplyCB): + * src/lyxfunc.C (getStatus, Dispatch): + * src/frontends/xforms/FormTabular.C: use modified c-tors to some + insets. + + * src/lyxfunc.C (Dispatch): string "ref" not used. Removed. + + * src/converter.[Ch] (Formats::View): + * src/lyx_cb.[Ch] (ShowMessage): constify Buffer * parameter. + + * src/paragraph.C (CopyIntoMinibuffer, Clone): Insets::Clone() passed + *current_view->buffer(). This will change later, but this patch is way + big enough already! + 2000-10-09 Juergen Vigna * src/text.C (GetRow): small fix. diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 85886425b5..e87f4b499d 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -161,12 +161,17 @@ void BufferView::Pimpl::buffer(Buffer * b) bv_->text->first = screen_->TopCursorVisible(bv_->text); owner_->updateMenubar(); owner_->updateToolbar(); + // Similarly, buffer-dependent dialogs should be updated or + // hidden. This should go here because some dialogs (eg ToC) + // require bv_->text. + owner_->getDialogs()->updateBufferDependent(); redraw(); bv_->insetWakeup(); } else { lyxerr[Debug::INFO] << " No Buffer!" << endl; owner_->updateMenubar(); owner_->updateToolbar(); + owner_->getDialogs()->hideBufferDependent(); updateScrollbar(); workarea_->redraw(); @@ -181,15 +186,6 @@ void BufferView::Pimpl::buffer(Buffer * b) owner_->updateLayoutChoice(); owner_->getMiniBuffer()->Init(); owner_->updateWindowTitle(); - // Similarly, buffer-dependent dialogs should be updated or hidden. - // This should go here because some dialogs (ToC) require bv_->text. - if (buffer_) owner_->getDialogs()->updateBufferDependent(); -#ifdef WITH_WARNINGS -#warning Is this the right place for this? -// What was wrong with where it used to be in the previous if(buffer_) above? -// There also used to be a hideBufferDependent somewhere here but I haven't -// time at present to check. This should at least fix the segfault. -#endif } diff --git a/src/buffer.C b/src/buffer.C index d2fd0ec56d..742c469386 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -882,7 +882,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, par->InsertChar(pos, LyXParagraph::META_NEWLINE, font); ++pos; } else if (token == "\\LyXTable") { - Inset * inset = new InsetTabular(this); + Inset * inset = new InsetTabular(*this); inset->Read(this, lex); par->InsertInset(pos, inset, font); ++pos; @@ -960,7 +960,7 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par, } else if (inscmd.getCmdName() == "index") { inset = new InsetIndex(inscmd); } else if (inscmd.getCmdName() == "include") { - inset = new InsetInclude(inscmd, this); + inset = new InsetInclude(inscmd, *this); } else if (inscmd.getCmdName() == "label") { inset = new InsetLabel(inscmd); } else if (inscmd.getCmdName() == "url" @@ -973,7 +973,7 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par, || inscmd.getCmdName() == "prettyref") { if (!inscmd.getOptions().empty() || !inscmd.getContents().empty()) { - inset = new InsetRef(inscmd); + inset = new InsetRef(inscmd, *this); } } else if (inscmd.getCmdName() == "tableofcontents" || inscmd.getCmdName() == "listofalgorithms" @@ -983,7 +983,7 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par, } else if (inscmd.getCmdName() == "printindex") { inset = new InsetPrintIndex(inscmd); } else if (inscmd.getCmdName() == "lyxparent") { - inset = new InsetParent(inscmd, this); + inset = new InsetParent(inscmd, *this); } } else { if (tmptok == "Quotes") { @@ -995,16 +995,16 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par, } else if (tmptok == "Formula") { inset = new InsetFormula; } else if (tmptok == "Figure") { - inset = new InsetFig(100, 100, this); + inset = new InsetFig(100, 100, *this); } else if (tmptok == "Info") { inset = new InsetInfo; } else if (tmptok == "Include") { InsetCommandParams p( "Include" ); - inset = new InsetInclude(p, this); + inset = new InsetInclude(p, *this); } else if (tmptok == "ERT") { inset = new InsetERT; } else if (tmptok == "Tabular") { - inset = new InsetTabular(this); + inset = new InsetTabular(*this); } else if (tmptok == "Text") { inset = new InsetText; } else if (tmptok == "Foot") { diff --git a/src/converter.C b/src/converter.C index 13d8e2e468..b778351703 100644 --- a/src/converter.C +++ b/src/converter.C @@ -98,7 +98,7 @@ void Formats::SetViewer(string const & name, string const & command) } -bool Formats::View(Buffer * buffer, string const & filename) +bool Formats::View(Buffer const * buffer, string const & filename) { if (filename.empty()) return false; diff --git a/src/converter.h b/src/converter.h index 757fe944d9..92eb41e01f 100644 --- a/src/converter.h +++ b/src/converter.h @@ -81,7 +81,7 @@ public: void SetViewer(string const & name, string const & command); /// static - bool View(Buffer * buffer, string const & filename); + bool View(Buffer const * buffer, string const & filename); /// static Format * GetFormat(string const & name); diff --git a/src/frontends/xforms/FormTabular.C b/src/frontends/xforms/FormTabular.C index 2e05c2ad85..4b7a492275 100644 --- a/src/frontends/xforms/FormTabular.C +++ b/src/frontends/xforms/FormTabular.C @@ -707,7 +707,7 @@ void FormTabular::apply_create() // comm->setMinibuffer(_("Inserting tabular inset...")); ysize = int(fl_get_slider_value(create_tabular_->slider_columns) + 0.5); xsize = int(fl_get_slider_value(create_tabular_->slider_rows) + 0.5); - InsetTabular * in = new InsetTabular(lv_->buffer(),xsize,ysize); + InsetTabular * in = new InsetTabular(*lv_->buffer(),xsize,ysize); if (!lv_->view()->open_new_inset(in)) { delete in; } diff --git a/src/insets/figinset.C b/src/insets/figinset.C index b0bfa738fd..490a520fad 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -926,8 +926,8 @@ void UnregisterFigure(InsetFig * fi) } -InsetFig::InsetFig(int tmpx, int tmpy, Buffer * o) - : owner(o) +InsetFig::InsetFig(int tmpx, int tmpy, Buffer const & o) + : owner(&o) { wid = tmpx; hgh = tmpy; @@ -1220,13 +1220,13 @@ void InsetFig::Edit(BufferView * bv, int, int, unsigned int) } -Inset * InsetFig::Clone() const +Inset * InsetFig::Clone(Buffer const & buffer) const { - InsetFig * tmp = new InsetFig(100, 100, owner); + InsetFig * tmp = new InsetFig(100, 100, buffer); if (lyxerr.debugging()) { lyxerr << "Clone Figure: buffer:[" - << current_view->buffer() + << &buffer << "], cbuffer:[xx]" << endl; } diff --git a/src/insets/figinset.h b/src/insets/figinset.h index 58afd4ebe6..421a0da786 100644 --- a/src/insets/figinset.h +++ b/src/insets/figinset.h @@ -20,7 +20,7 @@ struct Figref; class InsetFig: public Inset { public: /// - InsetFig(int tmpx, int tmpy, Buffer *); + InsetFig(int tmpx, int tmpy, Buffer const &); /// ~InsetFig(); /// @@ -58,7 +58,7 @@ public: /// Inset::Code LyxCode() const; /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// void CallbackFig(long arg); /// @@ -134,7 +134,7 @@ public: private: /// - Buffer * owner; + Buffer const * owner; /// restore values on the form void RestoreForm(); /// recompute screen params diff --git a/src/insets/insetbib.C b/src/insets/insetbib.C index 7a586aabf2..330c453e34 100644 --- a/src/insets/insetbib.C +++ b/src/insets/insetbib.C @@ -87,7 +87,7 @@ InsetBibKey::~InsetBibKey() } -Inset * InsetBibKey::Clone() const +Inset * InsetBibKey::Clone(Buffer const &) const { InsetBibKey * b = new InsetBibKey(params()); b->setCounter(counter); diff --git a/src/insets/insetbib.h b/src/insets/insetbib.h index 05f257bd3e..3c02c7618d 100644 --- a/src/insets/insetbib.h +++ b/src/insets/insetbib.h @@ -34,7 +34,7 @@ public: /// ~InsetBibKey(); /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /** Currently \bibitem is used as a LyX2.x command, so we need this method. */ @@ -82,7 +82,9 @@ public: /// ~InsetBibtex(); /// - Inset * Clone() const { return new InsetBibtex(params()); } + Inset * Clone(Buffer const &) const { + return new InsetBibtex(params()); + } /// string const getScreenLabel() const; /// diff --git a/src/insets/insetcite.h b/src/insets/insetcite.h index 43d3c21a27..8fa126caa5 100644 --- a/src/insets/insetcite.h +++ b/src/insets/insetcite.h @@ -24,7 +24,9 @@ public: /// InsetCitation(InsetCommandParams const &); /// - Inset * Clone() const { return new InsetCitation(params()); } + Inset * Clone(Buffer const &) const { + return new InsetCitation(params()); + } /// string const getScreenLabel() const; /// diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 345cd2b42d..2870b5d3bd 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -49,7 +49,7 @@ InsetCollapsable::InsetCollapsable() } -Inset * InsetCollapsable::Clone() const +Inset * InsetCollapsable::Clone(Buffer const &) const { InsetCollapsable * result = new InsetCollapsable(); result->inset->init(inset); diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 907d7b0ea7..87b89ffbe9 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -43,7 +43,7 @@ public: /// InsetCollapsable(); /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// void Read(Buffer const *, LyXLex &); /// diff --git a/src/insets/inseterror.h b/src/insets/inseterror.h index d2b79d33cb..5ed89186b3 100644 --- a/src/insets/inseterror.h +++ b/src/insets/inseterror.h @@ -65,7 +65,7 @@ public: /// EDITABLE Editable() const { return IS_EDITABLE; } /// - Inset * Clone() const { return new InsetError(contents); } + Inset * Clone(Buffer const &) const { return new InsetError(contents); } /// Inset::Code LyxCode() const { return Inset::NO_CODE; } /// We don't want "begin" and "end inset" in lyx-file diff --git a/src/insets/insetert.C b/src/insets/insetert.C index f90eaba32f..b418849888 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -44,7 +44,7 @@ void InsetERT::Write(Buffer const * buf, ostream & os) const } -Inset * InsetERT::Clone() const +Inset * InsetERT::Clone(Buffer const &) const { InsetERT * result = new InsetERT; result->inset->init(inset); diff --git a/src/insets/insetert.h b/src/insets/insetert.h index 0ba3405cb3..d50f1e244f 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -32,7 +32,7 @@ public: /// void Write(Buffer const * buf, std::ostream & os) const; /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// string const EditMessage() const; /// diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index a60d7facac..ad95586f74 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -392,7 +392,7 @@ void InsetExternal::Validate(LaTeXFeatures & features) const } -Inset * InsetExternal::Clone() const +Inset * InsetExternal::Clone(Buffer const &) const { InsetExternal * inset = new InsetExternal(); inset->templatename = templatename; diff --git a/src/insets/insetexternal.h b/src/insets/insetexternal.h index 6162638a5e..ae5568b88e 100644 --- a/src/insets/insetexternal.h +++ b/src/insets/insetexternal.h @@ -59,7 +59,7 @@ public: virtual Inset::Code LyxCode() const { return EXTERNAL_CODE; } /// - virtual Inset * Clone() const; + virtual Inset * Clone(Buffer const &) const; /// returns the text of the button virtual string const getScreenLabel() const; diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index 507ec59681..b477714924 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -135,7 +135,7 @@ void InsetFloat::Validate(LaTeXFeatures & features) const } -Inset * InsetFloat::Clone() const +Inset * InsetFloat::Clone(Buffer const &) const { InsetFloat * result = new InsetFloat(floatType); result->inset->init(inset); diff --git a/src/insets/insetfloat.h b/src/insets/insetfloat.h index 821fd7409f..6f28d4caed 100644 --- a/src/insets/insetfloat.h +++ b/src/insets/insetfloat.h @@ -34,7 +34,7 @@ public: /// void Validate(LaTeXFeatures & features) const; /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// Inset::Code LyxCode() const { return Inset::FLOAT_CODE; } /// diff --git a/src/insets/insetfoot.C b/src/insets/insetfoot.C index 03f3fae714..396c10330e 100644 --- a/src/insets/insetfoot.C +++ b/src/insets/insetfoot.C @@ -34,7 +34,7 @@ InsetFoot::InsetFoot() } -Inset * InsetFoot::Clone() const +Inset * InsetFoot::Clone(Buffer const &) const { InsetFoot * result = new InsetFoot; result->inset->init(inset); diff --git a/src/insets/insetfoot.h b/src/insets/insetfoot.h index 8c83d5a65c..26b7f2f7fa 100644 --- a/src/insets/insetfoot.h +++ b/src/insets/insetfoot.h @@ -28,7 +28,7 @@ public: /// InsetFoot(); /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// Inset::Code LyxCode() const { return Inset::FOOT_CODE; } /// diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 4435b3f461..af5035b804 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -663,7 +663,7 @@ InsetGraphicsParams InsetGraphics::getParams() const return params; } -Inset * InsetGraphics::Clone() const +Inset * InsetGraphics::Clone(Buffer const &) const { InsetGraphics * newInset = new InsetGraphics; diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index 72e9cafef0..ead8ed152c 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -86,7 +86,7 @@ public: Inset::Code LyxCode() const { return Inset::GRAPHICS_CODE; } /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /** Set the inset parameters, used by the GUIndependent dialog. Return true of new params are different from what was so far. diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 087d9a2104..8153c087cc 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -203,8 +203,8 @@ string unique_id() { } -InsetInclude::InsetInclude(InsetCommandParams const & p, Buffer * bf) - : InsetCommand(p), master(bf) +InsetInclude::InsetInclude(InsetCommandParams const & p, Buffer const & bf) + : InsetCommand(p), master(&bf) { flag = InsetInclude::INCLUDE; noload = false; @@ -229,9 +229,9 @@ InsetInclude::~InsetInclude() } -Inset * InsetInclude::Clone() const +Inset * InsetInclude::Clone(Buffer const & buffer) const { - InsetInclude * ii = new InsetInclude (params(), master); + InsetInclude * ii = new InsetInclude (params(), buffer); ii->setNoLoad(isNoLoad()); // By default, the newly created inset is of `include' type, // so we do not test this case. diff --git a/src/insets/insetinclude.h b/src/insets/insetinclude.h index a4a24d141b..a6d8c78b7c 100644 --- a/src/insets/insetinclude.h +++ b/src/insets/insetinclude.h @@ -27,11 +27,11 @@ struct LaTeXFeatures; class InsetInclude: public InsetCommand { public: /// - InsetInclude(InsetCommandParams const &, Buffer *); + InsetInclude(InsetCommandParams const &, Buffer const &); /// ~InsetInclude(); /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// Inset::Code LyxCode() const { return Inset::INCLUDE_CODE; } /// This returns the list of labels on the child buffer @@ -114,7 +114,7 @@ private: /// int flag; /// - Buffer * master; + Buffer const * master; /// string include_label; }; diff --git a/src/insets/insetindex.h b/src/insets/insetindex.h index 7d0120ab4f..686a8c0588 100644 --- a/src/insets/insetindex.h +++ b/src/insets/insetindex.h @@ -27,7 +27,9 @@ public: /// InsetIndex(InsetCommandParams const &); /// - Inset * Clone() const { return new InsetIndex(params());} + Inset * Clone(Buffer const &) const { + return new InsetIndex(params()); + } /// string const getScreenLabel() const; /// @@ -42,7 +44,9 @@ public: /// InsetPrintIndex(InsetCommandParams const &); /// - Inset * Clone() const { return new InsetPrintIndex(params());} + Inset * Clone(Buffer const &) const { + return new InsetPrintIndex(params()); + } /// Updates needed features for this inset. void Validate(LaTeXFeatures & features) const; /// diff --git a/src/insets/insetinfo.C b/src/insets/insetinfo.C index ae77a9b5ce..f0d355a13f 100644 --- a/src/insets/insetinfo.C +++ b/src/insets/insetinfo.C @@ -237,7 +237,7 @@ void InsetInfo::Edit(BufferView *bv, int, int, unsigned int) } -Inset * InsetInfo::Clone() const +Inset * InsetInfo::Clone(Buffer const &) const { return new InsetInfo(contents); } diff --git a/src/insets/insetinfo.h b/src/insets/insetinfo.h index 08f1ebc95a..6312551c7c 100644 --- a/src/insets/insetinfo.h +++ b/src/insets/insetinfo.h @@ -67,7 +67,7 @@ public: /// Inset::Code LyxCode() const; /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// static void CloseInfoCB(FL_OBJECT *, long data); private: diff --git a/src/insets/insetlabel.h b/src/insets/insetlabel.h index 38b7c534b4..87211ae6fe 100644 --- a/src/insets/insetlabel.h +++ b/src/insets/insetlabel.h @@ -23,7 +23,7 @@ public: /// InsetLabel(InsetCommandParams const &); /// - Inset * Clone() const { return new InsetLabel(params()); } + Inset * Clone(Buffer const &) const { return new InsetLabel(params()); } /// string const getScreenLabel() const { return getContents(); } /// diff --git a/src/insets/insetlatexaccent.C b/src/insets/insetlatexaccent.C index a6a5b0a324..eca8a50121 100644 --- a/src/insets/insetlatexaccent.C +++ b/src/insets/insetlatexaccent.C @@ -662,7 +662,7 @@ bool InsetLatexAccent::DirectWrite() const } -Inset * InsetLatexAccent::Clone() const +Inset * InsetLatexAccent::Clone(Buffer const &) const { return new InsetLatexAccent(contents); } diff --git a/src/insets/insetlatexaccent.h b/src/insets/insetlatexaccent.h index e583ab57ce..9d7cbe4362 100644 --- a/src/insets/insetlatexaccent.h +++ b/src/insets/insetlatexaccent.h @@ -67,7 +67,7 @@ public: /// bool DirectWrite() const; /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// Inset::Code LyxCode()const; /// diff --git a/src/insets/insetlist.C b/src/insets/insetlist.C index a71be8a629..2a4be5c851 100644 --- a/src/insets/insetlist.C +++ b/src/insets/insetlist.C @@ -57,7 +57,7 @@ void InsetList::Write(Buffer const * buf, ostream & os) const } -Inset * InsetList::Clone() const +Inset * InsetList::Clone(Buffer const &) const { InsetList * result = new InsetList; result->inset->init(inset); diff --git a/src/insets/insetlist.h b/src/insets/insetlist.h index bb8c02eb11..dc1e415e1a 100644 --- a/src/insets/insetlist.h +++ b/src/insets/insetlist.h @@ -28,7 +28,7 @@ public: /// void Write(Buffer const * buf, std::ostream & os) const; /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// Inset::Code LyxCode() const { return Inset::FOOT_CODE; } /// diff --git a/src/insets/insetmarginal.C b/src/insets/insetmarginal.C index 9d078780a9..758b7cfd25 100644 --- a/src/insets/insetmarginal.C +++ b/src/insets/insetmarginal.C @@ -35,7 +35,7 @@ InsetMarginal::InsetMarginal() } -Inset * InsetMarginal::Clone() const +Inset * InsetMarginal::Clone(Buffer const &) const { InsetMarginal * result = new InsetMarginal; result->inset->init(inset); diff --git a/src/insets/insetmarginal.h b/src/insets/insetmarginal.h index d8253c6343..775fdd61d8 100644 --- a/src/insets/insetmarginal.h +++ b/src/insets/insetmarginal.h @@ -26,7 +26,7 @@ public: /// InsetMarginal(); /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// Inset::Code LyxCode() const { return Inset::MARGIN_CODE; } /// diff --git a/src/insets/insetminipage.C b/src/insets/insetminipage.C index 7d34868024..ceb7d8da5c 100644 --- a/src/insets/insetminipage.C +++ b/src/insets/insetminipage.C @@ -75,7 +75,7 @@ void InsetMinipage::Write(Buffer const * buf, ostream & os) const } -Inset * InsetMinipage::Clone() const +Inset * InsetMinipage::Clone(Buffer const &) const { InsetMinipage * result = new InsetMinipage; result->inset->init(inset); diff --git a/src/insets/insetminipage.h b/src/insets/insetminipage.h index a85ab503ee..aff41a6eec 100644 --- a/src/insets/insetminipage.h +++ b/src/insets/insetminipage.h @@ -28,7 +28,7 @@ public: /// void Write(Buffer const * buf, std::ostream & os) const; /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// Inset::Code LyxCode() const { return Inset::MINIPAGE_CODE; } /// diff --git a/src/insets/insetparent.C b/src/insets/insetparent.C index b6a9381a20..3c6a7f2975 100644 --- a/src/insets/insetparent.C +++ b/src/insets/insetparent.C @@ -29,14 +29,11 @@ using std::ostream; -InsetParent::InsetParent(InsetCommandParams const & p, Buffer * bf) +InsetParent::InsetParent(InsetCommandParams const & p, Buffer const & bf) : InsetCommand(p) { string fn = p.getContents(); - if (bf) - setContents(MakeAbsPath(fn, OnlyPath(bf->fileName()))); - else - setContents(fn); + setContents(MakeAbsPath(fn, OnlyPath(bf.fileName()))); } diff --git a/src/insets/insetparent.h b/src/insets/insetparent.h index 548acbaea4..1d21a12745 100644 --- a/src/insets/insetparent.h +++ b/src/insets/insetparent.h @@ -27,9 +27,11 @@ class Buffer; class InsetParent : public InsetCommand { public: /// - InsetParent(InsetCommandParams const &, Buffer * owner = 0); + InsetParent(InsetCommandParams const &, Buffer const &); /// - Inset * Clone() const { return new InsetParent(params()); } + Inset * Clone(Buffer const & buffer) const { + return new InsetParent(params(), buffer); + } /// string const getScreenLabel() const; /// diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index 93104a4a43..54a709292f 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -311,7 +311,7 @@ void InsetQuotes::Validate(LaTeXFeatures & features) const } -Inset * InsetQuotes::Clone() const +Inset * InsetQuotes::Clone(Buffer const &) const { return new InsetQuotes(language, side, times); } diff --git a/src/insets/insetquotes.h b/src/insets/insetquotes.h index 978891bc48..2ed6f4e662 100644 --- a/src/insets/insetquotes.h +++ b/src/insets/insetquotes.h @@ -97,7 +97,7 @@ public: /// void Validate(LaTeXFeatures &) const; /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// Inset::Code LyxCode() const; private: diff --git a/src/insets/insetref.C b/src/insets/insetref.C index ca83db0a0e..ff995a8a9f 100644 --- a/src/insets/insetref.C +++ b/src/insets/insetref.C @@ -16,11 +16,8 @@ using std::ostream; -extern BufferView * current_view; - - -InsetRef::InsetRef(InsetCommandParams const & p) - : InsetCommand(p) +InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf) + : InsetCommand(p), isLatex(buf.isLatex()) {} void InsetRef::Edit(BufferView * bv, int, int, unsigned int button) @@ -50,7 +47,7 @@ string const InsetRef::getScreenLabel() const temp += getContents(); - if(!current_view->buffer()->isLatex() + if(!isLatex && !getOptions().empty()) { temp += "||"; temp += getOptions(); diff --git a/src/insets/insetref.h b/src/insets/insetref.h index 621dcf1252..392b80a36f 100644 --- a/src/insets/insetref.h +++ b/src/insets/insetref.h @@ -24,9 +24,11 @@ struct LaTeXFeatures; class InsetRef : public InsetCommand { public: /// - InsetRef(InsetCommandParams const &); + InsetRef(InsetCommandParams const &, Buffer const &); /// - Inset * Clone() const { return new InsetRef(params()); } + Inset * Clone(Buffer const & buffer) const { + return new InsetRef(params(), buffer); + } /// string const getScreenLabel() const; /// @@ -51,5 +53,7 @@ public: private: /// This function escapes 8-bit characters string const escape(string const &) const; + /// + bool isLatex; }; #endif diff --git a/src/insets/insetspecialchar.C b/src/insets/insetspecialchar.C index ca1b9cb4de..9f40477967 100644 --- a/src/insets/insetspecialchar.C +++ b/src/insets/insetspecialchar.C @@ -221,7 +221,7 @@ int InsetSpecialChar::DocBook(Buffer const * buf, ostream & os) const } -Inset * InsetSpecialChar::Clone() const +Inset * InsetSpecialChar::Clone(Buffer const &) const { return new InsetSpecialChar(kind); } diff --git a/src/insets/insetspecialchar.h b/src/insets/insetspecialchar.h index 928892878b..33315256d9 100644 --- a/src/insets/insetspecialchar.h +++ b/src/insets/insetspecialchar.h @@ -65,7 +65,7 @@ public: /// int DocBook(Buffer const *, std::ostream &) const; /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// Inset::Code LyxCode() const { diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 0c2bf5647e..608b25448a 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -115,8 +115,8 @@ bool cellstart(LyXParagraph::size_type p) } -InsetTabular::InsetTabular(Buffer * buf, int rows, int columns) - : buffer(buf) +InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns) + : buffer(&buf) { if (rows <= 0) rows = 1; @@ -137,8 +137,8 @@ InsetTabular::InsetTabular(Buffer * buf, int rows, int columns) } -InsetTabular::InsetTabular(InsetTabular const & tab, Buffer * buf) - : buffer(buf) +InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf) + : buffer(&buf) { tabular = new LyXTabular(this, *(tab.tabular)); the_locking_inset = 0; @@ -161,9 +161,9 @@ InsetTabular::~InsetTabular() } -Inset * InsetTabular::Clone() const +Inset * InsetTabular::Clone(Buffer const & buf) const { - InsetTabular * t = new InsetTabular(*this, buffer); + InsetTabular * t = new InsetTabular(*this, buf); delete t->tabular; t->tabular = tabular->Clone(t); return t; diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index ecacb2dba7..ad1807de1d 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -73,13 +73,13 @@ public: SELECTION }; /// - InsetTabular(Buffer *, int rows = 1, int columns = 1); + InsetTabular(Buffer const &, int rows = 1, int columns = 1); /// - InsetTabular(InsetTabular const &, Buffer *); + InsetTabular(InsetTabular const &, Buffer const &); /// ~InsetTabular(); /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// void Read(Buffer const *, LyXLex &); /// @@ -160,7 +160,7 @@ public: /// int getMaxWidth(Painter & pain, UpdatableInset const *) const; /// - Buffer * BufferOwner() const { return buffer; } + Buffer * BufferOwner() const { return const_cast(buffer); } /// LyXText * getLyXText(BufferView *) const; /// @@ -235,7 +235,7 @@ private: /// InsetText * the_locking_inset; /// - Buffer * buffer; + Buffer const * buffer; /// mutable LyXCursor cursor; /// diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 87bfa469d0..2f9fcf9ca0 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -138,7 +138,7 @@ void InsetText::clear() } -Inset * InsetText::Clone() const +Inset * InsetText::Clone(Buffer const &) const { InsetText * t = new InsetText(*this); return t; diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 631582fddd..1e5354d345 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -75,7 +75,7 @@ public: /// ~InsetText(); /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// InsetText & operator=(InsetText const & it); /// diff --git a/src/insets/insettheorem.C b/src/insets/insettheorem.C index 11ef790d8b..16b19a9d88 100644 --- a/src/insets/insettheorem.C +++ b/src/insets/insettheorem.C @@ -54,7 +54,7 @@ void InsetTheorem::Write(Buffer const * buf, ostream & os) const } -Inset * InsetTheorem::Clone() const +Inset * InsetTheorem::Clone(Buffer const &) const { InsetTheorem * result = new InsetTheorem; diff --git a/src/insets/insettheorem.h b/src/insets/insettheorem.h index e2a6a8a380..84ad0e0653 100644 --- a/src/insets/insettheorem.h +++ b/src/insets/insettheorem.h @@ -28,7 +28,7 @@ public: /// void Write(Buffer const * buf, std::ostream & os) const; /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// Inset::Code LyxCode() const { return Inset::THEOREM_CODE; } /// diff --git a/src/insets/insettoc.h b/src/insets/insettoc.h index 9acd77bde8..3c7d8bed37 100644 --- a/src/insets/insettoc.h +++ b/src/insets/insettoc.h @@ -25,7 +25,7 @@ public: /// InsetTOC(InsetCommandParams const & p) : InsetCommand(p) {} /// - Inset * Clone() const { return new InsetTOC(params()); } + Inset * Clone(Buffer const &) const { return new InsetTOC(params()); } /// string const getScreenLabel() const; /// diff --git a/src/insets/inseturl.h b/src/insets/inseturl.h index 1aaddcfab2..c2a8363379 100644 --- a/src/insets/inseturl.h +++ b/src/insets/inseturl.h @@ -27,7 +27,7 @@ public: explicit InsetUrl(InsetCommandParams const &); /// - Inset * Clone() const { return new InsetUrl(params()); } + Inset * Clone(Buffer const &) const { return new InsetUrl(params()); } /// Inset::Code LyxCode() const { return Inset::URL_CODE; } /// diff --git a/src/insets/lyxinset.h b/src/insets/lyxinset.h index 0e50b02f49..ac3b657681 100644 --- a/src/insets/lyxinset.h +++ b/src/insets/lyxinset.h @@ -190,7 +190,7 @@ public: } /// - virtual Inset * Clone() const = 0; + virtual Inset * Clone(Buffer const &) const = 0; /// returns true to override begin and end inset in file virtual bool DirectWrite() const; diff --git a/src/lyx_cb.C b/src/lyx_cb.C index c09fe4cc8a..7878bb0fb9 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -154,7 +154,7 @@ void MenuReload(Buffer * buf); void MenuLayoutSave(); -void ShowMessage(Buffer * buf, +void ShowMessage(Buffer const * buf, string const & msg1, string const & msg2, string const & msg3, int delay) @@ -836,7 +836,7 @@ void FigureApplyCB(FL_OBJECT *, long) current_view->owner()->getMiniBuffer()->Set(_("Inserting figure...")); if (fl_get_button(fd_form_figure->radio_inline)) { - InsetFig * new_inset = new InsetFig(100, 20, buffer); + InsetFig * new_inset = new InsetFig(100, 20, *buffer); current_view->insertInset(new_inset); current_view->owner()->getMiniBuffer()->Set(_("Figure inserted")); new_inset->Edit(current_view, 0, 0, 0); @@ -890,7 +890,7 @@ void FigureApplyCB(FL_OBJECT *, long) current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - Inset * new_inset = new InsetFig(100, 100, buffer); + Inset * new_inset = new InsetFig(100, 100, *buffer); current_view->insertInset(new_inset); new_inset->Edit(current_view, 0, 0, 0); current_view->update(BufferView::SELECT|BufferView::FITCUR); diff --git a/src/lyx_cb.h b/src/lyx_cb.h index 8904ee965f..fdeef102c2 100644 --- a/src/lyx_cb.h +++ b/src/lyx_cb.h @@ -19,7 +19,7 @@ extern bool BindFileSet; /// extern LyXFont const UserFreeFont(BufferParams const & params); /// -void ShowMessage(Buffer * buf, +void ShowMessage(Buffer const * buf, string const & msg1, string const & msg2 = string(), string const & msg3 = string(), int delay = 6); diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 45c612511c..7e99347dea 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -523,7 +523,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const flag |= ret; disable = false; } else { - static InsetTabular inset(owner->buffer(), 1, 1); + static InsetTabular inset(*owner->buffer(), 1, 1); func_status ret; disable = true; @@ -855,7 +855,6 @@ string const LyXFunc::Dispatch(int ac, meta_fake_bit = Mod1Mask; string buf; keyseq.print(buf, true); - string res = string("M-") + buf; setMessage(buf); // RVDK_PATCH_5 } break; @@ -1495,7 +1494,7 @@ string const LyXFunc::Dispatch(int ac, InsetCommandParams p; p.setFromString(argument); - InsetRef * inset = new InsetRef(p); + InsetRef * inset = new InsetRef(p, *owner->buffer()); if (!owner->view()->insertInset(inset)) delete inset; else @@ -2347,7 +2346,7 @@ string const LyXFunc::Dispatch(int ac, if (!argument.empty()) ::sscanf(argument.c_str(),"%d%d", &r, &c); InsetTabular * new_inset = - new InsetTabular(owner->buffer(), r, c); + new InsetTabular(*owner->buffer(), r, c); if (owner->view()->insertInset(new_inset)) new_inset->Edit(owner->view(), 0, 0, 0); else @@ -2796,7 +2795,7 @@ string const LyXFunc::Dispatch(int ac, { lyxerr << "arg " << argument << endl; InsetCommandParams p( "lyxparent", argument ); - Inset * inset = new InsetParent(p, owner->buffer()); + Inset * inset = new InsetParent(p, *owner->buffer()); if (!owner->view()->insertInset(inset, "Standard", true)) delete inset; } @@ -2805,7 +2804,7 @@ string const LyXFunc::Dispatch(int ac, case LFUN_CHILDINSERT: { InsetCommandParams p( "Include", argument ); - Inset * inset = new InsetInclude(p, owner->buffer()); + Inset * inset = new InsetInclude(p, *owner->buffer()); if (owner->view()->insertInset(inset, "Standard", true)) inset->Edit(owner->view(), 0, 0, 0); else diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 75e49f5ca5..19399b6a51 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -301,7 +301,7 @@ InsetFormula::~InsetFormula() } -Inset * InsetFormula::Clone() const +Inset * InsetFormula::Clone(Buffer const &) const { InsetFormula * f = new InsetFormula(par); f->label = label; diff --git a/src/mathed/formula.h b/src/mathed/formula.h index 99a018f276..f1dc758789 100644 --- a/src/mathed/formula.h +++ b/src/mathed/formula.h @@ -64,7 +64,7 @@ public: /// void Validate(LaTeXFeatures &) const; /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// Inset::Code LyxCode() const { return Inset::MATH_CODE; } /// diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index 10f9c5d238..5504ab93a0 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -61,7 +61,7 @@ InsetFormulaMacro::~InsetFormulaMacro() } -Inset * InsetFormulaMacro::Clone() const +Inset * InsetFormulaMacro::Clone(Buffer const &) const { return new InsetFormulaMacro(name); } diff --git a/src/mathed/formulamacro.h b/src/mathed/formulamacro.h index 3a66cfddc9..1e75f11717 100644 --- a/src/mathed/formulamacro.h +++ b/src/mathed/formulamacro.h @@ -56,7 +56,7 @@ public: /// int DocBook(Buffer const *, std::ostream &) const; /// - Inset * Clone() const; + Inset * Clone(Buffer const &) const; /// what appears in the minibuffer when opening string const EditMessage() const; diff --git a/src/paragraph.C b/src/paragraph.C index ed9ed07038..e822a99261 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -410,7 +410,7 @@ void LyXParagraph::CopyIntoMinibuffer(BufferParams const & bparams, minibuffer_inset = 0; if (minibuffer_char == LyXParagraph::META_INSET) { if (GetInset(pos)) { - minibuffer_inset = GetInset(pos)->Clone(); + minibuffer_inset = GetInset(pos)->Clone(*current_view->buffer()); } else { minibuffer_inset = 0; minibuffer_char = ' '; @@ -1610,7 +1610,8 @@ LyXParagraph * LyXParagraph::Clone() const // ale970302 if (bibkey) - result->bibkey = static_cast(bibkey->Clone()); + result->bibkey = static_cast + (bibkey->Clone(*current_view->buffer())); else result->bibkey = 0; @@ -1621,7 +1622,7 @@ LyXParagraph * LyXParagraph::Clone() const result->insetlist = insetlist; for (InsetList::iterator it = result->insetlist.begin(); it != result->insetlist.end(); ++it) - (*it).inset = (*it).inset->Clone(); + (*it).inset = (*it).inset->Clone(*current_view->buffer()); return result; }