]> git.lyx.org Git - features.git/commitdiff
Properly resolve crossref'ed data in BiblioInfo
authorJuergen Spitzmueller <spitz@lyx.org>
Sat, 24 Feb 2024 14:26:41 +0000 (15:26 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Sat, 24 Feb 2024 14:26:41 +0000 (15:26 +0100)
This needs to take the mappings into account as well, not just
plain fields.

src/BiblioInfo.cpp

index 63eb2f2263aaf1a94a262f8c1e563ebb54619df2..cb340d4c89b672f248f7e4fc1ed3d94c98d5dcb9 100644 (file)
@@ -1137,15 +1137,6 @@ docstring BibTeXInfo::getValueForKey(string const & oldkey, Buffer const & buf,
        }
 
        docstring ret = operator[](key);
-       if (ret.empty() && !xrefs.empty()) {
-               // xr is a (reference to a) BibTeXInfo const *
-               for (auto const & xr : xrefs) {
-                       if (xr && !(*xr)[key].empty()) {
-                               ret = (*xr)[key];
-                               break;
-                       }
-               }
-       }
        if (ret.empty()) {
                // some special keys
                // FIXME: dialog, textbefore and textafter have nothing to do with this
@@ -1283,6 +1274,21 @@ docstring BibTeXInfo::getValueForKey(string const & oldkey, Buffer const & buf,
                        ret = getYear();
        }
 
+       // If we have no result, check in the cross-ref'ed entries
+       if (ret.empty() && !xrefs.empty()) {
+               // xr is a (reference to a) BibTeXInfo const *
+               for (auto const & xr : xrefs) {
+                       if (!xr)
+                               continue;
+                       // use empty BibTeXInfoList to avoid loops
+                       BibTeXInfoList xr_dummy;
+                       ret = xr->getValueForKey(oldkey, buf, ci, xr_dummy, maxsize);
+                       if (!ret.empty())
+                               // success!
+                               break;
+               }
+       }
+
        if (cleanit)
                ret = xml::cleanAttr(ret);