]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.cpp
make frontend::Application a bit slimmer
[lyx.git] / src / CutAndPaste.cpp
index 3692dcc873fdaef55fdf95232feee7beb3b49513..998bd9d9d72ec5393a3785bac032b388dc8cddd5 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));
        }
 }
 
@@ -672,9 +674,8 @@ void saveSelection(Cursor & cur)
        if (cur.selection() 
            && cur.selBegin() == cur.bv().cursor().selBegin()
            && cur.selEnd() == cur.bv().cursor().selEnd()) {
-               LYXERR(Debug::ACTION) << BOOST_CURRENT_FUNCTION << ": `"
-                          << to_utf8(cur.selectionAsString(true)) << "'."
-                          << endl;
+               LYXERR(Debug::ACTION, BOOST_CURRENT_FUNCTION << ": `"
+                          << to_utf8(cur.selectionAsString(true)) << "'.");
                copySelectionToStack(cur, selectionBuffer);
        }
 }