From: Juergen Spitzmueller Date: Tue, 25 Sep 2018 13:24:46 +0000 (+0200) Subject: Add bibtex inset to outliner if "add to toc" is checked. X-Git-Tag: 2.3.2~60 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=416b71883b439476495e8c3db53aac741692799d;p=features.git Add bibtex inset to outliner if "add to toc" is checked. Fixes #11309 (cherry picked from commit a89e3c344bdafd2922321e434c2384020318ed2e) --- diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index 7a045932ba..8fd5fdef4d 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -31,6 +31,7 @@ #include "PDFOptions.h" #include "texstream.h" #include "TextClass.h" +#include "TocBackend.h" #include "frontends/alert.h" @@ -877,10 +878,31 @@ void InsetBibtex::validate(LaTeXFeatures & features) const } +docstring InsetBibtex::getRefLabel() const +{ + if (buffer().masterParams().documentClass().hasLaTeXLayout("chapter")) + return buffer().B_("Bibliography"); + return buffer().B_("References"); +} + + +void InsetBibtex::addToToc(DocIterator const & cpit, bool output_active, + UpdateType, TocBackend & backend) const +{ + if (!prefixIs(to_utf8(getParam("options")), "bibtotoc")) + return; + + docstring const str = getRefLabel(); + TocBuilder & b = backend.builder("tableofcontents"); + b.pushItem(cpit, str, output_active); + b.pop(); +} + + int InsetBibtex::plaintext(odocstringstream & os, OutputParams const & op, size_t max_length) const { - docstring const reflabel = buffer().B_("References"); + docstring const reflabel = getRefLabel(); // We could output more information here, e.g., what databases are included // and information about options. But I don't necessarily see any reason to diff --git a/src/insets/InsetBibtex.h b/src/insets/InsetBibtex.h index ec783d857b..bcad1a6b95 100644 --- a/src/insets/InsetBibtex.h +++ b/src/insets/InsetBibtex.h @@ -57,6 +57,9 @@ public: int plaintext(odocstringstream & ods, OutputParams const & op, size_t max_length = INT_MAX) const; /// + void addToToc(DocIterator const & di, bool output_active, + UpdateType utype, TocBackend & backend) const; + /// void collectBibKeys(InsetIterator const &, support::FileNameList &) const; /// void validate(LaTeXFeatures &) const; @@ -84,6 +87,8 @@ private: void parseBibTeXFiles(support::FileNameList &) const; /// bool usingBiblatex() const; + /// + docstring getRefLabel() const; /// \name Private functions inherited from Inset class //@{ diff --git a/status.23x b/status.23x index c07d5058a8..39cbc4cf4d 100644 --- a/status.23x +++ b/status.23x @@ -65,6 +65,8 @@ What's new - Allow the 'module in child not used in master' warning to be disabled. +- Add bibtex inset to outliner if "add to toc" is checked (bug 11309). + * DOCUMENTATION AND LOCALIZATION