d->bibfiles_cache_.clear();
for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) {
if (it->lyxCode() == BIBTEX_CODE) {
- InsetBibtex const & inset =
- static_cast<InsetBibtex const &>(*it);
+ InsetBibtex const & inset = static_cast<InsetBibtex const &>(*it);
support::FileNameList const bibfiles = inset.getBibFiles();
d->bibfiles_cache_.insert(d->bibfiles_cache_.end(),
bibfiles.begin(),
bibfiles.end());
} else if (it->lyxCode() == INCLUDE_CODE) {
- InsetInclude & inset =
- static_cast<InsetInclude &>(*it);
+ InsetInclude & inset = static_cast<InsetInclude &>(*it);
Buffer const * const incbuf = inset.getChildBuffer();
if (!incbuf)
continue;
continue;
}
- if (doing_export && iit->inset->asInsetMath()) {
- InsetMath * im = static_cast<InsetMath *>(iit->inset);
- if (im->asHullInset()) {
- InsetMathHull * hull = static_cast<InsetMathHull *>(im);
- hull->recordLocation(it);
- }
- }
+ InsetMath * im = iit->inset->asInsetMath();
+ if (doing_export && im)
+ im->asHullInset()->recordLocation(it);
if (iit->inset->lyxCode() != MATHMACRO_CODE)
continue;
// get macro data
MathMacroTemplate & macroTemplate =
- static_cast<MathMacroTemplate &>(*iit->inset);
+ *iit->inset->asInsetMath()->asMacroTemplate();
MacroContext mc(owner_, it);
macroTemplate.updateToContext(mc);
for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) {
if (it->lyxCode() == code) {
- InsetCommand & inset = static_cast<InsetCommand &>(*it);
- docstring const oldValue = inset.getParam(paramName);
+ InsetCommand * inset = it->asInsetCommand();
+ if (!inset)
+ continue;
+ docstring const oldValue = inset->getParam(paramName);
if (oldValue == from)
- inset.setParam(paramName, to);
+ inset->setParam(paramName, to);
}
}
}
if (inset
&& std::find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end()
&& (contents.empty() ||
+ //FIXME: This static_cast seems very dangerous. Does this
+ // mean that if contents is not empty, we must only be
+ // looking for InsetCommand's ??
static_cast<InsetCommand const *>(inset)->getFirstNonOptParam() == contents)) {
dit = tmpdit;
return true;
Inset const * inset = tmpdit.nextInset();
if (inset
&& std::find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end()) {
+ //FIXME: This static_cast seems very dangerous. Does this
+ // mean that if contents is not empty, we must only be
+ // looking for InsetCommand's ??
contents = static_cast<InsetCommand const *>(inset)->getFirstNonOptParam();
}
}
{
LASSERT(inset0, /**/);
if (inMathed())
- insert(MathAtom(inset0));
+ insert(MathAtom(inset0->asInsetMath()));
else {
text()->insertInset(*this, inset0);
inset0->setBuffer(bv_->buffer());
case MATH_HULL_CODE: {
// check for equation labels and resolve duplicates
- InsetMathHull & ins = static_cast<InsetMathHull &>(*it);
- std::vector<InsetLabel *> labels = ins.getLabels();
+ InsetMathHull * ins = it->asInsetMath()->asHullInset();
+ std::vector<InsetLabel *> labels = ins->getLabels();
for (size_t i = 0; i != labels.size(); ++i) {
if (!labels[i])
continue;
for (InsetIterator itt = inset_iterator_begin(in);
itt != i_end; ++itt) {
if (itt->lyxCode() == REF_CODE) {
- InsetCommand & ref =
- static_cast<InsetCommand &>(*itt);
- if (ref.getParam("reference") == oldname)
- ref.setParam("reference", newname);
+ InsetCommand * ref = itt->asInsetCommand();
+ if (ref->getParam("reference") == oldname)
+ ref->setParam("reference", newname);
} else if (itt->lyxCode() == MATH_REF_CODE) {
- InsetMathHull & mi =
- static_cast<InsetMathHull &>(*itt);
+ InsetMathHull * mi = itt->asInsetMath()->asHullInset();
// this is necessary to prevent an uninitialized
// buffer when the RefInset is in a MathBox.
// FIXME audit setBuffer calls
- mi.setBuffer(const_cast<Buffer &>(buffer));
- if (mi.asRefInset()->getTarget() == oldname)
- mi.asRefInset()->changeTarget(newname);
+ mi->setBuffer(const_cast<Buffer &>(buffer));
+ if (mi->asRefInset()->getTarget() == oldname)
+ mi->asRefInset()->changeTarget(newname);
}
}
}
for (InsetIterator itt = inset_iterator_begin(in);
itt != i_end; ++itt) {
if (itt->lyxCode() == CITE_CODE) {
- InsetCommand & ref =
- static_cast<InsetCommand &>(*itt);
- if (ref.getParam("key") == oldkey)
- ref.setParam("key", newkey);
+ InsetCommand * ref = itt->asInsetCommand();
+ if (ref->getParam("key") == oldkey)
+ ref->setParam("key", newkey);
}
}
break;
LASSERT(inTexted(), /**/);
// if we are in a tabular, we need the cell
if (inset().lyxCode() == TABULAR_CODE) {
- InsetTabular & tabular = static_cast<InsetTabular&>(inset());
- return tabular.cell(idx()).get();
+ InsetTabular * tabular = inset().asInsetTabular();
+ return tabular->cell(idx()).get();
}
return &inset();
}
InsetList::iterator end = d->insetlist_.end();
for (; it != end; ++it)
if (it->inset->lyxCode() == BIBITEM_CODE
- && it->pos > 0) {
- InsetBibitem * olditem = static_cast<InsetBibitem *>(it->inset);
+ && it->pos > 0) {
+ InsetCommand * olditem = it->inset->asInsetCommand();
oldkey = olditem->getParam("key");
oldlabel = olditem->getParam("label");
erasedInsetPosition = it->pos;
// There was an InsetBibitem at the beginning and we did have to
// erase one. So we give its properties to the beginning inset.
if (hasbibitem) {
- InsetBibitem * inset =
- static_cast<InsetBibitem *>(d->insetlist_.begin()->inset);
+ InsetCommand * inset = d->insetlist_.begin()->inset->asInsetCommand();
if (!oldkey.empty())
inset->setParam("key", oldkey);
inset->setParam("label", oldlabel);
if (!oldkey.empty())
inset->setParam("key", oldkey);
inset->setParam("label", oldlabel);
- insertInset(0, static_cast<Inset *>(inset),
+ insertInset(0, inset,
Change(track_changes ? Change::INSERTED : Change::UNCHANGED));
return 1;
for (; it != end; ++it) {
buffer().undo().recordUndo(it->second);
if (it->first->lyxCode() == MATH_REF_CODE) {
- InsetMathHull * mi =
- static_cast<InsetMathHull *>(it->first);
+ InsetMathHull * mi = it->first->asInsetMath()->asHullInset();
mi->asRefInset()->changeTarget(label);
} else {
- InsetCommand * ref =
- static_cast<InsetCommand *>(it->first);
+ InsetCommand * ref = it->first->asInsetCommand();
ref->setParam("reference", label);
}
}
DocIterator const ref_pit(it->second);
if (it->first->lyxCode() == MATH_REF_CODE)
toc.push_back(TocItem(ref_pit, 1,
- static_cast<InsetMathHull *>(it->first)->asRefInset()
+ it->first->asInsetMath()->asHullInset()->asRefInset()
->screenLabel()));
else
toc.push_back(TocItem(ref_pit, 1,
{}
-MathAtom::MathAtom(Inset * p)
- : nucleus_(static_cast<InsetMath *>(p))
+MathAtom::MathAtom(InsetMath * p)
+ : nucleus_(p)
{}
/// std::containers
MathAtom();
/// the "real constructor"
- explicit MathAtom(Inset * p);
+ explicit MathAtom(InsetMath * p);
/// copy constructor, invokes nucleus_->clone()
MathAtom(MathAtom const &);
/// we really need to clean up