]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/frontend_helpers.cpp
Fixed some lines that were too long. It compiled afterwards.
[lyx.git] / src / frontends / controllers / frontend_helpers.cpp
index 640bac3aa8d9ca85d1649e55dc04dd61ae3525cd..25c1434641dfdca00f8c7db0d8e28c8a1a007a13 100644 (file)
 
 #include "Buffer.h"
 #include "BufferParams.h"
+#include "Color.h"
 #include "debug.h"
 #include "gettext.h"
 #include "Language.h"
 #include "Length.h"
 
-#include <boost/regex.hpp>
-
-#include <algorithm>
-#include <config.h>
-
-#include "Color.h"
-
 #include "frontends/FileDialog.h"
 #include "frontends/alert.h"
+
 #include "support/filetools.h"
 #include "support/lstrings.h"
 #include "support/Package.h"
 #include "support/Systemcall.h"
 
 #include <boost/cregex.hpp>
+#include <boost/regex.hpp>
+
+#include <algorithm>
 #include <fstream>
+
 using std::string;
 using std::vector;
 using std::pair;
@@ -176,6 +175,9 @@ string const asValidLatexCommand(string const & input,
 
 docstring const familyName(docstring const & name)
 {
+       if (name.empty())
+               return docstring();
+
        // Very simple parser
        docstring fname = name;
 
@@ -188,7 +190,7 @@ docstring const familyName(docstring const & name)
        if (idx != docstring::npos)
                return ltrim(fname.substr(0, idx));
        idx = fname.rfind('.');
-       if (idx != docstring::npos)
+       if (idx != docstring::npos && idx + 1 < fname.size())
                fname = ltrim(fname.substr(idx + 1));
        // test if we have a LaTeX Space in front
        if (fname[0] == '\\')
@@ -1111,6 +1113,16 @@ public:
        }
 };
 
+
+class ColorSorter
+{
+public:
+       bool operator()(Color::color const & lhs,
+                       Color::color const & rhs) const {
+               return lcolor.getGUIName(lhs) < lcolor.getGUIName(rhs);
+       }
+};
+
 } // namespace anon
 
 
@@ -1145,6 +1157,14 @@ vector<LanguagePair> const getLanguageData(bool character_dlg)
        return langs;
 }
 
+
+vector<Color_color> const getSortedColors(vector<Color_color> colors)
+{
+       // sort the colors
+       std::sort(colors.begin(), colors.end(), ColorSorter());
+       return colors;
+}
+
 } // namespace frontend
 
 using support::addName;