From af2a6c651274e00693884ed7c6d301019aa73704 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 16 Nov 2001 09:07:40 +0000 Subject: [PATCH] introduce test for "equality" remove a few unneeded declarations git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3036 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_cursor.h | 10 ---------- src/mathed/math_data.C | 11 +++++++++++ src/mathed/math_data.h | 4 ++-- src/mathed/math_inset.h | 2 ++ src/mathed/math_nestinset.C | 11 +++++++++++ src/mathed/math_nestinset.h | 2 ++ 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 0df0c4ee61..0bb6d0063d 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -25,19 +25,9 @@ #include "math_inset.h" #include "LString.h" -class MathInset; -class MathAtom; -class MathGridInset; -class MathFuncInset; -class MathHullInset; -class MathScriptInset; -class MathSpaceInset; class InsetFormulaBase; -class MathArray; -class MathXArray; class Painter; class Selection; -class latexkeys; /// Description of a position struct MathCursorPos { diff --git a/src/mathed/math_data.C b/src/mathed/math_data.C index e6caaab34a..017742014f 100644 --- a/src/mathed/math_data.C +++ b/src/mathed/math_data.C @@ -204,3 +204,14 @@ MathArray::iterator MathArray::end() { return bf_.end(); } + + +bool MathArray::match(MathArray const & ar) const +{ + if (size() != ar.size()) + return false; + for (const_iterator it = begin(), jt = ar.begin(); it != end(); ++it, ++jt) + if (!it->nucleus()->match(jt->nucleus())) + return false; + return true; +} diff --git a/src/mathed/math_data.h b/src/mathed/math_data.h index 83c3383d44..4c5b7fbf04 100644 --- a/src/mathed/math_data.h +++ b/src/mathed/math_data.h @@ -19,9 +19,7 @@ #include #include "math_atom.h" -#include "LString.h" -class MathScriptInset; class MathMacro; class LaTeXFeatures; @@ -104,6 +102,8 @@ public: void dump2() const; /// void substitute(MathMacro const &); + /// + bool match(MathArray const &) const; /// MathAtom & at(size_type pos); diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index b617ed20af..9703fa0c92 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -229,6 +229,8 @@ public: virtual void validate(LaTeXFeatures & features) const; /// virtual void handleFont(MathTextCodes) {} + /// + virtual bool match(MathInset *) const { return false; } /// write normalized content virtual void normalize(NormalStream &) const; diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index 03c1c2f04e..4d4cfb6152 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -178,3 +178,14 @@ bool MathNestInset::covers(int x, int y) const } return x >= x0 && x <= x1 && y >= y0 && y <= y1; } + + +bool MathNestInset::match(MathInset * p) const +{ + if (nargs() != p->nargs()) + return false; + for (idx_type i = 0; i < nargs(); ++i) + if (!cell(i).match(p->cell(i))) + return false; + return true; +} diff --git a/src/mathed/math_nestinset.h b/src/mathed/math_nestinset.h index 1416239b63..0108943bc0 100644 --- a/src/mathed/math_nestinset.h +++ b/src/mathed/math_nestinset.h @@ -65,6 +65,8 @@ public: void push_back(MathAtom const &); /// void dump() const; + /// + bool match(MathInset *) const; /// void validate(LaTeXFeatures & features) const; -- 2.39.2