]> git.lyx.org Git - lyx.git/commitdiff
Cleanup MathMLStream
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 19 Jul 2024 12:57:58 +0000 (14:57 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 22 Jul 2024 18:53:29 +0000 (20:53 +0200)
This is preparatory work for fixing ticket #13069.

Remove direct accesses to the underlying stream of MathMLStream in
InsetMathChar, InsetMathSpecialChar, and in all << operators other
than MathMLStream << docstring. This will allow to add a hook later in
this operator.

Move default values of MathMLStream private members to their definition.

Get rid of line_ member, which is not used.

src/mathed/InsetMathChar.cpp
src/mathed/InsetMathSpecialChar.cpp
src/mathed/MathStream.cpp
src/mathed/MathStream.h

index 199982a5f7a13c829548adc92e9bdef6a71bce69..82d0b63f1eee61d06a43430fd6715272ac00e79a 100644 (file)
@@ -248,7 +248,7 @@ void InsetMathChar::mathmlize(MathMLStream & ms) const
 
        if (ms.inText()) {
                if (entity.empty())
-                       ms.os().put(char_);
+                       ms << char_;
                else
                        ms << from_ascii(entity);
                return;
index 746cec5bdabd5370d0c4da9563eb254061512047..12c9a4c1116d0838f15601759b094d92e7d91861 100644 (file)
@@ -139,7 +139,7 @@ void InsetMathSpecialChar::mathmlize(MathMLStream & ms) const
                ms << "&amp;";
                break;
        default:
-               ms.os().put(char_);
+               ms << char_;
                break;
        }
 }
index 4a006e4809672e88e5f3f0f3252a22ec4a07d9e2..dc4aa05df918656f87a8c2abc5cfd2b9773451f0 100644 (file)
@@ -289,7 +289,7 @@ TeXMathStream & operator<<(TeXMathStream & ws, unsigned int i)
 
 
 MathMLStream::MathMLStream(odocstream & os, std::string const & xmlns)
-       : os_(os), tab_(0), line_(0), in_text_(false), xmlns_(xmlns)
+       : os_(os), xmlns_(xmlns)
 {
        if (in_text_)
                font_math_style_ = TEXT_STYLE;
@@ -338,23 +338,30 @@ MathMLStream & operator<<(MathMLStream & ms, MathData const & ar)
 }
 
 
-MathMLStream & operator<<(MathMLStream & ms, char const * s)
+MathMLStream & operator<<(MathMLStream & ms, docstring const & s)
 {
        ms.os() << s;
        return ms;
 }
 
 
+MathMLStream & operator<<(MathMLStream & ms, char const * s)
+{
+       ms << from_utf8(s);
+       return ms;
+}
+
+
 MathMLStream & operator<<(MathMLStream & ms, char c)
 {
-       ms.os() << c;
+       ms << docstring(1,c);
        return ms;
 }
 
 
 MathMLStream & operator<<(MathMLStream & ms, char_type c)
 {
-       ms.os().put(c);
+       ms << docstring(1,c);
        return ms;
 }
 
@@ -410,13 +417,6 @@ MathMLStream & operator<<(MathMLStream & ms, CTag const & t)
 }
 
 
-MathMLStream & operator<<(MathMLStream & ms, docstring const & s)
-{
-       ms.os() << s;
-       return ms;
-}
-
-
 //////////////////////////////////////////////////////////////////////
 
 
index 04c7cb507eb228a5372a3ab358950d6502306c48..c8d684bc3844c3619f03b5354490353649ba0864 100644 (file)
@@ -9,8 +9,8 @@
  * Full author contact details are available in file CREDITS.
  */
 
-#ifndef MATH_MATHMLSTREAM_H
-#define MATH_MATHMLSTREAM_H
+#ifndef MATH_MATHSTREAM_H
+#define MATH_MATHSTREAM_H
 
 #include "InsetMath.h"
 #include "FontInfo.h"
@@ -382,13 +382,9 @@ public:
        void cr();
        ///
        odocstream & os() { return os_; }
-       ///
-       int line() const { return line_; }
-       ///
+       /// Indentation when nesting tags
        int & tab() { return tab_; }
        ///
-       friend MathMLStream & operator<<(MathMLStream &, char const *);
-       ///
        void defer(docstring const &);
        ///
        void defer(std::string const &);
@@ -412,11 +408,9 @@ private:
        ///
        odocstream & os_;
        ///
-       int tab_;
-       ///
-       int line_;
+       int tab_ = 0;
        ///
-       bool in_text_;
+       bool in_text_ = false;
        ///
        odocstringstream deferred_;
        ///