]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetnote.C
prevent crash when inserting minipage in table cell,
[lyx.git] / src / insets / insetnote.C
index 3ab249427fdcfa12109d9b6a0a3bea84f7970795..92a79b09f7d93cdd122b9b8010ac4daa732e5626 100644 (file)
@@ -26,6 +26,7 @@
 #include "debug.h"
 
 using std::ostream;
+using std::auto_ptr;
 
 
 void InsetNote::init()
@@ -58,9 +59,9 @@ InsetNote::~InsetNote() // MV
 }
 
 
-InsetBase * InsetNote::clone() const
+auto_ptr<InsetBase> InsetNote::clone() const
 {
-       return new InsetNote(*this);
+       return auto_ptr<InsetBase>(new InsetNote(*this));
 }
 
 
@@ -124,15 +125,14 @@ dispatch_result InsetNote::localDispatch(FuncRequest const & cmd)
                return DISPATCHED;
                }
        case LFUN_INSET_EDIT:
-               if (cmd.button() != mouse_button::button3) 
+               if (cmd.button() != mouse_button::button3)
                        return InsetCollapsable::localDispatch(cmd);
                return UNDISPATCHED;
        case LFUN_INSET_DIALOG_UPDATE:
                InsetNoteMailer("note", *this).updateDialog(bv);
                return DISPATCHED;
        case LFUN_MOUSE_RELEASE:
-               if (cmd.button() == mouse_button::button3 && cmd.x < button_length 
-                                       && cmd.y >= button_top_y && cmd.y <= button_bottom_y) {
+               if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
                        InsetNoteMailer("note", *this).showDialog(bv);
                        return DISPATCHED;
                }
@@ -150,38 +150,61 @@ int InsetNote::latex(Buffer const * buf, ostream & os,
 
        int i = 0;
        if (pt == "Comment")
-               os << "%\n\\begin{comment}\n"; // remember to validate
+                // verbatim
+               os << "%\n\\begin{comment}\n";
        else if (pt == "Greyedout")
-               os << "%\n\\textcolor[gray]{0.8}{";
+                // we roll our own macro
+               os << "%\n\\begin{lyxgreyedout}\n";
 
        if (pt != "Note")
                i = inset.latex(buf, os, runparams);
 
        if (pt == "Comment") {
                os << "%\n\\end{comment}\n";
-               i += 3;
-       } else if (pt == "Greyedout") { 
-               os << "\\normalcolor%\n}";
+               i += 3;
+       } else if (pt == "Greyedout") {
+               os << "%\n\\end{lyxgreyedout}\n";
                i += 2;
        }
        return i;
 }
 
 
-int InsetNote::linuxdoc(Buffer const *, std::ostream &) const
-{ 
-       return 0; 
+int InsetNote::linuxdoc(Buffer const * buf, std::ostream & os) const
+{
+       string const pt = params_.type;
+
+       int i = 0;
+       if (pt == "Comment")
+               os << "<comment>\n";
+
+       if (pt != "Note")
+               i = inset.linuxdoc(buf, os);
+
+       if (pt == "Comment") {
+               os << "\n</comment>\n";
+               i += 3;
+       }
+       return i;
 }
 
 
 int InsetNote::docbook(Buffer const * buf, std::ostream & os, bool mixcont) const
 {
-       int i = 0;
        string const pt = params_.type;
-       // incomplete, untested - MV
-       if (pt != "Note") 
+
+       int i = 0;
+       if (pt == "Comment")
+               os << "<remark>\n";
+
+       if (pt != "Note")
                i = inset.docbook(buf, os, mixcont);
-       return i; 
+
+       if (pt == "Comment") {
+               os << "\n</remark>\n";
+               i += 3;
+       }
+       return i;
 }
 
 
@@ -200,10 +223,12 @@ int InsetNote::ascii(Buffer const * buf, std::ostream & os, int ll) const
 
 void InsetNote::validate(LaTeXFeatures & features) const
 {
-       if (params_.type == "Comment") 
+       if (params_.type == "Comment")
                features.require("verbatim");
-       if (params_.type == "Greyedout")
+       if (params_.type == "Greyedout") {
                features.require("color");
+               features.require("lyxgreyedout");
+       }
        inset.validate(features);
 }
 
@@ -216,7 +241,7 @@ InsetNoteMailer::InsetNoteMailer(string const & name,
 }
 
 
-string const InsetNoteMailer::inset2string() const
+string const InsetNoteMailer::inset2string(Buffer const &) const
 {
        return params2string(name_, inset_.params());
 }
@@ -265,4 +290,3 @@ void InsetNoteParams::read(LyXLex & lex)
                type = lex.getString();
        }
 }
-