]> git.lyx.org Git - lyx.git/commitdiff
Add "notes" CiteEngine Type
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 7 Jul 2024 13:14:05 +0000 (15:14 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 7 Jul 2024 13:14:05 +0000 (15:14 +0200)
This is needed for (forthcoming) biblatex-chicago support (see #12240)

lib/scripts/layout2layout.py
src/Citation.h
src/CiteEnginesList.cpp
src/TextClass.cpp
src/frontends/qt/GuiDocument.cpp

index a610da47616e8246042e5ee638f1f075a40a0b64..428cf709a4ddc0d5c052e2c2af253a3ed1b9e93f 100644 (file)
@@ -9,7 +9,7 @@
 # This script will update a .layout file to current format
 
 # The latest layout format is also defined in src/TextClass.cpp
-currentFormat = 105
+currentFormat = 106
 
 
 # Incremented to format 4, 6 April 2007, lasgouttes
@@ -352,6 +352,9 @@ currentFormat = 105
 # Incremented to format 105, 2 June 2024 by spitz
 # ParskipFull and ParskipHalf class options
 
+# Incremented to format 106, 7 July 2024 by spitz
+# New CiteEngine type "notes"
+
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
 
@@ -586,7 +589,7 @@ def convert(lines, end_format):
                 i += 1
             continue
 
-        if 101 <= format <= 104:
+        if 101 <= format <= 105:
             # nothing to do.
             i += 1
             continue
index b7af22b751dac00951265db9d90be3ce43220d34..77c6f6f07f4f2c1c89d4fef047e03b4e43d7d8f7 100644 (file)
@@ -22,7 +22,8 @@ namespace lyx {
 enum CiteEngineType {
        ENGINE_TYPE_AUTHORYEAR = 1,
        ENGINE_TYPE_NUMERICAL = 2,
-       ENGINE_TYPE_DEFAULT = 3,
+       ENGINE_TYPE_NOTES = 4,
+       ENGINE_TYPE_DEFAULT = 7,
 };
 
 
index b12fa75edf280ce4dbdc96122a1e3569aa70672d..ef00d1d3be9a0d8d04d018baa938c108a502d956 100644 (file)
@@ -135,6 +135,7 @@ CiteEngineTypeTranslator const init_citeenginetypetranslator()
 {
        CiteEngineTypeTranslator translator("authoryear", ENGINE_TYPE_AUTHORYEAR);
        translator.addPair("numerical", ENGINE_TYPE_NUMERICAL);
+       translator.addPair("notes", ENGINE_TYPE_NOTES);
        translator.addPair("default", ENGINE_TYPE_DEFAULT);
        return translator;
 }
index 88164705527800521947b7f3a5c718f5c0880ebc..06d7b8453b98dd277a9b4f7cb74ba96552cd0832 100644 (file)
@@ -59,7 +59,7 @@ namespace lyx {
 // You should also run the development/tools/updatelayouts.py script,
 // to update the format of all of our layout files.
 //
-int const LAYOUT_FORMAT = 105; // spitz: ParskipHalf and ParskipFull class options
+int const LAYOUT_FORMAT = 106; // spitz: CiteEngineType notes
 
 
 // Layout format for the current lyx file format. Controls which format is
@@ -1117,6 +1117,7 @@ bool TextClass::readCiteEngine(Lexer & lexrc, ReadType rt, bool const add)
        int const type = readCiteEngineType(lexrc);
        bool authoryear = (type & ENGINE_TYPE_AUTHORYEAR);
        bool numerical = (type & ENGINE_TYPE_NUMERICAL);
+       bool notes = (type & ENGINE_TYPE_NOTES);
        bool defce = (type & ENGINE_TYPE_DEFAULT);
 
        if (rt == CITE_ENGINE) {
@@ -1126,6 +1127,8 @@ bool TextClass::readCiteEngine(Lexer & lexrc, ReadType rt, bool const add)
                        authoryear = getCiteStyles(ENGINE_TYPE_AUTHORYEAR).empty();
                if (numerical)
                        numerical = getCiteStyles(ENGINE_TYPE_NUMERICAL).empty();
+               if (notes)
+                       numerical = getCiteStyles(ENGINE_TYPE_NOTES).empty();
                if (defce)
                        defce = getCiteStyles(ENGINE_TYPE_DEFAULT).empty();
        }
@@ -1137,6 +1140,8 @@ bool TextClass::readCiteEngine(Lexer & lexrc, ReadType rt, bool const add)
                        cite_styles_[ENGINE_TYPE_AUTHORYEAR].clear();
                if (numerical)
                        cite_styles_[ENGINE_TYPE_NUMERICAL].clear();
+               if (notes)
+                       cite_styles_[ENGINE_TYPE_NOTES].clear();
                if (defce)
                        cite_styles_[ENGINE_TYPE_DEFAULT].clear();
        }
@@ -1236,6 +1241,8 @@ bool TextClass::readCiteEngine(Lexer & lexrc, ReadType rt, bool const add)
                                class_cite_styles_[ENGINE_TYPE_AUTHORYEAR].push_back(cs);
                        if (numerical)
                                class_cite_styles_[ENGINE_TYPE_NUMERICAL].push_back(cs);
+                       if (notes)
+                               class_cite_styles_[ENGINE_TYPE_NOTES].push_back(cs);
                        if (defce)
                                class_cite_styles_[ENGINE_TYPE_DEFAULT].push_back(cs);
                } else {
@@ -1243,6 +1250,8 @@ bool TextClass::readCiteEngine(Lexer & lexrc, ReadType rt, bool const add)
                                cite_styles_[ENGINE_TYPE_AUTHORYEAR].push_back(cs);
                        if (numerical)
                                cite_styles_[ENGINE_TYPE_NUMERICAL].push_back(cs);
+                       if (notes)
+                               cite_styles_[ENGINE_TYPE_NOTES].push_back(cs);
                        if (defce)
                                cite_styles_[ENGINE_TYPE_DEFAULT].push_back(cs);
                }
@@ -1251,12 +1260,15 @@ bool TextClass::readCiteEngine(Lexer & lexrc, ReadType rt, bool const add)
        // except if we have already a style to add something to
        bool apply_ay = !add;
        bool apply_num = !add;
+       bool apply_notes = !add;
        bool apply_def = !add;
        if (add) {
                if (type & ENGINE_TYPE_AUTHORYEAR)
                        apply_ay = !getCiteStyles(ENGINE_TYPE_AUTHORYEAR).empty();
                if (type & ENGINE_TYPE_NUMERICAL)
                        apply_num = !getCiteStyles(ENGINE_TYPE_NUMERICAL).empty();
+               if (type & ENGINE_TYPE_NOTES)
+                       apply_num = !getCiteStyles(ENGINE_TYPE_NOTES).empty();
                if (type & ENGINE_TYPE_DEFAULT)
                        apply_def = !getCiteStyles(ENGINE_TYPE_DEFAULT).empty();
        }
@@ -1278,6 +1290,8 @@ bool TextClass::readCiteEngine(Lexer & lexrc, ReadType rt, bool const add)
                                        cite_styles_[ENGINE_TYPE_AUTHORYEAR].push_back(ciss);
                                else if (cis.first == ENGINE_TYPE_NUMERICAL && apply_num)
                                        cite_styles_[ENGINE_TYPE_NUMERICAL].push_back(ciss);
+                               else if (cis.first == ENGINE_TYPE_NOTES && apply_notes)
+                                       cite_styles_[ENGINE_TYPE_NOTES].push_back(ciss);
                                else if (cis.first == ENGINE_TYPE_DEFAULT && apply_def)
                                        cite_styles_[ENGINE_TYPE_DEFAULT].push_back(ciss);
                        }
@@ -1287,6 +1301,8 @@ bool TextClass::readCiteEngine(Lexer & lexrc, ReadType rt, bool const add)
                class_cite_styles_[ENGINE_TYPE_AUTHORYEAR].clear();
        if (type & ENGINE_TYPE_NUMERICAL && apply_num)
                class_cite_styles_[ENGINE_TYPE_NUMERICAL].clear();
+       if (type & ENGINE_TYPE_NOTES && apply_notes)
+               class_cite_styles_[ENGINE_TYPE_NOTES].clear();
        if (type & ENGINE_TYPE_DEFAULT && apply_def)
                class_cite_styles_[ENGINE_TYPE_DEFAULT].clear();
        return getout;
@@ -1296,7 +1312,7 @@ bool TextClass::readCiteEngine(Lexer & lexrc, ReadType rt, bool const add)
 int TextClass::readCiteEngineType(Lexer & lexrc) const
 {
        static_assert(ENGINE_TYPE_DEFAULT ==
-                                 (ENGINE_TYPE_AUTHORYEAR | ENGINE_TYPE_NUMERICAL),
+                                 (ENGINE_TYPE_AUTHORYEAR | ENGINE_TYPE_NUMERICAL | ENGINE_TYPE_NOTES),
                                  "Incorrect default engine type");
        if (!lexrc.next()) {
                lexrc.printError("No cite engine type given for token: `$$Token'.");
@@ -1307,6 +1323,8 @@ int TextClass::readCiteEngineType(Lexer & lexrc) const
                return ENGINE_TYPE_AUTHORYEAR;
        else if (compare_ascii_no_case(type, "numerical") == 0)
                return ENGINE_TYPE_NUMERICAL;
+       else if (compare_ascii_no_case(type, "notes") == 0)
+               return ENGINE_TYPE_NOTES;
        else if (compare_ascii_no_case(type, "default") != 0) {
                string const s = "Unknown cite engine type `" + type
                        + "' given for token: `$$Token',";
@@ -1340,6 +1358,7 @@ bool TextClass::readCiteFormat(Lexer & lexrc, ReadType rt)
                        bool defined = false;
                        bool aydefined = false;
                        bool numdefined = false;
+                       bool notesdefined = false;
                        // Check if the macro is already def'ed
                        for (auto const & cm : cite_macros_) {
                                if (!(type & cm.first))
@@ -1354,6 +1373,9 @@ bool TextClass::readCiteFormat(Lexer & lexrc, ReadType rt)
                                        else if (cm.first == ENGINE_TYPE_NUMERICAL)
                                                // defined for numerical
                                                numdefined = true;
+                                       else if (cm.first == ENGINE_TYPE_NOTES)
+                                               // defined for notes
+                                               notesdefined = true;
                                }
                        }
                        if (!defined || overwrite) {
@@ -1361,6 +1383,8 @@ bool TextClass::readCiteFormat(Lexer & lexrc, ReadType rt)
                                        cite_macros_[ENGINE_TYPE_AUTHORYEAR][etype] = definition;
                                if (type & ENGINE_TYPE_NUMERICAL && (type != ENGINE_TYPE_DEFAULT || !numdefined))
                                        cite_macros_[ENGINE_TYPE_NUMERICAL][etype] = definition;
+                               if (type & ENGINE_TYPE_NOTES && (type != ENGINE_TYPE_DEFAULT || !notesdefined))
+                                       cite_macros_[ENGINE_TYPE_NOTES][etype] = definition;
                                if (type == ENGINE_TYPE_DEFAULT)
                                        cite_macros_[ENGINE_TYPE_DEFAULT][etype] = definition;
                        }
@@ -1368,6 +1392,7 @@ bool TextClass::readCiteFormat(Lexer & lexrc, ReadType rt)
                        bool defined = false;
                        bool aydefined = false;
                        bool numdefined = false;
+                       bool notesdefined = false;
                        // Check if the format is already def'ed
                        for (auto const & cm : cite_formats_) {
                                if (!(type & cm.first))
@@ -1382,6 +1407,9 @@ bool TextClass::readCiteFormat(Lexer & lexrc, ReadType rt)
                                        else if (cm.first == ENGINE_TYPE_NUMERICAL)
                                                // defined for numerical
                                                numdefined = true;
+                                       else if (cm.first == ENGINE_TYPE_NOTES)
+                                               // defined for notes
+                                               notesdefined = true;
                                }
                        }
                        if (!defined || overwrite){
@@ -1389,6 +1417,8 @@ bool TextClass::readCiteFormat(Lexer & lexrc, ReadType rt)
                                        cite_formats_[ENGINE_TYPE_AUTHORYEAR][etype] = definition;
                                if (type & ENGINE_TYPE_NUMERICAL && (type != ENGINE_TYPE_DEFAULT || !numdefined))
                                        cite_formats_[ENGINE_TYPE_NUMERICAL][etype] = definition;
+                               if (type & ENGINE_TYPE_NOTES && (type != ENGINE_TYPE_DEFAULT || !notesdefined))
+                                       cite_formats_[ENGINE_TYPE_NOTES][etype] = definition;
                                if (type == ENGINE_TYPE_DEFAULT)
                                        cite_formats_[ENGINE_TYPE_DEFAULT][etype] = definition;
                        }
index 0404fb22c6a2f9b3f523447ee1f8b91118d27dae..4c1cb600267ea226c18f39b99f2ef23b5b8773dc 100644 (file)
@@ -3286,6 +3286,9 @@ void GuiDocument::updateCiteStyles(vector<string> const & engs, CiteEngineType c
                else if (*it == "numerical")
                        biblioModule->citeStyleCO->addItem(qt_("Author-number"),
                                                           ENGINE_TYPE_NUMERICAL);
+               else if (*it == "notes")
+                       biblioModule->citeStyleCO->addItem(qt_("Notes[[bib style]]"),
+                                                          ENGINE_TYPE_NOTES);
        }
        int i = biblioModule->citeStyleCO->findData(sel);
        if (biblioModule->citeStyleCO->findData(sel) == -1)