]> git.lyx.org Git - features.git/blobdiff - src/mathed/array.C
mathed64.diff
[features.git] / src / mathed / array.C
index 47034105ec6960909d42d6bf17434824dd9300a5..0cec697b09b2cac159cfd75d439c0ba75e19f167 100644 (file)
@@ -5,9 +5,11 @@
 #pragma implementation
 #endif
 
+#include "debug.h"
 #include "array.h"
 #include "math_iter.h"
 #include "math_inset.h"
+#include "math_macro.h"
 
 #include "support/LOstream.h"
 
@@ -79,6 +81,29 @@ void MathedArray::deep_copy()
        }
 }
 
+void MathedArray::substitute(MathMacro * m)
+{
+       if (m->nargs() == 0)
+               return;
+
+       MathedIter it(this);
+       while (it.OK()) {
+               if (it.IsInset()) {
+                       MathedInset * inset = it.GetInset();
+                       if (inset->GetType() == LM_OT_MACRO_ARG) {
+                               int n = static_cast<MathMacroArgument *>(inset)->number() - 1;
+                               //lyxerr << "substituting an argument inset: " << n << "\n";
+                               inset = m->arg(n)->Clone();
+                       } else {
+                               inset->substitute(m);
+                               //lyxerr << "substituting in an ordinary inset\n";
+                       }
+                       raw_pointer_insert(inset, it.getPos() + 1);
+               }
+               it.Next();
+       }
+}
+
 
 MathedArray & MathedArray::operator=(MathedArray const & array)
 {
@@ -284,7 +309,7 @@ byte & MathedArray::operator[](int i)
 }
 
 
-void MathedArray::dump(ostream & os) const
+void MathedArray::dump2(ostream & os) const
 {
        buffer_type::const_iterator cit = bf_.begin();
        buffer_type::const_iterator end = bf_.end();
@@ -294,4 +319,28 @@ void MathedArray::dump(ostream & os) const
        os << endl;
 }
 
+void MathedArray::dump(ostream & os) const
+{
+       MathedIter it( const_cast<MathedArray*>(this) );
+       while (it.OK()) {
+               if (it.IsInset()) {
+                       MathedInset * inset = it.GetInset();
+                       os << "<inset: " << inset << ">";
+               } 
+               else if (it.IsTab())
+                       os << "<tab>";
+               else if (it.IsCR())
+                       os << "<cr>";
+               else if (it.IsScript())
+                       os << "<script>";
+               else if (it.IsFont())
+                       os << "<font: " << int(it.at()) << ">";
+               else if (it.at() >= 32 && it.at() < 127)
+                       os << it.at();
+               else
+                       os << "<unknown: " << int(it.at()) << ">";
+               it.Next();
+       }
+}
+