#include "PDFOptions.h"
#include "texstream.h"
#include "TextClass.h"
+#include "TocBackend.h"
#include "frontends/alert.h"
#include "support/convert.h"
#include "support/debug.h"
#include "support/docstream.h"
+#include "support/docstring_list.h"
#include "support/ExceptionMessage.h"
#include "support/FileNameList.h"
#include "support/filetools.h"
cur.recordUndo();
setParams(p);
+ cur.buffer()->clearBibFileCache();
cur.forceBufferUpdate();
break;
}
vector<docstring>::const_iterator it = bibfilelist.begin();
vector<docstring>::const_iterator en = bibfilelist.end();
for (; it != en; ++it) {
- FileName const bibfile = getBibTeXPath(*it, buffer());
+ FileName const bibfile = buffer().getBibfilePath(*it);
theFormats().edit(buffer(), bibfile,
theFormats().getFormatFromFile(bibfile));
}
tip += _("included in TOC");
}
if (!getParam("biblatexopts").empty()) {
- if (toc)
- tip += "<br />";
+ tip += "<br />";
tip += _("Options: ") + getParam("biblatexopts");
}
}
}
-FileNamePairList InsetBibtex::getBibFiles() const
+docstring_list InsetBibtex::getBibFiles() const
{
- FileName path(buffer().filePath());
- PathChanger p(path);
-
- // We need to store both the real FileName and the way it is entered
- // (with full path, rel path or as a single file name).
- // The latter is needed for biblatex's central bibfile macro.
- FileNamePairList vec;
-
- vector<docstring> bibfilelist = getVectorFromString(getParam("bibfiles"));
- vector<docstring>::const_iterator it = bibfilelist.begin();
- vector<docstring>::const_iterator en = bibfilelist.end();
- for (; it != en; ++it) {
- FileName const file = getBibTeXPath(*it, buffer());
-
- if (!file.empty())
- vec.push_back(make_pair(*it, file));
- else
- LYXERR0("Couldn't find " + to_utf8(*it) + " in InsetBibtex::getBibFiles()!");
- }
-
- return vec;
+ return getVectorFromString(getParam("bibfiles"));
}
namespace {
BiblioInfo keylist;
- FileNamePairList const files = getBibFiles();
- FileNamePairList::const_iterator it = files.begin();
- FileNamePairList::const_iterator en = files.end();
- for (; it != en; ++ it) {
- FileName const bibfile = it->second;
+ docstring_list const files = getBibFiles();
+ for (auto const & bf : files) {
+ FileName const bibfile = buffer().getBibfilePath(bf);
+ if (bibfile.empty()) {
+ LYXERR0("Unable to find path for " << bf << "!");
+ continue;
+ }
if (find(checkedFiles.begin(), checkedFiles.end(), bibfile) != checkedFiles.end())
// already checked this one. Skip.
continue;
VarMap strings;
while (ifs) {
-
ifs.get(ch);
if (!ifs)
break;
}
-FileName InsetBibtex::getBibTeXPath(docstring const & filename, Buffer const & buf)
-{
- string texfile = changeExtension(to_utf8(filename), "bib");
- // note that, if the filename can be found directly from the path,
- // findtexfile will just return a FileName object for that path.
- FileName file(findtexfile(texfile, "bib"));
- if (file.empty())
- file = FileName(makeAbsPath(texfile, buf.filePath()));
- return file;
-}
-
-
bool InsetBibtex::addDatabase(docstring const & db)
{
docstring bibfiles = getParam("bibfiles");
string() : to_ascii(params()["encoding"]);
if (buffer().params().bibEncoding() != enc) {
buffer().params().setBibEncoding(enc);
- buffer().reloadBibInfoCache(true);
+ buffer().invalidateBibinfoCache();
}
}
+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