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