2001-03-23 17:09:34 +00:00
|
|
|
/**
|
|
|
|
* \file ControlInclude.C
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-03-23 17:09:34 +00:00
|
|
|
*
|
|
|
|
* \author Alejandro Aguilar Sierra
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author John Levon
|
2002-10-21 17:38:09 +00:00
|
|
|
* \author Angus Leeming
|
2002-09-05 14:10:50 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2001-03-23 17:09:34 +00:00
|
|
|
*/
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
#include "ControlInclude.h"
|
2002-08-14 19:19:47 +00:00
|
|
|
|
|
|
|
#include "helper_funcs.h"
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "BufferView.h"
|
2002-08-14 19:19:47 +00:00
|
|
|
#include "funcrequest.h"
|
2001-04-05 12:26:41 +00:00
|
|
|
#include "gettext.h"
|
2002-08-14 19:19:47 +00:00
|
|
|
#include "lyxfunc.h"
|
2001-03-30 09:51:46 +00:00
|
|
|
#include "lyxrc.h"
|
2002-08-14 19:19:47 +00:00
|
|
|
|
|
|
|
#include "frontends/Alert.h"
|
2002-05-29 16:21:03 +00:00
|
|
|
|
2002-01-14 23:31:23 +00:00
|
|
|
#include "support/filetools.h"
|
2001-03-30 09:51:46 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
#include <utility>
|
2002-05-29 16:21:03 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
using std::pair;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
|
|
|
|
ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
|
|
|
|
: ControlInset<InsetInclude, InsetInclude::Params>(lv, d)
|
2002-06-18 15:44:30 +00:00
|
|
|
{}
|
2001-03-23 17:09:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
void ControlInclude::applyParamsToInset()
|
|
|
|
{
|
|
|
|
inset()->set(params());
|
2002-08-12 20:17:41 +00:00
|
|
|
bufferview()->updateInset(inset(), true);
|
2001-03-23 17:09:34 +00:00
|
|
|
}
|
2001-03-30 09:51:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
string const ControlInclude::Browse(string const & in_name, Type in_type)
|
|
|
|
{
|
2002-01-16 22:17:38 +00:00
|
|
|
string const title = _("Select document to include");
|
2001-03-30 09:51:46 +00:00
|
|
|
|
|
|
|
// input TeX, verbatim, or LyX file ?
|
2002-03-21 21:21:28 +00:00
|
|
|
string pattern;
|
2001-03-30 09:51:46 +00:00
|
|
|
switch (in_type) {
|
|
|
|
case INPUT:
|
2002-11-14 20:39:16 +00:00
|
|
|
pattern = _("*.(tex|lyx)| LaTeX/LyX Documents (*.tex *.lyx)");
|
2001-03-30 09:51:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VERBATIM:
|
2002-11-14 20:39:16 +00:00
|
|
|
pattern = _("*| All files (*)");
|
2001-03-30 09:51:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case INCLUDE:
|
2002-11-14 20:39:16 +00:00
|
|
|
pattern = _("*.(tex|lyx)| LaTeX/LyX Documents (*.tex *.lyx)");
|
2001-03-30 09:51:46 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-01-13 15:01:25 +00:00
|
|
|
pair<string, string> dir1(N_("Documents|#o#O"),
|
|
|
|
string(lyxrc.document_path));
|
2001-03-30 09:51:46 +00:00
|
|
|
|
2002-01-14 23:31:23 +00:00
|
|
|
string const docpath = OnlyPath(params().masterFilename_);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-11-17 08:32:09 +00:00
|
|
|
return browseRelFile(&lv_, in_name, docpath, title, pattern, false, dir1);
|
2001-03-30 09:51:46 +00:00
|
|
|
}
|
2001-07-25 12:37:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
void ControlInclude::load(string const & file)
|
|
|
|
{
|
2002-08-12 20:17:41 +00:00
|
|
|
lyxfunc().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
|
2001-07-25 12:37:43 +00:00
|
|
|
}
|
2002-01-21 10:47:19 +00:00
|
|
|
|
|
|
|
|
2002-01-24 15:49:53 +00:00
|
|
|
bool ControlInclude::fileExists(string const & file)
|
2002-01-21 10:47:19 +00:00
|
|
|
{
|
2002-08-07 08:11:41 +00:00
|
|
|
string const fileWithAbsPath
|
|
|
|
= MakeAbsPath(file, OnlyPath(params().masterFilename_));
|
2002-07-04 09:58:16 +00:00
|
|
|
|
|
|
|
if (IsFileReadable(fileWithAbsPath))
|
|
|
|
return true;
|
2002-10-21 17:38:09 +00:00
|
|
|
|
2002-09-09 17:32:53 +00:00
|
|
|
return false;
|
2002-01-21 10:47:19 +00:00
|
|
|
}
|