1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
14 #pragma implementation
17 #include "insetlabel.h"
18 #include "support/LOstream.h"
19 #include "frontends/Alert.h"
20 #include "support/lstrings.h" //frontStrip, strip
24 #include "BufferView.h"
25 #include "support/lstrings.h"
31 /* Label. Used to insert a label automatically */
34 InsetLabel::InsetLabel(InsetCommandParams const & p, bool)
39 vector<string> const InsetLabel::getLabelList() const
41 return vector<string>(1, getContents());
45 void InsetLabel::edit(BufferView * bv, int, int, mouse_button::state)
47 pair<bool, string> result = Alert::askForText(_("Enter label:"), getContents());
49 string new_contents = trim(result.second);
50 if (!new_contents.empty() &&
51 getContents() != new_contents) {
52 bv->buffer()->markDirty();
53 bool flag = bv->ChangeRefsIfUnique(getContents(),
55 setContents(new_contents);
57 bv->text->redoParagraph(bv);
62 bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
64 bv->updateInset(this, !flag);
71 void InsetLabel::edit(BufferView * bv, bool)
73 edit(bv, 0, 0, mouse_button::none);
77 int InsetLabel::latex(Buffer const *, ostream & os,
78 bool /*fragile*/, bool /*fs*/) const
80 os << escape(getCommand());
84 int InsetLabel::ascii(Buffer const *, ostream & os, int) const
86 os << "<" << getContents() << ">";
91 int InsetLabel::linuxdoc(Buffer const *, ostream & os) const
93 os << "<label id=\"" << getContents() << "\" >";
98 int InsetLabel::docbook(Buffer const *, ostream & os, bool) const
100 os << "<anchor id=\"" << getContents() << "\">";