}
case LFUN_SET_GRAPHICS_GROUP: {
- Inset * instmp = &cur.inset();
- if (instmp->lyxCode() != GRAPHICS_CODE) instmp = cur.nextInset();
- if (!instmp || instmp->lyxCode() != GRAPHICS_CODE) break;
+ InsetGraphics * ins = InsetGraphics::getCurrentGraphicsInset(cur);
+ if (!ins) break;
cur.recordUndoFullDocument();
- Inset & inset = *instmp;
- InsetGraphics & ins = static_cast<InsetGraphics &>(inset);
string id = to_utf8(cmd.argument());
string grp = InsetGraphics::getGroupParams(bv->buffer(), id);
- InsetGraphicsParams tmp, inspar = ins.getParams();
+ InsetGraphicsParams tmp, inspar = ins->getParams();
if (id.empty())
inspar.groupId = to_utf8(cmd.argument());
inspar = tmp;
}
- ins.setParams(inspar);
+ ins->setParams(inspar);
}
case LFUN_SPACE_INSERT:
return string();
}
+
void InsetGraphics::unifyGraphicsGroups(Buffer const & b, std::string const & argument)
{
- InsetGraphicsParams params;
- InsetGraphics::string2params(argument, b, params);
-
- Inset & inset = b.inset();
- InsetIterator it = inset_iterator_begin(inset);
- InsetIterator const end = inset_iterator_end(inset);
- for (; it != end; ++it) {
- if (it->lyxCode() == GRAPHICS_CODE) {
- InsetGraphics & ins = static_cast<InsetGraphics &>(*it);
- InsetGraphicsParams inspar = ins.getParams();
- if (params.groupId == inspar.groupId) {
- params.filename = inspar.filename;
- ins.setParams(params);
- }
- }
+ InsetGraphicsParams params;
+ InsetGraphics::string2params(argument, b, params);
+
+ Inset & inset = b.inset();
+ InsetIterator it = inset_iterator_begin(inset);
+ InsetIterator const end = inset_iterator_end(inset);
+ for (; it != end; ++it) {
+ if (it->lyxCode() == GRAPHICS_CODE) {
+ InsetGraphics & ins = static_cast<InsetGraphics &>(*it);
+ InsetGraphicsParams inspar = ins.getParams();
+ if (params.groupId == inspar.groupId) {
+ params.filename = inspar.filename;
+ ins.setParams(params);
}
+ }
+ }
}
+InsetGraphics * InsetGraphics::getCurrentGraphicsInset(Cursor const & cur)
+{
+ Inset * instmp = &cur.inset();
+ if (instmp->lyxCode() != GRAPHICS_CODE) instmp = cur.nextInset();
+ if (!instmp || instmp->lyxCode() != GRAPHICS_CODE) return 0;
+
+ InsetGraphics & ins = static_cast<InsetGraphics &>(*instmp);
+ return &ins;
+}
+
} // namespace lyx
Both groupId and params are taken from argument.
*/
static void unifyGraphicsGroups(Buffer const &, std::string const &);
+ static InsetGraphics * getCurrentGraphicsInset(Cursor const &);
/** Set the inset parameters, used by the GUIndependent dialog.
Return true of new params are different from what was so far.