]> git.lyx.org Git - lyx.git/blob - src/insets/insetlabel.C
rename the refresh stuff
[lyx.git] / src / insets / insetlabel.C
1 /**
2  * \file insetlabel.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13
14 #include "insetlabel.h"
15 #include "buffer.h"
16 #include "BufferView.h"
17 #include "funcrequest.h"
18 #include "gettext.h"
19 #include "lyxtext.h"
20
21 #include "support/lstrings.h"
22 #include "support/LOstream.h"
23 #include "support/lstrings.h" //frontStrip, strip
24
25 using std::ostream;
26 using std::vector;
27 using std::pair;
28
29
30 InsetLabel::InsetLabel(InsetCommandParams const & p, bool)
31         : InsetCommand(p)
32 {}
33
34
35 InsetLabel::~InsetLabel()
36 {
37         InsetCommandMailer mailer("label", *this);
38         mailer.hideDialog();
39 }
40
41
42 vector<string> const InsetLabel::getLabelList() const
43 {
44         return vector<string>(1, getContents());
45 }
46
47
48 void InsetLabel::edit(BufferView * bv, int, int, mouse_button::state)
49 {
50         InsetCommandMailer mailer("label", *this);
51         mailer.showDialog(bv);
52 }
53
54
55 dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd)
56 {
57         Inset::RESULT result = UNDISPATCHED;
58
59         switch (cmd.action) {
60         case LFUN_INSET_MODIFY: {
61                 InsetCommandParams p;
62                 InsetCommandMailer::string2params(cmd.argument, p);
63                 if (p.getCmdName().empty())
64                         return UNDISPATCHED;
65
66                 bool clean = true;
67                 if (view() && p.getContents() != params().getContents()) {
68                         clean = view()->ChangeRefsIfUnique(params().getContents(),
69                                                            p.getContents());
70                 }
71
72                 setParams(p);
73                 cmd.view()->updateInset(this);
74                 result = DISPATCHED;
75         }
76         break;
77
78         default:
79                 result = InsetCommand::localDispatch(cmd);
80         }
81
82         return result;
83 }
84
85
86 void InsetLabel::edit(BufferView * bv, bool)
87 {
88         edit(bv, 0, 0, mouse_button::none);
89 }
90
91
92 int InsetLabel::latex(Buffer const *, ostream & os,
93                       bool /*fragile*/, bool /*fs*/) const
94 {
95         os << escape(getCommand());
96         return 0;
97 }
98
99
100 int InsetLabel::ascii(Buffer const *, ostream & os, int) const
101 {
102         os << '<' << getContents()  << '>';
103         return 0;
104 }
105
106
107 int InsetLabel::linuxdoc(Buffer const *, ostream & os) const
108 {
109         os << "<label id=\"" << getContents() << "\" >";
110         return 0;
111 }
112
113
114 int InsetLabel::docbook(Buffer const *, ostream & os, bool) const
115 {
116         os << "<anchor id=\"" << getContents() << "\">";
117         return 0;
118 }