]> git.lyx.org Git - lyx.git/commitdiff
remove LyXParagraph Clone use newly added copy constructor instead, some whitespace...
authorLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 8 May 2001 10:50:09 +0000 (10:50 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 8 May 2001 10:50:09 +0000 (10:50 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1988 a592a061-630c-0410-9148-cb99ea01b6c8

16 files changed:
po/POTFILES.in
src/ChangeLog
src/CutAndPaste.C
src/insets/ChangeLog
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insetgraphics.C
src/insets/insettext.C
src/lyxparagraph.h
src/mathed/array.C
src/mathed/math_macroarg.C
src/mathed/math_parinset.C
src/mathed/math_spaceinset.C
src/paragraph.C
src/tabular.C
src/text2.C

index 04b1702eba515a409336ddf63aeb0bf7a4422ead..c0e4828c9cae347af8478a88ef6e2db4cdff7047 100644 (file)
@@ -9,7 +9,6 @@ src/converter.C
 src/CutAndPaste.C
 src/debug.C
 src/exporter.C
-src/ext_l10n.h
 src/figure_form.C
 src/figureForm.C
 src/FontLoader.C
index 46b160359384a1b5c6a2b32285f4abd0c868cdc5..ee996bc8e93e311e5b268c4cd658073b04586e42 100644 (file)
@@ -1,3 +1,11 @@
+2001-05-08  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * lyxparagraph.[Ch]: add copy constructor, remove Clone
+
+       * CutAndPaste.C (copySelection): use LyXParagraph copy constructor
+       (pasteSelection): likewise
+       * text2.C (CreateUndo): likewise
+
 2001-05-04  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * minibuffer.C (peek_event): temporarily reduce the functionality
index 1ac379811b908fb3ff874e84bc2718a897b00ac7..b549d2013c59c6fd11bdb86e15ad346649c431b0 100644 (file)
@@ -159,13 +159,21 @@ bool CutAndPaste::copySelection(LyXParagraph * startpar, LyXParagraph * endpar,
                // copy more than one paragraph
                // clone the paragraphs within the selection
                LyXParagraph * tmppar = startpar;
+#if 0
                buf = tmppar->Clone();
+#else
+               buf = new LyXParagraph(*tmppar);
+#endif
                LyXParagraph * tmppar2 = buf;
                
                while (tmppar != endpar
                       && tmppar->next()) {
                        tmppar = tmppar->next();
+#if 0
                        tmppar2->next(tmppar->Clone());
+#else
+                       tmppar2->next(new LyXParagraph(*tmppar));
+#endif
                        tmppar2->next()->previous(tmppar2);
                        tmppar2 = tmppar2->next();
                }
@@ -195,14 +203,18 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
        if (pos > (*par)->size())
                pos = (*par)->size();
        
-       LyXParagraph * tmpbuf;
+       // LyXParagraph * tmpbuf;
        LyXParagraph * tmppar = *par;
        int tmppos = pos;
        
        // There are two cases: cutbuffer only one paragraph or many
        if (!buf->next()) {
                // only within a paragraph
-               tmpbuf = buf->Clone();
+#if 0
+               LyXParagraph * tmpbuf = buf->Clone();
+#else
+               LyXParagraph * tmpbuf = new LyXParagraph(*buf);
+#endif
                // Some provisions should be done here for checking
                // if we are inserting at the beginning of a
                // paragraph. If there are a space at the beginning
@@ -230,12 +242,20 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
                // many paragraphs
                
                // make a copy of the simple cut_buffer
-               tmpbuf = buf;
+               LyXParagraph * tmpbuf = buf;
+#if 0
                LyXParagraph * simple_cut_clone = tmpbuf->Clone();
+#else
+               LyXParagraph * simple_cut_clone = new LyXParagraph(*tmpbuf);
+#endif
                LyXParagraph * tmpbuf2 = simple_cut_clone;
                while (tmpbuf->next()) {
                        tmpbuf = tmpbuf->next();
+#if 0
                        tmpbuf2->next(tmpbuf->Clone());
+#else
+                       tmpbuf2->next(new LyXParagraph(*tmpbuf));
+#endif
                        tmpbuf2->next()->previous(tmpbuf2);
                        tmpbuf2 = tmpbuf2->next();
                }
index 3609380f2d42d2aac5c76a7916994bde196fbb04..4c0f8967e764a2b4e002b7ade43132aed53ae7af 100644 (file)
@@ -1,3 +1,8 @@
+2001-05-08  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * insettext.C (Read): use clear
+       (SetParagraphData): use LyXParagraph copy constructor instead of clone
+
 2001-05-04  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * insetfloatlist.h: add a bunch of std:: qualifiers.
index e73455ce2a3cb27b3d3d173e14f1eb6ae4fd0d2b..d1cd344fea309d4d5c99f0dc63a2b5290279f72b 100644 (file)
@@ -49,19 +49,6 @@ InsetCollapsable::InsetCollapsable()
 }
 
 
-#if 0
-Inset * InsetCollapsable::Clone(Buffer const &) const
-{
-       InsetCollapsable * result = new InsetCollapsable;
-       result->inset.init(&inset);
-       result->inset.setOwner(result);
-
-       result->collapsed = collapsed;
-       return result;
-}
-#endif
-
-
 bool InsetCollapsable::InsertInset(BufferView * bv, Inset * in)
 {
        if (!InsertInsetAllowed(in)) {
index 47100ac6a4dc392e4afee7fe6620a9fc92b5606e..de94c0c9882d9535a57268102a0bf700409bce97 100644 (file)
@@ -42,8 +42,6 @@ public:
        ///
        InsetCollapsable();
        ///
-       //Inset * Clone(Buffer const &) const;
-       ///
        void Read(Buffer const *, LyXLex &);
        ///
        void Write(Buffer const *, std::ostream &) const;
@@ -132,9 +130,11 @@ public:
        bool nodraw() const;
        ///
        int scroll(bool recursive=true) const;
+       ///
        void scroll(BufferView *bv, float sx) const {
                UpdatableInset::scroll(bv, sx);
        }
+       ///
        void scroll(BufferView *bv, int offset) const {
                UpdatableInset::scroll(bv, offset);
        }
@@ -167,7 +167,6 @@ protected:
        mutable int button_top_y;
        ///
        mutable int button_bottom_y;
-
 private:
        ///
        string label;
index 95080ca68496d889d93cfe1e82cac83945a532a6..ff31082778143597bfcda2651bb6c485b2f5cd89 100644 (file)
@@ -164,12 +164,14 @@ InsetGraphics::InsetGraphics()
        : cacheHandle(0), imageLoaded(false)
 {}
 
+
 InsetGraphics::~InsetGraphics()
 {
        // Emits the hide signal to the dialog connected (if any)
        hideDialog();
 }
 
+
 char const *
 InsetGraphics::statusMessage() const
 {
@@ -202,6 +204,7 @@ InsetGraphics::statusMessage() const
        return msg;
 }
 
+
 int InsetGraphics::ascent(BufferView *, LyXFont const &) const
 {
        LyXImage * pixmap = 0;
@@ -236,6 +239,7 @@ int InsetGraphics::width(BufferView *, LyXFont const & font) const
        }
 }
 
+
 void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
                          int baseline, float & x, bool) const
 {
@@ -406,7 +410,6 @@ InsetGraphics::createLatexOptions() const
 }
 
 
-
 string const 
 InsetGraphics::prepareFile(Buffer const *buf) const
 {
@@ -457,6 +460,7 @@ InsetGraphics::prepareFile(Buffer const *buf) const
        return outfile;
 }
 
+
 int InsetGraphics::Latex(Buffer const *buf, ostream & os,
                bool /*fragile*/, bool/*fs*/) const
 {
@@ -542,6 +546,7 @@ int InsetGraphics::Linuxdoc(Buffer const *, ostream &) const
        return 0;
 }
 
+
 // For explanation on inserting graphics into DocBook checkout:
 // http://linuxdoc.org/LDP/LDP-Author-Guide/inserting-pictures.html
 // See also the docbook guide at http://www.docbook.org/
@@ -571,6 +576,7 @@ void InsetGraphics::Validate(LaTeXFeatures & features) const
                features.subfigure = true;
 }
 
+
 // Update the inset after parameters changed (read from file or changed in
 // dialog.
 void InsetGraphics::updateInset() const
@@ -590,6 +596,7 @@ void InsetGraphics::updateInset() const
        cacheHandle = temp;
 }
 
+
 bool InsetGraphics::setParams(InsetGraphicsParams const & params)
 {
        // If nothing is changed, just return and say so.
@@ -606,13 +613,16 @@ bool InsetGraphics::setParams(InsetGraphicsParams const & params)
        return true;
 }
 
+
 InsetGraphicsParams InsetGraphics::getParams() const
 {
        return params;
 }
 
+
 Inset * InsetGraphics::Clone(Buffer const &) const
 {
+#warning use the copy constructor instead. (Lgb)
        InsetGraphics * newInset = new InsetGraphics;
 
        newInset->cacheHandle = cacheHandle;
index f570e72eeaa568133b7305d67079c8f1a7cec0cc..2af0d6d1701194d6f6a2ac950e48da59448839be 100644 (file)
@@ -135,7 +135,7 @@ void InsetText::clear()
 {
        // delete all instances of LyXText before deleting the paragraps used
        // by it.
-       for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit){
+       for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit) {
                delete (*cit).second;
                (*cit).second = 0;
        }
@@ -177,6 +177,7 @@ void InsetText::Read(Buffer const * buf, LyXLex & lex)
        char depth = 0; // signed or unsigned?
        LyXFont font(LyXFont::ALL_INHERIT);
 
+#if 0
        // delete all instances of LyXText before deleting the paragraps used
        // by it.
        for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit) {
@@ -191,6 +192,10 @@ void InsetText::Read(Buffer const * buf, LyXLex & lex)
        }
 
        par = new LyXParagraph;
+#else
+       clear();
+#endif
+       
        while (lex.IsOK()) {
                lex.nextToken();
                token = lex.GetString();
@@ -1482,12 +1487,20 @@ void InsetText::SetParagraphData(LyXParagraph * p)
                par = tmp;
        }
 
+#if 0
        par = p->Clone();
+#else
+       par = new LyXParagraph(*p);
+#endif
        par->SetInsetOwner(this);
        LyXParagraph * np = par;
        while (p->next()) {
                p = p->next();
+#if 0
                np->next(p->Clone());
+#else
+               np->next(new LyXParagraph(*p));
+#endif
                np->next()->previous(np);
                np = np->next();
                np->SetInsetOwner(this);
index 0d0c87a35dc4715bb0aa407e1e9ead7397d26177..1c09a72024d8adf7d069ec63b32aded0d82e5e53 100644 (file)
@@ -88,6 +88,8 @@ public:
        /// this constructor inserts the new paragraph in a list
        explicit
        LyXParagraph(LyXParagraph * par);
+       ///
+       LyXParagraph(LyXParagraph const &);
        /// the destructor removes the new paragraph from the list
        ~LyXParagraph();
 
@@ -130,9 +132,10 @@ public:
        ///
        LyXParagraph * TeXEnvironment(Buffer const *, BufferParams const &,
                                      std::ostream &, TexRow & texrow);
+#if 0
        ///
        LyXParagraph * Clone() const;
-       
+#endif
        ///
        bool HasSameLayout(LyXParagraph const * par) const;
        
index c393574a94bfb6c5b34f55962a6993736d718824..e8f337704344fb470e80895ccdde8f9520ed15bb 100644 (file)
@@ -68,6 +68,7 @@ MathedArray::MathedArray(MathedArray const & array)
        deep_copy();
 }
 
+
 void MathedArray::deep_copy()
 {
        MathedIter it(this);
@@ -81,6 +82,7 @@ void MathedArray::deep_copy()
        }
 }
 
