]> git.lyx.org Git - features.git/commitdiff
cosmetics: rename (x)array.[Ch] into math_(x)data.[Ch]
authorAndré Pönitz <poenitz@gmx.net>
Thu, 8 Nov 2001 12:55:58 +0000 (12:55 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 8 Nov 2001 12:55:58 +0000 (12:55 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2988 a592a061-630c-0410-9148-cb99ea01b6c8

12 files changed:
src/mathed/Makefile.am
src/mathed/array.C [deleted file]
src/mathed/array.h [deleted file]
src/mathed/math_data.C [new file with mode: 0644]
src/mathed/math_data.h [new file with mode: 0644]
src/mathed/math_inset.h
src/mathed/math_macro.C
src/mathed/math_parser.C
src/mathed/math_xdata.C [new file with mode: 0644]
src/mathed/math_xdata.h [new file with mode: 0644]
src/mathed/xarray.C [deleted file]
src/mathed/xarray.h [deleted file]

index ee2683fc1235de0da8d8c8940e2d7732a3095248..e3962acf03aff06d12b31814f2cf8487ce9822c1 100644 (file)
@@ -8,10 +8,6 @@ BOOST_INCLUDES = -I$(top_srcdir)/boost
 INCLUDES = -I${srcdir}/../ $(SIGC_CFLAGS) $(BOOST_INCLUDES)
 
 libmathed_la_SOURCES = \
-       array.C \
-       array.h \
-       xarray.C \
-       xarray.h \
        formulabase.C \
        formulabase.h \
        formula.C \
@@ -34,6 +30,8 @@ libmathed_la_SOURCES = \
        math_charinset.h \
        math_cursor.C \
        math_cursor.h \
+       math_data.C \
+       math_data.h \
        math_decorationinset.C \
        math_decorationinset.h \
        math_defs.h \
@@ -107,4 +105,6 @@ libmathed_la_SOURCES = \
        math_support.C \
        math_support.h \
        math_symbolinset.C \
-       math_symbolinset.h
+       math_symbolinset.h \
+       math_xdata.C \
+       math_xdata.h
diff --git a/src/mathed/array.C b/src/mathed/array.C
deleted file mode 100644 (file)
index 6fa0b87..0000000
+++ /dev/null
@@ -1,337 +0,0 @@
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "math_inset.h"
-#include "math_charinset.h"
-#include "math_scriptinset.h"
-#include "math_stringinset.h"
-#include "math_mathmlstream.h"
-#include "math_support.h"
-#include "debug.h"
-#include "array.h"
-#include "support/LAssert.h"
-
-
-MathArray::MathArray()
-{}
-
-
-MathArray::MathArray(MathArray const & array, size_type from, size_type to)
-       : bf_(array.begin() + from, array.begin() + to)
-{}
-
-
-void MathArray::substitute(MathMacro const & m)
-{
-       for (iterator it = begin(); it != end(); ++it)
-               it->nucleus()->substitute(m);
-}
-
-
-MathScriptInset const * MathArray::asScript(const_iterator it) const
-{
-       if (it->nucleus()->asScriptInset())
-               return 0;
-       const_iterator jt = it + 1;
-       if (jt == end())
-               return 0;
-       if (!jt->nucleus())
-               return 0;
-       return jt->nucleus()->asScriptInset();
-}
-
-
-MathAtom & MathArray::at(size_type pos)
-{
-       lyx::Assert(pos < size());
-       return bf_[pos];
-}
-
-
-MathAtom const & MathArray::at(size_type pos) const
-{
-       lyx::Assert(pos < size());
-       return bf_[pos];
-}
-
-
-void MathArray::insert(size_type pos, MathAtom const & t)
-{
-       bf_.insert(begin() + pos, t);
-}
-
-
-void MathArray::insert(size_type pos, MathArray const & array)
-{
-       bf_.insert(begin() + pos, array.begin(), array.end());
-}
-
-
-void MathArray::push_back(MathAtom const & t)
-{      
-       bf_.push_back(t);
-}
-
-
-void MathArray::push_back(MathArray const & array)
-{
-       insert(size(), array);
-}
-
-
-void MathArray::clear()
-{
-       erase();
-}
-
-
-void MathArray::swap(MathArray & array)
-{
-       if (this != &array) 
-               bf_.swap(array.bf_);
-}
-
-
-bool MathArray::empty() const
-{
-       return bf_.empty();
-}
-
-
-MathArray::size_type MathArray::size() const
-{
-       return bf_.size();
-}
-
-
-void MathArray::erase()
-{
-       erase(0, size());
-}
-
-
-void MathArray::erase(size_type pos)
-{
-       if (pos < size())
-               erase(pos, pos + 1);
-}
-
-
-void MathArray::erase(size_type pos1, size_type pos2)
-{
-       bf_.erase(begin() + pos1, begin() + pos2);
-}
-
-
-MathAtom & MathArray::back()
-{
-       return bf_.back();
-}
-
-
-void MathArray::dump2() const
-{
-       NormalStream ns(lyxerr);
-       for (const_iterator it = begin(); it != end(); ++it)
-               ns << it->nucleus() << ' ';
-}
-
-
-void MathArray::dump() const
-{
-       NormalStream ns(lyxerr);
-       for (const_iterator it = begin(); it != end(); ++it)
-               ns << "<" << it->nucleus() << ">";
-}
-
-
-// returns sequence of char with same code starting at it up to end
-// it might be less, though...
-string charSequence(MathArray::const_iterator it, MathArray::const_iterator end)
-{
-       string s;
-       MathCharInset const * p = it->nucleus()->asCharInset();
-       if (!p)
-               return s;
-
-       for (MathTextCodes c = p->code(); it != end; ++it) {
-               if (!it->nucleus())
-                       break;
-               p = it->nucleus()->asCharInset();
-               if (!p || p->code() != c)
-                       break;
-               s += p->getChar();
-       }
-       return s;
-}
-
-
-MathArray MathArray::glueChars() const
-{
-       MathArray ar;
-       const_iterator it = begin();
-       while (it != end()) {
-               if (it->nucleus() && it->nucleus()->asCharInset()) {
-                       string s = charSequence(it, end());
-                       MathTextCodes c = it->nucleus()->asCharInset()->code();
-                       ar.push_back(MathAtom(new MathStringInset(s, c)));
-                       it += s.size();
-               } else {
-                       ar.push_back(*it);
-                       ++it;
-               }
-       }
-       return ar;
-}
-
-
-bool needAsterisk(MathAtom const &, MathAtom const &)
-{
-       return false;
-}
-
-
-MathArray MathArray::guessAsterisks() const
-{
-       if (size() <= 1)
-               return *this;
-       MathArray ar;
-       ar.push_back(*begin());
-       for (const_iterator it = begin(), jt = begin()+1 ; jt != end(); ++it, ++jt) {
-               if (needAsterisk(*it, *jt))
-                       ar.push_back(MathAtom(new MathCharInset('*')));
-               ar.push_back(*it);
-       }
-       ar.push_back(*end());
-       return ar;
-}
-
-
-void MathArray::write(MathWriteInfo & wi) const
-{
-       MathArray ar = glueChars();
-       for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
-               MathInset const * p = it->nucleus();
-               if (MathScriptInset const * q = ar.asScript(it)) {
-                       q->write(p, wi);
-                       ++it;
-               } else {
-                       p->write(wi);
-               }
-       }
-}
-
-
-void MathArray::writeNormal(NormalStream & os) const
-{
-       MathArray ar = glueChars();
-       for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
-               MathInset const * p = it->nucleus();
-               if (MathScriptInset const * q = ar.asScript(it)) {
-                       q->writeNormal(p, os);
-                       ++it;
-               } else 
-                       p->writeNormal(os);
-       }
-}
-
-
-void MathArray::octavize(OctaveStream & os) const
-{
-       MathArray ar = glueChars();
-       for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
-               MathInset const * p = it->nucleus();
-               if (MathScriptInset const * q = ar.asScript(it)) {
-                       q->octavize(p, os);
-                       ++it;
-               } else 
-                       p->octavize(os);
-       }
-}
-
-
-void MathArray::maplize(MapleStream & os) const
-{
-       MathArray ar = glueChars();
-       for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
-               MathInset const * p = it->nucleus();
-               if (MathScriptInset const * q = ar.asScript(it)) {
-                       q->maplize(p, os);
-                       ++it;
-               } else 
-                       p->maplize(os);
-       }
-}
-
-
-void MathArray::mathmlize(MathMLStream & os) const
-{
-       MathArray ar = glueChars();
-       if (ar.size() == 0)
-               os << "<mrow/>";
-       else if (ar.size() == 1)
-               os << ar.begin()->nucleus();
-       else {
-               os << MTag("mrow");
-               for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
-                       MathInset const * p = it->nucleus();
-                       if (MathScriptInset const * q = ar.asScript(it)) {
-                               q->mathmlize(p, os);
-                               ++it;
-                       } else 
-                               p->mathmlize(os);
-               }
-               os << ETag("mrow");
-       }
-}
-
-
-void MathArray::validate(LaTeXFeatures & features) const
-{
-       for (const_iterator it = begin(); it != end(); ++it)
-               if (it->nucleus())
-                       it->nucleus()->validate(features);
-}
-
-
-void MathArray::pop_back()
-{      
-       if (!size()) {
-               lyxerr << "pop_back from empty array!\n";
-               return;
-       }
-       bf_.pop_back();
-}
-
-
-MathArray::const_iterator MathArray::begin() const
-{
-       return bf_.begin();
-}
-
-
-MathArray::const_iterator MathArray::end() const
-{
-       return bf_.end();
-}
-
-
-MathArray::iterator MathArray::begin()
-{
-       return bf_.begin();
-}
-
-
-MathArray::iterator MathArray::end()
-{
-       return bf_.end();
-}
-
-
-bool MathArray::isMatrix() const
-{
-       return size() == 1 && begin()->nucleus() && begin()->nucleus()->isMatrix();
-}
-
-
diff --git a/src/mathed/array.h b/src/mathed/array.h
deleted file mode 100644 (file)
index 007d758..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-// -*- C++ -*-
-/*
- *  Purpose:     A general purpose resizable array.  
- *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx> 
- *  Created:     January 1996
- *
- *  Dependencies: None (almost)
- *
- *  Copyright: 1996, Alejandro Aguilar Sierra
- *                 1997  The LyX Team!
- *
- *   You are free to use and modify this code under the terms of
- *   the GNU General Public Licence version 2 or later.
- */
-
-#ifndef MATHEDARRAY_H
-#define MATHEDARRAY_H
-
-#include <vector>
-
-#include "math_atom.h"
-#include "LString.h"
-
-class MathScriptInset;
-class MathMacro;
-class MathWriteInfo;
-class MathMetricsInfo;
-class LaTeXFeatures;
-class NormalStream;
-class MapleStream;
-class MathMLStream;
-class OctaveStream;
-
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-
-/** \class MathArray
-    \brief Low level container for math insets
-    
-    \author Alejandro Aguilar Sierra
-    \author André Pönitz
-    \author Lars Gullik Bjønnes
-    \version February 2001
-  */
-
-class MathArray  {
-public:
-       ///
-       typedef std::vector<MathAtom>        buffer_type;
-       ///
-       typedef buffer_type::const_iterator  const_iterator;
-       ///
-       typedef buffer_type::iterator        iterator;
-       ///
-       typedef buffer_type::size_type       size_type;
-
-public:
-       ///
-       MathArray();
-       ///
-       MathArray(MathArray const &, size_type from, size_type to);
-
-       ///
-       size_type size() const;
-       ///
-       bool empty() const;
-       ///
-       void clear();
-       ///
-       void swap(MathArray &);
-       
-       ///
-       void insert(size_type pos, MathAtom const &);
-       ///
-       void insert(size_type pos, MathArray const &);
-
-       ///
-       void erase(size_type pos1, size_type pos2);
-       ///
-       void erase(size_type pos);
-       ///
-       void erase();
-
-       ///
-       void push_back(MathAtom const &);
-       ///
-       void push_back(MathArray const &);
-       ///
-       void pop_back();
-       ///
-       MathAtom & back();
-
-       ///
-       void dump() const;
-       ///
-       void dump2() const;
-       ///
-       void substitute(MathMacro const &);
-
-       ///
-       MathAtom & at(size_type pos);
-       ///
-       MathAtom const & at(size_type pos) const;
-       /// glue chars if necessary
-       void write(MathWriteInfo & os) const;
-       ///
-       void writeNormal(NormalStream &) const;
-       ///
-       void validate(LaTeXFeatures &) const;
-       ///
-       const_iterator begin() const;   
-       ///
-       const_iterator end() const;     
-       ///
-       iterator begin();
-       ///
-       iterator end();
-       ///
-       MathScriptInset const * asScript(const_iterator it) const;
-       /// glues chars with the same attributes into MathStringInsets
-       MathArray glueChars() const;
-       /// insert asterisks in "suitable" places
-       MathArray guessAsterisks() const;
-
-       /// interface to Octave
-       void octavize(OctaveStream &) const;
-       /// interface to Maple
-       void maplize(MapleStream &) const;
-       /// interface to MathML
-       void mathmlize(MathMLStream &) const;
-
-       ///
-       bool isMatrix() const;
-
-private:
-       /// Buffer
-       buffer_type bf_;
-};
-
-#endif
diff --git a/src/mathed/math_data.C b/src/mathed/math_data.C
new file mode 100644 (file)
index 0000000..3082140
--- /dev/null
@@ -0,0 +1,337 @@
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "math_inset.h"
+#include "math_charinset.h"
+#include "math_scriptinset.h"
+#include "math_stringinset.h"
+#include "math_mathmlstream.h"
+#include "math_support.h"
+#include "math_data.h"
+#include "debug.h"
+#include "support/LAssert.h"
+
+
+MathArray::MathArray()
+{}
+
+
+MathArray::MathArray(MathArray const & ar, size_type from, size_type to)
+       : bf_(ar.begin() + from, ar.begin() + to)
+{}
+
+
+void MathArray::substitute(MathMacro const & m)
+{
+       for (iterator it = begin(); it != end(); ++it)
+               it->nucleus()->substitute(m);
+}
+
+
+MathScriptInset const * MathArray::asScript(const_iterator it) const
+{
+       if (it->nucleus()->asScriptInset())
+               return 0;
+       const_iterator jt = it + 1;
+       if (jt == end())
+               return 0;
+       if (!jt->nucleus())
+               return 0;
+       return jt->nucleus()->asScriptInset();
+}
+
+
+MathAtom & MathArray::at(size_type pos)
+{
+       lyx::Assert(pos < size());
+       return bf_[pos];
+}
+
+
+MathAtom const & MathArray::at(size_type pos) const
+{
+       lyx::Assert(pos < size());
+       return bf_[pos];
+}
+
+
+void MathArray::insert(size_type pos, MathAtom const & t)
+{
+       bf_.insert(begin() + pos, t);
+}
+
+
+void MathArray::insert(size_type pos, MathArray const & ar)
+{
+       bf_.insert(begin() + pos, ar.begin(), ar.end());
+}
+
+
+void MathArray::push_back(MathAtom const & t)
+{      
+       bf_.push_back(t);
+}
+
+
+void MathArray::push_back(MathArray const & ar)
+{
+       insert(size(), ar);
+}
+
+
+void MathArray::clear()
+{
+       erase();
+}
+
+
+void MathArray::swap(MathArray & ar)
+{
+       if (this != &ar) 
+               bf_.swap(ar.bf_);
+}
+
+
+bool MathArray::empty() const
+{
+       return bf_.empty();
+}
+
+
+MathArray::size_type MathArray::size() const
+{
+       return bf_.size();
+}
+
+
+void MathArray::erase()
+{
+       erase(0, size());
+}
+
+
+void MathArray::erase(size_type pos)
+{
+       if (pos < size())
+               erase(pos, pos + 1);
+}
+
+
+void MathArray::erase(size_type pos1, size_type pos2)
+{
+       bf_.erase(begin() + pos1, begin() + pos2);
+}
+
+
+MathAtom & MathArray::back()
+{
+       return bf_.back();
+}
+
+
+void MathArray::dump2() const
+{
+       NormalStream ns(lyxerr);
+       for (const_iterator it = begin(); it != end(); ++it)
+               ns << it->nucleus() << ' ';
+}
+
+
+void MathArray::dump() const
+{
+       NormalStream ns(lyxerr);
+       for (const_iterator it = begin(); it != end(); ++it)
+               ns << "<" << it->nucleus() << ">";
+}
+
+
+// returns sequence of char with same code starting at it up to end
+// it might be less, though...
+string charSequence(MathArray::const_iterator it, MathArray::const_iterator end)
+{
+       string s;
+       MathCharInset const * p = it->nucleus()->asCharInset();
+       if (!p)
+               return s;
+
+       for (MathTextCodes c = p->code(); it != end; ++it) {
+               if (!it->nucleus())
+                       break;
+               p = it->nucleus()->asCharInset();
+               if (!p || p->code() != c)
+                       break;
+               s += p->getChar();
+       }
+       return s;
+}
+
+
+MathArray MathArray::glueChars() const
+{
+       MathArray ar;
+       const_iterator it = begin();
+       while (it != end()) {
+               if (it->nucleus() && it->nucleus()->asCharInset()) {
+                       string s = charSequence(it, end());
+                       MathTextCodes c = it->nucleus()->asCharInset()->code();
+                       ar.push_back(MathAtom(new MathStringInset(s, c)));
+                       it += s.size();
+               } else {
+                       ar.push_back(*it);
+                       ++it;
+               }
+       }
+       return ar;
+}
+
+
+bool needAsterisk(MathAtom const &, MathAtom const &)
+{
+       return false;
+}
+
+
+MathArray MathArray::guessAsterisks() const
+{
+       if (size() <= 1)
+               return *this;
+       MathArray ar;
+       ar.push_back(*begin());
+       for (const_iterator it = begin(), jt = begin()+1 ; jt != end(); ++it, ++jt) {
+               if (needAsterisk(*it, *jt))
+                       ar.push_back(MathAtom(new MathCharInset('*')));
+               ar.push_back(*it);
+       }
+       ar.push_back(*end());
+       return ar;
+}
+
+
+void MathArray::write(MathWriteInfo & wi) const
+{
+       MathArray ar = glueChars();
+       for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
+               MathInset const * p = it->nucleus();
+               if (MathScriptInset const * q = ar.asScript(it)) {
+                       q->write(p, wi);
+                       ++it;
+               } else {
+                       p->write(wi);
+               }
+       }
+}
+
+
+void MathArray::writeNormal(NormalStream & os) const
+{
+       MathArray ar = glueChars();
+       for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
+               MathInset const * p = it->nucleus();
+               if (MathScriptInset const * q = ar.asScript(it)) {
+                       q->writeNormal(p, os);
+                       ++it;
+               } else 
+                       p->writeNormal(os);
+       }
+}
+
+
+void MathArray::octavize(OctaveStream & os) const
+{
+       MathArray ar = glueChars();
+       for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
+               MathInset const * p = it->nucleus();
+               if (MathScriptInset const * q = ar.asScript(it)) {
+                       q->octavize(p, os);
+                       ++it;
+               } else 
+                       p->octavize(os);
+       }
+}
+
+
+void MathArray::maplize(MapleStream & os) const
+{
+       MathArray ar = glueChars();
+       for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
+               MathInset const * p = it->nucleus();
+               if (MathScriptInset const * q = ar.asScript(it)) {
+                       q->maplize(p, os);
+                       ++it;
+               } else 
+                       p->maplize(os);
+       }
+}
+
+
+void MathArray::mathmlize(MathMLStream & os) const
+{
+       MathArray ar = glueChars();
+       if (ar.size() == 0)
+               os << "<mrow/>";
+       else if (ar.size() == 1)
+               os << ar.begin()->nucleus();
+       else {
+               os << MTag("mrow");
+               for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
+                       MathInset const * p = it->nucleus();
+                       if (MathScriptInset const * q = ar.asScript(it)) {
+                               q->mathmlize(p, os);
+                               ++it;
+                       } else 
+                               p->mathmlize(os);
+               }
+               os << ETag("mrow");
+       }
+}
+
+
+void MathArray::validate(LaTeXFeatures & features) const
+{
+       for (const_iterator it = begin(); it != end(); ++it)
+               if (it->nucleus())
+                       it->nucleus()->validate(features);
+}
+
+
+void MathArray::pop_back()
+{      
+       if (!size()) {
+               lyxerr << "pop_back from empty array!\n";
+               return;
+       }
+       bf_.pop_back();
+}
+
+
+MathArray::const_iterator MathArray::begin() const
+{
+       return bf_.begin();
+}
+
+
+MathArray::const_iterator MathArray::end() const
+{
+       return bf_.end();
+}
+
+
+MathArray::iterator MathArray::begin()
+{
+       return bf_.begin();
+}
+
+
+MathArray::iterator MathArray::end()
+{
+       return bf_.end();
+}
+
+
+bool MathArray::isMatrix() const
+{
+       return size() == 1 && begin()->nucleus() && begin()->nucleus()->isMatrix();
+}
+
+
diff --git a/src/mathed/math_data.h b/src/mathed/math_data.h
new file mode 100644 (file)
index 0000000..007d758
--- /dev/null
@@ -0,0 +1,143 @@
+// -*- C++ -*-
+/*
+ *  Purpose:     A general purpose resizable array.  
+ *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx> 
+ *  Created:     January 1996
+ *
+ *  Dependencies: None (almost)
+ *
+ *  Copyright: 1996, Alejandro Aguilar Sierra
+ *                 1997  The LyX Team!
+ *
+ *   You are free to use and modify this code under the terms of
+ *   the GNU General Public Licence version 2 or later.
+ */
+
+#ifndef MATHEDARRAY_H
+#define MATHEDARRAY_H
+
+#include <vector>
+
+#include "math_atom.h"
+#include "LString.h"
+
+class MathScriptInset;
+class MathMacro;
+class MathWriteInfo;
+class MathMetricsInfo;
+class LaTeXFeatures;
+class NormalStream;
+class MapleStream;
+class MathMLStream;
+class OctaveStream;
+
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+
+/** \class MathArray
+    \brief Low level container for math insets
+    
+    \author Alejandro Aguilar Sierra
+    \author André Pönitz
+    \author Lars Gullik Bjønnes
+    \version February 2001
+  */
+
+class MathArray  {
+public:
+       ///
+       typedef std::vector<MathAtom>        buffer_type;
+       ///
+       typedef buffer_type::const_iterator  const_iterator;
+       ///
+       typedef buffer_type::iterator        iterator;
+       ///
+       typedef buffer_type::size_type       size_type;
+
+public:
+       ///
+       MathArray();
+       ///
+       MathArray(MathArray const &, size_type from, size_type to);
+
+       ///
+       size_type size() const;
+       ///
+       bool empty() const;
+       ///
+       void clear();
+       ///
+       void swap(MathArray &);
+       
+       ///
+       void insert(size_type pos, MathAtom const &);
+       ///
+       void insert(size_type pos, MathArray const &);
+
+       ///
+       void erase(size_type pos1, size_type pos2);
+       ///
+       void erase(size_type pos);
+       ///
+       void erase();
+
+       ///
+       void push_back(MathAtom const &);
+       ///
+       void push_back(MathArray const &);
+       ///
+       void pop_back();
+       ///
+       MathAtom & back();
+
+       ///
+       void dump() const;
+       ///
+       void dump2() const;
+       ///
+       void substitute(MathMacro const &);
+
+       ///
+       MathAtom & at(size_type pos);
+       ///
+       MathAtom const & at(size_type pos) const;
+       /// glue chars if necessary
+       void write(MathWriteInfo & os) const;
+       ///
+       void writeNormal(NormalStream &) const;
+       ///
+       void validate(LaTeXFeatures &) const;
+       ///
+       const_iterator begin() const;   
+       ///
+       const_iterator end() const;     
+       ///
+       iterator begin();
+       ///
+       iterator end();
+       ///
+       MathScriptInset const * asScript(const_iterator it) const;
+       /// glues chars with the same attributes into MathStringInsets
+       MathArray glueChars() const;
+       /// insert asterisks in "suitable" places
+       MathArray guessAsterisks() const;
+
+       /// interface to Octave
+       void octavize(OctaveStream &) const;
+       /// interface to Maple
+       void maplize(MapleStream &) const;
+       /// interface to MathML
+       void mathmlize(MathMLStream &) const;
+
+       ///
+       bool isMatrix() const;
+
+private:
+       /// Buffer
+       buffer_type bf_;
+};
+
+#endif
index 5d8098e8bd9f9b03197ab7dcdaafb00a952537b3..a710af65d7403973e542abe2d7f593e4e3a04199 100644 (file)
@@ -28,7 +28,7 @@
 #pragma interface
 #endif
 
