]> git.lyx.org Git - features.git/commitdiff
some reindentation, revert workarea xpos++, constify, remove all traces of LyXParagra...
authorLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 8 May 2001 13:28:44 +0000 (13:28 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 8 May 2001 13:28:44 +0000 (13:28 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1989 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView_pimpl.C
src/ChangeLog
src/CutAndPaste.C
src/WorkArea.h
src/insets/insettext.C
src/lyxparagraph.h
src/paragraph.C
src/text2.C
src/undo.C
src/undo.h

index 508fa79aa6c285c02db17c185f184044ede433e3..0d252ea5d0a583d287425619886d324b2138be34 100644 (file)
@@ -902,7 +902,8 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
 #if 0
                        if (move_cursor && (tmpinset != bv_->theLockingInset()))
 #endif
-                               text->SetCursor(bv_, cursor.par(),cursor.pos()-1,true);
+                               text->SetCursor(bv_, cursor.par(),
+                                               cursor.pos() - 1, true);
                        x = x - start_x;
                        // The origin of an inset is on the baseline
                        y = y_tmp - (text->cursor.y()); 
index ee996bc8e93e311e5b268c4cd658073b04586e42..fc5f99f35e19c99751bd457b2d1130cd17c7697f 100644 (file)
@@ -1,5 +1,12 @@
 2001-05-08  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
+       * paragraph.C (writeFile): reindent
+       (Erase): reindent
+
+       * WorkArea.h: revert the xpos + etc changes.
+
+       * CutAndPaste.C (SwitchLayoutsBetweenClasses): constify name and s
+
        * lyxparagraph.[Ch]: add copy constructor, remove Clone
 
        * CutAndPaste.C (copySelection): use LyXParagraph copy constructor
index b549d2013c59c6fd11bdb86e15ad346649c431b0..59b1fdc37e5fd34a0b43103f1cd7bb470c058a31 100644 (file)
@@ -159,21 +159,13 @@ 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();
                }
@@ -210,11 +202,8 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
        // There are two cases: cutbuffer only one paragraph or many
        if (!buf->next()) {
                // only within a paragraph
-#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
@@ -243,19 +232,12 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
                
                // make a copy of the simple cut_buffer
                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();
                }
@@ -343,7 +325,8 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(LyXTextClassList::size_type c1,
                return ret;
 
     while (par) {
-               string name = textclasslist.NameOfLayout(c1, par->layout);
+               string const name = textclasslist.NameOfLayout(c1,
+                                                              par->layout);
                int lay = 0;
                pair<bool, LyXTextClass::LayoutList::size_type> pp =
                        textclasslist.NumberOfLayout(c2, name);
@@ -357,7 +340,7 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(LyXTextClassList::size_type c1,
                
                if (name != textclasslist.NameOfLayout(c2, par->layout)) {
                        ++ret;
-                       string s = _("Layout had to be changed from\n")
+                       string const s = _("Layout had to be changed from\n")
                                + name + _(" to ")
                                + textclasslist.NameOfLayout(c2, par->layout)
                                + _("\nbecause of class conversion from\n")
index 1d757c021f9d4da38339f54697a9cd99408cf135..95d8e0d334a6a1287c90e562aa4239b9c7e428c3 100644 (file)
@@ -35,17 +35,17 @@ public:
        ///
        int workWidth() const { return work_area->w; }
        ///
-       //unsigned int width() const { return work_area->w + scrollbar->w; }
-       unsigned int width() const { return backgroundbox->w + 15; }
+       unsigned int width() const { return work_area->w + scrollbar->w; }
+       //unsigned int width() const { return backgroundbox->w + 15; }
        ///
-       //unsigned int height() const { return work_area->h; }
-       unsigned int height() const { return backgroundbox->h; }
+       unsigned int height() const { return work_area->h; }
+       //unsigned int height() const { return backgroundbox->h; }
        ///
-       //int xpos() const { return work_area->x; }
-       int xpos() const { return backgroundbox->x; }
+       int xpos() const { return work_area->x; }
+       //int xpos() const { return backgroundbox->x; }
        ///
-       //int ypos() const { return work_area->y; }
-       int ypos() const { return backgroundbox->y; }
+       int ypos() const { return work_area->y; }
+       //int ypos() const { return backgroundbox->y; }
        ///
        void resize(int xpos, int ypos, int width, int height);
        ///
index 2af0d6d1701194d6f6a2ac950e48da59448839be..b4aead7368dadb18d88da3387c3a808cd7607237 100644 (file)
@@ -177,24 +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) {
-               delete (*cit).second;
-               (*cit).second = 0;
-       }
-
-       while (par) {
-               LyXParagraph * tmp = par->next();
-               delete par;
-               par = tmp;
-       }
-
-       par = new LyXParagraph;
-#else
        clear();
-#endif
        
        while (lex.IsOK()) {
                lex.nextToken();
@@ -1487,20 +1470,12 @@ 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 1c09a72024d8adf7d069ec63b32aded0d82e5e53..6b823baeb4de5e749950c3fb867d2f29b48fe3dd 100644 (file)
@@ -132,10 +132,6 @@ public:
        ///
        LyXParagraph * TeXEnvironment(Buffer const *, BufferParams const &,
                                      std::ostream &, TexRow & texrow);
-#if 0
-       ///
-       LyXParagraph * Clone() const;
-#endif
        ///
        bool HasSameLayout(LyXParagraph const * par) const;
        
index b059f338719e15a7740cd7becc3bd3c87aab2009..314c4829c3515fd47ee2c6d633be8582f762a8e0 100644 (file)
@@ -180,80 +180,80 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os,
                             BufferParams const & bparams,
                             char footflag, char dth) const
 {
-               // The beginning or end of a deeper (i.e. nested) area?
-               if (dth != params.depth()) {
-                       if (params.depth() > dth) {
-                               while (params.depth() > dth) {
-                                       os << "\n\\begin_deeper ";
-                                       ++dth;
-                               }
-                       } else {
-                               while (params.depth() < dth) {
-                                       os << "\n\\end_deeper ";
-                                       --dth;
-                               }
+       // The beginning or end of a deeper (i.e. nested) area?
+       if (dth != params.depth()) {
+               if (params.depth() > dth) {
+                       while (params.depth() > dth) {
+                               os << "\n\\begin_deeper ";
+                               ++dth;
                        }
-               }
-
-               // First write the layout
-               os << "\n\\layout "
-                  << textclasslist.NameOfLayout(bparams.textclass, layout)
-                  << "\n";
-
-               // Maybe some vertical spaces.
-               if (params.spaceTop().kind() != VSpace::NONE)
-                       os << "\\added_space_top "
-                          << params.spaceTop().asLyXCommand() << " ";
-               if (params.spaceBottom().kind() != VSpace::NONE)
-                       os << "\\added_space_bottom "
-                          << params.spaceBottom().asLyXCommand() << " ";
-
-               // Maybe the paragraph has special spacing
-               params.spacing().writeFile(os, true);
-               
-               // The labelwidth string used in lists.
-               if (!params.labelWidthString().empty())
-                       os << "\\labelwidthstring "
-                          << params.labelWidthString() << '\n';
-
-               // Lines above or below?
-               if (params.lineTop())
-                       os << "\\line_top ";
-               if (params.lineBottom())
-                       os << "\\line_bottom ";
-
-               // Pagebreaks above or below?
-               if (params.pagebreakTop())
-                       os << "\\pagebreak_top ";
-               if (params.pagebreakBottom())
-                       os << "\\pagebreak_bottom ";
-                       
-               // Start of appendix?
-               if (params.startOfAppendix())
-                       os << "\\start_of_appendix ";
-
-               // Noindent?
-               if (params.noindent())
-                       os << "\\noindent ";
-                       
-               // Alignment?
-               if (params.align() != LYX_ALIGN_LAYOUT) {
-                       int h = 0;
-                       switch (params.align()) {
-                       case LYX_ALIGN_LEFT: h = 1; break;
-                       case LYX_ALIGN_RIGHT: h = 2; break;
-                       case LYX_ALIGN_CENTER: h = 3; break;
-                       default: h = 0; break;
+               } else {
+                       while (params.depth() < dth) {
+                               os << "\n\\end_deeper ";
+                               --dth;
                        }
-                       os << "\\align " << string_align[h] << " ";
                }
-
+       }
+       
+       // First write the layout
+       os << "\n\\layout "
+          << textclasslist.NameOfLayout(bparams.textclass, layout)
+          << "\n";
+       
+       // Maybe some vertical spaces.
+       if (params.spaceTop().kind() != VSpace::NONE)
+               os << "\\added_space_top "
+                  << params.spaceTop().asLyXCommand() << " ";
+       if (params.spaceBottom().kind() != VSpace::NONE)
+               os << "\\added_space_bottom "
+                  << params.spaceBottom().asLyXCommand() << " ";
+       
+       // Maybe the paragraph has special spacing
+       params.spacing().writeFile(os, true);
+       
+       // The labelwidth string used in lists.
+       if (!params.labelWidthString().empty())
+               os << "\\labelwidthstring "
+                  << params.labelWidthString() << '\n';
+       
+       // Lines above or below?
+       if (params.lineTop())
+               os << "\\line_top ";
+       if (params.lineBottom())
+               os << "\\line_bottom ";
+       
+       // Pagebreaks above or below?
+       if (params.pagebreakTop())
+               os << "\\pagebreak_top ";
+       if (params.pagebreakBottom())
+               os << "\\pagebreak_bottom ";
+       
+       // Start of appendix?
+       if (params.startOfAppendix())
+               os << "\\start_of_appendix ";
+       
+       // Noindent?
+       if (params.noindent())
+               os << "\\noindent ";
+       
+       // Alignment?
+       if (params.align() != LYX_ALIGN_LAYOUT) {
+               int h = 0;
+               switch (params.align()) {
+               case LYX_ALIGN_LEFT: h = 1; break;
+               case LYX_ALIGN_RIGHT: h = 2; break;
+               case LYX_ALIGN_CENTER: h = 3; break;
+               default: h = 0; break;
+               }
+               os << "\\align " << string_align[h] << " ";
+       }
+       
        // bibitem  ale970302
        if (bibkey)
                bibkey->Write(buf, os);
-
+       
        LyXFont font1(LyXFont::ALL_INHERIT, bparams.language);
-
+       
        int column = 0;
        for (size_type i = 0; i < size(); ++i) {
                if (!i) {
@@ -268,7 +268,7 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os,
                        column = 0;
                        font1 = font2;
                }
-
+               
                value_type const c = GetChar(i);
                switch (c) {
                case META_INSET:
@@ -468,60 +468,60 @@ void LyXParagraph::Clear()
 void LyXParagraph::Erase(LyXParagraph::size_type pos)
 {
        lyx::Assert(pos < size());
-               // if it is an inset, delete the inset entry 
-               if (text[pos] == LyXParagraph::META_INSET) {
-                       // find the entry
-                       InsetTable search_inset(pos, 0);
-                       InsetList::iterator it =
-                               lower_bound(insetlist.begin(),
-                                           insetlist.end(),
-                                           search_inset, matchIT());
-                       if (it != insetlist.end() && (*it).pos == pos) {
-                               delete (*it).inset;
-                               insetlist.erase(it);
-                       }
+       // if it is an inset, delete the inset entry 
+       if (text[pos] == LyXParagraph::META_INSET) {
+               // find the entry
+               InsetTable search_inset(pos, 0);
+               InsetList::iterator it =
+                       lower_bound(insetlist.begin(),
+                                   insetlist.end(),
+                                   search_inset, matchIT());
+               if (it != insetlist.end() && (*it).pos == pos) {
+                       delete (*it).inset;
+                       insetlist.erase(it);
                }
-
-               text.erase(text.begin() + pos);
-
-               // Erase entries in the tables.
-               FontTable search_font(pos, LyXFont());
-               
-               FontList::iterator it =
-                       lower_bound(fontlist.begin(),
-                                   fontlist.end(),
-                                   search_font, matchFT());
-               if (it != fontlist.end() && (*it).pos() == pos &&
-                   (pos == 0 || 
-                    (it != fontlist.begin() && (*(it - 1)).pos() == pos - 1))) {
-                       // If it is a multi-character font
-                       // entry, we just make it smaller
-                       // (see update below), otherwise we
-                       // should delete it.
-                       unsigned int const i = it - fontlist.begin();
-                       fontlist.erase(fontlist.begin() + i);
-                       it = fontlist.begin() + i;
-                       if (i > 0 && i < fontlist.size() &&
-                           fontlist[i - 1].font() == fontlist[i].font()) {
-                               fontlist.erase(fontlist.begin() + i - 1);
-                               it = fontlist.begin() + i - 1;
-                       }
+       }
+       
+       text.erase(text.begin() + pos);
+       
+       // Erase entries in the tables.
+       FontTable search_font(pos, LyXFont());
+       
+       FontList::iterator it =
+               lower_bound(fontlist.begin(),
+                           fontlist.end(),
+                           search_font, matchFT());
+       if (it != fontlist.end() && (*it).pos() == pos &&
+           (pos == 0 || 
+            (it != fontlist.begin() && (*(it - 1)).pos() == pos - 1))) {
+               // If it is a multi-character font
+               // entry, we just make it smaller
+               // (see update below), otherwise we
+               // should delete it.
+               unsigned int const i = it - fontlist.begin();
+               fontlist.erase(fontlist.begin() + i);
+               it = fontlist.begin() + i;
+               if (i > 0 && i < fontlist.size() &&
+                   fontlist[i - 1].font() == fontlist[i].font()) {
+                       fontlist.erase(fontlist.begin() + i - 1);
+                       it = fontlist.begin() + i - 1;
                }
-
-               // Update all other entries.
-               FontList::iterator fend = fontlist.end();
-               for (; it != fend; ++it)
-                       (*it).pos((*it).pos() - 1);
-
-               // Update the inset table.
-               InsetTable search_inset(pos, 0);
-               InsetList::iterator lend = insetlist.end();
-               for (InsetList::iterator it =
-                            upper_bound(insetlist.begin(),
-                                        lend,
-                                        search_inset, matchIT());
-                    it != lend; ++it)
-                       --(*it).pos;
+       }
+       
+       // Update all other entries.
+       FontList::iterator fend = fontlist.end();
+       for (; it != fend; ++it)
+               (*it).pos((*it).pos() - 1);
+       
+       // Update the inset table.
+       InsetTable search_inset(pos, 0);
+       InsetList::iterator lend = insetlist.end();
+       for (InsetList::iterator it =
+                    upper_bound(insetlist.begin(),
+                                lend,
+                                search_inset, matchIT());
+            it != lend; ++it)
+               --(*it).pos;
 }
 
 
@@ -1049,40 +1049,6 @@ int LyXParagraph::StripLeadingSpaces(LyXTextClassList::size_type tclass)
 }
 
 
-#if 0
-LyXParagraph * LyXParagraph::Clone() const
-{
-       // create a new paragraph
-       LyXParagraph * result = new LyXParagraph;
-   
-       result->MakeSameLayout(this);
-
-       // this is because of the dummy layout of the paragraphs that
-       // follow footnotes
-       result->layout = layout;
-
-       result->inset_owner = inset_owner;
-   
-        // ale970302
-       if (bibkey)
-               result->bibkey = static_cast<InsetBibKey *>
-                                (bibkey->Clone(*current_view->buffer()));
-       else
-               result->bibkey = 0;
-    
-       // copy everything behind the break-position to the new paragraph
-
-       result->text = text;
-       result->fontlist = fontlist;
-       result->insetlist = insetlist;
-       for (InsetList::iterator it = result->insetlist.begin();
-            it != result->insetlist.end(); ++it)
-               (*it).inset = (*it).inset->Clone(*current_view->buffer());
-       return result;
-}
-#endif
-
-
 bool LyXParagraph::HasSameLayout(LyXParagraph const * par) const
 {
        return 
index ae472cbc90ab1b57705cf8687219f4d5adca1e47..572e1778df32d66d15056375b4e9856079ec3df7 100644 (file)
@@ -2690,11 +2690,7 @@ Undo * LyXText::CreateUndo(Buffer * buf, Undo::undo_kind kind,
        if (start && end && (start != end->next()) &&
            ((before != behind) || (!before && !behind))) {
                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
@@ -2708,11 +2704,7 @@ 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
index 793df3b079f3562bbd57e90f043b8508e95a7a27..bc51dff11ea8a9ce4b71cc6972937a55b9f14e38 100644 (file)
 
 #include <config.h>
 
-#include "undo.h"
-
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
+#include "undo.h"
+
 
 Undo::Undo(undo_kind kind_arg,
           int number_before_arg, int number_behind_arg,
index d378dc7a73bb3b5c1fd4a4d4daf4d0230f31e28b..d1c468848de3821da7cf5ac73690ae7f4a7d2cb2 100644 (file)
 #pragma interface
 #endif
 
+#include <list>
+
 #include "lyxparagraph.h"
 
-#include <list>
 
 ///
 class Undo {