+
 void MathedArray::substitute(MathMacro * m)
 {
        if (m->nargs() == 0)
@@ -125,6 +127,7 @@ MathedArray & MathedArray::operator=(MathedArray const & array)
        return *this;
 }
 
+
 void MathedArray::push_back(MathedInset * inset, int t)
 {
        MathedIter it(this);
@@ -133,6 +136,7 @@ void MathedArray::push_back(MathedInset * inset, int t)
        it.insertInset(inset, t);
 }
 
+
 void MathedArray::push_back(byte b, MathedTextCodes c)
 {
        MathedIter it(this);
@@ -141,6 +145,7 @@ void MathedArray::push_back(byte b, MathedTextCodes c)
        it.insert(b, c);
 }
 
+
 void MathedArray::clear()
 {
        last_ = 0;
@@ -148,6 +153,7 @@ void MathedArray::clear()
        bf_[0] = 0;
 }
 
+
 void MathedArray::swap(MathedArray & array)
 {
        if (this != &array) {
@@ -348,6 +354,7 @@ void MathedArray::dump2(ostream & os) const
        os << endl;
 }
 
+
 void MathedArray::dump(ostream & os) const
 {
        MathedIter it( const_cast<MathedArray*>(this) );
@@ -371,5 +378,3 @@ void MathedArray::dump(ostream & os) const
                it.Next();
        }
 }
