]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathStream.h
Fix missing TexRow.h include after change 670efa8f646218f2a378f0cc614c4c37a9f6b89a
[lyx.git] / src / mathed / MathStream.h
index 40b06a0ef0561d401c52840bd699a543e8043275..28eda3ff25abc91a2e66573ce0a894eb2d7d2885 100644 (file)
 #ifndef MATH_MATHMLSTREAM_H
 #define MATH_MATHMLSTREAM_H
 
-#include "support/strfwd.h"
-
 #include "InsetMath.h"
-// FIXME: Move to individual insets
-#include "MetricsInfo.h"
+#include "texstream.h"
+#include "TexRow.h"
+
+#include "support/Changer.h"
+#include "support/strfwd.h"
+#include "support/unique_ptr.h"
 
 
 namespace lyx {
@@ -39,10 +41,9 @@ public:
                wsPreview
        };
        ///
-       WriteStream(odocstream & os, bool fragile, bool latex, OutputType output,
-               Encoding const * encoding = 0);
-       ///
-       explicit WriteStream(odocstream & os);
+       explicit WriteStream(otexrowstream & os, bool fragile = false,
+                            bool latex = false, OutputType output = wsDefault,
+                            Encoding const * encoding = 0);
        ///
        ~WriteStream();
        ///
@@ -54,11 +55,17 @@ public:
        ///
        OutputType output() const { return output_; }
        ///
-       odocstream & os() { return os_; }
+       otexrowstream & os() { return os_; }
+       ///
+       TexRow & texrow() { return os_.texrow(); }
        ///
        bool & firstitem() { return firstitem_; }
        ///
        void addlines(unsigned int);
+       /// record whether we can write an immediately following newline char
+       void canBreakLine(bool breakline) { canbreakline_ = breakline; }
+       /// tell whether we can write an immediately following newline char
+       bool canBreakLine() const { return canbreakline_; }
        /// writes space if next thing is isalpha()
        void pendingSpace(bool how);
        /// writes space if next thing is isalpha()
@@ -81,9 +88,15 @@ public:
        bool asciiOnly() const { return ascii_; }
        /// LaTeX encoding
        Encoding const * encoding() const { return encoding_; }
+
+       /// Temporarily change the TexRow information about the outer row entry.
+       Changer changeRowEntry(RowEntry entry);
+       /// TexRow::starts the innermost outer math inset
+       /// returns true if the outer row entry will appear at this line
+       bool startOuterRow();
 private:
        ///
-       odocstream & os_;
+       otexrowstream & os_;
        /// do we have to write \\protect sometimes
        bool fragile_;
        /// are we at the beginning of an MathData?
@@ -102,10 +115,15 @@ private:
        bool locked_;
        /// should we use only ascii chars when producing latex code?
        bool ascii_;
+       /// are we allowed to output an immediately following newline?
+       bool canbreakline_;
        ///
        int line_;
        ///
        Encoding const * encoding_;
+       /// Row entry we are in
+       /// (it is a pointer to allow forward-declaration)
+       unique_ptr<RowEntry> row_entry_;
 };
 
 ///
@@ -262,6 +280,13 @@ public:
 };
 
 
+/// Throw MathExportException to signal that the attempt to export
+/// some math in the current format did not succeed. E.g., we can't
+/// export xymatrix as MathML, so that will throw, and we'll fall back
+/// to images.
+class MathExportException : public std::exception {};
+
+
 class MathStream {
 public:
        ///
@@ -286,9 +311,7 @@ public:
        bool inText() const { return in_text_; }
 private:
        ///
-       void setTextMode() { in_text_ = true; }
-       ///
-       void setMathMode() { in_text_ = false; }
+       void setTextMode(bool t) { in_text_ = t; }
        ///
        odocstream & os_;
        ///
@@ -296,8 +319,6 @@ private:
        ///
        int line_;
        ///
-       char lastchar_;
-       ///
        bool in_text_;
        ///
        odocstringstream deferred_;
@@ -324,30 +345,16 @@ MathStream & operator<<(MathStream &, ETag const &);
 
 
 /// A simpler version of ModeSpecifier, for MathML
-// FIXME There are still problems here with nesting, at least
-// potentially. The problem is that true nesting of text mode isn't
-// actually possible. I.e., we can't have: 
-//             <mtext><mtext></mtext></mtext>
-// So we have to have:
-//             <mtext></mtext><mtext></mtext><mtext></mtext>
-// instead, where the last is really a continuation of the first.
-// We'll need some kind of stack to remember all that.
 class SetMode {
 public:
-       ///
-       explicit SetMode(MathStream & os, bool text, std::string const & attrs);
        ///
        explicit SetMode(MathStream & os, bool text);
        ///
        ~SetMode();
 private:
-       ///
-       void init(bool, std::string const &);
        ///
        MathStream & os_;
        ///
-       bool opened_;
-       ///
        bool was_text_;
 };
 
@@ -376,9 +383,7 @@ public:
        bool inText() const { return in_text_; }
 private:
        ///
-       void setTextMode() { in_text_ = true; }
-       ///
-       void setMathMode() { in_text_ = false; }
+       void setTextMode(bool t) { in_text_ = t; }
        ///
        odocstream & os_;
        ///
@@ -386,8 +391,6 @@ private:
        ///
        int line_;
        ///
-       char lastchar_;
-       ///
        bool in_text_;
        ///
        odocstringstream deferred_;
@@ -415,20 +418,14 @@ HtmlStream & operator<<(HtmlStream &, ETag const &);
 
 class SetHTMLMode {
 public:
-       ///
-       explicit SetHTMLMode(HtmlStream & os, bool text, std::string attrs);
        ///
        explicit SetHTMLMode(HtmlStream & os, bool text);
        ///
        ~SetHTMLMode();
 private:
-       ///
-       void init(bool, std::string const &);
        ///
        HtmlStream & os_;
        ///
-       bool opened_;
-       ///
        bool was_text_;
 };
 
@@ -590,6 +587,9 @@ OctaveStream & operator<<(OctaveStream &, char);
 ///
 OctaveStream & operator<<(OctaveStream &, int);
 
+
+docstring convertDelimToXMLEscape(docstring const & name);
+
 } // namespace lyx
 
 #endif