]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetnote.C
whitespace changes;
[lyx.git] / src / insets / insetnote.C
index 89ac827f58894c444184b46fff04918511356376..d4a1f7797e5731f367e8352cd642bf7d09dfc582 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;
 
+
 void InsetNote::init()
 {
        LyXFont font(LyXFont::ALL_SANE);
        font.decSize();
        font.setColor(LColor::note);
        setLabelFont(font);
-       setAutoCollapse(false);
-
+       setBackgroundColor(LColor::note);
        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
+{
+       return new InsetNote(*const_cast<InsetNote *>(this), same_id);
+}
+
+
+// This constructor is used for reading old InsetInfo
 InsetNote::InsetNote(Buffer const * buf, string const & contents, 
                     bool collapsed)
        : InsetCollapsable(collapsed)
@@ -51,19 +69,15 @@ InsetNote::InsetNote(Buffer const * buf, string const & contents,
        init();
 
        Paragraph * par = inset.paragraph();
-       Paragraph::size_type pos = 0;
-       buf->insertStringAsLines(par, pos, labelfont, contents);
-}
+       LyXFont font(LyXFont::ALL_INHERIT, buf->params.language);
 
-Inset * InsetNote::clone(Buffer const &, bool same_id) const
-{
-       InsetNote * result = new InsetNote;
-       result->inset.init(&inset, same_id);
+       // 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);
 
-       result->collapsed_ = collapsed_;
-       if (same_id)
-               result->id_ = id_;
-       return result;
+       lyx::pos_type pos;
+       buf->insertStringAsLines(par, pos, font, strip(contents, '\n'));
 }