]> git.lyx.org Git - lyx.git/blob - src/Exporter.h
Avoid full metrics computation with Update:FitCursor
[lyx.git] / src / Exporter.h
1 // -*- C++ -*-
2 /**
3  * \file Exporter.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  * \author Jean-Marc Lasgouttes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef EXPORTER_H
14 #define EXPORTER_H
15
16 #include "support/FileName.h"
17
18 #include <map>
19 #include <string>
20 #include <vector>
21
22
23 namespace lyx {
24
25 enum CopyStatus {
26         SUCCESS,
27         FORCE,
28         CANCEL
29 };
30
31
32 /** copy file \p sourceFile to \p destFile. If \p force is false, the user
33  *  will be asked before existing files are overwritten. If \p only_tmp
34  *  is true, then only copy files that are in our tmp dir (to avoid other files
35  *  overwriting themselves).
36  *  \return
37  *  - SUCCESS if this file got copied
38  *  - FORCE   if subsequent calls should not ask for confirmation before
39  *            overwriting files anymore.
40  *  - CANCEL  if the export should be cancelled
41  */
42 CopyStatus copyFile(std::string const & format,
43         support::FileName const & sourceFile, support::FileName const & destFile,
44         std::string const & latexFile, bool force, bool only_tmp = true);
45
46
47 class ExportedFile {
48 public:
49         ExportedFile(support::FileName const &, std::string const &);
50         /// absolute name of the source file
51         support::FileName sourceName;
52         /// final name that the exported file should get (absolute name or
53         /// relative to the directory of the master document)
54         std::string exportName;
55 };
56
57
58 bool operator==(ExportedFile const &, ExportedFile const &);
59
60
61 class ExportData {
62 public:
63         /** add a referenced file for one format.
64          *  No inset should ever write any file outside the tempdir.
65          *  Instead, files that need to be exported have to be registered
66          *  with this method.
67          *  Then the exporter mechanism copies them to the right place, asks
68          *  for confirmation before overwriting existing files etc.
69          * \param format     format that references the given file
70          * \param sourceName source file name. Needs to be absolute
71          * \param exportName resulting file name. Can be either absolute
72          *                   or relative to the exported document.
73          */
74         void addExternalFile(std::string const & format,
75                              support::FileName const & sourceName,
76                              std::string const & exportName);
77         /** add a referenced file for one format.
78          *  The final name is the source file name without path.
79          * \param format     format that references the given file
80          * \param sourceName source file name. Needs to be absolute
81          */
82         void addExternalFile(std::string const & format,
83                              support::FileName const & sourceName);
84         /// get referenced files for \p format
85         std::vector<ExportedFile> const
86                 externalFiles(std::string const & format) const;
87 private:
88         typedef std::map<std::string, std::vector<ExportedFile> > FileMap;
89         /** Files that are referenced by the export result in the
90          *  different formats.
91          */
92         FileMap externalfiles_;
93 };
94
95
96 } // namespace lyx
97
98 #endif