]> git.lyx.org Git - features.git/commitdiff
fix bug 2126 (references in math)
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Tue, 22 Nov 2005 13:52:25 +0000 (13:52 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Tue, 22 Nov 2005 13:52:25 +0000 (13:52 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10616 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/ChangeLog
src/mathed/command_inset.C
src/mathed/command_inset.h
src/mathed/math_hullinset.C
src/mathed/math_nestinset.C
src/mathed/ref_inset.C
src/mathed/ref_inset.h

index 804e5bcc2e8cd816d14c169e3c142696396fd3cc..205ca8a5e22da923cfef3d728707fb9c280ad9e5 100644 (file)
@@ -1,3 +1,17 @@
+2005-11-15  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
+
+       * command_inset.[Ch] (editXY): implement, since MathNestInset::editXY
+       loops through the cells and that is not possible here because they are
+       not visible
+       * math_hullinset.C (getStatus): allow reference and label in
+       LFUN_INSET_INSERT
+       * math_hullinset.C (doDispatch): create ref inset in LFUN_INSET_INSERT
+       * math_nestinset.C (doDispatch): allow references
+       * math_nestinset.C (doDispatch): remove never reached code for
+       LFUN_INSET_APPLY
+       * ref_inset.[Ch] (getStatus): implement, otherwise we'll trigger an
+       assertion in LyXFunc::getStatus
+
 2005-11-08  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
 
        * math_parser.C (delEmptyLastRow): Don't delete the dummy row, but
index 3e4c7f4055c802baea836ed0de1c8cfce77bdb04..40c38acc44fee8ffccd9dcb8e54a7639ceb8905c 100644 (file)
@@ -47,6 +47,13 @@ void CommandInset::metrics(MetricsInfo & mi, Dimension & dim) const
 }
 
 
+InsetBase * CommandInset::editXY(LCursor & cur, int x, int y)
+{
+       edit(cur, true);
+       return this;
+}
+
+
 void CommandInset::draw(PainterInfo & pi, int x, int y) const
 {
        button_.draw(pi, x, y);
index b0de073df565ac55419f8a303c6b176dca587c27..8872cfec91fb25fe02808a3405f3375af3f5d910 100644 (file)
@@ -28,6 +28,8 @@ public:
        ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///
+       InsetBase * editXY(LCursor &, int, int);
+       ///
        void write(WriteStream & os) const;
        //
        // void infoize(std::ostream & os) const;
index b264756962d1fcf501c57cebd7f55c6c825cbbdc..12417efb4cb3baba887840b887a1778e6878e17d 100644 (file)
@@ -14,6 +14,7 @@
 #include "math_colorinset.h"
 #include "math_data.h"
 #include "math_extern.h"
+#include "math_factory.h"
 #include "math_hullinset.h"
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
@@ -1075,7 +1076,14 @@ void MathHullInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                                cur.bv().buffer()->changeRefsIfUnique(old, str);
                                label(r, str);
                        }
+                       break;
                }
+               MathArray ar;
+               if (createMathInset_fromDialogStr(cmd.argument, ar)) {
+                       recordUndo(cur);
+                       cur.insert(ar);
+               } else
+                       cur.undispatched();
                break;
        }
 
