]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetnote.C
move inset related stuff from src/graphics to src/inset/
[lyx.git] / src / insets / insetnote.C
index a27c71c0ce6a30c0285bc0f7fd9c68f0edee9261..21c1e9770fb643ad8cba552fbe041a185c7a5f83 100644 (file)
@@ -1,8 +1,8 @@
 /* This file is part of
  * ======================================================
- * 
+ *
  *           LyX, The Document Processor
- *      
+ *
  *          Copyright 1998 The LyX Team.
  *
  * ======================================================
@@ -17,6 +17,7 @@
 #include "insetnote.h"
 #include "gettext.h"
 #include "lyxfont.h"
+#include "language.h"
 #include "buffer.h"
 #include "BufferView.h"
 #include "lyxtext.h"
 
 using std::ostream;
 
+
 void InsetNote::init()
 {
        LyXFont font(LyXFont::ALL_SANE);
        font.decSize();
        font.setColor(LColor::note);
        setLabelFont(font);
-#if 0
-       setAutoCollapse(false);
-#endif
-       setBackgroundColor(LColor::note);
-
+       setBackgroundColor(LColor::notebg);
        setLabel(_("note"));
        setInsetName("Note");
 }
 
 
-InsetNote::InsetNote()
-       : InsetCollapsable()
+InsetNote::InsetNote(BufferParams const & bp)
+       : InsetCollapsable(bp)
+{
+       init();
+}
+
+
+InsetNote::InsetNote(InsetNote const & in, bool same_id)
+       : InsetCollapsable(in, same_id)
 {
        init();
 }
 
 
-InsetNote::InsetNote(Buffer const * buf, string const & contents, 
+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)
+       : InsetCollapsable(buf->params, collapsed)
 {
        init();
 
        Paragraph * par = inset.paragraph();
-       Paragraph::size_type pos = 0;
-       buf->insertStringAsLines(par, pos, LyXFont(LyXFont::ALL_INHERIT), 
-                                strip(contents, '\n'));
+       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'));
 }
 
 
-string const InsetNote::editMessage() const 
+string const InsetNote::editMessage() const
 {
        return _("Opened Note Inset");
 }