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