[LyX/master] Properly resolve crossref'ed data in BiblioInfo
Juergen Spitzmueller
spitz at lyx.org
Sat Feb 24 14:28:43 UTC 2024
commit 5b11066a3787bc136b0a5bb6ba34e67af51ccd89
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Sat Feb 24 15:26:41 2024 +0100
Properly resolve crossref'ed data in BiblioInfo
This needs to take the mappings into account as well, not just
plain fields.
---
src/BiblioInfo.cpp | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp
index 63eb2f2263..cb340d4c89 100644
--- a/src/BiblioInfo.cpp
+++ b/src/BiblioInfo.cpp
@@ -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);
More information about the lyx-cvs
mailing list