1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
2002-09-25 14:26:13 +00:00
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
* \file InsetQuotes.h
|
2002-09-25 14:26:13 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
* \author Jean-Marc Lasgouttes
|
2016-12-24 09:13:51 +00:00
|
|
|
* \author Jürgen Spitzmüller
|
2002-03-21 17:09:55 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-25 14:26:13 +00:00
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
#ifndef INSET_QUOTES_H
|
|
|
|
#define INSET_QUOTES_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
#include "Inset.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2020-12-02 20:34:28 +00:00
|
|
|
#include <map>
|
2006-09-02 10:18:20 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2020-11-30 20:34:16 +00:00
|
|
|
///
|
|
|
|
enum class QuoteStyle : int {
|
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
English,
|
2020-11-30 20:34:16 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
Swedish,
|
2020-11-30 20:34:16 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
German,
|
2020-11-30 20:34:16 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
Polish,
|
2020-11-30 20:34:16 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
Swiss,
|
2020-11-30 20:34:16 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
Danish,
|
2020-11-30 20:34:16 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
Plain,
|
2020-11-30 20:34:16 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
British,
|
2020-11-30 20:34:16 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
SwedishG,
|
2020-11-30 20:34:16 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
French,
|
2020-11-30 20:34:16 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
FrenchIN,
|
2020-11-30 20:34:16 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
Russian,
|
2020-11-30 20:34:16 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
CJK,
|
2020-11-30 20:34:16 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
CJKAngle,
|
2020-11-30 20:34:16 +00:00
|
|
|
///
|
2020-12-02 16:00:40 +00:00
|
|
|
Hungarian,
|
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
Dynamic
|
2020-11-30 20:34:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
enum class QuoteSide : int {
|
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
Opening,
|
2020-11-30 20:34:16 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
Closing
|
2020-11-30 20:34:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
enum class QuoteLevel : int {
|
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
Secondary,
|
2020-11-30 20:34:16 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
Primary
|
2020-11-30 20:34:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/** Quotes.
|
|
|
|
Used for the various quotes. German, English, French, all either
|
2002-03-21 17:09:55 +00:00
|
|
|
double or single **/
|
2016-12-24 09:13:51 +00:00
|
|
|
class InsetQuotesParams {
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
2016-12-24 09:13:51 +00:00
|
|
|
/// Returns the unicode character of a given quote
|
|
|
|
char_type getQuoteChar(QuoteStyle const &, QuoteLevel const &,
|
2018-07-15 10:11:10 +00:00
|
|
|
QuoteSide const &, bool const rtl = false) const;
|
2016-12-24 09:13:51 +00:00
|
|
|
/// Returns a map of quotation marks
|
|
|
|
std::map<std::string, docstring> getTypes() const;
|
|
|
|
///
|
2018-07-15 10:11:10 +00:00
|
|
|
docstring getLaTeXQuote(char_type c, std::string const &,
|
|
|
|
bool const rtl = false) const;
|
2016-12-24 09:13:51 +00:00
|
|
|
///
|
|
|
|
docstring getHTMLQuote(char_type c) const;
|
2019-05-09 23:35:40 +00:00
|
|
|
///
|
|
|
|
docstring getXMLQuote(char_type c) const;
|
2017-01-05 13:25:36 +00:00
|
|
|
/// Returns a descriptive label of a style suitable for dialog and menu
|
|
|
|
docstring const getGuiLabel(QuoteStyle const & qs,
|
2020-11-01 10:57:14 +00:00
|
|
|
bool langdef = false) const;
|
2017-01-05 13:25:36 +00:00
|
|
|
/// Returns a descriptive label of a given char
|
2020-11-01 10:57:14 +00:00
|
|
|
docstring const getShortGuiLabel(docstring const & str) const;
|
2016-12-24 09:13:51 +00:00
|
|
|
///
|
|
|
|
int stylescount() const;
|
2017-01-05 13:25:36 +00:00
|
|
|
/// Returns the matching style shortcut char
|
|
|
|
char getStyleChar(QuoteStyle const & style) const;
|
|
|
|
/// Returns the quote style from the shortcut string
|
|
|
|
QuoteStyle getQuoteStyle(std::string const & s,
|
|
|
|
bool const allow_wildcards = false,
|
2020-11-30 22:00:40 +00:00
|
|
|
QuoteStyle fallback = QuoteStyle::English) const;
|
2017-01-05 13:25:36 +00:00
|
|
|
/// Returns the quote sind from the shortcut string
|
|
|
|
QuoteSide getQuoteSide(std::string const & s,
|
|
|
|
bool const allow_wildcards = false,
|
2020-11-30 22:00:40 +00:00
|
|
|
QuoteSide fallback = QuoteSide::Opening) const;
|
2017-01-05 13:25:36 +00:00
|
|
|
/// Returns the quote level from the shortcut string
|
|
|
|
QuoteLevel getQuoteLevel(std::string const & s,
|
|
|
|
bool const allow_wildcards = false,
|
2020-11-30 22:00:40 +00:00
|
|
|
QuoteLevel fallback = QuoteLevel::Primary) const;
|
2016-12-24 09:13:51 +00:00
|
|
|
};
|
2002-03-21 17:09:55 +00:00
|
|
|
|
2016-12-24 09:13:51 +00:00
|
|
|
///
|
|
|
|
extern InsetQuotesParams quoteparams;
|
|
|
|
|
|
|
|
/** Quotes.
|
|
|
|
Used for the various quotes. German, English, French, all either
|
|
|
|
double or single **/
|
|
|
|
class InsetQuotes : public Inset
|
|
|
|
{
|
|
|
|
public:
|
1999-09-27 18:44:28 +00:00
|
|
|
/** The constructor works like this:
|
|
|
|
\begin{itemize}
|
2002-03-21 17:09:55 +00:00
|
|
|
\item fls <- french single quote left
|
|
|
|
\item grd <- german double quote right
|
1999-09-27 18:44:28 +00:00
|
|
|
\item etc.
|
|
|
|
\end{itemize}
|
2000-04-08 17:02:02 +00:00
|
|
|
*/
|
2009-11-08 15:53:21 +00:00
|
|
|
explicit InsetQuotes(Buffer * buf, std::string const & str = "eld");
|
2004-02-20 10:32:44 +00:00
|
|
|
/// Direct access to inner/outer quotation marks
|
2020-11-30 20:34:16 +00:00
|
|
|
InsetQuotes(Buffer * buf, char_type c, QuoteLevel level,
|
2016-12-20 16:55:43 +00:00
|
|
|
std::string const & side = std::string(),
|
|
|
|
std::string const & style = std::string());
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
docstring layoutName() const override;
|
2007-04-29 12:32:14 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void metrics(MetricsInfo &, Dimension &) const override;
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void draw(PainterInfo & pi, int x, int y) const override;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void write(std::ostream &) const override;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void read(Lexer & lex) override;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
|
2016-12-17 11:58:33 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void latex(otexstream &, OutputParams const &) const override;
|
2000-03-06 02:42:40 +00:00
|
|
|
///
|
2013-03-08 19:52:18 +00:00
|
|
|
int plaintext(odocstringstream & ods, OutputParams const & op,
|
2020-10-01 07:42:11 +00:00
|
|
|
size_t max_length = INT_MAX) const override;
|
2000-04-24 20:58:23 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void docbook(XMLStream &, OutputParams const &) const override;
|
2009-06-05 17:48:14 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
docstring xhtml(XMLStream &, OutputParams const &) const override;
|
2005-11-25 14:40:34 +00:00
|
|
|
|
2017-07-03 17:45:58 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void toString(odocstream &) const override;
|
2010-12-20 21:55:09 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void forOutliner(docstring &, size_t const maxlen, bool const) const override;
|
2005-11-25 14:40:34 +00:00
|
|
|
|
2016-12-10 10:53:42 +00:00
|
|
|
/// Update the contextual information of this inset
|
2020-10-01 07:42:11 +00:00
|
|
|
void updateBuffer(ParIterator const &, UpdateType, bool const deleted = false) override;
|
2016-12-10 10:53:42 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void validate(LaTeXFeatures &) const override;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
std::string contextMenuName() const override;
|
2016-12-17 11:58:33 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
InsetCode lyxCode() const override { return QUOTE_CODE; }
|
2007-10-16 16:48:21 +00:00
|
|
|
/// should this inset be handled like a normal character
|
2020-10-01 07:42:11 +00:00
|
|
|
bool isChar() const override { return true; }
|
2016-12-24 09:13:51 +00:00
|
|
|
|
2016-12-17 11:58:33 +00:00
|
|
|
/// Returns the current quote type
|
|
|
|
std::string getType() const;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
private:
|
2008-02-27 20:43:16 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
Inset * clone() const override { return new InsetQuotes(*this); }
|
2004-11-23 23:04:52 +00:00
|
|
|
|
2004-02-20 10:32:44 +00:00
|
|
|
/// Decide whether we need left or right quotation marks
|
2008-03-15 00:02:41 +00:00
|
|
|
void setSide(char_type c);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2016-12-18 09:29:35 +00:00
|
|
|
void parseString(std::string const &,
|
|
|
|
bool const allow_wildcards = false);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2008-03-15 00:02:41 +00:00
|
|
|
docstring displayString() const;
|
2015-02-09 22:24:13 +00:00
|
|
|
///
|
2019-05-09 23:35:40 +00:00
|
|
|
docstring getQuoteEntity(bool isHTML) const;
|
2016-12-16 10:23:22 +00:00
|
|
|
///
|
2020-11-30 20:34:16 +00:00
|
|
|
QuoteStyle getStyle(std::string const &);
|
2008-03-15 00:02:41 +00:00
|
|
|
|
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
QuoteStyle style_ = QuoteStyle::English;
|
2008-03-15 00:02:41 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
QuoteSide side_ = QuoteSide::Opening;
|
2008-03-15 00:02:41 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
QuoteLevel level_ = QuoteLevel::Primary;
|
2016-12-07 14:37:03 +00:00
|
|
|
///
|
2020-11-30 22:00:40 +00:00
|
|
|
QuoteStyle global_style_ = QuoteStyle::English;
|
2017-08-10 09:47:52 +00:00
|
|
|
/// Current font encoding
|
2016-12-07 14:37:03 +00:00
|
|
|
std::string fontenc_;
|
2016-12-10 10:53:42 +00:00
|
|
|
/// Code of the contextual language
|
|
|
|
std::string context_lang_;
|
|
|
|
/// Is this in a pass-thru context?
|
2020-11-24 20:42:06 +00:00
|
|
|
bool pass_thru_ = false;
|
2016-12-26 13:41:14 +00:00
|
|
|
/// Do we use fontspec?
|
2020-11-24 20:42:06 +00:00
|
|
|
bool fontspec_ = false;
|
2017-08-10 09:47:52 +00:00
|
|
|
/// Do we have an internal font encoding?
|
2020-11-24 20:42:06 +00:00
|
|
|
bool internal_fontenc_ = false;
|
2018-07-15 10:11:10 +00:00
|
|
|
/// Are we writing RTL?
|
2020-11-24 20:42:06 +00:00
|
|
|
bool rtl_ = false;
|
2016-12-24 09:13:51 +00:00
|
|
|
///
|
|
|
|
friend class InsetQuotesParams;
|
2016-12-17 11:58:33 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/// \name Protected functions inherited from Inset class
|
|
|
|
//@{
|
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void doDispatch(Cursor & cur, FuncRequest & cmd) override;
|
2016-12-17 11:58:33 +00:00
|
|
|
//@}
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|