On Wed, Aug 22, 2007 at 02:50:09PM -0500, Bo Peng wrote: > I was told that no patch should break autotools, so here it is an > updated patch with autotools support.
Good boy. Andre' > + > + > +Expected features: > +========================= > + > +1. With embedding enabled (disabled by default), .lyx file can embed > graphics, > +listings, bib file etc. > + > +2. Embedding of certain files are automatic (graphics, bib etc), and > +other files can be embedded manually. > + > +3. Embedded file.lyx file is a zip file, with file.lyx, manifest.txt > +and embedded files. There is no subdirectory in this zip file (with current > +implementation). > + > +4. If no file is embedded, file.lyx is in plain text format. This is desired > +by many users because pure-text format allows easy manipulation and better > +version control. > + > +5. Embedded files can be "EMBEDDED", "EXTERNAL", or "AUTO". In the > +"AUTO" mode, external files will be used if available; otherwise the > +embedded version will be used. In this way, users can work as usual by > +modifying external listings, graphics, and do not have to worry about > +embedding. "EMBEDDED" and "EXTERNAL" modes ignore or use external files > +respectively. > + > +6. An embedding dialog is provided to change embedding status (buffer > +level or individual embedded files), manually embed, extract, view > +or edit files. > + > +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. The advantage of lyx' embedding approach is that external files > +will be automatically used and embedded if the file is in "AUTO" mode. > + > + > +Implementation: > +====================== > + > +1. An EmbeddedFiles class is implemented to keep the embedded files ( > +class EmbeddedFile). (c.f. src/EmbeddedFiles.[h|cpp]) > +This class keeps a manifest that has > + a. external relative filename > + b. inzip filename (no directory structure), name aliasing is used if > + two external files share the same name. > + c. embedding mode. > +It also provides functions to > + a. manipulate manifest > + b. scan a buffer for embeddable files > + c. look up inzipname from external filename > + d. look up external filename from inzipname > + > +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() first. > +If there is any embedded files, these files are compressed along with > +file.lyx and a manifest.txt. If there is no embedded file, or if > +embedding is disabled, file.lyx is saved in the usual pure-text form. > +(c.f. Buffer::writeFile(), EmbeddedFiles::write()) > + > +4. When a lyx file.lyx file is opened, if it is a zip file, it is > +decompressed to tmppath(). If manifest.txt and file.lyx exists in > +tmppath(), the manifest is read to buffer, and tmppath()/file.lyx is > +read as usual. If file.lyx is not a zip file, it is read as usual. > +(c.f. bool Buffer::readFile()) > + > +5. A menu item Document -> Embedded Files is provided to open > +a embedding dialog. It handles a EmbddedFiles point directly. > +From this dialog, a user can disable embedding, change embedding status, > +or embed other files, extract, view, edit files. > + > +6. When a lyx file is loaded, Embedded files can have > + a. both external and internal copy > + b. only external copy (filename()) > + c. only embedded copy (temppath()/inzipname) > +And each can have "AUTO", "EXTERNAL", "EMBEDDED" status. Proper > +handling of each case is required. > + > +7. 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. > + > +8. Individual embeddable insets should find ways to handle embedded files. > +InsetGraphics replace params().filename with its temppath()/inzipname version > +when the inset is created. The filename appears as /tmp/..../inzipname > +when lyx runs. When params().filename is saved, lyx checks if this is an > +embedded file (check path == temppath()), if so, save filename() instead. > +(c.f. InsetGraphic::read(), InsetGraphics::edit(), > InsetGraphicsParams::write()) > + PS: And that is really nice.