]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlTexinfo.C
fix crash due to invalidated iterator
[lyx.git] / src / frontends / controllers / ControlTexinfo.C
index 82ca195d404cf3368838582c56eea1060a5f72bc..6262d4a21e92234dfc52d1c63fd5ad8c21421df9 100644 (file)
@@ -3,9 +3,9 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author Herbert Voss
+ * \author Herbert Voß
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 #include "ControlTexinfo.h"
 #include "funcrequest.h"
 
+#include "support/filetools.h"
+
+#include <algorithm>
+
+using std::string;
+using std::vector;
+
+namespace lyx {
+
+using support::OnlyFilename;
+
+namespace frontend {
 
 void getTexFileList(ControlTexinfo::texFileSuffix type,
-                   std::vector<string> & list)
+                   std::vector<string> & list, bool withPath)
 {
        string filename;
        switch (type) {
@@ -37,6 +49,15 @@ void getTexFileList(ControlTexinfo::texFileSuffix type,
                rescanTexStyles();
                getTexFileList(filename, list);
        }
+       if (withPath)
+               return;
+       vector<string>::iterator it  = list.begin();
+       vector<string>::iterator end = list.end();
+       for (; it != end; ++it) {
+               *it = OnlyFilename(*it);
+       }
+       // sort on filename only (no path)
+       std::sort(list.begin(), list.end());
 }
 
 
@@ -56,3 +77,24 @@ string const ControlTexinfo::getClassOptions(string const & filename) const
 {
        return getListOfOptions(filename, "cls");
 }
+
+
+string const ControlTexinfo::getFileType(ControlTexinfo::texFileSuffix type) const
+{
+       string ftype;
+       switch (type) {
+       case ControlTexinfo::bst:
+               ftype = "bst";
+               break;
+       case ControlTexinfo::cls:
+               ftype = "cls";
+               break;
+       case ControlTexinfo::sty:
+               ftype = "sty";
+               break;
+       }
+       return ftype;
+}
+
+} // namespace frontend
+} // namespace lyx