-
-       
index 91589b32e48067e0a751dc7796172bcb11d2cbf1..12e04d2895c438aa6822bdea0fe419df9994e831 100644 (file)
@@ -12,6 +12,7 @@
 
 using std::endl;
 
+
 MathMacroArgument::MathMacroArgument(int n)
        : MathedInset(string(), LM_OT_MACRO_ARG, LM_ST_TEXT),
                number_(n)
@@ -23,17 +24,20 @@ MathMacroArgument::MathMacroArgument(int n)
        }
 }
 
+
 MathedInset * MathMacroArgument::Clone()
 {
        //return new MathMacroArgument(*this);
        return this;
 }
 
+
 int MathMacroArgument::number() const
 {
        return number_;
 }
 
+
 void MathMacroArgument::substitute(MathMacro * /*m*/)
 {
        lyxerr << "Calling MathMacroArgument::substitute!\n";
index d51ffee57abe0dc79a5831a6fc88082387993299..a4348853dd14e344e4160fbdb6b085ec6e082c98 100644 (file)
@@ -26,6 +26,7 @@ MathedRowContainer & MathParInset::getRowSt()
        return row_;
 }
 
+
 string MathParInset::label() const
 {
        if (row_.size() == 0) {
@@ -53,6 +54,7 @@ MathedInset * MathParInset::Clone()
        return new MathParInset(*this);
 }
 
+
 void MathParInset::substitute(MathMacro * m)
 {
        //lyxerr << "called: MathParInset::substitute, m: " << m << endl;
index ce715e133a0d03ffd8d2258cab5224a82caae112..9b7110360c33a6456b9a5e693dbabebf88328a61 100644 (file)
@@ -50,6 +50,7 @@ void MathSpaceInset::Write(ostream & os, bool /* fragile */)
        }
 }
 
