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