]> git.lyx.org Git - features.git/commitdiff
Fix dialog interaction with InsetMathRef (leftover from changed
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Fri, 6 Apr 2007 08:30:37 +0000 (08:30 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Fri, 6 Apr 2007 08:30:37 +0000 (08:30 +0000)
InsetCommandParams)

* src/mathed/InsetMathCommand.[Ch]
(CommandInset::createDialogStr): Move to InsetMathRef, since it is
no longer generic.

* src/mathed/MathFactory.C
(createInsetMath_fromDialogStr): Use InsetCommandMailer instead of
manual parsing. This ensures that the syntax is correct.

* src/mathed/InsetMathRef.[Ch]
(InsetMathRef::createDialogStr): Moved here from InsetMathCommand,
but use InsetCommandMailer.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17738 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathCommand.C
src/mathed/InsetMathCommand.h
src/mathed/InsetMathRef.C
src/mathed/InsetMathRef.h
src/mathed/MathFactory.C

index 785017cc392ca9ea8c1c9d26fe549334377292b7..3f58ea5117727f6204a0e5919798097849baa917 100644 (file)
@@ -79,15 +79,4 @@ docstring const CommandInset::screenLabel() const
        return name_;
 }
 
-
-string const CommandInset::createDialogStr(string const & name) const
-{
-       odocstringstream os;
-       os << from_ascii(name + " LatexCommand ");
-       WriteStream ws(os);
-       write(ws);
-       return to_utf8(os.str()) + "\n\\end_inset\n\n";
-}
-
-
 } // namespace lyx
index 93c280aa38c9be54616f39e6820e5b92d465a6ed..e2a114304d15284f0f76d716e457343276c26075 100644 (file)
@@ -38,8 +38,6 @@ public:
        // void infoize(odocstream & os) const;
        ///
        virtual docstring const screenLabel() const;
-       /// generate something that will be understood by the Dialogs.
-       std::string const createDialogStr(std::string const & name) const;
        ///
        docstring const & commandname() const { return name_; }
 private:
index 92a37e4ca0cb0d61b8aa795c48316195678070c7..63afad169a3f35fd38cad6e4d6ead0cb521e20c4 100644 (file)
@@ -26,6 +26,8 @@
 #include "outputparams.h"
 #include "sgml.h"
 
+#include "insets/insetcommand.h"
+
 
 namespace lyx {
 
@@ -171,6 +173,16 @@ int RefInset::docbook(Buffer const & buf, odocstream & os,
 }
 
 
+string const RefInset::createDialogStr(string const & name) const
+{
+       InsetCommandParams icp(to_ascii(commandname()));
+       icp["reference"] = asString(cell(0));
+       if (!cell(1).empty())
+               icp["name"] = asString(cell(1));
+       return InsetCommandMailer::params2string(name, icp);
+}
+
+
 RefInset::ref_type_info RefInset::types[] = {
        { from_ascii("ref"),       from_ascii(N_("Standard")),              from_ascii(N_("Ref: "))},
        { from_ascii("eqref"),     from_ascii(N_("Equation")),              from_ascii(N_("EqRef: "))},
index 25d1391e50cf795d8818cacc11306cd497c8e7a1..0d1504e097d1dc0c6152000f8a3e54929d52ff82 100644 (file)
@@ -39,6 +39,8 @@ public:
 
        /// docbook output
        int docbook(Buffer const & buf, odocstream & os, OutputParams const &) const;
+       /// generate something that will be understood by the Dialogs.
+       std::string const createDialogStr(std::string const & name) const;
 
        struct ref_type_info {
                ///
index 170b6392fca0efcbdfc5f1d3d96037cad317ff67..62bcef30db3a579a06823e195289936c7e915c2c 100644 (file)
@@ -56,6 +56,8 @@
 
 #include "debug.h"
 
+#include "insets/insetcommand.h"
+
 #include "support/filetools.h" // LibFileSearch
 #include "support/lstrings.h"
 
@@ -405,20 +407,17 @@ MathAtom createInsetMath(docstring const & s)
 bool createInsetMath_fromDialogStr(docstring const & str, MathArray & ar)
 {
        // An example str:
-       // "ref LatexCommand \\ref{sec:Title}\n\\end_inset\n\n";
+       // "ref LatexCommand ref\nreference \"sec:Title\"\n\\end_inset\n\n";
        docstring name;
        docstring body = split(str, name, ' ');
 
        if (name != "ref" )
                return false;
 
-       // body comes with a head "LatexCommand " and a
-       // tail "\nend_inset\n\n". Strip them off.
-       docstring trimmed;
-       body = split(body, trimmed, ' ');
-       split(body, trimmed, '\n');
-
-       mathed_parse_cell(ar, trimmed);
+       InsetCommandParams icp("ref");
+       // FIXME UNICODE
+       InsetCommandMailer::string2params("ref", to_utf8(str), icp);
+       mathed_parse_cell(ar, icp.getCommand());
        if (ar.size() != 1)
                return false;