]> git.lyx.org Git - features.git/commitdiff
Use the new lyxlex interface in InsetERT.
authorAngus Leeming <leeming@lyx.org>
Wed, 10 Dec 2003 21:32:05 +0000 (21:32 +0000)
committerAngus Leeming <leeming@lyx.org>
Wed, 10 Dec 2003 21:32:05 +0000 (21:32 +0000)
Ensure that InetExternalParams has a default template (RasterImage).

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

src/insets/ChangeLog
src/insets/insetert.C
src/insets/insetexternal.C

index ada3f05a673d55934cce3962f34f0157877b8349..706bfe102b058b408061b87080920366883bfb91 100644 (file)
@@ -1,3 +1,10 @@
+2003-12-10  Angus Leeming  <leeming@lyx.org>
+
+       * insetert.C (string2params): clean-up using the new lyxlex interface.
+
+       * insetexternal.C: ensure that InsetExternalParams has a default
+       template, 'RasterImage'.
+
 2003-12-10  Angus Leeming  <leeming@lyx.org>
 
        * insetnote.[Ch]: change the storage type of InsetNoteParams::type
index eb5a7fd22c6869ee1e4ba4be45ebc8a3dea4ed2f..1fe2feb33cf4528f02645b861618628a162fd858 100644 (file)
 #include "frontends/Alert.h"
 #include "frontends/LyXView.h"
 
-#include "support/tostr.h"
+#include "support/std_sstream.h"
 
 using lyx::pos_type;
 
-using lyx::support::split;
-using lyx::support::strToInt;
-
 using std::endl;
 using std::min;
-using std::string;
+
 using std::auto_ptr;
+using std::istringstream;
 using std::ostream;
+using std::ostringstream;
+using std::string;
 
 
 void InsetERT::init()
@@ -479,22 +479,33 @@ string const InsetERTMailer::inset2string(Buffer const &) const
 
 
 void InsetERTMailer::string2params(string const & in,
-                                  InsetCollapsable::InsetCollapsable::CollapseStatus & status)
+                                  InsetCollapsable::CollapseStatus & status)
 {
        status = InsetCollapsable::Collapsed;
 
-       string name;
-       string body = split(in, name, ' ');
+       istringstream data(in);
+       LyXLex lex(0,0);
+       lex.setStream(data);
 
-       if (body.empty())
+       string name;
+       lex >> name;
+       if (name != name_) {
+               lyxerr << "InsetERTMailer::string2params(" << in << ")\n"
+                      << "Missing identifier \"" << name_ << '"' << std::endl;
                return;
+       }
 
-       status = static_cast<InsetCollapsable::CollapseStatus>(strToInt(body));
+       int s;
+       lex >> s;
+       if (lex)
+               status = static_cast<InsetCollapsable::CollapseStatus>(s);
 }
 
 
 string const
 InsetERTMailer::params2string(InsetCollapsable::CollapseStatus status)
 {
-       return name_ + ' ' + tostr(status);
+       ostringstream data;
+       data << name_ << ' ' << status;
+       return data.str();
 }
index 7c7d888a2c6cdbe0a2b004163446e90cc54328c9..ba65ca17d57991d6fa0c21169d43f53096aebc31 100644 (file)
@@ -63,7 +63,9 @@ namespace {
 
 external::DisplayType const defaultDisplayType = external::NoDisplay;
 
-unsigned int defaultLyxScale = 100;
+unsigned int const defaultLyxScale = 100;
+
+string const defaultTemplateName = "RasterImage";
 
 } // namespace anon
 
@@ -134,7 +136,8 @@ Translator<DisplayType, string> const & displayTranslator()
 
 InsetExternalParams::InsetExternalParams()
        : display(defaultDisplayType),
-         lyxscale(defaultLyxScale)
+         lyxscale(defaultLyxScale),
+         templatename_(defaultTemplateName)
 {}
 
 
@@ -372,7 +375,7 @@ bool InsetExternalParams::read(Buffer const & buffer, LyXLex & lex)
        }
 
        if (!found_end)
-               lex.printError("ExternalInset::read: Missing \\end_inset.");
+               lex.printError("ExternalInsetParams::read: Missing \\end_inset.");
 
        // This is a trick to make sure that the data are self-consistent.
        settemplate(templatename_);