]> git.lyx.org Git - lyx.git/blob - src/insets/insetnote.C
update no.po
[lyx.git] / src / insets / insetnote.C
1 /**
2  * \file insetnote.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "insetnote.h"
18 #include "gettext.h"
19 #include "lyxfont.h"
20 #include "language.h"
21 #include "buffer.h"
22 #include "BufferView.h"
23 #include "lyxtext.h"
24 #include "insets/insettext.h"
25 #include "support/LOstream.h"
26 #include "support/lstrings.h"
27 #include "debug.h"
28
29 using std::ostream;
30
31
32 void InsetNote::init()
33 {
34         LyXFont font(LyXFont::ALL_SANE);
35         font.decSize();
36         font.decSize();
37         font.setColor(LColor::note);
38         setLabelFont(font);
39         setBackgroundColor(LColor::notebg);
40         setLabel(_("note"));
41         setInsetName("Note");
42 }
43
44
45 InsetNote::InsetNote(BufferParams const & bp)
46         : InsetCollapsable(bp)
47 {
48         init();
49 }
50
51
52 InsetNote::InsetNote(InsetNote const & in, bool same_id)
53         : InsetCollapsable(in, same_id)
54 {
55         init();
56 }
57
58
59 Inset * InsetNote::clone(Buffer const &, bool same_id) const
60 {
61         return new InsetNote(*const_cast<InsetNote *>(this), same_id);
62 }
63
64
65 // This constructor is used for reading old InsetInfo
66 InsetNote::InsetNote(Buffer const * buf, string const & contents,
67                      bool collapsed)
68         : InsetCollapsable(buf->params, collapsed)
69 {
70         init();
71
72         Paragraph * par = inset.paragraph();
73         LyXFont font(LyXFont::ALL_INHERIT, buf->params.language);
74
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);
79
80         lyx::pos_type pos = 0;
81         buf->insertStringAsLines(par, pos, font, rtrim(contents, "\n"));
82 }
83
84
85 string const InsetNote::editMessage() const
86 {
87         return _("Opened Note Inset");
88 }
89
90
91 void InsetNote::write(Buffer const *buf, ostream & os) const
92 {
93         os << getInsetName() << "\n";
94         InsetCollapsable::write(buf, os);
95 }