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