]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/context.h
* support/qstring_helpers.h: erase ucs4_to_qstring() method.
[lyx.git] / src / tex2lyx / context.h
index 5a2edffe9a5a77f9c48a34eb5ef20465b2d3d140..fd71d6441b26e65231d651f47a782ae6633ab770 100644 (file)
@@ -17,6 +17,9 @@
 #include <iosfwd>
 
 
+namespace lyx {
+
+
 /*!
  * Small helper struct that holds font properties.
  * The names are in LyX language, not LaTeX.
@@ -45,19 +48,40 @@ public:
 };
 
 
+bool operator==(Font const &, Font const &);
+
+
+inline bool operator!=(Font const & f1, Font 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);
+                       Font const & newfont);
 
 
-// A helper struct
+/*!
+ * A helper struct.
+ *
+ * Every bit of text has a corresponding context.
+ * Usage: Parsing begins with a global context. A new context is opened for
+ * every new LaTeX group, e.g. at the beginning of a new environment.
+ * The old context is used again after the group is closed.
+ *
+ * Since not all paragraph parameters in LyX have the same scoping as their
+ * LaTeX counterpart we may have to transfer context properties (e. g. the
+ * font) from and to the parent context.
+ */
 class Context {
 public:
        Context(bool need_layout_,
                LyXTextClass const & textclass_,
                LyXLayout_ptr layout_ = LyXLayout_ptr(),
                LyXLayout_ptr parent_layout_= LyXLayout_ptr(),
-               Font font_ = Font());
+               Font font_ = Font());
+       ~Context();
 
        /// Output a \\begin_layout if requested
        void check_layout(std::ostream & os);
@@ -97,13 +121,23 @@ public:
        /// If there has been an \\begin_deeper, we'll need a matching
        /// \\end_deeper
        bool need_end_deeper;
-       /// If we are in an itemize-like environment, we need an \\item
+       /// If we are in an itemize-like environment, we need an \item
        /// for each paragraph, otherwise this has to be a deeper
        /// paragraph.
        bool has_item;
        /// we are handling a standard paragraph in an itemize-like
        /// environment
        bool deeper_paragraph;
+       /*!
+        * Inside of unknown environments we may not allow font and layout
+        * changes.
+        * Otherwise things like
+        * \\large\\begin{foo}\\huge bar\\end{foo}
+        * would not work.
+        */
+       bool new_layout_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;
@@ -117,4 +151,7 @@ public:
        static Font normalfont;
 };
 
+
+} // namespace lyx
+
 #endif