]> git.lyx.org Git - lyx.git/blob - src/insets/insetlabel.C
rename Inset to InsetOld
[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(InsetCommandParams const & p, bool)
38 //      : InsetCommand(p, false)
39 // {}
40
41
42 InsetLabel::~InsetLabel()
43 {
44         InsetCommandMailer("label", *this).hideDialog();
45 }
46
47
48 void InsetLabel::getLabelList(std::vector<string> & list) const
49 {
50         list.push_back(getContents());
51 }
52
53
54 dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd)
55 {
56         InsetOld::RESULT result = UNDISPATCHED;
57
58         switch (cmd.action) {
59
60         case LFUN_INSET_EDIT:
61                 InsetCommandMailer("label", *this).showDialog(cmd.view());
62                 result = DISPATCHED;
63                 break;
64
65         case LFUN_INSET_MODIFY: {
66                 InsetCommandParams p;
67                 InsetCommandMailer::string2params(cmd.argument, p);
68                 if (p.getCmdName().empty())
69                         return UNDISPATCHED;
70
71                 bool clean = true;
72                 if (view() && p.getContents() != params().getContents()) {
73                         clean = view()->ChangeRefsIfUnique(params().getContents(),
74                                                            p.getContents());
75                 }
76
77                 setParams(p);
78                 cmd.view()->updateInset(this);
79                 result = DISPATCHED;
80         }
81         break;
82
83         default:
84                 result = InsetCommand::localDispatch(cmd);
85         }
86
87         return result;
88 }
89
90
91 int InsetLabel::latex(Buffer const *, ostream & os,
92                       LatexRunParams const &) const
93 {
94         os << escape(getCommand());
95         return 0;
96 }
97
98
99 int InsetLabel::ascii(Buffer const *, ostream & os, int) const
100 {
101         os << '<' << getContents()  << '>';
102         return 0;
103 }
104
105
106 int InsetLabel::linuxdoc(Buffer const *, ostream & os) const
107 {
108         os << "<label id=\"" << getContents() << "\" >";
109         return 0;
110 }
111
112
113 int InsetLabel::docbook(Buffer const *, ostream & os, bool) const
114 {
115         os << "<anchor id=\"" << getContents() << "\">";
116         return 0;
117 }