2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file insetlabel.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "insetlabel.h"
|
2000-05-19 16:46:01 +00:00
|
|
|
|
#include "buffer.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "BufferView.h"
|
2003-02-27 16:24:14 +00:00
|
|
|
|
#include "funcrequest.h"
|
|
|
|
|
#include "gettext.h"
|
|
|
|
|
#include "lyxtext.h"
|
|
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2003-02-27 16:24:14 +00:00
|
|
|
|
#include "support/LOstream.h"
|
|
|
|
|
#include "support/lstrings.h" //frontStrip, strip
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
|
using std::ostream;
|
2000-05-19 16:46:01 +00:00
|
|
|
|
using std::vector;
|
|
|
|
|
using std::pair;
|
2000-04-04 00:19:15 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
|
InsetLabel::InsetLabel(InsetCommandParams const & p, bool)
|
2000-08-04 13:12:30 +00:00
|
|
|
|
: InsetCommand(p)
|
|
|
|
|
{}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2003-02-27 16:24:14 +00:00
|
|
|
|
InsetLabel::~InsetLabel()
|
|
|
|
|
{
|
|
|
|
|
InsetCommandMailer mailer("label", *this);
|
|
|
|
|
mailer.hideDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
vector<string> const InsetLabel::getLabelList() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-04-04 23:00:42 +00:00
|
|
|
|
return vector<string>(1, getContents());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-27 16:24:14 +00:00
|
|
|
|
void InsetLabel::edit(BufferView *, int, int, mouse_button::state)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-02-27 16:24:14 +00:00
|
|
|
|
InsetCommandMailer mailer("label", *this);
|
|
|
|
|
mailer.showDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd)
|
|
|
|
|
{
|
2003-03-04 14:31:04 +00:00
|
|
|
|
if (cmd.action != LFUN_INSET_MODIFY)
|
2003-02-27 16:24:14 +00:00
|
|
|
|
return UNDISPATCHED;
|
|
|
|
|
|
|
|
|
|
InsetCommandParams p;
|
|
|
|
|
InsetCommandMailer::string2params(cmd.argument, p);
|
|
|
|
|
if (p.getCmdName().empty())
|
|
|
|
|
return UNDISPATCHED;
|
|
|
|
|
|
|
|
|
|
bool clean = true;
|
|
|
|
|
if (view() && p.getContents() != params().getContents()) {
|
2003-03-04 14:31:04 +00:00
|
|
|
|
clean = view()->ChangeRefsIfUnique(params().getContents(),
|
|
|
|
|
p.getContents());
|
2000-05-19 16:46:01 +00:00
|
|
|
|
}
|
2003-02-27 16:24:14 +00:00
|
|
|
|
|
|
|
|
|
setParams(p);
|
|
|
|
|
if (view())
|
|
|
|
|
view()->updateInset(this, !clean);
|
|
|
|
|
|
|
|
|
|
return DISPATCHED;
|
|
|
|
|
// if (result.first) {
|
|
|
|
|
// string new_contents = trim(result.second);
|
|
|
|
|
// if (!new_contents.empty() &&
|
|
|
|
|
// getContents() != new_contents) {
|
|
|
|
|
// bv->buffer()->markDirty();
|
|
|
|
|
// bool flag = bv->ChangeRefsIfUnique(getContents(),
|
|
|
|
|
// new_contents);
|
|
|
|
|
// setContents(new_contents);
|
|
|
|
|
// bv->updateInset(this, !flag);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2000-05-19 16:46:01 +00:00
|
|
|
|
}
|
1999-12-07 00:44:53 +00:00
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
2001-07-20 14:18:48 +00:00
|
|
|
|
void InsetLabel::edit(BufferView * bv, bool)
|
|
|
|
|
{
|
2002-05-26 17:33:14 +00:00
|
|
|
|
edit(bv, 0, 0, mouse_button::none);
|
2001-07-20 14:18:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
int InsetLabel::latex(Buffer const *, ostream & os,
|
2000-04-19 01:42:55 +00:00
|
|
|
|
bool /*fragile*/, bool /*fs*/) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << escape(getCommand());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
int InsetLabel::ascii(Buffer const *, ostream & os, int) const
|
2000-04-24 20:58:23 +00:00
|
|
|
|
{
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '<' << getContents() << '>';
|
2000-04-24 20:58:23 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
int InsetLabel::linuxdoc(Buffer const *, ostream & os) const
|
2000-03-06 02:42:40 +00:00
|
|
|
|
{
|
|
|
|
|
os << "<label id=\"" << getContents() << "\" >";
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
int InsetLabel::docbook(Buffer const *, ostream & os, bool) const
|
2000-03-06 02:42:40 +00:00
|
|
|
|
{
|
2002-04-03 17:44:05 +00:00
|
|
|
|
os << "<anchor id=\"" << getContents() << "\">";
|
2000-03-06 02:42:40 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|