+ InsetCommandParams p(BIBTEX_CODE);
+ try {
+ if (!InsetCommandMailer::string2params("bibtex",
+ to_utf8(cmd.argument()), p)) {
+ cur.noUpdate();
+ break;
+ }
+ } catch (ExceptionMessage const & message) {
+ if (message.type_ == WarningException) {
+ Alert::warning(message.title_, message.details_);
+ cur.noUpdate();
+ } else
+ throw message;
+ break;
+ }
+ //
+ InsetCommandParams orig = params();
+ // returned "embed" is composed of "true" or "false", which needs to be adjusted
+ string tmp;
+ string emb;
+
+ string newBibfiles;
+ string newEmbedStatus;
+
+ string bibfiles = to_utf8(p["bibfiles"]);
+ string embedStatus = to_utf8(p["embed"]);
+
+ bibfiles = split(bibfiles, tmp, ',');
+ embedStatus = split(embedStatus, emb, ',');
+ while (!tmp.empty()) {
+ EmbeddedFile file(changeExtension(tmp, "bib"), buffer().filePath());
+ if (!newBibfiles.empty())
+ newBibfiles += ",";
+ newBibfiles += tmp;
+ if (!newEmbedStatus.empty())
+ newEmbedStatus += ",";
+ if (emb == "true")
+ newEmbedStatus += file.inzipName();
+ // Get next file name
+ bibfiles = split(bibfiles, tmp, ',');
+ embedStatus = split(embedStatus, emb, ',');
+ }
+ LYXERR(Debug::FILES, "Update parameters from " << p["bibfiles"]
+ << " " << p["embed"] << " to " << newBibfiles << " "
+ << newEmbedStatus);
+ p["bibfiles"] = from_utf8(newBibfiles);
+ p["embed"] = from_utf8(newEmbedStatus);
+
+ setParams(p);
+ try {
+ // test parameter and copy files
+ embeddedFiles();
+ } catch (ExceptionMessage const & message) {
+ Alert::error(message.title_, message.details_);
+ // do not set parameter if an error happens
+ setParams(orig);
+ break;
+ }
+ buffer().updateBibfilesCache();