mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Change how InsetBibTeX does this check.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20996 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
404572d97d
commit
26fd6a1420
@ -26,6 +26,7 @@
|
||||
|
||||
#include "frontends/alert.h"
|
||||
|
||||
#include "support/ExceptionMessage.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxlib.h"
|
||||
@ -90,12 +91,22 @@ void InsetBibtex::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
|
||||
case LFUN_INSET_MODIFY: {
|
||||
InsetCommandParams p("bibtex");
|
||||
InsetCommandMailer::string2params("bibtex", to_utf8(cmd.argument()), p);
|
||||
if (!p.getCmdName().empty()) {
|
||||
setParams(p);
|
||||
cur.buffer().updateBibfilesCache();
|
||||
} else
|
||||
cur.noUpdate();
|
||||
try {
|
||||
if (!InsetCommandMailer::string2params("bibtex",
|
||||
to_utf8(cmd.argument()), p)) {
|
||||
cur.noUpdate();
|
||||
break;
|
||||
}
|
||||
} catch (support::ExceptionMessage const & message) {
|
||||
if (message.type_ == support::WarningException) {
|
||||
Alert::warning(message.title_, message.details_);
|
||||
cur.noUpdate();
|
||||
} else
|
||||
throw message;
|
||||
break;
|
||||
}
|
||||
setParams(p);
|
||||
cur.buffer().updateBibfilesCache();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -187,12 +187,12 @@ string const InsetCommandMailer::inset2string(Buffer const &) const
|
||||
}
|
||||
|
||||
|
||||
void InsetCommandMailer::string2params(
|
||||
bool InsetCommandMailer::string2params(
|
||||
string const & name, string const & in, InsetCommandParams & params)
|
||||
{
|
||||
params.clear();
|
||||
if (in.empty())
|
||||
return;
|
||||
return false;
|
||||
|
||||
istringstream data(in);
|
||||
Lexer lex(0,0);
|
||||
@ -200,17 +200,22 @@ void InsetCommandMailer::string2params(
|
||||
|
||||
string n;
|
||||
lex >> n;
|
||||
if (!lex || n != name)
|
||||
return print_mailer_error("InsetCommandMailer", in, 1, name);
|
||||
if (!lex || n != name) {
|
||||
print_mailer_error("InsetCommandMailer", in, 1, name);
|
||||
return false;
|
||||
}
|
||||
|
||||
// This is part of the inset proper that is usually swallowed
|
||||
// by Text::readInset
|
||||
string id;
|
||||
lex >> id;
|
||||
if (!lex || id != "CommandInset")
|
||||
return print_mailer_error("InsetCommandMailer", in, 2, "LatexCommand");
|
||||
if (!lex || id != "CommandInset") {
|
||||
print_mailer_error("InsetCommandMailer", in, 2, "LatexCommand");
|
||||
return false;
|
||||
}
|
||||
|
||||
params.read(lex);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -136,8 +136,8 @@ public:
|
||||
virtual std::string const & name() const { return name_; }
|
||||
///
|
||||
virtual std::string const inset2string(Buffer const &) const;
|
||||
///
|
||||
static void string2params(std::string const &, std::string const & name,
|
||||
/// returns true if params are successfully read
|
||||
static bool string2params(std::string const &, std::string const & name,
|
||||
InsetCommandParams &);
|
||||
///
|
||||
static std::string const params2string(std::string const & name,
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
explicit InsetCommandParams(std::string const & insetType,
|
||||
std::string const & cmdName);
|
||||
///
|
||||
std::string insetType() { return insetType_; }
|
||||
std::string insetType() const { return insetType_; }
|
||||
///
|
||||
void read(Lexer &);
|
||||
/// Parse the command
|
||||
|
Loading…
Reference in New Issue
Block a user