]> git.lyx.org Git - lyx.git/blobdiff - src/support/filetools.cpp
correct format for unsigned long argument, remoteCloseLink is oneway void
[lyx.git] / src / support / filetools.cpp
index bb531b807ca5d9cd0d1351e5cc9680d8b3250327..68c92d8daaa65fd5562c2db283c4c7ade4dcb45e 100644 (file)
@@ -30,6 +30,7 @@
 #include "support/gettext.h"
 #include "support/lstrings.h"
 #include "support/os.h"
+#include "support/Messages.h"
 #include "support/Package.h"
 #include "support/Path.h"
 #include "support/Systemcall.h"
@@ -282,7 +283,7 @@ FileName const i18nLibFileSearch(string const & dir, string const & name,
           each po file is able to tell us its name. (JMarc)
        */
 
-       string lang = to_ascii(_(languageTestString()));
+       string lang = getGuiMessages().language();
        string const language = getEnv("LANGUAGE");
        if (!lang.empty() && !language.empty())
                lang = language;
@@ -802,25 +803,26 @@ docstring const makeDisplayPath(string const & path, unsigned int threshold)
                return from_utf8(os::external_path(str));
 
        string const prefix = ".../";
-       string temp;
+       docstring dstr = from_utf8(str);
+       docstring temp;
 
-       while (str.length() > threshold)
-               str = split(str, temp, '/');
+       while (dstr.length() > threshold)
+               dstr = split(dstr, temp, '/');
 
        // Did we shorten everything away?
-       if (str.empty()) {
+       if (dstr.empty()) {
                // Yes, filename itself is too long.
                // Pick the start and the end of the filename.
-               str = onlyFileName(path);
-               string const head = str.substr(0, threshold / 2 - 3);
+               dstr = from_utf8(onlyFileName(path));
+               docstring const head = dstr.substr(0, threshold / 2 - 3);
 
-               string::size_type len = str.length();
-               string const tail =
-                       str.substr(len - threshold / 2 - 2, len - 1);
-               str = head + "..." + tail;
+               docstring::size_type len = dstr.length();
+               docstring const tail =
+                       dstr.substr(len - threshold / 2 - 2, len - 1);
+               dstr = head + from_ascii("...") + tail;
        }
 
-       return from_utf8(os::external_path(prefix + str));
+       return from_utf8(os::external_path(prefix + to_utf8(dstr)));
 }
 
 
@@ -1015,59 +1017,6 @@ FileName const findtexfile(string const & fil, string const & /*format*/)
 }
 
 
-void readBB_lyxerrMessage(FileName const & file, bool & zipped,
-       string const & message)
-{
-       LYXERR(Debug::GRAPHICS, "[readBB_from_PSFile] " << message);
-       // FIXME: Why is this func deleting a file? (Lgb)
-       if (zipped)
-               file.removeFile();
-}
-
-
-string const readBB_from_PSFile(FileName const & file)
-{
-       // in a (e)ps-file it's an entry like %%BoundingBox:23 45 321 345
-       // It seems that every command in the header has an own line,
-       // getline() should work for all files.
-       // On the other hand some plot programs write the bb at the
-       // end of the file. Than we have in the header:
-       // %%BoundingBox: (atend)
-       // In this case we must check the end.
-       bool zipped = file.isZippedFile();
-       FileName const file_ = zipped ? unzipFile(file) : file;
-       string const format = file_.guessFormatFromContents();
-
-       if (format != "eps" && format != "ps") {
-               readBB_lyxerrMessage(file_, zipped,"no(e)ps-format");
-               return string();
-       }
-
-       static lyx::regex bbox_re(
-               "^%%BoundingBox:\\s*([[:digit:]]+)\\s+([[:digit:]]+)\\s+([[:digit:]]+)\\s+([[:digit:]]+)");
-       ifstream is(file_.toFilesystemEncoding().c_str());
-       while (is) {
-               string s;
-               getline(is,s);
-               lyx::smatch what;
-               if (regex_match(s, what, bbox_re)) {
-                       // Our callers expect the tokens in the string
-                       // separated by single spaces.
-                       // FIXME: change return type from string to something
-                       // sensible
-                       ostringstream os;
-                       os << what.str(1) << ' ' << what.str(2) << ' '
-                          << what.str(3) << ' ' << what.str(4);
-                       string const bb = os.str();
-                       readBB_lyxerrMessage(file_, zipped, bb);
-                       return bb;
-               }
-       }
-       readBB_lyxerrMessage(file_, zipped, "no bb found");
-       return string();
-}
-
-
 int compare_timestamps(FileName const & file1, FileName const & file2)
 {
        // If the original is newer than the copy, then copy the original