+
 void MathSpaceInset::WriteNormal(ostream & os)
 {
        os << "[space " << space_ << "] ";
index bf7593d71a36431b343528ac685984d4ecb4f258..b059f338719e15a7740cd7becc3bd3c87aab2009 100644 (file)
@@ -119,6 +119,63 @@ LyXParagraph::LyXParagraph(LyXParagraph * par)
 }
 
 
+LyXParagraph::LyXParagraph(LyXParagraph const & lp)
+{
+       for (int i = 0; i < 10; ++i) setCounter(i , 0);
+       enumdepth = 0;
+       itemdepth = 0;
+       next_ = 0;
+       previous_ = 0;
+       id_ = paragraph_id++;
+       Clear();
+   
+       MakeSameLayout(&lp);
+
+       // this is because of the dummy layout of the paragraphs that
+       // follow footnotes
+       layout = lp.layout;
+
+       inset_owner = lp.inset_owner;
+   
+        // ale970302
+       if (lp.bibkey)
+               bibkey = static_cast<InsetBibKey *>
+                       (lp.bibkey->Clone(*current_view->buffer()));
+       else
+               bibkey = 0;
+       
+       // copy everything behind the break-position to the new paragraph
+
+       text = lp.text;
+       fontlist = lp.fontlist;
+       insetlist = lp.insetlist;
+       for (InsetList::iterator it = insetlist.begin();
+            it != insetlist.end(); ++it)
+               it->inset = it->inset->Clone(*current_view->buffer());
+}
+
+
+// the destructor removes the new paragraph from the list
+LyXParagraph::~LyXParagraph()
+{
+       if (previous_)
+               previous_->next_ = next_;
+       if (next_)
+               next_->previous_ = previous_;
+
+       for (InsetList::iterator it = insetlist.begin();
+            it != insetlist.end(); ++it) {
+               delete (*it).inset;
+       }
+
+        // ale970302
+       delete bibkey;
+       //
+       //lyxerr << "LyXParagraph::paragraph_id = "
+       //       << LyXParagraph::paragraph_id << endl;
+}
+
+
 void LyXParagraph::writeFile(Buffer const * buf, ostream & os,
                             BufferParams const & bparams,
                             char footflag, char dth) const
