2 * \file ControlInclude.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alejandro Aguilar Sierra
8 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS.
15 #include "ControlInclude.h"
16 #include "helper_funcs.h"
21 #include "funcrequest.h"
25 #include "insets/insetinclude.h"
27 #include "support/filefilterlist.h"
28 #include "support/filetools.h"
37 using support::FileFilterList;
38 using support::IsFileReadable;
39 using support::MakeAbsPath;
40 using support::OnlyPath;
44 ControlInclude::ControlInclude(Dialog & parent)
45 : Dialog::Controller(parent)
49 bool ControlInclude::initialiseParams(string const & data)
51 InsetIncludeMailer::string2params(data, params_);
56 void ControlInclude::clearParams()
58 params_ = InsetCommandParams();
62 void ControlInclude::dispatchParams()
64 string const lfun = InsetIncludeMailer::params2string(params_);
65 kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
69 void ControlInclude::setParams(InsetCommandParams const & params)
75 string const ControlInclude::browse(string const & in_name, Type in_type) const
77 string const title = _("Select document to include");
79 // input TeX, verbatim, or LyX file ?
80 FileFilterList filters;
84 filters = FileFilterList(_("LaTeX/LyX Documents (*.tex *.lyx)"));
90 pair<string, string> dir1(N_("Documents|#o#O"),
91 string(lyxrc.document_path));
93 string const docpath = OnlyPath(kernel().buffer().fileName());
95 return browseRelFile(in_name, docpath, title,
96 filters, false, dir1);
100 void ControlInclude::load(string const & file)
102 string const ext = support::GetExtension(file);
104 kernel().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
106 // tex file or other text file in verbatim mode
107 formats.edit(kernel().buffer(), file, "text");
111 bool ControlInclude::fileExists(string const & file)
113 string const fileWithAbsPath
115 OnlyPath(kernel().buffer().fileName()));
117 if (IsFileReadable(fileWithAbsPath))
123 } // namespace frontend