From 83e37d57dd3228814360a46cb5487ed4fb50ee6c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Thu, 29 May 2003 11:19:52 +0000 Subject: [PATCH] remove NO_STD_LIST stuff, and some other small changes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7063 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 16 ++ src/Makefile.am | 1 - src/ParagraphList.C | 392 ------------------------------------------ src/buffer.h | 1 - src/paragraph.C | 8 - src/paragraph.h | 26 +-- src/paragraph_funcs.h | 1 - src/paragraph_pimpl.h | 2 +- src/text2.C | 15 +- src/trans_mgr.C | 1 - 10 files changed, 25 insertions(+), 438 deletions(-) delete mode 100644 src/ParagraphList.C diff --git a/src/ChangeLog b/src/ChangeLog index d08116d749..805793496e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,21 @@ 2003-05-29 Lars Gullik Bjønnes + * trans_mgr.C: remove one case of current_view + + * text2.C (cursorBottom): delete NO_STD_LIST stuff + + * paragraph_funcs.h: remove paragraph.h include + + * paragraph.h: delete NO_STD_LIST stuff + + * paragraph.C (Paragraph): delete NO_STD_LIST stuff + + * buffer.h: remove paragraph.h include + + * ParagraphList.C: delete file + + * Makefile.am (lyx_SOURCES): remove ParagraphList.C + * toc.C (getTocList): adjust * paragraph_pimpl.C (validate): adjust diff --git a/src/Makefile.am b/src/Makefile.am index b830c21dd9..5d775d0342 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -79,7 +79,6 @@ lyx_SOURCES = \ MenuBackend.h \ paragraph_funcs.C \ paragraph_funcs.h \ - ParagraphList.C \ ParagraphList.h \ ParagraphParameters.C \ ParagraphParameters.h \ diff --git a/src/ParagraphList.C b/src/ParagraphList.C deleted file mode 100644 index 3e19224f9c..0000000000 --- a/src/ParagraphList.C +++ /dev/null @@ -1,392 +0,0 @@ -#include - -#include "ParagraphList.h" - -#include "paragraph.h" - -#ifdef NO_STD_LIST - -////////// The ParagraphList::iterator - -ParagraphList::iterator::iterator() - : ptr(0) -{} - - -ParagraphList::iterator::iterator(Paragraph * p) - : ptr(p) -{} - - -ParagraphList::iterator::reference -ParagraphList::iterator::operator*() -{ - return *ptr; -} - - -ParagraphList::iterator::pointer -ParagraphList::iterator::operator->() -{ - return ptr; -} - - -ParagraphList::iterator & -ParagraphList::iterator::operator++() -{ - ptr = ptr->next_par_; - return *this; -} - - -ParagraphList::iterator -ParagraphList::iterator::operator++(int) -{ - iterator tmp = *this; - ++*this; - return tmp; -} - - -ParagraphList::iterator & -ParagraphList::iterator::operator--() -{ - ptr = ptr->prev_par_; - return *this; -} - - -ParagraphList::iterator -ParagraphList::iterator::operator--(int) -{ - iterator tmp = *this; - --*this; - return tmp; -} - - -bool operator==(ParagraphList::iterator const & i1, - ParagraphList::iterator const & i2) -{ - return &(*const_cast(i1)) - == &(*const_cast(i2)); -} - - -bool operator!=(ParagraphList::iterator const & i1, - ParagraphList::iterator const & i2) -{ - return !(i1 == i2); -} - -////////// The ParagraphList::const_iterator - -ParagraphList::const_iterator::const_iterator() - : ptr(0) -{} - - -ParagraphList::const_iterator::const_iterator(Paragraph * p) - : ptr(p) -{} - - -ParagraphList::const_iterator::const_reference -ParagraphList::const_iterator::operator*() -{ - return *ptr; -} - - -ParagraphList::const_iterator::const_pointer -ParagraphList::const_iterator::operator->() -{ - return ptr; -} - - -ParagraphList::const_iterator & -ParagraphList::const_iterator::operator++() -{ - ptr = ptr->next_par_; - return *this; -} - - -ParagraphList::const_iterator -ParagraphList::const_iterator::operator++(int) -{ - const_iterator tmp = *this; - ++*this; - return tmp; -} - - -ParagraphList::const_iterator & -ParagraphList::const_iterator::operator--() -{ - ptr = ptr->prev_par_; - return *this; -} - - -ParagraphList::const_iterator -ParagraphList::const_iterator::operator--(int) -{ - const_iterator tmp = *this; - --*this; - return tmp; -} - - -bool operator==(ParagraphList::const_iterator const & i1, - ParagraphList::const_iterator const & i2) -{ - return &(*const_cast(i1)) - == &(*const_cast(i2)); -} - - -bool operator!=(ParagraphList::const_iterator const & i1, - ParagraphList::const_iterator const & i2) -{ - return !(i1 == i2); -} - -////////// -////////// The ParagraphList proper -////////// - -ParagraphList::ParagraphList() - : parlist(0) -{} - - -ParagraphList::ParagraphList(ParagraphList const & pl) - : parlist(0) -{ - // Deep copy. - ParagraphList::const_iterator it = pl.begin(); - ParagraphList::const_iterator end = pl.end(); - for (; it != end; ++it) { - push_back(*it); - } -} - - -ParagraphList & ParagraphList::operator=(ParagraphList const & rhs) -{ - ParagraphList tmp(rhs); - std::swap(parlist, tmp.parlist); - return *this; -} - - -ParagraphList::iterator -ParagraphList::insert(ParagraphList::iterator it, Paragraph const & p) -{ - Paragraph * par = new Paragraph(p); - - if (it != end()) { - Paragraph * prev = it->prev_par_; - par->next_par_ = &*it; - par->prev_par_ = prev; - prev->next_par_ = par; - it->prev_par_= par; - } else if (parlist == 0) { - parlist = par; - } else { - // Find last par. - Paragraph * last = parlist; - while (last->next_par_) - last = last->next_par_; - last->next_par_ = par; - par->prev_par_ = last; - } - return iterator(par); -} - - - -void ParagraphList::insert(iterator pos, iterator beg, iterator end) -{ - for (; beg != end; ++beg) { - insert(pos, *beg); - } -} - - -void ParagraphList::assign(iterator beg, iterator end) -{ - clear(); - for (; beg != end; ++beg) { - push_back(*beg); - } -} - - -void ParagraphList::splice(iterator pos, ParagraphList & pl) -{ - if (pl.parlist == 0) - return; - - Paragraph * first = pl.parlist; - Paragraph * last = first; - while (last->next_par_) - last = last->next_par_; - - if (pos == end()) { - if (parlist == 0) { - parlist = first; - } else { - Paragraph * last_par = &back(); - last_par->next_par_ = first; - first->prev_par_ = last_par; - } - } else if (pos == begin()) { - last->next_par_ = parlist; - parlist->prev_par_ = last; - parlist = first; - } else { - Paragraph * pos_par = &*pos; - Paragraph * before_pos = pos_par->prev_par_; - - before_pos->next_par_ = first; - first->prev_par_ = before_pos; - last->next_par_ = pos_par; - pos_par->prev_par_ = last; - } - pl.parlist = 0; -} - - -void ParagraphList::clear() -{ - while (parlist) { - Paragraph * tmp = parlist->next_par_; - delete parlist; - parlist = tmp; - } -} - - -ParagraphList::iterator ParagraphList::erase(ParagraphList::iterator it) -{ - Paragraph * prev = it->prev_par_; - Paragraph * next = it->next_par_; - - if (prev) - prev->next_par_ = next; - else - parlist = next; - - if (next) - next->prev_par_ = prev; - - delete &*it; - return next; -} - - -ParagraphList::iterator ParagraphList::erase(ParagraphList::iterator first, - ParagraphList::iterator last) -{ - while (first != last) { - erase(first++); - } - return last; -} - - -ParagraphList::iterator ParagraphList::begin() -{ - return iterator(parlist); -} - - -ParagraphList::const_iterator ParagraphList::begin() const -{ - return const_iterator(parlist); -} - - -ParagraphList::iterator ParagraphList::end() -{ - return iterator(); -} - - -ParagraphList::const_iterator ParagraphList::end() const -{ - return const_iterator(); -} - - -Paragraph const & ParagraphList::front() const -{ - return *parlist; -} - - -Paragraph & ParagraphList::front() -{ - return *parlist; -} - - -Paragraph const & ParagraphList::back() const -{ - Paragraph * tmp = parlist; - while (tmp->next_par_) - tmp = tmp->next_par_; - return *tmp; -} - - -Paragraph & ParagraphList::back() -{ - Paragraph * tmp = parlist; - while (tmp->next_par_) - tmp = tmp->next_par_; - return *tmp; -} - - -void ParagraphList::push_back(Paragraph const & pr) -{ - Paragraph * p = new Paragraph(pr); - - if (!parlist) { - parlist = p; - return; - } - - Paragraph * pos = parlist; - while (pos->next_par_) - pos = pos->next_par_; - pos->next_par_ = p; - p->prev_par_ = pos; -} - - -int ParagraphList::size() const -{ - // When we switch to a std::container this will be O(1) - // instead of O(n). (Lgb) - Paragraph * tmp = parlist; - int c = 0; - while (tmp) { - ++c; - tmp = tmp->next_par_; - } - return c; -} - - -bool ParagraphList::empty() const -{ - return parlist == 0; -} - -#endif diff --git a/src/buffer.h b/src/buffer.h index 455225f4c9..02de0cb72b 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -20,7 +20,6 @@ #include "bufferparams.h" #include "texrow.h" #include "ParagraphList.h" -#include "paragraph.h" #include "author.h" #include "iterators.h" diff --git a/src/paragraph.C b/src/paragraph.C index 229d223184..cd53424db6 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -70,10 +70,6 @@ Inset * minibuffer_inset; Paragraph::Paragraph() : pimpl_(new Paragraph::Pimpl(this)) { -#ifdef NO_STD_LIST - next_par_ = 0; - prev_par_ = 0; -#endif enumdepth = 0; itemdepth = 0; params().clear(); @@ -85,10 +81,6 @@ Paragraph::Paragraph(Paragraph const & lp) { enumdepth = 0; itemdepth = 0; -#ifdef NO_STD_LIST - next_par_ = 0; - prev_par_ = 0; -#endif // this is because of the dummy layout of the paragraphs that // follow footnotes layout_ = lp.layout(); diff --git a/src/paragraph.h b/src/paragraph.h index 5262105682..23df61ad70 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -34,20 +34,9 @@ class ParagraphParameters; class TexRow; class ParagraphList; -// Define this if you want to try out the new storage container for -// paragraphs. (Lgb) -// This is non working and far from finished. -//#define NO_STD_LIST 1 - /// A Paragraph holds all text, attributes and insets in a text paragraph class Paragraph { public: -#ifdef NO_STD_LIST - // Remove this whan ParagraphList transition is over. (Lgb) - friend class ParagraphList; - friend class ParagraphList::iterator; - friend class ParagraphList::const_iterator; -#endif /// enum META_KIND { /// Note that this is 1 right now to avoid @@ -182,10 +171,11 @@ public: /// mark whole par as erased void markErased(); - /// Paragraphs can contain "manual labels", for example, Description environment. - /// The text for this user-editable label is stored in the paragraph alongside - /// the text of the rest of the paragraph (the body). This function returns - /// the starting position of the body of the text in the paragraph. + /// Paragraphs can contain "manual labels", for example, Description + /// environment. The text for this user-editable label is stored in + /// the paragraph alongside the text of the rest of the paragraph + /// (the body). This function returns the starting position of the + /// body of the text in the paragraph. int beginningOfBody() const; /// @@ -304,18 +294,12 @@ public: /// InsetList insetlist; /// - //Counters & counters(); - /// void owningBuffer(Buffer const & b) { buffer_.reset(&b); } private: /// LyXLayout_ptr layout_; -#ifdef NO_STD_LIST - Paragraph * next_par_; - Paragraph * prev_par_; -#endif /// boost::optional buffer_; diff --git a/src/paragraph_funcs.h b/src/paragraph_funcs.h index 1567edca17..8004315313 100644 --- a/src/paragraph_funcs.h +++ b/src/paragraph_funcs.h @@ -13,7 +13,6 @@ #define PARAGRAPH_FUNCS_H #include "ParagraphList.h" -#include "paragraph.h" #include "support/types.h" class Buffer; diff --git a/src/paragraph_pimpl.h b/src/paragraph_pimpl.h index 4edd5da9e2..9a1ea617d6 100644 --- a/src/paragraph_pimpl.h +++ b/src/paragraph_pimpl.h @@ -1,7 +1,7 @@ // -*- C++ -*- /** * \file paragraph_pimpl.h - * Copyright 1995-2002 the LyX Team + * Copyright 1995-2003 the LyX Team * Read the file COPYING */ diff --git a/src/text2.C b/src/text2.C index 55a7b7c20d..c380608e37 100644 --- a/src/text2.C +++ b/src/text2.C @@ -883,18 +883,9 @@ void LyXText::cursorTop() void LyXText::cursorBottom() { -#warning FIXME - // This is how it should be: -#ifndef NO_STD_LIST - ParagraphList::iterator lastpit = boost::prior(ownerParagraphs().end()); -#else - ParagraphList::iterator lastpit = ownerParagraphs().begin(); - ParagraphList::iterator end = ownerParagraphs().end(); - while (boost::next(lastpit) != end) - ++lastpit; -#endif - int pos = lastpit->size(); - setCursor(lastpit, pos); + ParagraphList::iterator lastpit = + boost::prior(ownerParagraphs().end()); + setCursor(lastpit, lastpit->size()); } diff --git a/src/trans_mgr.C b/src/trans_mgr.C index 4ea10090b0..d4cc80fce2 100644 --- a/src/trans_mgr.C +++ b/src/trans_mgr.C @@ -17,7 +17,6 @@ using std::pair; extern string const DoAccent(string const &, tex_accent); extern string const DoAccent(char, tex_accent); -extern BufferView * current_view; // TransFSMData -- 2.39.2