mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-02 08:10:39 +00:00
remove LyXParagraph Clone use newly added copy constructor instead, some whitespace changes
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1988 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
da10b97545
commit
352479f603
@ -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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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";
|
||||
|
@ -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;
|
||||
|
@ -50,6 +50,7 @@ void MathSpaceInset::Write(ostream & os, bool /* fragile */)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MathSpaceInset::WriteNormal(ostream & os)
|
||||
{
|
||||
os << "[space " << space_ << "] ";
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
14
src/text2.C
14
src/text2.C
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user