]> git.lyx.org Git - lyx.git/blob - src/Buffer.h
configure.py: Check path accessibility before call to os.path.isfile.
[lyx.git] / src / Buffer.h
1 // -*- C++ -*-
2 /**
3  * \file Buffer.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef BUFFER_H
13 #define BUFFER_H
14
15 #include "OutputEnums.h"
16 #include "OutputParams.h"
17
18 #include "insets/InsetCode.h"
19
20 #include "support/strfwd.h"
21 #include "support/types.h"
22
23 #include <map>
24 #include <list>
25 #include <set>
26 #include <string>
27 #include <vector>
28
29
30 namespace lyx {
31
32 class BiblioInfo;
33 class BibTeXInfo;
34 class BufferParams;
35 class DispatchResult;
36 class DocIterator;
37 class docstring_list;
38 class ErrorList;
39 class FuncRequest;
40 class FuncStatus;
41 class Inset;
42 class InsetLabel;
43 class InsetRef;
44 class Font;
45 class Format;
46 class Lexer;
47 class Text;
48 class LyXVC;
49 class LaTeXFeatures;
50 class Language;
51 class MacroData;
52 class MacroNameSet;
53 class MacroSet;
54 class OutputParams;
55 class Paragraph;
56 class ParConstIterator;
57 class ParIterator;
58 class ParagraphList;
59 class TeXErrors;
60 class TexRow;
61 class TocBackend;
62 class Undo;
63 class WordLangTuple;
64
65 namespace frontend {
66 class GuiBufferDelegate;
67 class WorkAreaManager;
68 }
69
70 namespace support {
71 class FileName;
72 class FileNameList;
73 }
74
75 namespace graphics {
76 class PreviewLoader;
77 }
78
79
80 class Buffer;
81 typedef std::list<Buffer *> ListOfBuffers;
82 /// a list of Buffers we cloned
83 typedef std::set<Buffer *> CloneList;
84
85
86 /** The buffer object.
87  * This is the buffer object. It contains all the information about
88  * a document loaded into LyX.
89  * The buffer object owns the Text (wrapped in an InsetText), which
90  * contains the individual paragraphs of the document.
91  *
92  *
93  * I am not sure if the class is complete or
94  * minimal, probably not.
95  * \author Lars Gullik Bjønnes
96  */
97
98 class MarkAsExporting;
99
100 class Buffer {
101 public:
102         /// What type of log will \c getLogName() return?
103         enum LogType {
104                 latexlog, ///< LaTeX log
105                 buildlog  ///< Literate build log
106         };
107
108         /// Result of \c readFile()
109         enum ReadStatus {
110                 ReadSuccess,
111                 ReadCancel,
112                 // failures
113                 ReadFailure,
114                 ReadWrongVersion,
115                 ReadFileNotFound,
116                 ReadVCError,
117                 ReadAutosaveFailure,
118                 ReadEmergencyFailure,
119                 ReadNoLyXFormat,
120                 ReadDocumentFailure,
121                 // lyx2lyx
122                 LyX2LyXNoTempFile,
123                 LyX2LyXNotFound,
124                 LyX2LyXOlderFormat,
125                 LyX2LyXNewerFormat,
126                 // other
127                 ReadOriginal
128         };
129
130         enum ExportStatus {
131                 // export
132                 ExportSuccess,
133                 ExportCancel,
134                 ExportError,
135                 ExportNoPathToFormat,
136                 ExportTexPathHasSpaces,
137                 ExportConverterError,
138                 // preview
139                 PreviewSuccess,
140                 PreviewError
141         };
142
143         /// Method to check if a file is externally modified, used by
144         /// isExternallyModified()
145         /**
146          * timestamp is fast but inaccurate. For example, the granularity
147          * of timestamp on a FAT filesystem is 2 seconds. Also, various operations
148          * may touch the timestamp of a file even when its content is unchanged.
149          *
150          * checksum is accurate but slow, which can be a problem when it is
151          * frequently used, or used for a large file on a slow (network) file
152          * system.
153          *
154          * FIXME: replace this method with support/FileMonitor.
155          */
156         enum CheckMethod {
157                 checksum_method, ///< Use file checksum
158                 timestamp_method ///< Use timestamp, and checksum if timestamp has changed
159         };
160
161         ///
162         enum UpdateScope {
163                 UpdateMaster,
164                 UpdateChildOnly
165         };
166
167         /// Constructor
168         explicit Buffer(std::string const & file, bool readonly = false,
169                 Buffer const * cloned_buffer = 0);
170
171         /// Destructor
172         ~Buffer();
173
174         /// Clones the entire structure of which this Buffer is part, starting
175         /// with the master and cloning all the children, too.
176         Buffer * cloneFromMaster() const;
177         /// Just clones this single Buffer. For autosave.
178         Buffer * cloneBufferOnly() const;
179         ///
180         bool isClone() const;
181
182         /** High-level interface to buffer functionality.
183             This function parses a command string and executes it.
184         */
185         void dispatch(std::string const & command, DispatchResult & result);
186
187         /// Maybe we know the function already by number...
188         void dispatch(FuncRequest const & func, DispatchResult & result);
189
190         /// Can this function be exectued?
191         /// \return true if we made a decision
192         bool getStatus(FuncRequest const & cmd, FuncStatus & flag);
193
194         ///
195         DocIterator getParFromID(int id) const;
196         /// do we have a paragraph with this id?
197         bool hasParWithID(int id) const;
198
199         ///
200         frontend::WorkAreaManager & workAreaManager() const;
201
202         /** Save file.
203             Takes care of auto-save files and backup file if requested.
204             Returns \c true if the save is successful, \c false otherwise.
205         */
206         bool save() const;
207         /// Renames and saves the buffer
208         bool saveAs(support::FileName const & fn);
209
210         /// Write document to stream. Returns \c false if unsuccessful.
211         bool write(std::ostream &) const;
212         /// Write file. Returns \c false if unsuccessful.
213         bool writeFile(support::FileName const &) const;
214
215         /// \name Functions involved in reading files/strings.
216         //@{
217         /// Loads the LyX file into the buffer. This function
218         /// tries to extract the file from version control if it
219         /// cannot be found. If it can be found, it will try to
220         /// read an emergency save file or an autosave file.
221         /// \sa loadThisLyXFile
222         ReadStatus loadLyXFile();
223         /// Loads the LyX file \c fn into the buffer. If you want
224         /// to check for files in a version control container,
225         /// emergency or autosave files, one should use \c loadLyXFile.
226         /// /sa loadLyXFile
227         ReadStatus loadThisLyXFile(support::FileName const & fn);
228         /// import a new document from a string
229         bool importString(std::string const &, docstring const &, ErrorList &);
230         /// import a new file
231         bool importFile(std::string const &, support::FileName const &, ErrorList &);
232         /// read a new document from a string
233         bool readString(std::string const &);
234         /// Reloads the LyX file
235         /// \param clearUndo if false, leave alone the undo stack.
236         ReadStatus reload(bool clearUndo = true);
237 //FIXME: The following function should be private
238 //private:
239         /// read the header, returns number of unknown tokens
240         int readHeader(Lexer & lex);
241
242 private:
243         ///
244         typedef std::map<Buffer const *, Buffer *> BufferMap;
245         ///
246         void cloneWithChildren(BufferMap &, CloneList *) const;
247         /// save timestamp and checksum of the given file.
248         void saveCheckSum() const;
249         /// read a new file
250         ReadStatus readFile(support::FileName const & fn);
251         /// Reads a file without header.
252         /// \param par if != 0 insert the file.
253         /// \return \c true if file is not completely read.
254         bool readDocument(Lexer &);
255         /// Try to extract the file from a version control container
256         /// before reading if the file cannot be found.
257         /// \sa LyXVC::file_not_found_hook
258         ReadStatus extractFromVC();
259         /// Reads the first tag of a LyX File and
260         /// returns the file format number.
261         ReadStatus parseLyXFormat(Lexer & lex, support::FileName const & fn,
262                 int & file_format) const;
263         /// Convert the LyX file to the LYX_FORMAT using
264         /// the lyx2lyx script and returns the filename
265         /// of the temporary file to be read
266         ReadStatus convertLyXFormat(support::FileName const & fn,
267                 support::FileName & tmpfile, int from_format);
268         //@}
269
270 public:
271         /// \name Functions involved in autosave and emergency files.
272         //@{
273         /// Save an autosave file to #filename.lyx#
274         bool autoSave() const;
275         /// save emergency file
276         /// \return a status message towards the user.
277         docstring emergencyWrite();
278
279 //FIXME:The following function should be private
280 //private:
281         ///
282         void removeAutosaveFile() const;
283
284 private:
285         /// Try to load an autosave file associated to \c fn.
286         ReadStatus loadAutosave();
287         /// Try to load an emergency file associated to \c fn.
288         ReadStatus loadEmergency();
289         /// Get the filename of the emergency file associated with the Buffer
290         support::FileName getEmergencyFileName() const;
291         /// Get the filename of the autosave file associated with the Buffer
292         support::FileName getAutosaveFileName() const;
293         ///
294         void moveAutosaveFile(support::FileName const & old) const;
295         //@}
296
297 public:
298         /// Fill in the ErrorList with the TeXErrors
299         void bufferErrors(TeXErrors const &, ErrorList &) const;
300
301         enum OutputWhat {
302                 FullSource,
303                 OnlyBody,
304                 IncludedFile,
305                 OnlyPreamble,
306                 CurrentParagraph
307         };
308
309         /// Just a wrapper for writeLaTeXSource, first creating the ofstream.
310         bool makeLaTeXFile(support::FileName const & filename,
311                            std::string const & original_path,
312                            OutputParams const &,
313                            OutputWhat output = FullSource) const;
314         /** Export the buffer to LaTeX.
315             If \p os is a file stream, and params().inputenc is "auto" or
316             "default", and the buffer contains text in different languages
317             with more than one encoding, then this method will change the
318             encoding associated to \p os. Therefore you must not call this
319             method with a string stream if the output is supposed to go to a
320             file. \code
321             ofdocstream ofs;
322             otexstream os(ofs, texrow);
323             ofs.open("test.tex");
324             writeLaTeXSource(os, ...);
325             ofs.close();
326             \endcode is NOT equivalent to \code
327             odocstringstream oss;
328             otexstream os(oss, texrow);
329             writeLaTeXSource(os, ...);
330             ofdocstream ofs;
331             ofs.open("test.tex");
332             ofs << oss.str();
333             ofs.close();
334             \endcode
335          */
336         void writeLaTeXSource(otexstream & os,
337                            std::string const & original_path,
338                            OutputParams const &,
339                            OutputWhat output = FullSource) const;
340         ///
341         void makeDocBookFile(support::FileName const & filename,
342                              OutputParams const & runparams_in,
343                              OutputWhat output = FullSource) const;
344         ///
345         void writeDocBookSource(odocstream & os, std::string const & filename,
346                              OutputParams const & runparams_in,
347                              OutputWhat output = FullSource) const;
348         ///
349         void makeLyXHTMLFile(support::FileName const & filename,
350                              OutputParams const & runparams_in) const;
351         ///
352         void writeLyXHTMLSource(odocstream & os,
353                              OutputParams const & runparams_in,
354                              OutputWhat output = FullSource) const;
355         /// returns the main language for the buffer (document)
356         Language const * language() const;
357         /// get l10n translated to the buffers language
358         docstring const B_(std::string const & l10n) const;
359
360         ///
361         int runChktex();
362         /// return true if the main lyx file does not need saving
363         bool isClean() const;
364         ///
365         bool isDepClean(std::string const & name) const;
366
367         /// whether or not disk file has been externally modified
368         bool isExternallyModified(CheckMethod method) const;
369
370         /// mark the main lyx file as not needing saving
371         void markClean() const;
372
373         ///
374         void markDepClean(std::string const & name);
375
376         ///
377         void setUnnamed(bool flag = true);
378
379         /// Whether or not a filename has been assigned to this buffer
380         bool isUnnamed() const;
381
382         /// Whether or not this buffer is internal.
383         ///
384         /// An internal buffer does not contain a real document, but some auxiliary text segment.
385         /// It is not associated with a filename, it is never saved, thus it does not need to be
386         /// automatically saved, nor it needs to trigger any "do you want to save ?" question.
387         bool isInternal() const;
388
389         void setInternal(bool flag);
390
391         /// Mark this buffer as dirty.
392         void markDirty();
393
394         /// Returns the buffer's filename. It is always an absolute path.
395         support::FileName fileName() const;
396
397         /// Returns the buffer's filename. It is always an absolute path.
398         std::string absFileName() const;
399
400         /// Returns the path where the buffer lives.
401         /// It is always an absolute path.
402         std::string filePath() const;
403
404         /** A transformed version of the file name, adequate for LaTeX.
405             \param no_path optional if \c true then the path is stripped.
406         */
407         std::string latexName(bool no_path = true) const;
408
409         /// Get the name and type of the log.
410         std::string logName(LogType * type = 0) const;
411
412         /// Set document's parent Buffer.
413         void setParent(Buffer const *);
414         Buffer const * parent() const;
415
416         /** Get the document's master (or \c this if this is not a
417             child document)
418          */
419         Buffer const * masterBuffer() const;
420
421         /// \return true if \p child is a child of this \c Buffer.
422         bool isChild(Buffer * child) const;
423
424         /// \return true if this \c Buffer has children
425         bool hasChildren() const;
426
427         /// \return a list of the direct children of this Buffer.
428         /// this list has no duplicates and is in the order in which
429         /// the children appear.
430         ListOfBuffers getChildren() const;
431
432         /// \return a list of all descendents of this Buffer (children,
433         /// grandchildren, etc). this list has no duplicates and is in
434         /// the order in which the children appear.
435         ListOfBuffers getDescendents() const;
436
437         /// Collect all relative buffers, in the order in which they appear.
438         /// I.e., the "root" Buffer is first, then its first child, then any
439         /// of its children, etc. However, there are no duplicates in this
440         /// list.
441         /// This is "stable", too, in the sense that it returns the same
442         /// thing from whichever Buffer it is called.
443         ListOfBuffers allRelatives() const;
444
445         /// Is buffer read-only?
446         bool isReadonly() const;
447
448         /// Set buffer read-only flag
449         void setReadonly(bool flag = true);
450
451         /** Validate a buffer for LaTeX.
452             This validates the buffer, and returns a struct for use by
453             #makeLaTeX# and others. Its main use is to figure out what
454             commands and packages need to be included in the LaTeX file.
455             It (should) also check that the needed constructs are there
456             (i.e. that the \refs points to coresponding \labels). It
457             should perhaps inset "error" insets to help the user correct
458             obvious mistakes.
459         */
460         void validate(LaTeXFeatures &) const;
461
462         /// Reference information is cached in the Buffer, so we do not
463         /// have to check or read things over and over.
464         ///
465         /// There are two caches.
466         ///
467         /// One is a cache of the BibTeX files from which reference info is
468         /// being gathered. This cache is PER BUFFER, and the cache for the
469         /// master essentially includes the cache for its children. This gets
470         /// invalidated when an InsetBibtex is created, deleted, or modified.
471         ///
472         /// The other is a cache of the reference information itself. This
473         /// exists only in the master buffer, and when it needs to be updated,
474         /// the children add their information to the master's cache.
475
476         /// Calling this method invalidates the cache and so requires a
477         /// re-read.
478         void invalidateBibinfoCache() const;
479         /// This invalidates the cache of files we need to check.
480         void invalidateBibfileCache() const;
481         /// Updates the cached bibliography information, checking first to see
482         /// whether the cache is valid. If so, we do nothing. If not, then we
483         /// reload all the BibTeX info.
484         /// Note that this operates on the master document.
485         void reloadBibInfoCache() const;
486         /// \return the bibliography information for this buffer's master,
487         /// or just for it, if it isn't a child.
488         BiblioInfo const & masterBibInfo() const;
489         /// collect bibliography info from the various insets in this buffer.
490         void collectBibKeys() const;
491         /// add some BiblioInfo to our cache
492         void addBiblioInfo(BiblioInfo const & bi) const;
493         /// add a single piece of bibliography info to our cache
494         void addBibTeXInfo(docstring const & key, BibTeXInfo const & bi) const;
495         ///
496         void makeCitationLabels() const;
497         ///
498         bool citeLabelsValid() const;
499         ///
500         void getLabelList(std::vector<docstring> &) const;
501
502         /// This removes the .aux and .bbl files from the temp dir.
503         void removeBiblioTempFiles() const;
504
505         ///
506         void changeLanguage(Language const * from, Language const * to);
507
508         ///
509         bool isMultiLingual() const;
510         ///
511         std::set<Language const *> getLanguages() const;
512
513         ///
514         BufferParams & params();
515         BufferParams const & params() const;
516
517         /** The list of paragraphs.
518             This is a linked list of paragraph, this list holds the
519             whole contents of the document.
520          */
521         ParagraphList & paragraphs();
522         ParagraphList const & paragraphs() const;
523
524         /// LyX version control object.
525         LyXVC & lyxvc();
526         LyXVC const & lyxvc() const;
527
528         /// Where to put temporary files.
529         std::string const temppath() const;
530
531         /// Used when typesetting to place errorboxes.
532         TexRow const & texrow() const;
533         TexRow & texrow();
534
535         ///
536         ParIterator par_iterator_begin();
537         ///
538         ParConstIterator par_iterator_begin() const;
539         ///
540         ParIterator par_iterator_end();
541         ///
542         ParConstIterator par_iterator_end() const;
543
544         // Position of the child buffer where it appears first in the master.
545         DocIterator firstChildPosition(Buffer const * child);
546
547         /** \returns true only when the file is fully loaded.
548          *  Used to prevent the premature generation of previews
549          *  and by the citation inset.
550          */
551         bool isFullyLoaded() const;
552         /// Set by buffer_funcs' newFile.
553         void setFullyLoaded(bool);
554
555         /// FIXME: Needed by RenderPreview.
556         graphics::PreviewLoader * loader() const;
557         /// Update the LaTeX preview snippets associated with this buffer
558         void updatePreviews() const;
559         /// Remove any previewed LaTeX snippets associated with this buffer
560         void removePreviews() const;
561
562         /// Our main text (inside the top InsetText)
563         Text & text() const;
564
565         /// Our top InsetText
566         Inset & inset() const;
567
568         //
569         // Macro handling
570         //
571         /// Collect macro definitions in paragraphs
572         void updateMacros() const;
573         /// Iterate through the whole buffer and try to resolve macros
574         void updateMacroInstances(UpdateType) const;
575
576         /// List macro names of this buffer, the parent and the children
577         void listMacroNames(MacroNameSet & macros) const;
578         /// Collect macros of the parent and its children in front of this buffer.
579         void listParentMacros(MacroSet & macros, LaTeXFeatures & features) const;
580
581         /// Return macro defined before pos (or in the master buffer)
582         MacroData const * getMacro(docstring const & name, DocIterator const & pos, bool global = true) const;
583         /// Return macro defined anywhere in the buffer (or in the master buffer)
584         MacroData const * getMacro(docstring const & name, bool global = true) const;
585         /// Return macro defined before the inclusion of the child
586         MacroData const * getMacro(docstring const & name, Buffer const & child, bool global = true) const;
587
588         /// Collect user macro names at loading time
589         typedef std::set<docstring> UserMacroSet;
590         mutable UserMacroSet usermacros;
591
592         /// Replace the inset contents for insets which InsetCode is equal
593         /// to the passed \p inset_code.
594         void changeRefsIfUnique(docstring const & from, docstring const & to);
595
596         /// get source code (latex/docbook) for some paragraphs, or all paragraphs
597         /// including preamble
598         void getSourceCode(odocstream & os, std::string const format,
599                            pit_type par_begin, pit_type par_end, OutputWhat output,
600                            bool master) const;
601
602         /// Access to error list.
603         /// This method is used only for GUI visualisation of Buffer related
604         /// errors (like parsing or LateX compilation). This method is const
605         /// because modifying the returned ErrorList does not touch the document
606         /// contents.
607         ErrorList & errorList(std::string const & type) const;
608
609         /// The Toc backend.
610         /// This is useful only for screen visualisation of the Buffer. This
611         /// method is const because modifying this backend does not touch
612         /// the document contents.
613         TocBackend & tocBackend() const;
614
615         ///
616         Undo & undo();
617
618         /// This function is called when the buffer is changed.
619         void changed(bool update_metrics) const;
620         ///
621         void setChild(DocIterator const & dit, Buffer * child);
622         ///
623         void updateTocItem(std::string const &, DocIterator const &) const;
624         /// This function is called when the buffer structure is changed.
625         void structureChanged() const;
626         /// This function is called when some parsing error shows up.
627         void errors(std::string const & err, bool from_master = false) const;
628         /// This function is called when the buffer busy status change.
629         void setBusy(bool on) const;
630         /// Update window titles of all users.
631         void updateTitles() const;
632         /// Reset autosave timers for all users.
633         void resetAutosaveTimers() const;
634         ///
635         void message(docstring const & msg) const;
636
637         ///
638         void setGuiDelegate(frontend::GuiBufferDelegate * gui);
639         ///
640         bool hasGuiDelegate() const;
641
642         ///
643         ExportStatus doExport(std::string const & target, bool put_in_tempdir) const;
644         ///
645         ExportStatus doExport(std::string const & target, bool put_in_tempdir,
646                 std::string & result_file) const;
647         ///
648         ExportStatus preview(std::string const & format) const;
649
650 private:
651         /// target is a format name optionally followed by a space
652         /// and a destination file-name
653         ExportStatus doExport(std::string const & target, bool put_in_tempdir,
654                 bool includeall, std::string & result_file) const;
655         ///
656         ExportStatus doExport(std::string const & target, bool put_in_tempdir,
657                 bool includeall) const;
658         ///
659         ExportStatus preview(std::string const & format, bool includeall = false) const;
660         ///
661         void setMathFlavor(OutputParams & op) const;
662
663 public:
664         ///
665         bool isExporting() const;
666
667         ///
668         typedef std::vector<std::pair<Inset *, ParIterator> > References;
669         ///
670         References const & references(docstring const & label) const;
671         ///
672         void addReference(docstring const & label, Inset * inset, ParIterator it);
673         ///
674         void clearReferenceCache() const;
675         ///
676         void setInsetLabel(docstring const & label, InsetLabel const * il);
677         ///
678         InsetLabel const * insetLabel(docstring const & label) const;
679
680         /// return a list of all used branches (also in children)
681         void getUsedBranches(std::list<docstring> &, bool const from_master = false) const;
682
683         /// sets the buffer_ member for every inset in this buffer.
684         // FIXME This really shouldn't be needed, but at the moment it's not
685         // clear how to do it just for the individual pieces we need.
686         void setBuffersForInsets() const;
687         /// Updates screen labels and some other information associated with
688         /// insets and paragraphs. Actually, it's more like a general "recurse
689         /// through the Buffer" routine, that visits all the insets and paragraphs.
690         void updateBuffer() const { updateBuffer(UpdateMaster, InternalUpdate); }
691         /// \param scope: whether to start with the master document or just
692         /// do this one.
693         /// \param output: whether we are preparing for output.
694         void updateBuffer(UpdateScope scope, UpdateType utype) const;
695         ///
696         void updateBuffer(ParIterator & parit, UpdateType utype) const;
697
698         /// Spellcheck starting from \p from.
699         /// \p from initial position, will then points to the next misspelled
700         ///    word.
701         /// \p to will points to the end of the next misspelled word.
702         /// \p word_lang will contain the found misspelled word.
703         /// \return progress if a new word was found.
704         int spellCheck(DocIterator & from, DocIterator & to,
705                 WordLangTuple & word_lang, docstring_list & suggestions) const;
706         ///
707         void checkChildBuffers();
708         ///
709         void checkMasterBuffer();
710
711         /// compute statistics between \p from and \p to
712         /// \p from initial position
713         /// \p to points to the end position
714         /// \p skipNoOutput if notes etc. should be ignored
715         void updateStatistics(DocIterator & from, DocIterator & to,
716                                                   bool skipNoOutput = true) const;
717         /// statistics accessor functions
718         int wordCount() const;
719         int charCount(bool with_blanks) const;
720
721 private:
722         friend class MarkAsExporting;
723         /// mark the buffer as busy exporting something, or not
724         void setExportStatus(bool e) const;
725
726         ///
727         References & getReferenceCache(docstring const & label);
728         /// Change name of buffer. Updates "read-only" flag.
729         void setFileName(support::FileName const & fname);
730         ///
731         void getLanguages(std::set<Language const *> &) const;
732         /// Checks whether any of the referenced bibfiles have changed since the
733         /// last time we loaded the cache. Note that this does NOT update the
734         /// cached information.
735         void checkIfBibInfoCacheIsValid() const;
736         /// Update the list of all bibfiles in use (including bibfiles
737         /// of loaded child documents).
738         void updateBibfilesCache(UpdateScope scope = UpdateMaster) const;
739         /// Return the list with all bibfiles in use (including bibfiles
740         /// of loaded child documents).
741         support::FileNameList const &
742                 getBibfilesCache(UpdateScope scope = UpdateMaster) const;
743         ///
744         void collectChildren(ListOfBuffers & children, bool grand_children) const;
745
746         /// noncopyable
747         Buffer(Buffer const &);
748         void operator=(Buffer const &);
749
750         /// Use the Pimpl idiom to hide the internals.
751         class Impl;
752         /// The pointer never changes although *pimpl_'s contents may.
753         Impl * const d;
754 };
755
756
757 /// Helper class, to guarantee that the export status
758 /// gets reset properly. To use, simply create a local variable:
759 ///    MarkAsExporting mex(bufptr);
760 /// and leave the rest to us.
761 class MarkAsExporting {
762 public:
763         MarkAsExporting(Buffer const * buf) : buf_(buf)
764         {
765                 buf_->setExportStatus(true);
766         }
767         ~MarkAsExporting()
768         {
769                 buf_->setExportStatus(false);
770         }
771 private:
772         Buffer const * const buf_;
773 };
774
775
776 } // namespace lyx
777
778 #endif