@@ -408,27 +465,6 @@ void LyXParagraph::Clear()
 }
 
 
-// the destructor removes the new paragraph from the list
-LyXParagraph::~LyXParagraph()
-{
-       if (previous_)
-               previous_->next_ = next_;
-       if (next_)
-               next_->previous_ = previous_;
-
-       for (InsetList::iterator it = insetlist.begin();
-            it != insetlist.end(); ++it) {
-               delete (*it).inset;
-       }
-
-        // ale970302
-       delete bibkey;
-       //
-       //lyxerr << "LyXParagraph::paragraph_id = "
-       //       << LyXParagraph::paragraph_id << endl;
-}
-
-
 void LyXParagraph::Erase(LyXParagraph::size_type pos)
 {
        lyx::Assert(pos < size());
@@ -1013,6 +1049,7 @@ int LyXParagraph::StripLeadingSpaces(LyXTextClassList::size_type tclass)
 }
 
 
+#if 0
 LyXParagraph * LyXParagraph::Clone() const
 {
        // create a new paragraph
@@ -1043,6 +1080,7 @@ LyXParagraph * LyXParagraph::Clone() const
                (*it).inset = (*it).inset->Clone(*current_view->buffer());
        return result;
 }
+#endif
 
 
 bool LyXParagraph::HasSameLayout(LyXParagraph const * par) const
index 3d68635b218d858c59564110881b35e661ed2bd8..ce8d196ee99fd69dadf8f46032d4f1f77a8bb07f 100644 (file)
@@ -115,6 +115,12 @@ LyXTabular::LyXTabular(Buffer const * buf, InsetTabular * inset, LyXLex & lex)
 
 LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
 {
+#if 0
+#warning This while method should look like this: (Lgb)
+
+               LyXTabular tmp(lt);
+               tmp.swap(*this);
+#else
        // If this and lt is not of the same size we have a serious bug
        // So then it is ok to throw an exception, or for now
        // call abort()
@@ -134,7 +140,7 @@ LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
        rotate = lt.rotate;
 
        Reinit();
-       
+#endif
        return *this;
 }
 
index d1ec3e1612d7c2a8b379d96875cad92849482463..ae472cbc90ab1b57705cf8687219f4d5adca1e47 100644 (file)
@@ -2672,8 +2672,6 @@ Undo * LyXText::CreateUndo(Buffer * buf, Undo::undo_kind kind,
        }
        // create a new Undo
        LyXParagraph * undopar;
-       LyXParagraph * tmppar;
-       LyXParagraph * tmppar2;
 
        LyXParagraph * start = 0;
        LyXParagraph * end = 0;
@@ -2691,8 +2689,12 @@ Undo * LyXText::CreateUndo(Buffer * buf, Undo::undo_kind kind,
        }
        if (start && end && (start != end->next()) &&
            ((before != behind) || (!before && !behind))) {
-               tmppar = start;
-               tmppar2 = tmppar->Clone();
+               LyXParagraph * tmppar = start;
+#if 0
+               LyXParagraph * tmppar2 = tmppar->Clone();
+#else
+               LyXParagraph * tmppar2 = new LyXParagraph(*tmppar);
+#endif
                tmppar2->id(tmppar->id());
 
                // a memory optimization: Just store the layout information
@@ -2706,7 +2708,11 @@ Undo * LyXText::CreateUndo(Buffer * buf, Undo::undo_kind kind,
   
                while (tmppar != end && tmppar->next()) {
                        tmppar = tmppar->next();
+#if 0
                        tmppar2->next(tmppar->Clone());
+#else
+                       tmppar2->next(new LyXParagraph(*tmppar));
+#endif
                        tmppar2->next()->id(tmppar->id());
                        // a memory optimization: Just store the layout
                        // information when only edit