]> git.lyx.org Git - lyx.git/blob - src/insets/InsetQuotes.h
Fix bug #9383. Writing directly to the output stream bypassed the
[lyx.git] / src / insets / InsetQuotes.h
1 // -*- C++ -*-
2 /**
3  * \file InsetQuotes.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jean-Marc Lasgouttes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSET_QUOTES_H
13 #define INSET_QUOTES_H
14
15 #include "Inset.h"
16
17 #include "support/docstring.h"
18
19
20 namespace lyx {
21
22 /** Quotes.
23   Used for the various quotes. German, English, French, all either
24   double or single **/
25 class InsetQuotes : public Inset
26 {
27 public:
28         ///
29         enum QuoteLanguage {
30                 ///
31                 EnglishQuotes,
32                 ///
33                 SwedishQuotes,
34                 ///
35                 GermanQuotes,
36                 ///
37                 PolishQuotes,
38                 ///
39                 FrenchQuotes,
40                 ///
41                 DanishQuotes
42         };
43         ///
44         enum QuoteSide {
45                 ///
46                 LeftQuote,
47                 ///
48                 RightQuote
49         };
50         ///
51         enum QuoteTimes {
52                 ///
53                 SingleQuotes,
54                 ///
55                 DoubleQuotes
56         };
57
58         /** The constructor works like this:
59           \begin{itemize}
60             \item fls <- french single quote left
61             \item grd <- german double quote right
62             \item etc.
63           \end{itemize}
64           */
65         explicit InsetQuotes(Buffer * buf, std::string const & str = "eld");
66         /// Create the right quote inset after character c
67         InsetQuotes(Buffer * buffer, char_type c);
68         /// Direct access to inner/outer quotation marks
69         InsetQuotes(Buffer * buf, char_type c, QuoteTimes t);
70         ///
71         docstring layoutName() const;
72         ///
73         void metrics(MetricsInfo &, Dimension &) const;
74         ///
75         void draw(PainterInfo & pi, int x, int y) const;
76         ///
77         void write(std::ostream &) const;
78         ///
79         void read(Lexer & lex);
80         ///
81         void latex(otexstream &, OutputParams const &) const;
82         ///
83         int plaintext(odocstringstream & ods, OutputParams const & op,
84                       size_t max_length = INT_MAX) const;
85         ///
86         int docbook(odocstream &, OutputParams const &) const;
87         ///
88         docstring xhtml(XHTMLStream &, OutputParams const &) const;
89
90         /// 
91         void toString(odocstream &) const;
92         ///
93         void forOutliner(docstring &, size_t maxlen) const;
94
95         ///
96         void validate(LaTeXFeatures &) const;
97         ///
98         InsetCode lyxCode() const { return QUOTE_CODE; }
99         /// should this inset be handled like a normal character
100         bool isChar() const { return true; }
101
102 private:
103         ///
104         Inset * clone() const { return new InsetQuotes(*this); }
105
106         /// Decide whether we need left or right quotation marks
107         void setSide(char_type c);
108         ///
109         void parseString(std::string const &);
110         ///
111         docstring displayString() const;
112         ///
113         docstring getQuoteEntity() const;
114
115         ///
116         QuoteLanguage language_;
117         ///
118         QuoteSide side_;
119         ///
120         QuoteTimes times_;
121 };
122
123 } // namespace lyx
124
125 #endif