]> git.lyx.org Git - features.git/blobdiff - src/insets/insetnote.C
Replace LString.h with support/std_string.h,
[features.git] / src / insets / insetnote.C
index 92e5dc4581bc69382086e77e13a8984175f264cb..bc508810282e88691c5cdaea38b0a132327b4bca 100644 (file)
@@ -7,28 +7,24 @@
  * \author Martin Vermeer
  * \author Jürgen Spitzmüller
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-#include "Lsstream.h"
-
 #include "insetnote.h"
-#include "gettext.h"
-#include "lyxfont.h"
-#include "language.h"
-#include "buffer.h"
+
 #include "BufferView.h"
+#include "funcrequest.h"
+#include "gettext.h"
+#include "LaTeXFeatures.h"
 #include "lyxlex.h"
-#include "lyxtext.h"
-#include "insets/insettext.h"
-#include "support/LOstream.h"
-#include "support/lstrings.h"
-#include "debug.h"
+#include "metricsinfo.h"
+
+#include "support/std_sstream.h"
 
-using std::ostream;
 using std::auto_ptr;
+using std::ostream;
 
 
 void InsetNote::init()
@@ -73,14 +69,14 @@ string const InsetNote::editMessage() const
 }
 
 
-void InsetNote::write(Buffer const * buf, ostream & os) const
+void InsetNote::write(Buffer const & buf, ostream & os) const
 {
        params_.write(os);
        InsetCollapsable::write(buf, os);
 }
 
 
-void InsetNote::read(Buffer const * buf, LyXLex & lex)
+void InsetNote::read(Buffer const & buf, LyXLex & lex)
 {
        InsetCollapsable::read(buf, lex);
        setButtonLabel();
@@ -110,6 +106,18 @@ void InsetNote::setButtonLabel()
 }
 
 
+void InsetNote::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+       InsetCollapsable::metrics(mi, dim);
+       // Contrary to Greyedout, these cannot be construed as part of the
+       // running text: make them stand on their own
+       if (params_.type == "Note" || params_.type == "Comment")
+               if (!collapsed_)
+                       dim.wid = mi.base.textwidth;
+       dim_ = dim;
+}
+
+
 bool InsetNote::showInsetDialog(BufferView * bv) const
 {
        InsetNoteMailer("note", const_cast<InsetNote &>(*this)).showDialog(bv);
@@ -122,35 +130,39 @@ dispatch_result InsetNote::localDispatch(FuncRequest const & cmd)
        BufferView * bv = cmd.view();
 
        switch (cmd.action) {
-       case LFUN_INSET_MODIFY:
-               {
+
+       case LFUN_INSET_MODIFY: {
                InsetNoteParams params;
                InsetNoteMailer::string2params(cmd.argument, params);
                params_.type = params.type;
                setButtonLabel();
                bv->updateInset(this);
                return DISPATCHED;
-               }
+       }
+
        case LFUN_INSET_EDIT:
-               if (cmd.button() != mouse_button::button3)
-                       return InsetCollapsable::localDispatch(cmd);
-               return UNDISPATCHED;
+               if (cmd.button() == mouse_button::button3)
+                       return UNDISPATCHED;
+               return InsetCollapsable::localDispatch(cmd);
+
        case LFUN_INSET_DIALOG_UPDATE:
                InsetNoteMailer("note", *this).updateDialog(bv);
                return DISPATCHED;
+
        case LFUN_MOUSE_RELEASE:
                if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
                        InsetNoteMailer("note", *this).showDialog(bv);
                        return DISPATCHED;
                }
                // fallthrough:
+
        default:
                return InsetCollapsable::localDispatch(cmd);
        }
 }
 
 
-int InsetNote::latex(Buffer const * buf, ostream & os,
+int InsetNote::latex(Buffer const & buf, ostream & os,
                                                LatexRunParams const & runparams) const
 {
        string const pt = params_.type;
@@ -168,16 +180,16 @@ int InsetNote::latex(Buffer const * buf, ostream & os,
 
        if (pt == "Comment") {
                os << "%\n\\end{comment}\n";
-               i += 3;
+               i += 4;
        } else if (pt == "Greyedout") {
                os << "%\n\\end{lyxgreyedout}\n";
-               i += 2;
-       }
+               i += 4;
+       } 
        return i;
 }
 
 
-int InsetNote::linuxdoc(Buffer const * buf, std::ostream & os) const
+int InsetNote::linuxdoc(Buffer const & buf, std::ostream & os) const
 {
        string const pt = params_.type;
 
@@ -196,7 +208,7 @@ int InsetNote::linuxdoc(Buffer const * buf, std::ostream & os) const
 }
 
 
-int InsetNote::docbook(Buffer const * buf, std::ostream & os, bool mixcont) const
+int InsetNote::docbook(Buffer const & buf, std::ostream & os, bool mixcont) const
 {
        string const pt = params_.type;
 
@@ -215,7 +227,7 @@ int InsetNote::docbook(Buffer const * buf, std::ostream & os, bool mixcont) cons
 }
 
 
-int InsetNote::ascii(Buffer const * buf, std::ostream & os, int ll) const
+int InsetNote::ascii(Buffer const & buf, std::ostream & os, int ll) const
 {
        int i = 0;
        string const pt = params_.type;