X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetQuotes.h;h=41bad175b8157c342829b302e17e038bfdd4baa6;hb=9e308ddb0323719152d97371e0ab0ee80c318010;hp=fa9c26b0acaf5848c3cab5688b8938835880fdb9;hpb=421853d1bf021b7180a61d8c2908ede2dce48061;p=lyx.git diff --git a/src/insets/InsetQuotes.h b/src/insets/InsetQuotes.h index fa9c26b0ac..41bad175b8 100644 --- a/src/insets/InsetQuotes.h +++ b/src/insets/InsetQuotes.h @@ -15,76 +15,100 @@ #include "Inset.h" -#include "support/docstring.h" +#include namespace lyx { +/// +enum class QuoteStyle : int { + /// + English, + /// + Swedish, + /// + German, + /// + Polish, + /// + Swiss, + /// + Danish, + /// + Plain, + /// + British, + /// + SwedishG, + /// + French, + /// + FrenchIN, + /// + Russian, + /// + CJK, + /// + CJKAngle, + /// + Hungarian, + /// + Dynamic +}; + +/// +enum class QuoteSide : int { + /// + Opening, + /// + Closing +}; + +/// +enum class QuoteLevel : int { + /// + Secondary, + /// + Primary +}; + + /** Quotes. Used for the various quotes. German, English, French, all either double or single **/ class InsetQuotesParams { public: - /// - enum QuoteStyle { - /// - EnglishQuotes, - /// - SwedishQuotes, - /// - GermanQuotes, - /// - PolishQuotes, - /// - SwissQuotes, - /// - DanishQuotes, - /// - PlainQuotes, - /// - BritishQuotes, - /// - SwedishGQuotes, - /// - FrenchQuotes, - /// - FrenchINQuotes, - /// - RussianQuotes, - /// - CJKQuotes, - /// - CJKAngleQuotes, - /// - DynamicQuotes - }; - /// - enum QuoteSide { - /// - OpeningQuote, - /// - ClosingQuote - }; - /// - enum QuoteLevel { - /// - SecondaryQuotes, - /// - PrimaryQuotes - }; /// Returns the unicode character of a given quote char_type getQuoteChar(QuoteStyle const &, QuoteLevel const &, - QuoteSide const &) const; + QuoteSide const &, bool const rtl = false) const; /// Returns a map of quotation marks std::map getTypes() const; /// - docstring getLaTeXQuote(char_type c, std::string const &) const; + docstring getLaTeXQuote(char_type c, std::string const &, + bool const rtl = false) const; /// - docstring getHTMLQuote(char_type c) const; - /// Returns a label suitable for dialog and menu - docstring const getGuiLabel(QuoteStyle const & qs); + docstring getXMLQuote(char_type c) const; + /// Returns a descriptive label of a style suitable for dialog and menu + docstring const getGuiLabel(QuoteStyle const & qs, + bool langdef = false) const; + /// Returns a descriptive label of a given char + docstring const getShortGuiLabel(docstring const & str) const; /// int stylescount() const; + /// 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, + QuoteStyle fallback = QuoteStyle::English) const; + /// Returns the quote sind from the shortcut string + QuoteSide getQuoteSide(std::string const & s, + bool const allow_wildcards = false, + QuoteSide fallback = QuoteSide::Opening) const; + /// Returns the quote level from the shortcut string + QuoteLevel getQuoteLevel(std::string const & s, + bool const allow_wildcards = false, + QuoteLevel fallback = QuoteLevel::Primary) const; }; /// @@ -105,54 +129,58 @@ public: */ explicit InsetQuotes(Buffer * buf, std::string const & str = "eld"); /// Direct access to inner/outer quotation marks - InsetQuotes(Buffer * buf, char_type c, InsetQuotesParams::QuoteLevel level, + InsetQuotes(Buffer * buf, char_type c, QuoteLevel level, std::string const & side = std::string(), std::string const & style = std::string()); /// - docstring layoutName() const; + docstring layoutName() const override; /// - void metrics(MetricsInfo &, Dimension &) const; + void metrics(MetricsInfo &, Dimension &) const override; /// - void draw(PainterInfo & pi, int x, int y) const; + void draw(PainterInfo & pi, int x, int y) const override; /// - void write(std::ostream &) const; + void write(std::ostream &) const override; /// - void read(Lexer & lex); + void read(Lexer & lex) override; /// - bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const; + bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override; /// - void latex(otexstream &, OutputParams const &) const; + void latex(otexstream &, OutputParams const &) const override; /// int plaintext(odocstringstream & ods, OutputParams const & op, - size_t max_length = INT_MAX) const; + size_t max_length = INT_MAX) const override; /// - int docbook(odocstream &, OutputParams const &) const; + void docbook(XMLStream &, OutputParams const &) const override; /// - docstring xhtml(XHTMLStream &, OutputParams const &) const; + docstring xhtml(XMLStream &, OutputParams const &) const override; - /// - void toString(odocstream &) const; /// - void forOutliner(docstring &, size_t const maxlen, bool const) const; + bool hasToString() const override { return true; } + /// + void toString(odocstream &) const override; + /// + void forOutliner(docstring &, size_t const maxlen, bool const) const override; /// Update the contextual information of this inset - void updateBuffer(ParIterator const &, UpdateType); + void updateBuffer(ParIterator const &, UpdateType, bool const deleted = false) override; /// - void validate(LaTeXFeatures &) const; + void validate(LaTeXFeatures &) const override; /// - std::string contextMenuName() const; + std::string contextMenuName() const override; /// - InsetCode lyxCode() const { return QUOTE_CODE; } + InsetCode lyxCode() const override { return QUOTE_CODE; } /// should this inset be handled like a normal character - bool isChar() const { return true; } + bool isChar() const override { return true; } /// Returns the current quote type std::string getType() const; + /// + std::pair isWords() const override; private: /// - Inset * clone() const { return new InsetQuotes(*this); } + Inset * clone() const override { return new InsetQuotes(*this); } /// Decide whether we need left or right quotation marks void setSide(char_type c); @@ -162,26 +190,28 @@ private: /// docstring displayString() const; /// - docstring getQuoteEntity() const; + docstring getQuoteXMLEntity() const; /// - InsetQuotesParams::QuoteStyle getStyle(std::string const &); + QuoteStyle getStyle(std::string const &); /// - InsetQuotesParams::QuoteStyle style_; - /// - InsetQuotesParams::QuoteSide side_; + QuoteStyle style_ = QuoteStyle::English; /// - InsetQuotesParams::QuoteLevel level_; + QuoteSide side_ = QuoteSide::Opening; /// - InsetQuotesParams::QuoteStyle global_style_; + QuoteLevel level_ = QuoteLevel::Primary; /// - std::string fontenc_; + QuoteStyle global_style_ = QuoteStyle::English; /// Code of the contextual language std::string context_lang_; /// Is this in a pass-thru context? - bool pass_thru_; + bool pass_thru_ = false; /// Do we use fontspec? - bool fontspec_; + bool fontspec_ = false; + /// Do we have an internal font encoding? + bool internal_fontenc_ = false; + /// Are we writing RTL? + bool rtl_ = false; /// friend class InsetQuotesParams; @@ -189,7 +219,7 @@ protected: /// \name Protected functions inherited from Inset class //@{ /// - void doDispatch(Cursor & cur, FuncRequest & cmd); + void doDispatch(Cursor & cur, FuncRequest & cmd) override; //@} };