class EmbeddedFile : public support::DocFileName
{
public:
+ EmbeddedFile() {};
+
EmbeddedFile(std::string const & file, std::string const & inzip_name,
bool embedded, Inset const * inset);
/// filename in the zip file, usually the relative path
std::string inzipName() const { return inzip_name_; }
+ void setInzipName(std::string name) { inzip_name_ = name; }
/// embedded file, equals to temppath()/inzipName()
std::string embeddedFile(Buffer const * buf) const;
/// embeddedFile() or absFilename() depending on embedding status
bool extract(Buffer const * buf) const;
/// update embedded file from external file, does not change embedding status
bool updateFromExternalFile(Buffer const * buf) const;
+ ///
+ /// After the embedding status is changed, update all insets related
+ /// to this file item.
+ /// Because inset pointers may not be up to date, EmbeddedFiles::update()
+ /// would better be called before this function is called.
+ void updateInsets(Buffer const * buf) const;
private:
/// filename in zip file
typedef std::vector<EmbeddedFile> EmbeddedFileList;
public:
///
- EmbeddedFiles(Buffer * buffer = NULL): file_list_(), buffer_(buffer) {}
+ EmbeddedFiles(Buffer * buffer = 0) : file_list_(), buffer_(buffer) {}
///
~EmbeddedFiles() {}
bool enabled() const;
/// set buffer params embedded flag. Files will be updated or extracted
/// if such an operation fails, enable will fail.
- bool enable(bool flag);
+ void enable(bool flag);
/// add a file item.
/* \param filename filename to add
* \param inset Inset pointer
* \param inzipName suggested inzipname
*/
- void registerFile(std::string const & filename, bool embed = false,
- Inset const * inset = NULL,
+ EmbeddedFile & registerFile(std::string const & filename, bool embed = false,
+ Inset const * inset = 0,
std::string const & inzipName = std::string());
/// scan the buffer and get a list of EmbeddedFile
/// update all files from external, used when enable embedding
bool updateFromExternalFile() const;
///
- bool readManifest(Lexer & lex, ErrorList & errorList);
- void writeManifest(std::ostream & os) const;
+ /// update all insets to use embedded files when embedding status is changed
+ void updateInsets() const;
private:
/// get a unique inzip name, a suggestion can be given.
std::string const getInzipName(std::string const & name, std::string const & inzipName);
Buffer * buffer_;
};
+} // namespace lyx
-}
#endif