]> git.lyx.org Git - features.git/blobdiff - src/insets/insetnote.C
change "support/std_sstream.h" to <sstream>
[features.git] / src / insets / insetnote.C
index 83888887c7afc3cf369d2bb3d34e568c73aae0f3..3be5403fb54ccff288c0a69101b7009932e47a06 100644 (file)
@@ -15,6 +15,7 @@
 #include "insetnote.h"
 
 #include "BufferView.h"
+#include "cursor.h"
 #include "debug.h"
 #include "dispatchresult.h"
 #include "funcrequest.h"
@@ -26,9 +27,9 @@
 #include "paragraph.h"
 
 #include "support/lyxalgo.h"
-#include "support/std_sstream.h"
 #include "support/translator.h"
 
+#include <sstream>
 
 using std::string;
 using std::auto_ptr;
@@ -82,7 +83,6 @@ void InsetNoteParams::write(ostream & os) const
 {
        string const label = notetranslator().find(type);
        os << "Note " << label << "\n";
-       os << label << "\n";
 }
 
 
@@ -184,34 +184,30 @@ bool InsetNote::showInsetDialog(BufferView * bv) const
 }
 
 
-DispatchResult
-InsetNote::priv_dispatch(FuncRequest const & cmd,
-                        idx_type & idx, pos_type & pos)
+void InsetNote::priv_dispatch(LCursor & cur, FuncRequest & cmd)
 {
-       BufferView * bv = cmd.view();
-
        switch (cmd.action) {
 
-       case LFUN_INSET_MODIFY: {
+       case LFUN_INSET_MODIFY:
                InsetNoteMailer::string2params(cmd.argument, params_);
                setButtonLabel();
-               bv->update();
-               return DispatchResult(true, true);
-       }
+               cur.bv().update();
+               break;
 
        case LFUN_INSET_DIALOG_UPDATE:
-               InsetNoteMailer(*this).updateDialog(bv);
-               return DispatchResult(true, true);
+               InsetNoteMailer(*this).updateDialog(&cur.bv());
+               break;
 
        case LFUN_MOUSE_RELEASE:
-               if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
-                       InsetNoteMailer(*this).showDialog(bv);
-                       return DispatchResult(true, true);
-               }
-               // fallthrough:
+               if (cmd.button() == mouse_button::button3 && hitButton(cmd))
+                       InsetNoteMailer(*this).showDialog(&cur.bv());
+               else
+                       InsetCollapsable::priv_dispatch(cur, cmd);
+               break;
 
        default:
-               return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+               InsetCollapsable::priv_dispatch(cur, cmd);
+               break;
        }
 }
 
@@ -230,7 +226,7 @@ int InsetNote::latex(Buffer const & buf, ostream & os,
 
        ostringstream ss;
        ss << "%\n\\begin{" << type << "}\n";
-       inset.latex(buf, ss, runparams);
+       InsetText::latex(buf, ss, runparams);
        ss << "%\n\\end{" << type << "}\n";
 
        string const str = ss.str();
@@ -250,7 +246,7 @@ int InsetNote::linuxdoc(Buffer const & buf, std::ostream & os,
        if (params_.type == InsetNoteParams::Comment)
                ss << "<comment>\n";
 
-       inset.linuxdoc(buf, ss, runparams);
+       InsetText::linuxdoc(buf, ss, runparams);
 
        if (params_.type == InsetNoteParams::Comment)
                ss << "\n</comment>\n";
@@ -272,7 +268,7 @@ int InsetNote::docbook(Buffer const & buf, std::ostream & os,
        if (params_.type == InsetNoteParams::Comment)
                ss << "<remark>\n";
 
-       inset.docbook(buf, ss, runparams);
+       InsetText::docbook(buf, ss, runparams);
 
        if (params_.type == InsetNoteParams::Comment)
                ss << "\n</remark>\n";
@@ -292,7 +288,7 @@ int InsetNote::plaintext(Buffer const & buf, std::ostream & os,
 
        ostringstream ss;
        ss << "[";
-       inset.plaintext(buf, ss, runparams);
+       InsetText::plaintext(buf, ss, runparams);
        ss << "]";
 
        string const str = ss.str();
@@ -310,12 +306,12 @@ void InsetNote::validate(LaTeXFeatures & features) const
                features.require("color");
                features.require("lyxgreyedout");
        }
-       inset.validate(features);
+       InsetText::validate(features);
 }
 
 
 
-string const InsetNoteMailer:: name_("note");
+string const InsetNoteMailer::name_("note");
 
 InsetNoteMailer::InsetNoteMailer(InsetNote & inset)
        : inset_(inset)
@@ -351,18 +347,15 @@ void InsetNoteMailer::string2params(string const & in,
 
        string name;
        lex >> name;
-       if (!lex || name != name_) {
-               lyxerr << "InsetNoteMailer::string2params(" << in << ")\n"
-                      << "Missing identifier \"" << name_ << '"' << std::endl;
-               return;
-       }
+       if (!lex || name != name_)
+               return print_mailer_error("InsetNoteMailer", in, 1, name_);
 
        // This is part of the inset proper that is usually swallowed
        // by LyXText::readInset
-       string inset_id;
-       lex >> inset_id;
-       if (!lex || inset_id != "Note")
-               return;
+       string id;
+       lex >> id;
+       if (!lex || id != "Note")
+               return print_mailer_error("InsetBoxMailer", in, 2, "Note");
 
        params.read(lex);
 }