3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS
14 #pragma implementation
19 #include "helper_funcs.h"
21 #include "frontends/FileDialog.h"
22 #include "support/filetools.h" // OnlyPath, OnlyFilename
23 #include "support/lstrings.h"
24 #include "gettext.h" // _()
25 #include "frontends/Alert.h"
32 string const browseFile(LyXView * lv, string const & filename,
34 string const & pattern,
36 pair<string,string> const & dir1,
37 pair<string,string> const & dir2)
40 if (!filename.empty())
41 lastPath = OnlyPath(filename);
43 FileDialog fileDlg(lv, title, LFUN_SELECT_FILE_SYNC, dir1, dir2);
45 FileDialog::Result result;
49 result = fileDlg.save(lastPath, pattern,
50 OnlyFilename(filename));
52 result = fileDlg.open(lastPath, pattern,
53 OnlyFilename(filename));
55 if (result.second.empty())
58 lastPath = OnlyPath(result.second);
60 if (result.second.find_first_of("#~$% ") == string::npos)
63 Alert::alert(_("Filename can't contain any "
64 "of these characters:"),
65 _("space, '#', '~', '$' or '%'."));
72 string const browseRelFile(LyXView * lv, string const & filename,
73 string const & refpath,
75 string const & pattern,
77 pair<string,string> const & dir1,
78 pair<string,string> const & dir2)
80 string const fname = MakeAbsPath(filename, refpath);
82 string const outname = browseFile(lv, fname, title, pattern, save,
84 string const reloutname = MakeRelPath(outname, refpath);
85 if (prefixIs(reloutname, "../"))
92 // sorry this is just a temporary hack we should include vspace.h! (Jug)
93 extern const char * stringFromUnit(int);
95 vector<string> const getLatexUnits()
99 for (int i = 0; (str = stringFromUnit(i)); ++i)
100 units.push_back(str);