2 * \file ControlInclude.C
3 * Read the file COPYING
5 * \author Alejandro Aguilar Sierra
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS
15 #pragma implementation
18 #include "ControlInclude.h"
20 #include "helper_funcs.h"
22 #include "BufferView.h"
23 #include "funcrequest.h"
28 #include "frontends/Alert.h"
30 #include "support/filetools.h"
37 ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
38 : ControlInset<InsetInclude, InsetInclude::Params>(lv, d)
42 void ControlInclude::applyParamsToInset()
44 inset()->set(params());
45 bufferview()->updateInset(inset(), true);
49 string const ControlInclude::Browse(string const & in_name, Type in_type)
51 string const title = _("Select document to include");
53 // input TeX, verbatim, or LyX file ?
57 pattern = _("*.tex| LaTeX Documents (*.tex)");
61 pattern = _("*| All files ");
65 pattern = _("*.lyx| LyX Documents (*.lyx)");
69 pair<string, string> dir1(N_("Documents|#o#O"),
70 string(lyxrc.document_path));
72 string const docpath = OnlyPath(params().masterFilename_);
74 return browseRelFile(&lv_, in_name, docpath, title, pattern, dir1);
78 void ControlInclude::load(string const & file)
80 lyxfunc().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
84 bool ControlInclude::fileExists(string const & file)
86 string const fileWithAbsPath
87 = MakeAbsPath(file, OnlyPath(params().masterFilename_));
89 if (params().noload) {
91 if (prefixIs(file, "../") || prefixIs(file, "/"))
92 Alert::alert(_("Warning!"),
93 _("On some systems, with this options only relative path names"),
94 _("inside the master file dir are allowed. You might get a LaTeX error!"));
97 if (IsFileReadable(fileWithAbsPath))
101 Alert::alert(_("Warning!"), _("Specified file doesn't exist"));