commit 19cc4a1fcbd0786406b0207dbff43badb93d32ba
Author: Uwe Stöhr <uwesto...@lyx.org>
Date:   Fri May 12 01:06:05 2017 +0200

    GuiDocument: support also the class option reqno
    
    as discussed our support for the formula numbering side should be complete. 
There are document classes that uses left numbering as default and with the 
class option "reqno" this can be changed to right numbering. reqno requires the 
loading of amsamth.
---
 src/BufferParams.cpp              |    8 ++++++--
 src/BufferParams.h                |    4 ++--
 src/frontends/qt4/GuiDocument.cpp |   18 ++++++++++++------
 src/tex2lyx/Preamble.cpp          |    9 +++++++--
 4 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index bdfbc59..ef6ad0a 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -385,7 +385,7 @@ BufferParams::BufferParams()
        makeDocumentClass();
        paragraph_separation = ParagraphIndentSeparation;
        is_math_indent = false;
-       math_number_before = false;
+       math_number_before = "default";
        quotes_style = InsetQuotesParams::EnglishQuotes;
        dynamic_quotes = false;
        fontsize = "default";
@@ -1640,8 +1640,12 @@ bool BufferParams::writeLaTeX(otexstream & os, 
LaTeXFeatures & features,
        if (is_math_indent)
                clsoptions << "fleqn,";
 
-       if (math_number_before)
+       if (math_number_before == "true")
                clsoptions << "leqno,";
+       else if (math_number_before == "false") {
+               clsoptions << "reqno,";
+               features.require("amsmath");
+       }
 
        // language should be a parameter to \documentclass
        if (language->babel() == "hebrew"
diff --git a/src/BufferParams.h b/src/BufferParams.h
index 1c23d6c..be7c814 100644
--- a/src/BufferParams.h
+++ b/src/BufferParams.h
@@ -110,8 +110,8 @@ public:
        bool is_math_indent;
 
 
-       /// number formulas before them
-       bool math_number_before;
+       /// number formulas before or not
+       std::string math_number_before;
 
        /** Whether paragraphs are separated by using a indent like in
         *  articles or by using a little skip like in letters.
diff --git a/src/frontends/qt4/GuiDocument.cpp 
b/src/frontends/qt4/GuiDocument.cpp
index 99a248c..055981e 100644
--- a/src/frontends/qt4/GuiDocument.cpp
+++ b/src/frontends/qt4/GuiDocument.cpp
@@ -1283,7 +1283,8 @@ GuiDocument::GuiDocument(GuiView & lv)
        bc().addCheckedLineEdit(mathsModule->MathIndentLE);
        mathsModule->MathNumberingPosCO->addItem(qt_("Left"));
        mathsModule->MathNumberingPosCO->addItem(qt_("Default"));
-       mathsModule->MathNumberingPosCO->setCurrentIndex(2);
+       mathsModule->MathNumberingPosCO->addItem(qt_("Right"));
+       mathsModule->MathNumberingPosCO->setCurrentIndex(1);
        
 
        // latex class
@@ -2942,14 +2943,17 @@ void GuiDocument::applyView()
        }
        switch (mathsModule->MathNumberingPosCO->currentIndex()) {
                case 0:
-                       bp_.math_number_before = true;
+                       bp_.math_number_before = "true";
                        break;
                case 1:
-                       bp_.math_number_before = false;
+                       bp_.math_number_before = "default";
+                       break;
+               case 2:
+                       bp_.math_number_before = "false";
                        break;
                default:
                        // this should never happen
-                       bp_.math_number_before = false;
+                       bp_.math_number_before = "default";
                        break;
        }
 
@@ -3415,10 +3419,12 @@ void GuiDocument::paramsToDialog()
                mathsModule->MathIndentCO->setCurrentIndex(indent);
                enableMathIndent(indent);
        }
-       if (bp_.math_number_before)
+       if (bp_.math_number_before == "true")
                mathsModule->MathNumberingPosCO->setCurrentIndex(0);
-       else 
+       else if (bp_.math_number_before == "default")
                mathsModule->MathNumberingPosCO->setCurrentIndex(1);
+       else if (bp_.math_number_before == "false")
+               mathsModule->MathNumberingPosCO->setCurrentIndex(2);
 
        map<string, string> const & packages = BufferParams::auto_packages();
        for (map<string, string>::const_iterator it = packages.begin();
diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index 9465331..cf9dab7 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -494,7 +494,7 @@ Preamble::Preamble() : one_language(true), 
explicit_babel(false),
        h_font_tt_scale[1]        = "100";
        //h_font_cjk
        h_is_mathindent           = "0";
-       h_math_number_before      = "0";
+       h_math_number_before      = "default";
        h_graphics                = "default";
        h_default_output_format   = "default";
        h_html_be_strict          = "false";
@@ -1692,7 +1692,12 @@ void Preamble::parse(Parser & p, string const & 
forceclass,
                        // formula numbering side
                        if ((it = find(opts.begin(), opts.end(), "leqno"))
                                 != opts.end()) {
-                               h_math_number_before = "1";
+                               h_math_number_before = "true";
+                               opts.erase(it);
+                       }
+                       else if ((it = find(opts.begin(), opts.end(), "reqno"))
+                                != opts.end()) {
+                               h_math_number_before = "false";
                                opts.erase(it);
                        }
                        

Reply via email to