#ifndef CONTEXT_H
#define CONTEXT_H
-#include "LyXTextClass.h"
+#include "tex2lyx.h"
#include <iosfwd>
/*!
* Small helper struct that holds font properties.
* The names are in LyX language, not LaTeX.
- * We don't use LyXFont, because it pulls in a lot of dependencies and has
+ * We don't use Font, because it pulls in a lot of dependencies and has
* more strings than needed (e.g. font family error1 etc.).
* If more font related stuff is needed, it might be good to change to
- * LyXFont.
+ * Font.
*/
-class Font {
+class TeXFont {
public:
- Font()
+ TeXFont()
{
init();
}
void init()
{
- size = "normal";
+ size = "default";
family = "default";
series = "default";
shape = "default";
+ language = "english";
}
std::string size;
std::string family;
std::string series;
std::string shape;
+ std::string language;
};
-bool operator==(Font const &, Font const &);
+bool operator==(TeXFont const &, TeXFont const &);
-inline bool operator!=(Font const & f1, Font const & f2)
+inline bool operator!=(TeXFont const & f1, TeXFont const & f2)
{
return !operator==(f1, f2);
}
/// Output changed font parameters if \p oldfont and \p newfont differ
-void output_font_change(std::ostream & os, Font const & oldfont,
- Font const & newfont);
+void output_font_change(std::ostream & os, TeXFont const & oldfont,
+ TeXFont const & newfont);
/*!
class Context {
public:
Context(bool need_layout_,
- LyXTextClass const & textclass_,
- LyXLayout_ptr layout_ = LyXLayout_ptr(),
- LyXLayout_ptr parent_layout_= LyXLayout_ptr(),
- Font font_ = Font());
+ TeX2LyXDocClass const & textclass_,
+ Layout const * layout_ = 0,
+ Layout const * parent_layout_= 0,
+ TeXFont const & font_ = normalfont);
~Context();
/// Output a \\begin_layout if requested
/// Add extra stuff if not already there
void add_extra_stuff(std::string const &);
+ /*!
+ * Add paragraph-level extra stuff if not already there. This
+ * will be reset at the next check_layout()
+ */
+ void add_par_extra_stuff(std::string const &);
+
/// Do we need to output some \\begin_layout command before the
/// next characters?
bool need_layout;
/// Do we need to output some \\end_layout command
bool need_end_layout;
- /// We may need to add something after this \\begin_layout command
+ /// We may need to add something after each \\begin_layout command
std::string extra_stuff;
+ /// We may need to add something after this \\begin_layout command
+ std::string par_extra_stuff;
+ /// We may need to add something at the beginning of a list.
+ std::string list_extra_stuff;
+ /// Stuff between list begin and first item
+ std::string list_preamble;
+ /// A LaTeXParam to be ignored in parsing.
+ std::string latexparam;
/// If there has been an \\begin_deeper, we'll need a matching
/// \\end_deeper
bool need_end_deeper;
/// for each paragraph, otherwise this has to be a deeper
/// paragraph.
bool has_item;
+ /// If we are in an itemize-like environment, this marks
+ /// the text before the first \item. Typically, list
+ /// parameters (such as lengths) are adjusted here.
+ bool in_list_preamble;
+ /// Store commands that should not be converted
+ /// (stored without \\)
+ std::set<std::string> pass_thru_cmds;
/// we are handling a standard paragraph in an itemize-like
/// environment
bool deeper_paragraph;
* would not work.
*/
bool new_layout_allowed;
+ /// May -- be converted to endash and --- to emdash?
+ bool merging_hyphens_allowed;
/// Did we output anything yet in any context?
static bool empty;
/// The textclass of the document. Could actually be a global variable
- LyXTextClass const & textclass;
+ TeX2LyXDocClass const & textclass;
/// The layout of the current paragraph
- LyXLayout_ptr layout;
+ Layout const * layout;
/// The layout of the outer paragraph (for environment layouts)
- LyXLayout_ptr parent_layout;
+ Layout const * parent_layout;
/// font attributes of this context
- Font font;
+ TeXFont font;
/// font attributes of normal text
- static Font normalfont;
+ static TeXFont normalfont;
+ /// Table rotation angle
+ int tablerotation;
+ ///
+ bool in_table_cell;
+ ///
+ char cell_align;
+
+private:
+ void begin_layout(std::ostream & os, Layout const * const & l);
};