The branch, trivial, has been updated.

- Log -----------------------------------------------------------------

commit 2969388d1948ef8c4e87b19486185503d0510e02
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Tue Apr 19 21:32:44 2016 +0200

    Factor duplicate code that computes GraphicsType for paste

diff --git a/src/Text3.cpp b/src/Text3.cpp
index 4e0dbc9..2eba1af 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -481,12 +481,32 @@ bool Text::isRTL(Paragraph const & par) const
        return par.isRTL(buffer.params());
 }
 
-       
+
 namespace {
-               
-       Language const * getLanguage(Cursor const & cur, string const & lang) {
-               return lang.empty() ? cur.getFont().language() : 
languages.getLanguage(lang);
-       }
+
+Language const * getLanguage(Cursor const & cur, string const & lang)
+{
+       return lang.empty() ? cur.getFont().language() : 
languages.getLanguage(lang);
+}
+
+
+Clipboard::GraphicsType graphicsType(string const & arg)
+{
+       Clipboard::GraphicsType type = Clipboard::AnyGraphicsType;
+       if (arg == "pdf")
+               type = Clipboard::PdfGraphicsType;
+       else if (arg == "png")
+               type = Clipboard::PngGraphicsType;
+       else if (arg == "jpeg")
+               type = Clipboard::JpegGraphicsType;
+       else if (arg == "linkback")
+               type = Clipboard::LinkBackGraphicsType;
+       else if (arg == "emf")
+               type = Clipboard::EmfGraphicsType;
+       else if (arg == "wmf")
+               type = Clipboard::WmfGraphicsType;
+       return type;
+}
 
 }
 
@@ -1331,23 +1351,11 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                Clipboard::HtmlTextType : 
Clipboard::LaTeXTextType;
                        pasteClipboardText(cur, 
bv->buffer().errorList("Paste"), true, type);
                } else {
-                       Clipboard::GraphicsType type = 
Clipboard::AnyGraphicsType;
-                       if (arg == "pdf")
-                               type = Clipboard::PdfGraphicsType;
-                       else if (arg == "png")
-                               type = Clipboard::PngGraphicsType;
-                       else if (arg == "jpeg")
-                               type = Clipboard::JpegGraphicsType;
-                       else if (arg == "linkback")
-                               type = Clipboard::LinkBackGraphicsType;
-                       else if (arg == "emf")
-                               type = Clipboard::EmfGraphicsType;
-                       else if (arg == "wmf")
-                               type = Clipboard::WmfGraphicsType;
-                       else
-                               // we also check in getStatus()
+                       Clipboard::GraphicsType type = graphicsType(arg);
+                       if (type == Clipboard::AnyGraphicsType) {
+                       // we also check in getStatus()
                                LYXERR0("Unrecognized graphics type: " << arg);
-
+                       }
                        pasteClipboardGraphics(cur, 
bv->buffer().errorList("Paste"), type);
                }
 
@@ -2973,20 +2981,8 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & 
cmd,
                        break;
                }
 
-               Clipboard::GraphicsType type = Clipboard::AnyGraphicsType;
-               if (arg == "pdf")
-                       type = Clipboard::PdfGraphicsType;
-               else if (arg == "png")
-                       type = Clipboard::PngGraphicsType;
-               else if (arg == "jpeg")
-                       type = Clipboard::JpegGraphicsType;
-               else if (arg == "linkback")
-                       type = Clipboard::LinkBackGraphicsType;
-               else if (arg == "emf")
-                       type = Clipboard::EmfGraphicsType;
-               else if (arg == "wmf")
-                       type = Clipboard::WmfGraphicsType;
-               else {
+               Clipboard::GraphicsType type = graphicsType(arg);
+               if (type == Clipboard::AnyGraphicsType) {
                        // unknown argument
                        LYXERR0("Unrecognized graphics type: " << arg);
                        // we don't want to assert if the user just mistyped 
the LFUN

-----------------------------------------------------------------------

Summary of changes:
 src/Text3.cpp |   66 ++++++++++++++++++++++++++------------------------------
 1 files changed, 31 insertions(+), 35 deletions(-)


hooks/post-receive
-- 
Repository for new features

Reply via email to