]> git.lyx.org Git - lyx.git/blob - src/Buffer.h
corrected_env: use breakln instead of hardcoded linebreak
[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         double fontScalingFactor() const;
240
241 private:
242         ///
243         typedef std::map<Buffer const *, Buffer *> BufferMap;
244         ///
245         void cloneWithChildren(BufferMap &, CloneList *) const;
246         /// save timestamp and checksum of the given file.
247         void saveCheckSum() const;
248         /// read a new file
249         ReadStatus readFile(support::FileName const & fn);
250         /// Reads a file without header.
251         /// \param par if != 0 insert the file.
252         /// \return \c true if file is not completely read.
253         bool readDocument(Lexer &);
254         /// Try to extract the file from a version control container
255         /// before reading if the file cannot be found.
256         /// \sa LyXVC::file_not_found_hook
257         ReadStatus extractFromVC();
258         /// Reads the first tag of a LyX File and
259         /// returns the file format number.
260         ReadStatus parseLyXFormat(Lexer & lex, support::FileName const & fn,
261                 int & file_format) const;
262         /// Convert the LyX file to the LYX_FORMAT using
263         /// the lyx2lyx script and returns the filename
264         /// of the temporary file to be read
265         ReadStatus convertLyXFormat(support::FileName const & fn,
266                 support::FileName & tmpfile, int from_format);
267         //@}
268
269 public:
270         /// \name Functions involved in autosave and emergency files.
271         //@{
272         /// Save an autosave file to #filename.lyx#
273         bool autoSave() const;
274         /// save emergency file
275         /// \return a status message towards the user.
276         docstring emergencyWrite();
277
278 //FIXME:The following function should be private
279 //private:
280         ///
281         void removeAutosaveFile() const;
282
283 private:
284         /// Try to load an autosave file associated to \c fn.
285         ReadStatus loadAutosave();
286         /// Try to load an emergency file associated to \c fn.
287         ReadStatus loadEmergency();
288         /// Get the filename of the emergency file associated with the Buffer
289         support::FileName getEmergencyFileName() const;
290         /// Get the filename of the autosave file associated with the Buffer
291         support::FileName getAutosaveFileName() const;
292         ///
293         void moveAutosaveFile(support::FileName const & old) const;
294         //@}
295
296 public:
297         /// Fill in the ErrorList with the TeXErrors
298         void bufferErrors(TeXErrors const &, ErrorList &) const;
299
300         enum OutputWhat {
301                 FullSource,
302                 OnlyBody,
303                 IncludedFile,
304                 OnlyPreamble,
305                 CurrentParagraph
306         };
307
308         /// Just a wrapper for writeLaTeXSource, first creating the ofstream.
309         bool makeLaTeXFile(support::FileName const & filename,
310                            std::string const & original_path,
311                            OutputParams const &,
312                            OutputWhat output = FullSource) const;
313         /** Export the buffer to LaTeX.
314             If \p os is a file stream, and params().inputenc is "auto" or
315             "default", and the buffer contains text in different languages
316             with more than one encoding, then this method will change the
317             encoding associated to \p os. Therefore you must not call this
318             method with a string stream if the output is supposed to go to a
319             file. \code
320             ofdocstream ofs;
321             otexstream os(ofs, texrow);
322             ofs.open("test.tex");
323             writeLaTeXSource(os, ...);
324             ofs.close();
325             \endcode is NOT equivalent to \code
326             odocstringstream oss;
327             otexstream os(oss, texrow);
328             writeLaTeXSource(os, ...);
329             ofdocstream ofs;
330             ofs.open("test.tex");
331             ofs << oss.str();
332             ofs.close();
333             \endcode
334          */
335         void writeLaTeXSource(otexstream & os,
336                            std::string const & original_path,
337                            OutputParams const &,
338                            OutputWhat output = FullSource) const;
339         ///
340         void makeDocBookFile(support::FileName const & filename,
341                              OutputParams const & runparams_in,
342                              OutputWhat output = FullSource) const;
343         ///
344         void writeDocBookSource(odocstream & os, std::string const & filename,
345                              OutputParams const & runparams_in,
346                              OutputWhat output = FullSource) const;
347         ///
348         void makeLyXHTMLFile(support::FileName const & filename,
349                              OutputParams const & runparams_in) const;
350         ///
351         void writeLyXHTMLSource(odocstream & os,
352                              OutputParams const & runparams_in,
353                              OutputWhat output = FullSource) const;
354         /// returns the main language for the buffer (document)
355         Language const * language() const;
356         /// get l10n translated to the buffers language
357         docstring const B_(std::string const & l10n) const;
358
359         ///
360         int runChktex();
361         /// return true if the main lyx file does not need saving
362         bool isClean() const;
363         ///
364         bool isDepClean(std::string const & name) const;
365
366         /// whether or not disk file has been externally modified
367         bool isExternallyModified(CheckMethod method) const;
368
369         /// mark the main lyx file as not needing saving
370         void markClean() const;
371
372         ///
373         void markDepClean(std::string const & name);
374
375         ///
376         void setUnnamed(bool flag = true);
377
378         /// Whether or not a filename has been assigned to this buffer
379         bool isUnnamed() const;
380
381         /// Whether or not this buffer is internal.
382         ///
383         /// An internal buffer does not contain a real document, but some auxiliary text segment.
384         /// It is not associated with a filename, it is never saved, thus it does not need to be
385         /// automatically saved, nor it needs to trigger any "do you want to save ?" question.
386         bool isInternal() const;
387
388         void setInternal(bool flag);
389
390         /// Mark this buffer as dirty.
391         void markDirty();
392
393         /// Returns the buffer's filename. It is always an absolute path.
394         support::FileName fileName() const;
395
396         /// Returns the buffer's filename. It is always an absolute path.
397         std::string absFileName() const;
398
399         /// Returns the path where the buffer lives.
400         /// It is always an absolute path.
401         std::string filePath() const;
402
403         /** A transformed version of the file name, adequate for LaTeX.
404             \param no_path optional if \c true then the path is stripped.
405         */
406         std::string latexName(bool no_path = true) const;
407
408         /// Get the name and type of the log.
409         std::string logName(LogType * type = 0) const;
410
411         /// Set document's parent Buffer.
412         void setParent(Buffer const *);
413         Buffer const * parent() const;
414
415         /** Get the document's master (or \c this if this is not a
416             child document)
417          */
418         Buffer const * masterBuffer() const;
419
420         /// \return true if \p child is a child of this \c Buffer.
421         bool isChild(Buffer * child) const;
422
423         /// \return true if this \c Buffer has children
424         bool hasChildren() const;
425
426         /// \return a list of the direct children of this Buffer.
427         /// this list has no duplicates and is in the order in which
428         /// the children appear.
429         ListOfBuffers getChildren() const;
430
431         /// \return a list of all descendents of this Buffer (children,
432         /// grandchildren, etc). this list has no duplicates and is in
433         /// the order in which the children appear.
434         ListOfBuffers getDescendents() const;
435
436         /// Collect all relative buffers, in the order in which they appear.
437         /// I.e., the "root" Buffer is first, then its first child, then any
438         /// of its children, etc. However, there are no duplicates in this
439         /// list.
440         /// This is "stable", too, in the sense that it returns the same
441         /// thing from whichever Buffer it is called.
442         ListOfBuffers allRelatives() const;
443
444         /// Is buffer read-only?
445         bool isReadonly() const;
446
447         /// Set buffer read-only flag
448         void setReadonly(bool flag = true);
449
450         /** Validate a buffer for LaTeX.
451             This validates the buffer, and returns a struct for use by
452             #makeLaTeX# and others. Its main use is to figure out what
453             commands and packages need to be included in the LaTeX file.
454             It (should) also check that the needed constructs are there
455             (i.e. that the \refs points to coresponding \labels). It
456             should perhaps inset "error" insets to help the user correct
457             obvious mistakes.
458         */
459         void validate(LaTeXFeatures &) const;
460
461         /// Reference information is cached in the Buffer, so we do not
462         /// have to check or read things over and over.
463         ///
464         /// There are two caches.
465         ///
466         /// One is a cache of the BibTeX files from which reference info is
467         /// being gathered. This cache is PER BUFFER, and the cache for the
468         /// master essentially includes the cache for its children. This gets
469         /// invalidated when an InsetBibtex is created, deleted, or modified.
470         ///
471         /// The other is a cache of the reference information itself. This
472         /// exists only in the master buffer, and when it needs to be updated,
473         /// the children add their information to the master's cache.
474
475         /// Calling this method invalidates the cache and so requires a
476         /// re-read.
477         void invalidateBibinfoCache() const;
478         /// This invalidates the cache of files we need to check.
479         void invalidateBibfileCache() const;
480         /// Updates the cached bibliography information, checking first to see
481         /// whether the cache is valid. If so, we do nothing. If not, then we
482         /// reload all the BibTeX info.
483         /// Note that this operates on the master document.
484         void reloadBibInfoCache() const;
485         /// \return the bibliography information for this buffer's master,
486         /// or just for it, if it isn't a child.
487         BiblioInfo const & masterBibInfo() const;
488         /// collect bibliography info from the various insets in this buffer.
489         void collectBibKeys() const;
490         /// add some BiblioInfo to our cache
491         void addBiblioInfo(BiblioInfo const & bi) const;
492         /// add a single piece of bibliography info to our cache
493         void addBibTeXInfo(docstring const & key, BibTeXInfo const & bi) const;
494         ///
495         void makeCitationLabels() const;
496         ///
497         bool citeLabelsValid() const;
498         ///
499         void getLabelList(std::vector<docstring> &) const;
500
501         /// This removes the .aux and .bbl files from the temp dir.
502         void removeBiblioTempFiles() const;
503
504         ///
505         void changeLanguage(Language const * from, Language const * to);
506
507         ///
508         bool isMultiLingual() const;
509         ///
510         std::set<Language const *> getLanguages() const;
511
512         ///
513         BufferParams & params();
514         BufferParams const & params() const;
515         ///
516         BufferParams const & masterParams() const;
517
518         /** The list of paragraphs.
519             This is a linked list of paragraph, this list holds the
520             whole contents of the document.
521          */
522         ParagraphList & paragraphs();
523         ParagraphList const & paragraphs() const;
524
525         /// LyX version control object.
526         LyXVC & lyxvc();
527         LyXVC const & lyxvc() const;
528
529         /// Where to put temporary files.
530         std::string const temppath() const;
531
532         /// Used when typesetting to place errorboxes.
533         TexRow const & texrow() const;
534         TexRow & texrow();
535
536         ///
537         ParIterator par_iterator_begin();
538         ///
539         ParConstIterator par_iterator_begin() const;
540         ///
541         ParIterator par_iterator_end();
542         ///
543         ParConstIterator par_iterator_end() const;
544
545         // Position of the child buffer where it appears first in the master.
546         DocIterator firstChildPosition(Buffer const * child);
547
548         /** \returns true only when the file is fully loaded.
549          *  Used to prevent the premature generation of previews
550          *  and by the citation inset.
551          */
552         bool isFullyLoaded() const;
553         /// Set by buffer_funcs' newFile.
554         void setFullyLoaded(bool);
555
556         /// FIXME: Needed by RenderPreview.
557         graphics::PreviewLoader * loader() const;
558         /// Update the LaTeX preview snippets associated with this buffer
559         void updatePreviews() const;
560         /// Remove any previewed LaTeX snippets associated with this buffer
561         void removePreviews() const;
562
563         /// Our main text (inside the top InsetText)
564         Text & text() const;
565
566         /// Our top InsetText
567         Inset & inset() const;
568
569         //
570         // Macro handling
571         //
572         /// Collect macro definitions in paragraphs
573         void updateMacros() const;
574         /// Iterate through the whole buffer and try to resolve macros
575         void updateMacroInstances(UpdateType) const;
576
577         /// List macro names of this buffer, the parent and the children
578         void listMacroNames(MacroNameSet & macros) const;
579         /// Collect macros of the parent and its children in front of this buffer.
580         void listParentMacros(MacroSet & macros, LaTeXFeatures & features) const;
581
582         /// Return macro defined before pos (or in the master buffer)
583         MacroData const * getMacro(docstring const & name, DocIterator const & pos, bool global = true) const;
584         /// Return macro defined anywhere in the buffer (or in the master buffer)
585         MacroData const * getMacro(docstring const & name, bool global = true) const;
586         /// Return macro defined before the inclusion of the child
587         MacroData const * getMacro(docstring const & name, Buffer const & child, bool global = true) const;
588
589         /// Collect user macro names at loading time
590         typedef std::set<docstring> UserMacroSet;
591         mutable UserMacroSet usermacros;
592
593         /// Replace the inset contents for insets which InsetCode is equal
594         /// to the passed \p inset_code.
595         void changeRefsIfUnique(docstring const & from, docstring const & to);
596
597         /// get source code (latex/docbook) for some paragraphs, or all paragraphs
598         /// including preamble
599         void getSourceCode(odocstream & os, std::string const & format,
600                            pit_type par_begin, pit_type par_end, OutputWhat output,
601                            bool master) const;
602
603         /// Access to error list.
604         /// This method is used only for GUI visualisation of Buffer related
605         /// errors (like parsing or LateX compilation). This method is const
606         /// because modifying the returned ErrorList does not touch the document
607         /// contents.
608         ErrorList & errorList(std::string const & type) const;
609
610         /// The Toc backend.
611         /// This is useful only for screen visualisation of the Buffer. This
612         /// method is const because modifying this backend does not touch
613         /// the document contents.
614         TocBackend & tocBackend() const;
615
616         ///
617         Undo & undo();
618
619         /// This function is called when the buffer is changed.
620         void changed(bool update_metrics) const;
621         ///
622         void setChild(DocIterator const & dit, Buffer * child);
623         ///
624         void updateTocItem(std::string const &, DocIterator const &) const;
625         /// This function is called when the buffer structure is changed.
626         void structureChanged() const;
627         /// This function is called when some parsing error shows up.
628         void errors(std::string const & err, bool from_master = false) const;
629         /// This function is called when the buffer busy status change.
630         void setBusy(bool on) const;
631         /// Update window titles of all users.
632         void updateTitles() const;
633         /// Reset autosave timers for all users.
634         void resetAutosaveTimers() const;
635         ///
636         void message(docstring const & msg) const;
637
638         ///
639         void setGuiDelegate(frontend::GuiBufferDelegate * gui);
640         ///
641         bool hasGuiDelegate() const;
642
643         ///
644         ExportStatus doExport(std::string const & target, bool put_in_tempdir) const;
645         /// Export buffer to format \p format and open the result in a suitable viewer.
646         /// Note: This has nothing to do with preview of graphics or math formulas.
647         ExportStatus preview(std::string const & format) const;
648
649 private:
650         ///
651         ExportStatus doExport(std::string const & target, bool put_in_tempdir,
652                 std::string & result_file) const;
653         /// target is a format name optionally followed by a space
654         /// and a destination file-name
655         ExportStatus doExport(std::string const & target, bool put_in_tempdir,
656                 bool includeall, std::string & result_file) const;
657         ///
658         ExportStatus preview(std::string const & format, bool includeall = false) const;
659         ///
660         void setMathFlavor(OutputParams & op) const;
661
662 public:
663         ///
664         bool isExporting() const;
665
666         ///
667         typedef std::vector<std::pair<Inset *, ParIterator> > References;
668         ///
669         References const & references(docstring const & label) const;
670         ///
671         void addReference(docstring const & label, Inset * inset, ParIterator it);
672         ///
673         void clearReferenceCache() const;
674         ///
675         void setInsetLabel(docstring const & label, InsetLabel const * il);
676         ///
677         InsetLabel const * insetLabel(docstring const & label) const;
678
679         /// return a list of all used branches (also in children)
680         void getUsedBranches(std::list<docstring> &, bool const from_master = false) const;
681
682         /// sets the buffer_ member for every inset in this buffer.
683         // FIXME This really shouldn't be needed, but at the moment it's not
684         // clear how to do it just for the individual pieces we need.
685         void setBuffersForInsets() const;
686         /// Updates screen labels and some other information associated with
687         /// insets and paragraphs. Actually, it's more like a general "recurse
688         /// through the Buffer" routine, that visits all the insets and paragraphs.
689         void updateBuffer() const { updateBuffer(UpdateMaster, InternalUpdate); }
690         /// \param scope: whether to start with the master document or just
691         /// do this one.
692         /// \param output: whether we are preparing for output.
693         void updateBuffer(UpdateScope scope, UpdateType utype) const;
694         ///
695         void updateBuffer(ParIterator & parit, UpdateType utype) const;
696
697         /// Spellcheck starting from \p from.
698         /// \p from initial position, will then points to the next misspelled
699         ///    word.
700         /// \p to will points to the end of the next misspelled word.
701         /// \p word_lang will contain the found misspelled word.
702         /// \return progress if a new word was found.
703         int spellCheck(DocIterator & from, DocIterator & to,
704                 WordLangTuple & word_lang, docstring_list & suggestions) const;
705         ///
706         void checkChildBuffers();
707         ///
708         void checkMasterBuffer();
709
710         /// compute statistics between \p from and \p to
711         /// \p from initial position
712         /// \p to points to the end position
713         /// \p skipNoOutput if notes etc. should be ignored
714         void updateStatistics(DocIterator & from, DocIterator & to,
715                                                   bool skipNoOutput = true) const;
716         /// statistics accessor functions
717         int wordCount() const;
718         int charCount(bool with_blanks) const;
719
720 private:
721         friend class MarkAsExporting;
722         /// mark the buffer as busy exporting something, or not
723         void setExportStatus(bool e) const;
724
725         ///
726         References & getReferenceCache(docstring const & label);
727         /// Change name of buffer. Updates "read-only" flag.
728         void setFileName(support::FileName const & fname);
729         ///
730         void getLanguages(std::set<Language const *> &) const;
731         /// Checks whether any of the referenced bibfiles have changed since the
732         /// last time we loaded the cache. Note that this does NOT update the
733         /// cached information.
734         void checkIfBibInfoCacheIsValid() const;
735         /// Update the list of all bibfiles in use (including bibfiles
736         /// of loaded child documents).
737         void updateBibfilesCache(UpdateScope scope = UpdateMaster) const;
738         /// Return the list with all bibfiles in use (including bibfiles
739         /// of loaded child documents).
740         support::FileNameList const &
741                 getBibfilesCache(UpdateScope scope = UpdateMaster) const;
742         ///
743         void collectChildren(ListOfBuffers & children, bool grand_children) const;
744
745         /// noncopyable
746         Buffer(Buffer const &);
747         void operator=(Buffer const &);
748
749         /// Use the Pimpl idiom to hide the internals.
750         class Impl;
751         /// The pointer never changes although *pimpl_'s contents may.
752         Impl * const d;
753 };
754
755
756 /// Helper class, to guarantee that the export status
757 /// gets reset properly. To use, simply create a local variable:
758 ///    MarkAsExporting mex(bufptr);
759 /// and leave the rest to us.
760 class MarkAsExporting {
761 public:
762         MarkAsExporting(Buffer const * buf) : buf_(buf)
763         {
764                 buf_->setExportStatus(true);
765         }
766         ~MarkAsExporting()
767         {
768                 buf_->setExportStatus(false);
769         }
770 private:
771         Buffer const * const buf_;
772 };
773
774
775 } // namespace lyx
776
777 #endif