3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS
14 #pragma implementation
17 #include "insetnote.h"
22 #include "BufferView.h"
24 #include "insets/insettext.h"
25 #include "support/LOstream.h"
26 #include "support/lstrings.h"
32 void InsetNote::init()
34 LyXFont font(LyXFont::ALL_SANE);
37 font.setColor(LColor::note);
39 setBackgroundColor(LColor::notebg);
45 InsetNote::InsetNote(BufferParams const & bp)
46 : InsetCollapsable(bp)
52 InsetNote::InsetNote(InsetNote const & in, bool same_id)
53 : InsetCollapsable(in, same_id)
59 Inset * InsetNote::clone(Buffer const &, bool same_id) const
61 return new InsetNote(*const_cast<InsetNote *>(this), same_id);
65 // This constructor is used for reading old InsetInfo
66 InsetNote::InsetNote(Buffer const * buf, string const & contents,
68 : InsetCollapsable(buf->params, collapsed)
72 Paragraph * par = inset.paragraph();
73 LyXFont font(LyXFont::ALL_INHERIT, buf->params.language);
75 // Since XForms doesn't support RTL, we can assume that old notes
76 // in RTL documents are written in English.
77 if (font.language()->RightToLeft())
78 font.setLanguage(default_language);
80 lyx::pos_type pos = 0;
81 buf->insertStringAsLines(par, pos, font, rtrim(contents, "\n"));
85 string const InsetNote::editMessage() const
87 return _("Opened Note Inset");
91 void InsetNote::write(Buffer const *buf, ostream & os) const
93 os << getInsetName() << "\n";
94 InsetCollapsable::write(buf, os);