]> git.lyx.org Git - lyx.git/blob - src/insets/insetnote.C
Few fixes for inserERT/insetNote
[lyx.git] / src / insets / insetnote.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *          Copyright 1998 The LyX Team.
7  *
8  * ======================================================
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 "buffer.h"
21 #include "BufferView.h"
22 #include "lyxtext.h"
23 #include "insets/insettext.h"
24 #include "support/LOstream.h"
25 #include "support/lstrings.h"
26 #include "debug.h"
27
28 using std::ostream;
29
30 void InsetNote::init()
31 {
32         LyXFont font(LyXFont::ALL_SANE);
33         font.decSize();
34         font.setColor(LColor::note);
35         setLabelFont(font);
36         setBackgroundColor(LColor::note);
37         setLabel(_("note"));
38         setInsetName("Note");
39 }
40
41
42 InsetNote::InsetNote()
43         : InsetCollapsable()
44 {
45         init();
46 }
47
48
49 InsetNote::InsetNote(InsetNote const & in, bool same_id)
50         : InsetCollapsable(in, same_id)
51 {
52         init();
53 }
54
55
56 Inset * InsetNote::clone(Buffer const &, bool same_id) const
57 {
58         return new InsetNote(*const_cast<InsetNote *>(this), same_id);
59 }
60
61
62 // This constructor is used for reading old InsetInfo
63 InsetNote::InsetNote(Buffer const * buf, string const & contents, 
64                      bool collapsed)
65         : InsetCollapsable(collapsed)
66 {
67         init();
68
69         Paragraph * par = inset.paragraph();
70         Paragraph::size_type pos = 0;
71         LyXFont font(LyXFont::ALL_INHERIT, buf->params.language);
72
73         // Since XForms doesn't support RTL, we can assume that old notes
74         // in RTL documents are written in English.
75         if (font.language()->RightToLeft())
76                 font.setLanguage(default_language);
77
78         buf->insertStringAsLines(par, pos, font, strip(contents, '\n'));
79 }
80
81
82 string const InsetNote::editMessage() const 
83 {
84         return _("Opened Note Inset");
85 }
86
87
88 void InsetNote::write(Buffer const *buf, ostream & os) const
89 {
90         os << getInsetName() << "\n";
91         InsetCollapsable::write(buf, os);
92 }