]> git.lyx.org Git - features.git/commitdiff
make ParagraphList::push_back take a reference instead of a pointer.
authorLars Gullik Bjønnes <larsbj@gullik.org>
Sat, 24 May 2003 11:54:10 +0000 (11:54 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Sat, 24 May 2003 11:54:10 +0000 (11:54 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7036 a592a061-630c-0410-9148-cb99ea01b6c8

12 files changed:
src/ChangeLog
src/ParagraphList.C
src/ParagraphList.h
src/bufferlist.C
src/converter.C
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlDocument.C
src/insets/ChangeLog
src/insets/insettext.C
src/paragraph.C
src/paragraph.h
src/undo_funcs.C

index 32208912a17df29cb24e029beebba5e72364ef9b..7986fda635ccf2c235a42ed4408207536883abc4 100644 (file)
@@ -1,9 +1,17 @@
 2003-05-24  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
+       * paragraph.[Ch] (id): new function
+
+       * bufferlist.C (newFile): adjust
+
+       * ParagraphList.C (ParagraphList): adjust
+       (assign): adjust
+       (push_back): take a reference instead of a pointer.
+
        * paragraph.h: add NO_STD_LIST define, remove NO_NEXT define.
 
        * paragraph.C: remove all NO_NEXT node add some NO_STD_LIST parts
-       instead. 
+       instead.
 
        * ParagraphList.h: degenerate to std::list if NO_STD_LIST is not
        set else use old code.
index e375f0836fd838ef5480749fee07796c6ed190f2..9ebcdebe61d6f0a23c2aad26070fad9972edf260 100644 (file)
@@ -96,7 +96,7 @@ ParagraphList::ParagraphList(ParagraphList const & pl)
        ParagraphList::iterator it = pl.begin();
        ParagraphList::iterator end = pl.end();
        for (; it != end; ++it) {
-               push_back(new Paragraph(*it, false));
+               push_back(*it);
        }
 }
 
@@ -145,7 +145,7 @@ void ParagraphList::assign(iterator beg, iterator end)
 {
        clear();
        for (; beg != end; ++beg) {
-               push_back(new Paragraph(*beg, false));
+               push_back(*beg);
        }
 }
 
@@ -277,8 +277,10 @@ Paragraph & ParagraphList::back()
 }
 
 
-void ParagraphList::push_back(Paragraph * p)
+void ParagraphList::push_back(Paragraph const & pr)
 {
+       Paragraph * p = new Paragraph(pr, false);
+
        if (!parlist) {
                parlist = p;
                return;
index 38b6ede88b4de8ff6fc11446533236473c795066..2251875ac9de853042e27f5b887ad2ad75aa5c52 100644 (file)
@@ -85,7 +85,7 @@ public:
        ///
        iterator end() const;
        ///
-       void push_back(Paragraph *);
+       void push_back(Paragraph const &);
        ///
        Paragraph const & front() const;
        ///
index 52928050f62e5abbeab76f831c5480d85110fb0e..25faf205fbc3bb15d5cfe814f01ceb1d8fd9aec7 100644 (file)
@@ -362,7 +362,7 @@ Buffer * BufferList::readFile(string const & s, bool ronly)
                        if (fileInfoA.getModificationTime()
                            > fileInfo2.getModificationTime()) {
                                string const file = MakeDisplayPath(s, 20);
-                               string text = bformat(_("The backup of the document %1$s is newer.\n\n" 
+                               string text = bformat(_("The backup of the document %1$s is newer.\n\n"
                                        "Load the backup instead?"), file);
                                int const ret = Alert::prompt(_("Load backup?"),
                                        text, 0, 1, _("&Load backup"), _("Load &original"));
@@ -442,11 +442,11 @@ Buffer * BufferList::newFile(string const & name, string tname, bool isNamed)
                                "could not be read."), file);
                        Alert::error(_("Could not read template"), text);
                        // no template, start with empty buffer
-                       b->paragraphs.push_back(new Paragraph);
+                       b->paragraphs.push_back(Paragraph());
                        b->paragraphs.begin()->layout(b->params.getLyXTextClass().defaultLayout());
                }
        } else {  // start with empty buffer
-               b->paragraphs.push_back(new Paragraph);
+               b->paragraphs.push_back(Paragraph());
                b->paragraphs.begin()->layout(b->params.getLyXTextClass().defaultLayout());
        }
 
index 6ed16425ff3e992e3b138066c745c500f1bc42bd..cd8a7ae10e673916274bdde8cc0433cb67c18da6 100644 (file)
@@ -463,7 +463,7 @@ bool Converters::formatIsUsed(string const & format)
 }
 
 
