]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetnote.C
Don't remove cell selections after fontchange.
[lyx.git] / src / insets / insetnote.C
index f5d7fc8ca5fa5a1e5ababfdefec7c160e624902a..da3c39bfd6449a9f938261ad331b4db4b86358aa 100644 (file)
 #include "insetnote.h"
 #include "gettext.h"
 #include "lyxfont.h"
+#include "language.h"
+#include "buffer.h"
 #include "BufferView.h"
 #include "lyxtext.h"
 #include "insets/insettext.h"
 #include "support/LOstream.h"
+#include "support/lstrings.h"
 #include "debug.h"
 
 using std::ostream;
 
-InsetNote::InsetNote()
-       : InsetCollapsable()
+
+void InsetNote::init()
 {
        LyXFont font(LyXFont::ALL_SANE);
        font.decSize();
-       font.decSize();
        font.setColor(LColor::note);
        setLabelFont(font);
-       setAutoCollapse(true);
-
+       setBackgroundColor(LColor::notebg);
        setLabel(_("note"));
        setInsetName("Note");
 }
 
 
+InsetNote::InsetNote()
+       : InsetCollapsable()
+{
+       init();
+}
+
+
+InsetNote::InsetNote(InsetNote const & in, bool same_id)
+       : InsetCollapsable(in, same_id)
+{
+       init();
+}
+
+
 Inset * InsetNote::clone(Buffer const &, bool same_id) const
 {
-       InsetNote * result = new InsetNote;
-       result->inset.init(&inset, same_id);
+       return new InsetNote(*const_cast<InsetNote *>(this), same_id);
+}
+
 
-       result->collapsed_ = collapsed_;
-       if (same_id)
-               result->id_ = id_;
-       return result;
+// This constructor is used for reading old InsetInfo
+InsetNote::InsetNote(Buffer const * buf, string const & contents, 
+                    bool collapsed)
+       : InsetCollapsable(collapsed)
+{
+       init();
+
+       Paragraph * par = inset.paragraph();
+       LyXFont font(LyXFont::ALL_INHERIT, buf->params.language);
+
+       // Since XForms doesn't support RTL, we can assume that old notes
+       // in RTL documents are written in English.
+       if (font.language()->RightToLeft())
+               font.setLanguage(default_language);
+
+       lyx::pos_type pos = 0;
+       buf->insertStringAsLines(par, pos, font, strip(contents, '\n'));
 }
 
 
@@ -60,8 +89,6 @@ string const InsetNote::editMessage() const
 
 void InsetNote::write(Buffer const *buf, ostream & os) const
 {
-       //os << getInsetName() << "\n";
-       os << "Info\n";
+       os << getInsetName() << "\n";
        InsetCollapsable::write(buf, os);
 }
-