]> git.lyx.org Git - features.git/commitdiff
Move code to more appropriate place, cosmetics.
authorPavel Sanda <sanda@lyx.org>
Wed, 7 May 2008 14:44:58 +0000 (14:44 +0000)
committerPavel Sanda <sanda@lyx.org>
Wed, 7 May 2008 14:44:58 +0000 (14:44 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24657 a592a061-630c-0410-9148-cb99ea01b6c8

src/Text3.cpp
src/insets/InsetGraphics.cpp
src/insets/InsetGraphics.h

index 726224ff86cd61fcb42f1cb42c3848222a42559d..aed8fc83b93bfbdf4f96a7b3180947eef009bce1 100644 (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:
index f280818a2479604477e19044f5f7cb1bbc989b38..40354e85ffc8466c82496d0bbbff0cf28e2f784d 100644 (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);
-
-                       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
index 2c601567b7ab2b594ab7cc367c0a75b1069321af..cca885784f2814d76c9d779a6b88824466dea220 100644 (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.