]> git.lyx.org Git - lyx.git/blob - src/Exporter.h
HTML for math sizes.
[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.
34  *  \return
35  *  - SUCCESS if this file got copied
36  *  - FORCE   if subsequent calls should not ask for confirmation before
37  *            overwriting files anymore.
38  *  - CANCEL  if the export should be cancelled
39  */
40 CopyStatus copyFile(std::string const & format,
41         support::FileName const & sourceFile, support::FileName const & destFile,
42         std::string const & latexFile, bool force);
43
44
45 class ExportedFile {
46 public:
47         ExportedFile(support::FileName const &, std::string const &);
48         /// absolute name of the source file
49         support::FileName sourceName;
50         /// final name that the exported file should get (absolute name or
51         /// relative to the directory of the master document)
52         std::string exportName;
53 };
54
55
56 bool operator==(ExportedFile const &, ExportedFile const &);
57
58
59 class ExportData {
60 public:
61         /** add a referenced file for one format.
62          *  No inset should ever write any file outside the tempdir.
63          *  Instead, files that need to be exported have to be registered
64          *  with this method.
65          *  Then the exporter mechanism copies them to the right place, asks
66          *  for confirmation before overwriting existing files etc.
67          * \param format     format that references the given file
68          * \param sourceName source file name. Needs to be absolute
69          * \param exportName resulting file name. Can be either absolute
70          *                   or relative to the exported document.
71          */
72         void addExternalFile(std::string const & format,
73                              support::FileName const & sourceName,
74                              std::string const & exportName);
75         /** add a referenced file for one format.
76          *  The final name is the source file name without path.
77          * \param format     format that references the given file
78          * \param sourceName source file name. Needs to be absolute
79          */
80         void addExternalFile(std::string const & format,
81                              support::FileName const & sourceName);
82         /// get referenced files for \p format
83         std::vector<ExportedFile> const
84                 externalFiles(std::string const & format) const;
85 private:
86         typedef std::map<std::string, std::vector<ExportedFile> > FileMap;
87         /** Files that are referenced by the export result in the
88          *  different formats.
89          */
90         FileMap externalfiles_;
91 };
92
93
94 } // namespace lyx
95
96 #endif