]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlBibtex.C
5 new lfuns, move all apply code out of ControlDocument and into the core.
[lyx.git] / src / frontends / controllers / ControlBibtex.C
1 /**
2  * \file ControlBibtex.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  * \author Angus Leeming
8  * \author Herbert Voß
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "ControlBibtex.h"
16
17 #include "buffer.h"
18 #include "bufferparams.h"
19
20 #include "lyxrc.h"
21 #include "helper_funcs.h"
22 #include "tex_helpers.h"
23 #include "gettext.h"
24
25 #include "support/filetools.h"
26 #include "support/globbing.h"
27
28 using lyx::support::FileFilterList;
29 using lyx::support::OnlyFilename;
30
31 using std::pair;
32 using std::string;
33 using std::vector;
34
35
36 ControlBibtex::ControlBibtex(Dialog & d)
37         : ControlCommand(d, "bibtex")
38 {}
39
40
41 string const ControlBibtex::browse(string const & in_name,
42                                    string const & title,
43                                    FileFilterList const & filters) const
44 {
45         pair<string, string> dir1(_("Documents|#o#O"),
46                                   string(lyxrc.document_path));
47         return browseRelFile(in_name, kernel().bufferFilepath(),
48                              title, filters, false, dir1);
49 }
50
51
52 void ControlBibtex::getBibStyles(vector<string> & data) const
53 {
54         data.clear();
55
56         getTexFileList("bstFiles.lst", data);
57         // test, if we have a valid list, otherwise run rescan
58         if (data.empty()) {
59                 rescanBibStyles();
60                 getTexFileList("bstFiles.lst", data);
61         }
62         vector<string>::iterator it  = data.begin();
63         vector<string>::iterator end = data.end();
64         for (; it != end; ++it) {
65                 *it = OnlyFilename(*it);
66         }
67 }
68
69
70 void ControlBibtex::getBibFiles(vector<string> & data) const
71 {
72         data.clear();
73
74         getTexFileList("bibFiles.lst", data);
75         // test, if we have a valid list, otherwise run rescan
76         if (data.empty()) {
77                 rescanBibStyles();
78                 getTexFileList("bibFiles.lst", data);
79         }
80         vector<string>::iterator it  = data.begin();
81         vector<string>::iterator end = data.end();
82         for (; it != end; ++it) {
83                 *it = OnlyFilename(*it);
84         }
85 }
86
87
88 void ControlBibtex::rescanBibStyles() const
89 {
90         rescanTexStyles();
91 }
92
93
94 bool ControlBibtex::usingBibtopic() const
95 {
96     return kernel().buffer().params().use_bibtopic;
97 }