#include "dispatchresult.h"
#include "exporter.h"
#include "funcrequest.h"
+#include "FuncStatus.h"
#include "gettext.h"
#include "LaTeXFeatures.h"
#include "lyx_main.h"
#include "insets/render_preview.h"
-#include "support/FileInfo.h"
#include "support/filename.h"
#include "support/filetools.h"
#include "support/lstrings.h" // contains
#include "support/lyxlib.h"
-#include "support/tostr.h"
+#include "support/convert.h"
#include <boost/bind.hpp>
+#include <boost/filesystem/operations.hpp>
#include "support/std_ostream.h"
using lyx::support::ChangeExtension;
using lyx::support::contains;
using lyx::support::copy;
-using lyx::support::FileInfo;
using lyx::support::FileName;
using lyx::support::GetFileContents;
using lyx::support::IsFileReadable;
using lyx::support::IsLyXFilename;
+using lyx::support::latex_path;
using lyx::support::MakeAbsPath;
using lyx::support::MakeDisplayPath;
using lyx::support::MakeRelPath;
using std::ostream;
using std::ostringstream;
+namespace fs = boost::filesystem;
extern BufferList bufferlist;
string const uniqueID()
{
static unsigned int seed = 1000;
- return "file" + tostr(++seed);
+ return "file" + convert<string>(++seed);
}
} // namespace anon
params_(other.params_),
include_label(other.include_label),
preview_(new RenderMonitoredPreview(this)),
- set_label_(other.set_label_)
+ set_label_(false)
{
preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
}
case LFUN_INSET_MODIFY: {
InsetCommandParams p;
InsetIncludeMailer::string2params(cmd.argument, p);
- if (!p.getCmdName().empty()) {
+ if (!p.getCmdName().empty())
set(p, cur.buffer());
- cur.bv().update();
- }
+ else
+ cur.noUpdate();
break;
}
}
+bool InsetInclude::getStatus(LCursor & cur, FuncRequest const & cmd,
+ FuncStatus & flag) const
+{
+ switch (cmd.action) {
+
+ case LFUN_INSET_MODIFY:
+ case LFUN_INSET_DIALOG_UPDATE:
+ case LFUN_INSET_DIALOG_SHOW:
+ flag.enabled(true);
+ return true;
+
+ default:
+ return InsetBase::getStatus(cur, cmd, flag);
+ }
+}
+
+
InsetCommandParams const & InsetInclude::params() const
{
return params_;
void InsetInclude::write(ostream & os) const
{
os << "Include " << params_.getCommand() << '\n'
- << "preview " << tostr(params_.preview()) << '\n';
+ << "preview " << convert<string>(params_.preview()) << '\n';
}
Buffer * buf = bufferlist.getBuffer(included_file);
if (!buf) {
// the readonly flag can/will be wrong, not anymore I think.
- FileInfo finfo(included_file);
- if (!finfo.isOK())
+ if (!fs::exists(included_file))
return false;
buf = bufferlist.newBuffer(included_file);
if (!loadLyXFile(buf, included_file))
}
if (isVerbatim(params_)) {
+ incfile = latex_path(incfile);
os << '\\' << params_.getCmdName() << '{' << incfile << '}';
} else if (type(params_) == INPUT) {
runparams.exportdata->addExternalFile("latex", writefile,
// \input wants file with extension (default is .tex)
if (!IsLyXFilename(included_file)) {
+ incfile = latex_path(incfile);
os << '\\' << params_.getCmdName() << '{' << incfile << '}';
} else {
+ incfile = ChangeExtension(incfile, ".tex");
+ incfile = latex_path(incfile);
os << '\\' << params_.getCmdName() << '{'
- << ChangeExtension(incfile, ".tex")
+ << incfile
<< '}';
}
} else {
// \include don't want extension and demands that the
// file really have .tex
+ incfile = ChangeExtension(incfile, string());
+ incfile = latex_path(incfile);
os << '\\' << params_.getCmdName() << '{'
- << ChangeExtension(incfile, string())
+ << incfile
<< '}';
}
string id;
lex >> id;
if (!lex || id != "Include")
- return print_mailer_error("InsetBoxMailer", in, 2, "Include");
+ return print_mailer_error("InsetIncludeMailer", in, 2, "Include");
InsetInclude inset(params);
inset.read(lex);