]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCommandParams.h
InsetPhantom::latex(): use a switch
[lyx.git] / src / insets / InsetCommandParams.h
index 2ff6d5c27f9b0f5ae12f4f45cbe5407650432d40..a5d46785b8ef2c43002fbe1aa2f30a933d06eb79 100644 (file)
@@ -16,6 +16,8 @@
 
 #include "InsetCode.h"
 
+#include "OutputParams.h"
+
 #include "support/docstring.h"
 
 #include <string>
@@ -29,23 +31,33 @@ class Lexer;
 
 class ParamInfo {
 public:
+       ///
+       ParamInfo() {}
        /// Types of parameters
        enum ParamType {
                LATEX_OPTIONAL,    /// normal optional argument
                LATEX_REQUIRED,    /// normal required argument
                LYX_INTERNAL       /// a parameter used internally by LyX
        };
+       /// Special handling on output
+       enum ParamHandling {
+               HANDLING_NONE,    /// no special handling
+               HANDLING_ESCAPE,  /// escape special characters
+               HANDLING_LATEXIFY /// transform special characters to LaTeX macros
+       };
        ///
        class ParamData {
        // No parameter may be named "preview", because that is a required
        // flag for all commands.
        public:
                ///
-               ParamData(std::string const &, ParamType);
+               ParamData(std::string const &, ParamType, ParamHandling = HANDLING_NONE);
                ///
                std::string name() const { return name_; }
                ///
                ParamType type() const { return type_; }
+               ///
+               ParamHandling handling() const { return handling_; }
                /// whether this is an optional LaTeX argument
                bool isOptional() const;
                ///
@@ -58,10 +70,13 @@ public:
                std::string name_;
                ///
                ParamType type_;
+               /// do we need special handling on latex output?
+               ParamHandling handling_;
        };
 
        /// adds a new parameter
-       void add(std::string const & name, ParamType type);
+       void add(std::string const & name, ParamType type,
+                ParamHandling = HANDLING_NONE);
        ///
        bool empty() const { return info_.empty(); }
        ///
@@ -103,7 +118,7 @@ public:
        ///
        void write(std::ostream &) const;
        /// Build the complete LaTeX command
-       docstring getCommand() const;
+       docstring getCommand(OutputParams const &) const;
        /// Return the command name
        std::string const & getCmdName() const { return cmdName_; }
        /// Set the name to \p n. This must be a known name. All parameters
@@ -127,7 +142,11 @@ public:
        void clear();
        ///
        static bool isCompatibleCommand(InsetCode code, std::string const & s);
-
+       /// 
+       ParamInfo const & info() const { return info_; }
+       ///
+       docstring prepareCommand(OutputParams const & runparams,
+               docstring const & command, ParamInfo::ParamHandling handling) const;
 private:
        std::string getDefaultCmd(InsetCode code);
        /// checks whether we need to write an empty optional parameter