InsetInclude::InsetInclude(InsetCommandParams const & p, Buffer const & b)
+ : include_label(unique_id())
{
params_.cparams = p;
params_.masterFilename_ = b.fileName();
- include_label = unique_id();
}
// the readonly flag can/will be wrong, not anymore I think.
FileInfo finfo(getFileName());
- bool const ro = !finfo.writable();
- return bufferlist.readFile(getFileName(), ro) != 0;
+ if (!finfo.isOK())
+ return false;
+
+ return bufferlist.readFile(getFileName(), !finfo.writable()) != 0;
}
}
-int InsetInclude::ascii(Buffer const *, std::ostream & os, int) const
+int InsetInclude::ascii(Buffer const *, ostream & os, int) const
{
if (isVerbatim())
os << GetFileContents(getFileName());
// write it to a file (so far the complete file)
string writefile = ChangeExtension(getFileName(), ".sgml");
- if (!buffer->tmppath.empty() && !buffer->niceFile) {
+ if (!buffer->tmppath.empty() && buffer->niceFile) {
incfile = subst(incfile, '/','@');
writefile = AddName(buffer->tmppath, incfile);
} else
}
if (isVerbatim()) {
- os << "<inlinegraphic fileref=\"" << '&' << include_label << ';'
- << "\" format=\"linespecific\">"
- << "</inlinegraphic>";
+ os << "<![CDATA["
+ << GetFileContents(getFileName())
+ << "]]>";
} else
os << '&' << include_label << ';';
// write it to a file (so far the complete file)
string writefile = ChangeExtension(getFileName(), ".sgml");
- if (!buffer->tmppath.empty() && !buffer->niceFile) {
+ if (!buffer->tmppath.empty() && buffer->niceFile) {
incfile = subst(incfile, '/','@');
writefile = AddName(buffer->tmppath, incfile);
} else
}
if (isVerbatim()) {
- os << "<inlinegraphic fileref=\"" << '&' << include_label << ';'
- << "\" format=\"linespecific\">"
- << "</inlinegraphic>";
+ os << "<inlinegraphic fileref=\""
+ << '&' << include_label << ';'
+ << "\" format=\"linespecific\">";
} else
os << '&' << include_label << ';';
Buffer const * const b = bufferlist.getBuffer(getMasterFilename());
- if (b && !b->tmppath.empty() && b->niceFile) {
+ if (b && !b->tmppath.empty() && b->niceFile && !isVerbatim()) {
incfile = subst(incfile, '/','@');
writefile = AddName(b->tmppath, incfile);
} else