]> git.lyx.org Git - lyx.git/blob - src/insets/insetlabel.C
Re-add the RasterImage template.
[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 #include "insetlabel.h"
14
15 #include "BufferView.h"
16 #include "funcrequest.h"
17
18 #include "support/lstrings.h"
19
20 using lyx::support::escape;
21
22 using std::ostream;
23
24
25 InsetLabel::InsetLabel(InsetCommandParams const & p)
26         : InsetCommand(p)
27 {}
28
29
30 InsetLabel::~InsetLabel()
31 {
32         InsetCommandMailer("label", *this).hideDialog();
33 }
34
35
36 void InsetLabel::getLabelList(Buffer const &, std::vector<string> & list) const
37 {
38         list.push_back(getContents());
39 }
40
41
42 dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd)
43 {
44         switch (cmd.action) {
45
46         case LFUN_INSET_EDIT:
47                 InsetCommandMailer("label", *this).showDialog(cmd.view());
48                 return DISPATCHED;
49                 break;
50
51         case LFUN_INSET_MODIFY: {
52                 InsetCommandParams p;
53                 InsetCommandMailer::string2params(cmd.argument, p);
54                 if (p.getCmdName().empty())
55                         return UNDISPATCHED;
56
57                 bool clean = true;
58                 if (view() && p.getContents() != params().getContents()) {
59                         clean = view()->ChangeRefsIfUnique(params().getContents(),
60                                                            p.getContents());
61                 }
62
63                 setParams(p);
64                 cmd.view()->updateInset(this);
65                 return DISPATCHED;
66         }
67
68         default:
69                 return InsetCommand::localDispatch(cmd);
70         }
71 }
72
73
74 int InsetLabel::latex(Buffer const &, ostream & os,
75                       LatexRunParams const &) const
76 {
77         os << escape(getCommand());
78         return 0;
79 }
80
81
82 int InsetLabel::ascii(Buffer const &, ostream & os, int) const
83 {
84         os << '<' << getContents()  << '>';
85         return 0;
86 }
87
88
89 int InsetLabel::linuxdoc(Buffer const &, ostream & os) const
90 {
91         os << "<label id=\"" << getContents() << "\" >";
92         return 0;
93 }
94
95
96 int InsetLabel::docbook(Buffer const &, ostream & os, bool) const
97 {
98         os << "<anchor id=\"" << getContents() << "\">";
99         return 0;
100 }