]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlBibtex.C
Small clean-up.
[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 "lyxrc.h"
18 #include "helper_funcs.h"
19 #include "tex_helpers.h"
20 #include "gettext.h"
21
22 #include "support/filetools.h"
23
24 using lyx::support::OnlyFilename;
25
26 using std::pair;
27 using std::vector;
28
29
30 ControlBibtex::ControlBibtex(Dialog & d)
31         : ControlCommand(d, "bibtex")
32 {}
33
34
35 string const ControlBibtex::Browse(string const & in_name,
36                                    string const & title,
37                                    string const & pattern)
38 {
39         pair<string, string> dir1(_("Documents|#o#O"),
40                                   string(lyxrc.document_path));
41         return browseRelFile(in_name, kernel().bufferFilepath(),
42                              title, pattern, false, dir1);
43 }
44
45
46 void ControlBibtex::getBibStyles(vector<string> & data) const
47 {
48         data.clear();
49
50         getTexFileList("bstFiles.lst", data);
51         // test, if we have a valid list, otherwise run rescan
52         if (data.empty()) {
53                 rescanBibStyles();
54                 getTexFileList("bstFiles.lst", data);
55         }
56         vector<string>::iterator it  = data.begin();
57         vector<string>::iterator end = data.end();
58         for (; it != end; ++it) {
59                 *it = OnlyFilename(*it);
60         }
61 }
62
63
64 void ControlBibtex::getBibFiles(vector<string> & data) const
65 {
66         data.clear();
67
68         getTexFileList("bibFiles.lst", data);
69         // test, if we have a valid list, otherwise run rescan
70         if (data.empty()) {
71                 rescanBibStyles();
72                 getTexFileList("bibFiles.lst", data);
73         }
74         vector<string>::iterator it  = data.begin();
75         vector<string>::iterator end = data.end();
76         for (; it != end; ++it) {
77                 *it = OnlyFilename(*it);
78         }
79 }
80
81
82 void ControlBibtex::rescanBibStyles() const
83 {
84         rescanTexStyles();
85 }