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