3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * Full author contact details are available in file CREDITS
14 #include "insetlabel.h"
15 #include "support/LOstream.h"
16 #include "frontends/Alert.h"
17 #include "support/lstrings.h" //frontStrip, strip
21 #include "BufferView.h"
22 #include "support/lstrings.h"
28 /* Label. Used to insert a label automatically */
31 InsetLabel::InsetLabel(InsetCommandParams const & p, bool)
36 vector<string> const InsetLabel::getLabelList() const
38 return vector<string>(1, getContents());
42 void InsetLabel::edit(BufferView * bv, int, int, mouse_button::state)
44 pair<bool, string> result = Alert::askForText(_("Enter label:"), getContents());
46 string new_contents = trim(result.second);
47 if (!new_contents.empty() &&
48 getContents() != new_contents) {
49 bv->buffer()->markDirty();
50 bool flag = bv->ChangeRefsIfUnique(getContents(),
52 setContents(new_contents);
54 bv->text->redoParagraph(bv);
59 bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
61 bv->updateInset(this, !flag);
68 void InsetLabel::edit(BufferView * bv, bool)
70 edit(bv, 0, 0, mouse_button::none);
74 int InsetLabel::latex(Buffer const *, ostream & os,
75 bool /*fragile*/, bool /*fs*/) const
77 os << escape(getCommand());
81 int InsetLabel::ascii(Buffer const *, ostream & os, int) const
83 os << '<' << getContents() << '>';
88 int InsetLabel::linuxdoc(Buffer const *, ostream & os) const
90 os << "<label id=\"" << getContents() << "\" >";
95 int InsetLabel::docbook(Buffer const *, ostream & os, bool) const
97 os << "<anchor id=\"" << getContents() << "\">";