]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.cpp
cosmetics
[lyx.git] / src / CutAndPaste.cpp
index 9f4114e3817db70bc0d1f0b6c5986bbdfe3e8d76..2cab32ff7ad75f844870a020979afafb723ddd7b 100644 (file)
@@ -48,6 +48,7 @@
 
 #include "support/limited_stack.h"
 #include "support/lstrings.h"
+#include "support/docstream.h"
 
 #include "frontends/Clipboard.h"
 #include "frontends/Selection.h"
@@ -444,27 +445,28 @@ void switchBetweenClasses(TextClassPtr const & c1,
        // character styles
        InsetIterator const i_end = inset_iterator_end(in);
        for (InsetIterator it = inset_iterator_begin(in); it != i_end; ++it) {
-               if (it->lyxCode() == FLEX_CODE) {
-                       InsetFlex & inset =
-                               static_cast<InsetFlex &>(*it);
-                       string const name = inset.params().name;
-                       InsetLayout const & il = 
-                               tclass2.insetlayout(from_utf8(name));
-                       inset.setLayout(il);
-                       if (il.labelstring == from_utf8("UNDEFINED")) {
-                               // The flex inset is undefined in tclass2
-                               docstring const s = bformat(_(
-                                       "Flex inset %1$s is "
-                                       "undefined because of class "
-                                       "conversion from\n%2$s to %3$s"),
-                                        from_utf8(name), from_utf8(tclass1.name()),
-                                        from_utf8(tclass2.name()));
-                               // To warn the user that something had to be done.
-                               errorlist.push_back(ErrorItem(
-                                       _("Undefined flex inset"),
-                                       s, it.paragraph().id(), it.pos(), it.pos() + 1));
-                       } 
-               }
+               InsetCollapsable * inset = it->asInsetCollapsable();
+               if (!inset)
+                       continue;
+               if (inset->lyxCode() != FLEX_CODE)
+                       // FIXME: Should we verify all InsetCollapsable?
+                       continue;
+               docstring const name = inset->name();
+               InsetLayout const & il = tclass2.insetlayout(name);
+               inset->setLayout(il);
+               if (il.labelstring != from_utf8("UNDEFINED"))
+                       continue;
+               // The flex inset is undefined in tclass2
+               docstring const s = bformat(_(
+                       "Flex inset %1$s is "
+                       "undefined because of class "
+                       "conversion from\n%2$s to %3$s"),
+                       name, from_utf8(tclass1.name()),
+                       from_utf8(tclass2.name()));
+               // To warn the user that something had to be done.
+               errorlist.push_back(ErrorItem(
+                               _("Undefined flex inset"),
+                               s, it.paragraph().id(), it.pos(), it.pos() + 1));
        }
 }