]> git.lyx.org Git - features.git/commitdiff
mathed59.diff
authorLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 15 Mar 2001 15:07:17 +0000 (15:07 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 15 Mar 2001 15:07:17 +0000 (15:07 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1773 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/ChangeLog
src/mathed/Makefile.am
src/mathed/math_parser.C
src/mathed/math_rowst.C [new file with mode: 0644]
src/mathed/math_rowst.h

index 93c0e72c5ee721d6a6c33400faa60775edf8249f..9ff1e4090c30eda4def1ed92144ab0b75656643c 100644 (file)
@@ -1,24 +1,35 @@
+
+2001-03-15  André Pönitz  <poenitz@htwm.de>
+
+       * math_parser.C: read '\nonumber' again (was broken)
+
+       * math_rowst.C: new file
+
 2001-03-15  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * math_cursor.C: added using directive.
 
 2001-03-15  André Pönitz  <poenitz@htwm.de>
+
        * math_rowst.h: Finally remove MathedRowSt
 
        * math_parser.C:
          math_xiter.C: changed accordingly
 
 2001-03-12  André Pönitz  <poenitz@htwm.de>
+
        *       math_rowst.h: replace MathedRowSt with MathedRowStruct,
            more robust MathedRowSt::[gs]etTab (to get rid of the constructor arg)
 
 2001-03-10  André Pönitz  <poenitz@htwm.de>
+
        * math_xiter.[Ch]:
          math_matrixinset.C: move adjustVerticalSt to the only place where
       it is used. Fix a small bug where the cached row structure and the
            actual data get out of sync after the deletion of whole rows
 
 2001-03-09  André Pönitz  <poenitz@htwm.de>
+
        * math_cursor.C: use std::vector<> in MathStackXIter
                change selstk from a pointer to the "real thing"
 
@@ -29,6 +40,7 @@
        * math_parser.C: use MathedRowContainer::insert_after
 
 2001-03-08  André Pönitz  <poenitz@htwm.de>
+
        * math_rowst.h: give MathedRowContainer an 'insert' method. 
 
        * math_xiter.C: new 'container()' method to encapsulated access to
@@ -41,6 +53,7 @@
          automatically created by the compiler are ok now.
        
 2001-03-06  André Pönitz  <poenitz@htwm.de>
+
        * array.[Ch]: factor out deep_copy,
          remove third argument from raw_pointer_insert 
 
@@ -53,6 +66,7 @@
          several files: corresponding changes
 
 2001-03-04  André Pönitz  <poenitz@htwm.de>
+
   * math_macrotemplate.[Ch]:
     math_macro.C: move update() functionality to the macro
 
index 2dd298b51f7399803fcf10dee688ae4757f1b97d..296c4362a5c2fc43cd8ce070089276ce0ab1d517 100644 (file)
@@ -60,6 +60,7 @@ libmathed_la_SOURCES = \
        math_parser.h \
        math_root.C \
        math_root.h \
+       math_rowst.C \
        math_rowst.h \
        math_spaceinset.C \
        math_spaceinset.h \
index 68bc7bff671f4d52d47864d46814896006b1f2df..e37a14397b95cc127da7d9c21ced4e84f43eb6c0 100644 (file)
@@ -424,9 +424,6 @@ void mathed_parse(MathedArray & array, unsigned flags = 0,
        int acc_brace = 0;
        int acc_braces[8];
        MathParInset * mt = (mtx) ? *mtx : 0;
-       MathedRowContainer::iterator crow;
-       if (mt)
-               crow = mt->getRowSt().begin();
 
        ++plevel;
        MathedIter data(&array);
@@ -604,8 +601,7 @@ void mathed_parse(MathedArray & array, unsigned flags = 0,
                case LM_TK_NEWLINE:
                        if (mt && (flags & FLAG_END)) {
                                if (mt->Permit(LMPF_ALLOW_CR)) {
-                                       mt->getRowSt().insert(crow);
-                                       ++crow;
+                                       mt->getRowSt().push_back();
                                        data.insert('K', LM_TC_CR);
                                } else 
                                        mathPrintError("Unexpected newline");
@@ -757,8 +753,11 @@ void mathed_parse(MathedArray & array, unsigned flags = 0,
                        break;
                        
                case LM_TK_NONUM:
-                       if (crow)
-                               crow->setNumbered(false);
+                       if (mt) {
+                               if (!mt->getRowSt().size())
+                                       mt->getRowSt().push_back();
+                               mt->getRowSt().back().setNumbered(false);
+                       }
                        break;
                
                case LM_TK_PMOD:
@@ -869,7 +868,6 @@ void mathed_parse(MathedArray & array, unsigned flags = 0,
                                        }
                                        mt->SetStyle(size);
                                        mt->SetType(mathed_env);
-                                       crow = mt->getRowSt().begin();
                                }
                                
                                lyxerr[Debug::MATHED] << "MATH BEGIN[" << mathed_env << "]" << endl;
@@ -914,8 +912,10 @@ void mathed_parse(MathedArray & array, unsigned flags = 0,
                                panic = true;
                                break;
                        } 
-                       if (crow) {
-                               crow->setLabel(yytext.data());
+                       if (mt) {
+                               if (!mt->getRowSt().size())
+                                       mt->getRowSt().push_back();
+                               mt->getRowSt().back().setLabel(yytext.data());
                        } else {
                                mathed_label = yytext.data();
                        }
diff --git a/src/mathed/math_rowst.C b/src/mathed/math_rowst.C
new file mode 100644 (file)
index 0000000..66fd687
--- /dev/null
@@ -0,0 +1,176 @@
+
+#include "math_rowst.h"
+#include "support/LAssert.h"
+
+
+//
+// MathedRowContainer
+//
+
+MathedRowStruct::MathedRowStruct()
+       : asc_(0), desc_(0), y_(0), numbered_(true)
+{}
+
+string const & MathedRowStruct::getLabel() const
+{
+       return label_;
+}
+
+bool MathedRowStruct::isNumbered() const
+{
+       return numbered_;
+}
+
+int MathedRowStruct::getBaseline() const
+{
+       return y_;
+}
+
+void MathedRowStruct::setBaseline(int b)
+{
+       y_ = b;
+}
+
+int MathedRowStruct::ascent() const
+{
+       return asc_;
+}
+
+int MathedRowStruct::descent() const
+{
+       return desc_;
+}
+
+void MathedRowStruct::ascent(int a)
+{
+       asc_ = a;
+}
+
+void MathedRowStruct::descent(int d)
+{
+       desc_ = d;
+}
+
+int MathedRowStruct::getTab(unsigned int i) const
+{
+       return i < widths_.size() ? widths_[i] : 0;
+}
+
+void MathedRowStruct::setLabel(string const & l)
+{
+       label_ = l;
+}
+
+void MathedRowStruct::setNumbered(bool nf)
+{
+       numbered_ = nf;
+}
+
+void MathedRowStruct::setTab(unsigned int i, int t)
+{
+       if (i >= widths_.size())
+               widths_.resize(i + 2);  
+       widths_[i] = t;
+}
+
+
+
+//
+// MathedRowContainer
+//
+
+
+MathedRowContainer::iterator MathedRowContainer::begin()
+{
+       return iterator(this);
+}
+
+bool MathedRowContainer::empty() const
+{
+       return data_.size() == 0;
+}
+
+void MathedRowContainer::insert(iterator const & it)
+{
+       Assert(it.st_ == this);
+       data_.insert(data_.begin() + it.pos_, MathedRowStruct());
+}
+               
+void MathedRowContainer::erase(iterator & it)
+{
+       Assert(it.st_ == this);
+       data_.erase(data_.begin() + it.pos_);
+}
+
+MathedRowStruct & MathedRowContainer::back()
+{
+       Assert(data_.size());
+       return data_.back();
+}
+
+void MathedRowContainer::push_back()
+{
+       data_.push_back(MathedRowStruct());
+}
+
+
+MathedRowContainer::size_type MathedRowContainer::size() const
+{
+       return data_.size();
+}
+
+
+
+//
+// MathedRowContainer::iterator
+//
+
+MathedRowContainer::iterator::iterator()
+       : st_(0), pos_(0)
+{}
+
+MathedRowContainer::iterator::iterator(MathedRowContainer * m)
+       : st_(m), pos_(0)
+{}
+
+MathedRowContainer::iterator::operator void *() const
+{
+       return (void *)(st_ && pos_ < st_->size());
+}
+
+MathedRowStruct & MathedRowContainer::iterator::operator*()
+{
+       Assert(st_);
+       return st_->data_[pos_];
+}
+
+MathedRowStruct * MathedRowContainer::iterator::operator->()
+{
+       Assert(st_);
+       return &st_->data_[pos_];
+}
+
+MathedRowStruct const * MathedRowContainer::iterator::operator->() const
+{
+       Assert(st_);
+       return &st_->data_[pos_];
+}
+
+void MathedRowContainer::iterator::operator++()
+{
+       Assert(st_);
+       ++pos_;
+}
+
+bool MathedRowContainer::iterator::is_last() const
+{
+       Assert(st_);
+       return pos_ == st_->size() - 1;
+}
+
+bool MathedRowContainer::iterator::operator==(const iterator & it) const
+{
+       return st_ == it.st_ && pos_ == it.pos_;
+}
+
+
index 16a265a7790d93e8b018a77f5a057f024a9fe059..f93dc1d8fb08be7ccc83f56be5fcf4d5266f958f 100644 (file)
@@ -2,8 +2,8 @@
 #ifndef MATH_ROWST_H
 #define MATH_ROWST_H
 
-#include <vector>
 #include "support/LAssert.h"
+#include <vector>
 
 /** The physical structure of a row and aditional information is stored here.
     It allows to manage the extra info independently of the paragraph data.  
@@ -17,9 +17,7 @@ public:
        typedef std::vector<int> Widths;
        
        ///
-       MathedRowStruct()
-               : asc_(0), desc_(0), y_(0), numbered_(true)
-               {}
+       MathedRowStruct();
        ///
        string const & getLabel() const;
        ///
@@ -62,34 +60,32 @@ protected:
 };
 
 
-// The idea is to change this  MathedRowContainer  to mimic the behaviour
-// of std::list<MathedRowStruct> in several small steps.  In the end it
-// could be replaced by such a list and MathedRowSt can go as well.
-struct MathedRowContainer {
-///
+class MathedRowContainer {
+private:
+       ///
+       typedef std::vector<MathedRowStruct>   data_type;
+       ///
+       typedef data_type::size_type           size_type;
+       ///
        struct iterator {
                ///
-               iterator() : st_(0), pos_(0) {}
+               iterator();
                ///
-               explicit iterator(MathedRowContainer * m) : st_(m), pos_(0) {}
-               /// "better" conversion to bool, static_cast doens't help?
-               operator void *() const
-                       { return (void *)(st_ && pos_ < st_->data_.size()); }
+               explicit iterator(MathedRowContainer * m);
+               /// "better" conversion to bool
+               operator void *() const;
                ///
-               MathedRowStruct & operator*() { Assert(st_); return st_->data_[pos_]; }
+               MathedRowStruct & operator*();
                ///
-               MathedRowStruct * operator->() { return &st_->data_[pos_]; }
+               MathedRowStruct * operator->();
                ///
-               MathedRowStruct const * operator->() const { return &st_->data_[pos_]; }
+               MathedRowStruct const * operator->() const;
                ///
-               void operator++() { Assert(st_); ++pos_; }
+               void operator++();
                ///
-               bool is_last() const { Assert(st_); return pos_ == st_->data_.size() - 1; }
+               bool is_last() const;
                ///
-               bool operator==(const iterator & it) const
-                       { return st_ == it.st_ && pos_ == it.pos_; }
+               bool operator==(const iterator & it) const;
 
        //private:
                MathedRowContainer * st_;
@@ -97,23 +93,24 @@ struct MathedRowContainer {
                unsigned int pos_;
        };
 
+public:
+       /// 
+       iterator begin();
        ///
-       iterator begin() { return iterator(this); }
-       ///
-       bool empty() const { return data_.size() == 0; }
-
-       /// insert 'item' before 'iterator'
-       void insert(iterator const & it) {
-               Assert(it.st_ == this);
-               data_.insert(data_.begin() + it.pos_, MathedRowStruct());
-       }
-
-       /// insert 'item' before 'iterator'
-       void erase(iterator & it) {
-               Assert(it.st_ == this);
-               data_.erase(data_.begin() + it.pos_);
-       }
+       bool empty() const;
 
+       /// insert item before 'it'
+       void insert(iterator const & it);
+       /// erase item pointed to by 'it'
+       void erase(iterator & it);
+       /// access to last row
+       MathedRowStruct & back();
+       /// append empty element
+       void push_back();
+       ///
+       size_type size() const;
+       
+//private:
        ///
        std::vector<MathedRowStruct> data_;
 
@@ -122,90 +119,4 @@ private:
        void operator=(MathedRowContainer const &); // unimplemented
 };
 
-
-
-inline
-string const & MathedRowStruct::getLabel() const
-{
-       return label_;
-}
-
-
-inline
-bool MathedRowStruct::isNumbered() const
-{
-       return numbered_;
-}
-
-
-inline
-int MathedRowStruct::getBaseline() const
-{
-       return y_;
-}
-
-
-inline
-void MathedRowStruct::setBaseline(int b)
-{
-       y_ = b;
-}
-
-
-inline
-int MathedRowStruct::ascent() const
-{
-       return asc_;
-}
-
-
-inline
-int MathedRowStruct::descent() const
-{
-       return desc_;
-}
-
-
-inline
-void MathedRowStruct::ascent(int a)
-{
-       asc_ = a;
-}
-
-
-inline
-void MathedRowStruct::descent(int d)
-{
-       desc_ = d;
-}
-
-
-inline
-int MathedRowStruct::getTab(unsigned int i) const
-{
-       return i < widths_.size() ? widths_[i] : 0;
-}
-
-
-inline
-void MathedRowStruct::setLabel(string const & l)
-{
-       label_ = l;
-}
-
-
-inline
-void MathedRowStruct::setNumbered(bool nf)
-{
-       numbered_ = nf;
-}
-
-
-inline
-void MathedRowStruct::setTab(unsigned int i, int t)
-{
-       if (i >= widths_.size())
-               widths_.resize(i + 2);  
-       widths_[i] = t;
-}
 #endif