]> git.lyx.org Git - lyx.git/blob - src/insets/InsetGraphics.h
Fix bug #6315: counters in insets that don't produce output have ghost values.
[lyx.git] / src / insets / InsetGraphics.h
1 // -*- C++ -*-
2 /**
3  * \file InsetGraphics.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Baruch Even
8  * \author Herbert Voß
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef INSET_GRAPHICS_H
14 #define INSET_GRAPHICS_H
15
16 #include "Inset.h"
17 #include "InsetGraphicsParams.h"
18
19 #include <set>
20
21 namespace lyx {
22
23 class RenderGraphic;
24 class LaTeXFeatures;
25
26 /////////////////////////////////////////////////////////////////////////
27 //
28 // InsetGraphics
29 //
30 /////////////////////////////////////////////////////////////////////////
31
32 /// Used for images etc.
33 class InsetGraphics : public Inset
34 {
35 public:
36         ///
37         InsetGraphics(Buffer * buf);
38         ///
39         ~InsetGraphics();
40
41         ///
42         static void string2params(std::string const & data,
43                                   Buffer const & buffer,
44                                   InsetGraphicsParams &);
45         ///
46         static std::string params2string(InsetGraphicsParams const &,
47                                           Buffer const &);
48
49         /** Set the inset parameters, used by the GUIndependent dialog.
50             Return true of new params are different from what was so far.
51         */
52         bool setParams(InsetGraphicsParams const & params);
53
54         InsetGraphicsParams getParams() const { return params_;}
55         ///
56         bool clickable(int, int) const { return true; }
57
58 private:
59         ///
60         InsetGraphics(InsetGraphics const &);
61
62         ///
63         bool isLabeled() const { return true; }
64         void metrics(MetricsInfo &, Dimension &) const;
65         ///
66         bool hasSettings() const { return true; }
67         ///
68         void write(std::ostream &) const;
69         ///
70         void read(Lexer & lex);
71         /** returns the number of rows (\n's) of generated tex code.
72          #fragile == true# means, that the inset should take care about
73          fragile commands by adding a #\protect# before.
74          */
75         int latex(odocstream &, OutputParams const &) const;
76         ///
77         int plaintext(odocstream &, OutputParams const &) const;
78         ///
79         int docbook(odocstream &, OutputParams const &) const;
80         ///
81         docstring xhtml(XHTMLStream & os, OutputParams const &) const;
82         /** Tell LyX what the latex features you need i.e. what latex packages
83             you need to be included.
84          */
85         void validate(LaTeXFeatures & features) const;
86         /// returns LyX code associated with the inset. Used for TOC, ...)
87         InsetCode lyxCode() const { return GRAPHICS_CODE; }
88         /// Get the inset parameters, used by the GUIndependent dialog.
89         InsetGraphicsParams const & params() const;
90         ///
91         void draw(PainterInfo & pi, int x, int y) const;
92         ///
93         bool showInsetDialog(BufferView * bv) const;
94         ///
95         void editGraphics(InsetGraphicsParams const &) const;
96         ///
97         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
98         ///
99         void addToToc(DocIterator const &);
100         ///
101         docstring contextMenu(BufferView const & bv, int x, int y) const;
102         /// Force inset into LTR environment if surroundings are RTL
103         bool forceLTR() const { return true; }
104         ///
105         void doDispatch(Cursor & cur, FuncRequest & cmd);
106         ///
107         Inset * clone() const;
108         /// Get the status message, depends on the image loading status.
109         std::string statusMessage() const;
110         /// Create the options for the latex command.
111         std::string createLatexOptions() const;
112         /// Create length values for docbook export.
113         docstring toDocbookLength(Length const & len) const;
114         /// Create the atributes for docbook export.
115         docstring createDocBookAttributes() const;
116         /// Convert the file if needed, and return the location of the file.
117         /// This version is for use with LaTeX-style output.
118         std::string prepareFile(OutputParams const &) const;
119         /// Convert the file if needed, and return the location of the file.
120         /// This version is for use with HTML-style output.
121         /// \return the new filename, relative to the location of the HTML file,
122         /// or an empty string on error.
123         std::string prepareHTMLFile(OutputParams const & runparams) const;
124
125         ///
126         InsetGraphicsParams params_;
127         /// holds the entity name that defines the graphics location (SGML).
128         docstring const graphic_label;
129         /// The thing that actually draws the image on LyX's screen.
130         RenderGraphic * graphic_;
131 };
132
133 namespace graphics {
134
135         /// Saves the list of currently used groups in the document.
136         void getGraphicsGroups(Buffer const &, std::set<std::string> &);
137
138         /// how many members has the current group?
139         int countGroupMembers(Buffer const &, std::string const &);
140
141         /// Returns parameters of a given graphics group (except filename).
142         std::string getGroupParams(Buffer const &, std::string const &);
143
144         /** Synchronize all Graphics insets of the group.
145             Both groupId and params are taken from argument.
146         */
147         void unifyGraphicsGroups(Buffer &, std::string const &);
148         InsetGraphics * getCurrentGraphicsInset(Cursor const &);
149
150 }
151
152 } // namespace lyx
153
154 #endif // INSET_GRAPHICS_H