]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCitation.cpp
Unify the parameters of the [append/copy][row/column] family
[lyx.git] / src / insets / InsetCitation.cpp
index c1a5145f0e70f5e20623fde57d5f07075addf337..2406a2ecb6b8c0a03ef4e0df2152d790a2ce7c32 100644 (file)
@@ -141,20 +141,20 @@ docstring InsetCitation::toolTip(BufferView const & bv, int, int) const
 
 
 namespace {
-       
+
 // FIXME See the header for the issue.
-string defaultCiteCommand(CiteEngine engine)
+string defaultCiteCommand(CiteEngine engine, CiteEngineType engine_type)
 {
        string str;
        switch (engine) {
                case ENGINE_BASIC:
                        str = "cite";
                        break;
-               case ENGINE_NATBIB_AUTHORYEAR:
-                       str = "citet";
-                       break;
-               case ENGINE_NATBIB_NUMERICAL:
-                       str = "citep";
+               case ENGINE_NATBIB:
+                       if (engine_type == ENGINE_TYPE_AUTHORYEAR)
+                               str = "citet";
+                       else
+                               str = "citep";
                        break;
                case ENGINE_JURABIB:
                        str = "cite";
@@ -163,10 +163,11 @@ string defaultCiteCommand(CiteEngine engine)
        return str;
 }
 
-       
-string asValidLatexCommand(string const & input, CiteEngine const engine)
+
+string asValidLatexCommand(string const & input, CiteEngine const engine,
+       CiteEngineType const engine_type)
 {
-       string const default_str = defaultCiteCommand(engine);
+       string const default_str = defaultCiteCommand(engine, engine_type);
        if (!InsetCitation::isCompatibleCommand(input))
                return default_str;
 
@@ -179,8 +180,7 @@ string asValidLatexCommand(string const & input, CiteEngine const engine)
                                output = default_str;
                        break;
 
-               case ENGINE_NATBIB_AUTHORYEAR:
-               case ENGINE_NATBIB_NUMERICAL:
+               case ENGINE_NATBIB:
                        if (input == "cite" || input == "citefield"
                            || input == "citetitle" || input == "cite*")
                                output = default_str;
@@ -210,7 +210,7 @@ string asValidLatexCommand(string const & input, CiteEngine const engine)
 }
 
 
-inline docstring wrapCitation(docstring const & key, 
+inline docstring wrapCitation(docstring const & key,
                docstring const & content, bool for_xhtml)
 {
        if (!for_xhtml)
@@ -259,8 +259,9 @@ docstring InsetCitation::complexLabel(bool for_xhtml) const
        // CITE:        author/<before field>
 
        CiteEngine const engine = buffer().params().citeEngine();
+       CiteEngineType const engine_type = buffer().params().citeEngineType();
        // We don't currently use the full or forceUCase fields.
-       string cite_type = asValidLatexCommand(getCmdName(), engine);
+       string cite_type = asValidLatexCommand(getCmdName(), engine, engine_type);
        if (cite_type[0] == 'C')
                // If we were going to use them, this would mean ForceUCase
                cite_type = string(1, 'c') + cite_type.substr(1);
@@ -341,22 +342,22 @@ docstring InsetCitation::complexLabel(bool for_xhtml) const
                                else
                                        label += wrapCitation(*it, author, for_xhtml) + sep_str;
                        }
-               } 
+               }
                // nocite
                else if (cite_type == "nocite") {
                        label += *it + sep_str;
-               } 
+               }
                // (authors1 (<before> year);  ... ;
                //  authors_last (<before> year, <after>)
                else if (cite_type == "citet") {
                        switch (engine) {
-                       case ENGINE_NATBIB_AUTHORYEAR:
-                               label += author + op_str + before_str +
-                                       wrapCitation(*it, year, for_xhtml) + cp + sep_str;
-                               break;
-                       case ENGINE_NATBIB_NUMERICAL:
-                               label += author + op_str + before_str + 
-                                       wrapCitation(*it, citenum, for_xhtml) + cp + sep_str;
+                       case ENGINE_NATBIB:
+                               if (engine_type == ENGINE_TYPE_AUTHORYEAR)
+                                       label += author + op_str + before_str +
+                                               wrapCitation(*it, year, for_xhtml) + cp + sep_str;
+                               else
+                                       label += author + op_str + before_str +
+                                               wrapCitation(*it, citenum, for_xhtml) + cp + sep_str;
                                break;
                        case ENGINE_JURABIB:
                                label += before_str + author + op_str +
@@ -365,39 +366,39 @@ docstring InsetCitation::complexLabel(bool for_xhtml) const
                        case ENGINE_BASIC:
                                break;
                        }
-               } 
-               // author, year; author, year; ...      
+               }
+               // author, year; author, year; ...
                else if (cite_type == "citep" ||
                           cite_type == "citealp") {
-                       if (engine == ENGINE_NATBIB_NUMERICAL) {
+                       if (engine_type == ENGINE_TYPE_NUMERICAL) {
                                label += wrapCitation(*it, citenum, for_xhtml) + sep_str;
                        } else {
                                label += wrapCitation(*it, author + ", " + year, for_xhtml) + sep_str;
                        }
 
-               } 
+               }
                // (authors1 <before> year;
                //  authors_last <before> year, <after>)
                else if (cite_type == "citealt") {
                        switch (engine) {
-                       case ENGINE_NATBIB_AUTHORYEAR:
-                               label += author + ' ' + before_str +
-                                       wrapCitation(*it, year, for_xhtml) + sep_str;
-                               break;
-                       case ENGINE_NATBIB_NUMERICAL:
-                               label += author + ' ' + before_str + '#' + 
-                                       wrapCitation(*it, citenum, for_xhtml) + sep_str;
+                       case ENGINE_NATBIB:
+                               if (engine_type == ENGINE_TYPE_AUTHORYEAR)
+                                       label += author + ' ' + before_str +
+                                               wrapCitation(*it, year, for_xhtml) + sep_str;
+                               else
+                                       label += author + ' ' + before_str + '#' +
+                                               wrapCitation(*it, citenum, for_xhtml) + sep_str;
                                break;
                        case ENGINE_JURABIB:
-                               label += before_str + 
+                               label += before_str +
                                        wrapCitation(*it, author + ' ' + year, for_xhtml) + sep_str;
                                break;
                        case ENGINE_BASIC:
                                break;
                        }
 
-               
-               } 
+
+               }
                // author; author; ...
                else if (cite_type == "citeauthor") {
                        label += wrapCitation(*it, author, for_xhtml) + sep_str;
@@ -416,7 +417,8 @@ docstring InsetCitation::complexLabel(bool for_xhtml) const
                        label.insert(label.size() - 1, after_str);
                } else {
                        bool const add =
-                               !(engine == ENGINE_NATBIB_NUMERICAL &&
+                               !(engine == ENGINE_NATBIB &&
+                                 engine_type == ENGINE_TYPE_NUMERICAL &&
                                  (cite_type == "citeauthor" ||
                                   cite_type == "citeyear"));
                        if (add)
@@ -430,7 +432,7 @@ docstring InsetCitation::complexLabel(bool for_xhtml) const
                label = before_str + label;
        }
 
-       if (cite_type == "citep" || cite_type == "citeyearpar" || 
+       if (cite_type == "citep" || cite_type == "citeyearpar" ||
            (cite_type == "cite" && engine == ENGINE_BASIC) )
                label = op + label + cp;
 
@@ -567,10 +569,11 @@ void InsetCitation::forToc(docstring & os, size_t) const
 void InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
 {
        CiteEngine cite_engine = buffer().params().citeEngine();
+       CiteEngineType cite_engine_type = buffer().params().citeEngineType();
        BiblioInfo const & bi = buffer().masterBibInfo();
        // FIXME UNICODE
        docstring const cite_str = from_utf8(
-               asValidLatexCommand(getCmdName(), cite_engine));
+               asValidLatexCommand(getCmdName(), cite_engine, cite_engine_type));
 
        if (runparams.inulemcmd)
                os << "\\mbox{";
@@ -600,8 +603,7 @@ void InsetCitation::validate(LaTeXFeatures & features) const
        switch (features.bufferParams().citeEngine()) {
        case ENGINE_BASIC:
                break;
-       case ENGINE_NATBIB_AUTHORYEAR:
-       case ENGINE_NATBIB_NUMERICAL:
+       case ENGINE_NATBIB:
                features.require("natbib");
                break;
        case ENGINE_JURABIB: