make ParagraphList::push_back take a reference instead of a pointer.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7036 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2003-05-24 11:54:10 +00:00
parent 27de8d9ee0
commit 297b40c725
12 changed files with 72 additions and 23 deletions

View 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.

View 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;

View File

@ -85,7 +85,7 @@ public:
///
iterator end() const;
///
void push_back(Paragraph *);
void push_back(Paragraph const &);
///
Paragraph const & front() const;
///

View 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());
}

View 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)

View 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:

View 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());

View 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>

View 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

View 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();

View 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;

View 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));