#include "insetinclude.h"
#include "buffer.h"
+#include "buffer_funcs.h"
#include "bufferlist.h"
#include "BufferView.h"
#include "debug.h"
#include <cstdlib>
+using namespace lyx::support;
+
using std::ostream;
using std::endl;
using std::vector;
using std::pair;
+using std::auto_ptr;
+
extern BufferList bufferlist;
-class InsetInclude::PreviewImpl : public grfx::PreviewedInset {
+class InsetInclude::PreviewImpl : public lyx::graphics::PreviewedInset {
public:
///
PreviewImpl(InsetInclude & p) : PreviewedInset(p) {}
InsetInclude::InsetInclude(Params const & p)
: params_(p), include_label(uniqueID()),
- preview_(new PreviewImpl(*this))
+ preview_(new PreviewImpl(*this)),
+ set_label_(false)
{}
InsetInclude::InsetInclude(InsetCommandParams const & p, Buffer const & b)
: include_label(uniqueID()),
- preview_(new PreviewImpl(*this))
+ preview_(new PreviewImpl(*this)),
+ set_label_(false)
{
params_.cparams = p;
params_.masterFilename_ = b.fileName();
}
+InsetInclude::InsetInclude(InsetInclude const & other)
+ : InsetOld(other),
+ params_(other.params_),
+ include_label(other.include_label),
+ preview_(new PreviewImpl(*this)),
+ set_label_(other.set_label_)
+{}
+
+
InsetInclude::~InsetInclude()
{
InsetIncludeMailer mailer(*this);
return DISPATCHED;
default:
- return InsetButton::localDispatch(cmd);
+ return InsetOld::localDispatch(cmd);
}
}
if (preview_->monitoring())
preview_->stopMonitoring();
- if (grfx::PreviewedInset::activated() && params_.flag == INPUT)
+ if (lyx::graphics::PreviewedInset::activated() && params_.flag == INPUT)
preview_->generatePreview();
}
-Inset * 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_));
}
FileInfo finfo(getFileName());
if (!finfo.isOK())
return false;
-
- return bufferlist.loadLyXFile(getFileName(), false) != 0;
+ return loadLyXFile(bufferlist.newBuffer(getFileName()),
+ getFileName());
}
tmp->markDepClean(buffer->tmppath);
tmp->makeLaTeXFile(writefile, OnlyPath(getMasterFilename()),
- runparams, true);
+ runparams, false);
}
if (isVerbatim()) {
}
-vector<string> const InsetInclude::getLabelList() const
+void InsetInclude::getLabelList(std::vector<string> & list) const
{
- vector<string> l;
-
if (loadIfNeeded()) {
Buffer * tmp = bufferlist.getBuffer(getFileName());
tmp->setParentName("");
- l = tmp->getLabelList();
+ tmp->getLabelList(list);
tmp->setParentName(getMasterFilename());
}
-
- return l;
}
-void InsetInclude::fillWithBibKeys(vector<pair<string,string> > & keys) const
+void InsetInclude::fillWithBibKeys(std::vector<std::pair<string,string> > & keys) const
{
if (loadIfNeeded()) {
Buffer * tmp = bufferlist.getBuffer(getFileName());
dim.des = preview_->pimage()->descent();
dim.wid = preview_->pimage()->width();
} else {
- InsetButton::metrics(mi, dim);
+ if (!set_label_) {
+ set_label_ = true;
+ button_.update(getScreenLabel(mi.base.bv->buffer()),
+ editable() != NOT_EDITABLE);
+ }
+ button_.metrics(mi, dim);
}
dim_ = dim;
}
{
cache(pi.base.bv);
if (!preview_->previewReady()) {
- InsetButton::draw(pi, x, y);
+ button_.draw(pi, x, y);
return;
}
if (!preview_->monitoring())
preview_->startMonitoring();
- Dimension dim;
- MetricsInfo mi;
- mi.base.bv = pi.base.bv;
- mi.base.font = pi.base.font;
- metrics(mi, dim);
- dim_ = dim;
-
- pi.pain.image(x, y - dim.asc, dim.wid, dim.height(),
+ pi.pain.image(x, y - dim_.asc, dim_.wid, dim_.height(),
*(preview_->pimage()->image()));
}
+BufferView * InsetInclude::view() const
+{
+ return button_.view();
+}
+
+
//
// preview stuff
//
-void InsetInclude::addPreview(grfx::PreviewLoader & ploader) const
+void InsetInclude::addPreview(lyx::graphics::PreviewLoader & ploader) const
{
preview_->addPreview(ploader);
}
{}
-string const InsetIncludeMailer::inset2string() const
+string const InsetIncludeMailer::inset2string(Buffer const &) const
{
return params2string(inset_.params());
}