*
* \author Lars Gullik Bjønnes
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
using std::endl;
using std::vector;
using std::pair;
+using std::auto_ptr;
+
extern BufferList bufferlist;
InsetInclude::InsetInclude(InsetInclude const & other)
- : Inset(other),
+ : InsetOld(other),
params_(other.params_),
include_label(other.include_label),
preview_(new PreviewImpl(*this)),
return DISPATCHED;
default:
- return Inset::localDispatch(cmd);
+ return InsetOld::localDispatch(cmd);
}
}
}
-InsetBase * InsetInclude::clone() const
+auto_ptr<InsetBase> InsetInclude::clone() const
{
//Params p(params_);
//p.masterFilename_ = buffer.fileName();
#warning FIXME: broken cross-doc copy/paste - must fix
- return new InsetInclude(params_);
+ return auto_ptr<InsetBase>(new InsetInclude(params_));
}
-void InsetInclude::write(Buffer const *, ostream & os) const
+void InsetInclude::write(Buffer const &, ostream & os) const
+{
+ write(os);
+}
+
+
+void InsetInclude::write(ostream & os) const
{
os << "Include " << params_.cparams.getCommand() << '\n'
<< "preview " << tostr(params_.cparams.preview()) << '\n';
}
-void InsetInclude::read(Buffer const *, LyXLex & lex)
+void InsetInclude::read(Buffer const &, LyXLex & lex)
+{
+ read(lex);
+}
+
+
+void InsetInclude::read(LyXLex & lex)
{
params_.cparams.read(lex);
}
-bool InsetInclude::display() const
-{
- return !(params_.flag == INPUT);
-}
-
-
-string const InsetInclude::getScreenLabel(Buffer const *) const
+string const InsetInclude::getScreenLabel(Buffer const &) const
{
string temp;
}
-int InsetInclude::latex(Buffer const * buffer, ostream & os,
+int InsetInclude::latex(Buffer const & buffer, ostream & os,
LatexRunParams const & runparams) const
{
string incfile(params_.cparams.getContents());
Buffer * tmp = bufferlist.getBuffer(getFileName());
// FIXME: this should be a GUI warning
- if (tmp->params.textclass != buffer->params.textclass) {
+ if (tmp->params.textclass != buffer.params.textclass) {
lyxerr << "WARNING: Included file `"
<< MakeDisplayPath(getFileName())
<< "' has textclass `"
<< tmp->params.getLyXTextClass().name()
<< "' while parent file has textclass `"
- << buffer->params.getLyXTextClass().name()
+ << buffer.params.getLyXTextClass().name()
<< "'." << endl;
//return 0;
}
// write it to a file (so far the complete file)
string writefile = ChangeExtension(getFileName(), ".tex");
- if (!buffer->tmppath.empty() && !runparams.nice) {
+ if (!buffer.tmppath.empty() && !runparams.nice) {
incfile = subst(incfile, '/','@');
#ifdef __EMX__
incfile = subst(incfile, ':', '$');
#endif
- writefile = AddName(buffer->tmppath, incfile);
+ writefile = AddName(buffer.tmppath, incfile);
} else
writefile = getFileName();
writefile = ChangeExtension(writefile, ".tex");
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
- tmp->markDepClean(buffer->tmppath);
+ tmp->markDepClean(buffer.tmppath);
tmp->makeLaTeXFile(writefile, OnlyPath(getMasterFilename()),
- runparams, true);
+ runparams, false);
}
if (isVerbatim()) {
}
-int InsetInclude::ascii(Buffer const *, ostream & os, int) const
+int InsetInclude::ascii(Buffer const &, ostream & os, int) const
{
if (isVerbatim())
os << GetFileContents(getFileName());
}
-int InsetInclude::linuxdoc(Buffer const * buffer, ostream & os) const
+int InsetInclude::linuxdoc(Buffer const & buffer, ostream & os) const
{
string incfile(params_.cparams.getContents());
// 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);
+ writefile = AddName(buffer.tmppath, incfile);
} else
writefile = getFileName();
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
- tmp->makeLinuxDocFile(writefile, buffer->niceFile, true);
+ tmp->makeLinuxDocFile(writefile, buffer.niceFile, true);
}
if (isVerbatim()) {
}
-int InsetInclude::docbook(Buffer const * buffer, ostream & os,
+int InsetInclude::docbook(Buffer const & buffer, ostream & os,
bool /*mixcont*/) const
{
string incfile(params_.cparams.getContents());
// 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);
+ writefile = AddName(buffer.tmppath, incfile);
} else
writefile = getFileName();
if (IsLyXFilename(getFileName()))
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
- tmp->makeDocBookFile(writefile, buffer->niceFile, true);
+ tmp->makeDocBookFile(writefile, buffer.niceFile, true);
}
if (isVerbatim()) {
string incfile(params_.cparams.getContents());
string writefile;
- Buffer const * const b = bufferlist.getBuffer(getMasterFilename());
+ Buffer const & b = *bufferlist.getBuffer(getMasterFilename());
- if (b && !b->tmppath.empty() && !b->niceFile && !isVerbatim()) {
+ if (!b.tmppath.empty() && !b.niceFile && !isVerbatim()) {
incfile = subst(incfile, '/','@');
- writefile = AddName(b->tmppath, incfile);
+ writefile = AddName(b.tmppath, incfile);
} else
writefile = getFileName();
// a file got loaded
Buffer * const tmp = bufferlist.getBuffer(getFileName());
if (tmp) {
- if (b)
- tmp->niceFile = b->niceFile;
+ tmp->niceFile = b.niceFile;
tmp->validate(features);
}
}
} else {
if (!set_label_) {
set_label_ = true;
- button_.update(getScreenLabel(mi.base.bv->buffer()),
+ button_.update(getScreenLabel(*mi.base.bv->buffer()),
editable() != NOT_EDITABLE);
}
button_.metrics(mi, dim);
}
+ if (params_.flag == INPUT)
+ center_indent_ = 0;
+ else
+ center_indent_ = (mi.base.textwidth - dim.wid) / 2;
+ dim.wid = mi.base.textwidth;
dim_ = dim;
}
{
cache(pi.base.bv);
if (!preview_->previewReady()) {
- button_.draw(pi, x, y);
+ button_.draw(pi, x + center_indent_, y);
return;
}
if (!preview_->monitoring())
preview_->startMonitoring();
- pi.pain.image(x, y - dim_.asc, dim_.wid, dim_.height(),
+ pi.pain.image(x + center_indent_, y - dim_.asc, dim_.wid, dim_.height(),
*(preview_->pimage()->image()));
}
ostringstream os;
LatexRunParams runparams;
runparams.flavor = LatexRunParams::LATEX;
- parent().latex(view()->buffer(), os, runparams);
+ parent().latex(*view()->buffer(), os, runparams);
return STRCONV(os.str());
}
if (lex.isOK()) {
InsetInclude inset(params);
- inset.read(0, lex);
+ inset.read(lex);
params = inset.params();
}
}
inset.set(params);
ostringstream data;
data << name_ << ' ';
- inset.write(0, data);
+ inset.write(data);
data << "\\end_inset\n";
return STRCONV(data.str());
}