-#include "xarray.h"
+#include "math_xdata.h"
 #include "math_defs.h"
 
 /** Abstract base class for all math objects.
index 5bada3e06f3d6dd705d6be0b135e408ebcadfda0..707548ec2dec774fb087020886bfeed556b016f5 100644 (file)
@@ -19,7 +19,6 @@
 #endif
 
 #include "math_macro.h"
-#include "array.h"
 #include "support/lstrings.h"
 #include "support/LAssert.h"
 #include "debug.h"
index 4da7787d9c016097f76e345ea8a576eb06851c1d..5384cb5625f07aa53772b18ea37ac1fe0737d78f 100644 (file)
@@ -53,7 +53,6 @@ point to write some macros:
 #endif
 
 #include "math_parser.h"
-#include "array.h"
 #include "math_inset.h"
 #include "math_arrayinset.h"
 #include "math_braceinset.h"
@@ -72,9 +71,9 @@ point to write some macros:
 #include "math_specialcharinset.h"
 #include "math_splitinset.h"
 #include "math_sqrtinset.h"
-#include "debug.h"
 #include "math_support.h"
 #include "lyxlex.h"
+#include "debug.h"
 #include "support/lstrings.h"
 
 using std::istream;
diff --git a/src/mathed/math_xdata.C b/src/mathed/math_xdata.C
new file mode 100644 (file)
index 0000000..f0deef4
--- /dev/null
@@ -0,0 +1,117 @@
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "math_inset.h"
+#include "math_scriptinset.h"
+#include "math_support.h"
+#include "math_defs.h"
+#include "Painter.h"
+#include "debug.h"
+
+
+MathXArray::MathXArray()
+       : width_(0), ascent_(0), descent_(0), xo_(0), yo_(0), size_()
+{}
+
+
+void MathXArray::metrics(MathMetricsInfo const & st) const
+{
+       size_ = st;
+       mathed_char_dim(LM_TC_VAR, st, 'I', ascent_, descent_, width_);
+
+       if (data_.empty()) 
+               return;
+
+       math_font_max_dim(LM_TC_TEXTRM, st, ascent_, descent_); 
+       width_ = 0;
+
+       //lyxerr << "MathXArray::metrics(): '" << data_ << "'\n";
+       
+       for (const_iterator it = begin(); it != end(); ++it) {
+               MathInset const * p = it->nucleus();
+               if (MathScriptInset const * q = data_.asScript(it)) {
+                       q->metrics(p, st);
+                       ascent_  = std::max(ascent_,  q->ascent(p));
+                       descent_ = std::max(descent_, q->descent(p));
+                       width_  += q->width(p); 
+                       ++it;
+               } else {
+                       p->metrics(st);
+                       ascent_  = std::max(ascent_,  p->ascent());
+                       descent_ = std::max(descent_, p->descent());
+                       width_  += p->width();  
+               }
+       }
+       //lyxerr << "MathXArray::metrics(): '" << ascent_ << " " 
+       //      << descent_ << " " << width_ << "'\n";
+}
+
+
+void MathXArray::draw(Painter & pain, int x, int y) const
+{
+       xo_ = x;
+       yo_ = y;
+
+       if (data_.empty()) {
+               pain.rectangle(x, y - ascent_, width_, height(), LColor::mathline);
+               return;
+       }
+
+       for (const_iterator it = begin(); it != end(); ++it) {
+               MathInset const * p = it->nucleus();
+               if (MathScriptInset const * q = data_.asScript(it)) {
+                       q->draw(p, pain, x, y);
+                       x += q->width(p);
+                       ++it;
+               } else {
+                       p->draw(pain, x, y);
+                       x += p->width();
+               }
+       }
+}
+
+
+int MathXArray::pos2x(size_type targetpos) const
+{
+       int x = 0;
+       const_iterator target = std::min(begin() + targetpos, end());
+       for (const_iterator it = begin(); it < target; ++it) {
+               MathInset const * p = it->nucleus();
+               if (MathScriptInset const * q = data_.asScript(it)) {
+                       ++it;
+                       if (it < target)
+                               x += q->width(p);
+                       else  // "half" position
+                               x += q->dxx(p) + q->nwid(p);
+               } else
+                       x += p->width();
+       }
+       return x;
+}
+
+
+MathArray::size_type MathXArray::x2pos(int targetx) const
+{
+       const_iterator it = begin();
+       int lastx = 0;
+       int currx = 0;
+       for ( ; currx < targetx && it < end(); ++it) {
+               lastx = currx;
+
+               int wid = 0;
+               MathInset const * p = it->nucleus();
+               if (MathScriptInset const * q = data_.asScript(it)) {
+                       wid = q->width(p);
+                       ++it;
+               } else
+                       wid = p->width();
+
+               currx += wid;
+       }
+       if (abs(lastx - targetx) < abs(currx - targetx) && it != begin())
+               --it;
+       return it - begin();
+}
diff --git a/src/mathed/math_xdata.h b/src/mathed/math_xdata.h
new file mode 100644 (file)
index 0000000..d59caa0
--- /dev/null
@@ -0,0 +1,74 @@
+// -*- C++ -*-
+
+#ifndef MATHEDXARRAY_H
+#define MATHEDXARRAY_H
+
+#include <iosfwd>
+
+#include "math_data.h"
+#include "math_metricsinfo.h"
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+class Painter;
+
+class MathXArray
+{
+public:
+       ///
+       typedef MathArray::size_type       size_type;
+       ///
+       typedef MathArray::const_iterator  const_iterator;
+
+       ///
+       MathXArray();
+       ///
+       void metrics(MathMetricsInfo const & st) const;
+       ///
+       void draw(Painter & pain, int x, int y) const;
+
+       ///
+       int xo() const { return xo_; }
+       ///
+       int yo() const { return yo_; }
+       ///
+       int pos2x(size_type pos) const;
+       ///
+       size_type x2pos(int pos) const;
+
+       ///
+       int ascent() const { return ascent_; }
+       ///
+       int descent() const { return descent_; }
+       ///
+       int height() const { return ascent_ + descent_; }
+       ///
+       int width() const { return width_; }
+
+       ///
+       const_iterator begin() const { return data_.begin(); }
+       ///
+       const_iterator end() const { return data_.end(); }
+       
+public:
+       ///
+       MathArray data_;
+       ///
+       mutable int width_;
+       ///
+       mutable int ascent_;
+       ///
+       mutable int descent_;
+       ///
+       mutable int xo_;
+       ///
+       mutable int yo_;
+       ///
+       mutable MathMetricsInfo size_;
+};
+
+std::ostream & operator<<(std::ostream & os, MathXArray const & ar);
+
+#endif
diff --git a/src/mathed/xarray.C b/src/mathed/xarray.C
deleted file mode 100644 (file)
index 5e848f1..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-#include <config.h>
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "xarray.h"
-#include "math_inset.h"
-#include "math_scriptinset.h"
-#include "math_support.h"
-#include "math_defs.h"
-#include "Painter.h"
-#include "debug.h"
-
-
-MathXArray::MathXArray()
-       : width_(0), ascent_(0), descent_(0), xo_(0), yo_(0), size_()
-{}
-
-
-void MathXArray::metrics(MathMetricsInfo const & st) const
-{
-       size_ = st;
-       mathed_char_dim(LM_TC_VAR, st, 'I', ascent_, descent_, width_);
-
-       if (data_.empty()) 
-               return;
-
-       math_font_max_dim(LM_TC_TEXTRM, st, ascent_, descent_); 
-       width_ = 0;
-
-       //lyxerr << "MathXArray::metrics(): '" << data_ << "'\n";
-       
-       for (const_iterator it = begin(); it != end(); ++it) {
-               MathInset const * p = it->nucleus();
-               if (MathScriptInset const * q = data_.asScript(it)) {
-                       q->metrics(p, st);
-                       ascent_  = std::max(ascent_,  q->ascent(p));
-                       descent_ = std::max(descent_, q->descent(p));
-                       width_  += q->width(p); 
-                       ++it;
-               } else {
-                       p->metrics(st);
-                       ascent_  = std::max(ascent_,  p->ascent());
-                       descent_ = std::max(descent_, p->descent());
-                       width_  += p->width();  
-               }
-       }
-       //lyxerr << "MathXArray::metrics(): '" << ascent_ << " " 
-       //      << descent_ << " " << width_ << "'\n";
-}
-
-
-void MathXArray::draw(Painter & pain, int x, int y) const
-{
-       xo_ = x;
-       yo_ = y;
-
-       if (data_.empty()) {
-               pain.rectangle(x, y - ascent_, width_, height(), LColor::mathline);
-               return;
-       }
-
-       for (const_iterator it = begin(); it != end(); ++it) {
-               MathInset const * p = it->nucleus();
-               if (MathScriptInset const * q = data_.asScript(it)) {
-                       q->draw(p, pain, x, y);
-                       x += q->width(p);
-                       ++it;
-               } else {
-                       p->draw(pain, x, y);
-                       x += p->width();
-               }
-       }
-}
-
-
-int MathXArray::pos2x(size_type targetpos) const
-{
-       int x = 0;
-       const_iterator target = std::min(begin() + targetpos, end());
-       for (const_iterator it = begin(); it < target; ++it) {
-               MathInset const * p = it->nucleus();
-               if (MathScriptInset const * q = data_.asScript(it)) {
-                       ++it;
-                       if (it < target)
-                               x += q->width(p);
-                       else  // "half" position
-                               x += q->dxx(p) + q->nwid(p);
-               } else
-                       x += p->width();
-       }
-       return x;
-}
-
-
-MathArray::size_type MathXArray::x2pos(int targetx) const
-{
-       const_iterator it = begin();
-       int lastx = 0;
-       int currx = 0;
-       for ( ; currx < targetx && it < end(); ++it) {
-               lastx = currx;
-
-               int wid = 0;
-               MathInset const * p = it->nucleus();
-               if (MathScriptInset const * q = data_.asScript(it)) {
-                       wid = q->width(p);
-                       ++it;
-               } else
-                       wid = p->width();
-
-               currx += wid;
-       }
-       if (abs(lastx - targetx) < abs(currx - targetx) && it != begin())
-               --it;
-       return it - begin();
-}
diff --git a/src/mathed/xarray.h b/src/mathed/xarray.h
deleted file mode 100644 (file)
index b67d3b9..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-// -*- C++ -*-
-
-#ifndef MATHEDXARRAY_H
-#define MATHEDXARRAY_H
-
-#include <iosfwd>
-#include "array.h"
-#include "math_metricsinfo.h"
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-class Painter;
-
-class MathXArray
-{
-public:
-       ///
-       typedef MathArray::size_type       size_type;
-       ///
-       typedef MathArray::const_iterator  const_iterator;
-
-       ///
-       MathXArray();
-       ///
-       void metrics(MathMetricsInfo const & st) const;
-       ///
-       void draw(Painter & pain, int x, int y) const;
-
-       ///
-       int xo() const { return xo_; }
-       ///
-       int yo() const { return yo_; }
-       ///
-       int pos2x(size_type pos) const;
-       ///
-       size_type x2pos(int pos) const;
-
-       ///
-       int ascent() const { return ascent_; }
-       ///
-       int descent() const { return descent_; }
-       ///
-       int height() const { return ascent_ + descent_; }
-       ///
-       int width() const { return width_; }
-
-       ///
-       const_iterator begin() const { return data_.begin(); }
-       ///
-       const_iterator end() const { return data_.end(); }
-       
-public:
-       ///
-       MathArray data_;
-       ///
-       mutable int width_;
-       ///
-       mutable int ascent_;
-       ///
-       mutable int descent_;
-       ///
-       mutable int xo_;
-       ///
-       mutable int yo_;
-       ///
-       mutable MathMetricsInfo size_;
-};
-
-std::ostream & operator<<(std::ostream & os, MathXArray const & ar);
-
-#endif