From: Georg Baum Date: Fri, 6 Apr 2007 08:30:37 +0000 (+0000) Subject: Fix dialog interaction with InsetMathRef (leftover from changed X-Git-Tag: 1.6.10~10328 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ea1a4a886cdff7d4f2a97c7308ab9e2da4a80718;p=features.git Fix dialog interaction with InsetMathRef (leftover from changed 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 --- diff --git a/src/mathed/InsetMathCommand.C b/src/mathed/InsetMathCommand.C index 785017cc39..3f58ea5117 100644 --- a/src/mathed/InsetMathCommand.C +++ b/src/mathed/InsetMathCommand.C @@ -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 diff --git a/src/mathed/InsetMathCommand.h b/src/mathed/InsetMathCommand.h index 93c280aa38..e2a114304d 100644 --- a/src/mathed/InsetMathCommand.h +++ b/src/mathed/InsetMathCommand.h @@ -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: diff --git a/src/mathed/InsetMathRef.C b/src/mathed/InsetMathRef.C index 92a37e4ca0..63afad169a 100644 --- a/src/mathed/InsetMathRef.C +++ b/src/mathed/InsetMathRef.C @@ -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: "))}, diff --git a/src/mathed/InsetMathRef.h b/src/mathed/InsetMathRef.h index 25d1391e50..0d1504e097 100644 --- a/src/mathed/InsetMathRef.h +++ b/src/mathed/InsetMathRef.h @@ -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 { /// diff --git a/src/mathed/MathFactory.C b/src/mathed/MathFactory.C index 170b6392fc..62bcef30db 100644 --- a/src/mathed/MathFactory.C +++ b/src/mathed/MathFactory.C @@ -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;