commit c469ae5b5ebfeb4af79fb0e4cc976e0f6ce5a12b
Author: Thibaut Cuvelier <[email protected]>
Date: Sun Nov 3 03:53:55 2024 +0100
Move the MathMLVersion enum outside of MathMLStream.
This change is required to avoid circular dependencies between MathMLStream
and MathFontInfo: MathFontInfo requires the enum from MathMLStream (a quite
weak dependency) while MathMLStream will require MathFontInfo in a next commit
to handle fonts.
Along the way, make the enumeration an enum class (current best practice in
C++ since C++11).
---
src/BufferParams.cpp | 6 +++---
src/BufferParams.h | 2 +-
src/frontends/qt/GuiDocument.cpp | 2 +-
src/mathed/InsetMathChar.cpp | 2 +-
src/mathed/InsetMathHull.cpp | 6 +++---
src/mathed/MathStream.h | 15 ++++++++-------
6 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 8ae748d46b..29e1e15a73 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -485,7 +485,7 @@ BufferParams::BufferParams()
html_css_as_file = false;
docbook_table_output = HTMLTable;
docbook_mathml_prefix = MPrefix;
- docbook_mathml_version = MathMLStream::mathml3;
+ docbook_mathml_version = MathMLVersion::mathml3;
display_pixel_ratio = 1.0;
shell_escape = false;
@@ -1230,7 +1230,7 @@ string BufferParams::readToken(Lexer & lex, string const
& token,
} else if (token == "\\docbook_mathml_version") {
int temp;
lex >> temp;
- docbook_mathml_version =
static_cast<MathMLStream::MathMLVersion>(temp);
+ docbook_mathml_version = static_cast<MathMLVersion>(temp);
} else if (token == "\\output_sync") {
lex >> output_sync;
} else if (token == "\\output_sync_macro") {
@@ -1626,7 +1626,7 @@ void BufferParams::writeFile(ostream & os, Buffer const *
buf) const
os << "\\docbook_table_output " << docbook_table_output << '\n';
os << "\\docbook_mathml_prefix " << docbook_mathml_prefix << '\n';
- os << "\\docbook_mathml_version " << docbook_mathml_version << '\n';
+ os << "\\docbook_mathml_version " <<
static_cast<int>(docbook_mathml_version) << '\n';
if (html_math_img_scale != 1.0)
os << "\\html_math_img_scale " <<
convert<string>(html_math_img_scale) << '\n';
diff --git a/src/BufferParams.h b/src/BufferParams.h
index 541f8e3fe8..ae1cb02411 100644
--- a/src/BufferParams.h
+++ b/src/BufferParams.h
@@ -629,7 +629,7 @@ public:
MathMLNameSpacePrefix docbook_mathml_prefix;
/// what version of MathML to use for DocBook output (likely different
from the version used for XHTML)
- MathMLStream::MathMLVersion docbook_mathml_version;
+ MathMLVersion docbook_mathml_version;
/// allow the LaTeX backend to run external programs
bool shell_escape;
diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp
index 24bf8b94e6..594f14054f 100644
--- a/src/frontends/qt/GuiDocument.cpp
+++ b/src/frontends/qt/GuiDocument.cpp
@@ -4110,7 +4110,7 @@ void GuiDocument::applyView()
int mathmlversion = outputModule->mathmlverCB->currentIndex();
if (mathmlversion == -1)
mathmlversion = 0;
- auto const mv = static_cast<MathMLStream::MathMLVersion>(mathmlversion);
+ auto const mv = static_cast<MathMLVersion>(mathmlversion);
bp_.docbook_mathml_version = mv;
bp_.save_transient_properties =
diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp
index f504fe147f..801cab60aa 100644
--- a/src/mathed/InsetMathChar.cpp
+++ b/src/mathed/InsetMathChar.cpp
@@ -248,7 +248,7 @@ void InsetMathChar::mathmlize(MathMLStream & ms) const
case '>': entity = ">"; break;
case '&': entity = "&"; break;
case '-':
- if (ms.version() == MathMLStream::mathmlCore) {
+ if (ms.version() == MathMLVersion::mathmlCore) {
// − U+2212 MINUS SIGN
entity = "−";
}
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 4cc695334e..dbf1238ced 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -2432,7 +2432,7 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams
const & runparams) cons
}
odocstringstream osmath;
- MathMLStream ms(osmath, mathmlNamespacePrefix, MathMLStream::mathml3);
+ MathMLStream ms(osmath, mathmlNamespacePrefix, MathMLVersion::mathml3);
// Output the MathML subtree.
// TeX transcription. Avoid MTag/ETag so that there are no extraneous
spaces.
@@ -2665,9 +2665,9 @@ docstring InsetMathHull::xhtml(XMLStream & xs,
OutputParams const & op) const
// FIXME Eventually we would like to do this inset by inset.
if (mathtype == BufferParams::MathML3 || mathtype ==
BufferParams::MathMLCore) {
- MathMLStream::MathMLVersion mathml_version =
MathMLStream::mathmlCore;
+ MathMLVersion mathml_version = MathMLVersion::mathmlCore;
if (mathtype == BufferParams::MathML3)
- mathml_version = MathMLStream::mathml3;
+ mathml_version = MathMLVersion::mathml3;
odocstringstream os;
MathMLStream ms(os, "", mathml_version);
diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h
index bd0e90c3f5..9b76ff5344 100644
--- a/src/mathed/MathStream.h
+++ b/src/mathed/MathStream.h
@@ -27,6 +27,12 @@ class Encoding;
class MathAtom;
class MathData;
+///
+enum class MathMLVersion : int {
+ mathml3,
+ mathmlCore
+};
+
//
// LaTeX/LyX
//
@@ -375,15 +381,10 @@ class MathExportException : public std::exception {};
class MathMLStream {
public:
- ///
- enum MathMLVersion {
- mathml3,
- mathmlCore
- };
-
/// Builds a stream proxy for os; the MathML namespace is given by xmlns
/// (supposed to be already defined elsewhere in the document).
- explicit MathMLStream(odocstream & os, std::string const & xmlns = "",
MathMLVersion version = mathml3);
+ explicit MathMLStream(odocstream & os, std::string const & xmlns = "",
+ MathMLVersion version = MathMLVersion::mathml3);
///
void cr();
/// Indentation when nesting tags
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs