math_notinset.h \
math_parser.C \
math_parser.h \
+ math_replace.h \
math_rootinset.C \
math_rootinset.h \
math_scriptinset.C \
{
code_ = (code_ == t) ? LM_TC_VAR : t;
}
+
+
+bool MathCharInset::match(MathInset * p) const
+{
+ MathCharInset const * q = p->asCharInset();
+ return q && char_ == q->char_ && code_ == q->code_;
+}
bool isRelOp() const;
///
void handleFont(MathTextCodes t);
+ ///
+ bool match(MathInset *) const;
private:
/// the character
#include "math_spaceinset.h"
#include "math_specialcharinset.h"
#include "math_mathmlstream.h"
+#include "math_replace.h"
+#include "math_parser.h"
#define FILEDEBUG 0
return true;
}
+ if (s.size() >= 7 && s.substr(0, 7) == "replace") {
+ ReplaceData rep;
+ istringstream is(s.substr(7).c_str());
+ string from, to;
+ is >> from >> to;
+ mathed_parse_cell(rep.from, from);
+ mathed_parse_cell(rep.to, to);
+ lyxerr << "replacing '" << from << "' with '" << to << "'\n";
+ par()->replace(rep);
+ return true;
+ }
+
if (s == "\\over" || s == "\\choose" || s == "\\atop") {
MathArray ar = array();
MathAtom t = createMathInset(s.substr(1));
#pragma implementation
#endif
+#include "math_data.h"
#include "math_inset.h"
#include "math_deliminset.h"
#include "math_charinset.h"
#include "math_matrixinset.h"
#include "math_mathmlstream.h"
#include "math_support.h"
-#include "math_data.h"
+#include "math_replace.h"
#include "debug.h"
#include "support/LAssert.h"
return false;
return true;
}
+
+
+void MathArray::replace(ReplaceData & rep)
+{
+ for (size_type i = 0; i < size(); ++i) {
+ iterator it = begin() + i;
+ const_iterator rt = rep.from.begin();
+ const_iterator et = rep.from.end();
+ for (const_iterator jt = it; jt != end() && rt != et; ++jt, ++rt)
+ if (!jt->nucleus()->match(rt->nucleus()))
+ break;
+ if (rt == et) {
+ // match found
+ lyxerr << "match found!\n";
+ erase(it, it + rep.from.size());
+ insert(i, rep.to);
+ }
+ }
+
+ for (const_iterator it = begin(); it != end(); ++it)
+ it->nucleus()->replace(rep);
+}
class MathMacro;
class LaTeXFeatures;
+class ReplaceData;
#ifdef __GNUG__
void substitute(MathMacro const &);
///
bool match(MathArray const &) const;
+ ///
+ void replace(ReplaceData &);
///
MathAtom & at(size_type pos);
virtual void handleFont(MathTextCodes) {}
///
virtual bool match(MathInset *) const { return false; }
+ ///
+ virtual void replace(ReplaceData &) {}
/// write normalized content
virtual void normalize(NormalStream &) const;
void validate(LaTeXFeatures &) const;
///
bool isMacro() const { return true; }
+ ///
+ bool match(MathInset *) const { return false; }
///
void normalize(NormalStream &) const;
return false;
return true;
}
+
+
+void MathNestInset::replace(ReplaceData & rep)
+{
+ for (idx_type i = 0; i < nargs(); ++i)
+ cell(i).replace(rep);
+}
void dump() const;
///
bool match(MathInset *) const;
+ ///
+ void replace(ReplaceData &);
///
void validate(LaTeXFeatures & features) const;