mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
EmbeddedFile::enable() should take a reference instead of a pointer.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24055 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
534b81a5c1
commit
66a94937c3
@ -112,7 +112,7 @@ void EmbeddedFile::setEmbed(bool embed)
|
||||
}
|
||||
|
||||
|
||||
void EmbeddedFile::enable(bool enabled, Buffer const * buf, bool updateFile)
|
||||
void EmbeddedFile::enable(bool enabled, Buffer const & buf, bool updateFile)
|
||||
{
|
||||
// This function will be called when
|
||||
// 1. through EmbeddedFiles::enable() when a file is read. Files
|
||||
@ -126,7 +126,7 @@ void EmbeddedFile::enable(bool enabled, Buffer const * buf, bool updateFile)
|
||||
<< (updateFile ? " (update file)." : " (no update)."));
|
||||
|
||||
if (enabled) {
|
||||
temp_path_ = buf->temppath();
|
||||
temp_path_ = buf.temppath();
|
||||
if (!suffixIs(temp_path_, '/'))
|
||||
temp_path_ += '/';
|
||||
if (embedded() && updateFile)
|
||||
@ -254,11 +254,11 @@ bool EmbeddedFile::updateFromExternalFile() const
|
||||
}
|
||||
|
||||
|
||||
EmbeddedFile EmbeddedFile::copyTo(Buffer const * buf)
|
||||
EmbeddedFile EmbeddedFile::copyTo(Buffer const & buf)
|
||||
{
|
||||
EmbeddedFile file = EmbeddedFile(absFilename(), buf->filePath());
|
||||
EmbeddedFile file = EmbeddedFile(absFilename(), buf.filePath());
|
||||
file.setEmbed(embedded());
|
||||
file.enable(buf->embedded(), buf, false);
|
||||
file.enable(buf.embedded(), buf, false);
|
||||
|
||||
// use external file.
|
||||
if (!embedded())
|
||||
@ -459,7 +459,7 @@ void EmbeddedFileList::enable(bool enabled, Buffer & buffer, bool updateFile)
|
||||
iterator it_end = end();
|
||||
// an exception may be thrown
|
||||
for (; it != it_end; ++it) {
|
||||
it->enable(enabled, &buffer, updateFile);
|
||||
it->enable(enabled, buffer, updateFile);
|
||||
if (it->embedded())
|
||||
++count_embedded;
|
||||
else
|
||||
@ -570,7 +570,7 @@ void EmbeddedFileList::validate(Buffer const & buffer)
|
||||
for (; e_it != e_end; ++e_it) {
|
||||
EmbeddedFile file = EmbeddedFile(*e_it, buffer.filePath());
|
||||
// do not update from external file
|
||||
file.enable(true, &buffer, false);
|
||||
file.enable(true, buffer, false);
|
||||
// but we do need to check file existence.
|
||||
if (!FileName(file.embeddedFile()).exists())
|
||||
throw ExceptionMessage(ErrorException, _("Failed to open file"),
|
||||
@ -594,7 +594,7 @@ void EmbeddedFileList::update(Buffer const & buffer)
|
||||
for (; it != it_end; ++it) {
|
||||
EmbeddedFile file = EmbeddedFile(*it, buffer.filePath());
|
||||
file.setEmbed(true);
|
||||
file.enable(buffer.embedded(), &buffer, false);
|
||||
file.enable(buffer.embedded(), buffer, false);
|
||||
insert(end(), file);
|
||||
}
|
||||
}
|
||||
|
@ -153,14 +153,14 @@ public:
|
||||
*/
|
||||
bool isEnabled() const { return !temp_path_.empty(); }
|
||||
/// enable embedding of this file
|
||||
void enable(bool enabled, Buffer const * buf, bool updateFile);
|
||||
void enable(bool enabled, Buffer const & buf, bool updateFile);
|
||||
|
||||
/// extract file, does not change embedding status
|
||||
bool extract() const;
|
||||
/// update embedded file from external file, does not change embedding status
|
||||
bool updateFromExternalFile() const;
|
||||
/// copy an embedded file to another buffer
|
||||
EmbeddedFile copyTo(Buffer const * buf);
|
||||
EmbeddedFile copyTo(Buffer const & buf);
|
||||
///
|
||||
/// After the embedding status is changed, update all insets related
|
||||
/// to this file item. For example, a graphic inset may need to monitor
|
||||
|
@ -643,7 +643,7 @@ void GuiExternal::applyView()
|
||||
EmbeddedFile file(fromqstr(fileED->text()), buf.filePath());
|
||||
file.setEmbed(embedCB->checkState() == Qt::Checked);
|
||||
// move file around if needed, an exception may be raised.
|
||||
file.enable(buf.embedded(), &buf, true);
|
||||
file.enable(buf.embedded(), buf, true);
|
||||
// if things are OK..., embed params_.filename
|
||||
params_.filename.setEmbed(file.embedded());
|
||||
} catch (ExceptionMessage const & message) {
|
||||
|
@ -578,7 +578,7 @@ void GuiGraphics::applyView()
|
||||
EmbeddedFile file(fromqstr(filename->text()), buf.filePath());
|
||||
file.setEmbed(embedCB->checkState() == Qt::Checked);
|
||||
// move file around if needed, an exception may be raised.
|
||||
file.enable(buf.embedded(), &buf, true);
|
||||
file.enable(buf.embedded(), buf, true);
|
||||
// if things are OK..., embed igp.filename
|
||||
igp.filename.setEmbed(file.embedded());
|
||||
} catch (ExceptionMessage const & message) {
|
||||
|
@ -250,7 +250,7 @@ void GuiInclude::applyView()
|
||||
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);
|
||||
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) {
|
||||
|
@ -60,7 +60,7 @@ void InsetBibtex::setBuffer(Buffer & buffer)
|
||||
EmbeddedFileList::iterator en = bibfiles_.end();
|
||||
for (; it != en; ++it) {
|
||||
try {
|
||||
*it = it->copyTo(&buffer);
|
||||
*it = it->copyTo(buffer);
|
||||
} catch (ExceptionMessage const & message) {
|
||||
Alert::error(message.title_, message.details_);
|
||||
// failed to embed
|
||||
@ -781,7 +781,7 @@ void InsetBibtex::updateBibFiles() const
|
||||
efp->setEmbed(new_status);
|
||||
try {
|
||||
// copy file if embedding status changed.
|
||||
efp->enable(buffer().embedded(), &buffer(), old_status != new_status);
|
||||
efp->enable(buffer().embedded(), buffer(), old_status != new_status);
|
||||
} catch (ExceptionMessage const & message) {
|
||||
Alert::error(message.title_, message.details_);
|
||||
// failed to change embeddeing status
|
||||
@ -792,7 +792,7 @@ void InsetBibtex::updateBibFiles() const
|
||||
EmbeddedFile file(bib.absFilename(), buffer().filePath());
|
||||
file.setEmbed(!embfile.empty());
|
||||
try {
|
||||
file.enable(buffer().embedded(), &buffer(), true);
|
||||
file.enable(buffer().embedded(), buffer(), true);
|
||||
} catch (ExceptionMessage const & message) {
|
||||
Alert::error(message.title_, message.details_);
|
||||
// failed to embed
|
||||
|
@ -434,7 +434,7 @@ void InsetExternal::setBuffer(Buffer & buffer)
|
||||
try {
|
||||
// a file may not be copied successfully when, e.g. buffer_
|
||||
// has already been closed.
|
||||
params_.filename = params_.filename.copyTo(&buffer);
|
||||
params_.filename = params_.filename.copyTo(buffer);
|
||||
} catch (ExceptionMessage const & message) {
|
||||
Alert::error(message.title_, message.details_);
|
||||
// failed to embed
|
||||
@ -742,7 +742,7 @@ void InsetExternal::read(Lexer & lex)
|
||||
InsetExternalParams params;
|
||||
if (params.read(buffer(), lex)) {
|
||||
// exception handling is not needed as long as embedded files are in place.
|
||||
params.filename.enable(buffer().embedded(), &buffer(), false);
|
||||
params.filename.enable(buffer().embedded(), buffer(), false);
|
||||
setParams(params);
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ void InsetGraphics::setBuffer(Buffer & buffer)
|
||||
try {
|
||||
// a file may not be copied successfully when, e.g. buffer_
|
||||
// has already been closed.
|
||||
params_.filename = params_.filename.copyTo(&buffer);
|
||||
params_.filename = params_.filename.copyTo(buffer);
|
||||
} catch (ExceptionMessage const & message) {
|
||||
Alert::error(message.title_, message.details_);
|
||||
// failed to embed
|
||||
@ -308,7 +308,7 @@ void InsetGraphics::read(Lexer & lex)
|
||||
else
|
||||
LYXERR(Debug::GRAPHICS, "Not a Graphics inset!");
|
||||
|
||||
params_.filename.enable(buffer().embedded(), &buffer(), false);
|
||||
params_.filename.enable(buffer().embedded(), buffer(), false);
|
||||
graphic_->update(params().as_grfxParams());
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ EmbeddedFile const includedFilename(Buffer const & buffer,
|
||||
onlyPath(parentFilename(buffer)));
|
||||
file.setEmbed(!params["embed"].empty());
|
||||
file.setInzipName(to_utf8(params["embed"]));
|
||||
file.enable(buffer.embedded(), &buffer, false);
|
||||
file.enable(buffer.embedded(), buffer, false);
|
||||
return file;
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ void InsetInclude::setBuffer(Buffer & buffer)
|
||||
if (buffer_) {
|
||||
try {
|
||||
EmbeddedFile file_from = includedFilename(*buffer_, params());
|
||||
EmbeddedFile file_to = file_from.copyTo(&buffer);
|
||||
EmbeddedFile file_to = file_from.copyTo(buffer);
|
||||
if (file_to.embedded())
|
||||
setParam("embed", from_utf8(file_to.inzipName()));
|
||||
} catch (ExceptionMessage const & message) {
|
||||
|
Loading…
Reference in New Issue
Block a user