#include <algorithm> // For the std::max
-extern string system_tempdir;
// set by Exporters
using namespace lyx::support;
using std::ostream;
using std::endl;
+using std::auto_ptr;
namespace {
InsetGraphics::InsetGraphics(InsetGraphics const & ig)
- : Inset(ig),
+ : InsetOld(ig),
boost::signals::trackable(),
graphic_label(uniqueID()),
graphic_(new GraphicRenderer(*ig.graphic_))
}
-InsetBase * InsetGraphics::clone() const
+auto_ptr<InsetBase> InsetGraphics::clone() const
{
- return new InsetGraphics(*this);
+ return auto_ptr<InsetBase>(new InsetGraphics(*this));
}
{
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
- string const bufpath = cmd.view()->buffer()->filePath();
+ Buffer const & buffer = *cmd.view()->buffer();
InsetGraphicsParams p;
- InsetGraphicsMailer::string2params(cmd.argument, bufpath, p);
+ InsetGraphicsMailer::string2params(cmd.argument, buffer, p);
if (!p.filename.empty()) {
setParams(p);
cmd.view()->updateInset(this);
return DISPATCHED;
default:
- return Inset::localDispatch(cmd);
+ return InsetOld::localDispatch(cmd);
}
}
}
-Inset::EDITABLE InsetGraphics::editable() const
+InsetOld::EDITABLE InsetGraphics::editable() const
{
return IS_EDITABLE;
}
{
// LaTeX can cope if the graphics file doesn't exist, so just return the
// filename.
- string orig_file = params().filename;
- string const rel_file = MakeRelPath(orig_file, buf->filePath());
+ string orig_file = params().filename.absFilename();
+ string const rel_file = params().filename.relFilename(buf->filePath());
if (!IsFileReadable(orig_file)) {
lyxerr[Debug::GRAPHICS]
// just output a message about it in the latex output.
lyxerr[Debug::GRAPHICS]
<< "insetgraphics::latex: Filename = "
- << params().filename << endl;
+ << params().filename.absFilename() << endl;
- string const relative_file = MakeRelPath(params().filename, buf->filePath());
+ string const relative_file =
+ params().filename.relFilename(buf->filePath());
// A missing (e)ps-extension is no problem for LaTeX, so
// we have to test three different cases
#warning uh, but can our cache handle it ? no.
- string const file_ = params().filename;
+ string const file_ = params().filename.absFilename();
bool const file_exists =
!file_.empty() &&
(IsFileReadable(file_) || // original
// 1. Convert file to ascii using gifscii
// 2. Read ascii output file and add it to the output stream.
// at least we send the filename
- os << '<' << bformat(_("Graphics file: %1$s"), params().filename) << ">\n";
+ os << '<' << bformat(_("Graphics file: %1$s"),
+ params().filename.absFilename()) << ">\n";
return 0;
}
-int InsetGraphics::linuxdoc(Buffer const *, ostream &) const
+int InsetGraphics::linuxdoc(Buffer const * buf, ostream & os) const
{
- // No graphics in LinuxDoc output. Should check how/what to add.
+ string const file_name = buf->niceFile ?
+ params().filename.relFilename(buf->filePath()):
+ params().filename.absFilename();
+
+ os << "<eps file=\"" << file_name << "\">\n";
+ os << "<img src=\"" << file_name << "\">";
return 0;
}
if (params().filename.empty())
return;
- features.includeFile(graphic_label, RemoveExtension(params().filename));
+ features.includeFile(graphic_label,
+ RemoveExtension(params().filename.absFilename()));
features.require("graphicx");
}
-BufferView * InsetGraphics::view() const
-{
- return graphic_->view();
-}
-
-
string const InsetGraphicsMailer::name_("graphics");
InsetGraphicsMailer::InsetGraphicsMailer(InsetGraphics & inset)
{}
-string const InsetGraphicsMailer::inset2string() const
+string const InsetGraphicsMailer::inset2string(Buffer const & buffer) const
{
- BufferView * bv = inset_.view();
- if (bv)
- return params2string(inset_.params(), bv->buffer()->filePath());
- return string();
+ return params2string(inset_.params(), buffer);
}
void InsetGraphicsMailer::string2params(string const & in,
- string const & buffer_path,
- InsetGraphicsParams & params)
+ Buffer const & buffer,
+ InsetGraphicsParams & params)
{
params = InsetGraphicsParams();
if (lex.isOK()) {
InsetGraphics inset;
- inset.readInsetGraphics(lex, buffer_path);
+ inset.readInsetGraphics(lex, buffer.filePath());
params = inset.params();
}
}
string const
InsetGraphicsMailer::params2string(InsetGraphicsParams const & params,
- string const & buffer_path)
+ Buffer const & buffer)
{
ostringstream data;
data << name_ << ' ';
- params.Write(data, buffer_path);
+ params.Write(data, buffer.filePath());
data << "\\end_inset\n";
return STRCONV(data.str());
}