]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlBibtex.C
obvious stuff
[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 std::pair;
29 using std::string;
30 using std::vector;
31
32
33 namespace lyx {
34
35 using support::FileFilterList;
36 using support::OnlyFilename;
37
38 namespace frontend {
39
40
41 ControlBibtex::ControlBibtex(Dialog & d)
42         : ControlCommand(d, "bibtex")
43 {}
44
45
46 string const ControlBibtex::browse(string const & in_name,
47                                    string const & title,
48                                    FileFilterList const & filters) const
49 {
50         pair<string, string> dir1(_("Documents|#o#O"),
51                                   string(lyxrc.document_path));
52         return browseRelFile(in_name, kernel().bufferFilepath(),
53                              title, filters, false, dir1);
54 }
55
56
57 void ControlBibtex::getBibStyles(vector<string> & data) const
58 {
59         data.clear();
60
61         getTexFileList("bstFiles.lst", data);
62         // test, if we have a valid list, otherwise run rescan
63         if (data.empty()) {
64                 rescanBibStyles();
65                 getTexFileList("bstFiles.lst", data);
66         }
67         vector<string>::iterator it  = data.begin();
68         vector<string>::iterator end = data.end();
69         for (; it != end; ++it) {
70                 *it = OnlyFilename(*it);
71         }
72 }
73
74
75 void ControlBibtex::getBibFiles(vector<string> & data) const
76 {
77         data.clear();
78
79         getTexFileList("bibFiles.lst", data);
80         // test, if we have a valid list, otherwise run rescan
81         if (data.empty()) {
82                 rescanBibStyles();
83                 getTexFileList("bibFiles.lst", data);
84         }
85         vector<string>::iterator it  = data.begin();
86         vector<string>::iterator end = data.end();
87         for (; it != end; ++it) {
88                 *it = OnlyFilename(*it);
89         }
90 }
91
92
93 void ControlBibtex::rescanBibStyles() const
94 {
95         rescanTexStyles();
96 }
97
98
99 bool ControlBibtex::usingBibtopic() const
100 {
101     return kernel().buffer().params().use_bibtopic;
102 }
103
104 } // namespace frontend
105 } // namespace lyx