#include "insets/render_preview.h"
#include "buffer.h"
-#include "BufferView.h"
#include "cursor.h"
#include "debug.h"
#include "dispatchresult.h"
#include "exporter.h"
+#include "FuncStatus.h"
#include "funcrequest.h"
#include "gettext.h"
#include "LaTeXFeatures.h"
#include "metricsinfo.h"
#include "outputparams.h"
-#include "frontends/lyx_gui.h"
-#include "frontends/LyXView.h"
-
#include "graphics/PreviewLoader.h"
-#include "support/FileInfo.h"
#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
-#include "support/tostr.h"
+#include "support/convert.h"
#include "support/translator.h"
#include <boost/bind.hpp>
namespace external = lyx::external;
namespace graphics = lyx::graphics;
+using lyx::docstring;
using std::endl;
using std::string;
using std::auto_ptr;
<< '\n';
if (lyxscale != defaultLyxScale)
- os << "\tlyxscale " << tostr(lyxscale) << '\n';
+ os << "\tlyxscale " << convert<string>(lyxscale) << '\n';
if (draft)
os << "\tdraft\n";
}
if (!rotationdata.no_rotation()) {
- os << "\trotateAngle " << rotationdata.angle() << '\n';
+ os << "\trotateAngle " << rotationdata.adjAngle() << '\n';
if (rotationdata.origin() != external::RotationData::DEFAULT)
os << "\trotateOrigin "
<< rotationdata.originString() << '\n';
if (!resizedata.no_resize()) {
using support::float_equal;
-
- if (!float_equal(resizedata.scale, 0.0, 0.05)) {
- if (!float_equal(resizedata.scale, 100.0, 0.05))
+ double const scl = convert<double>(resizedata.scale);
+ if (!float_equal(scl, 0.0, 0.05)) {
+ if (!float_equal(scl, 100.0, 0.05))
os << "\tscale "
<< resizedata.scale << '\n';
} else {
case EX_ROTATEANGLE:
lex.next();
- rotationdata.angle(lex.getFloat());
+ rotationdata.angle = lex.getString();
break;
case EX_ROTATEORIGIN:
case EX_SCALE:
lex.next();
- resizedata.scale = lex.getFloat();
+ resizedata.scale = lex.getString();
break;
case EX_WIDTH:
{}
-auto_ptr<InsetBase> InsetExternal::clone() const
+auto_ptr<InsetBase> InsetExternal::doClone() const
{
return auto_ptr<InsetBase>(new InsetExternal(*this));
}
}
-void InsetExternal::priv_dispatch(LCursor & cur, FuncRequest & cmd)
+void InsetExternal::doDispatch(LCursor & cur, FuncRequest & cmd)
{
switch (cmd.action) {
case LFUN_EXTERNAL_EDIT: {
Buffer const & buffer = cur.buffer();
InsetExternalParams p;
- InsetExternalMailer::string2params(cmd.argument, buffer, p);
+ InsetExternalMailer::string2params(lyx::to_utf8(cmd.argument()), buffer, p);
external::editExternal(p, buffer);
break;
}
case LFUN_INSET_MODIFY: {
Buffer const & buffer = cur.buffer();
InsetExternalParams p;
- InsetExternalMailer::string2params(cmd.argument, buffer, p);
+ InsetExternalMailer::string2params(lyx::to_utf8(cmd.argument()), buffer, p);
setParams(p, buffer);
break;
}
break;
default:
- InsetOld::priv_dispatch(cur, cmd);
+ InsetBase::doDispatch(cur, cmd);
+ }
+}
+
+
+bool InsetExternal::getStatus(LCursor & cur, FuncRequest const & cmd,
+ FuncStatus & flag) const
+{
+ switch (cmd.action) {
+
+ case LFUN_EXTERNAL_EDIT:
+ case LFUN_INSET_MODIFY:
+ case LFUN_INSET_DIALOG_UPDATE:
+ flag.enabled(true);
+ return true;
+
+ default:
+ return InsetBase::getStatus(cur, cmd, flag);
}
}
gparams.scale = eparams.lyxscale;
if (eparams.clipdata.clip)
gparams.bb = eparams.clipdata.bbox;
- gparams.angle = eparams.rotationdata.angle();
+ gparams.angle = convert<double>(eparams.rotationdata.adjAngle());
switch (eparams.display) {
case external::DefaultDisplay:
if (gparams.display == graphics::DefaultDisplay)
gparams.display = lyxrc.display_graphics;
// Override the above if we're not using a gui
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
gparams.display = graphics::NoDisplay;
return gparams;
}
-string const getScreenLabel(InsetExternalParams const & params,
+docstring const getScreenLabel(InsetExternalParams const & params,
Buffer const & buffer)
{
external::Template const * const ptr =
external::getTemplatePtr(params);
if (!ptr)
- return support::bformat(_("External template %1$s is not installed"),
- params.templatename());
- return external::doSubstitution(params, buffer, ptr->guiName);
+ // FIXME UNICODE
+ return support::bformat((_("External template %1$s is not installed")),
+ lyx::from_utf8(params.templatename()));
+ // FIXME UNICODE
+ return lyx::from_utf8(external::doSubstitution(params, buffer,
+ ptr->guiName, false));
}
void add_preview_and_start_loading(RenderMonitoredPreview &,
// run through the LaTeX compiler.
// If we're running through the LaTeX compiler, we should write the
// generated files in the bufer's temporary directory.
- bool const external_in_tmpdir = !runparams.nice;
+ bool const external_in_tmpdir = !runparams.nice && !runparams.dryrun;
// If the template has specified a PDFLaTeX output, then we try and
// use that.
et.formats.find("PDFLaTeX");
if (cit != et.formats.end())
return external::writeExternal(params_, "PDFLaTeX",
- buf, os,
- *(runparams.exportdata),
- external_in_tmpdir);
+ buf, os,
+ *(runparams.exportdata),
+ external_in_tmpdir,
+ runparams.inComment);
}
return external::writeExternal(params_, "LaTeX", buf, os,
- *(runparams.exportdata),
- external_in_tmpdir);
+ *(runparams.exportdata),
+ external_in_tmpdir,
+ runparams.inComment);
}
-int InsetExternal::plaintext(Buffer const & buf, ostream & os,
+int InsetExternal::plaintext(Buffer const & buf, lyx::odocstream & os,
OutputParams const & runparams) const
{
- return external::writeExternal(params_, "Ascii", buf, os,
- *(runparams.exportdata));
-}
-
-
-int InsetExternal::linuxdoc(Buffer const & buf, ostream & os,
- OutputParams const & runparams) const
-{
- return external::writeExternal(params_, "LinuxDoc", buf, os,
- *(runparams.exportdata));
+ std::ostringstream oss;
+ int const retval = external::writeExternal(params_, "Ascii", buf, oss,
+ *(runparams.exportdata), false,
+ runparams.inComment);
+ // FIXME UNICODE
+ os << lyx::from_utf8(oss.str());
+ return retval;
}
OutputParams const & runparams) const
{
return external::writeExternal(params_, "DocBook", buf, os,
- *(runparams.exportdata));
+ *(runparams.exportdata), false,
+ runparams.inComment);
}
return;
external::Template const & et = *et_ptr;
+ string format;
+ switch (features.runparams().flavor) {
+ case OutputParams::LATEX:
+ format = "LaTeX";
+ break;
+ case OutputParams::PDFLATEX:
+ format = "PDFLaTeX";
+ break;
+ case OutputParams::XML:
+ format = "DocBook";
+ break;
+ }
external::Template::Formats::const_iterator cit =
- et.formats.find("LaTeX");
+ et.formats.find(format);
if (cit == et.formats.end())
return;
- if (!cit->second.requirement.empty())
- features.require(cit->second.requirement);
+ // FIXME: We don't need that always
+ features.require("lyxdot");
+
+ vector<string>::const_iterator it = cit->second.requirements.begin();
+ vector<string>::const_iterator end = cit->second.requirements.end();
+ for (; it != end; ++it)
+ features.require(*it);
external::TemplateManager & etm = external::TemplateManager::get();
- vector<string>::const_iterator it = cit->second.preambleNames.begin();
- vector<string>::const_iterator end = cit->second.preambleNames.end();
+ it = cit->second.preambleNames.begin();
+ end = cit->second.preambleNames.end();
for (; it != end; ++it) {
string const preamble = etm.getPreambleDefByName(*it);
if (!preamble.empty())
string const included_file = params.filename.absFilename();
return params.display == external::PreviewDisplay &&
- support::IsFileReadable(included_file);
+ support::isFileReadable(included_file);
}