+
+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"
* 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
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
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
math_parser.h \
math_root.C \
math_root.h \
+ math_rowst.C \
math_rowst.h \
math_spaceinset.C \
math_spaceinset.h \
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);
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");
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:
}
mt->SetStyle(size);
mt->SetType(mathed_env);
- crow = mt->getRowSt().begin();
}
lyxerr[Debug::MATHED] << "MATH BEGIN[" << mathed_env << "]" << endl;
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();
}
--- /dev/null
+
+#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_;
+}
+
+
#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.
typedef std::vector<int> Widths;
///
- MathedRowStruct()
- : asc_(0), desc_(0), y_(0), numbered_(true)
- {}
+ MathedRowStruct();
///
string const & getLabel() const;
///
};
-
-// 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_;
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_;
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