From: Lars Gullik Bjønnes Date: Tue, 8 May 2001 10:50:09 +0000 (+0000) Subject: remove LyXParagraph Clone use newly added copy constructor instead, some whitespace... X-Git-Tag: 1.6.10~21253 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=352479f603b4e3cab9ae7f3a54262983b79595af;p=features.git 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 --- diff --git a/po/POTFILES.in b/po/POTFILES.in index 04b1702eba..c0e4828c9c 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -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 diff --git a/src/ChangeLog b/src/ChangeLog index 46b1603593..ee996bc8e9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2001-05-08 Lars Gullik Bjønnes + + * 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 * minibuffer.C (peek_event): temporarily reduce the functionality diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 1ac379811b..b549d2013c 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -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(); } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 3609380f2d..4c0f8967e7 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2001-05-08 Lars Gullik Bjønnes + + * insettext.C (Read): use clear + (SetParagraphData): use LyXParagraph copy constructor instead of clone + 2001-05-04 Jean-Marc Lasgouttes * insetfloatlist.h: add a bunch of std:: qualifiers. diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index e73455ce2a..d1cd344fea 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -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)) { diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 47100ac6a4..de94c0c988 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -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; diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 95080ca684..ff31082778 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -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; diff --git a/src/insets/insettext.C b/src/insets/insettext.C index f570e72eea..2af0d6d170 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -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); diff --git a/src/lyxparagraph.h b/src/lyxparagraph.h index 0d0c87a35d..1c09a72024 100644 --- a/src/lyxparagraph.h +++ b/src/lyxparagraph.h @@ -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; diff --git a/src/mathed/array.C b/src/mathed/array.C index c393574a94..e8f3377043 100644 --- a/src/mathed/array.C +++ b/src/mathed/array.C @@ -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(this) ); @@ -371,5 +378,3 @@ void MathedArray::dump(ostream & os) const it.Next(); } } - - diff --git a/src/mathed/math_macroarg.C b/src/mathed/math_macroarg.C index 91589b32e4..12e04d2895 100644 --- a/src/mathed/math_macroarg.C +++ b/src/mathed/math_macroarg.C @@ -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"; diff --git a/src/mathed/math_parinset.C b/src/mathed/math_parinset.C index d51ffee57a..a4348853dd 100644 --- a/src/mathed/math_parinset.C +++ b/src/mathed/math_parinset.C @@ -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; diff --git a/src/mathed/math_spaceinset.C b/src/mathed/math_spaceinset.C index ce715e133a..9b7110360c 100644 --- a/src/mathed/math_spaceinset.C +++ b/src/mathed/math_spaceinset.C @@ -50,6 +50,7 @@ void MathSpaceInset::Write(ostream & os, bool /* fragile */) } } + void MathSpaceInset::WriteNormal(ostream & os) { os << "[space " << space_ << "] "; diff --git a/src/paragraph.C b/src/paragraph.C index bf7593d71a..b059f33871 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -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 + (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 diff --git a/src/tabular.C b/src/tabular.C index 3d68635b21..ce8d196ee9 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -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; } diff --git a/src/text2.C b/src/text2.C index d1ec3e1612..ae472cbc90 100644 --- a/src/text2.C +++ b/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