mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
Embedding: prepare params()[embed] in GuiInclude rather than InsetInclude
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23708 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
72c26ac6d1
commit
ded962802e
@ -131,7 +131,9 @@ void EmbeddedFile::enable(bool flag, Buffer const * buf, bool updateFile)
|
||||
if (embedded() && updateFile)
|
||||
updateFromExternalFile();
|
||||
} else {
|
||||
if (embedded() && updateFile)
|
||||
// when a new embeddeed file is created, it is not enabled, and
|
||||
// there is no need to extract.
|
||||
if (enabled() && embedded() && updateFile)
|
||||
extract();
|
||||
temp_path_ = "";
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "GuiInclude.h"
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "EmbeddedFiles.h"
|
||||
#include "Format.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "support/gettext.h"
|
||||
@ -23,8 +24,11 @@
|
||||
#include "qt_helpers.h"
|
||||
#include "LyXRC.h"
|
||||
|
||||
#include "frontends/alert.h"
|
||||
|
||||
#include "support/os.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/ExceptionMessage.h"
|
||||
#include "support/FileFilterList.h"
|
||||
#include "support/filetools.h"
|
||||
|
||||
@ -240,7 +244,19 @@ void GuiInclude::updateContents()
|
||||
void GuiInclude::applyView()
|
||||
{
|
||||
params_["filename"] = from_utf8(internal_path(fromqstr(filenameED->text())));
|
||||
params_["embed"] = embedCB->checkState() == Qt::Checked ? _("true") : _("false");
|
||||
params_["embed"].clear();
|
||||
try {
|
||||
Buffer & buf = buffer();
|
||||
EmbeddedFile file(to_utf8(params_["filename"]), buf.filePath());
|
||||
file.setEmbed(embedCB->checkState() == Qt::Checked);
|
||||
// move file around if needed, an exception may be raised.
|
||||
file.enable(buf.embedded(), &buf, true);
|
||||
// if things are OK..., set params_["embed"]
|
||||
params_["embed"] = file.embedded() ? from_utf8(file.inzipName()) : docstring();
|
||||
} catch (ExceptionMessage const & message) {
|
||||
Alert::error(message.title_, message.details_);
|
||||
// params_["embed"] will be empty if a file is failed to embed
|
||||
}
|
||||
params_.preview(previewCB->isChecked());
|
||||
|
||||
int const item = typeCO->currentIndex();
|
||||
|
@ -47,7 +47,6 @@
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/docstream.h"
|
||||
#include "support/ExceptionMessage.h"
|
||||
#include "support/FileNameList.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/gettext.h"
|
||||
@ -267,24 +266,6 @@ void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
label_->initView();
|
||||
}
|
||||
}
|
||||
try {
|
||||
// the embed parameter passed back from the dialog
|
||||
// is "true" or "false", we need to change it.
|
||||
EmbeddedFile file = EmbeddedFile(to_utf8(p["filename"]),
|
||||
onlyPath(parentFilename(buf)));
|
||||
file.setEmbed(p["embed"] == _("true"));
|
||||
// move file around if needed, an exception may be raised.
|
||||
file.enable(buf.embedded(), &buf, true);
|
||||
// if things are OK..., set p["embed"]
|
||||
if (file.embedded())
|
||||
p["embed"] = from_utf8(file.inzipName());
|
||||
else
|
||||
p["embed"].clear();
|
||||
} catch (ExceptionMessage const & message) {
|
||||
Alert::error(message.title_, message.details_);
|
||||
// do not set parameter if an error happens
|
||||
break;
|
||||
}
|
||||
setParams(p);
|
||||
buffer().updateBibfilesCache();
|
||||
} else
|
||||
|
Loading…
Reference in New Issue
Block a user