]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsConverter.h
Do not compute metrics at each preview when loading file
[lyx.git] / src / graphics / GraphicsConverter.h
1 // -*- C++ -*-
2 /**
3  * \file GraphicsConverter.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  *
11  * The controller of a conversion process from file AA of format A to
12  * file BB of format B.
13  * Once finished, a signal is emitted to inform any listeners (connected
14  * through the connect() method).
15  */
16
17 #ifndef GRAPHICSCONVERTER_H
18 #define GRAPHICSCONVERTER_H
19
20 #include "support/signals.h"
21
22 #include <memory>
23
24 namespace lyx {
25
26 namespace support { class FileName; }
27
28 namespace graphics {
29
30 class Converter {
31 public:
32         /// Can the conversion be performed?
33         static bool isReachable(std::string const & from_format_name,
34                                 std::string const & to_format_name);
35
36         /** One Converter per conversion ensures that the (hidden) signal
37          *  is always connected to the expected slot.
38          */
39         Converter(support::FileName const & doc_fname,
40                   support::FileName const & from_file, std::string const & to_file_base,
41                   std::string const & from_format, std::string const & to_format);
42
43         /// We are explicit about when we begin the conversion process.
44         void startConversion() const;
45
46         /** Connect and you'll be informed when the conversion process has
47          *  finished.
48          *  If the conversion is successful, then the listener is passed \c true.
49          *  The connection is closed when this is destroyed.
50          */
51         typedef signal<void(bool)> sig_type;
52         typedef sig_type::slot_type slot_type;
53         ///
54         connection connect(slot_type const &) const;
55
56         /** If the conversion is successful, this returns the name of the
57          *  resulting file.
58          *  If conversion fails or has not been completed, however, it
59          *  returns an empty string.
60          */
61         support::FileName const & convertedFile() const;
62
63 private:
64         /// noncopyable
65         Converter(Converter const &);
66         void operator=(Converter const &);
67
68         /// Use the Pimpl idiom to hide the internals.
69         class Impl;
70         /// The pointer never changes although *pimpl_'s contents may.
71         std::shared_ptr<Impl> const pimpl_;
72 };
73
74 } // namespace graphics
75 } // namespace lyx
76
77 #endif // GRAPHICSCONVERTER_H