This moves the 'update' loop from the template to the macro. It is still
the template that gets updated, so it should not fix the bug yet, but I
believe it is a step in the right direction.

(If we have several macros with individual arguments, rendering their
common template can't work. So we need some kind of copy of the macro or
the macro itself to replace the formal arguments of the template with the
individual pars).

Andre'

-- 
André Pönitz ........................................ [EMAIL PROTECTED]
Index: ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/ChangeLog,v
retrieving revision 1.52
diff -u -p -r1.52 ChangeLog
--- ChangeLog   2001/03/01 20:25:38     1.52
+++ ChangeLog   2001/03/05 07:42:20
@@ -1,3 +1,8 @@
+2001-02-14  André Pönitz  <[EMAIL PROTECTED]>
+
+       * math_macrotemplate.[Ch]:
+         math_macro.C: move update() functionality to the macro
+
 2001-03-01  Lars Gullik Bjønnes  <[EMAIL PROTECTED]>
 
        * math_iter.h: add comment on virtual destructor
Index: math_macro.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macro.C,v
retrieving revision 1.48
diff -u -p -r1.48 math_macro.C
--- math_macro.C        2001/03/01 15:33:22     1.48
+++ math_macro.C        2001/03/05 07:42:20
@@ -64,8 +64,11 @@ MathedInset * MathMacro::Clone()
 
 void MathMacro::Metrics()
 {
-       if (nargs_ > 0)
-               tmplate_->update(this);
+       // this loop is the old MathMacroTemplate::update()
+       for (int i = 0; i < nargs_; ++i) {
+               tmplate_->setMacroPar(i, args_[i].array, getRowSt()); 
+       }
+
        tmplate_->SetStyle(size());
        tmplate_->Metrics();
        width = tmplate_->Width();
Index: math_macrotemplate.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macrotemplate.C,v
retrieving revision 1.11
diff -u -p -r1.11 math_macrotemplate.C
--- math_macrotemplate.C        2001/03/01 15:33:22     1.11
+++ math_macrotemplate.C        2001/03/05 07:42:21
@@ -114,20 +114,6 @@ void MathMacroTemplate::Metrics()
 }
 
 
-void MathMacroTemplate::update(MathMacro * macro)
-{
-       Assert(macro);
-       int const idx = macro->getArgumentIdx();
-       for (int i = 0; i < nargs_; ++i) {
-                       macro->setArgumentIdx(i);
-                       args_[i].setData(macro->GetData());
-                       MathedRowSt * row = macro->getRowSt();
-                       args_[i].setRowSt(row);
-       }       
-       macro->setArgumentIdx(idx);
-}
-
-
 void MathMacroTemplate::WriteDef(ostream & os, bool fragile)
 {
        os << "\n\\newcommand{\\" << name << "}";
@@ -170,3 +156,11 @@ void MathMacroTemplate::SetMacroFocus(in
                }
        }
 }
+
+void MathMacroTemplate::setMacroPar
+       (int i, MathedArray const & ar, MathedRowSt * r)
+{
+       args_[i].setData(ar);
+       args_[i].setRowSt(r);
+}
+
Index: math_macrotemplate.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macrotemplate.h,v
retrieving revision 1.7
diff -u -p -r1.7 math_macrotemplate.h
--- math_macrotemplate.h        2001/03/01 14:07:43     1.7
+++ math_macrotemplate.h        2001/03/05 07:42:21
@@ -40,12 +40,11 @@ public:
        ///
        MathParInset * getMacroPar(int) const;
        ///
+       void setMacroPar(int, MathedArray const &, MathedRowSt *);
+       ///
        void SetMacroFocus(int &, int, int);
        ///
        void setEditMode(bool);
-       
-       /// Replace the appropriate arguments with a specific macro's data
-       void update(MathMacro * m);
 private:
        /// Are we in edit mode or not?
        bool edit_;

Reply via email to