Move code to more appropriate place, cosmetics.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24657 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Pavel Sanda 2008-05-07 14:44:58 +00:00
parent 4b07e1ea92
commit c32f7c377e
3 changed files with 30 additions and 21 deletions

View File

@ -893,17 +893,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
}
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());
@ -913,7 +910,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
inspar = tmp;
}
ins.setParams(inspar);
ins->setParams(inspar);
}
case LFUN_SPACE_INSERT:

View File

@ -985,26 +985,37 @@ string InsetGraphics::getGroupParams(Buffer const & b, std::string const & group
return string();
}
void InsetGraphics::unifyGraphicsGroups(Buffer const & b, std::string const & argument)
{
InsetGraphicsParams params;
InsetGraphics::string2params(argument, b, 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);
}
}
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

View File

@ -57,6 +57,7 @@ public:
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.