X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetlabel.C;h=66963db35005b0d03398cbd7e78de312fdfb6f78;hb=6ce86e2bfe0a403e0e811b66fdddb2d56cfe0f83;hp=0a2a94f0447a72394fff9b18029200533f47beff;hpb=def72111a5ac739cf8c5377a67adeee64c37e1ab;p=lyx.git diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index 0a2a94f044..66963db350 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -1,110 +1,118 @@ -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-1999 The LyX Team. +/** + * \file insetlabel.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * ====================================================== */ + * \author Lars Gullik Bjønnes + * + * Full author contact details are available in file CREDITS + */ #include -#ifdef __GNUG__ -#pragma implementation -#endif #include "insetlabel.h" +#include "buffer.h" +#include "BufferView.h" +#include "funcrequest.h" +#include "gettext.h" +#include "lyxtext.h" -/* Label. Used to insert a label automatically */ +#include "support/lstrings.h" +#include "support/LOstream.h" +#include "support/lstrings.h" //frontStrip, strip +using std::ostream; +using std::vector; +using std::pair; -InsetLabel::InsetLabel(string const & cmd) -{ - scanCommand(cmd); -} +InsetLabel::InsetLabel(InsetCommandParams const & p, bool) + : InsetCommand(p) +{} -Inset * InsetLabel::Clone() const + +InsetLabel::~InsetLabel() { - return new InsetLabel(getCommand()); + InsetCommandMailer mailer("label", *this); + mailer.hideDialog(); } -int InsetLabel::GetNumberOfLabels() const +vector const InsetLabel::getLabelList() const { - return 1; + return vector(1, getContents()); } -string InsetLabel::getLabel(int) const +void InsetLabel::edit(BufferView * bv, int, int, mouse_button::state) { - return contents; + InsetCommandMailer mailer("label", *this); + mailer.showDialog(bv); } -int InsetLabel::Latex(ostream & os, signed char /*fragile*/) const +dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd) { - os << escape(getCommand()); - return 0; + Inset::RESULT result = UNDISPATCHED; + + switch (cmd.action) { + case LFUN_INSET_MODIFY: { + InsetCommandParams p; + InsetCommandMailer::string2params(cmd.argument, p); + if (p.getCmdName().empty()) + return UNDISPATCHED; + + bool clean = true; + if (view() && p.getContents() != params().getContents()) { + clean = view()->ChangeRefsIfUnique(params().getContents(), + p.getContents()); + } + + setParams(p); + cmd.view()->updateInset(this); + result = DISPATCHED; + } + break; + + default: + result = InsetCommand::localDispatch(cmd); + } + + return result; } -#ifndef USE_OSTREAM_ONLY -int InsetLabel::Latex(string & file, signed char /*fragile*/) const +void InsetLabel::edit(BufferView * bv, bool) { - file += escape(getCommand()); - return 0; + edit(bv, 0, 0, mouse_button::none); } -int InsetLabel::Linuxdoc(string & file) const +int InsetLabel::latex(Buffer const *, ostream & os, + bool /*fragile*/, bool /*fs*/) const { - file += "