X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetlabel.C;h=66963db35005b0d03398cbd7e78de312fdfb6f78;hb=6ce86e2bfe0a403e0e811b66fdddb2d56cfe0f83;hp=8e0e8c8f13dfa850742b5426ad1c88b32337118f;hpb=27de1486ca34aaad446adb798d71a77d6f6304da;p=lyx.git diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index 8e0e8c8f13..66963db350 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -1,102 +1,118 @@ -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright (C) 1995 Matthias Ettrich - * Copyright (C) 1995-1998 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" -// $Id: insetlabel.C,v 1.1 1999/09/27 18:44:39 larsbj Exp $ +#include "support/lstrings.h" +#include "support/LOstream.h" +#include "support/lstrings.h" //frontStrip, strip -#if !defined(lint) && !defined(WITH_WARNINGS) -static char vcid[] = "$Id: insetlabel.C,v 1.1 1999/09/27 18:44:39 larsbj Exp $"; -#endif /* lint */ +using std::ostream; +using std::vector; +using std::pair; -/* Label. Used to insert a label automatically */ - -InsetLabel::InsetLabel(LString const & cmd) -{ - scanCommand(cmd); -} +InsetLabel::InsetLabel(InsetCommandParams const & p, bool) + : InsetCommand(p) +{} InsetLabel::~InsetLabel() { + InsetCommandMailer mailer("label", *this); + mailer.hideDialog(); } -Inset* InsetLabel::Clone() +vector const InsetLabel::getLabelList() const { - InsetLabel *result = new InsetLabel(getCommand()); - return result; + return vector(1, getContents()); } -int InsetLabel::GetNumberOfLabels() const +void InsetLabel::edit(BufferView * bv, int, int, mouse_button::state) { - return 1; + InsetCommandMailer mailer("label", *this); + mailer.showDialog(bv); } -LString InsetLabel::getLabel(int) const +dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd) { - return contents; + 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; } -int InsetLabel::Latex(FILE *file, signed char /*fragile*/) + +void InsetLabel::edit(BufferView * bv, bool) { - fprintf(file, "%s", escape(getCommand()).c_str()); - return 0; + edit(bv, 0, 0, mouse_button::none); } -int InsetLabel::Latex(LString &file, signed char /*fragile*/) +int InsetLabel::latex(Buffer const *, ostream & os, + bool /*fragile*/, bool /*fs*/) const { - file += escape(getCommand()); + os << escape(getCommand()); return 0; } -int InsetLabel::Linuxdoc(LString &file) +int InsetLabel::ascii(Buffer const *, ostream & os, int) const { - file += "