-bool Converters::scanLog(Buffer const * buffer, string const & command,
+bool Converters::scanLog(Buffer const * buffer, string const & /*command*/,
                         string const & filename)
 {
        if (!buffer)
index 94e167e1ccdc1fdbefbb0015d9ed3898c2bb036a..b6c83d3401083588bf1096bcbbd23368821f2658 100644 (file)
@@ -1,3 +1,7 @@
+2003-05-24  Lars Gullik Bjønnes  <larsbj@gullik.net>
+
+       * ControlDocument.C (saveAsDefault): adjust
+
 2003-05-21  Alfredo Braunstein  <abraunst@libero.it>
 
        * ViewBase.h:
index 1edecf88c613c2616cf727c398cb77bcdd4ce34b..58b6877adf0e15d97617e63721ce37c039da633f 100644 (file)
@@ -162,8 +162,8 @@ void ControlDocument::saveAsDefault()
        defaults.params = params();
 
        // add an empty paragraph. Is this enough?
-       Paragraph * par = new Paragraph;
-       par->layout(params().getLyXTextClass().defaultLayout());
+       Paragraph par;
+       par.layout(params().getLyXTextClass().defaultLayout());
        defaults.paragraphs.push_back(par);
 
        defaults.writeFile(defaults.fileName());
index 53ceb435191d771fe275f3e254d1ac3ba22f62ca..807ade6e34588a4d722f8ebdc3f79004c12dbaa5 100644 (file)
@@ -1,3 +1,9 @@
+2003-05-24  Lars Gullik Bjønnes  <larsbj@gullik.net>
+
+       * insettext.C (InsetText): adjust
+       (clear): adjust
+       (setParagraphData): separate same_id cases, adjust
+       (appendParagraphs): adjust
 
 2003-05-23  André Pönitz  <poenitz@gmx.net>
 
index 383597720fd5ee1c8af332a7da8508a739d81e8f..d74aea11ded64147f5d154367a7223a0b6f17ae7 100644 (file)
@@ -139,7 +139,7 @@ InsetText::InsetText(BufferParams const & bp)
        : UpdatableInset(), lt(0), in_update(false), do_resize(0),
          do_reinit(false)
 {
-       paragraphs.push_back(new Paragraph);
+       paragraphs.push_back(Paragraph());
        paragraphs.begin()->layout(bp.getLyXTextClass().defaultLayout());
        if (bp.tracking_changes)
                paragraphs.begin()->trackChanges();
@@ -217,7 +217,7 @@ void InsetText::clear(bool just_mark_erased)
        LyXLayout_ptr old_layout = paragraphs.begin()->layout();
 
        paragraphs.clear();
-       paragraphs.push_back(new Paragraph);
+       paragraphs.push_back(Paragraph());
        paragraphs.begin()->setInsetOwner(this);
        paragraphs.begin()->layout(old_layout);
 
@@ -1945,13 +1945,34 @@ void InsetText::setParagraphData(ParagraphList const & plist, bool same_id)
        // we have to unlock any locked inset otherwise we're in troubles
        the_locking_inset = 0;
 
-       paragraphs.clear();
-       ParagraphList::iterator pit = plist.begin();
-       ParagraphList::iterator pend = plist.end();
-       for (; pit != pend; ++pit) {
-               Paragraph * new_par = new Paragraph(*pit, same_id);
-               new_par->setInsetOwner(this);
-               paragraphs.push_back(new_par);
+       #warning CHECK not adhering to same_id here might wreck havoc (Lgb)
+       // But it it makes no difference that is a lot better.
+       if (same_id) {
+               lyxerr << "Same_id called with 'true'" << endl;
+               lyxerr << "Please report this to the list." << endl;
+
+               paragraphs.clear();
+               ParagraphList::iterator it = plist.begin();
+               ParagraphList::iterator end = plist.end();
+               for (; it != end; ++it) {
+                       int const id = it->id();
+                       paragraphs.push_back(*it);
+                       Paragraph & tmp = paragraphs.back();
+                       tmp.setInsetOwner(this);
+                       tmp.id(id);
+               }
+       } else {
+#warning FIXME.
+               // See if this can be simplified when std::list is in effect.
+               paragraphs.clear();
+
+               ParagraphList::iterator it = plist.begin();
+               ParagraphList::iterator end = plist.end();
+               for (; it != end; ++it) {
+                       paragraphs.push_back(*it);
+                       Paragraph & tmp = paragraphs.back();
+                       tmp.setInsetOwner(this);
+               }
        }
 
        reinitLyXText();
@@ -2635,7 +2656,7 @@ void InsetText::appendParagraphs(Buffer * buffer, ParagraphList & plist)
 
        ParagraphList::iterator pend = plist.end();
        for (; pit != pend; ++pit) {
-               paragraphs.push_back(new Paragraph(*pit, false));
+               paragraphs.push_back(*pit);
        }
 
 #endif
index 605330f2ff6922b74dadd4d0006bb9a5db8ec95d..f5c2694036f9c3b9460d98e67fae7df44eaf0574 100644 (file)
@@ -1341,6 +1341,12 @@ int Paragraph::id() const
 }
 
 
+void Paragraph::id(int i)
+{
+       pimpl_->id_ = i;
+}
+
+
 LyXLayout_ptr const & Paragraph::layout() const
 {
        Inset * inset = inInset();
index 31362d94c53354eb12e3607492582bb4db4ec94f..c426e34132743196a9a33a1339051094b90ab7f8 100644 (file)
@@ -90,6 +90,8 @@ public:
 
        /// return the unique ID of this paragraph
        int id() const;
+       /// Set the Id of this paragraph.
+       void id(int);
 
        ///
        int startTeXParParams(BufferParams const &, std::ostream &, bool) const;
index f820005ebcaa49fba85ae0123657943c0c8d8413..a352978977ca9cc748ed32d5638a683edbe2c4a4 100644 (file)
@@ -168,7 +168,7 @@ bool textHandleUndo(BufferView * bv, Undo & undo)
                        }
                */
        }
-       
+
        // Set the cursor for redoing
        // if we have a par before the first.
        if (before != null) {
@@ -295,7 +295,7 @@ bool createUndo(BufferView * bv, Undo::undo_kind kind,
        // Create a new Undo.
        std::vector<Paragraph *> undo_pars;
 
-       for (ParagraphList::iterator it = *first; it != *last; ++it) 
+       for (ParagraphList::iterator it = *first; it != *last; ++it)
                undo_pars.push_back(new Paragraph(*it, true));
        undo_pars.push_back(new Paragraph(**last, true));