4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Jean-Marc Lasgouttes
8 * \author Jürgen Spitzmüller
10 * Full author contact details are available in file CREDITS.
13 #ifndef INSET_QUOTES_H
14 #define INSET_QUOTES_H
18 #include "support/docstring.h"
24 Used for the various quotes. German, English, French, all either
26 class InsetQuotesParams {
75 /// Returns the unicode character of a given quote
76 char_type getQuoteChar(QuoteStyle const &, QuoteLevel const &,
77 QuoteSide const &) const;
78 /// Returns a map of quotation marks
79 std::map<std::string, docstring> getTypes() const;
81 docstring getLaTeXQuote(char_type c, std::string const &) const;
83 docstring getHTMLQuote(char_type c) const;
84 /// Returns a descriptive label of a style suitable for dialog and menu
85 docstring const getGuiLabel(QuoteStyle const & qs,
86 bool langdef = false);
87 /// Returns a descriptive label of a given char
88 docstring const getShortGuiLabel(docstring const string);
90 int stylescount() const;
91 /// Returns the matching style shortcut char
92 char getStyleChar(QuoteStyle const & style) const;
93 /// Returns the quote style from the shortcut string
94 QuoteStyle getQuoteStyle(std::string const & s,
95 bool const allow_wildcards = false,
96 QuoteStyle fallback = EnglishQuotes);
97 /// Returns the quote sind from the shortcut string
98 QuoteSide getQuoteSide(std::string const & s,
99 bool const allow_wildcards = false,
100 QuoteSide fallback = OpeningQuote);
101 /// Returns the quote level from the shortcut string
102 QuoteLevel getQuoteLevel(std::string const & s,
103 bool const allow_wildcards = false,
104 QuoteLevel fallback = PrimaryQuotes);
108 extern InsetQuotesParams quoteparams;
111 Used for the various quotes. German, English, French, all either
113 class InsetQuotes : public Inset
116 /** The constructor works like this:
118 \item fls <- french single quote left
119 \item grd <- german double quote right
123 explicit InsetQuotes(Buffer * buf, std::string const & str = "eld");
124 /// Direct access to inner/outer quotation marks
125 InsetQuotes(Buffer * buf, char_type c, InsetQuotesParams::QuoteLevel level,
126 std::string const & side = std::string(),
127 std::string const & style = std::string());
129 docstring layoutName() const;
131 void metrics(MetricsInfo &, Dimension &) const;
133 void draw(PainterInfo & pi, int x, int y) const;
135 void write(std::ostream &) const;
137 void read(Lexer & lex);
139 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
141 void latex(otexstream &, OutputParams const &) const;
143 int plaintext(odocstringstream & ods, OutputParams const & op,
144 size_t max_length = INT_MAX) const;
146 int docbook(odocstream &, OutputParams const &) const;
148 docstring xhtml(XHTMLStream &, OutputParams const &) const;
151 void toString(odocstream &) const;
153 void forOutliner(docstring &, size_t const maxlen, bool const) const;
155 /// Update the contextual information of this inset
156 void updateBuffer(ParIterator const &, UpdateType);
159 void validate(LaTeXFeatures &) const;
161 std::string contextMenuName() const;
163 InsetCode lyxCode() const { return QUOTE_CODE; }
164 /// should this inset be handled like a normal character
165 bool isChar() const { return true; }
167 /// Returns the current quote type
168 std::string getType() const;
172 Inset * clone() const { return new InsetQuotes(*this); }
174 /// Decide whether we need left or right quotation marks
175 void setSide(char_type c);
177 void parseString(std::string const &,
178 bool const allow_wildcards = false);
180 docstring displayString() const;
182 docstring getQuoteEntity() const;
184 InsetQuotesParams::QuoteStyle getStyle(std::string const &);
187 InsetQuotesParams::QuoteStyle style_;
189 InsetQuotesParams::QuoteSide side_;
191 InsetQuotesParams::QuoteLevel level_;
193 InsetQuotesParams::QuoteStyle global_style_;
194 /// Current font encoding
195 std::string fontenc_;
196 /// Code of the contextual language
197 std::string context_lang_;
198 /// Is this in a pass-thru context?
200 /// Do we use fontspec?
202 /// Do we have an internal font encoding?
203 bool internal_fontenc_;
205 friend class InsetQuotesParams;
208 /// \name Protected functions inherited from Inset class
211 void doDispatch(Cursor & cur, FuncRequest & cmd);