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 &, bool const rtl = false) 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 &,
82 bool const rtl = false) const;
84 docstring getHTMLQuote(char_type c) const;
85 /// Returns a descriptive label of a style suitable for dialog and menu
86 docstring const getGuiLabel(QuoteStyle const & qs,
87 bool langdef = false);
88 /// Returns a descriptive label of a given char
89 docstring const getShortGuiLabel(docstring const & str);
91 int stylescount() const;
92 /// Returns the matching style shortcut char
93 char getStyleChar(QuoteStyle const & style) const;
94 /// Returns the quote style from the shortcut string
95 QuoteStyle getQuoteStyle(std::string const & s,
96 bool const allow_wildcards = false,
97 QuoteStyle fallback = EnglishQuotes);
98 /// Returns the quote sind from the shortcut string
99 QuoteSide getQuoteSide(std::string const & s,
100 bool const allow_wildcards = false,
101 QuoteSide fallback = OpeningQuote);
102 /// Returns the quote level from the shortcut string
103 QuoteLevel getQuoteLevel(std::string const & s,
104 bool const allow_wildcards = false,
105 QuoteLevel fallback = PrimaryQuotes);
109 extern InsetQuotesParams quoteparams;
112 Used for the various quotes. German, English, French, all either
114 class InsetQuotes : public Inset
117 /** The constructor works like this:
119 \item fls <- french single quote left
120 \item grd <- german double quote right
124 explicit InsetQuotes(Buffer * buf, std::string const & str = "eld");
125 /// Direct access to inner/outer quotation marks
126 InsetQuotes(Buffer * buf, char_type c, InsetQuotesParams::QuoteLevel level,
127 std::string const & side = std::string(),
128 std::string const & style = std::string());
130 docstring layoutName() const;
132 void metrics(MetricsInfo &, Dimension &) const;
134 void draw(PainterInfo & pi, int x, int y) const;
136 void write(std::ostream &) const;
138 void read(Lexer & lex);
140 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
142 void latex(otexstream &, OutputParams const &) const;
144 int plaintext(odocstringstream & ods, OutputParams const & op,
145 size_t max_length = INT_MAX) const;
147 int docbook(odocstream &, OutputParams const &) const;
149 docstring xhtml(XHTMLStream &, OutputParams const &) const;
152 void toString(odocstream &) const;
154 void forOutliner(docstring &, size_t const maxlen, bool const) const;
156 /// Update the contextual information of this inset
157 void updateBuffer(ParIterator const &, UpdateType);
160 void validate(LaTeXFeatures &) const;
162 std::string contextMenuName() const;
164 InsetCode lyxCode() const { return QUOTE_CODE; }
165 /// should this inset be handled like a normal character
166 bool isChar() const { return true; }
168 /// Returns the current quote type
169 std::string getType() const;
173 Inset * clone() const { return new InsetQuotes(*this); }
175 /// Decide whether we need left or right quotation marks
176 void setSide(char_type c);
178 void parseString(std::string const &,
179 bool const allow_wildcards = false);
181 docstring displayString() const;
183 docstring getQuoteEntity() const;
185 InsetQuotesParams::QuoteStyle getStyle(std::string const &);
188 InsetQuotesParams::QuoteStyle style_;
190 InsetQuotesParams::QuoteSide side_;
192 InsetQuotesParams::QuoteLevel level_;
194 InsetQuotesParams::QuoteStyle global_style_;
195 /// Current font encoding
196 std::string fontenc_;
197 /// Code of the contextual language
198 std::string context_lang_;
199 /// Is this in a pass-thru context?
201 /// Do we use fontspec?
203 /// Do we have an internal font encoding?
204 bool internal_fontenc_;
205 /// Are we writing RTL?
208 friend class InsetQuotesParams;
211 /// \name Protected functions inherited from Inset class
214 void doDispatch(Cursor & cur, FuncRequest & cmd);