diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index f98acafc62..4f6ec6c5ea 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,21 @@ +2005-05-23 Angus Leeming + + * helper_funcs.[Ch] (browseFile, browseRelFile, browseDir): add + a boolean argument to denote whether the functions should check + the returned path name for spaces. (If the parent document is + a LaTeX file and if the latex compiler cannot handle such paths.) + + * ControlBibtex.C (Browse): + * ControlExternal.C (Browse): + * ControlGraphics.C (Browse): + * ControlInclude.C (Browse): check whether the returned path + contains spaces and whether LaTeX can handle such a path. + + * ControlPrefs.C (browsebind, browseUI, browsekbmap, browsedict) + (browse, browsedir): + * ControlPrint.C (Browse): do not check whether the returned + path contains spaces. + 2005-05-18 Angus Leeming * helper_funcs.C (get_invalid_chars_latex, printable_list): new @@ -52,16 +70,16 @@ 2004-04-29 Jean-Marc Lasgouttes - * ControlMath.C (find_xpm): - * ControlBibtex.C (applyParamsToInset): + * ControlMath.C (find_xpm): + * ControlBibtex.C (applyParamsToInset): * ControlBibitem.C (applyParamsToInset): fix #warning directives - + * ControlDialog.tmpl (show, update, hide): gcc 3.4 compilation fix 2003-02-10 Jean-Marc Lasgouttes * ControlInclude.C (Browse): replace masterFilename_ with - parentFilename_. + parentFilename_. 2003-06-06 John Levon @@ -80,7 +98,7 @@ 2003-02-17 John Levon * ControlDialog.tmpl: do build before setParams for - spellchecker's sake + spellchecker's sake * ControlSpellchecker.h: * ControlSpellchecker.C: rework @@ -103,7 +121,7 @@ 2003-01-11 Juergen Spitzmueller * helper_funcs.[Ch]: implement browseDir (browse directory) [bug 824] - + * ControlPrefs.[Ch]: implement browsedir for the use of use browseDir. 2002-12-02 Lars Gullik Bjønnes diff --git a/src/frontends/controllers/ControlBibtex.C b/src/frontends/controllers/ControlBibtex.C index b2dcbeca3e..fc0cce18ee 100644 --- a/src/frontends/controllers/ControlBibtex.C +++ b/src/frontends/controllers/ControlBibtex.C @@ -60,7 +60,7 @@ string const ControlBibtex::Browse(string const & in_name, { pair dir1(_("Documents|#o#O"), string(lyxrc.document_path)); - return browseRelFile(&lv_, in_name, buffer()->filePath(), + return browseRelFile(&lv_, true, in_name, buffer()->filePath(), title, pattern, false, dir1); } diff --git a/src/frontends/controllers/ControlExternal.C b/src/frontends/controllers/ControlExternal.C index a3d15bed96..699e674ba6 100644 --- a/src/frontends/controllers/ControlExternal.C +++ b/src/frontends/controllers/ControlExternal.C @@ -150,5 +150,5 @@ string const ControlExternal::Browse(string const & input) const std::pair dir1(N_("Documents|#o#O"), string(lyxrc.document_path)); - return browseRelFile(&lv_, input, bufpath, title, pattern, false, dir1); + return browseRelFile(&lv_, true, input, bufpath, title, pattern, false, dir1); } diff --git a/src/frontends/controllers/ControlGraphics.C b/src/frontends/controllers/ControlGraphics.C index e9080b2cd4..bb1b1c8e2d 100644 --- a/src/frontends/controllers/ControlGraphics.C +++ b/src/frontends/controllers/ControlGraphics.C @@ -88,7 +88,7 @@ string const ControlGraphics::Browse(string const & in_name) pair dir1(_("Clipart|#C#c"), clipdir); pair dir2(_("Documents|#o#O"), string(lyxrc.document_path)); // Show the file browser dialog - return browseRelFile(&lv_, in_name, buffer()->filePath(), + return browseRelFile(&lv_, true, in_name, buffer()->filePath(), title, "*.*", false, dir1, dir2); } diff --git a/src/frontends/controllers/ControlInclude.C b/src/frontends/controllers/ControlInclude.C index 02a3ff2536..00d5354134 100644 --- a/src/frontends/controllers/ControlInclude.C +++ b/src/frontends/controllers/ControlInclude.C @@ -68,7 +68,7 @@ string const ControlInclude::Browse(string const & in_name, Type in_type) string const docpath = OnlyPath(params().parentFilename_); - return browseRelFile(&lv_, in_name, docpath, title, pattern, false, dir1); + return browseRelFile(&lv_, true, in_name, docpath, title, pattern, false, dir1); } diff --git a/src/frontends/controllers/ControlPrefs.C b/src/frontends/controllers/ControlPrefs.C index 23300db9e4..5397906395 100644 --- a/src/frontends/controllers/ControlPrefs.C +++ b/src/frontends/controllers/ControlPrefs.C @@ -66,7 +66,7 @@ string const ControlPrefs::browsebind(string const & file) name = _("User Bind|#U#u"); pair dir2(name, dir); - return browseFile(&lv_, file, _("Choose bind file"), "*.bind", false, dir1, dir2); + return browseFile(&lv_, false, file, _("Choose bind file"), "*.bind", false, dir1, dir2); } @@ -83,7 +83,7 @@ string const ControlPrefs::browseUI(string const & file) name = _("User UI|#U#u"); pair dir2(name, dir); - return browseFile(&lv_, file, _("Choose UI file"), "*.ui", false, dir1, dir2); + return browseFile(&lv_, false, file, _("Choose UI file"), "*.ui", false, dir1, dir2); } @@ -93,25 +93,25 @@ string const ControlPrefs::browsekbmap(string const & file) string const name = _("Key maps|#K#k"); pair dir1(name, dir); - return browseFile(&lv_, file, _("Choose keyboard map"), "*.kmap", false, dir1); + return browseFile(&lv_, false, file, _("Choose keyboard map"), "*.kmap", false, dir1); } string const ControlPrefs::browsedict(string const & file) { - return browseFile(&lv_, file, _("Choose personal dictionary"), "*.ispell"); + return browseFile(&lv_, false, file, _("Choose personal dictionary"), "*.ispell"); } string const ControlPrefs::browse(string const & file, string const & title) { - return browseFile(&lv_, file, title, "*", true); + return browseFile(&lv_, false, file, title, "*", true); } string const ControlPrefs::browsedir(string const & path, string const & title) { - return browseDir(&lv_, path, title); + return browseDir(&lv_, false, path, title); } diff --git a/src/frontends/controllers/ControlPrint.C b/src/frontends/controllers/ControlPrint.C index d6574331c9..8cf2a7b8fa 100644 --- a/src/frontends/controllers/ControlPrint.C +++ b/src/frontends/controllers/ControlPrint.C @@ -75,7 +75,7 @@ string const ControlPrint::Browse(string const & in_name) string const pattern = "*.ps"; // Show the file browser dialog - return browseRelFile(&lv_, in_name, buffer()->filePath(), + return browseRelFile(&lv_, false, in_name, buffer()->filePath(), title, pattern, true); } diff --git a/src/frontends/controllers/helper_funcs.C b/src/frontends/controllers/helper_funcs.C index 1bbcd16b76..bb19605606 100644 --- a/src/frontends/controllers/helper_funcs.C +++ b/src/frontends/controllers/helper_funcs.C @@ -63,7 +63,9 @@ string const printable_list(string const & invalid_chars) } // namespace anon -string const browseFile(LyXView * lv, string const & filename, +string const browseFile(LyXView * lv, + bool check_returned_filename, + string const & filename, string const & title, string const & pattern, bool save, @@ -89,6 +91,8 @@ string const browseFile(LyXView * lv, string const & filename, result = fileDlg.open(lastPath, pattern, OnlyFilename(filename)); + if (!check_returned_filename) + break; if (invalid_chars.empty()) break; if (result_path.empty()) @@ -105,17 +109,20 @@ string const browseFile(LyXView * lv, string const & filename, } -string const browseRelFile(LyXView * lv, string const & filename, - string const & refpath, - string const & title, - string const & pattern, - bool save, - pair const & dir1, - pair const & dir2) +string const browseRelFile(LyXView * lv, + bool check_returned_filename, + string const & filename, + string const & refpath, + string const & title, + string const & pattern, + bool save, + pair const & dir1, + pair const & dir2) { string const fname = MakeAbsPath(filename, refpath); - string const outname = browseFile(lv, fname, title, pattern, save, + string const outname = browseFile(lv, check_returned_filename, + fname, title, pattern, save, dir1, dir2); string const reloutname = MakeRelPath(outname, refpath); if (prefixIs(reloutname, "../")) @@ -125,10 +132,12 @@ string const browseRelFile(LyXView * lv, string const & filename, } -string const browseDir(LyXView * lv, string const & pathname, - string const & title, - pair const & dir1, - pair const & dir2) +string const browseDir(LyXView * lv, + bool check_returned_pathname, + string const & pathname, + string const & title, + pair const & dir1, + pair const & dir2) { string lastPath("."); if (!pathname.empty()) @@ -145,6 +154,8 @@ string const browseDir(LyXView * lv, string const & pathname, result = fileDlg.opendir(lastPath, OnlyFilename(pathname)); + if (!check_returned_pathname) + break; if (invalid_chars.empty()) break; if (result_path.empty()) diff --git a/src/frontends/controllers/helper_funcs.h b/src/frontends/controllers/helper_funcs.h index 1ab9897017..f50a5d6fe4 100644 --- a/src/frontends/controllers/helper_funcs.h +++ b/src/frontends/controllers/helper_funcs.h @@ -26,7 +26,9 @@ class LyXView; dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog. */ string const -browseFile(LyXView * lv, string const & filename, +browseFile(LyXView * lv, + bool check_returned_filename, + string const & filename, string const & title, string const & pattern, bool save = false, @@ -43,7 +45,9 @@ browseFile(LyXView * lv, string const & filename, intended to be useful for insets which encapsulate files/ */ string const -browseRelFile(LyXView * lv, string const & filename, +browseRelFile(LyXView * lv, + bool check_returned_filename, + string const & filename, string const & refpath, string const & title, string const & pattern, @@ -60,12 +64,14 @@ browseRelFile(LyXView * lv, string const & filename, dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog. */ string const -browseDir(LyXView * lv, string const & pathname, - string const & title, - std::pair const & dir1 = - std::make_pair(string(), string()), - std::pair const & dir2 = - std::make_pair(string(), string())); +browseDir(LyXView * lv, + bool check_returned_pathname, + string const & pathname, + string const & title, + std::pair const & dir1 = + std::make_pair(string(), string()), + std::pair const & dir2 = + std::make_pair(string(), string())); /// Returns a vector of units that can be used to create a valid LaTeX length.