]> git.lyx.org Git - features.git/commitdiff
Move special handling of paste function from InsetCollapsable to InsetText
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 14 Jul 2009 13:00:42 +0000 (13:00 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 14 Jul 2009 13:00:42 +0000 (13:00 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30562 a592a061-630c-0410-9148-cb99ea01b6c8

src/Text3.cpp
src/insets/InsetCollapsable.cpp
src/insets/InsetCollapsable.h
src/insets/InsetText.cpp
src/insets/InsetText.h

index fe8b508b1676c7e4e1582a02dbe8739eac4de2da..5c726f97c9a140cfad3b906a778a770175efd917 100644 (file)
@@ -512,6 +512,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 {
        LYXERR(Debug::ACTION, "Text::dispatch: cmd: " << cmd);
 
+       // Dispatch if the cursor is inside the text. It is not the
+       // case for context menus (bug 5797).
+       if (cur.text() != this) {
+               cur.undispatched();
+               return;
+       }
+
        BufferView * bv = &cur.bv();
        TextMetrics * tm = &bv->textMetrics(this);
        if (!tm->contains(cur.pit())) {
index 51c7048a409474d1e2e9cc77eedbd120da704405..de8561f69b7a5442a90964668d4d7ec5cd094c2d 100644 (file)
@@ -180,7 +180,7 @@ void InsetCollapsable::read(Lexer & lex)
        // since new text inherits the language from the last position of the
        // existing text.  As a side effect this makes us also robust against
        // bugs in LyX that might lead to font changes in ERT in .lyx files.
-       resetParagraphsFont();
+       fixParagraphsFont();
 }
 
 
@@ -557,19 +557,6 @@ void InsetCollapsable::doDispatch(Cursor & cur, FuncRequest & cmd)
                cur.dispatched();
                break;
 
-       case LFUN_PASTE:
-       case LFUN_CLIPBOARD_PASTE:
-       case LFUN_SELECTION_PASTE:
-       case LFUN_PRIMARY_SELECTION_PASTE: {
-               InsetText::doDispatch(cur, cmd);
-               // Since we can only store plain text, we must reset all
-               // attributes.
-               // FIXME: Change only the pasted paragraphs
-
-               resetParagraphsFont();
-               break;
-       }
-
        case LFUN_TAB_INSERT: {
                bool const multi_par_selection = cur.selection() &&
                        cur.selBegin().pit() != cur.selEnd().pit();
@@ -668,23 +655,6 @@ void InsetCollapsable::doDispatch(Cursor & cur, FuncRequest & cmd)
 }
 
 
-void InsetCollapsable::resetParagraphsFont()
-{
-       Font font(inherit_font, buffer().params().language);
-       if (getLayout().isForceLtr())
-               font.setLanguage(latex_language);
-       if (getLayout().isPassThru()) {
-               ParagraphList::iterator par = paragraphs().begin();
-               ParagraphList::iterator const end = paragraphs().end();
-               while (par != end) {
-                       par->resetFonts(font);
-                       par->params().clear();
-                       ++par;
-               }
-       }
-}
-
-
 bool InsetCollapsable::getStatus(Cursor & cur, FuncRequest const & cmd,
                FuncStatus & flag) const
 {
index 0ed8bcf63fc55ecd8979af7e6a591443677db25d..85ded86eafc081d0441fc39455e2f22be192f4fd 100644 (file)
@@ -159,8 +159,6 @@ protected:
        ///
        docstring floatName(std::string const & type) const;
        ///
-       virtual void resetParagraphsFont();
-       ///
        mutable CollapseStatus status_;
 private:
        ///
index a396041a30bbb453b7725cf64aa325835495df3e..0a5cb92764662f2f38916c41ae24fcb974a6c8d7 100644 (file)
@@ -29,6 +29,7 @@
 #include "InsetCaption.h"
 #include "InsetList.h"
 #include "Intl.h"
+#include "Language.h"
 #include "Lexer.h"
 #include "lyxfind.h"
 #include "LyXRC.h"
@@ -265,12 +266,20 @@ void InsetText::doDispatch(Cursor & cur, FuncRequest & cmd)
        LYXERR(Debug::ACTION, "InsetText::doDispatch()"
                << " [ cmd.action = " << cmd.action << ']');
 
-       // Dispatch only to text_ if the cursor is inside
-       // the text_. It is not for context menus (bug 5797).
-       if (cur.text() == &text_)
+       switch (cmd.action) {
+       case LFUN_PASTE:
+       case LFUN_CLIPBOARD_PASTE:
+       case LFUN_SELECTION_PASTE:
+       case LFUN_PRIMARY_SELECTION_PASTE:
                text_.dispatch(cur, cmd);
-       else
-               cur.undispatched();
+               // If we we can only store plain text, we must reset all
+               // attributes.
+               // FIXME: Change only the pasted paragraphs
+               fixParagraphsFont();
+               break;
+       default:
+               text_.dispatch(cur, cmd);
+       }
        
        if (!cur.result().dispatched())
                Inset::doDispatch(cur, cmd);
@@ -306,6 +315,23 @@ bool InsetText::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
+void InsetText::fixParagraphsFont()
+{
+       Font font(inherit_font, buffer().params().language);
+       if (getLayout().isForceLtr())
+               font.setLanguage(latex_language);
+       if (getLayout().isPassThru()) {
+               ParagraphList::iterator par = paragraphs().begin();
+               ParagraphList::iterator const end = paragraphs().end();
+               while (par != end) {
+                       par->resetFonts(font);
+                       par->params().clear();
+                       ++par;
+               }
+       }
+}
+
+
 void InsetText::setChange(Change const & change)
 {
        ParagraphList::iterator pit = paragraphs().begin();
index d2526a6afac040f3e9f8a673c2dd7a677d99bd89..c0efea092ec8e6d7fbb152cb9ed272c912bdb4ca 100644 (file)
@@ -111,6 +111,9 @@ public:
        ///
        virtual bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
 
+       ///
+       void fixParagraphsFont();
+
        /// set the change for the entire inset
        void setChange(Change const & change);
        /// accept the changes within the inset