2 * \file ControlBibtex.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS.
15 #include "ControlBibtex.h"
19 #include "bufferparams.h"
22 #include "helper_funcs.h"
23 #include "tex_helpers.h"
26 #include "support/filefilterlist.h"
27 #include "support/filetools.h"
28 #include "support/lstrings.h"
37 using support::contains;
38 using support::FileFilterList;
39 using support::OnlyFilename;
40 using support::prefixIs;
46 ControlBibtex::ControlBibtex(Dialog & d)
47 : ControlCommand(d, "bibtex")
51 string const ControlBibtex::browseBib(string const & in_name) const
53 pair<string, string> dir1(_("Documents|#o#O"),
54 string(lyxrc.document_path));
55 FileFilterList const filter(_("BibTeX Databases (*.bib)"));
56 return browseRelFile(in_name, kernel().bufferFilepath(),
57 _("Select a BibTeX database to add"),
62 string const ControlBibtex::browseBst(string const & in_name) const
64 pair<string, string> dir1(_("Documents|#o#O"),
65 string(lyxrc.document_path));
66 FileFilterList const filter(_("BibTeX Styles (*.bst)"));
67 return browseRelFile(in_name, kernel().bufferFilepath(),
68 _("Select a BibTeX style"), filter, false, dir1);
72 void ControlBibtex::getBibStyles(vector<string> & data) const
76 getTexFileList("bstFiles.lst", data);
77 // test, if we have a valid list, otherwise run rescan
80 getTexFileList("bstFiles.lst", data);
82 vector<string>::iterator it = data.begin();
83 vector<string>::iterator end = data.end();
84 for (; it != end; ++it) {
85 *it = OnlyFilename(*it);
87 // sort on filename only (no path)
88 std::sort(data.begin(), data.end());
92 void ControlBibtex::getBibFiles(vector<string> & data) const
96 getTexFileList("bibFiles.lst", data);
97 // test, if we have a valid list, otherwise run rescan
100 getTexFileList("bibFiles.lst", data);
102 vector<string>::iterator it = data.begin();
103 vector<string>::iterator end = data.end();
104 for (; it != end; ++it) {
105 *it = OnlyFilename(*it);
107 // sort on filename only (no path)
108 std::sort(data.begin(), data.end());
112 void ControlBibtex::rescanBibStyles() const
118 bool ControlBibtex::usingBibtopic() const
120 return kernel().buffer().params().use_bibtopic;
124 bool ControlBibtex::bibtotoc() const
126 return prefixIs(params().getOptions(), "bibtotoc");
130 string const ControlBibtex::getStylefile() const
132 // the different bibtex packages have (and need) their
133 // own "plain" stylefiles
134 biblio::CiteEngine_enum const & engine =
135 biblio::getEngine(kernel().buffer());
138 case biblio::ENGINE_BASIC:
139 defaultstyle = "plain";
141 case biblio::ENGINE_NATBIB_AUTHORYEAR:
142 defaultstyle = "plainnat";
144 case biblio::ENGINE_NATBIB_NUMERICAL:
145 defaultstyle = "plainnat";
147 case biblio::ENGINE_JURABIB:
148 defaultstyle = "jurabib";
152 string bst = params().getOptions();
155 if (contains(bst,',')) {
156 string bibtotoc = "bibtotoc";
157 bst = split(bst, bibtotoc, ',');
162 // propose default style file for new insets
163 // existing insets might have (legally) no bst files
164 // (if the class already provides a style)
165 if (bst.empty() && params().getContents().empty())
171 } // namespace frontend