From: Lars Gullik Bjønnes Date: Tue, 23 Nov 2004 23:04:52 +0000 (+0000) Subject: clone NVI, other small stuff X-Git-Tag: 1.6.10~14804 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=59413be9a0b999c17784d1abad01e55819ecd27a;p=features.git clone NVI, other small stuff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9295 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index f70d86ac62..1d3e4d6252 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2004-11-23 Lars Gullik Bjonnes + + * tabular.C (cellstruct): use initialization, store a shared_ptr + to insettext instead of the insettext directly, adjust to fit. + (operator=): new function + (swap): new function + (rowstruct): use initialization + (columnstruct): use initialization + (ltType): use initialization + + + * lyxlength.h (swap): new function + + * LColor.[Ch] (operator=): use the common semantics + 2004-11-22 Jean-Marc Lasgouttes * lyxfind.C (findNextChange): update the bufferview after setting @@ -19,13 +34,13 @@ code; return true also for digits (isWord, isKomma): remove - * text.C (cursorRightOneWord, cursorLeftOneWord, getWord): + * text.C (cursorRightOneWord, cursorLeftOneWord, getWord): * lyxfind.C (MatchString()): use isLetter instead of isWord 2004-11-17 Lars Gullik Bjonnes * pariterator.h (operatir=): comment out un-implemented member - function. + function. * paragraph.h: resolve ambiguity found by gcc 4.0 with the use of a static cast. diff --git a/src/LColor.C b/src/LColor.C index 1642e4f6c3..b2f1ba545f 100644 --- a/src/LColor.C +++ b/src/LColor.C @@ -160,10 +160,10 @@ LColor::~LColor() {} -void LColor::operator=(LColor const & c) +LColor & LColor::operator=(LColor tmp) { - LColor tmp(c); boost::swap(pimpl_, tmp.pimpl_); + return *this; } diff --git a/src/LColor.h b/src/LColor.h index b410378dc2..700bb66aba 100644 --- a/src/LColor.h +++ b/src/LColor.h @@ -189,7 +189,7 @@ public: /// ~LColor(); /// - void operator=(LColor const &); + LColor & operator=(LColor); /** set the given LyX color to the color defined by the X11 name given * \returns true if successful. diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 144237db57..eddd062b5b 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,21 @@ +2004-11-23 Lars Gullik Bjonnes + + * render_base.h (operator=): use common semantics + + * insettext.C (operator=): delete this + (copy constructor): implement this properly + (init): use for_each and bind + (clear): ditto + (appendParagraphs): ditto + + * insettabular.C: add more const. Adjust for changes in tabular. + + * insetbase.h: Use NVI on clone. Add virtual doClone and update + all children, also make copy constructor protected. Added some + safe-guards to clone. + + * insets: adjust to fit. + 2004-11-16 Jean-Marc Lasgouttes * insetoptarg.C (latexOptional): return number of lines instead of @@ -27,14 +45,14 @@ * insetcharstyle.[Ch]: * insetert.[Ch]: implement getStatus - + * insetcharstyle.C (draw): visual clue when the cursor is inside the inset 2004-11-02 José Matos * insetcharstyle.C (docbook): - * insetlabel.C (linuxdoc, docbook): + * insetlabel.C (linuxdoc, docbook): * insetref.C (linuxdoc, docbook): escape chacters in id to produce always legal output. @@ -43,7 +61,7 @@ 2004-11-01 Jürgen Spitzmüller - * insetcharstyle.C (priv_dispatch): prevent paragraph breaks + * insetcharstyle.C (priv_dispatch): prevent paragraph breaks 2004-11-01 Georg Baum @@ -64,7 +82,7 @@ InsetText methods rather than outputVerbatim (escapes special characters) [bug 1731] * insetcharstyle.C (outputVerbatim): remove this function. - * insetcharstyle.C (priv_dispatch): fix typo in LFUN_MOUSE_PRESS, + * insetcharstyle.C (priv_dispatch): fix typo in LFUN_MOUSE_PRESS, which caused an infinite loop. 2004-10-29 José Matos @@ -97,7 +115,7 @@ 2004-10-26 Angus Leeming - * ExternalSupport.C (updateExternal): + * ExternalSupport.C (updateExternal): * insetgraphics.C (copyFileIfNeeded): use the new Movers to move external files to the temp directory. @@ -2621,7 +2639,7 @@ * graphicinset.C (draw): add a comment for the #if 0 block. - * insetexternal.h: remove Params::parameters variable. + * insetexternal.h: remove Params::parameters variable. * insetexternal.C (read, write): rewrite to output new ExternalInset format and read it back making full use of LyXLex. @@ -4472,7 +4490,7 @@ * insetexternal.C: all c-library variables have been moved into namespace std. Wrap using std::xyz declarations inside a #ifndef - CXX_GLOBAL_CSTD block. + CXX_GLOBAL_CSTD block. 2002-06-05 Jean-Marc Lasgouttes diff --git a/src/insets/inset.C b/src/insets/inset.C index 1f60140025..c467ebe6d2 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -82,7 +82,7 @@ int InsetOld::scroll(bool) const } -void InsetOld::setPosCache(PainterInfo const & pi, int x, int y) const +void InsetOld::setPosCache(PainterInfo const &, int x, int y) const { //lyxerr << "InsetOld:: position cache to " << x << " " << y << std::endl; theCoords.insets_.add(this, x, y); diff --git a/src/insets/inset.h b/src/insets/inset.h index ece7a34e29..11fd79bfe1 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -34,8 +34,6 @@ public: /// InsetOld(); /// - InsetOld(InsetOld const & in); - /// int ascent() const; /// int descent() const; @@ -58,12 +56,16 @@ public: /// bool forceDefaultParagraphs(InsetBase const * inset) const; protected: + /// + InsetOld(InsetOld const & in); /// mutable int scx; /// mutable Dimension dim_; private: + InsetOld & operator=(InsetOld const &) const; + /// std::string name_; /** We store the LColor::color value as an int to get LColor.h out @@ -78,10 +80,10 @@ private: * having to expose inset.h. */ class InsetOld_code { - InsetOld::Code val_; + InsetBase::Code val_; public: - InsetOld_code(InsetOld::Code val) : val_(val) {} - operator InsetOld::Code() const { return val_; } + InsetOld_code(InsetBase::Code val) : val_(val) {} + operator InsetBase::Code() const { return val_; } }; #endif diff --git a/src/insets/insetbase.C b/src/insets/insetbase.C index f40b4d52a7..9968f41d73 100644 --- a/src/insets/insetbase.C +++ b/src/insets/insetbase.C @@ -103,6 +103,14 @@ TranslatorMap const build_translator() } // namespace anon +InsetBase::InsetBase() +{} + + +InsetBase::InsetBase(InsetBase const &) +{} + + InsetBase::Code InsetBase::translate(std::string const & name) { static TranslatorMap const translator = build_translator(); diff --git a/src/insets/insetbase.h b/src/insets/insetbase.h index d87ac7c15a..adb1bd0944 100644 --- a/src/insets/insetbase.h +++ b/src/insets/insetbase.h @@ -12,7 +12,10 @@ #ifndef INSETBASE_H #define INSETBASE_H +#include + #include +#include #include #include @@ -61,7 +64,13 @@ public: /// virtual base class destructor virtual ~InsetBase() {} /// replicate ourselves - virtual std::auto_ptr clone() const = 0; + std::auto_ptr clone() const + { + std::auto_ptr b = doClone(); + BOOST_ASSERT(typeid(*b) == typeid(*this)); + return b; + } + /// identification as math inset virtual MathInset * asMathInset() { return 0; } @@ -351,9 +360,6 @@ public: * defaults to empty. */ virtual void addPreview(lyx::graphics::PreviewLoader &) const {} -protected: - // the real dispatcher - virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd); public: /// returns LyX code associated with the inset. Used for TOC, ...) virtual Code lyxCode() const { return NO_CODE; } @@ -376,6 +382,13 @@ public: virtual int ascent() const { return 10; } /// pretty arbitrary virtual int descent() const { return 10; } +protected: + InsetBase(); + InsetBase(InsetBase const &); + // the real dispatcher + virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd); +private: + virtual std::auto_ptr doClone() const = 0; }; diff --git a/src/insets/insetbibitem.C b/src/insets/insetbibitem.C index 2e74ad6803..f90e68efec 100644 --- a/src/insets/insetbibitem.C +++ b/src/insets/insetbibitem.C @@ -47,7 +47,7 @@ InsetBibitem::InsetBibitem(InsetCommandParams const & p) } -auto_ptr InsetBibitem::clone() const +auto_ptr InsetBibitem::doClone() const { auto_ptr b(new InsetBibitem(params())); b->setCounter(counter); diff --git a/src/insets/insetbibitem.h b/src/insets/insetbibitem.h index b05d22fe4a..b91d9f0159 100644 --- a/src/insets/insetbibitem.h +++ b/src/insets/insetbibitem.h @@ -24,8 +24,6 @@ class InsetBibitem : public InsetCommand { public: /// InsetBibitem(InsetCommandParams const &); - /// - std::auto_ptr clone() const; /** Currently \bibitem is used as a LyX2.x command, so we need this method. */ @@ -53,6 +51,8 @@ protected: /// virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd); private: + virtual std::auto_ptr doClone() const; + /// int counter; /// diff --git a/src/insets/insetbibtex.C b/src/insets/insetbibtex.C index dd21b522cb..22c3886751 100644 --- a/src/insets/insetbibtex.C +++ b/src/insets/insetbibtex.C @@ -62,7 +62,7 @@ InsetBibtex::InsetBibtex(InsetCommandParams const & p) {} -std::auto_ptr InsetBibtex::clone() const +std::auto_ptr InsetBibtex::doClone() const { return std::auto_ptr(new InsetBibtex(*this)); } diff --git a/src/insets/insetbibtex.h b/src/insets/insetbibtex.h index 0a7cbf7093..1ab4d85694 100644 --- a/src/insets/insetbibtex.h +++ b/src/insets/insetbibtex.h @@ -23,8 +23,6 @@ public: /// InsetBibtex(InsetCommandParams const &); /// - std::auto_ptr clone() const; - /// std::string const getScreenLabel(Buffer const &) const; /// EDITABLE editable() const { return IS_EDITABLE; } @@ -47,8 +45,10 @@ public: /// void validate(LaTeXFeatures &) const; protected: - /// virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd); +private: + virtual std::auto_ptr doClone() const; + }; #endif // INSET_BIBTEX_H diff --git a/src/insets/insetbox.C b/src/insets/insetbox.C index f93283ad24..e1836d5e23 100644 --- a/src/insets/insetbox.C +++ b/src/insets/insetbox.C @@ -104,7 +104,7 @@ InsetBox::~InsetBox() } -auto_ptr InsetBox::clone() const +auto_ptr InsetBox::doClone() const { return auto_ptr(new InsetBox(*this)); } diff --git a/src/insets/insetbox.h b/src/insets/insetbox.h index 49281cbdf8..a29ac78520 100644 --- a/src/insets/insetbox.h +++ b/src/insets/insetbox.h @@ -56,13 +56,9 @@ class InsetBox : public InsetCollapsable { public: /// InsetBox(BufferParams const &, std::string const &); - /// Copy constructor - InsetBox(InsetBox const &); /// ~InsetBox(); /// - virtual std::auto_ptr clone() const; - /// std::string const editMessage() const; /// InsetOld::Code lyxCode() const { return InsetOld::BOX_CODE; } @@ -104,11 +100,13 @@ public: Doublebox }; protected: - /// + InsetBox(InsetBox const &); virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd); private: friend class InsetBoxParams; + virtual std::auto_ptr doClone() const; + /// used by the constructors void init(); /// diff --git a/src/insets/insetbranch.C b/src/insets/insetbranch.C index 4803d186e3..d199b7ce06 100644 --- a/src/insets/insetbranch.C +++ b/src/insets/insetbranch.C @@ -60,7 +60,7 @@ InsetBranch::~InsetBranch() } -auto_ptr InsetBranch::clone() const +auto_ptr InsetBranch::doClone() const { return auto_ptr(new InsetBranch(*this)); } diff --git a/src/insets/insetbranch.h b/src/insets/insetbranch.h index 4cb870a155..f0c002ba05 100644 --- a/src/insets/insetbranch.h +++ b/src/insets/insetbranch.h @@ -37,13 +37,9 @@ class InsetBranch : public InsetCollapsable { public: /// InsetBranch(BufferParams const &, InsetBranchParams const &); - /// Copy constructor - InsetBranch(InsetBranch const &); /// ~InsetBranch(); /// - virtual std::auto_ptr clone() const; - /// std::string const editMessage() const; /// InsetOld::Code lyxCode() const { return InsetOld::BRANCH_CODE; } @@ -80,11 +76,13 @@ public: bool isBranchSelected(BranchList const & branchlist) const; protected: - /// + InsetBranch(InsetBranch const &); virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd); private: friend class InsetBranchParams; + virtual std::auto_ptr doClone() const; + /// used by the constructors void init(); /// diff --git a/src/insets/insetcharstyle.C b/src/insets/insetcharstyle.C index 1cf5be9773..9d8e51eb43 100644 --- a/src/insets/insetcharstyle.C +++ b/src/insets/insetcharstyle.C @@ -72,7 +72,7 @@ InsetCharStyle::InsetCharStyle(InsetCharStyle const & in) } -auto_ptr InsetCharStyle::clone() const +auto_ptr InsetCharStyle::doClone() const { return auto_ptr(new InsetCharStyle(*this)); } @@ -122,13 +122,13 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const int desc = InsetText::descent(); if (has_label_) desc -= ascent(); - + pi.pain.line(x, y + desc - 4, x, y + desc, params_.labelfont.color()); - pi.pain.line(x, y + desc, x + dim_.wid - 2, y + desc, + pi.pain.line(x, y + desc, x + dim_.wid - 2, y + desc, params_.labelfont.color()); - pi.pain.line(x + dim_.wid - 2, y + desc, x + dim_.wid - 2, y + desc - 4, + pi.pain.line(x + dim_.wid - 2, y + desc, x + dim_.wid - 2, y + desc - 4, params_.labelfont.color()); - + // the name of the charstyle. Can be toggled. if (has_label_) { LyXFont font(params_.labelfont); @@ -142,16 +142,16 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const pi.pain.rectText(x + (dim_.wid - w) / 2, y + desc + a, params_.type, font, LColor::none, LColor::none); } - + // a visual clue when the cursor is inside the inset LCursor & cur = pi.base.bv->cursor(); if (cur.isInside(this)) { y -= ascent(); pi.pain.line(x, y + 4, x, y, params_.labelfont.color()); pi.pain.line(x + 4, y, x, y, params_.labelfont.color()); - pi.pain.line(x + dim_.wid - 2, y + 4, x + dim_.wid - 2, y, + pi.pain.line(x + dim_.wid - 2, y + 4, x + dim_.wid - 2, y, params_.labelfont.color()); - pi.pain.line(x + dim_.wid - 6, y, x + dim_.wid - 2, y, + pi.pain.line(x + dim_.wid - 6, y, x + dim_.wid - 2, y, params_.labelfont.color()); } } @@ -191,7 +191,7 @@ bool InsetCharStyle::getStatus(LCursor & cur, FuncRequest const & cmd, case LFUN_BREAKPARAGRAPH_SKIP: status.enabled(false); return true; - + default: return InsetCollapsable::getStatus(cur, cmd, status); } diff --git a/src/insets/insetcharstyle.h b/src/insets/insetcharstyle.h index d9c5405fc2..c926e0ccf1 100644 --- a/src/insets/insetcharstyle.h +++ b/src/insets/insetcharstyle.h @@ -44,10 +44,6 @@ class InsetCharStyle : public InsetCollapsable { public: /// InsetCharStyle(BufferParams const &, CharStyles::iterator); - /// Copy constructor - InsetCharStyle(InsetCharStyle const &); - /// - virtual std::auto_ptr clone() const; /// std::string const editMessage() const; /// @@ -81,15 +77,16 @@ public: InsetCharStyleParams const & params() const { return params_; } protected: - /// + InsetCharStyle(InsetCharStyle const &); virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd); /// bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const; private: - /// friend class InsetCharStyleParams; + virtual std::auto_ptr doClone() const; + /// used by the constructors void init(); /// diff --git a/src/insets/insetcite.h b/src/insets/insetcite.h index fd90c887fc..aa2b742ffe 100644 --- a/src/insets/insetcite.h +++ b/src/insets/insetcite.h @@ -25,10 +25,6 @@ public: /// InsetCitation(InsetCommandParams const &); /// - std::auto_ptr clone() const { - return std::auto_ptr(new InsetCitation(params())); - } - /// std::string const getScreenLabel(Buffer const &) const; /// EDITABLE editable() const { return IS_EDITABLE; } @@ -46,6 +42,11 @@ public: void validate(LaTeXFeatures &) const; private: + virtual std::auto_ptr doClone() const + { + return std::auto_ptr(new InsetCitation(params())); + } + /// This function does the donkey work of creating the pretty label std::string const generateLabel(Buffer const &) const; diff --git a/src/insets/insetenv.C b/src/insets/insetenv.C index 5980ab9aed..478d2a9f35 100644 --- a/src/insets/insetenv.C +++ b/src/insets/insetenv.C @@ -41,7 +41,7 @@ InsetEnvironment::InsetEnvironment(InsetEnvironment const & in) {} -auto_ptr InsetEnvironment::clone() const +auto_ptr InsetEnvironment::doClone() const { return auto_ptr(new InsetEnvironment(*this)); } diff --git a/src/insets/insetenv.h b/src/insets/insetenv.h index ae5b231862..3385a4cda0 100644 --- a/src/insets/insetenv.h +++ b/src/insets/insetenv.h @@ -21,14 +21,10 @@ public: /// InsetEnvironment(BufferParams const &, std::string const & name); /// - InsetEnvironment(InsetEnvironment const &); - /// void write(Buffer const & buf, std::ostream & os) const; /// void read(Buffer const & buf, LyXLex & lex); /// - virtual std::auto_ptr clone() const; - /// InsetOld::Code lyxCode() const { return InsetOld::ENVIRONMENT_CODE; } /// int latex(Buffer const &, std::ostream &, @@ -45,8 +41,10 @@ public: be closed before generating this inset. This is needed for insets that may contain several paragraphs */ bool noFontChange() const { return true; } - +protected: + InsetEnvironment(InsetEnvironment const &); private: + virtual std::auto_ptr doClone() const; /// the layout LyXLayout_ptr layout_; }; diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 0804464617..f8de91372a 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -72,7 +72,7 @@ InsetERT::InsetERT(InsetERT const & in) } -auto_ptr InsetERT::clone() const +auto_ptr InsetERT::doClone() const { return auto_ptr(new InsetERT(*this)); } @@ -250,7 +250,7 @@ bool InsetERT::getStatus(LCursor & cur, FuncRequest const & cmd, case LFUN_UNDERLINE: status.enabled(false); return true; - + default: return InsetCollapsable::getStatus(cur, cmd, status); } diff --git a/src/insets/insetert.h b/src/insets/insetert.h index 2c1a84e1d2..9cb08225e3 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -32,10 +32,6 @@ public: /// InsetERT(BufferParams const &, CollapseStatus status = Open); /// - InsetERT(InsetERT const &); - /// - virtual std::auto_ptr clone() const; - /// InsetERT(BufferParams const &, Language const *, std::string const & contents, CollapseStatus status); /// @@ -73,11 +69,13 @@ public: /// bool forceDefaultParagraphs(InsetBase const *) const { return true; } protected: + InsetERT(InsetERT const &); /// virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd); /// bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const; private: + virtual std::auto_ptr doClone() const; /// void init(); /// diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index b4548c6250..33e477c44d 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -415,7 +415,7 @@ InsetExternal::InsetExternal(InsetExternal const & other) {} -auto_ptr InsetExternal::clone() const +auto_ptr InsetExternal::doClone() const { return auto_ptr(new InsetExternal(*this)); } diff --git a/src/insets/insetexternal.h b/src/insets/insetexternal.h index c2e38d9529..34901ec1d7 100644 --- a/src/insets/insetexternal.h +++ b/src/insets/insetexternal.h @@ -105,12 +105,8 @@ class InsetExternal : public InsetOld, public boost::signals::trackable public: InsetExternal(); /// - InsetExternal(InsetExternal const &); - /// virtual ~InsetExternal(); /// - virtual std::auto_ptr clone() const; - /// virtual InsetOld::Code lyxCode() const { return EXTERNAL_CODE; } /// virtual EDITABLE editable() const { return IS_EDITABLE; } @@ -150,9 +146,12 @@ public: void edit(LCursor & cur, bool left); protected: + InsetExternal(InsetExternal const &); /// void priv_dispatch(LCursor & cur, FuncRequest & cmd); private: + virtual std::auto_ptr doClone() const; + /** This method is connected to the graphics loader, so we are * informed when the image has been loaded. */ diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index 41d7dffe8e..156bd62f70 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -271,7 +271,7 @@ void InsetFloat::validate(LaTeXFeatures & features) const } -auto_ptr InsetFloat::clone() const +auto_ptr InsetFloat::doClone() const { return auto_ptr(new InsetFloat(*this)); } diff --git a/src/insets/insetfloat.h b/src/insets/insetfloat.h index 633d0a7533..a5b4867fba 100644 --- a/src/insets/insetfloat.h +++ b/src/insets/insetfloat.h @@ -51,8 +51,6 @@ public: /// void validate(LaTeXFeatures & features) const; /// - virtual std::auto_ptr clone() const; - /// InsetOld::Code lyxCode() const { return InsetOld::FLOAT_CODE; } /// int latex(Buffer const &, std::ostream &, @@ -84,6 +82,8 @@ public: protected: virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd); private: + virtual std::auto_ptr doClone() const; + /// InsetFloatParams params_; }; diff --git a/src/insets/insetfloatlist.h b/src/insets/insetfloatlist.h index 197b2dc182..c257013f7c 100644 --- a/src/insets/insetfloatlist.h +++ b/src/insets/insetfloatlist.h @@ -24,10 +24,6 @@ public: /// InsetFloatList(std::string const & type); /// - virtual std::auto_ptr clone() const { - return std::auto_ptr(new InsetFloatList(getCmdName())); - } - /// std::string const getScreenLabel(Buffer const &) const; /// EDITABLE editable() const { return IS_EDITABLE; } @@ -53,6 +49,11 @@ public: OutputParams const & runparams) const; /// void validate(LaTeXFeatures & features) const; +private: + virtual std::auto_ptr doClone() const + { + return std::auto_ptr(new InsetFloatList(getCmdName())); + } }; #endif diff --git a/src/insets/insetfoot.C b/src/insets/insetfoot.C index 409a0107e2..0ed4db0936 100644 --- a/src/insets/insetfoot.C +++ b/src/insets/insetfoot.C @@ -45,7 +45,7 @@ InsetFoot::InsetFoot(InsetFoot const & in) } -auto_ptr InsetFoot::clone() const +auto_ptr InsetFoot::doClone() const { return auto_ptr(new InsetFoot(*this)); } diff --git a/src/insets/insetfoot.h b/src/insets/insetfoot.h index e99370063d..821b7c5141 100644 --- a/src/insets/insetfoot.h +++ b/src/insets/insetfoot.h @@ -23,10 +23,6 @@ public: /// InsetFoot(BufferParams const &); /// - InsetFoot(InsetFoot const &); - /// - virtual std::auto_ptr clone() const; - /// InsetOld::Code lyxCode() const { return InsetOld::FOOT_CODE; } /// int latex(Buffer const &, std::ostream &, @@ -36,6 +32,10 @@ public: OutputParams const & runparams) const; /// std::string const editMessage() const; +protected: + InsetFoot(InsetFoot const &); +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 017ab2a5c6..8fd76dee93 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -167,7 +167,7 @@ InsetGraphics::InsetGraphics(InsetGraphics const & ig) } -auto_ptr InsetGraphics::clone() const +auto_ptr InsetGraphics::doClone() const { return auto_ptr(new InsetGraphics(*this)); } diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index 2e8535c65f..2a552da511 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -29,8 +29,6 @@ public: /// InsetGraphics(); /// - InsetGraphics(InsetGraphics const &); - /// ~InsetGraphics(); /// void metrics(MetricsInfo &, Dimension &) const; @@ -65,9 +63,6 @@ public: /// returns LyX code associated with the inset. Used for TOC, ...) InsetOld::Code lyxCode() const { return InsetOld::GRAPHICS_CODE; } - /// - virtual std::auto_ptr clone() const; - /** Set the inset parameters, used by the GUIndependent dialog. Return true of new params are different from what was so far. */ @@ -82,12 +77,14 @@ public: /// void editGraphics(InsetGraphicsParams const &, Buffer const &) const; protected: + InsetGraphics(InsetGraphics const &); /// void priv_dispatch(LCursor & cur, FuncRequest & cmd); private: - /// friend class InsetGraphicsMailer; + virtual std::auto_ptr doClone() const; + /// Read the inset native format void readInsetGraphics(LyXLex & lex, std::string const & bufpath); diff --git a/src/insets/insethfill.C b/src/insets/insethfill.C index 0e43c963f4..32e4bb40bd 100644 --- a/src/insets/insethfill.C +++ b/src/insets/insethfill.C @@ -22,7 +22,7 @@ InsetHFill::InsetHFill() {} -std::auto_ptr InsetHFill::clone() const +std::auto_ptr InsetHFill::doClone() const { return std::auto_ptr(new InsetHFill); } diff --git a/src/insets/insethfill.h b/src/insets/insethfill.h index 2d21203a12..3a670743a3 100644 --- a/src/insets/insethfill.h +++ b/src/insets/insethfill.h @@ -22,8 +22,6 @@ public: /// void metrics(MetricsInfo &, Dimension &) const; /// - std::auto_ptr clone() const; - /// std::string const getScreenLabel(Buffer const &) const; /// InsetOld::Code lyxCode() const { return InsetOld::HFILL_CODE; } @@ -46,7 +44,8 @@ public: /// is this equivalent to a space (which is BTW different from // a line separator)? bool isSpace() const; - +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index befd4eb611..cb9a12c09a 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -226,7 +226,7 @@ void InsetInclude::set(InsetCommandParams const & p, Buffer const & buffer) } -auto_ptr InsetInclude::clone() const +auto_ptr InsetInclude::doClone() const { return auto_ptr(new InsetInclude(*this)); } diff --git a/src/insets/insetinclude.h b/src/insets/insetinclude.h index b0aae9d27f..3e140a22f7 100644 --- a/src/insets/insetinclude.h +++ b/src/insets/insetinclude.h @@ -28,12 +28,8 @@ class InsetInclude: public InsetOld { public: /// InsetInclude(InsetCommandParams const &); - InsetInclude(InsetInclude const &); ~InsetInclude(); - /// - virtual std::auto_ptr clone() const; - /// Override these InsetButton methods if Previewing void metrics(MetricsInfo & mi, Dimension & dim) const; /// @@ -82,9 +78,12 @@ public: /// void addPreview(lyx::graphics::PreviewLoader &) const; protected: + InsetInclude(InsetInclude const &); /// virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd); private: + virtual std::auto_ptr doClone() const; + /** Slot receiving a signal that the external file has changed * and the preview should be regenerated. */ diff --git a/src/insets/insetindex.h b/src/insets/insetindex.h index 997ec4a76a..78842a281a 100644 --- a/src/insets/insetindex.h +++ b/src/insets/insetindex.h @@ -24,10 +24,6 @@ public: /// InsetIndex(InsetCommandParams const &); /// - virtual std::auto_ptr clone() const { - return std::auto_ptr(new InsetIndex(params())); - } - /// std::string const getScreenLabel(Buffer const &) const; /// EDITABLE editable() const { return IS_EDITABLE; } @@ -36,6 +32,10 @@ public: /// int docbook(Buffer const &, std::ostream &, OutputParams const &) const; +private: + virtual std::auto_ptr doClone() const { + return std::auto_ptr(new InsetIndex(params())); + } }; @@ -43,10 +43,6 @@ class InsetPrintIndex : public InsetCommand { public: /// InsetPrintIndex(InsetCommandParams const &); - /// - virtual std::auto_ptr clone() const { - return std::auto_ptr(new InsetPrintIndex(params())); - } /// Updates needed features for this inset. void validate(LaTeXFeatures & features) const; /// @@ -57,6 +53,10 @@ public: bool display() const { return true; } /// std::string const getScreenLabel(Buffer const &) const; +private: + virtual std::auto_ptr doClone() const { + return std::auto_ptr(new InsetPrintIndex(params())); + } }; #endif diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index c8e7c0c7f4..7e19d69bd2 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -40,7 +40,7 @@ InsetLabel::InsetLabel(InsetCommandParams const & p) {} -std::auto_ptr InsetLabel::clone() const +std::auto_ptr InsetLabel::doClone() const { return std::auto_ptr(new InsetLabel(params())); } diff --git a/src/insets/insetlabel.h b/src/insets/insetlabel.h index 3d18632c0d..8ea8190e2f 100644 --- a/src/insets/insetlabel.h +++ b/src/insets/insetlabel.h @@ -19,8 +19,6 @@ public: /// InsetLabel(InsetCommandParams const &); /// - std::auto_ptr clone() const; - /// std::string const getScreenLabel(Buffer const &) const; /// EDITABLE editable() const { return IS_EDITABLE; } @@ -41,8 +39,9 @@ public: int docbook(Buffer const &, std::ostream &, OutputParams const &) const; protected: - /// virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd); +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/insets/insetlatexaccent.C b/src/insets/insetlatexaccent.C index 95a3ffc3de..33f6d6ad58 100644 --- a/src/insets/insetlatexaccent.C +++ b/src/insets/insetlatexaccent.C @@ -49,7 +49,7 @@ InsetLatexAccent::InsetLatexAccent(string const & str) } -auto_ptr InsetLatexAccent::clone() const +auto_ptr InsetLatexAccent::doClone() const { return auto_ptr(new InsetLatexAccent(contents)); } diff --git a/src/insets/insetlatexaccent.h b/src/insets/insetlatexaccent.h index 09f6748c88..854fdb5f78 100644 --- a/src/insets/insetlatexaccent.h +++ b/src/insets/insetlatexaccent.h @@ -60,8 +60,6 @@ public: /// bool directWrite() const; /// - virtual std::auto_ptr clone() const; - /// InsetOld::Code lyxCode()const; /// inline bool canDisplay(); @@ -118,6 +116,9 @@ public: }; private: friend std::ostream & operator<<(std::ostream &, ACCENT_TYPES); + + virtual std::auto_ptr doClone() const; + /// Check if we know the modifier and can display it ok on screen. void checkContents(); /// diff --git a/src/insets/insetline.h b/src/insets/insetline.h index 9e5fb6c187..504854f8af 100644 --- a/src/insets/insetline.h +++ b/src/insets/insetline.h @@ -20,10 +20,6 @@ public: InsetLine() {} - std::auto_ptr clone() const { - return std::auto_ptr(new InsetLine); - } - InsetOld::Code lyxCode() const { return InsetOld::LINE_CODE; } void metrics(MetricsInfo &, Dimension &) const; @@ -51,6 +47,11 @@ public: bool display() const { return true; } /// void validate(LaTeXFeatures & features) const; +private: + virtual std::auto_ptr doClone() const + { + return std::auto_ptr(new InsetLine); + } }; #endif // INSET_NEWLINE_H diff --git a/src/insets/insetmarginal.C b/src/insets/insetmarginal.C index e46838c06e..9147236c8b 100644 --- a/src/insets/insetmarginal.C +++ b/src/insets/insetmarginal.C @@ -40,7 +40,7 @@ InsetMarginal::InsetMarginal(InsetMarginal const & in) } -auto_ptr InsetMarginal::clone() const +auto_ptr InsetMarginal::doClone() const { return auto_ptr(new InsetMarginal(*this)); } diff --git a/src/insets/insetmarginal.h b/src/insets/insetmarginal.h index bc51d73756..36d395d409 100644 --- a/src/insets/insetmarginal.h +++ b/src/insets/insetmarginal.h @@ -24,16 +24,16 @@ public: /// InsetMarginal(BufferParams const &); /// - InsetMarginal(InsetMarginal const &); - /// - virtual std::auto_ptr clone() const; - /// InsetOld::Code lyxCode() const { return InsetOld::MARGIN_CODE; } /// int latex(Buffer const &, std::ostream &, OutputParams const &) const; /// std::string const editMessage() const; +protected: + InsetMarginal(InsetMarginal const &); +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/insets/insetnewline.h b/src/insets/insetnewline.h index e3b3879609..8f9589c7af 100644 --- a/src/insets/insetnewline.h +++ b/src/insets/insetnewline.h @@ -20,10 +20,6 @@ public: InsetNewline() {} - virtual std::auto_ptr clone() const { - return std::auto_ptr(new InsetNewline); - } - InsetOld::Code lyxCode() const { return InsetOld::NEWLINE_CODE; } void metrics(MetricsInfo &, Dimension &) const; @@ -50,6 +46,11 @@ public: /// is this equivalent to a space (which is BTW different from // a line separator)? bool isSpace() const; +private: + virtual std::auto_ptr doClone() const + { + return std::auto_ptr(new InsetNewline); + } }; #endif // INSET_NEWLINE_H diff --git a/src/insets/insetnote.C b/src/insets/insetnote.C index 3be5403fb5..ec0eb9018d 100644 --- a/src/insets/insetnote.C +++ b/src/insets/insetnote.C @@ -123,7 +123,7 @@ InsetNote::~InsetNote() } -auto_ptr InsetNote::clone() const +auto_ptr InsetNote::doClone() const { return auto_ptr(new InsetNote(*this)); } diff --git a/src/insets/insetnote.h b/src/insets/insetnote.h index 65d05ce4cc..9f46783116 100644 --- a/src/insets/insetnote.h +++ b/src/insets/insetnote.h @@ -39,13 +39,9 @@ class InsetNote : public InsetCollapsable { public: /// InsetNote(BufferParams const &, std::string const &); - /// Copy constructor - InsetNote(InsetNote const &); /// ~InsetNote(); /// - virtual std::auto_ptr clone() const; - /// std::string const editMessage() const; /// InsetOld::Code lyxCode() const { return InsetOld::NOTE_CODE; } @@ -74,11 +70,14 @@ public: /// InsetNoteParams const & params() const { return params_; } protected: + InsetNote(InsetNote const &); /// virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd); private: friend class InsetNoteParams; + virtual std::auto_ptr doClone() const; + /// used by the constructors void init(); /// diff --git a/src/insets/insetoptarg.C b/src/insets/insetoptarg.C index 9c2d88c75a..6b889fd726 100644 --- a/src/insets/insetoptarg.C +++ b/src/insets/insetoptarg.C @@ -45,7 +45,7 @@ InsetOptArg::InsetOptArg(InsetOptArg const & in) } -auto_ptr InsetOptArg::clone() const +auto_ptr InsetOptArg::doClone() const { return auto_ptr(new InsetOptArg(*this)); } diff --git a/src/insets/insetoptarg.h b/src/insets/insetoptarg.h index 0b2deee38b..2dc95bc471 100644 --- a/src/insets/insetoptarg.h +++ b/src/insets/insetoptarg.h @@ -24,9 +24,6 @@ class InsetOptArg : public InsetCollapsable { public: InsetOptArg(BufferParams const &); - InsetOptArg(InsetOptArg const &); - /// make a duplicate of this inset - virtual std::auto_ptr clone() const; /// code of the inset InsetOld::Code lyxCode() const { return InsetOld::OPTARG_CODE; } /// return an message upon editing @@ -40,6 +37,10 @@ public: OutputParams const &) const; /// Write out tothe .lyx file void write(Buffer const & buf, std::ostream & os) const; +protected: + InsetOptArg(InsetOptArg const &); +private: + virtual std::auto_ptr doClone() const; }; #endif // INSETOPTARG_H diff --git a/src/insets/insetpagebreak.h b/src/insets/insetpagebreak.h index bbcda78522..ca0440cdeb 100644 --- a/src/insets/insetpagebreak.h +++ b/src/insets/insetpagebreak.h @@ -20,10 +20,6 @@ public: InsetPagebreak() {} - std::auto_ptr clone() const { - return std::auto_ptr(new InsetPagebreak); - } - InsetOld::Code lyxCode() const { return InsetOld::LINE_CODE; } void metrics(MetricsInfo &, Dimension &) const; @@ -49,6 +45,11 @@ public: bool directWrite() const { return true; } bool display() const { return true; } +private: + virtual std::auto_ptr doClone() const + { + return std::auto_ptr(new InsetPagebreak); + } }; #endif // INSET_NEWLINE_H diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index ffbe7286c4..3b548cd69d 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -365,7 +365,7 @@ void InsetQuotes::validate(LaTeXFeatures & features) const } -auto_ptr InsetQuotes::clone() const +auto_ptr InsetQuotes::doClone() const { return auto_ptr(new InsetQuotes(language_, side_, times_)); } diff --git a/src/insets/insetquotes.h b/src/insets/insetquotes.h index f8d453b983..c88dfeb8bf 100644 --- a/src/insets/insetquotes.h +++ b/src/insets/insetquotes.h @@ -70,8 +70,6 @@ public: /// Direct access to inner/outer quotation marks InsetQuotes(char c, quote_language l, quote_times t); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -103,6 +101,8 @@ public: bool isChar() const { return true; } private: + virtual std::auto_ptr doClone() const; + /// quote_language language_; /// diff --git a/src/insets/insetref.h b/src/insets/insetref.h index 239d3317f0..f5fcd2bc77 100644 --- a/src/insets/insetref.h +++ b/src/insets/insetref.h @@ -35,12 +35,6 @@ public: InsetRef(InsetCommandParams const &, Buffer const &); - InsetRef(InsetRef const &); - - /// - virtual std::auto_ptr clone() const { - return std::auto_ptr(new InsetRef(*this)); - } /// std::string const getScreenLabel(Buffer const &) const; /// @@ -64,9 +58,14 @@ public: /// void validate(LaTeXFeatures & features) const; protected: + InsetRef(InsetRef const &); + /// void priv_dispatch(LCursor & cur, FuncRequest & cmd); private: + virtual std::auto_ptr doClone() const { + return std::auto_ptr(new InsetRef(*this)); + } /// bool isLatex; }; diff --git a/src/insets/insetspace.C b/src/insets/insetspace.C index 11cc7925e1..ef95d15d79 100644 --- a/src/insets/insetspace.C +++ b/src/insets/insetspace.C @@ -255,7 +255,7 @@ int InsetSpace::docbook(Buffer const &, ostream & os, } -auto_ptr InsetSpace::clone() const +auto_ptr InsetSpace::doClone() const { return auto_ptr(new InsetSpace(kind_)); } diff --git a/src/insets/insetspace.h b/src/insets/insetspace.h index eb87db4acb..cd9d813f86 100644 --- a/src/insets/insetspace.h +++ b/src/insets/insetspace.h @@ -73,8 +73,6 @@ public: int docbook(Buffer const &, std::ostream &, OutputParams const &) const; /// - virtual std::auto_ptr clone() const; - /// InsetOld::Code lyxCode() const { return InsetOld::SPACE_CODE; } /// We don't need \begin_inset and \end_inset bool directWrite() const { return true; } @@ -87,6 +85,8 @@ public: // a line separator)? bool isSpace() const; private: + virtual std::auto_ptr doClone() const; + /// And which kind is this? Kind kind_; }; diff --git a/src/insets/insetspecialchar.C b/src/insets/insetspecialchar.C index c9ea76abe5..528abb78bb 100644 --- a/src/insets/insetspecialchar.C +++ b/src/insets/insetspecialchar.C @@ -243,7 +243,7 @@ int InsetSpecialChar::docbook(Buffer const &, ostream & os, } -auto_ptr InsetSpecialChar::clone() const +auto_ptr InsetSpecialChar::doClone() const { return auto_ptr(new InsetSpecialChar(kind_)); } diff --git a/src/insets/insetspecialchar.h b/src/insets/insetspecialchar.h index 2dadf74798..6f6c607518 100644 --- a/src/insets/insetspecialchar.h +++ b/src/insets/insetspecialchar.h @@ -65,8 +65,6 @@ public: int docbook(Buffer const &, std::ostream &, OutputParams const &) const; /// - virtual std::auto_ptr clone() const; - /// InsetOld::Code lyxCode() const { return InsetOld::SPECIALCHAR_CODE; } /// We don't need \begin_inset and \end_inset bool directWrite() const { return true; } @@ -80,6 +78,8 @@ public: // should we break lines after this inset? bool isLineSeparator() const; private: + virtual std::auto_ptr doClone() const; + /// And which kind is this? Kind kind_; }; diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 77560cc055..f283968386 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -46,6 +46,8 @@ using lyx::support::ltrim; using lyx::support::strToInt; using lyx::support::strToDbl; +using boost::shared_ptr; + using std::auto_ptr; using std::endl; using std::max; @@ -170,7 +172,7 @@ InsetTabular::~InsetTabular() } -auto_ptr InsetTabular::clone() const +auto_ptr InsetTabular::doClone() const { return auto_ptr(new InsetTabular(*this)); } @@ -239,7 +241,7 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const if (!p_width.zero()) { m.base.textwidth = p_width.inPixels(mi.base.textwidth); } - tabular.getCellInset(cell).metrics(m, dim); + tabular.getCellInset(cell)->metrics(m, dim); maxAsc = max(maxAsc, dim.asc); maxDesc = max(maxDesc, dim.des); tabular.setWidthOfCell(cell, dim.wid); @@ -288,7 +290,7 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const drawCellSelection(pi, nx, y, i, j, idx); int const cx = nx + tabular.getBeginningOfTextInCell(idx); - cell(idx).draw(pi, cx, y); + cell(idx)->draw(pi, cx, y); drawCellLines(pi.pain, nx, y, i, idx); nx += tabular.getWidthOfColumn(idx); ++idx; @@ -475,7 +477,7 @@ void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest & cmd) case LFUN_RIGHTSEL: case LFUN_RIGHT: - cell(cur.idx()).dispatch(cur, cmd); + cell(cur.idx())->dispatch(cur, cmd); cur.dispatched(); // override the cell's decision if (sl == cur.top()) isRightToLeft(cur) ? movePrevCell(cur) : moveNextCell(cur); @@ -487,7 +489,7 @@ void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest & cmd) case LFUN_LEFTSEL: case LFUN_LEFT: - cell(cur.idx()).dispatch(cur, cmd); + cell(cur.idx())->dispatch(cur, cmd); cur.dispatched(); // override the cell's decision if (sl == cur.top()) isRightToLeft(cur) ? moveNextCell(cur) : movePrevCell(cur); @@ -499,7 +501,7 @@ void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest & cmd) case LFUN_DOWNSEL: case LFUN_DOWN: - cell(cur.idx()).dispatch(cur, cmd); + cell(cur.idx())->dispatch(cur, cmd); cur.dispatched(); // override the cell's decision if (sl == cur.top()) if (tabular.row_of_cell(cur.idx()) != tabular.rows() - 1) { @@ -516,7 +518,7 @@ void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest & cmd) case LFUN_UPSEL: case LFUN_UP: - cell(cur.idx()).dispatch(cur, cmd); + cell(cur.idx())->dispatch(cur, cmd); cur.dispatched(); // override the cell's decision if (sl == cur.top()) if (tabular.row_of_cell(cur.idx()) != 0) { @@ -584,7 +586,7 @@ void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest & cmd) // insert file functions case LFUN_FILE_INSERT_ASCII_PARA: case LFUN_FILE_INSERT_ASCII: { - string tmpstr = getContentsOfAsciiFile(&cur.bv(), cmd.argument, false); + string const tmpstr = getContentsOfAsciiFile(&cur.bv(), cmd.argument, false); if (!tmpstr.empty() && !insertAsciiString(cur.bv(), tmpstr, false)) cur.undispatched(); break; @@ -603,7 +605,7 @@ void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest & cmd) if (tablemode(cur)) cutSelection(cur); else - cell(cur.idx()).dispatch(cur, cmd); + cell(cur.idx())->dispatch(cur, cmd); break; case LFUN_COPY: @@ -645,7 +647,7 @@ void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest & cmd) string::size_type op = 0; int cell = 0; - int cells = paste_tabular->getNumberOfCells(); + int const cells = paste_tabular->getNumberOfCells(); cols = 0; LyXFont font; for (size_t p = 0; cell < cells && p < len; ++p) { @@ -654,13 +656,13 @@ void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest & cmd) break; switch (clip[p]) { case '\t': - paste_tabular->getCellInset(cell). + paste_tabular->getCellInset(cell)-> setText(clip.substr(op, p - op), font); ++cols; ++cell; break; case '\n': - paste_tabular->getCellInset(cell). + paste_tabular->getCellInset(cell)-> setText(clip.substr(op, p - op), font); while (cols++ < maxCols) ++cell; @@ -671,7 +673,7 @@ void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest & cmd) } // check for the last cell if there is no trailing '\n' if (cell < cells && op < len) - paste_tabular->getCellInset(cell). + paste_tabular->getCellInset(cell)-> setText(clip.substr(op, len - op), font); } else if (!insertAsciiString(cur.bv(), clip, true)) { // so that the clipboard is used and it goes on @@ -688,12 +690,12 @@ void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest & cmd) pasteSelection(cur); break; } - cell(cur.idx()).dispatch(cur, cmd); + cell(cur.idx())->dispatch(cur, cmd); break; default: // we try to handle this event in the insets dispatch function. - cell(cur.idx()).dispatch(cur, cmd); + cell(cur.idx())->dispatch(cur, cmd); break; } @@ -878,7 +880,7 @@ bool InsetTabular::getStatus(LCursor & cur, FuncRequest const & cmd, default: // we try to handle this event in the insets dispatch function. - return cell(cur.idx()).getStatus(cur, cmd, status); + return cell(cur.idx())->getStatus(cur, cmd, status); } } @@ -893,7 +895,7 @@ int InsetTabular::latex(Buffer const & buf, ostream & os, int InsetTabular::plaintext(Buffer const & buf, ostream & os, OutputParams const & runparams) const { - int dp = runparams.linelen ? runparams.depth : 0; + int const dp = runparams.linelen ? runparams.depth : 0; return tabular.plaintext(buf, os, runparams, dp, false, 0); } @@ -941,13 +943,13 @@ void InsetTabular::validate(LaTeXFeatures & features) const } -InsetText const & InsetTabular::cell(int idx) const +shared_ptr InsetTabular::cell(int idx) const { return tabular.getCellInset(idx); } -InsetText & InsetTabular::cell(int idx) +shared_ptr InsetTabular::cell(int idx) { return tabular.getCellInset(idx); } @@ -955,7 +957,7 @@ InsetText & InsetTabular::cell(int idx) void InsetTabular::getCursorPos(LCursor const & cur, int & x, int & y) const { - cell(cur.idx()).getCursorPos(cur, x, y); + cell(cur.idx())->getCursorPos(cur, x, y); } @@ -972,13 +974,13 @@ InsetBase * InsetTabular::setPos(LCursor & cur, int x, int y) const } } cur.idx() = idx_min; - InsetBase * inset = cell(cur.idx()).text_.editXY(cur, x, y); + InsetBase * inset = cell(cur.idx())->text_.editXY(cur, x, y); //lyxerr << "# InsetTabular::setPos()\n" << cur << endl; return inset; } -int InsetTabular::getCellXPos(int cell) const +int InsetTabular::getCellXPos(int const cell) const { int c = cell; @@ -1026,7 +1028,7 @@ void InsetTabular::moveNextCell(LCursor & cur) if (isRightToLeft(cur)) { lyxerr << "InsetTabular::moveNextCell A cur: " << endl; if (tabular.isFirstCellInRow(cur.idx())) { - int row = tabular.row_of_cell(cur.idx()); + int const row = tabular.row_of_cell(cur.idx()); if (row == tabular.rows() - 1) return; cur.idx() = tabular.getCellBelow(tabular.getLastCellInRow(row)); @@ -1052,7 +1054,7 @@ void InsetTabular::movePrevCell(LCursor & cur) { if (isRightToLeft(cur)) { if (tabular.isLastCellInRow(cur.idx())) { - int row = tabular.row_of_cell(cur.idx()); + int const row = tabular.row_of_cell(cur.idx()); if (row == 0) return; cur.idx() = tabular.getFirstCellInRow(row); @@ -1176,8 +1178,8 @@ void InsetTabular::tabularFeatures(LCursor & cur, recordUndo(cur, Undo::ATOMIC); getSelection(cur, sel_row_start, sel_row_end, sel_col_start, sel_col_end); - int row = tabular.row_of_cell(cur.idx()); - int column = tabular.column_of_cell(cur.idx()); + int const row = tabular.row_of_cell(cur.idx()); + int const column = tabular.column_of_cell(cur.idx()); bool flag = true; LyXTabular::ltType ltt; @@ -1517,8 +1519,8 @@ bool InsetTabular::pasteSelection(LCursor & cur) { if (!paste_tabular) return false; - int actcol = tabular.column_of_cell(cur.idx()); - int actrow = tabular.row_of_cell(cur.idx()); + int const actcol = tabular.column_of_cell(cur.idx()); + int const actrow = tabular.row_of_cell(cur.idx()); for (int r1 = 0, r2 = actrow; r1 < paste_tabular->rows() && r2 < tabular.rows(); ++r1, ++r2) { @@ -1536,9 +1538,9 @@ bool InsetTabular::pasteSelection(LCursor & cur) --c1; continue; } - InsetText & inset = tabular.getCellInset(r2, c2); + shared_ptr inset = tabular.getCellInset(r2, c2); inset = paste_tabular->getCellInset(r1, c1); - inset.markNew(); + inset->markNew(); } } return true; @@ -1555,7 +1557,7 @@ void InsetTabular::cutSelection(LCursor & cur) getSelection(cur, rs, re, cs, ce); for (int i = rs; i <= re; ++i) for (int j = cs; j <= ce; ++j) - cell(tabular.getCellNumber(i, j)).clear(track); + cell(tabular.getCellNumber(i, j))->clear(track); // cursor position might be invalid now cur.pos() = cur.lastpos(); @@ -1602,21 +1604,21 @@ size_t InsetTabular::nargs() const LyXText * InsetTabular::getText(int idx) const { - return size_t(idx) < nargs() ? cell(idx).getText(0) : 0; + return size_t(idx) < nargs() ? cell(idx)->getText(0) : 0; } void InsetTabular::markErased() { for (idx_type idx = 0; idx < nargs(); ++idx) - cell(idx).markErased(); + cell(idx)->markErased(); } bool InsetTabular::forceDefaultParagraphs(InsetBase const *) const { #if 0 - const int cell = tabular.getCellFromInset(in); + int const cell = tabular.getCellFromInset(in); if (cell != -1) return tabular.getPWidth(cell).zero(); @@ -1643,7 +1645,7 @@ bool InsetTabular::insertAsciiString(BufferView & bv, string const & buf, int cols = 1; int rows = 1; int maxCols = 1; - string::size_type len = buf.length(); + string::size_type const len = buf.length(); string::size_type p = 0; while (p < len && (p = buf.find_first_of("\t\n", p)) != string::npos) { @@ -1678,7 +1680,7 @@ bool InsetTabular::insertAsciiString(BufferView & bv, string const & buf, } string::size_type op = 0; - int cells = loctab->getNumberOfCells(); + int const cells = loctab->getNumberOfCells(); p = 0; cols = ocol; rows = loctab->rows(); @@ -1693,10 +1695,10 @@ bool InsetTabular::insertAsciiString(BufferView & bv, string const & buf, case '\t': // we can only set this if we are not too far right if (cols < columns) { - InsetText & inset = loctab->getCellInset(cell); - Paragraph & par = inset.text_.getPar(0); - LyXFont const font = inset.text_.getFont(par, 0); - inset.setText(buf.substr(op, p - op), font); + shared_ptr inset = loctab->getCellInset(cell); + Paragraph & par = inset->text_.getPar(0); + LyXFont const font = inset->text_.getFont(par, 0); + inset->setText(buf.substr(op, p - op), font); ++cols; ++cell; } @@ -1704,10 +1706,10 @@ bool InsetTabular::insertAsciiString(BufferView & bv, string const & buf, case '\n': // we can only set this if we are not too far right if (cols < columns) { - InsetText & inset = tabular.getCellInset(cell); - Paragraph & par = inset.text_.getPar(0); - LyXFont const font = inset.text_.getFont(par, 0); - inset.setText(buf.substr(op, p - op), font); + shared_ptr inset = tabular.getCellInset(cell); + Paragraph & par = inset->text_.getPar(0); + LyXFont const font = inset->text_.getFont(par, 0); + inset->setText(buf.substr(op, p - op), font); } cols = ocol; ++row; @@ -1720,10 +1722,10 @@ bool InsetTabular::insertAsciiString(BufferView & bv, string const & buf, } // check for the last cell if there is no trailing '\n' if (cell < cells && op < len) { - InsetText & inset = loctab->getCellInset(cell); - Paragraph & par = inset.text_.getPar(0); - LyXFont const font = inset.text_.getFont(par, 0); - inset.setText(buf.substr(op, len - op), font); + shared_ptr inset = loctab->getCellInset(cell); + Paragraph & par = inset->text_.getPar(0); + LyXFont const font = inset->text_.getFont(par, 0); + inset->setText(buf.substr(op, len - op), font); } return true; } @@ -1735,7 +1737,7 @@ void InsetTabular::addPreview(PreviewLoader & loader) const int const columns = tabular.columns(); for (int i = 0; i < rows; ++i) { for (int j = 0; j < columns; ++j) - tabular.getCellInset(i, j).addPreview(loader); + tabular.getCellInset(i, j)->addPreview(loader); } } diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index ec48c8ae6b..54e279e3d2 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -50,12 +50,8 @@ public: /// InsetTabular(Buffer const &, int rows = 1, int columns = 1); /// - InsetTabular(InsetTabular const &); - /// ~InsetTabular(); /// - virtual std::auto_ptr clone() const; - /// void read(Buffer const &, LyXLex &); /// void write(Buffer const &, std::ostream &) const; @@ -66,7 +62,7 @@ public: /// std::string const editMessage() const; /// - bool insetAllowed(InsetOld::Code) const { return true; } + bool insetAllowed(InsetBase::Code) const { return true; } /// bool isTextInset() const { return true; } /** returns true if, when outputing LaTeX, font changes should @@ -90,7 +86,7 @@ public: /// void validate(LaTeXFeatures & features) const; /// - Code lyxCode() const { return InsetOld::TABULAR_CODE; } + Code lyxCode() const { return InsetBase::TABULAR_CODE; } /// get the absolute screen x,y of the cursor void getCursorPos(LCursor const & cur, int & x, int & y) const; /// @@ -107,9 +103,9 @@ public: /// number of cells size_t nargs() const; /// - InsetText const & cell(int) const; + boost::shared_ptr cell(int) const; /// - InsetText & cell(int); + boost::shared_ptr cell(int); /// LyXText * getText(int) const; @@ -141,11 +137,14 @@ public: mutable LyXTabular tabular; protected: + InsetTabular(InsetTabular const &); /// void priv_dispatch(LCursor & cur, FuncRequest & cmd); /// bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const; private: + virtual std::auto_ptr doClone() const; + /// void drawCellLines(Painter &, int x, int baseline, int row, int cell) const; diff --git a/src/insets/insettext.C b/src/insets/insettext.C index ba6feb7617..7ac46bc85c 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -59,6 +59,9 @@ using lyx::graphics::PreviewLoader; using lyx::support::isStrUnsignedInt; using lyx::support::strToUnsignedInt; +using boost::bind; +using boost::ref; + using std::endl; using std::for_each; using std::max; @@ -83,33 +86,22 @@ InsetText::InsetText(BufferParams const & bp) InsetText::InsetText(InsetText const & in) : UpdatableInset(in), text_(in.text_.bv_owner) { - // this is ugly... - operator=(in); -} - - -InsetText::InsetText() : text_(0) -{} - - -void InsetText::operator=(InsetText const & in) -{ - UpdatableInset::operator=(in); autoBreakRows_ = in.autoBreakRows_; drawFrame_ = in.drawFrame_; frame_color_ = in.frame_color_; - text_ = LyXText(in.text_.bv_owner); text_.paragraphs() = in.text_.paragraphs(); init(); } +InsetText::InsetText() : text_(0) +{} + + void InsetText::init() { - ParagraphList::iterator pit = paragraphs().begin(); - ParagraphList::iterator end = paragraphs().end(); - for (; pit != end; ++pit) - pit->setInsetOwner(this); + for_each(paragraphs().begin(), paragraphs().end(), + bind(&Paragraph::setInsetOwner, _1, this)); old_par = -1; } @@ -118,10 +110,8 @@ void InsetText::clear(bool just_mark_erased) { ParagraphList & pars = paragraphs(); if (just_mark_erased) { - ParagraphList::iterator it = pars.begin(); - ParagraphList::iterator end = pars.end(); - for (; it != end; ++it) - it->markErased(); + for_each(pars.begin(), pars.end(), + bind(&Paragraph::markErased, _1)); return; } @@ -135,7 +125,7 @@ void InsetText::clear(bool just_mark_erased) } -auto_ptr InsetText::clone() const +auto_ptr InsetText::doClone() const { return auto_ptr(new InsetText(*this)); } @@ -336,7 +326,7 @@ int InsetText::plaintext(Buffer const & buf, ostream & os, for (; it != end; ++it) asciiParagraph(buf, *it, os, runparams, it == beg); - //FIXME: Give the total numbers of lines + // FIXME: Give the total numbers of lines return 0; } @@ -360,7 +350,7 @@ int InsetText::docbook(Buffer const & buf, ostream & os, void InsetText::validate(LaTeXFeatures & features) const { for_each(paragraphs().begin(), paragraphs().end(), - boost::bind(&Paragraph::validate, _1, boost::ref(features))); + bind(&Paragraph::validate, _1, ref(features))); } @@ -409,8 +399,9 @@ void InsetText::markNew(bool track_changes) void InsetText::setText(string const & data, LyXFont const & font) { clear(false); + Paragraph & first = paragraphs().front(); for (unsigned int i = 0; i < data.length(); ++i) - paragraphs().begin()->insertChar(i, data[i], font); + first.insertChar(i, data[i], font); } @@ -476,15 +467,15 @@ void InsetText::appendParagraphs(Buffer * buffer, ParagraphList & plist) // And it probably does. You have to take a look at this John. (Lgb) #warning John, have a look here. (Lgb) #endif + ParagraphList & pl = paragraphs(); + ParagraphList::iterator pit = plist.begin(); - ParagraphList::iterator ins = paragraphs().insert(paragraphs().end(), *pit); + ParagraphList::iterator ins = pl.insert(pl.end(), *pit); ++pit; - mergeParagraph(buffer->params(), paragraphs(), - ins - paragraphs().begin() - 1); + mergeParagraph(buffer->params(), pl, ins - pl.begin() - 1); - ParagraphList::iterator pend = plist.end(); - for (; pit != pend; ++pit) - paragraphs().push_back(*pit); + for_each(pit, plist.end(), + bind(&ParagraphList::push_back, ref(pl), _1)); } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index fe4e93230c..65b1f6ded1 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -41,13 +41,7 @@ public: /// explicit InsetText(BufferParams const &); /// - explicit InsetText(); - /// - InsetText(InsetText const &); - /// - virtual std::auto_ptr clone() const; - /// - void operator=(InsetText const & it); + InsetText(); /// empty inset to empty par, or just mark as erased void clear(bool just_mark_erased); /// @@ -79,7 +73,7 @@ public: /// void validate(LaTeXFeatures & features) const; /// - InsetOld::Code lyxCode() const { return InsetOld::TEXT_CODE; } + Code lyxCode() const { return TEXT_CODE; } /// FIXME, document void getCursorPos(LCursor const & cur, int & x, int & y) const; /// @@ -143,9 +137,12 @@ public: bool allowSpellCheck() const { return true; } protected: + InsetText(InsetText const &); /// void priv_dispatch(LCursor & cur, FuncRequest & cmd); private: + virtual std::auto_ptr doClone() const; + /// void updateLocal(LCursor &); /// diff --git a/src/insets/insettheorem.C b/src/insets/insettheorem.C index 9f1ee9f0a0..92e1f7789f 100644 --- a/src/insets/insettheorem.C +++ b/src/insets/insettheorem.C @@ -56,7 +56,7 @@ void InsetTheorem::write(Buffer const * buf, ostream & os) const } -auto_ptr InsetTheorem::clone() const +auto_ptr InsetTheorem::doClone() const { #ifdef WITH_WARNINGS #warning Is this inset used? If YES this is WRONG!!! (Jug) diff --git a/src/insets/insettheorem.h b/src/insets/insettheorem.h index ce91284428..b4e00a9d73 100644 --- a/src/insets/insettheorem.h +++ b/src/insets/insettheorem.h @@ -25,8 +25,6 @@ public: /// void write(Buffer const & buf, std::ostream & os) const; /// - virtual InsetBase * clone() const; - /// Inset::Code lyxCode() const { return Inset::THEOREM_CODE; } /// void metrics(MetricsInfo &, Dimension &) const; @@ -38,6 +36,8 @@ public: /// string const editMessage() const; private: + virtual std::auto_ptr doClone() const; + /// mutable unsigned int center_indent_; }; diff --git a/src/insets/insettoc.C b/src/insets/insettoc.C index fa91fa2855..c109646a39 100644 --- a/src/insets/insettoc.C +++ b/src/insets/insettoc.C @@ -30,7 +30,7 @@ InsetTOC::InsetTOC(InsetCommandParams const & p) {} -std::auto_ptr InsetTOC::clone() const +std::auto_ptr InsetTOC::doClone() const { return std::auto_ptr(new InsetTOC(*this)); } diff --git a/src/insets/insettoc.h b/src/insets/insettoc.h index 98813a7f1a..2adb8a4472 100644 --- a/src/insets/insettoc.h +++ b/src/insets/insettoc.h @@ -21,8 +21,6 @@ public: /// explicit InsetTOC(InsetCommandParams const &); /// - std::auto_ptr clone() const; - /// std::string const getScreenLabel(Buffer const &) const; /// EDITABLE editable() const { return IS_EDITABLE; } @@ -39,6 +37,8 @@ public: /// int docbook(Buffer const &, std::ostream &, OutputParams const &) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/insets/inseturl.h b/src/insets/inseturl.h index 3f30120b32..24f55a846c 100644 --- a/src/insets/inseturl.h +++ b/src/insets/inseturl.h @@ -25,10 +25,6 @@ public: explicit InsetUrl(InsetCommandParams const &); /// - virtual std::auto_ptr clone() const { - return std::auto_ptr(new InsetUrl(params())); - } - /// InsetOld::Code lyxCode() const { return InsetOld::URL_CODE; } /// void validate(LaTeXFeatures &) const; @@ -50,6 +46,10 @@ public: /// int docbook(Buffer const &, std::ostream &, OutputParams const &) const; +private: + virtual std::auto_ptr doClone() const { + return std::auto_ptr(new InsetUrl(params())); + } }; #endif diff --git a/src/insets/insetvspace.C b/src/insets/insetvspace.C index 5946dd70e2..368d1a259b 100644 --- a/src/insets/insetvspace.C +++ b/src/insets/insetvspace.C @@ -54,7 +54,7 @@ InsetVSpace::~InsetVSpace() } -std::auto_ptr InsetVSpace::clone() const +std::auto_ptr InsetVSpace::doClone() const { return std::auto_ptr(new InsetVSpace(*this)); } diff --git a/src/insets/insetvspace.h b/src/insets/insetvspace.h index b7e0ef4446..e12046ece0 100644 --- a/src/insets/insetvspace.h +++ b/src/insets/insetvspace.h @@ -26,8 +26,6 @@ public: /// ~InsetVSpace(); /// - std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -57,6 +55,8 @@ protected: virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd); private: + virtual std::auto_ptr doClone() const; + /// VSpace space_; }; diff --git a/src/insets/insetwrap.C b/src/insets/insetwrap.C index 0fa0ad5306..60f264e69b 100644 --- a/src/insets/insetwrap.C +++ b/src/insets/insetwrap.C @@ -169,7 +169,7 @@ void InsetWrap::validate(LaTeXFeatures & features) const } -auto_ptr InsetWrap::clone() const +auto_ptr InsetWrap::doClone() const { return auto_ptr(new InsetWrap(*this)); } diff --git a/src/insets/insetwrap.h b/src/insets/insetwrap.h index bfd3f59c01..7ed0dc42a5 100644 --- a/src/insets/insetwrap.h +++ b/src/insets/insetwrap.h @@ -47,8 +47,6 @@ public: /// void validate(LaTeXFeatures & features) const; /// - virtual std::auto_ptr clone() const; - /// InsetOld::Code lyxCode() const { return InsetOld::WRAP_CODE; } /// int latex(Buffer const &, std::ostream &, @@ -70,6 +68,8 @@ protected: /// virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd); private: + virtual std::auto_ptr doClone() const; + /// InsetWrapParams params_; }; diff --git a/src/insets/render_base.h b/src/insets/render_base.h index 23a5e9af43..ba9221fbf7 100644 --- a/src/insets/render_base.h +++ b/src/insets/render_base.h @@ -45,7 +45,7 @@ public: protected: RenderBase() {} RenderBase(RenderBase const &) {} - void operator=(RenderBase const &) {} + RenderBase & operator=(RenderBase const &) { return *this; } /// Cached mutable Dimension dim_; diff --git a/src/insets/render_preview.h b/src/insets/render_preview.h index 46ebf16cdb..b525f86331 100644 --- a/src/insets/render_preview.h +++ b/src/insets/render_preview.h @@ -84,7 +84,7 @@ public: private: /// Not implemented. - void operator=(RenderPreview const &); + RenderPreview & operator=(RenderPreview const &); /// This method is connected to the PreviewLoader::imageReady signal. void imageReady(lyx::graphics::PreviewImage const &); diff --git a/src/lyxlength.h b/src/lyxlength.h index 2b0f33e6a7..78416cbefd 100644 --- a/src/lyxlength.h +++ b/src/lyxlength.h @@ -53,6 +53,12 @@ public: /// "data" must be a decimal number, followed by a unit explicit LyXLength(std::string const & data); + void swap(LyXLength & rhs) + { + std::swap(val_, rhs.val_); + std::swap(unit_, rhs.unit_); + } + /// double value() const; /// diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index c640f2015f..5bd6636eb1 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,13 @@ +2004-11-24 Lars Gullik Bjonnes + + * math_hullinset.C (operator): use common semantics + +2004-11-23 Lars Gullik Bjonnes + + * math_atom.C (operator): use common semantics + + * Adjust for clone changes + 2004-11-22 Georg Baum * math_hullinset.[Ch] (rowChangeOK): new diff --git a/src/mathed/command_inset.C b/src/mathed/command_inset.C index 076dfd34b9..3e4c7f4055 100644 --- a/src/mathed/command_inset.C +++ b/src/mathed/command_inset.C @@ -30,7 +30,7 @@ CommandInset::CommandInset(string const & name) } -auto_ptr CommandInset::clone() const +auto_ptr CommandInset::doClone() const { return auto_ptr(new CommandInset(*this)); } diff --git a/src/mathed/command_inset.h b/src/mathed/command_inset.h index ffec6a7625..b0de073df5 100644 --- a/src/mathed/command_inset.h +++ b/src/mathed/command_inset.h @@ -24,8 +24,6 @@ public: /// explicit CommandInset(std::string const & name); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -40,6 +38,8 @@ public: /// std::string const & commandname() const { return name_; } private: + virtual std::auto_ptr doClone() const; + /// std::string name_; /// diff --git a/src/mathed/math_amsarrayinset.C b/src/mathed/math_amsarrayinset.C index 6fdca3e708..448fd152a7 100644 --- a/src/mathed/math_amsarrayinset.C +++ b/src/mathed/math_amsarrayinset.C @@ -30,7 +30,7 @@ MathAMSArrayInset::MathAMSArrayInset(string const & name) {} -auto_ptr MathAMSArrayInset::clone() const +auto_ptr MathAMSArrayInset::doClone() const { return auto_ptr(new MathAMSArrayInset(*this)); } diff --git a/src/mathed/math_amsarrayinset.h b/src/mathed/math_amsarrayinset.h index 87c64ee868..6185a6c2a5 100644 --- a/src/mathed/math_amsarrayinset.h +++ b/src/mathed/math_amsarrayinset.h @@ -23,8 +23,6 @@ public: /// MathAMSArrayInset(std::string const & name); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pain, int x, int y) const; @@ -39,6 +37,7 @@ public: void normalize(NormalStream &) const; private: + virtual std::auto_ptr doClone() const; /// char const * name_left() const; /// diff --git a/src/mathed/math_arrayinset.C b/src/mathed/math_arrayinset.C index 28dc9e9569..1e1554d45c 100644 --- a/src/mathed/math_arrayinset.C +++ b/src/mathed/math_arrayinset.C @@ -69,7 +69,7 @@ MathArrayInset::MathArrayInset(string const & name, string const & str) } -auto_ptr MathArrayInset::clone() const +auto_ptr MathArrayInset::doClone() const { return auto_ptr(new MathArrayInset(*this)); } diff --git a/src/mathed/math_arrayinset.h b/src/mathed/math_arrayinset.h index dbd9fe3bc0..a61e7c036b 100644 --- a/src/mathed/math_arrayinset.h +++ b/src/mathed/math_arrayinset.h @@ -28,8 +28,6 @@ public: /// convienience constructor from whitespace/newline seperated data MathArrayInset(std::string const &, std::string const & str); /// - std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -48,6 +46,7 @@ public: void maple(MapleStream & os) const; private: + virtual std::auto_ptr doClone() const; /// std::string name_; }; diff --git a/src/mathed/math_atom.C b/src/mathed/math_atom.C index bd5cda75be..4b8259f1ff 100644 --- a/src/mathed/math_atom.C +++ b/src/mathed/math_atom.C @@ -34,12 +34,13 @@ MathAtom::MathAtom(MathAtom const & at) } -void MathAtom::operator=(MathAtom const & at) +MathAtom & MathAtom::operator=(MathAtom const & at) { if (&at == this) - return; + return *this; MathAtom tmp(at); swap(tmp.nucleus_, nucleus_); + return *this; } diff --git a/src/mathed/math_atom.h b/src/mathed/math_atom.h index 37553df1ed..e4e2ce99a4 100644 --- a/src/mathed/math_atom.h +++ b/src/mathed/math_atom.h @@ -55,7 +55,7 @@ public: /// we really need to clean up ~MathAtom(); /// assignment invokes nucleus_->clone() - void operator=(MathAtom const &); + MathAtom & operator=(MathAtom const &); /// access to the inset (checked with gprof) MathInset * nucleus() { return nucleus_; } MathInset const * nucleus() const { return nucleus_; } diff --git a/src/mathed/math_biginset.C b/src/mathed/math_biginset.C index c259c4cafa..ade63c123b 100644 --- a/src/mathed/math_biginset.C +++ b/src/mathed/math_biginset.C @@ -25,7 +25,7 @@ MathBigInset::MathBigInset(string const & name, string const & delim) {} -auto_ptr MathBigInset::clone() const +auto_ptr MathBigInset::doClone() const { return auto_ptr(new MathBigInset(*this)); } diff --git a/src/mathed/math_biginset.h b/src/mathed/math_biginset.h index df6899e234..f9547cc469 100644 --- a/src/mathed/math_biginset.h +++ b/src/mathed/math_biginset.h @@ -22,8 +22,6 @@ public: /// MathBigInset(std::string const & name, std::string const & delim); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -33,6 +31,7 @@ public: void normalize(NormalStream & os) const; private: + virtual std::auto_ptr doClone() const; /// size_type size() const; /// diff --git a/src/mathed/math_binominset.C b/src/mathed/math_binominset.C index 7e3016271a..7e89c8f3f3 100644 --- a/src/mathed/math_binominset.C +++ b/src/mathed/math_binominset.C @@ -25,7 +25,7 @@ MathBinomInset::MathBinomInset(bool choose) {} -auto_ptr MathBinomInset::clone() const +auto_ptr MathBinomInset::doClone() const { return auto_ptr(new MathBinomInset(*this)); } diff --git a/src/mathed/math_binominset.h b/src/mathed/math_binominset.h index ee2703c8cd..08a8985765 100644 --- a/src/mathed/math_binominset.h +++ b/src/mathed/math_binominset.h @@ -21,8 +21,6 @@ public: /// explicit MathBinomInset(bool choose = false); /// - virtual std::auto_ptr clone() const; - /// void write(WriteStream & os) const; /// void normalize(NormalStream &) const; @@ -31,6 +29,7 @@ public: /// void draw(PainterInfo &, int x, int y) const; private: + virtual std::auto_ptr doClone() const; /// int dw() const; /// diff --git a/src/mathed/math_boldsymbolinset.C b/src/mathed/math_boldsymbolinset.C index c17b3ff791..fc847197e4 100644 --- a/src/mathed/math_boldsymbolinset.C +++ b/src/mathed/math_boldsymbolinset.C @@ -24,7 +24,7 @@ MathBoldsymbolInset::MathBoldsymbolInset() {} -auto_ptr MathBoldsymbolInset::clone() const +auto_ptr MathBoldsymbolInset::doClone() const { return auto_ptr(new MathBoldsymbolInset(*this)); } diff --git a/src/mathed/math_boldsymbolinset.h b/src/mathed/math_boldsymbolinset.h index 489a122345..cb5a6eb046 100644 --- a/src/mathed/math_boldsymbolinset.h +++ b/src/mathed/math_boldsymbolinset.h @@ -21,8 +21,6 @@ public: /// MathBoldsymbolInset(); /// - std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -36,6 +34,8 @@ public: void write(WriteStream & os) const; /// void infoize(std::ostream & os) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_boxedinset.C b/src/mathed/math_boxedinset.C index df4f2a112d..d16e4b169c 100644 --- a/src/mathed/math_boxedinset.C +++ b/src/mathed/math_boxedinset.C @@ -29,7 +29,7 @@ MathBoxedInset::MathBoxedInset() {} -auto_ptr MathBoxedInset::clone() const +auto_ptr MathBoxedInset::doClone() const { return auto_ptr(new MathBoxedInset(*this)); } @@ -74,4 +74,3 @@ void MathBoxedInset::validate(LaTeXFeatures & features) const { features.require("amsmath"); } - diff --git a/src/mathed/math_boxedinset.h b/src/mathed/math_boxedinset.h index f41510f976..c87ade2aab 100644 --- a/src/mathed/math_boxedinset.h +++ b/src/mathed/math_boxedinset.h @@ -21,8 +21,6 @@ public: /// MathBoxedInset(); /// - std::auto_ptr clone() const; - /// void validate(LaTeXFeatures & features) const; /// void metrics(MetricsInfo & mi, Dimension & dim) const; @@ -34,6 +32,8 @@ public: void normalize(NormalStream & ns) const; /// void infoize(std::ostream & os) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_boxinset.C b/src/mathed/math_boxinset.C index 10e070c8b7..a5af582e8c 100644 --- a/src/mathed/math_boxinset.C +++ b/src/mathed/math_boxinset.C @@ -25,7 +25,7 @@ MathBoxInset::MathBoxInset(string const & name) {} -auto_ptr MathBoxInset::clone() const +auto_ptr MathBoxInset::doClone() const { return auto_ptr(new MathBoxInset(*this)); } diff --git a/src/mathed/math_boxinset.h b/src/mathed/math_boxinset.h index eef210737b..df9bcd6cff 100644 --- a/src/mathed/math_boxinset.h +++ b/src/mathed/math_boxinset.h @@ -26,8 +26,6 @@ public: /// explicit MathBoxInset(std::string const & name); /// - std::auto_ptr clone() const; - /// mode_type currentMode() const { return TEXT_MODE; } /// void metrics(MetricsInfo & mi, Dimension & dim) const; @@ -41,6 +39,7 @@ public: void infoize(std::ostream & os) const; private: + virtual std::auto_ptr doClone() const; /// std::string name_; }; diff --git a/src/mathed/math_braceinset.C b/src/mathed/math_braceinset.C index a23154cb2b..fe63f1b8b9 100644 --- a/src/mathed/math_braceinset.C +++ b/src/mathed/math_braceinset.C @@ -33,7 +33,7 @@ MathBraceInset::MathBraceInset(MathArray const & ar) } -auto_ptr MathBraceInset::clone() const +auto_ptr MathBraceInset::doClone() const { return auto_ptr(new MathBraceInset(*this)); } diff --git a/src/mathed/math_braceinset.h b/src/mathed/math_braceinset.h index 29bfd2524b..c6c0af1747 100644 --- a/src/mathed/math_braceinset.h +++ b/src/mathed/math_braceinset.h @@ -23,8 +23,6 @@ public: /// MathBraceInset(MathArray const & ar); /// - std::auto_ptr clone() const; - /// MathBraceInset const * asBraceInset() const { return this; } /// we write extra braces in any case... bool extraBraces() const { return true; } @@ -46,6 +44,8 @@ public: void mathmlize(MathMLStream &) const; /// void infoize(std::ostream & os) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_casesinset.C b/src/mathed/math_casesinset.C index eaea9c43f5..fc1b331628 100644 --- a/src/mathed/math_casesinset.C +++ b/src/mathed/math_casesinset.C @@ -25,7 +25,7 @@ MathCasesInset::MathCasesInset(row_type n) {} -auto_ptr MathCasesInset::clone() const +auto_ptr MathCasesInset::doClone() const { return auto_ptr(new MathCasesInset(*this)); } diff --git a/src/mathed/math_casesinset.h b/src/mathed/math_casesinset.h index 9ee1fa1a8a..cb93c6c41a 100644 --- a/src/mathed/math_casesinset.h +++ b/src/mathed/math_casesinset.h @@ -22,8 +22,6 @@ public: /// explicit MathCasesInset(row_type rows = 1u); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -38,6 +36,8 @@ public: void write(WriteStream & os) const; /// void validate(LaTeXFeatures & features) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_charinset.C b/src/mathed/math_charinset.C index 8578aa8148..2f64372ee7 100644 --- a/src/mathed/math_charinset.C +++ b/src/mathed/math_charinset.C @@ -51,7 +51,7 @@ MathCharInset::MathCharInset(char c) -auto_ptr MathCharInset::clone() const +auto_ptr MathCharInset::doClone() const { return auto_ptr(new MathCharInset(*this)); } diff --git a/src/mathed/math_charinset.h b/src/mathed/math_charinset.h index 76a1feab00..7c63e71dc0 100644 --- a/src/mathed/math_charinset.h +++ b/src/mathed/math_charinset.h @@ -21,8 +21,6 @@ public: /// explicit MathCharInset(char c); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -47,6 +45,7 @@ public: bool isRelOp() const; private: + virtual std::auto_ptr doClone() const; /// the character char char_; /// cached width diff --git a/src/mathed/math_colorinset.C b/src/mathed/math_colorinset.C index 5a87a63f85..4c48ea0745 100644 --- a/src/mathed/math_colorinset.C +++ b/src/mathed/math_colorinset.C @@ -28,7 +28,7 @@ MathColorInset::MathColorInset(bool oldstyle) {} -auto_ptr MathColorInset::clone() const +auto_ptr MathColorInset::doClone() const { return auto_ptr(new MathColorInset(*this)); } diff --git a/src/mathed/math_colorinset.h b/src/mathed/math_colorinset.h index 3f16f4e6d4..604fb08098 100644 --- a/src/mathed/math_colorinset.h +++ b/src/mathed/math_colorinset.h @@ -21,8 +21,6 @@ public: /// explicit MathColorInset(bool oldstyle); /// - std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// we write extra braces in any case... bool extraBraces() const { return true; } @@ -37,6 +35,7 @@ public: /// void infoize(std::ostream & os) const; private: + virtual std::auto_ptr doClone() const; /// width of '[' in current font mutable int w_; /// diff --git a/src/mathed/math_commentinset.C b/src/mathed/math_commentinset.C index 0d82240115..790871ccbe 100644 --- a/src/mathed/math_commentinset.C +++ b/src/mathed/math_commentinset.C @@ -32,7 +32,7 @@ MathCommentInset::MathCommentInset(string const & str) } -auto_ptr MathCommentInset::clone() const +auto_ptr MathCommentInset::doClone() const { return auto_ptr(new MathCommentInset(*this)); } diff --git a/src/mathed/math_commentinset.h b/src/mathed/math_commentinset.h index b08df8860c..509ae0c661 100644 --- a/src/mathed/math_commentinset.h +++ b/src/mathed/math_commentinset.h @@ -25,8 +25,6 @@ public: /// explicit MathCommentInset(std::string const &); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -47,5 +45,7 @@ public: void mathmlize(MathMLStream &) const; /// void infoize(std::ostream & os) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_decorationinset.C b/src/mathed/math_decorationinset.C index 25dd231ca4..d824ba585d 100644 --- a/src/mathed/math_decorationinset.C +++ b/src/mathed/math_decorationinset.C @@ -32,7 +32,7 @@ MathDecorationInset::MathDecorationInset(latexkeys const * key) } -auto_ptr MathDecorationInset::clone() const +auto_ptr MathDecorationInset::doClone() const { return auto_ptr(new MathDecorationInset(*this)); } diff --git a/src/mathed/math_decorationinset.h b/src/mathed/math_decorationinset.h index 37f8df1893..f6ede8de73 100644 --- a/src/mathed/math_decorationinset.h +++ b/src/mathed/math_decorationinset.h @@ -24,8 +24,6 @@ public: /// explicit MathDecorationInset(latexkeys const * key); /// - virtual std::auto_ptr clone() const; - /// void draw(PainterInfo &, int x, int y) const; /// void write(WriteStream & os) const; @@ -39,6 +37,7 @@ public: bool isScriptable() const; private: + virtual std::auto_ptr doClone() const; /// bool upper() const; /// diff --git a/src/mathed/math_deliminset.C b/src/mathed/math_deliminset.C index 549ea335a3..ee5dc03f93 100644 --- a/src/mathed/math_deliminset.C +++ b/src/mathed/math_deliminset.C @@ -64,7 +64,7 @@ MathDelimInset::MathDelimInset } -auto_ptr MathDelimInset::clone() const +auto_ptr MathDelimInset::doClone() const { return auto_ptr(new MathDelimInset(*this)); } diff --git a/src/mathed/math_deliminset.h b/src/mathed/math_deliminset.h index 5a59875854..23955f8d00 100644 --- a/src/mathed/math_deliminset.h +++ b/src/mathed/math_deliminset.h @@ -26,8 +26,6 @@ public: /// MathDelimInset(std::string const & left, std::string const & right, MathArray const &); /// - virtual std::auto_ptr clone() const; - /// MathDelimInset * asDelimInset() { return this; } /// MathDelimInset const * asDelimInset() const { return this; } @@ -61,6 +59,7 @@ public: /// std::string right_; private: + virtual std::auto_ptr doClone() const; /// mutable int dw_; }; diff --git a/src/mathed/math_dfracinset.C b/src/mathed/math_dfracinset.C index 33e3095735..3b0c76d280 100644 --- a/src/mathed/math_dfracinset.C +++ b/src/mathed/math_dfracinset.C @@ -28,7 +28,7 @@ MathDfracInset::MathDfracInset() {} -auto_ptr MathDfracInset::clone() const +auto_ptr MathDfracInset::doClone() const { return auto_ptr(new MathDfracInset(*this)); } diff --git a/src/mathed/math_dfracinset.h b/src/mathed/math_dfracinset.h index e1c91202f3..1a24b1b5e6 100644 --- a/src/mathed/math_dfracinset.h +++ b/src/mathed/math_dfracinset.h @@ -21,8 +21,6 @@ public: /// MathDfracInset(); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; @@ -32,6 +30,8 @@ public: void mathmlize(MathMLStream &) const; /// void validate(LaTeXFeatures & features) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_diffinset.C b/src/mathed/math_diffinset.C index 3d32081793..4b7cdac9ff 100644 --- a/src/mathed/math_diffinset.C +++ b/src/mathed/math_diffinset.C @@ -24,7 +24,7 @@ MathDiffInset::MathDiffInset() {} -auto_ptr MathDiffInset::clone() const +auto_ptr MathDiffInset::doClone() const { return auto_ptr(new MathDiffInset(*this)); } diff --git a/src/mathed/math_diffinset.h b/src/mathed/math_diffinset.h index 4eaeaf44f9..b25140ec4a 100644 --- a/src/mathed/math_diffinset.h +++ b/src/mathed/math_diffinset.h @@ -21,9 +21,7 @@ class MathDiffInset : public MathNestInset { public: /// - explicit MathDiffInset(); - /// - virtual std::auto_ptr clone() const; + MathDiffInset(); /// void addDer(MathArray const & der); /// @@ -41,6 +39,8 @@ public: void mathmlize(MathMLStream &) const; /// void write(WriteStream & os) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_dotsinset.C b/src/mathed/math_dotsinset.C index 8ab3afe6fe..1c7b4ff3a9 100644 --- a/src/mathed/math_dotsinset.C +++ b/src/mathed/math_dotsinset.C @@ -26,7 +26,7 @@ MathDotsInset::MathDotsInset(latexkeys const * key) {} -auto_ptr MathDotsInset::clone() const +auto_ptr MathDotsInset::doClone() const { return auto_ptr(new MathDotsInset(*this)); } diff --git a/src/mathed/math_dotsinset.h b/src/mathed/math_dotsinset.h index 79f5cef64f..90cd39ade8 100644 --- a/src/mathed/math_dotsinset.h +++ b/src/mathed/math_dotsinset.h @@ -23,8 +23,6 @@ public: /// explicit MathDotsInset(latexkeys const * l); /// - std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -35,5 +33,7 @@ protected: mutable int dh_; /// latexkeys const * key_; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_envinset.C b/src/mathed/math_envinset.C index d0a282f1e7..14942be2b1 100644 --- a/src/mathed/math_envinset.C +++ b/src/mathed/math_envinset.C @@ -26,7 +26,7 @@ MathEnvInset::MathEnvInset(string const & name) {} -auto_ptr MathEnvInset::clone() const +auto_ptr MathEnvInset::doClone() const { return auto_ptr(new MathEnvInset(*this)); } diff --git a/src/mathed/math_envinset.h b/src/mathed/math_envinset.h index 27bc2365d2..ab32bda5e6 100644 --- a/src/mathed/math_envinset.h +++ b/src/mathed/math_envinset.h @@ -23,8 +23,6 @@ public: /// MathEnvInset(std::string const & name_); /// - virtual std::auto_ptr clone() const; - /// void draw(PainterInfo &, int x, int y) const; /// void write(WriteStream & os) const; @@ -36,6 +34,7 @@ public: void infoize(std::ostream & os) const; private: + virtual std::auto_ptr doClone() const; /// name of that environment std::string name_; }; diff --git a/src/mathed/math_exfuncinset.C b/src/mathed/math_exfuncinset.C index b6e5d60921..1655e7fd95 100644 --- a/src/mathed/math_exfuncinset.C +++ b/src/mathed/math_exfuncinset.C @@ -33,7 +33,7 @@ MathExFuncInset::MathExFuncInset(string const & name, MathArray const & ar) } -auto_ptr MathExFuncInset::clone() const +auto_ptr MathExFuncInset::doClone() const { return auto_ptr(new MathExFuncInset(*this)); } diff --git a/src/mathed/math_exfuncinset.h b/src/mathed/math_exfuncinset.h index 222cb482cc..d999d9af0d 100644 --- a/src/mathed/math_exfuncinset.h +++ b/src/mathed/math_exfuncinset.h @@ -28,8 +28,6 @@ public: /// MathExFuncInset(std::string const & name, MathArray const & ar); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -48,6 +46,7 @@ public: void octave(OctaveStream &) const; private: + virtual std::auto_ptr doClone() const; /// std::string const name_; }; diff --git a/src/mathed/math_exintinset.C b/src/mathed/math_exintinset.C index e41dad3134..bd4afb918a 100644 --- a/src/mathed/math_exintinset.C +++ b/src/mathed/math_exintinset.C @@ -35,7 +35,7 @@ MathExIntInset::MathExIntInset(string const & name) // 3 - upper -auto_ptr MathExIntInset::clone() const +auto_ptr MathExIntInset::doClone() const { return auto_ptr(new MathExIntInset(*this)); } diff --git a/src/mathed/math_exintinset.h b/src/mathed/math_exintinset.h index b1e11d8814..8047fe21c8 100644 --- a/src/mathed/math_exintinset.h +++ b/src/mathed/math_exintinset.h @@ -27,8 +27,6 @@ public: /// explicit MathExIntInset(std::string const & name_); /// - virtual std::auto_ptr clone() const; - /// void symbol(std::string const &); /// void metrics(MetricsInfo & mi, Dimension & dim) const; @@ -48,6 +46,7 @@ public: /// void write(WriteStream & os) const; private: + virtual std::auto_ptr doClone() const; /// bool hasScripts() const; diff --git a/src/mathed/math_fboxinset.C b/src/mathed/math_fboxinset.C index 33ab17d14f..6fbbb38c8b 100644 --- a/src/mathed/math_fboxinset.C +++ b/src/mathed/math_fboxinset.C @@ -28,7 +28,7 @@ MathFboxInset::MathFboxInset() {} -auto_ptr MathFboxInset::clone() const +auto_ptr MathFboxInset::doClone() const { return auto_ptr(new MathFboxInset(*this)); } @@ -75,4 +75,3 @@ void MathFboxInset::infoize(std::ostream & os) const { os << "FBox: "; } - diff --git a/src/mathed/math_fboxinset.h b/src/mathed/math_fboxinset.h index 215eaf4cda..405a7c5b27 100644 --- a/src/mathed/math_fboxinset.h +++ b/src/mathed/math_fboxinset.h @@ -21,8 +21,6 @@ public: /// MathFboxInset(); /// - std::auto_ptr clone() const; - /// mode_type currentMode() const; /// void metrics(MetricsInfo & mi, Dimension & dim) const; @@ -34,6 +32,8 @@ public: void normalize(NormalStream & ns) const; /// void infoize(std::ostream & os) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_fontinset.C b/src/mathed/math_fontinset.C index b4ad80771c..4a72b31102 100644 --- a/src/mathed/math_fontinset.C +++ b/src/mathed/math_fontinset.C @@ -26,7 +26,7 @@ MathFontInset::MathFontInset(latexkeys const * key) {} -auto_ptr MathFontInset::clone() const +auto_ptr MathFontInset::doClone() const { return auto_ptr(new MathFontInset(*this)); } diff --git a/src/mathed/math_fontinset.h b/src/mathed/math_fontinset.h index 5174823b04..efe6ce2033 100644 --- a/src/mathed/math_fontinset.h +++ b/src/mathed/math_fontinset.h @@ -23,8 +23,6 @@ public: /// explicit MathFontInset(latexkeys const * key); /// - virtual std::auto_ptr clone() const; - /// MathFontInset * asFontInset() { return this; } /// MathFontInset const * asFontInset() const { return this; } @@ -46,6 +44,7 @@ public: void infoize(std::ostream & os) const; private: + virtual std::auto_ptr doClone() const; /// the font to be used on screen latexkeys const * key_; }; diff --git a/src/mathed/math_fontoldinset.C b/src/mathed/math_fontoldinset.C index 6b2a27174b..e339c27ac3 100644 --- a/src/mathed/math_fontoldinset.C +++ b/src/mathed/math_fontoldinset.C @@ -27,7 +27,7 @@ MathFontOldInset::MathFontOldInset(latexkeys const * key) } -auto_ptr MathFontOldInset::clone() const +auto_ptr MathFontOldInset::doClone() const { return auto_ptr(new MathFontOldInset(*this)); } diff --git a/src/mathed/math_fontoldinset.h b/src/mathed/math_fontoldinset.h index 09a0df3baa..0db0702c1e 100644 --- a/src/mathed/math_fontoldinset.h +++ b/src/mathed/math_fontoldinset.h @@ -22,8 +22,6 @@ class MathFontOldInset : public MathNestInset { public: /// explicit MathFontOldInset(latexkeys const * key); - /// - virtual std::auto_ptr clone() const; /// we are in text mode. mode_type currentMode() const { return TEXT_MODE; } /// we write extra braces in any case... @@ -44,6 +42,7 @@ public: void infoize(std::ostream & os) const; private: + virtual std::auto_ptr doClone() const; /// the font to be used on screen latexkeys const * key_; }; diff --git a/src/mathed/math_fracinset.C b/src/mathed/math_fracinset.C index b694d72fe1..829ddf5134 100644 --- a/src/mathed/math_fracinset.C +++ b/src/mathed/math_fracinset.C @@ -29,7 +29,7 @@ MathFracInset::MathFracInset(bool atop) {} -auto_ptr MathFracInset::clone() const +auto_ptr MathFracInset::doClone() const { return auto_ptr(new MathFracInset(*this)); } diff --git a/src/mathed/math_fracinset.h b/src/mathed/math_fracinset.h index 90ea9c9fd7..2707fe8cc0 100644 --- a/src/mathed/math_fracinset.h +++ b/src/mathed/math_fracinset.h @@ -22,8 +22,6 @@ public: /// explicit MathFracInset(bool atop = false); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; @@ -49,8 +47,9 @@ public: /// void mathmlize(MathMLStream &) const; public: + virtual std::auto_ptr doClone() const; /// - const bool atop_; + bool const atop_; }; #endif diff --git a/src/mathed/math_frameboxinset.C b/src/mathed/math_frameboxinset.C index 805e217cf5..bb6badd6bb 100644 --- a/src/mathed/math_frameboxinset.C +++ b/src/mathed/math_frameboxinset.C @@ -25,7 +25,7 @@ MathFrameboxInset::MathFrameboxInset() {} -auto_ptr MathFrameboxInset::clone() const +auto_ptr MathFrameboxInset::doClone() const { return auto_ptr(new MathFrameboxInset(*this)); } diff --git a/src/mathed/math_frameboxinset.h b/src/mathed/math_frameboxinset.h index e7adbdd52f..7c7ea77b00 100644 --- a/src/mathed/math_frameboxinset.h +++ b/src/mathed/math_frameboxinset.h @@ -21,8 +21,6 @@ public: /// MathFrameboxInset(); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -33,6 +31,7 @@ public: /// mode_type currentMode() const { return TEXT_MODE; } private: + virtual std::auto_ptr doClone() const; /// width of '[' in current font mutable int w_; }; diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index 07325ab759..dd25e08041 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -186,7 +186,7 @@ MathGridInset::~MathGridInset() } -auto_ptr MathGridInset::clone() const +auto_ptr MathGridInset::doClone() const { return auto_ptr(new MathGridInset(*this)); } diff --git a/src/mathed/math_gridinset.h b/src/mathed/math_gridinset.h index 225051b7f2..52ff62a52b 100644 --- a/src/mathed/math_gridinset.h +++ b/src/mathed/math_gridinset.h @@ -20,7 +20,6 @@ * This is the base to all grid-like editable math objects */ class MathGridInset : public MathNestInset { - public: /// additional per-cell information @@ -94,8 +93,6 @@ public: /// Ensures that the dialog is closed. ~MathGridInset(); /// - std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi) const; /// void metrics(MetricsInfo & mi, Dimension &) const; @@ -238,6 +235,8 @@ public: std::vector cellinfo_; /// char v_align_; // add approp. type +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 94674cdb14..7bf1b7903e 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -158,21 +158,23 @@ MathHullInset::~MathHullInset() {} -auto_ptr MathHullInset::clone() const +auto_ptr MathHullInset::doClone() const { return auto_ptr(new MathHullInset(*this)); } -void MathHullInset::operator=(MathHullInset const & other) +MathHullInset & MathHullInset::operator=(MathHullInset const & other) { if (this == &other) - return; + return *this; *static_cast(this) = MathGridInset(other); type_ = other.type_; nonum_ = other.nonum_; label_ = other.label_; preview_.reset(new RenderPreview(*other.preview_, this)); + + return *this; } @@ -1355,7 +1357,7 @@ int MathHullInset::docbook(Buffer const & buf, ostream & os, name = "informalequation"; string bname = name; - if (!label(0).empty()) + if (!label(0).empty()) bname += " id=\"" + sgml::cleanID(buf, runparams, label(0)) + "\""; ms << MTag(bname.c_str()); @@ -1373,23 +1375,23 @@ int MathHullInset::docbook(Buffer const & buf, ostream & os, MathGridInset::mathmlize(ms); ms << ETag("math"); } else { - ms << MTag("alt role=\"tex\""); + ms << MTag("alt role=\"tex\""); res = latex(buf, ls, runparams); ms << subst(subst(ls.str(), "&", "&"), "<", "<"); ms << ETag("alt"); } - + ms << ""; - else + else ms << "\">"; - + ms << ETag(name.c_str()); return ms.line() + res; } diff --git a/src/mathed/math_hullinset.h b/src/mathed/math_hullinset.h index 4d50f5e9a6..8f6d205d50 100644 --- a/src/mathed/math_hullinset.h +++ b/src/mathed/math_hullinset.h @@ -26,13 +26,9 @@ public: /// explicit MathHullInset(std::string const & type); /// - MathHullInset(MathHullInset const &); - /// ~MathHullInset(); /// - std::auto_ptr clone() const; - /// - void operator=(MathHullInset const &); + MathHullInset & operator=(MathHullInset const &); /// mode_type currentMode() const; /// @@ -122,8 +118,10 @@ public: protected: - /// - void priv_dispatch(LCursor & cur, FuncRequest & cmd); + MathHullInset(MathHullInset const &); + + virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd); + /// do we want to handle this event? bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus & status) const; @@ -131,6 +129,7 @@ protected: std::string eolString(row_type row, bool fragile) const; private: + virtual std::auto_ptr doClone() const; /// void setType(std::string const & type); /// diff --git a/src/mathed/math_kerninset.C b/src/mathed/math_kerninset.C index a7ac65c906..b07c8eee1e 100644 --- a/src/mathed/math_kerninset.C +++ b/src/mathed/math_kerninset.C @@ -34,7 +34,7 @@ MathKernInset::MathKernInset(string const & s) {} -auto_ptr MathKernInset::clone() const +auto_ptr MathKernInset::doClone() const { return auto_ptr(new MathKernInset(*this)); } diff --git a/src/mathed/math_kerninset.h b/src/mathed/math_kerninset.h index 3a3de3b7c4..48d50638b8 100644 --- a/src/mathed/math_kerninset.h +++ b/src/mathed/math_kerninset.h @@ -28,8 +28,6 @@ public: /// explicit MathKernInset(std::string const & wid); /// - std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -38,6 +36,7 @@ public: /// void normalize(NormalStream & ns) const; private: + virtual std::auto_ptr doClone() const; /// width in em LyXLength wid_; }; diff --git a/src/mathed/math_lefteqninset.C b/src/mathed/math_lefteqninset.C index fd2c691a3f..46771075a9 100644 --- a/src/mathed/math_lefteqninset.C +++ b/src/mathed/math_lefteqninset.C @@ -24,7 +24,7 @@ MathLefteqnInset::MathLefteqnInset() {} -auto_ptr MathLefteqnInset::clone() const +auto_ptr MathLefteqnInset::doClone() const { return auto_ptr(new MathLefteqnInset(*this)); } diff --git a/src/mathed/math_lefteqninset.h b/src/mathed/math_lefteqninset.h index 71a5ae71ec..d5fe40ee6b 100644 --- a/src/mathed/math_lefteqninset.h +++ b/src/mathed/math_lefteqninset.h @@ -22,8 +22,6 @@ public: /// MathLefteqnInset(); /// - virtual std::auto_ptr clone() const; - /// std::string name() const; /// void metrics(MetricsInfo & mi, Dimension & dim) const; @@ -31,5 +29,7 @@ public: void draw(PainterInfo & pi, int x, int y) const; /// void infoize(std::ostream & os) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_liminset.C b/src/mathed/math_liminset.C index 79712556cf..c86c4741fc 100644 --- a/src/mathed/math_liminset.C +++ b/src/mathed/math_liminset.C @@ -29,7 +29,7 @@ MathLimInset::MathLimInset } -auto_ptr MathLimInset::clone() const +auto_ptr MathLimInset::doClone() const { return auto_ptr(new MathLimInset(*this)); } diff --git a/src/mathed/math_liminset.h b/src/mathed/math_liminset.h index cd9d2579c5..fb246ddea7 100644 --- a/src/mathed/math_liminset.h +++ b/src/mathed/math_liminset.h @@ -23,8 +23,6 @@ public: /// MathLimInset(MathArray const & f, MathArray const & x, MathArray const & x0); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -39,6 +37,8 @@ public: void mathmlize(MathMLStream &) const; /// void write(WriteStream & os) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index f1e1f495e7..10a2286c18 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -33,7 +33,7 @@ MathMacro::MathMacro(string const & name, int numargs) {} -auto_ptr MathMacro::clone() const +auto_ptr MathMacro::doClone() const { return auto_ptr(new MathMacro(*this)); } diff --git a/src/mathed/math_macro.h b/src/mathed/math_macro.h index 28a184aa68..2a3637578f 100644 --- a/src/mathed/math_macro.h +++ b/src/mathed/math_macro.h @@ -25,8 +25,6 @@ public: /// A macro can be built from an existing template MathMacro(std::string const & name, int numargs); /// - std::auto_ptr clone() const; - /// void draw(PainterInfo & pi, int x, int y) const; /// void drawExpanded(PainterInfo & pi, int x, int y) const; @@ -52,6 +50,7 @@ public: void infoize2(std::ostream &) const; private: + virtual std::auto_ptr doClone() const; /// void updateExpansion() const; /// diff --git a/src/mathed/math_macroarg.C b/src/mathed/math_macroarg.C index 777bb5c94c..d4b7adf986 100644 --- a/src/mathed/math_macroarg.C +++ b/src/mathed/math_macroarg.C @@ -35,7 +35,7 @@ MathMacroArgument::MathMacroArgument(size_t n) } -auto_ptr MathMacroArgument::clone() const +auto_ptr MathMacroArgument::doClone() const { return auto_ptr(new MathMacroArgument(*this)); } diff --git a/src/mathed/math_macroarg.h b/src/mathed/math_macroarg.h index d7d763d878..0db549d7ab 100644 --- a/src/mathed/math_macroarg.h +++ b/src/mathed/math_macroarg.h @@ -22,8 +22,6 @@ public: /// explicit MathMacroArgument(std::size_t); /// - std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; @@ -38,6 +36,7 @@ public: void write(WriteStream & os) const; private: + virtual std::auto_ptr doClone() const; /// A number between 1 and 9 std::size_t number_; /// diff --git a/src/mathed/math_macrotemplate.C b/src/mathed/math_macrotemplate.C index c0b869b985..d4051c6698 100644 --- a/src/mathed/math_macrotemplate.C +++ b/src/mathed/math_macrotemplate.C @@ -64,7 +64,7 @@ MathMacroTemplate::MathMacroTemplate(std::istream & is) } -auto_ptr MathMacroTemplate::clone() const +auto_ptr MathMacroTemplate::doClone() const { return auto_ptr(new MathMacroTemplate(*this)); } diff --git a/src/mathed/math_macrotemplate.h b/src/mathed/math_macrotemplate.h index ff888046ae..54ff52f317 100644 --- a/src/mathed/math_macrotemplate.h +++ b/src/mathed/math_macrotemplate.h @@ -31,8 +31,6 @@ public: /// explicit MathMacroTemplate(std::istream & is); /// - std::auto_ptr clone() const; - /// void edit(LCursor & cur, bool left); /// EDITABLE editable() const { return HIGHLY_EDITABLE; } @@ -62,6 +60,7 @@ public: InsetBase::Code lyxCode() const { return MATHMACRO_CODE; } private: + virtual std::auto_ptr doClone() const; /// prefix in inset std::string prefix() const; diff --git a/src/mathed/math_makeboxinset.C b/src/mathed/math_makeboxinset.C index 9c16adc0ce..a3d6d4b480 100644 --- a/src/mathed/math_makeboxinset.C +++ b/src/mathed/math_makeboxinset.C @@ -25,7 +25,7 @@ MathMakeboxInset::MathMakeboxInset() {} -auto_ptr MathMakeboxInset::clone() const +auto_ptr MathMakeboxInset::doClone() const { return auto_ptr(new MathMakeboxInset(*this)); } diff --git a/src/mathed/math_makeboxinset.h b/src/mathed/math_makeboxinset.h index b6e8a8d582..5ddf3618e3 100644 --- a/src/mathed/math_makeboxinset.h +++ b/src/mathed/math_makeboxinset.h @@ -22,8 +22,6 @@ public: /// MathMakeboxInset(); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -36,6 +34,7 @@ public: /// void infoize(std::ostream & os) const; private: + virtual std::auto_ptr doClone() const; /// width of '[' in current font mutable int w_; }; diff --git a/src/mathed/math_matrixinset.C b/src/mathed/math_matrixinset.C index f1343b4736..bbd3f17bfe 100644 --- a/src/mathed/math_matrixinset.C +++ b/src/mathed/math_matrixinset.C @@ -22,7 +22,7 @@ MathMatrixInset::MathMatrixInset(MathGridInset const & p) {} -auto_ptr MathMatrixInset::clone() const +auto_ptr MathMatrixInset::doClone() const { return auto_ptr(new MathMatrixInset(*this)); } diff --git a/src/mathed/math_matrixinset.h b/src/mathed/math_matrixinset.h index 027c18a2c3..43b58cba33 100644 --- a/src/mathed/math_matrixinset.h +++ b/src/mathed/math_matrixinset.h @@ -20,11 +20,9 @@ class MathMatrixInset : public MathGridInset { public: /// - MathMatrixInset(MathGridInset const &); + explicit MathMatrixInset(MathGridInset const &); /// - MathMatrixInset(std::string const & str); - /// - virtual std::auto_ptr clone() const; + explicit MathMatrixInset(std::string const & str); /// identifies MatrixInsets MathMatrixInset const * asMatrixInset() const { return this; } @@ -40,6 +38,8 @@ public: void mathmlize(MathMLStream &) const; /// void octave(OctaveStream &) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_mboxinset.C b/src/mathed/math_mboxinset.C index c3f090db00..43ddc1823b 100644 --- a/src/mathed/math_mboxinset.C +++ b/src/mathed/math_mboxinset.C @@ -40,7 +40,7 @@ MathMBoxInset::MathMBoxInset(BufferView & bv) } -auto_ptr MathMBoxInset::clone() const +auto_ptr MathMBoxInset::doClone() const { return auto_ptr(new MathMBoxInset(*this)); } diff --git a/src/mathed/math_mboxinset.h b/src/mathed/math_mboxinset.h index 9a8be27272..a7199541c7 100644 --- a/src/mathed/math_mboxinset.h +++ b/src/mathed/math_mboxinset.h @@ -21,9 +21,7 @@ class MathMBoxInset : public MathDimInset { public: /// - MathMBoxInset(BufferView & bv); - /// - std::auto_ptr clone() const; + explicit MathMBoxInset(BufferView & bv); /// this stores metrics information in cache_ void metrics(MetricsInfo & mi, Dimension & dim) const; /// draw according to cached metrics @@ -50,6 +48,8 @@ protected: mutable LyXText text_; /// BufferView * const bv_; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_numberinset.C b/src/mathed/math_numberinset.C index 01ffcf170f..30647cf3c5 100644 --- a/src/mathed/math_numberinset.C +++ b/src/mathed/math_numberinset.C @@ -25,7 +25,7 @@ MathNumberInset::MathNumberInset(string const & s) {} -auto_ptr MathNumberInset::clone() const +auto_ptr MathNumberInset::doClone() const { return auto_ptr(new MathNumberInset(*this)); } diff --git a/src/mathed/math_numberinset.h b/src/mathed/math_numberinset.h index fc9ed67070..c936b8d034 100644 --- a/src/mathed/math_numberinset.h +++ b/src/mathed/math_numberinset.h @@ -23,8 +23,6 @@ public: /// explicit MathNumberInset(std::string const & s); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; @@ -45,6 +43,7 @@ public: void write(WriteStream & os) const; private: + virtual std::auto_ptr doClone() const; /// the number as string std::string str_; }; diff --git a/src/mathed/math_oversetinset.C b/src/mathed/math_oversetinset.C index 1d8a8ee8f3..ed4670407b 100644 --- a/src/mathed/math_oversetinset.C +++ b/src/mathed/math_oversetinset.C @@ -21,7 +21,7 @@ using std::max; using std::auto_ptr; -auto_ptr MathOversetInset::clone() const +auto_ptr MathOversetInset::doClone() const { return auto_ptr(new MathOversetInset(*this)); } @@ -84,4 +84,3 @@ void MathOversetInset::validate(LaTeXFeatures & features) const features.require("amsmath"); MathNestInset::validate(features); } - diff --git a/src/mathed/math_oversetinset.h b/src/mathed/math_oversetinset.h index c7f0a4c30b..f73ac6149b 100644 --- a/src/mathed/math_oversetinset.h +++ b/src/mathed/math_oversetinset.h @@ -18,8 +18,6 @@ /// Inset for overset class MathOversetInset : public MathFracbaseInset { public: - /// - std::auto_ptr clone() const; /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// @@ -34,6 +32,8 @@ public: void normalize(NormalStream &) const; /// void validate(LaTeXFeatures & features) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_rootinset.C b/src/mathed/math_rootinset.C index 85025a1add..646cbfa789 100644 --- a/src/mathed/math_rootinset.C +++ b/src/mathed/math_rootinset.C @@ -29,7 +29,7 @@ MathRootInset::MathRootInset() {} -auto_ptr MathRootInset::clone() const +auto_ptr MathRootInset::doClone() const { return auto_ptr(new MathRootInset(*this)); } diff --git a/src/mathed/math_rootinset.h b/src/mathed/math_rootinset.h index 025304b334..19e7629300 100644 --- a/src/mathed/math_rootinset.h +++ b/src/mathed/math_rootinset.h @@ -22,8 +22,6 @@ public: /// MathRootInset(); /// - virtual std::auto_ptr clone() const; - /// bool idxUpDown(LCursor & cur, bool up) const; /// void metrics(MetricsInfo & mi, Dimension & dim) const; @@ -40,6 +38,8 @@ public: void maple(MapleStream &) const; /// void octave(OctaveStream &) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_scriptinset.C b/src/mathed/math_scriptinset.C index bb6cbe81e5..55f9a6159a 100644 --- a/src/mathed/math_scriptinset.C +++ b/src/mathed/math_scriptinset.C @@ -47,8 +47,7 @@ MathScriptInset::MathScriptInset(MathAtom const & at, bool up) } - -auto_ptr MathScriptInset::clone() const +auto_ptr MathScriptInset::doClone() const { return auto_ptr(new MathScriptInset(*this)); } diff --git a/src/mathed/math_scriptinset.h b/src/mathed/math_scriptinset.h index 3855f6f251..fc853613ea 100644 --- a/src/mathed/math_scriptinset.h +++ b/src/mathed/math_scriptinset.h @@ -28,8 +28,6 @@ public: /// create inset with single script and given nucleus MathScriptInset(MathAtom const & at, bool up); /// - std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -103,6 +101,7 @@ protected: /// void priv_dispatch(LCursor & cur, FuncRequest & cmd); private: + virtual std::auto_ptr doClone() const; /// returns x offset for main part int dxx() const; /// returns width of nucleus if any diff --git a/src/mathed/math_sizeinset.C b/src/mathed/math_sizeinset.C index 49966d2292..7bed06ea22 100644 --- a/src/mathed/math_sizeinset.C +++ b/src/mathed/math_sizeinset.C @@ -29,7 +29,7 @@ MathSizeInset::MathSizeInset(latexkeys const * l) {} -auto_ptr MathSizeInset::clone() const +auto_ptr MathSizeInset::doClone() const { return auto_ptr(new MathSizeInset(*this)); } diff --git a/src/mathed/math_sizeinset.h b/src/mathed/math_sizeinset.h index 2ec061a0e3..5847ac1f1f 100644 --- a/src/mathed/math_sizeinset.h +++ b/src/mathed/math_sizeinset.h @@ -23,8 +23,6 @@ class MathSizeInset : public MathNestInset { public: /// explicit MathSizeInset(latexkeys const * l); - /// - virtual std::auto_ptr clone() const; /// we write extra braces in any case... bool extraBraces() const { return true; } /// @@ -38,8 +36,8 @@ public: void normalize(NormalStream &) const; /// void infoize(std::ostream & os) const; - private: + virtual std::auto_ptr doClone() const; /// latexkeys const * key_; /// diff --git a/src/mathed/math_spaceinset.C b/src/mathed/math_spaceinset.C index a3599f655b..411903116b 100644 --- a/src/mathed/math_spaceinset.C +++ b/src/mathed/math_spaceinset.C @@ -46,7 +46,7 @@ MathSpaceInset::MathSpaceInset(string const & name) } -auto_ptr MathSpaceInset::clone() const +auto_ptr MathSpaceInset::doClone() const { return auto_ptr(new MathSpaceInset(*this)); } diff --git a/src/mathed/math_spaceinset.h b/src/mathed/math_spaceinset.h index d43d384a5f..c6fad086d4 100644 --- a/src/mathed/math_spaceinset.h +++ b/src/mathed/math_spaceinset.h @@ -23,8 +23,6 @@ public: /// explicit MathSpaceInset(std::string const & name); /// - virtual std::auto_ptr clone() const; - /// MathSpaceInset const * asSpaceInset() const { return this; } /// MathSpaceInset * asSpaceInset() { return this; } @@ -54,6 +52,7 @@ public: /// void write(WriteStream & os) const; private: + virtual std::auto_ptr doClone() const; /// int space_; }; diff --git a/src/mathed/math_splitinset.C b/src/mathed/math_splitinset.C index 90388dbd38..e903a04b84 100644 --- a/src/mathed/math_splitinset.C +++ b/src/mathed/math_splitinset.C @@ -27,7 +27,7 @@ MathSplitInset::MathSplitInset(string const & name) } -auto_ptr MathSplitInset::clone() const +auto_ptr MathSplitInset::doClone() const { return auto_ptr(new MathSplitInset(*this)); } diff --git a/src/mathed/math_splitinset.h b/src/mathed/math_splitinset.h index 98ac168c23..49faf48f4e 100644 --- a/src/mathed/math_splitinset.h +++ b/src/mathed/math_splitinset.h @@ -20,14 +20,13 @@ public: /// explicit MathSplitInset(std::string const & name); /// - virtual std::auto_ptr clone() const; - /// void write(WriteStream & os) const; /// int defaultColSpace(col_type) { return 0; } /// char defaultColAlign(col_type); private: + virtual std::auto_ptr doClone() const; /// std::string name_; }; diff --git a/src/mathed/math_sqrtinset.C b/src/mathed/math_sqrtinset.C index 61da212107..4705ae7846 100644 --- a/src/mathed/math_sqrtinset.C +++ b/src/mathed/math_sqrtinset.C @@ -25,7 +25,7 @@ MathSqrtInset::MathSqrtInset() {} -auto_ptr MathSqrtInset::clone() const +auto_ptr MathSqrtInset::doClone() const { return auto_ptr(new MathSqrtInset(*this)); } diff --git a/src/mathed/math_sqrtinset.h b/src/mathed/math_sqrtinset.h index 7279ef3e81..b767926842 100644 --- a/src/mathed/math_sqrtinset.h +++ b/src/mathed/math_sqrtinset.h @@ -22,8 +22,6 @@ public: /// MathSqrtInset(); /// - virtual std::auto_ptr clone() const; - /// void draw(PainterInfo &, int x, int y) const; /// void metrics(MetricsInfo & mi, Dimension & dim) const; @@ -44,5 +42,7 @@ public: void octave(OctaveStream &) const; /// void mathmlize(MathMLStream &) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_stackrelinset.C b/src/mathed/math_stackrelinset.C index 4254f1869d..d5a1c5bfb5 100644 --- a/src/mathed/math_stackrelinset.C +++ b/src/mathed/math_stackrelinset.C @@ -23,7 +23,7 @@ MathStackrelInset::MathStackrelInset() {} -auto_ptr MathStackrelInset::clone() const +auto_ptr MathStackrelInset::doClone() const { return auto_ptr(new MathStackrelInset(*this)); } diff --git a/src/mathed/math_stackrelinset.h b/src/mathed/math_stackrelinset.h index f53033a978..31f33f4c86 100644 --- a/src/mathed/math_stackrelinset.h +++ b/src/mathed/math_stackrelinset.h @@ -25,8 +25,6 @@ public: /// MathStackrelInset(); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -35,6 +33,8 @@ public: void write(WriteStream & os) const; /// void normalize(NormalStream &) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_stringinset.C b/src/mathed/math_stringinset.C index dfb664c26c..4800e32edd 100644 --- a/src/mathed/math_stringinset.C +++ b/src/mathed/math_stringinset.C @@ -25,7 +25,7 @@ MathStringInset::MathStringInset(string const & s) {} -auto_ptr MathStringInset::clone() const +auto_ptr MathStringInset::doClone() const { return auto_ptr(new MathStringInset(*this)); } diff --git a/src/mathed/math_stringinset.h b/src/mathed/math_stringinset.h index bbbd670348..f233b5169f 100644 --- a/src/mathed/math_stringinset.h +++ b/src/mathed/math_stringinset.h @@ -24,8 +24,6 @@ public: /// explicit MathStringInset(std::string const & s); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -48,6 +46,7 @@ public: void write(WriteStream & os) const; private: + virtual std::auto_ptr doClone() const; /// the string std::string str_; }; diff --git a/src/mathed/math_substackinset.C b/src/mathed/math_substackinset.C index 696a9986e9..6a288af21b 100644 --- a/src/mathed/math_substackinset.C +++ b/src/mathed/math_substackinset.C @@ -23,7 +23,7 @@ MathSubstackInset::MathSubstackInset() {} -auto_ptr MathSubstackInset::clone() const +auto_ptr MathSubstackInset::doClone() const { return auto_ptr(new MathSubstackInset(*this)); } diff --git a/src/mathed/math_substackinset.h b/src/mathed/math_substackinset.h index 1f4dcdc209..8013695740 100644 --- a/src/mathed/math_substackinset.h +++ b/src/mathed/math_substackinset.h @@ -22,8 +22,6 @@ public: /// MathSubstackInset(); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -40,6 +38,8 @@ public: void normalize(NormalStream &) const; /// void maple(MapleStream &) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_symbolinset.C b/src/mathed/math_symbolinset.C index 8a4359cff5..d3cc5a1daa 100644 --- a/src/mathed/math_symbolinset.C +++ b/src/mathed/math_symbolinset.C @@ -40,7 +40,7 @@ MathSymbolInset::MathSymbolInset(string const & name) {} -auto_ptr MathSymbolInset::clone() const +auto_ptr MathSymbolInset::doClone() const { return auto_ptr(new MathSymbolInset(*this)); } diff --git a/src/mathed/math_symbolinset.h b/src/mathed/math_symbolinset.h index ebda7fc20f..29fcafb4ea 100644 --- a/src/mathed/math_symbolinset.h +++ b/src/mathed/math_symbolinset.h @@ -29,8 +29,6 @@ public: /// explicit MathSymbolInset(std::string const & name); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; @@ -68,6 +66,7 @@ public: void infoize2(std::ostream & os) const; private: + virtual std::auto_ptr doClone() const; /// latexkeys const * sym_; /// diff --git a/src/mathed/math_tabularinset.C b/src/mathed/math_tabularinset.C index 571b1bc30b..78712160eb 100644 --- a/src/mathed/math_tabularinset.C +++ b/src/mathed/math_tabularinset.C @@ -39,7 +39,7 @@ MathTabularInset::MathTabularInset(string const & name, char valign, {} -auto_ptr MathTabularInset::clone() const +auto_ptr MathTabularInset::doClone() const { return auto_ptr(new MathTabularInset(*this)); } diff --git a/src/mathed/math_tabularinset.h b/src/mathed/math_tabularinset.h index 88224601b2..e2476d246e 100644 --- a/src/mathed/math_tabularinset.h +++ b/src/mathed/math_tabularinset.h @@ -26,8 +26,6 @@ public: /// MathTabularInset(std::string const &, char valign, std::string const & halign); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -44,6 +42,7 @@ public: void maple(MapleStream &) const; private: + virtual std::auto_ptr doClone() const; /// std::string name_; }; diff --git a/src/mathed/math_tfracinset.C b/src/mathed/math_tfracinset.C index f18d6caed3..9671363c2f 100644 --- a/src/mathed/math_tfracinset.C +++ b/src/mathed/math_tfracinset.C @@ -31,7 +31,7 @@ MathTfracInset::MathTfracInset() {} -auto_ptr MathTfracInset::clone() const +auto_ptr MathTfracInset::doClone() const { return auto_ptr(new MathTfracInset(*this)); } diff --git a/src/mathed/math_tfracinset.h b/src/mathed/math_tfracinset.h index b2727ebfdb..c384f25667 100644 --- a/src/mathed/math_tfracinset.h +++ b/src/mathed/math_tfracinset.h @@ -21,8 +21,6 @@ public: /// MathTfracInset(); /// - virtual std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; @@ -32,6 +30,8 @@ public: void mathmlize(MathMLStream &) const; /// void validate(LaTeXFeatures & features) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_undersetinset.C b/src/mathed/math_undersetinset.C index b0ee5632df..5ba13ad186 100644 --- a/src/mathed/math_undersetinset.C +++ b/src/mathed/math_undersetinset.C @@ -22,7 +22,7 @@ using std::auto_ptr; -auto_ptr MathUndersetInset::clone() const +auto_ptr MathUndersetInset::doClone() const { return auto_ptr(new MathUndersetInset(*this)); } @@ -96,4 +96,3 @@ void MathUndersetInset::validate(LaTeXFeatures & features) const features.require("amsmath"); MathNestInset::validate(features); } - diff --git a/src/mathed/math_undersetinset.h b/src/mathed/math_undersetinset.h index c6473e1980..c80a23497e 100644 --- a/src/mathed/math_undersetinset.h +++ b/src/mathed/math_undersetinset.h @@ -18,8 +18,6 @@ /// Inset for underset class MathUndersetInset : public MathFracbaseInset { public: - /// - std::auto_ptr clone() const; /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// @@ -36,6 +34,8 @@ public: void normalize(NormalStream & ns) const; /// void validate(LaTeXFeatures & features) const; +private: + virtual std::auto_ptr doClone() const; }; #endif diff --git a/src/mathed/math_unknowninset.C b/src/mathed/math_unknowninset.C index 496b274c05..12a29cab56 100644 --- a/src/mathed/math_unknowninset.C +++ b/src/mathed/math_unknowninset.C @@ -25,7 +25,7 @@ MathUnknownInset::MathUnknownInset(string const & nm, bool final, bool black) {} -auto_ptr MathUnknownInset::clone() const +auto_ptr MathUnknownInset::doClone() const { return auto_ptr(new MathUnknownInset(*this)); } diff --git a/src/mathed/math_unknowninset.h b/src/mathed/math_unknowninset.h index af0971777a..0dcb683f32 100644 --- a/src/mathed/math_unknowninset.h +++ b/src/mathed/math_unknowninset.h @@ -22,8 +22,6 @@ public: explicit MathUnknownInset(std::string const & name, bool final = true, bool black = false); /// - std::auto_ptr clone() const; - /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; @@ -51,6 +49,7 @@ public: /// bool final() const; private: + virtual std::auto_ptr doClone() const; /// std::string name_; /// are we finished creating the name? diff --git a/src/mathed/math_xarrowinset.C b/src/mathed/math_xarrowinset.C index 0867aa84e9..3676171d54 100644 --- a/src/mathed/math_xarrowinset.C +++ b/src/mathed/math_xarrowinset.C @@ -25,7 +25,7 @@ MathXArrowInset::MathXArrowInset(string const & name) {} -auto_ptr MathXArrowInset::clone() const +auto_ptr MathXArrowInset::doClone() const { return auto_ptr(new MathXArrowInset(*this)); } diff --git a/src/mathed/math_xarrowinset.h b/src/mathed/math_xarrowinset.h index a828e3f5f6..dd0a5b1e24 100644 --- a/src/mathed/math_xarrowinset.h +++ b/src/mathed/math_xarrowinset.h @@ -21,8 +21,6 @@ public: /// explicit MathXArrowInset(std::string const & name); /// - virtual std::auto_ptr clone() const; - /// void draw(PainterInfo & pi, int x, int y) const; /// void write(WriteStream & os) const; @@ -32,6 +30,7 @@ public: void normalize(NormalStream & os) const; private: + virtual std::auto_ptr doClone() const; /// bool upper() const; /// diff --git a/src/paragraph.C b/src/paragraph.C index d39d434039..946c8e03c9 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -944,7 +944,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf, ++column; } if (!asdefault) - column += startTeXParParams(bparams, os, + column += startTeXParParams(bparams, os, runparams.moving_arg); } diff --git a/src/pariterator.h b/src/pariterator.h index 2fbb0abb1a..5f8281de7c 100644 --- a/src/pariterator.h +++ b/src/pariterator.h @@ -50,7 +50,7 @@ public: ParIterator(DocIterator const &); /// This really should be implemented... - //void operator=(ParIterator const &); + //ParIterator & operator=(ParIterator const &); /// ParIterator & operator++(); /// diff --git a/src/tabular.C b/src/tabular.C index 34f3e19273..6343b925ae 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -40,6 +40,9 @@ using lyx::support::rtrim; using lyx::support::strToInt; using lyx::support::suffixIs; +using boost::shared_ptr; +using boost::dynamic_pointer_cast; + using std::abs; using std::endl; using std::getline; @@ -205,7 +208,7 @@ bool string2type(string const str, bool & num) } -bool getTokenValue(string const & str, const char * token, string & ret) +bool getTokenValue(string const & str, char const * token, string & ret) { ret.erase(); size_t token_length = strlen(token); @@ -227,7 +230,7 @@ bool getTokenValue(string const & str, const char * token, string & ret) } -bool getTokenValue(string const & str, const char * token, int & num) +bool getTokenValue(string const & str, char const * token, int & num) { string tmp; num = 0; @@ -238,14 +241,14 @@ bool getTokenValue(string const & str, const char * token, int & num) } -bool getTokenValue(string const & str, const char * token, LyXAlignment & num) +bool getTokenValue(string const & str, char const * token, LyXAlignment & num) { string tmp; return getTokenValue(str, token, tmp) && string2type(tmp, num); } -bool getTokenValue(string const & str, const char * token, +bool getTokenValue(string const & str, char const * token, LyXTabular::VAlignment & num) { string tmp; @@ -253,7 +256,7 @@ bool getTokenValue(string const & str, const char * token, } -bool getTokenValue(string const & str, const char * token, +bool getTokenValue(string const & str, char const * token, LyXTabular::BoxType & num) { string tmp; @@ -261,7 +264,7 @@ bool getTokenValue(string const & str, const char * token, } -bool getTokenValue(string const & str, const char * token, bool & flag) +bool getTokenValue(string const & str, char const * token, bool & flag) { // set the flag always to false as this should be the default for bools // not in the file-format. @@ -271,7 +274,7 @@ bool getTokenValue(string const & str, const char * token, bool & flag) } -bool getTokenValue(string const & str, const char * token, LyXLength & len) +bool getTokenValue(string const & str, char const * token, LyXLength & len) { // set the lenght to be zero() as default as this it should be if not // in the file format. @@ -296,52 +299,95 @@ void l_getline(istream & is, string & str) /// Define a few methods for the inner structs LyXTabular::cellstruct::cellstruct(BufferParams const & bp) - : inset(bp) -{ - cellno = 0; - width_of_cell = 0; - multicolumn = LyXTabular::CELL_NORMAL; - alignment = LYX_ALIGN_CENTER; - valignment = LYX_VALIGN_TOP; - top_line = true; - bottom_line = false; - left_line = true; - right_line = false; - usebox = BOX_NONE; - rotate = false; + : cellno(0), + width_of_cell(0), + multicolumn(LyXTabular::CELL_NORMAL), + alignment(LYX_ALIGN_CENTER), + valignment(LYX_VALIGN_TOP), + top_line(true), + bottom_line(false), + left_line(true), + right_line(false), + usebox(BOX_NONE), + rotate(false), + inset(new InsetText(bp)) +{} + + +LyXTabular::cellstruct::cellstruct(cellstruct const & cs) + : cellno(cs.cellno), + width_of_cell(cs.width_of_cell), + multicolumn(cs.multicolumn), + alignment(cs.alignment), + valignment(cs.valignment), + top_line(cs.top_line), + bottom_line(cs.bottom_line), + left_line(cs.left_line), + right_line(cs.right_line), + usebox(cs.usebox), + rotate(cs.rotate), + align_special(cs.align_special), + p_width(cs.p_width), + inset(dynamic_cast(cs.inset->clone().release())) +{} + + +LyXTabular::cellstruct & +LyXTabular::cellstruct::operator=(cellstruct cs) +{ + swap(cs); + return *this; +} + + +void +LyXTabular::cellstruct::swap(cellstruct & rhs) +{ + std::swap(cellno, rhs.cellno); + std::swap(width_of_cell, rhs.width_of_cell); + std::swap(multicolumn, rhs.multicolumn); + std::swap(alignment, rhs.alignment); + std::swap(valignment, rhs.valignment); + std::swap(top_line, rhs.top_line); + std::swap(bottom_line, rhs.bottom_line); + std::swap(left_line, rhs.left_line); + std::swap(right_line, rhs.right_line); + std::swap(usebox, rhs.usebox); + std::swap(rotate, rhs.rotate); + std::swap(align_special, rhs.align_special); + p_width.swap(rhs.p_width); + inset.swap(rhs.inset); } LyXTabular::rowstruct::rowstruct() -{ - top_line = true; - bottom_line = false; - ascent_of_row = 0; - descent_of_row = 0; - endhead = false; - endfirsthead = false; - endfoot = false; - endlastfoot = false; - newpage = false; -} + : ascent_of_row(0), + descent_of_row(0), + top_line(true), + bottom_line(false), + endhead(false), + endfirsthead(false), + endfoot(false), + endlastfoot(false), + newpage(false) +{} LyXTabular::columnstruct::columnstruct() + : alignment(LYX_ALIGN_CENTER), + valignment(LYX_VALIGN_TOP), + left_line(true), + right_line(false), + width_of_column(0) { - left_line = true; - right_line = false; - alignment = LYX_ALIGN_CENTER; - valignment = LYX_VALIGN_TOP; - width_of_column = 0; } LyXTabular::ltType::ltType() -{ - topDL = false; - bottomDL = false; - empty = false; -} + : topDL(false), + bottomDL(false), + empty(false) +{} LyXTabular::LyXTabular(BufferParams const & bp, int rows_arg, int columns_arg) @@ -379,7 +425,7 @@ void LyXTabular::fixCellNums() for (int j = 0; j < columns_; ++j) { // When debugging it can be nice to set // this to true. - cell_info[i][j].inset.setDrawFrame(false); + cell_info[i][j].inset->setDrawFrame(false); cell_info[i][j].cellno = cellno++; } cell_info[i].back().right_line = true; @@ -389,11 +435,11 @@ void LyXTabular::fixCellNums() } -void LyXTabular::appendRow(BufferParams const & bp, int cell) +void LyXTabular::appendRow(BufferParams const & bp, int const cell) { ++rows_; - int row = row_of_cell(cell); + int const row = row_of_cell(cell); row_vector::iterator rit = row_info.begin() + row; row_info.insert(rit, rowstruct()); @@ -413,13 +459,13 @@ void LyXTabular::appendRow(BufferParams const & bp, int cell) if (bp.tracking_changes) for (int j = 0; j < columns_; ++j) - cell_info[row + 1][j].inset.markNew(true); + cell_info[row + 1][j].inset->markNew(true); set_row_column_number_info(); } -void LyXTabular::deleteRow(int row) +void LyXTabular::deleteRow(int const row) { // Not allowed to delete last row if (rows_ == 1) @@ -432,7 +478,7 @@ void LyXTabular::deleteRow(int row) } -void LyXTabular::appendColumn(BufferParams const & bp, int cell) +void LyXTabular::appendColumn(BufferParams const & bp, int const cell) { ++columns_; @@ -455,15 +501,15 @@ void LyXTabular::appendColumn(BufferParams const & bp, int cell) } //++column; for (int i = 0; i < rows_; ++i) { - cell_info[i][column + 1].inset.clear(false); + cell_info[i][column + 1].inset->clear(false); if (bp.tracking_changes) - cell_info[i][column + 1].inset.markNew(true); + cell_info[i][column + 1].inset->markNew(true); } fixCellNums(); } -void LyXTabular::deleteColumn(int column) +void LyXTabular::deleteColumn(int const column) { // Not allowed to delete last column if (columns_ == 1) @@ -514,7 +560,7 @@ void LyXTabular::set_row_column_number_info() for (int column = 0; column < columns_; ++column) { if (isPartOfMultiColumn(row,column)) continue; - cell_info[row][column].inset.setAutoBreakRows( + cell_info[row][column].inset->setAutoBreakRows( !getPWidth(getCellNumber(row, column)).zero()); } } @@ -527,7 +573,7 @@ int LyXTabular::getNumberOfCells() const } -int LyXTabular::numberOfCellsInRow(int cell) const +int LyXTabular::numberOfCellsInRow(int const cell) const { int const row = row_of_cell(cell); int result = 0; @@ -539,7 +585,7 @@ int LyXTabular::numberOfCellsInRow(int cell) const // returns 1 if there is a topline, returns 0 if not -bool LyXTabular::topLine(int cell, bool onlycolumn) const +bool LyXTabular::topLine(int const cell, bool const onlycolumn) const { if (!onlycolumn && isMultiColumn(cell)) return cellinfo_of_cell(cell).top_line; @@ -813,7 +859,7 @@ void LyXTabular::setColumnPWidth(int cell, LyXLength const & width) for (int i = 0; i < rows_; ++i) { int const cell = getCellNumber(i, j); // because of multicolumns - getCellInset(cell).setAutoBreakRows(!getPWidth(cell).zero()); + getCellInset(cell)->setAutoBreakRows(!getPWidth(cell).zero()); } } @@ -824,7 +870,7 @@ bool LyXTabular::setMColumnPWidth(int cell, LyXLength const & width) return false; cellinfo_of_cell(cell).p_width = width; - getCellInset(cell).setAutoBreakRows(!width.zero()); + getCellInset(cell)->setAutoBreakRows(!width.zero()); return true; } @@ -1125,7 +1171,7 @@ void LyXTabular::write(Buffer const & buf, ostream & os) const << write_attribute("special", cell_info[i][j].align_special) << ">\n"; os << "\\begin_inset "; - cell_info[i][j].inset.write(buf, os); + cell_info[i][j].inset->write(buf, os); os << "\n\\end_inset\n" << "\n"; } @@ -1325,7 +1371,7 @@ void LyXTabular::read(Buffer const & buf, LyXLex & lex) getTokenValue(line, "special", cell_info[i][j].align_special); l_getline(is, line); if (prefixIs(line, "\\begin_inset")) { - cell_info[i][j].inset.read(buf, lex); + cell_info[i][j].inset->read(buf, lex); l_getline(is, line); } if (!prefixIs(line, "")) { @@ -1378,8 +1424,8 @@ void LyXTabular::setMultiColumn(Buffer * buffer, int cell, int number) for (int i = 1; i < number; ++i) { cellstruct & cs1 = cellinfo_of_cell(cell + i); cs1.multicolumn = CELL_PART_OF_MULTICOLUMN; - cs.inset.appendParagraphs(buffer, cs1.inset.paragraphs()); - cs1.inset.clear(false); + cs.inset->appendParagraphs(buffer, cs1.inset->paragraphs()); + cs1.inset->clear(false); } set_row_column_number_info(); } @@ -1987,24 +2033,23 @@ bool LyXTabular::isValidRow(int row) const int LyXTabular::TeXRow(ostream & os, int i, Buffer const & buf, OutputParams const & runparams) const { - int ret = 0; int cell = getCellNumber(i, 0); - ret += TeXTopHLine(os, i); + int ret = TeXTopHLine(os, i); for (int j = 0; j < columns_; ++j) { if (isPartOfMultiColumn(i, j)) continue; ret += TeXCellPreamble(os, cell); - InsetText & inset = getCellInset(cell); + shared_ptr inset = getCellInset(cell); - Paragraph & par = inset.paragraphs().front(); + Paragraph const & par = inset->paragraphs().front(); bool rtl = par.isRightToLeftPar(buf.params()) && !par.empty() && getPWidth(cell).zero(); if (rtl) os << "\\R{"; - ret += inset.latex(buf, os, runparams); + ret += inset->latex(buf, os, runparams); if (rtl) os << '}'; @@ -2154,9 +2199,9 @@ int LyXTabular::linuxdoc(Buffer const & buf, ostream & os, for (int j = 0; j < columns_; ++j) { if (isPartOfMultiColumn(i, j)) continue; - InsetText & inset = getCellInset(cell); + shared_ptr inset = getCellInset(cell); - ret += inset.linuxdoc(buf, os, runparams); + ret += inset->linuxdoc(buf, os, runparams); if (isLastCellInRow(cell)) { os << "@\n"; @@ -2215,7 +2260,7 @@ int LyXTabular::docbookRow(Buffer const & buf, ostream & os, int row, } os << '>'; - ret += getCellInset(cell).docbook(buf, os, runparams); + ret += getCellInset(cell)->docbook(buf, os, runparams); os << "\n"; ++cell; } @@ -2412,7 +2457,7 @@ int LyXTabular::asciiPrintCell(Buffer const & buf, ostream & os, bool onlydata) const { ostringstream sstr; - int ret = getCellInset(cell).plaintext(buf, sstr, runparams); + int const ret = getCellInset(cell)->plaintext(buf, sstr, runparams); if (onlydata) { os << sstr.str(); @@ -2476,7 +2521,7 @@ int LyXTabular::plaintext(Buffer const & buf, ostream & os, if (isMultiColumnReal(cell)) continue; ostringstream sstr; - getCellInset(cell).plaintext(buf, sstr, runparams); + getCellInset(cell)->plaintext(buf, sstr, runparams); if (clen[j] < sstr.str().length()) clen[j] = sstr.str().length(); } @@ -2488,7 +2533,7 @@ int LyXTabular::plaintext(Buffer const & buf, ostream & os, if (!isMultiColumnReal(cell) || isPartOfMultiColumn(i, j)) continue; ostringstream sstr; - getCellInset(cell).plaintext(buf, sstr, runparams); + getCellInset(cell)->plaintext(buf, sstr, runparams); int len = int(sstr.str().length()); int const n = cells_in_multicolumn(cell); for (int k = j; len > 0 && k < j + n - 1; ++k) @@ -2501,8 +2546,7 @@ int LyXTabular::plaintext(Buffer const & buf, ostream & os, int cell = 0; for (int i = 0; i < rows_; ++i) { if (!onlydata && asciiTopHLine(os, i, clen)) - for (int j = 0; j < depth; ++j) - os << " "; + os << string(depth * 2, ' '); for (int j = 0; j < columns_; ++j) { if (isPartOfMultiColumn(i, j)) continue; @@ -2514,24 +2558,22 @@ int LyXTabular::plaintext(Buffer const & buf, ostream & os, } os << endl; if (!onlydata) { - for (int j = 0; j < depth; ++j) - os << " "; + os << string(depth * 2, ' '); if (asciiBottomHLine(os, i, clen)) - for (int j = 0; j < depth; ++j) - os << " "; + os << string(depth * 2, ' '); } } return ret; } -InsetText & LyXTabular::getCellInset(int cell) const +shared_ptr LyXTabular::getCellInset(int cell) const { return cell_info[row_of_cell(cell)][column_of_cell(cell)].inset; } -InsetText & LyXTabular::getCellInset(int row, int column) const +shared_ptr LyXTabular::getCellInset(int row, int column) const { return cell_info[row][column].inset; } @@ -2546,7 +2588,7 @@ int LyXTabular::getCellFromInset(InsetBase const * inset) const } for (int cell = 0, n = getNumberOfCells(); cell < n; ++cell) - if (&getCellInset(cell) == inset) { + if (getCellInset(cell).get() == inset) { lyxerr[Debug::INSETTEXT] << "LyXTabular::getCellFromInset: " << "cell=" << cell << endl; return cell; @@ -2572,7 +2614,7 @@ void LyXTabular::validate(LaTeXFeatures & features) const if (getVAlignment(cell) != LYX_VALIGN_TOP || (!getPWidth(cell).zero() && !isMultiColumn(cell))) features.require("array"); - getCellInset(cell).validate(features); + getCellInset(cell)->validate(features); } } @@ -2582,13 +2624,13 @@ void LyXTabular::getLabelList(Buffer const & buffer, { for (int i = 0; i < rows_; ++i) for (int j = 0; j < columns_; ++j) - getCellInset(i, j).getLabelList(buffer, list); + getCellInset(i, j)->getLabelList(buffer, list); } LyXTabular::BoxType LyXTabular::useParbox(int cell) const { - ParagraphList const & parlist = getCellInset(cell).paragraphs(); + ParagraphList const & parlist = getCellInset(cell)->paragraphs(); ParagraphList::const_iterator cit = parlist.begin(); ParagraphList::const_iterator end = parlist.end(); diff --git a/src/tabular.h b/src/tabular.h index f4cdf9cf80..62de87e810 100644 --- a/src/tabular.h +++ b/src/tabular.h @@ -18,6 +18,8 @@ #include "lyxlength.h" #include "insets/insettext.h" +#include + #include #include @@ -364,9 +366,9 @@ public: /// // end longtable support /// - InsetText & getCellInset(int cell) const; + boost::shared_ptr getCellInset(int cell) const; /// - InsetText & getCellInset(int row, int column) const; + boost::shared_ptr getCellInset(int row, int column) const; /// Search for \param inset in the tabular, with the /// int getCellFromInset(InsetBase const * inset) const; @@ -385,6 +387,12 @@ public: /// cellstruct(BufferParams const &); /// + cellstruct(cellstruct const &); + /// + cellstruct & operator=(cellstruct); + /// + void swap(cellstruct & rhs); + /// int cellno; /// int width_of_cell; @@ -411,7 +419,7 @@ public: /// LyXLength p_width; // this is only set for multicolumn!!! /// - InsetText inset; + boost::shared_ptr inset; }; cellstruct & cellinfo_of_cell(int cell) const; ///