]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlTexinfo.C
Rename .C => .cpp for files in src/frontends/controllers, step 1
[lyx.git] / src / frontends / controllers / ControlTexinfo.C
index 5ef281138512df1430396a254807d1b99391de3c..7694773600a4fb9e684573baeef32858d1981097 100644 (file)
 /**
- * \file ControlTexinfo.C
+ * \file ControlTexinfo.cpp
  * 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 "helper_funcs.h"
-#include "tex_helpers.h"
+#include <algorithm>
 
-#include "frontends/Dialogs.h"
-#include "frontends/LyXView.h"
+using std::string;
+using std::vector;
 
-#include "support/filetools.h" // FileSearch
-#include "support/path.h"
-#include "support/lstrings.h"
+namespace lyx {
 
-extern string user_lyxdir; // home of *Files.lst
+using support::onlyFilename;
 
-namespace {
+namespace frontend {
 
-string getFileList(ControlTexinfo::texFileSuffix type, bool withFullPath)
+void getTexFileList(ControlTexinfo::texFileSuffix type,
+                   std::vector<string> & list, bool withPath)
 {
+       string filename;
        switch (type) {
-           case ControlTexinfo::bst:
-               return getTexFileList("bstFiles.lst", withFullPath);
+       case ControlTexinfo::bst:
+               filename = "bstFiles.lst";
                break;
-           case ControlTexinfo::cls:
-               return getTexFileList("clsFiles.lst", withFullPath);
+       case ControlTexinfo::cls:
+               filename = "clsFiles.lst";
                break;
-           case ControlTexinfo::sty:
-               return getTexFileList("styFiles.lst", withFullPath);
+       case ControlTexinfo::sty:
+               filename = "styFiles.lst";
                break;
        }
-       return string();
+       getTexFileList(filename, list);
+       if (list.empty()) {
+               // build filelists of all availabe bst/cls/sty-files.
+               // Done through kpsewhich and an external script,
+               // saved in *Files.lst
+               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());
 }
 
-} // namespace anon
-
 
-ControlTexinfo::ControlTexinfo(LyXView & lv, Dialogs & d)
-       : ControlDialogBI(lv, d)
+ControlTexinfo::ControlTexinfo(Dialog & parent)
+       : Dialog::Controller(parent)
 {}
 
 
-// build filelists of all availabe bst/cls/sty-files. done through
-// kpsewhich and an external script, saved in *Files.lst
-void ControlTexinfo::rescanStyles() const
+void ControlTexinfo::viewFile(string const & filename) const
 {
-    rescanTexStyles();
+       string const arg = "file " + filename;
+       kernel().dispatch(FuncRequest(LFUN_DIALOG_SHOW, arg));
 }
 
 
-void ControlTexinfo::runTexhash() const
+string const ControlTexinfo::getClassOptions(string const & filename) const
 {
-    texhash();
+       return getListOfOptions(filename, "cls");
 }
 
 
-string const
-ControlTexinfo::getContents(texFileSuffix type, bool withFullPath) const
+string const ControlTexinfo::getFileType(ControlTexinfo::texFileSuffix type) const
 {
-       string list(getFileList(type, withFullPath));
-
-       // initial scan
-       if (list.empty()) {
-               rescanStyles();
-               list = getFileList(type, withFullPath);
+       string ftype;
+       switch (type) {
+       case ControlTexinfo::bst:
+               ftype = "bst";
+               break;
+       case ControlTexinfo::cls:
+               ftype = "cls";
+               break;
+       case ControlTexinfo::sty:
+               ftype = "sty";
+               break;
        }
-       return list;
-}
-
-
-void ControlTexinfo::viewFile(string const filename) const
-{
-       lv_.getDialogs().show("file", filename);
+       return ftype;
 }
 
-
-string const ControlTexinfo::getClassOptions(string const & filename) const
-{
-       return getListOfOptions(filename, "cls");
-}
+} // namespace frontend
+} // namespace lyx