]> git.lyx.org Git - lyx.git/blob - src/exporter.h
hopefully fix tex2lyx linking.
[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 <map>
17 #include <string>
18 #include <vector>
19
20
21 namespace lyx {
22
23
24 class Buffer;
25 class Format;
26
27 class Exporter {
28 public:
29         ///
30         static
31         bool Export(Buffer * buffer, std::string const & format,
32                     bool put_in_tempdir, std::string & result_file);
33         ///
34         static
35         bool Export(Buffer * buffer, std::string const & format,
36                     bool put_in_tempdir);
37         ///
38         static
39         bool preview(Buffer * buffer, std::string const & format);
40         ///
41         static
42         bool isExportable(Buffer const & buffer, std::string const & format);
43         ///
44         static
45         std::vector<Format const *> const
46         getExportableFormats(Buffer const & buffer, bool only_viewable);
47         ///
48 };
49
50
51 class ExportedFile {
52 public:
53         ExportedFile(std::string const &, std::string const &);
54         /// absolute name of the source file
55         std::string sourceName;
56         /// final name that the exported file should get (absolute name or
57         /// relative to the directory of the master document)
58         std::string exportName;
59 };
60
61
62 bool operator==(ExportedFile const &, ExportedFile const &);
63
64
65 class ExportData {
66 public:
67         /** add a referenced file for one format.
68          *  No inset should ever write any file outside the tempdir.
69          *  Instead, files that need to be exported have to be registered
70          *  with this method.
71          *  Then the exporter mechanism copies them to the right place, asks
72          *  for confirmation before overwriting existing files etc.
73          * \param format     format that references the given file
74          * \param sourceName source file name. Needs to be absolute
75          * \param exportName resulting file name. Can be either absolute
76          *                   or relative to the exported document.
77          */
78         void addExternalFile(std::string const & format,
79                              std::string const & sourceName,
80                              std::string const & exportName);
81         /** add a referenced file for one format.
82          *  The final name is the source file name without path.
83          * \param format     format that references the given file
84          * \param sourceName source file name. Needs to be absolute
85          */
86         void addExternalFile(std::string const & format,
87                              std::string const & sourceName);
88         /// get referenced files for \p format
89         std::vector<ExportedFile> const
90         externalFiles(std::string const & format) const;
91 private:
92         typedef std::map<std::string, std::vector<ExportedFile> > FileMap;
93         /** Files that are referenced by the export result in the
94          *  different formats.
95          */
96         FileMap externalfiles;
97 };
98
99
100 } // namespace lyx
101
102 #endif