]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlTexinfo.C
Rename .C => .cpp for files in src/frontends/controllers, step 1
[lyx.git] / src / frontends / controllers / ControlTexinfo.C
1 /**
2  * \file ControlTexinfo.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Herbert Voß
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "ControlTexinfo.h"
14 #include "funcrequest.h"
15
16 #include "support/filetools.h"
17
18 #include <algorithm>
19
20 using std::string;
21 using std::vector;
22
23 namespace lyx {
24
25 using support::onlyFilename;
26
27 namespace frontend {
28
29 void getTexFileList(ControlTexinfo::texFileSuffix type,
30                     std::vector<string> & list, bool withPath)
31 {
32         string filename;
33         switch (type) {
34         case ControlTexinfo::bst:
35                 filename = "bstFiles.lst";
36                 break;
37         case ControlTexinfo::cls:
38                 filename = "clsFiles.lst";
39                 break;
40         case ControlTexinfo::sty:
41                 filename = "styFiles.lst";
42                 break;
43         }
44         getTexFileList(filename, list);
45         if (list.empty()) {
46                 // build filelists of all availabe bst/cls/sty-files.
47                 // Done through kpsewhich and an external script,
48                 // saved in *Files.lst
49                 rescanTexStyles();
50                 getTexFileList(filename, list);
51         }
52         if (withPath)
53                 return;
54         vector<string>::iterator it  = list.begin();
55         vector<string>::iterator end = list.end();
56         for (; it != end; ++it) {
57                 *it = onlyFilename(*it);
58         }
59         // sort on filename only (no path)
60         std::sort(list.begin(), list.end());
61 }
62
63
64 ControlTexinfo::ControlTexinfo(Dialog & parent)
65         : Dialog::Controller(parent)
66 {}
67
68
69 void ControlTexinfo::viewFile(string const & filename) const
70 {
71         string const arg = "file " + filename;
72         kernel().dispatch(FuncRequest(LFUN_DIALOG_SHOW, arg));
73 }
74
75
76 string const ControlTexinfo::getClassOptions(string const & filename) const
77 {
78         return getListOfOptions(filename, "cls");
79 }
80
81
82 string const ControlTexinfo::getFileType(ControlTexinfo::texFileSuffix type) const
83 {
84         string ftype;
85         switch (type) {
86         case ControlTexinfo::bst:
87                 ftype = "bst";
88                 break;
89         case ControlTexinfo::cls:
90                 ftype = "cls";
91                 break;
92         case ControlTexinfo::sty:
93                 ftype = "sty";
94                 break;
95         }
96         return ftype;
97 }
98
99 } // namespace frontend
100 } // namespace lyx