]> git.lyx.org Git - lyx.git/blob - src/insets/insetlabel.C
Enable convertDefault.sh to run even if its executable bit is not set.
[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 namespace lyx::support;
26
27 using std::ostream;
28 using std::vector;
29 using std::pair;
30
31
32 InsetLabel::InsetLabel(InsetCommandParams const & p)
33         : InsetCommand(p)
34 {}
35
36
37 InsetLabel::~InsetLabel()
38 {
39         InsetCommandMailer("label", *this).hideDialog();
40 }
41
42
43 void InsetLabel::getLabelList(std::vector<string> & list) const
44 {
45         list.push_back(getContents());
46 }
47
48
49 dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd)
50 {
51         switch (cmd.action) {
52
53         case LFUN_INSET_EDIT:
54                 InsetCommandMailer("label", *this).showDialog(cmd.view());
55                 return DISPATCHED;
56                 break;
57
58         case LFUN_INSET_MODIFY: {
59                 InsetCommandParams p;
60                 InsetCommandMailer::string2params(cmd.argument, p);
61                 if (p.getCmdName().empty())
62                         return UNDISPATCHED;
63
64                 bool clean = true;
65                 if (view() && p.getContents() != params().getContents()) {
66                         clean = view()->ChangeRefsIfUnique(params().getContents(),
67                                                            p.getContents());
68                 }
69
70                 setParams(p);
71                 cmd.view()->updateInset(this);
72                 return DISPATCHED;
73         }
74
75         default:
76                 return InsetCommand::localDispatch(cmd);
77         }
78 }
79
80
81 int InsetLabel::latex(Buffer const &, ostream & os,
82                       LatexRunParams const &) const
83 {
84         os << escape(getCommand());
85         return 0;
86 }
87
88
89 int InsetLabel::ascii(Buffer const &, ostream & os, int) const
90 {
91         os << '<' << getContents()  << '>';
92         return 0;
93 }
94
95
96 int InsetLabel::linuxdoc(Buffer const &, ostream & os) const
97 {
98         os << "<label id=\"" << getContents() << "\" >";
99         return 0;
100 }
101
102
103 int InsetLabel::docbook(Buffer const &, ostream & os, bool) const
104 {
105         os << "<anchor id=\"" << getContents() << "\">";
106         return 0;
107 }