[LyX/master] DocBook: add the MathML-namespace prefix in the GUI.

Thibaut Cuvelier tcuvelier at lyx.org
Mon Mar 22 23:33:20 UTC 2021


commit 6a5288e31ead332a096b6137699a2cc767665e94
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Tue Mar 23 00:32:36 2021 +0100

    DocBook: add the MathML-namespace prefix in the GUI.
---
 src/BufferParams.cpp             |    6 ++++
 src/frontends/qt/GuiDocument.cpp |   10 +++++-
 src/frontends/qt/ui/OutputUi.ui  |   57 ++++++++++++++++++++++++++++++++++++++
 src/tex2lyx/Preamble.cpp         |    2 +
 src/tex2lyx/Preamble.h           |    1 +
 5 files changed, 74 insertions(+), 2 deletions(-)

diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 35c2172..ec4cc0d 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -478,6 +478,7 @@ BufferParams::BufferParams()
 	html_math_img_scale = 1.0;
 	html_css_as_file = false;
 	docbook_table_output = HTMLTable;
+	docbook_mathml_prefix = MPrefix;
 	display_pixel_ratio = 1.0;
 
 	shell_escape = false;
@@ -1191,6 +1192,10 @@ string BufferParams::readToken(Lexer & lex, string const & token,
 		int temp;
 		lex >> temp;
 		docbook_table_output = static_cast<TableOutput>(temp);
+	} else if (token == "\\docbook_mathml_prefix") {
+		int temp;
+		lex >> temp;
+		docbook_mathml_prefix = static_cast<MathMLNameSpacePrefix>(temp);
 	} else if (token == "\\output_sync") {
 		lex >> output_sync;
 	} else if (token == "\\output_sync_macro") {
@@ -1555,6 +1560,7 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
 	   << "\\html_be_strict " << convert<string>(html_be_strict) << '\n';
 
 	os << "\\docbook_table_output " << docbook_table_output << '\n';
+	os << "\\docbook_mathml_prefix " << docbook_mathml_prefix << '\n';
 
 	if (html_math_img_scale != 1.0)
 		os << "\\html_math_img_scale " << convert<string>(html_math_img_scale) << '\n';
diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp
index 85564bd..3bda935 100644
--- a/src/frontends/qt/GuiDocument.cpp
+++ b/src/frontends/qt/GuiDocument.cpp
@@ -3778,10 +3778,15 @@ void GuiDocument::applyView()
 	int tablefmt = outputModule->tableoutCB->currentIndex();
 	if (tablefmt == -1)
 		tablefmt = 0;
-	BufferParams::TableOutput const to =
-			static_cast<BufferParams::TableOutput>(tablefmt);
+	auto const to = static_cast<BufferParams::TableOutput>(tablefmt);
 	bp_.docbook_table_output = to;
 
+	int mathmlprefix = outputModule->mathmlprefixCB->currentIndex();
+	if (mathmlprefix == -1)
+		mathmlprefix = 0;
+	auto const mp = static_cast<BufferParams::MathMLNameSpacePrefix>(mathmlprefix);
+	bp_.docbook_mathml_prefix = mp;
+
 	bp_.save_transient_properties =
 		outputModule->saveTransientPropertiesCB->isChecked();
 	bp_.postpone_fragile_content =
@@ -4422,6 +4427,7 @@ void GuiDocument::paramsToDialog()
 	outputModule->cssCB->setChecked(bp_.html_css_as_file);
 
 	outputModule->tableoutCB->setCurrentIndex(bp_.docbook_table_output);
+	outputModule->mathmlprefixCB->setCurrentIndex(bp_.docbook_mathml_prefix);
 
 	outputModule->saveTransientPropertiesCB
 		->setChecked(bp_.save_transient_properties);
diff --git a/src/frontends/qt/ui/OutputUi.ui b/src/frontends/qt/ui/OutputUi.ui
index 6dc2a29..ba04619 100644
--- a/src/frontends/qt/ui/OutputUi.ui
+++ b/src/frontends/qt/ui/OutputUi.ui
@@ -75,6 +75,63 @@
         </property>
        </spacer>
       </item>
+      <item row="1" column="0">
+       <widget class="QLabel" name="mathmlprefixLA">
+        <property name="font">
+         <font>
+          <weight>50</weight>
+          <bold>false</bold>
+         </font>
+        </property>
+        <property name="text">
+         <string>&MathML namespace prefix:</string>
+        </property>
+        <property name="buddy">
+         <cstring>mathmlprefixCB</cstring>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1">
+       <widget class="QComboBox" name="mathmlprefixCB">
+        <property name="font">
+         <font>
+          <weight>50</weight>
+          <bold>false</bold>
+         </font>
+        </property>
+        <property name="toolTip">
+         <string>Namespace prefix to use for MathML formulae.</string>
+        </property>
+        <item>
+         <property name="text">
+          <string>No prefix (namespace defined inline for each tag)</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>m (default)</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>mml</string>
+         </property>
+        </item>
+       </widget>
+      </item>
+      <item row="1" column="2">
+       <spacer name="horizontalSpacer_6">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>40</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
      </layout>
     </widget>
    </item>
diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index f15a9f1..e14176e 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -554,6 +554,7 @@ Preamble::Preamble() : one_language(true), explicit_babel(false),
 	h_html_css_as_file        = "0";
 	h_html_math_output        = "0";
 	h_docbook_table_output    = "0";
+	h_docbook_mathml_prefix   = "1";
 	h_index[0]                = "Index";
 	h_index_command           = "default";
 	h_inputencoding           = "auto-legacy";
@@ -2129,6 +2130,7 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled
 	   << "\\html_css_as_file " << h_html_css_as_file << "\n"
 	   << "\\html_be_strict " << h_html_be_strict << "\n"
 	   << "\\docbook_table_output " << h_docbook_table_output << "\n"
+	   << "\\docbook_mathml_prefix " << h_docbook_mathml_prefix << "\n"
 	   << authors_
 	   << "\\end_header\n\n"
 	   << "\\begin_body\n";
diff --git a/src/tex2lyx/Preamble.h b/src/tex2lyx/Preamble.h
index 5287f53..8bdb358 100644
--- a/src/tex2lyx/Preamble.h
+++ b/src/tex2lyx/Preamble.h
@@ -193,6 +193,7 @@ private:
 	std::string h_html_css_as_file;
 	std::string h_html_math_output;
 	std::string h_docbook_table_output;
+	std::string h_docbook_mathml_prefix;
 	std::string h_index[99];
 	std::string h_index_command;
 	std::string h_inputencoding;


More information about the lyx-cvs mailing list