@@ -1138,6 +1146,15 @@ bool MathHullInset::getStatus(LCursor & cur, FuncRequest const & cmd,
        case LFUN_INSERT_LABEL:
                status.enabled(type_ != "simple");
                return true;
+       case LFUN_INSET_INSERT: {
+               // Don't test createMathInset_fromDialogStr(), since
+               // getStatus is not called with a valid reference and the
+               // dialog would not be applyable.
+               string const name = cmd.getArg(0);
+               status.enabled(name == "ref" ||
+                              (name == "label" && type_ != "simple"));
+               break;
+       }
        case LFUN_TABULAR_FEATURE: {
                istringstream is(cmd.argument);
                string s;
index ec23d10bdc00723890090c249e6410aa51cae730..c6ef7f2d510d1c91479ea259ff733a828181734f 100644 (file)
@@ -30,6 +30,7 @@
 #include "math_symbolinset.h"
 #include "math_support.h"
 #include "math_unknowninset.h"
+#include "ref_inset.h"
 
 #include "BufferView.h"
 #include "CutAndPaste.h"
@@ -56,7 +57,6 @@
 using lyx::cap::copySelection;
 using lyx::cap::grabAndEraseSelection;
 using lyx::cap::cutSelection;
-using lyx::cap::pasteSelection;
 using lyx::cap::replaceSelection;
 using lyx::cap::selClearOrDel;
 
@@ -885,34 +885,14 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_DIALOG_SHOW_NEW_INSET: {
                string const & name = cmd.argument;
                string data;
-#if 0
                if (name == "ref") {
                        RefInset tmp(name);
                        data = tmp.createDialogStr(name);
                }
-#endif
                cur.bv().owner()->getDialogs().show(name, data, 0);
                break;
        }
 
-       case LFUN_INSET_APPLY: {
-               string const name = cmd.getArg(0);
-               InsetBase * base = cur.bv().owner()->getDialogs().getOpenInset(name);
-
-               if (base) {
-                       FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument);
-                       base->dispatch(cur, fr);
-                       break;
-               }
-               MathArray ar;
-               if (createMathInset_fromDialogStr(cmd.argument, ar)) {
-                       cur.insert(ar);
-                       break;
-               }
-               cur.undispatched();
-               break;
-       }
-
        default:
                MathDimInset::doDispatch(cur, cmd);
                break;
index 47734214dafbf1e52238f8544d7aee0fe763d571..3d33e8152931e3d9491bc854272063eb9a3314c1 100644 (file)
@@ -18,6 +18,7 @@
 #include "cursor.h"
 #include "debug.h"
 #include "funcrequest.h"
+#include "FuncStatus.h"
 #include "gettext.h"
 #include "math_data.h"
 #include "math_factory.h"
@@ -70,6 +71,14 @@ void RefInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                cur.undispatched();
                break;
 
+       case LFUN_INSET_DIALOG_UPDATE: {
+               string const data = createDialogStr("ref");
+               if (cur.bv().owner()->getDialogs().visible("ref"))
+                       cur.bv().owner()->getDialogs().update("ref", data);
+               break;
+       }
+
+       case LFUN_INSET_DIALOG_SHOW:
        case LFUN_MOUSE_RELEASE:
                if (cmd.button() == mouse_button::button3) {
                        lyxerr << "trying to goto ref '" << asString(cell(0)) << "'" << endl;
@@ -97,6 +106,25 @@ void RefInset::doDispatch(LCursor & cur, FuncRequest & cmd)
 }
 
 
+bool RefInset::getStatus(LCursor & cur, FuncRequest const & cmd,
+                         FuncStatus & status) const
+{
+       switch (cmd.action) {
+       // we handle these
+       case LFUN_INSET_MODIFY:
+       case LFUN_INSET_DIALOG_UPDATE:
+       case LFUN_INSET_DIALOG_SHOW:
+       case LFUN_MOUSE_RELEASE:
+       case LFUN_MOUSE_PRESS:
+       case LFUN_MOUSE_MOTION:
+               status.enabled(true);
+               return true;
+       default:
+               return CommandInset::getStatus(cur, cmd, status);
+       }
+}
+
+
 string const RefInset::screenLabel() const
 {
        string str;
index 7e3c58ce2d006fd8dbde820bd64c3821eec140e5..cf5298ef1a138b16a74dabaadee7633b2a46de6c 100644 (file)
@@ -55,7 +55,10 @@ public:
        ///
        static std::string const & getName(int type);
 protected:
+       ///
        virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
+       ///
+       bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
 private:
        ///
        virtual std::auto_ptr<InsetBase> doClone() const;