From 8a69ffd3bfaa4ab23b281a38b9a65f0a8550c997 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Sun, 20 Apr 2008 03:08:11 +0000 Subject: [PATCH] Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got everything, but this does compile, and it seems to work at least reasonably well. Any problems should of course be reported to the list. For the record, this developer is sorry that the problems with this code were not noticed much earlier. It's not fun to do so much work and then have it all reverted. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24373 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 80 +--- src/Buffer.h | 11 +- src/BufferParams.cpp | 28 +- src/BufferParams.h | 8 +- src/BufferView.cpp | 16 - src/Converter.cpp | 4 +- src/CutAndPaste.cpp | 2 +- src/EmbeddedFiles.cpp | 645 ----------------------------- src/EmbeddedFiles.h | 257 ------------ src/FuncCode.h | 15 +- src/LayoutFile.cpp | 4 - src/LayoutFile.h | 4 +- src/LyXAction.cpp | 8 - src/LyXRC.cpp | 20 +- src/LyXRC.h | 3 - src/Makefile.am | 2 - src/frontends/qt4/GuiBibtex.cpp | 2 +- src/frontends/qt4/GuiDocument.cpp | 10 - src/frontends/qt4/GuiGraphics.cpp | 8 +- src/frontends/qt4/GuiGraphics.h | 1 - src/frontends/qt4/GuiInclude.cpp | 1 + src/frontends/qt4/GuiPrefs.cpp | 4 - src/frontends/qt4/GuiToc.cpp | 2 - src/frontends/qt4/GuiView.cpp | 8 +- src/frontends/qt4/GuiView.h | 2 - src/frontends/qt4/Menus.cpp | 4 +- src/frontends/qt4/ui/PrefUi.ui | 7 - src/graphics/GraphicsParams.cpp | 6 +- src/graphics/GraphicsParams.h | 6 - src/insets/ExternalSupport.cpp | 8 +- src/insets/Inset.h | 8 +- src/insets/InsetBibtex.cpp | 2 +- src/insets/InsetBibtex.h | 2 - src/insets/InsetExternal.cpp | 48 +-- src/insets/InsetExternal.h | 9 +- src/insets/InsetGraphics.cpp | 46 +- src/insets/InsetGraphics.h | 6 - src/insets/InsetGraphicsParams.cpp | 8 +- src/insets/InsetGraphicsParams.h | 7 +- src/insets/InsetInclude.cpp | 6 +- src/insets/RenderGraphic.cpp | 21 +- src/insets/RenderGraphic.h | 1 - 42 files changed, 57 insertions(+), 1283 deletions(-) delete mode 100644 src/EmbeddedFiles.cpp delete mode 100644 src/EmbeddedFiles.h diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 3149aea9ae..b590f3646c 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -25,7 +25,6 @@ #include "Converter.h" #include "Counters.h" #include "DocIterator.h" -#include "EmbeddedFiles.h" #include "Encoding.h" #include "ErrorList.h" #include "Exporter.h" @@ -191,9 +190,6 @@ public: /// Container for all sort of Buffer dependant errors. map errorLists; - /// all embedded files of this buffer - EmbeddedFileList embedded_files; - /// timestamp and checksum used to test if the file has been externally /// modified. (Used to properly enable 'File->Revert to saved', bug 4114). time_t timestamp_; @@ -239,8 +235,7 @@ Buffer::Impl::Impl(Buffer & parent, FileName const & file, bool readonly_) : parent_buffer(0), lyx_clean(true), bak_clean(true), unnamed(false), read_only(readonly_), filename(file), file_fully_loaded(false), toc_backend(&parent), macro_lock(false), - embedded_files(), timestamp_(0), checksum_(0), wa_(0), - undo_(parent) + timestamp_(0), checksum_(0), wa_(0), undo_(parent) { temppath = createBufferTmpDir(); lyxvc.setBuffer(&parent); @@ -367,24 +362,6 @@ TocBackend & Buffer::tocBackend() const } -EmbeddedFileList & Buffer::embeddedFiles() -{ - return d->embedded_files; -} - - -EmbeddedFileList const & Buffer::embeddedFiles() const -{ - return d->embedded_files; -} - - -bool Buffer::embedded() const -{ - return params().embedded; -} - - Undo & Buffer::undo() { return d->undo_; @@ -503,8 +480,7 @@ int Buffer::readHeader(Lexer & lex) LYXERR(Debug::PARSER, "Handling document header token: `" << token << '\''); - string unknown = params().readToken(lex, token, d->filename.onlyPath(), - d->temppath); + string unknown = params().readToken(lex, token, d->filename.onlyPath()); if (!unknown.empty()) { if (unknown[0] != '\\' && token == "\\textclass") { Alert::warning(_("Unknown document class"), @@ -575,22 +551,6 @@ bool Buffer::readDocument(Lexer & lex) // read main text bool const res = text().read(*this, lex, errorList, &(d->inset)); - // Enable embeded files, which will set temp path and move - // inconsistent inzip files if needed. - try { - embeddedFiles().validate(*this); - embeddedFiles().enable(params().embedded, *this, false); - } catch (ExceptionMessage const & message) { - Alert::error(message.title_, message.details_); - Alert::warning(_("Failed to read embedded files"), - _("Due to most likely a bug, LyX failed to locate all embedded " - "file. If you unzip the LyX file, you should be able to see and " - "open content.lyx which is your main text. You may also be able " - "to recover some embedded files. Please report this bug to the " - "lyx-devel mailing list.")); - return false; - } - updateMacros(); updateMacroInstances(); return res; @@ -688,20 +648,7 @@ bool Buffer::readFile(FileName const & filename) // decompress to a temp directory LYXERR(Debug::FILES, filename << " is in zip format. Unzip to " << temppath()); ::unzipToDir(filename.toFilesystemEncoding(), temppath()); - // - FileName lyxfile(addName(temppath(), "content.lyx")); - // if both manifest.txt and file.lyx exist, this is am embedded file - if (lyxfile.exists()) { - // if in bundled format, save checksum of the compressed file, not content.lyx - saveCheckSum(filename); - params().embedded = true; - fname = lyxfile; - } } - // The embedded lyx file can also be compressed, for backward compatibility - format = fname.guessFormatFromContents(); - if (format == "gzip" || format == "zip" || format == "compress") - params().compressed = true; // remove dummy empty par paragraphs().clear(); @@ -888,22 +835,15 @@ bool Buffer::writeFile(FileName const & fname) const bool retval = false; - FileName content; - if (params().embedded) - // first write the .lyx file to the temporary directory - content = FileName(addName(temppath(), "content.lyx")); - else - content = fname; - docstring const str = bformat(_("Saving document %1$s..."), - makeDisplayPath(content.absFilename())); + makeDisplayPath(fname.absFilename())); message(str); if (params().compressed) { - gz::ogzstream ofs(content.toFilesystemEncoding().c_str(), ios::out|ios::trunc); + gz::ogzstream ofs(fname.toFilesystemEncoding().c_str(), ios::out|ios::trunc); retval = ofs && write(ofs); } else { - ofstream ofs(content.toFilesystemEncoding().c_str(), ios::out|ios::trunc); + ofstream ofs(fname.toFilesystemEncoding().c_str(), ios::out|ios::trunc); retval = ofs && write(ofs); } @@ -914,15 +854,6 @@ bool Buffer::writeFile(FileName const & fname) const removeAutosaveFile(d->filename.absFilename()); - if (params().embedded) { - message(str + _(" writing embedded files.")); - // if embedding is enabled, write file.lyx and all the embedded files - // to the zip file fname. - if (!d->embedded_files.writeFile(fname, *this)) { - message(str + _(" could not write embedded files!")); - return false; - } - } saveCheckSum(d->filename); message(str + _(" done.")); @@ -2597,4 +2528,5 @@ void Buffer::bufferErrors(TeXErrors const & terr, ErrorList & errorList) const } } + } // namespace lyx diff --git a/src/Buffer.h b/src/Buffer.h index edafa55a0c..cee8dfaa6c 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -14,6 +14,7 @@ #include "insets/InsetCode.h" +#include "support/FileNameList.h" #include "support/strfwd.h" #include "support/types.h" #include "support/SignalSlot.h" @@ -25,7 +26,6 @@ namespace lyx { class BufferParams; -class EmbeddedFileList; class DocIterator; class ErrorItem; class ErrorList; @@ -404,15 +404,10 @@ public: /// method is const because modifying this backend does not touch /// the document contents. TocBackend & tocBackend() const; - - //@{ - EmbeddedFileList & embeddedFiles(); - EmbeddedFileList const & embeddedFiles() const; - bool embedded() const; - //@} + /// Undo & undo(); - + /// This function is called when the buffer is changed. void changed() const; /// This function is called when the buffer structure is changed. diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 01fbfb0a45..33e8a08963 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -277,7 +277,6 @@ public: AuthorList authorlist; BranchList branchlist; - vector extraEmbeddedFiles; Bullet temp_bullets[4]; Bullet user_defined_bullets[4]; Spacing spacing; @@ -351,7 +350,6 @@ BufferParams::BufferParams() listings_params = string(); pagestyle = "default"; compressed = false; - embedded = lyxrc.use_bundled_format; for (int iter = 0; iter < 4; ++iter) { user_defined_bullet(iter) = ITEMIZE_DEFAULTS[iter]; temp_bullet(iter) = ITEMIZE_DEFAULTS[iter]; @@ -378,18 +376,6 @@ AuthorList const & BufferParams::authors() const } -vector & BufferParams::extraEmbeddedFiles() -{ - return pimpl_->extraEmbeddedFiles; -} - - -vector const & BufferParams::extraEmbeddedFiles() const -{ - return pimpl_->extraEmbeddedFiles; -} - - BranchList & BufferParams::branchlist() { return pimpl_->branchlist; @@ -467,7 +453,7 @@ void BufferParams::setDefSkip(VSpace const & vs) string BufferParams::readToken(Lexer & lex, string const & token, - FileName const & filepath, FileName const & temppath) + FileName const & filepath) { if (token == "\\textclass") { lex.next(); @@ -476,8 +462,6 @@ string BufferParams::readToken(Lexer & lex, string const & token, // NOTE: in this case, the textclass (.cls file) is assumed to be available. string tcp; LayoutFileList & bcl = LayoutFileList::get(); - if (!temppath.empty()) - tcp = bcl.addLayoutFile(classname, temppath.absFilename(), LayoutFileList::Embedded); if (tcp.empty() && !filepath.empty()) tcp = bcl.addLayoutFile(classname, filepath.absFilename(), LayoutFileList::Local); if (!tcp.empty()) @@ -673,16 +657,6 @@ string BufferParams::readToken(Lexer & lex, string const & token, toktmp << endl; return toktmp; } - } else if (token == "\\extra_embedded_files") { - extraEmbeddedFiles().clear(); - string par; - lex >> par; - string tmp; - par = split(par, tmp, ','); - while (!tmp.empty()) { - extraEmbeddedFiles().push_back(tmp); - par = split(par, tmp, ','); - } } else { lyxerr << "BufferParams::readToken(): Unknown token: " << token << endl; diff --git a/src/BufferParams.h b/src/BufferParams.h index 55749646c5..eee2d69cbb 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -67,8 +67,7 @@ public: /// read a header token, if unrecognised, return it or an unknown class name std::string readToken(Lexer & lex, std::string const & token, ///< token to read. - support::FileName const & filepath, - support::FileName const & temppath); ///< where to look for local layout file. + support::FileName const & filepath); /// void writeFile(std::ostream &) const; @@ -266,11 +265,6 @@ public: bool outputChanges; /// bool compressed; - /// - bool embedded; - /// - std::vector & extraEmbeddedFiles(); - std::vector const & extraEmbeddedFiles() const; /// the author list for the document AuthorList & authors(); diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 1957c9777f..092a81f13d 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -24,7 +24,6 @@ #include "Cursor.h" #include "CutAndPaste.h" #include "DispatchResult.h" -#include "EmbeddedFiles.h" #include "ErrorList.h" #include "factory.h" #include "FloatList.h" @@ -943,11 +942,6 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd) break; } - case LFUN_BUFFER_TOGGLE_EMBEDDING: { - flag.setOnOff(buffer_.params().embedded); - break; - } - case LFUN_SCREEN_UP: case LFUN_SCREEN_DOWN: case LFUN_SCROLL: @@ -1311,16 +1305,6 @@ bool BufferView::dispatch(FuncRequest const & cmd) buffer_.params().compressed = !buffer_.params().compressed; break; - case LFUN_BUFFER_TOGGLE_EMBEDDING: { - // turn embedding on/off - try { - buffer_.embeddedFiles().enable(!buffer_.params().embedded, buffer_, true); - } catch (ExceptionMessage const & message) { - Alert::error(message.title_, message.details_); - } - break; - } - case LFUN_NEXT_INSET_TOGGLE: { // this is the real function we want to invoke FuncRequest tmpcmd = FuncRequest(LFUN_INSET_TOGGLE, cmd.origin); diff --git a/src/Converter.cpp b/src/Converter.cpp index e674fc9d48..154263e42b 100644 --- a/src/Converter.cpp +++ b/src/Converter.cpp @@ -496,8 +496,8 @@ bool Converters::move(string const & fmt, string const to_base = removeExtension(to.absFilename()); string const to_extension = getExtension(to.absFilename()); - FileNameList const files = FileName(path).dirList(getExtension(from.absFilename())); - for (FileNameList::const_iterator it = files.begin(); + support::FileNameList const files = FileName(path).dirList(getExtension(from.absFilename())); + for (support::FileNameList::const_iterator it = files.begin(); it != files.end(); ++it) { string const from2 = it->absFilename(); string const file2 = onlyFilename(from2); diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index 087d68ba14..a535a8255d 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -861,7 +861,7 @@ void pasteClipboardGraphics(Cursor & cur, ErrorList & /* errorList */, // create inset for graphic InsetGraphics * inset = new InsetGraphics(cur.buffer()); InsetGraphicsParams params; - params.filename = EmbeddedFile(filename.absFilename(), cur.buffer().filePath()); + params.filename = support::DocFileName(filename.absFilename()); inset->setParams(params); cur.recordUndo(); cur.insert(inset); diff --git a/src/EmbeddedFiles.cpp b/src/EmbeddedFiles.cpp deleted file mode 100644 index 0caebe0dbd..0000000000 --- a/src/EmbeddedFiles.cpp +++ /dev/null @@ -1,645 +0,0 @@ -// -*- C++ -*- -/** - * \file EmbeddedFileList.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Bo Peng - * - * Full author contact details are available in file CREDITS. - * - */ - -#include - -#include "EmbeddedFiles.h" - -#include "Buffer.h" -#include "BufferParams.h" -#include "ErrorList.h" -#include "Format.h" -#include "InsetIterator.h" -#include "Lexer.h" -#include "LyX.h" -#include "Paragraph.h" -#include "Session.h" - -#include "frontends/alert.h" - -#include "support/debug.h" -#include "support/filetools.h" -#include "support/gettext.h" -#include "support/convert.h" -#include "support/lstrings.h" -#include "support/ExceptionMessage.h" -#include "support/FileZipListDir.h" - -#include "support/assert.h" - -#include -#include -#include - -using namespace std; -using namespace lyx::support; - -namespace lyx { - -namespace Alert = frontend::Alert; - -EmbeddedFile::EmbeddedFile(string const & file, std::string const & buffer_path) - : DocFileName("", false), embedded_(false), inset_list_() -{ - set(file, buffer_path); -} - - -void EmbeddedFile::set(std::string const & filename, std::string const & buffer_path) -{ - DocFileName::set(filename, buffer_path); - if (filename.empty()) - return; - - if (!buffer_path.empty()) - inzip_name_ = calcInzipName(buffer_path); -} - - -void EmbeddedFile::setInzipName(std::string const & name) -{ - if (name.empty() || name == inzip_name_) - return; - - // an enabled EmbeededFile should have this problem handled - LASSERT(!isEnabled(), /**/); - // file will be synced when it is enabled - inzip_name_ = name; -} - - -string EmbeddedFile::embeddedFile() const -{ - LASSERT(isEnabled(), /**/); - return temp_path_ + inzip_name_; -} - - -FileName EmbeddedFile::availableFile() const -{ - if (isEnabled() && embedded()) - return FileName(embeddedFile()); - return *this; -} - - -string EmbeddedFile::latexFilename(std::string const & buffer_path) const -{ - return (isEnabled() && embedded()) ? inzip_name_ : relFilename(buffer_path); -} - - -void EmbeddedFile::addInset(Inset const * inset) -{ - if (inset) - inset_list_.push_back(inset); -} - - -void EmbeddedFile::setEmbed(bool embed) -{ - embedded_ = embed; -} - - -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 - // should be in place so no updateFromExternalFile or extract() - // should be called. (updateFile should be false in this case). - // 2. through menu item enable/disable. updateFile should be true. - // 3. A single embedded file is added or modified. updateFile - // can be true or false. - LYXERR(Debug::FILES, (enabled ? "Enable" : "Disable") - << " " << absFilename() - << (updateFile ? " (update file)." : " (no update).")); - - if (enabled) { - temp_path_ = buf.temppath(); - if (!suffixIs(temp_path_, '/')) - temp_path_ += '/'; - if (embedded() && updateFile) - updateFromExternalFile(); - } else { - // when a new embeddeed file is created, it is not enabled, and - // there is no need to extract. - if (isEnabled() && embedded() && updateFile) - extract(); - temp_path_ = ""; - } -} - - -bool EmbeddedFile::extract() const -{ - LASSERT(isEnabled(), /**/); - - string ext_file = absFilename(); - string emb_file = embeddedFile(); - - FileName emb(emb_file); - FileName ext(ext_file); - - if (!emb.exists()) { - if (ext.exists()) - return true; - throw ExceptionMessage(ErrorException, _("Failed to extract file"), - bformat(_("Cannot extract file '%1$s'.\n" - "Source file %2$s does not exist"), - from_utf8(outputFilename()), from_utf8(emb_file))); - } - - // if external file already exists ... - if (ext.exists()) { - // no need to copy if the files are the same - if (checksum() == FileName(emb_file).checksum()) - return true; - // otherwise, ask if overwrite - int ret = Alert::prompt( - _("Overwrite external file?"), - bformat(_("External file %1$s already exists, do you want to overwrite it?"), - from_utf8(ext_file)), 1, 1, _("&Overwrite"), _("&Cancel")); - if (ret != 0) - // if the user does not want to overwrite, we still consider it - // a successful operation. - return true; - } - // copy file - - // need to make directory? - FileName path = ext.onlyPath(); - if (!path.createPath()) { - throw ExceptionMessage(ErrorException, _("Copy file failure"), - bformat(_("Cannot create file path '%1$s'.\n" - "Please check whether the path is writeable."), - from_utf8(path.absFilename()))); - return false; - } - - if (emb.copyTo(ext)) { - LYXERR(Debug::FILES, "Extract file " << emb_file << " to " << ext_file << endl); - return true; - } - - throw ExceptionMessage(ErrorException, _("Copy file failure"), - bformat(_("Cannot copy file %1$s to %2$s.\n" - "Please check whether the directory exists and is writeable."), - from_utf8(emb_file), from_utf8(ext_file))); - return false; -} - - -bool EmbeddedFile::updateFromExternalFile() const -{ - LASSERT(isEnabled(), /**/); - - string ext_file = absFilename(); - string emb_file = embeddedFile(); - - FileName emb(emb_file); - FileName ext(ext_file); - - if (!ext.exists()) { - // no need to update - if (emb.exists()) - return true; - // no external and internal file - throw ExceptionMessage(ErrorException, - _("Failed to embed file"), - bformat(_("Failed to embed file %1$s.\n" - "Please check whether this file exists and is readable."), - from_utf8(ext_file))); - } - - // if embedded file already exists ... - if (emb.exists()) { - // no need to copy if the files are the same - if (checksum() == FileName(emb_file).checksum()) - return true; - // other wise, ask if overwrite - int const ret = Alert::prompt( - _("Update embedded file?"), - bformat(_("Embedded file %1$s already exists, do you want to overwrite it"), - from_utf8(ext_file)), 1, 1, _("&Overwrite"), _("&Cancel")); - if (ret != 0) - // if the user does not want to overwrite, we still consider it - // a successful operation. - return true; - } - // copy file - // need to make directory? - FileName path = emb.onlyPath(); - if (!path.isDirectory()) - path.createPath(); - if (ext.copyTo(emb)) - return true; - throw ExceptionMessage(ErrorException, - _("Copy file failure"), - bformat(_("Cannot copy file %1$s to %2$s.\n" - "Please check whether the directory exists and is writeable."), - from_utf8(ext_file), from_utf8(emb_file))); - //LYXERR(Debug::DEBUG, "Fs error: " << fe.what()); - return false; -} - - -EmbeddedFile EmbeddedFile::copyTo(Buffer const & buf) -{ - EmbeddedFile file = EmbeddedFile(absFilename(), buf.filePath()); - file.setEmbed(embedded()); - file.enable(buf.embedded(), buf, false); - - // use external file. - if (!embedded()) - return file; - - LYXERR(Debug::FILES, "Copy " << availableFile() - << " to " << file.availableFile()); - - FileName from_file = availableFile(); - FileName to_file = file.availableFile(); - - if (!from_file.exists()) { - // no from file - throw ExceptionMessage(ErrorException, - _("Failed to copy embedded file"), - bformat(_("Failed to embed file %1$s.\n" - "Please check whether the source file is available"), - from_utf8(absFilename()))); - file.setEmbed(false); - return file; - } - - // if destination file already exists ... - if (to_file.exists()) { - // no need to copy if the files are the same - if (checksum() == to_file.checksum()) - return file; - // other wise, ask if overwrite - int const ret = Alert::prompt( - _("Update embedded file?"), - bformat(_("Embedded file %1$s already exists, do you want to overwrite it"), - from_utf8(to_file.absFilename())), 1, 1, _("&Overwrite"), _("&Cancel")); - if (ret != 0) - // if the user does not want to overwrite, we still consider it - // a successful operation. - return file; - } - // copy file - // need to make directory? - FileName path = to_file.onlyPath(); - if (!path.isDirectory()) - path.createPath(); - if (from_file.copyTo(to_file)) - return file; - throw ExceptionMessage(ErrorException, - _("Copy file failure"), - bformat(_("Cannot copy file %1$s to %2$s.\n" - "Please check whether the directory exists and is writeable."), - from_utf8(from_file.absFilename()), from_utf8(to_file.absFilename()))); - return file; -} - - -void EmbeddedFile::updateInsets() const -{ - vector::const_iterator it = inset_list_.begin(); - vector::const_iterator it_end = inset_list_.end(); - for (; it != it_end; ++it) - const_cast(*it)->updateEmbeddedFile(*this); -} - - -bool EmbeddedFile::isReadableFile() const -{ - return availableFile().isReadableFile(); -} - - -unsigned long EmbeddedFile::checksum() const -{ - return availableFile().checksum(); -} - -/** -Under the lyx temp directory, content.lyx and its embedded files are usually -saved as - -$temp/$embDirName/file.lyx -$temp/$embDirName/figure1.png for ./figure1.png) -$temp/$embDirName/sub/figure2.png for ./sub/figure2.png) - -This works fine for embedded files that are in the current or deeper directory -of the document directory, but not for files such as ../figures/figure.png. -A unique name $upDirName is chosen to represent .. in such filenames so that -'up' directories can be stored 'down' the directory tree: - -$temp/$embDirName/$upDirName/figures/figure.png for ../figures/figure.png -$temp/$embDirName/$upDirName/$upDirName/figure.png for ../../figure.png - -This name has to be fixed because it is used in lyx bundled .zip file. - -Using a similar trick, we use $absDirName for absolute path so that -an absolute filename can be saved as - -$temp/$embDirName/$absDirName/a/absolute/path for /a/absolute/path - -FIXME: -embDirName is set to . so that embedded layout and class files can be -used directly. However, putting all embedded files directly under -the temp directory may lead to file conflicts. For example, if a user -embeds a file blah.log in blah.lyx, it will be replaced when -'latex blah.tex' is called. -*/ -const std::string embDirName = "."; -const std::string upDirName = "LyX.Embed.Dir.Up"; -const std::string absDirName = "LyX.Embed.Dir.Abs"; -const std::string driveName = "LyX.Embed.Drive"; -const std::string spaceName = "LyX.Embed.Space"; - -std::string EmbeddedFile::calcInzipName(std::string const & buffer_path) -{ - string inzipName = to_utf8(makeRelPath(from_utf8(absFilename()), - from_utf8(buffer_path))); - - if (FileName(inzipName).isAbsolute()) - inzipName = absDirName + '/' + inzipName; - - // replace .. by upDirName - if (prefixIs(inzipName, ".")) - inzipName = subst(inzipName, "..", upDirName); - // replace special characters by their value - inzipName = subst(inzipName, ":", driveName); - inzipName = subst(inzipName, " ", spaceName); - - // to avoid name conflict between $docu_path/file and $temp_path/file - // embedded files are in a subdirectory of $temp_path. - inzipName = embDirName + '/' + inzipName; - return inzipName; -} - - -void EmbeddedFile::syncInzipFile(std::string const & buffer_path) -{ - LASSERT(isEnabled(), /**/); - string old_emb_file = temp_path_ + '/' + inzip_name_; - FileName old_emb(old_emb_file); - - if (!old_emb.exists()) - throw ExceptionMessage(ErrorException, _("Failed to open file"), - bformat(_("Embedded file %1$s does not exist. Did you tamper lyx temporary directory?"), - old_emb.displayName())); - - string new_inzip_name = calcInzipName(buffer_path); - if (new_inzip_name == inzip_name_) - return; - - LYXERR(Debug::FILES, " OLD ZIP " << old_emb_file << - " NEW ZIP " << calcInzipName(buffer_path)); - - string new_emb_file = temp_path_ + '/' + new_inzip_name; - FileName new_emb(new_emb_file); - - // need to make directory? - FileName path = new_emb.onlyPath(); - if (!path.createPath()) { - throw ExceptionMessage(ErrorException, _("Sync file failure"), - bformat(_("Cannot create file path '%1$s'.\n" - "Please check whether the path is writeable."), - from_utf8(path.absFilename()))); - return; - } - - if (old_emb.copyTo(new_emb)) { - LYXERR(Debug::FILES, "Sync inzip file from " << inzip_name_ - << " to " << new_inzip_name); - inzip_name_ = new_inzip_name; - return; - } - throw ExceptionMessage(ErrorException, _("Sync file failure"), - bformat(_("Cannot copy file %1$s to %2$s.\n" - "Please check whether the directory exists and is writeable."), - from_utf8(old_emb_file), from_utf8(new_emb_file))); -} - - -bool operator==(EmbeddedFile const & lhs, EmbeddedFile const & rhs) -{ - return lhs.absFilename() == rhs.absFilename() - && lhs.saveAbsPath() == rhs.saveAbsPath() - && lhs.embedded() == rhs.embedded(); -} - - -bool operator!=(EmbeddedFile const & lhs, EmbeddedFile const & rhs) -{ - return !(lhs == rhs); -} - - -void EmbeddedFileList::enable(bool enabled, Buffer & buffer, bool updateFile) -{ - // update embedded file list - update(buffer); - - int count_embedded = 0; - int count_external = 0; - iterator it = begin(); - iterator it_end = end(); - // an exception may be thrown - for (; it != it_end; ++it) { - it->enable(enabled, buffer, updateFile); - if (it->embedded()) - ++count_embedded; - else - ++count_external; - } - // if operation is successful (no exception is thrown) - buffer.params().embedded = enabled; - - // if the operation is successful, update insets - for (it = begin(); it != it_end; ++it) - it->updateInsets(); - - if (!updateFile || (count_external == 0 && count_embedded == 0)) - return; - - // show result - if (enabled) { - docstring const msg = bformat(_("%1$d external files are ignored.\n" - "%2$d embeddable files are embedded.\n"), count_external, count_embedded); - Alert::information(_("Packing all files"), msg); - } else { - docstring const msg = bformat(_("%1$d external files are ignored.\n" - "%2$d embedded files are extracted.\n"), count_external, count_embedded); - Alert::information(_("Unpacking all files"), msg); - } -} - - -void EmbeddedFileList::registerFile(EmbeddedFile const & file, - Inset const * inset, Buffer const & buffer) -{ - LASSERT(!buffer.embedded() || file.isEnabled(), /**/); - - string newfile = file.absFilename(); - iterator efp = findFile(newfile); - if (efp != end()) { - if (efp->embedded() != file.embedded()) { - Alert::error(_("Wrong embedding status."), - bformat(_("File %1$s is included in more than one insets, " - "but with different embedding status. Assuming embedding status."), - from_utf8(efp->outputFilename()))); - efp->setEmbed(true); - // update the inset with this embedding status. - const_cast(inset)->updateEmbeddedFile(*efp); - } - efp->addInset(inset); - return; - } - file.clearInsets(); - push_back(file); - back().addInset(inset); -} - - -EmbeddedFileList::const_iterator - EmbeddedFileList::findFile(std::string const & filename) const -{ - // try to find this file from the list - std::vector::const_iterator it = begin(); - std::vector::const_iterator it_end = end(); - for (; it != it_end; ++it) - if (it->absFilename() == filename) - return it; - return end(); -} - - -EmbeddedFileList::iterator - EmbeddedFileList::findFile(std::string const & filename) -{ - // try to find this file from the list - std::vector::iterator it = begin(); - std::vector::iterator it_end = end(); - for (; it != it_end; ++it) - if (it->absFilename() == filename) - return it; - return end(); -} - - -void EmbeddedFileList::validate(Buffer const & buffer) -{ - clear(); - - for (InsetIterator it = inset_iterator_begin(buffer.inset()); it; ++it) - it->registerEmbeddedFiles(*this); - - iterator it = begin(); - iterator it_end = end(); - for (; it != it_end; ++it) { - if (buffer.embedded() && it->embedded()) - // An exception will be raised if inzip file does not exist - it->syncInzipFile(buffer.filePath()); - else - // inzipName may be OS dependent - it->setInzipName(it->calcInzipName(buffer.filePath())); - } - for (it = begin(); it != it_end; ++it) - it->updateInsets(); - - if (!buffer.embedded()) - return; - - // check if extra embedded files exist - vector extra = buffer.params().extraEmbeddedFiles(); - vector::iterator e_it = extra.begin(); - vector::iterator e_end = extra.end(); - 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); - // but we do need to check file existence. - if (!FileName(file.embeddedFile()).exists()) - throw ExceptionMessage(ErrorException, _("Failed to open file"), - bformat(_("Embedded file %1$s does not exist. Did you tamper lyx temporary directory?"), - file.displayName())); - } -} - - -void EmbeddedFileList::update(Buffer const & buffer) -{ - clear(); - - for (InsetIterator it = inset_iterator_begin(buffer.inset()); it; ++it) - it->registerEmbeddedFiles(*this); - - // add extra embedded files - vector extra = buffer.params().extraEmbeddedFiles(); - vector::iterator it = extra.begin(); - vector::iterator it_end = extra.end(); - for (; it != it_end; ++it) { - EmbeddedFile file = EmbeddedFile(*it, buffer.filePath()); - file.setEmbed(true); - file.enable(buffer.embedded(), buffer, false); - insert(end(), file); - } -} - - -bool EmbeddedFileList::writeFile(DocFileName const & filename, Buffer const & buffer) -{ - // file in the temporary path has the content - string const content = FileName(addName(buffer.temppath(), - "content.lyx")).toFilesystemEncoding(); - - vector > filenames; - // add content.lyx to filenames - filenames.push_back(make_pair(content, "content.lyx")); - // prepare list of embedded file - update(buffer); - // - iterator it = begin(); - iterator it_end = end(); - for (; it != it_end; ++it) { - if (it->embedded()) { - string file = it->embeddedFile(); - if (!FileName(file).exists()) - throw ExceptionMessage(ErrorException, _("Failed to write file"), - bformat(_("Embedded file %1$s does not exist. Did you tamper lyx temporary directory?"), - it->displayName())); - filenames.push_back(make_pair(file, it->inzipName())); - LYXERR(Debug::FILES, "Writing file " << it->outputFilename() - << " as " << it->inzipName() << endl); - } - } - // write a zip file with all these files. Write to a temp file first, to - // avoid messing up the original file in case something goes terribly wrong. - DocFileName zipfile(addName(buffer.temppath(), - onlyFilename(changeExtension( - filename.toFilesystemEncoding(), ".zip")))); - - ::zipFiles(zipfile.toFilesystemEncoding(), filenames); - // copy file back - if (!zipfile.copyTo(filename)) { - Alert::error(_("Save failure"), - bformat(_("Cannot create file %1$s.\n" - "Please check whether the directory exists and is writeable."), - from_utf8(filename.absFilename()))); - } - return true; -} - -} // namespace lyx diff --git a/src/EmbeddedFiles.h b/src/EmbeddedFiles.h deleted file mode 100644 index 1ef99b34fb..0000000000 --- a/src/EmbeddedFiles.h +++ /dev/null @@ -1,257 +0,0 @@ -// -*- C++ -*- -/** - * \file EmbeddedFiles.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Bo Peng - * - * Full author contact details are available in file CREDITS. - * - */ - -#ifndef EMBEDDEDFILES_H -#define EMBEDDEDFILES_H - -#include "support/FileName.h" - -#include -#include - -/** - -This file, and the embed checkbox in dialogs of InsetGraphics etc, implements -an 'Embedded Files' feature of lyx. - - -Expected features: -========================= - -1. Bundled .lyx file can embed graphics, listings, bib file etc. The bundle -format is used when Document->Save in bundled format is selected. - -2. Embedded file.lyx file is a zip file, with content.lyx and embedded files. - -3. The embedding status of embedded files are set from individual insets. - -4. Extra files such as .cls and .layout can be embedded from Document-> -Settings->Embedded Files->Extra Embedded Files. - -5. When Document->Save in bundled format is selected, all embedded files -become bundled. Changes to the external version of this file does not -affect the output of the .lyx file. - -6. When Document->Save in bundled format is unchecked, all embedded files -are copied to their original locations. - -Overall, this feature allows two ways of editing a .lyx file - -a. The continuous use of the pure-text .lyx file format with external -files. This is the default file format, and allows external editing -of .lyx file and better use of version control systems. - -b. The embedded way. Figures etc are inserted to .lyx file and will -be embedded. These embedded files can be viewed or edited through -the embedding dialog. This file can be shared with others more -easily. - -Format a and b can be converted easily, by packing/unpacking a .lyx file. - -Implementation: -====================== - -1. An EmbeddedFiles class is implemented to keep the embedded files ( -class EmbeddedFile). (c.f. src/EmbeddedFiles.[h|cpp]) - -2. When a file is saved, it is scanned for embedded files. (c.f. -EmbeddedFiles::update(), Inset::registerEmbeddedFiles()). - -3. When a lyx file file.lyx is saved, it is save to tmppath()/content.lyx -first. Embedded files are compressed along with content.lyx. -If embedding is disabled, file.lyx is saved in the usual pure-text format. -(c.f. Buffer::writeFile(), EmbeddedFiles::writeFile()) - -4. When a lyx file.lyx file is opened, if it is a zip file, it is -decompressed to tmppath() and tmppath()/content.lyx is read as usual. -(c.f. bool Buffer::readFile()) - -5. A menu item Document -> Save in bundled format is provided to pack/unpack -a .lyx file. - -6. If embedding of a .lyx file with embedded files is disabled, all its -embedded files are copied to their respective external filenames. This -is why external filename will exist even if a file is at "EMBEDDED" status. - -*/ - -namespace lyx { - -class Buffer; -class Inset; -class Lexer; -class ErrorList; - -class EmbeddedFile : public support::DocFileName -{ -public: - /// - EmbeddedFile(std::string const & file = std::string(), - std::string const & buffer_path = std::string()); - - /// set filename and inzipName. - /** - * NOTE: inzip_name_ is not unique across operation systems and is not - * guaranteed to be the same across different versions of LyX. - * inzip_name_ will be saved to the LyX file, and is used to indicate - * whether or not a file is embedded, and where the embedded file is in - * the bundled file. When a file is read, the stored inzip names are used - * at first. EmbeddedFiles::validate() will then scan these embedded files - * and update their inzip name, moving bundled files around if needed. - * This scheme has the advantage that it is safe to change how inzip files - * are saved in a bundled file. - * - * NOTE that this treatment does not welcome an UUID solution because - * all embedded files will have to be renamed when an embedded file is - * opened. It is of course possible to use saved inzipname, but that is - * not easy. For example, when a new EmbeddedFile is created with the same - * file as an old one, it needs to be synced to the old inzipname... - **/ - void set(std::string const & filename, std::string const & buffer_path); - /** Set the inzip name of an EmbeddedFile, which should be the name - * of an actual embedded file on disk. - */ - void setInzipName(std::string const & name); - - /// filename in the zip file, which is related to buffer temp directory. - std::string inzipName() const { return inzip_name_; } - - /// embedded file, equals to temppath()/inzipName() - std::string embeddedFile() const; - /// embeddedFile() or absFilename() depending on embedding status - /// and whether or not embedding is enabled. - FileName availableFile() const; - /// relative file name or inzipName() - std::string latexFilename(std::string const & buffer_path) const; - - /// add an inset that refers to this file - void addInset(Inset const * inset); - /// clear all isnets that associated with this file. - void clearInsets() const { inset_list_.clear(); } - - /// embedding status of this file - bool embedded() const { return embedded_; } - /// set embedding status. - void setEmbed(bool embed); - - /// whether or not embedding is enabled for the current file - /** - * An embedded file needs to know the temp path of a buffer to know - * where its embedded copy is. This has to be stored within EmbeddedFile - * because this class is often used when Buffer is unavailable. However, - * when an embedded file is copied to another buffer, temp_path_ has - * to be updated and file copying may be needed. - */ - bool isEnabled() const { return !temp_path_.empty(); } - /// enable embedding of this file - 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); - /// - /// After the embedding status is changed, update all insets related - /// to this file item. For example, a graphic inset may need to monitor - /// embedded file instead of external file. - void updateInsets() const; - - /// Check readability of availableFile - bool isReadableFile() const; - /// Calculate checksum of availableFile - unsigned long checksum() const; - - // calculate inzip_name_ from filename - std::string calcInzipName(std::string const & buffer_path); - // move an embedded disk file with an existing inzip_name_ to - // a calculated inzip_name_, if they differ. - void syncInzipFile(std::string const & buffer_path); -private: - /// filename in zip file - std::string inzip_name_; - /// the status of this docfile - bool embedded_; - /// Insets that contains this file item. Because a - /// file item can be referred by several Insets, a vector is used. - mutable std::vector inset_list_; - /// Embedded file needs to know whether enbedding is enabled, - /// and where is the lyx temporary directory. Such information can - /// be retrived from a buffer, but a buffer is not always available when - /// an EmbeddedFile is used. - std::string temp_path_; -}; - - -bool operator==(EmbeddedFile const & lhs, EmbeddedFile const & rhs); -bool operator!=(EmbeddedFile const & lhs, EmbeddedFile const & rhs); - - -class EmbeddedFileList { -public: - /// - typedef std::vector::iterator iterator; - /// - typedef std::vector::const_iterator const_iterator; - /// - iterator begin() { return eflist_.begin(); } - iterator end() { return eflist_.end(); } - const_iterator begin() const { return eflist_.begin(); } - const_iterator end() const { return eflist_.end(); } - /// - void push_back(EmbeddedFile const & ef) { eflist_.push_back(ef); } - /// - EmbeddedFile const & back() const { return eflist_.back(); } - EmbeddedFile & back() { return eflist_.back(); } - /// - void clear() { eflist_.clear(); } - /// - bool empty() const { return eflist_.empty(); } - /// - void insert(iterator position, const_iterator itbeg, const_iterator itend) - { eflist_.insert(position, itbeg, itend); } - void insert(iterator position, EmbeddedFile const & ef) - { eflist_.insert(position, ef); } - /// - iterator erase(iterator position) { return eflist_.erase(position); } - - - /// set buffer params embedded flag. Files will be updated or extracted - /// if such an operation fails, enable will fail. - void enable(bool enabled, Buffer & buffer, bool updateFile); - - /// add a file item. - /** \param file Embedded file to add - * \param inset Inset pointer - */ - void registerFile(EmbeddedFile const & file, Inset const * inset, - Buffer const & buffer); - /// returns an iterator pointing to the Embedded file representing - /// the file with the absolute filename . - const_iterator findFile(std::string const & filename) const; - iterator findFile(std::string const & filename); - - /// validate embedded fies after a file is read. - void validate(Buffer const & buffer); - /// scan the buffer and get a list of EmbeddedFile - void update(Buffer const & buffer); - /// write a zip file - bool writeFile(support::DocFileName const & filename, Buffer const & buffer); -private: - /// - std::vector eflist_; -}; - -} // namespace lyx - -#endif diff --git a/src/FuncCode.h b/src/FuncCode.h index 6425751ff5..76ccd974ab 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -375,45 +375,44 @@ enum FuncCode LFUN_MASTER_BUFFER_UPDATE, // Tommaso, 20070920 LFUN_INFO_INSERT, // bpeng, 20071007 LFUN_CALL, // broider, 20071002 - LFUN_BUFFER_TOGGLE_EMBEDDING, // bpeng, 20071021 LFUN_CHAR_LEFT, // dov, 20071022 - // 290 LFUN_CHAR_LEFT_SELECT, // dov, 20071022 + // 290 LFUN_CHAR_RIGHT, // dov, 20071022 LFUN_CHAR_RIGHT_SELECT, // dov, 20071022 LFUN_FINISHED_BACKWARD, // dov, 20071022 LFUN_FINISHED_FORWARD, // dov, 20071022 - // 295 LFUN_WORD_LEFT, // dov, 20071028 + // 295 LFUN_WORD_LEFT_SELECT, // dov, 20071028 LFUN_WORD_RIGHT, // dov, 20071028 LFUN_WORD_RIGHT_SELECT, // dov, 20071028 LFUN_MATH_MACRO_FOLD, - // 300 LFUN_MATH_MACRO_UNFOLD, + // 300 LFUN_MATH_MACRO_ADD_PARAM, LFUN_MATH_MACRO_REMOVE_PARAM, LFUN_MATH_MACRO_APPEND_GREEDY_PARAM, LFUN_MATH_MACRO_REMOVE_GREEDY_PARAM, - // 305 LFUN_MATH_MACRO_MAKE_OPTIONAL, + // 305 LFUN_MATH_MACRO_MAKE_NONOPTIONAL, LFUN_MATH_MACRO_ADD_OPTIONAL_PARAM, LFUN_MATH_MACRO_REMOVE_OPTIONAL_PARAM, LFUN_MATH_MACRO_ADD_GREEDY_OPTIONAL_PARAM, - // 310 LFUN_IN_MATHMACROTEMPLATE, + // 310 LFUN_SCROLL, LFUN_UI_TOGGLE, LFUN_SPLIT_VIEW, LFUN_CLOSE_TAB_GROUP, - // 315 LFUN_COMPLETION_POPUP, + // 315 LFUN_COMPLETION_INLINE, LFUN_COMPLETION_COMPLETE, LFUN_NEXT_INSET_MODIFY, // JSpitzm 20080323 LFUN_LASTACTION // end of the table - // 320 + // 319 }; diff --git a/src/LayoutFile.cpp b/src/LayoutFile.cpp index 8f0d9210b5..8a1595bafc 100644 --- a/src/LayoutFile.cpp +++ b/src/LayoutFile.cpp @@ -195,8 +195,6 @@ void LayoutFileList::reset(LayoutFileIndex const & classname) { string const LayoutFileList::localPrefix = "LOCAL:"; -string const LayoutFileList::embeddedPrefix = "EMBED:"; - LayoutFileIndex LayoutFileList::addLayoutFile(string const & textclass, string const & path, @@ -212,8 +210,6 @@ LayoutFileIndex if (type == Local) localIndex = localPrefix + fullName; - else if (type == Embedded) - localIndex = embeddedPrefix + textclass; // if the local file has already been loaded, return it if (haveClass(localIndex)) diff --git a/src/LayoutFile.h b/src/LayoutFile.h index fd95c04e91..0a5ec3472b 100644 --- a/src/LayoutFile.h +++ b/src/LayoutFile.h @@ -90,8 +90,7 @@ public: enum Layout_Type { System, - Local, - Embedded + Local }; /// add a textclass from user local directory. @@ -104,7 +103,6 @@ public: std::vector classList() const; /// static std::string const localPrefix; - static std::string const embeddedPrefix; private: /// typedef std::map ClassMap; diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 60f90f76d0..48d1a808ae 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -1478,14 +1478,6 @@ void LyXAction::init() * \endvar */ { LFUN_BUFFER_TOGGLE_COMPRESSION, "buffer-toggle-compression", Noop, Buffer }, -/*! - * \var lyx::FuncCode lyx::LFUN_BUFFER_TOGGLE_EMBEDDING - * \li Action: Toggles the embeddding feature on/off. - * \li Syntax: buffer-toggle-embedding - * \li Origin: bpeng, 21 Oct 2007 - * \endvar - */ - { LFUN_BUFFER_TOGGLE_EMBEDDING, "buffer-toggle-embedding", Noop, Buffer }, /*! * \var lyx::FuncCode lyx::LFUN_BUFFER_CLOSE * \li Action: Closes the current buffer. diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 412a078494..09a4d5bf10 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -163,7 +163,6 @@ LexerKeyword lyxrcTags[] = { { "\\tex_expects_windows_paths", LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS }, { "\\ui_file", LyXRC::RC_UIFILE }, { "\\use_alt_language", LyXRC::RC_USE_ALT_LANG }, - { "\\use_bundled_format", LyXRC::RC_USE_BUNDLED_FORMAT }, { "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE }, { "\\use_escape_chars", LyXRC::RC_USE_ESC_CHARS }, { "\\use_input_encoding", LyXRC::RC_USE_INP_ENC }, @@ -297,7 +296,6 @@ void LyXRC::setDefaults() user_name = to_utf8(support::user_name()); user_email = to_utf8(support::user_email()); open_buffers_in_tabs = true; - use_bundled_format = false; // Fullscreen settings full_screen_limit = false; @@ -1048,9 +1046,6 @@ int LyXRC::read(Lexer & lexrc) case RC_OPEN_BUFFERS_IN_TABS: lexrc >> open_buffers_in_tabs; break; - case RC_USE_BUNDLED_FORMAT: - lexrc >> use_bundled_format; - break; case RC_LAST: break; // this is just a dummy @@ -1639,19 +1634,10 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c } if (tag != RC_LAST) break; - case RC_USE_BUNDLED_FORMAT: - if (ignore_system_lyxrc || - use_bundled_format != system_lyxrc.use_bundled_format) { - os << "\\use_bundled_format " - << convert(use_bundled_format) - << '\n'; - } - if (tag != RC_LAST) - break; - os << "\n#\n" - << "# COLOR SECTION ###################################\n" - << "#\n\n"; + os << "\n#\n" + << "# COLOR SECTION ###################################\n" + << "#\n\n"; case RC_SET_COLOR: for (int i = 0; i < Color_ignore; ++i) { diff --git a/src/LyXRC.h b/src/LyXRC.h index 3b5daaedbe..b7855f7ecd 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -152,7 +152,6 @@ public: RC_USER_NAME, RC_USETEMPDIR, RC_USE_ALT_LANG, - RC_USE_BUNDLED_FORMAT, RC_USE_CONVERTER_CACHE, RC_USE_ESC_CHARS, RC_USE_INP_ENC, @@ -443,8 +442,6 @@ public: bool completion_popup_after_complete; /// bool open_buffers_in_tabs; - /// - bool use_bundled_format; }; diff --git a/src/Makefile.am b/src/Makefile.am index 4826fe8226..715e6ae2c7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -99,7 +99,6 @@ SOURCEFILESCORE = \ CutAndPaste.cpp \ DepTable.cpp \ DocIterator.cpp \ - EmbeddedFiles.cpp \ Encoding.cpp \ ErrorList.cpp \ Exporter.cpp \ @@ -196,7 +195,6 @@ HEADERFILESCORE = \ DepTable.h \ DispatchResult.h \ DocIterator.h \ - EmbeddedFiles.h \ Encoding.h \ ErrorList.h \ Exporter.h \ diff --git a/src/frontends/qt4/GuiBibtex.cpp b/src/frontends/qt4/GuiBibtex.cpp index 31f7b1bf63..cfc696664a 100644 --- a/src/frontends/qt4/GuiBibtex.cpp +++ b/src/frontends/qt4/GuiBibtex.cpp @@ -17,7 +17,6 @@ #include "Buffer.h" #include "BufferParams.h" -#include "EmbeddedFiles.h" #include "ui_BibtexAddUi.h" #include "qt_helpers.h" #include "Validator.h" @@ -32,6 +31,7 @@ #include "support/debug.h" #include "support/ExceptionMessage.h" #include "support/FileFilterList.h" +#include "support/FileName.h" #include "support/filetools.h" // changeExtension #include "support/gettext.h" #include "support/lstrings.h" diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index cb9aefaa8f..614ac0a49e 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -1282,16 +1282,6 @@ void GuiDocument::classChanged() setLayoutComboByIDString(bp_.baseClassID()); return; } - } else if (prefixIs(classname, LayoutFileList::embeddedPrefix)) { - int const ret = Alert::prompt(_("Embedded layout"), - _("The layout file you have selected is an embedded layout that\n" - "is embedded to a buffer. You cannot make use of it unless\n" - "it is already embedded to this buffer.\n"), - 1, 1, _("&Set Layout"), _("&Cancel")); - if (ret == 1) { - setLayoutComboByIDString(bp_.baseClassID()); - return; - } } // FIXME Note that by doing things this way, we load the TextClass // as soon as it is selected. So, if you use the scroll wheel when diff --git a/src/frontends/qt4/GuiGraphics.cpp b/src/frontends/qt4/GuiGraphics.cpp index 75ccbf8085..a8c0d92432 100644 --- a/src/frontends/qt4/GuiGraphics.cpp +++ b/src/frontends/qt4/GuiGraphics.cpp @@ -315,12 +315,6 @@ void GuiGraphics::on_getPB_clicked() } -void GuiGraphics::on_filename_textChanged(const QString & filename) -{ - EmbeddedFile file = EmbeddedFile(fromqstr(filename), fromqstr(bufferFilepath())); -} - - void GuiGraphics::setAutoText() { if (scaleCB->isChecked()) @@ -596,7 +590,7 @@ void GuiGraphics::updateContents() else origin->setCurrentIndex(0); - //// latex section + // latex section latexoptions->setText(toqstr(igp.special)); } diff --git a/src/frontends/qt4/GuiGraphics.h b/src/frontends/qt4/GuiGraphics.h index 6879b28889..3e767bb38a 100644 --- a/src/frontends/qt4/GuiGraphics.h +++ b/src/frontends/qt4/GuiGraphics.h @@ -45,7 +45,6 @@ private Q_SLOTS: void change_bb(); void on_browsePB_clicked(); void on_getPB_clicked(); - void on_filename_textChanged(const QString &); void on_scaleCB_toggled(bool); void on_WidthCB_toggled(bool); void on_HeightCB_toggled(bool); diff --git a/src/frontends/qt4/GuiInclude.cpp b/src/frontends/qt4/GuiInclude.cpp index 80323fccf7..08da8668bf 100644 --- a/src/frontends/qt4/GuiInclude.cpp +++ b/src/frontends/qt4/GuiInclude.cpp @@ -26,6 +26,7 @@ #include "support/os.h" #include "support/lstrings.h" #include "support/FileFilterList.h" +#include "support/FileName.h" #include "support/filetools.h" #include "insets/InsetListingsParams.h" diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 49ca60b6de..1b781fb45a 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -1838,8 +1838,6 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form, QWidget * parent) this, SIGNAL(changed())); connect(tooltipCB, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - connect(useBundledCB, SIGNAL(toggled(bool)), - this, SIGNAL(changed())); lastfilesSB->setMaximum(maxlastfiles); } @@ -1855,7 +1853,6 @@ void PrefUserInterface::apply(LyXRC & rc) const rc.num_lastfiles = lastfilesSB->value(); rc.use_tooltip = tooltipCB->isChecked(); rc.open_buffers_in_tabs = openDocumentsInTabsCB->isChecked(); - rc.use_bundled_format = useBundledCB->isChecked(); } @@ -1874,7 +1871,6 @@ void PrefUserInterface::update(LyXRC const & rc) lastfilesSB->setValue(rc.num_lastfiles); tooltipCB->setChecked(rc.use_tooltip); openDocumentsInTabsCB->setChecked(rc.open_buffers_in_tabs); - useBundledCB->setChecked(rc.use_bundled_format); } diff --git a/src/frontends/qt4/GuiToc.cpp b/src/frontends/qt4/GuiToc.cpp index feb1a7396e..73bd3d751e 100644 --- a/src/frontends/qt4/GuiToc.cpp +++ b/src/frontends/qt4/GuiToc.cpp @@ -224,8 +224,6 @@ docstring GuiToc::guiName(string const & type) const return _("Table of Contents"); if (type == "child") return _("Child Documents"); - if (type == "embedded") - return _("Embedded Files"); if (type == "graphics") return _("List of Graphics"); if (type == "equation") diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 3201ffa127..2ff88433a7 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -949,12 +949,6 @@ void GuiView::updateToc() } -void GuiView::updateEmbeddedFiles() -{ - updateDialog("embedding", ""); -} - - void GuiView::autoSave() { LYXERR(Debug::INFO, "Running autoSave()"); @@ -2018,7 +2012,7 @@ namespace { char const * const dialognames[] = { "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character", -"citation", "document", "embedding", "errorlist", "ert", "external", "file", +"citation", "document", "errorlist", "ert", "external", "file", "findreplace", "float", "graphics", "include", "index", "nomenclature", "label", "log", "mathdelimiter", "mathmatrix", "note", "paragraph", "prefs", "print", "ref", "sendto", "space", "spellchecker", "symbols", "tabular", "tabularcreate", diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index 4ccc9a9030..8bd547dbdd 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -109,8 +109,6 @@ public: /// called on timeout void autoSave(); - /// - void updateEmbeddedFiles(); /// \return the current buffer view. BufferView * view(); diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index d2d2fd57dc..1a91ca82a1 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -914,9 +914,7 @@ void MenuDefinition::expandToc(Buffer const * buf) else if (cit->first == "child") { label = qt_("Child Documents"); in_other_list = false; - } else if (cit->first == "embedded") - label = qt_("Embedded Files"); - else if (cit->first == "graphics") + } else if (cit->first == "graphics") label = qt_("List of Graphics"); else if (cit->first == "equation") label = qt_("List of Equations"); diff --git a/src/frontends/qt4/ui/PrefUi.ui b/src/frontends/qt4/ui/PrefUi.ui index 1c7f837e02..a9d1beab0c 100644 --- a/src/frontends/qt4/ui/PrefUi.ui +++ b/src/frontends/qt4/ui/PrefUi.ui @@ -171,13 +171,6 @@ - - - - Use &bundled format for new documents - - - diff --git a/src/graphics/GraphicsParams.cpp b/src/graphics/GraphicsParams.cpp index 0b2fbb2c14..659cbe84c0 100644 --- a/src/graphics/GraphicsParams.cpp +++ b/src/graphics/GraphicsParams.cpp @@ -25,8 +25,7 @@ namespace graphics { Params::Params() : display(ColorDisplay), scale(100), - angle(0), - icon("") + angle(0) {} @@ -36,8 +35,7 @@ bool operator==(Params const & a, Params const & b) a.display == b.display && a.bb == b.bb && a.scale == b.scale && - a.angle == b.angle && - a.icon == b.icon); + a.angle == b.angle); } diff --git a/src/graphics/GraphicsParams.h b/src/graphics/GraphicsParams.h index d086a25857..a7b7c8ffa4 100644 --- a/src/graphics/GraphicsParams.h +++ b/src/graphics/GraphicsParams.h @@ -72,12 +72,6 @@ public: */ /// Rotation angle. double angle; - - /** The icon to be displayed to the top-left corner of an image. - * It is mutable because an icon reflects a temporary state of - * the image, and is variable. - */ - mutable std::string icon; }; bool operator==(Params const &, Params const &); diff --git a/src/insets/ExternalSupport.cpp b/src/insets/ExternalSupport.cpp index 0d2615883b..374de438b4 100644 --- a/src/insets/ExternalSupport.cpp +++ b/src/insets/ExternalSupport.cpp @@ -50,8 +50,8 @@ Template const * getTemplatePtr(InsetExternalParams const & params) void editExternal(InsetExternalParams const & params, Buffer const & buffer) { - formats.edit(buffer, params.filename.availableFile(), - formats.getFormatFromFile(params.filename)); + formats.edit(buffer, params.filename, + formats.getFormatFromFile(params.filename)); } @@ -254,7 +254,7 @@ void updateExternal(InsetExternalParams const & params, if (from_checksum != temp_checksum) { Mover const & mover = getMover(from_format); - if (!mover.copy(params.filename.availableFile(), temp_file)) { + if (!mover.copy(params.filename, temp_file)) { LYXERR(Debug::EXTERNAL, "external::updateExternal. " << "Unable to copy " << params.filename << " to " << temp_file); return; // FAILURE @@ -310,7 +310,7 @@ void updateExternal(InsetExternalParams const & params, ErrorList el; bool const success = theConverters().convert(&buffer, temp_file, abs_to_file, - params.filename.availableFile(), from_format, to_format, el, + params.filename, from_format, to_format, el, Converters::try_default | Converters::try_cache); if (!success) { diff --git a/src/insets/Inset.h b/src/insets/Inset.h index b86f35c542..5d21a0fe1d 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -53,8 +53,7 @@ class ParConstIterator; class ParIterator; class Text; class TocList; -class EmbeddedFile; -class EmbeddedFileList; +class FileNameList; namespace graphics { class PreviewLoader; } @@ -435,11 +434,6 @@ public: /// Add an entry to the TocList /// pit is the ParConstIterator of the paragraph containing the inset virtual void addToToc(ParConstIterator const &) const {} - /// report files that can be embedded with the lyx file - virtual void registerEmbeddedFiles(EmbeddedFileList &) const {} - /// update the properties of an embedded file of an inset - /// the name of the embedded file should not change. - virtual void updateEmbeddedFile(EmbeddedFile const &) {} /// Fill keys with BibTeX information virtual void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const {} /// Update the counters of this inset and of its contents diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index 5ecddbc501..5149087620 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -292,7 +292,7 @@ support::FileNameList InsetBibtex::getBibFiles() const FileName path(buffer().filePath()); support::PathChanger p(path); - FileNameList vec; + support::FileNameList vec; vector bibfilelist = getVectorFromString(getParam("bibfiles")); vector::const_iterator it = bibfilelist.begin(); diff --git a/src/insets/InsetBibtex.h b/src/insets/InsetBibtex.h index e54dd7ab4f..64cab78bea 100644 --- a/src/insets/InsetBibtex.h +++ b/src/insets/InsetBibtex.h @@ -13,7 +13,6 @@ #define INSET_BIBTEX_H #include "BiblioInfo.h" -#include "EmbeddedFiles.h" #include "InsetCommand.h" #include "support/FileNameList.h" @@ -22,7 +21,6 @@ namespace lyx { - /** Used to insert BibTeX's information */ class InsetBibtex : public InsetCommand { diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index 64329bb722..643e1e2abb 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -190,6 +190,7 @@ void InsetExternalParams::write(Buffer const & buf, ostream & os) const if (!filename.empty()) os << "\tfilename " << filename.outputFilename(buf.filePath()) << '\n'; + if (display != defaultDisplayType) os << "\tdisplay " << external::displayTranslator().find(display) @@ -246,7 +247,6 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex) enum { EX_TEMPLATE = 1, EX_FILENAME, - EX_EMBED, EX_DISPLAY, EX_LYXSCALE, EX_DRAFT, @@ -268,7 +268,6 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex) { "clip", EX_CLIP }, { "display", EX_DISPLAY}, { "draft", EX_DRAFT}, - { "embed", EX_EMBED}, { "extra", EX_EXTRA }, { "filename", EX_FILENAME}, { "height", EX_HEIGHT }, @@ -300,14 +299,6 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex) break; } - case EX_EMBED: { - lex.next(); - string const name = lex.getString(); - filename.setInzipName(name); - filename.setEmbed(!name.empty()); - break; - } - case EX_DISPLAY: { lex.next(); string const name = lex.getString(); @@ -426,23 +417,6 @@ InsetExternal::~InsetExternal() } -void InsetExternal::setBuffer(Buffer & buffer) -{ - if (buffer_) { - try { - // a file may not be copied successfully when, e.g. buffer_ - // has already been closed. - params_.filename = params_.filename.copyTo(buffer); - } catch (ExceptionMessage const & message) { - Alert::error(message.title_, message.details_); - // failed to embed - params_.filename.setEmbed(false); - } - } - Inset::setBuffer(buffer); -} - - void InsetExternal::statusChanged() const { updateFrontend(); @@ -503,18 +477,6 @@ bool InsetExternal::getStatus(Cursor & cur, FuncRequest const & cmd, } -void InsetExternal::registerEmbeddedFiles(EmbeddedFileList & files) const -{ - files.registerFile(params_.filename, this, buffer()); -} - - -void InsetExternal::updateEmbeddedFile(EmbeddedFile const & file) -{ - params_.filename = file; -} - - void InsetExternal::edit(Cursor & cur, bool, EntryDirection) { cur.bv().showDialog("external", @@ -568,8 +530,7 @@ graphics::Params get_grfx_params(InsetExternalParams const & eparams) { graphics::Params gparams; - gparams.filename = eparams.filename.availableFile(); - gparams.icon = eparams.filename.embedded() ? "pin.png" : ""; + gparams.filename = eparams.filename; gparams.scale = eparams.lyxscale; if (eparams.clipdata.clip) gparams.bb = eparams.clipdata.bbox; @@ -738,11 +699,8 @@ void InsetExternal::write(ostream & os) const 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); + if (params.read(buffer(), lex)) setParams(params); - } } diff --git a/src/insets/InsetExternal.h b/src/insets/InsetExternal.h index 8956c7c38d..1d1d0d4be5 100644 --- a/src/insets/InsetExternal.h +++ b/src/insets/InsetExternal.h @@ -14,7 +14,6 @@ #include "Inset.h" #include "ExternalTransforms.h" -#include "EmbeddedFiles.h" #include "support/FileName.h" #include "support/Translator.h" @@ -78,7 +77,7 @@ public: std::string const & templatename() const { return templatename_; } /// The external file. - EmbeddedFile filename; + support::DocFileName filename; /// How the inset is to be displayed by LyX. external::DisplayType display; /// The scale of the displayed graphic (if shown). @@ -119,8 +118,6 @@ public: InsetExternalParams const & params() const; /// void setParams(InsetExternalParams const &); - /// - void setBuffer(Buffer & buffer); /// \returns the number of rows (\n's) of generated code. int latex(odocstream &, OutputParams const &) const; @@ -151,10 +148,6 @@ private: void edit(Cursor & cur, bool front, EntryDirection entry_from); /// bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const; - /// external file can be embedded - void registerEmbeddedFiles(EmbeddedFileList &) const; - /// - void updateEmbeddedFile(EmbeddedFile const &); /// void doDispatch(Cursor & cur, FuncRequest & cmd); /// diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp index 4830119e0f..51a527fa0c 100644 --- a/src/insets/InsetGraphics.cpp +++ b/src/insets/InsetGraphics.cpp @@ -54,7 +54,6 @@ TODO #include "Converter.h" #include "Cursor.h" #include "DispatchResult.h" -#include "EmbeddedFiles.h" #include "ErrorList.h" #include "Exporter.h" #include "Format.h" @@ -182,23 +181,6 @@ InsetGraphics::~InsetGraphics() } -void InsetGraphics::setBuffer(Buffer & buffer) -{ - if (buffer_) { - try { - // a file may not be copied successfully when, e.g. buffer_ - // has already been closed. - params_.filename = params_.filename.copyTo(buffer); - } catch (ExceptionMessage const & message) { - Alert::error(message.title_, message.details_); - // failed to embed - params_.filename.setEmbed(false); - } - } - Inset::setBuffer(buffer); -} - - void InsetGraphics::doDispatch(Cursor & cur, FuncRequest & cmd) { switch (cmd.action) { @@ -254,23 +236,10 @@ bool InsetGraphics::getStatus(Cursor & cur, FuncRequest const & cmd, } -void InsetGraphics::registerEmbeddedFiles(EmbeddedFileList & files) const -{ - files.registerFile(params().filename, this, buffer()); -} - - -void InsetGraphics::updateEmbeddedFile(EmbeddedFile const & file) -{ - // only properties of an embedded file can be changed here. - params_.filename = file; -} - - void InsetGraphics::edit(Cursor & cur, bool, EntryDirection) { cur.bv().showDialog("graphics", params2string(params(), -cur.bv().buffer()), this); + cur.bv().buffer()), this); } @@ -304,7 +273,6 @@ void InsetGraphics::read(Lexer & lex) lex.setContext("InsetGraphics::read"); //lex >> "Graphics"; readInsetGraphics(lex, buffer().filePath(), params_); - params_.filename.enable(buffer().embedded(), buffer(), false); graphic_->update(params().as_grfxParams()); } @@ -569,7 +537,7 @@ string InsetGraphics::prepareFile(OutputParams const & runparams) const if (params().filename.empty()) return string(); - string const orig_file = params().filename.availableFile().absFilename(); + string const orig_file = params().filename.absFilename(); // this is for dryrun and display purposes, do not use latexFilename string const rel_file = params().filename.relFilename(buffer().filePath()); @@ -579,7 +547,7 @@ string InsetGraphics::prepareFile(OutputParams const & runparams) const // temp_file will contain the file for LaTeX to act on if, for example, // we move it to a temp dir or uncompress it. - FileName temp_file = params().filename.availableFile(); + FileName temp_file = params().filename; // The master buffer. This is useful when there are multiple levels // of include files @@ -599,7 +567,7 @@ string InsetGraphics::prepareFile(OutputParams const & runparams) const GraphicsCopyStatus status; boost::tie(status, temp_file) = - copyToDirIfNeeded(params().filename.availableFile(), temp_path); + copyToDirIfNeeded(params().filename, temp_path); if (status == FAILURE) return orig_file; @@ -935,11 +903,7 @@ void InsetGraphics::addToToc(ParConstIterator const & cpit) const { TocBackend & backend = buffer().tocBackend(); - docstring str = params_.filename.displayName(); - if (params_.filename.embedded()) { - backend.toc("embedded").push_back(TocItem(cpit, 0, str)); - str += _(" (embedded)"); - } + docstring const str = params_.filename.displayName(); backend.toc("graphics").push_back(TocItem(cpit, 0, str)); } diff --git a/src/insets/InsetGraphics.h b/src/insets/InsetGraphics.h index 5f8f5aea35..dae9a701d2 100644 --- a/src/insets/InsetGraphics.h +++ b/src/insets/InsetGraphics.h @@ -56,8 +56,6 @@ private: /// InsetGraphics(InsetGraphics const &); - /// - void setBuffer(Buffer & buffer); /// bool isLabeled() const { return true; } void metrics(MetricsInfo &, Dimension &) const; @@ -92,10 +90,6 @@ private: void editGraphics(InsetGraphicsParams const &, Buffer const &) const; /// bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const; - /// all graphics can be embedded - void registerEmbeddedFiles(EmbeddedFileList &) const; - /// - void updateEmbeddedFile(EmbeddedFile const &); /// void addToToc(ParConstIterator const &) const; /// diff --git a/src/insets/InsetGraphicsParams.cpp b/src/insets/InsetGraphicsParams.cpp index 8cc2052233..35fb9bcb51 100644 --- a/src/insets/InsetGraphicsParams.cpp +++ b/src/insets/InsetGraphicsParams.cpp @@ -182,11 +182,6 @@ bool InsetGraphicsParams::Read(Lexer & lex, string const & token, string const & if (token == "filename") { lex.eatLine(); filename.set(lex.getString(), bufpath); - } else if (token == "embed") { - lex.next(); - string const name = lex.getString(); - filename.setInzipName(name); - filename.setEmbed(!name.empty()); } else if (token == "lyxscale") { lex.next(); lyxscale = lex.getInteger(); @@ -251,8 +246,7 @@ bool InsetGraphicsParams::Read(Lexer & lex, string const & token, string const & graphics::Params InsetGraphicsParams::as_grfxParams() const { graphics::Params pars; - pars.filename = filename.availableFile(); - pars.icon = filename.embedded() ? "pin.png" : ""; + pars.filename = filename; pars.scale = lyxscale; pars.angle = convert(rotateAngle); diff --git a/src/insets/InsetGraphicsParams.h b/src/insets/InsetGraphicsParams.h index 5a321ecc6a..f3429afe9b 100644 --- a/src/insets/InsetGraphicsParams.h +++ b/src/insets/InsetGraphicsParams.h @@ -16,7 +16,10 @@ #include "graphics/GraphicsTypes.h" #include "Length.h" -#include "EmbeddedFiles.h" + +#include "support/FileName.h" + +#include namespace lyx { @@ -31,7 +34,7 @@ class InsetGraphicsParams { public: /// Image filename. - EmbeddedFile filename; + support::DocFileName filename; /// Scaling the Screen inside Lyx unsigned int lyxscale; /// How to display the image inside LyX diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 130c843e9a..d56f97dc50 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -140,9 +140,10 @@ FileName const includedFilename(Buffer const & buffer, InsetCommandParams const & params) { return makeAbsPath(to_utf8(params["filename"]), - onlyPath(parentFilename(buffer))); + onlyPath(parentFilename(buffer))); } + InsetLabel * createLabel(docstring const & label_str) { if (label_str.empty()) @@ -385,8 +386,7 @@ int InsetInclude::latex(odocstream & os, OutputParams const & runparams) const if (incfile.empty()) return 0; - FileName const included_file = - includedFilename(buffer(), params()); + FileName const included_file = includedFilename(buffer(), params()); // Check we're not trying to include ourselves. // FIXME RECURSIVE INCLUDE diff --git a/src/insets/RenderGraphic.cpp b/src/insets/RenderGraphic.cpp index 3520290a97..07185ccdfe 100644 --- a/src/insets/RenderGraphic.cpp +++ b/src/insets/RenderGraphic.cpp @@ -38,16 +38,13 @@ namespace lyx { RenderGraphic::RenderGraphic(Inset const * inset) { loader_.connect(boost::bind(&Inset::updateFrontend, inset)); - icon_.connect(boost::bind(&Inset::updateFrontend, inset)); } RenderGraphic::RenderGraphic(RenderGraphic const & other, Inset const * inset) - : RenderBase(other), loader_(other.loader_), icon_(other.icon_), - params_(other.params_) + : RenderBase(other), loader_(other.loader_), params_(other.params_) { loader_.connect(boost::bind(&Inset::updateFrontend, inset)); - icon_.connect(boost::bind(&Inset::updateFrontend, inset)); } @@ -63,15 +60,6 @@ void RenderGraphic::update(graphics::Params const & params) if (!params_.filename.empty()) loader_.reset(params_.filename, params_); - // If icon is set to empty, icon_ will not be reset to empty - // but will not be displayed. This is to avoid repeated loading - // of the same icon when figure status changes. - if (!params_.icon.empty()) { - support::FileName const icon = support::libFileSearch("images/", - params_.icon, "png"); - if (!icon.empty()) // using an empty bounding box - icon_.reset(icon, graphics::Params()); - } } @@ -186,10 +174,6 @@ void RenderGraphic::draw(PainterInfo & pi, int x, int y) const loader_.startLoading(); if (!loader_.monitoring()) loader_.startMonitoring(); - if (icon_.status() == graphics::WaitingToLoad) - icon_.startLoading(); - if (!icon_.monitoring()) - icon_.startMonitoring(); } // This will draw the graphics. If the graphics has not been @@ -229,9 +213,6 @@ void RenderGraphic::draw(PainterInfo & pi, int x, int y) const y - 4, msg, msgFont); } } - if (!params_.icon.empty() && readyToDisplay(icon_)) - pi.pain.image(x + Inset::TEXT_TO_INSET_OFFSET, y - dim_.asc, - 10, 10, *icon_.image()); } diff --git a/src/insets/RenderGraphic.h b/src/insets/RenderGraphic.h index 938322fad0..5edb7ce940 100644 --- a/src/insets/RenderGraphic.h +++ b/src/insets/RenderGraphic.h @@ -45,7 +45,6 @@ private: /// The stored data. graphics::Loader loader_; - graphics::Loader icon_; graphics::Params params_; }; -- 2.39.2