]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
avoid float-conversion warning and simplify size computation
[lyx.git] / src / Text3.cpp
index f80bde6554d38c8fe10b5f0c9aaaec32fbec7aa1..8707b76062d8c6569981cf00cc91cccc98cae628 100644 (file)
@@ -72,6 +72,7 @@
 #include "support/gettext.h"
 #include "support/lassert.h"
 #include "support/lstrings.h"
+#include "support/lyxalgo.h"
 #include "support/lyxtime.h"
 #include "support/os.h"
 #include "support/regex.h"
@@ -79,8 +80,6 @@
 #include "mathed/InsetMathHull.h"
 #include "mathed/MathMacroTemplate.h"
 
-#include <boost/next_prior.hpp>
-
 #include <clocale>
 #include <sstream>
 
@@ -266,6 +265,42 @@ static bool doInsertInset(Cursor & cur, Text * text,
                }
                return true;
        }
+       else if (cmd.action() == LFUN_ARGUMENT_INSERT) {
+               bool cotextinsert = false;
+               InsetArgument const * const ia = static_cast<InsetArgument const *>(inset);
+               Layout const & lay = cur.paragraph().layout();
+               Layout::LaTeXArgMap args = lay.args();
+               Layout::LaTeXArgMap::const_iterator const lait = args.find(ia->name());
+               if (lait != args.end())
+                       cotextinsert = (*lait).second.insertcotext;
+               else {
+                       InsetLayout const & il = cur.inset().getLayout();
+                       args = il.args();
+                       Layout::LaTeXArgMap::const_iterator const ilait = args.find(ia->name());
+                       if (ilait != args.end())
+                               cotextinsert = (*ilait).second.insertcotext;
+               }
+               // The argument requests to insert a copy of the co-text to the inset
+               if (cotextinsert) {
+                       docstring ds;
+                       // If we have a selection within a paragraph, use this
+                       if (cur.selection() && cur.selBegin().pit() == cur.selEnd().pit())
+                               ds = cur.selectionAsString(false);
+                       // else use the whole paragraph
+                       else
+                               ds = cur.paragraph().asString();
+                       text->insertInset(cur, inset);
+                       if (edit)
+                               inset->edit(cur, true);
+                       // Now put co-text into inset
+                       Font const f(inherit_font, cur.current_font.language());
+                       if (!ds.empty()) {
+                               cur.text()->insertStringAsLines(cur, ds, f);
+                               cur.leaveInset(*inset);
+                       }
+                       return true;
+               }
+       }
 
        bool gotsel = false;
        if (cur.selection()) {
@@ -341,7 +376,7 @@ static void outline(OutlineOp mode, Cursor & cur)
        ParagraphList & pars = buf.text().paragraphs();
        ParagraphList::iterator const bgn = pars.begin();
        // The first paragraph of the area to be copied:
-       ParagraphList::iterator start = boost::next(bgn, pit);
+       ParagraphList::iterator start = next(bgn, pit);
        // The final paragraph of area to be copied:
        ParagraphList::iterator finish = start;
        ParagraphList::iterator const end = pars.end();
@@ -392,7 +427,7 @@ static void outline(OutlineOp mode, Cursor & cur)
                                // Nothing to move.
                                return;
                        // Go one down from *this* header:
-                       ParagraphList::iterator dest = boost::next(finish, 1);
+                       ParagraphList::iterator dest = next(finish, 1);
                        // Go further down to find header to insert in front of:
                        for (; dest != end; ++dest) {
                                toclevel = buf.text().getTocLevel(distance(bgn, dest));
@@ -770,7 +805,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                ParagraphList & pars = buf.text().paragraphs();
                ParagraphList::iterator bgn = pars.begin();
                // The first paragraph of the area to be selected:
-               ParagraphList::iterator start = boost::next(bgn, pit);
+               ParagraphList::iterator start = next(bgn, pit);
                // The final paragraph of area to be selected:
                ParagraphList::iterator finish = start;
                ParagraphList::iterator end = pars.end();
@@ -1047,8 +1082,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                        needsUpdate |= backspace(cur);
                                        cur.resetAnchor();
                                }
-                               // It is possible to make it a lot faster still
-                               // just comment out the line below...
                        }
                } else {
                        cutSelection(cur, true, false);
@@ -2930,25 +2963,30 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                        break;
                }
 
-               // explicit graphics type?
                Clipboard::GraphicsType type = Clipboard::AnyGraphicsType;
-               if ((arg == "pdf" && (type = Clipboard::PdfGraphicsType))
-                         || (arg == "png" && (type = Clipboard::PngGraphicsType))
-                         || (arg == "jpeg" && (type = Clipboard::JpegGraphicsType))
-                         || (arg == "linkback" &&  (type = Clipboard::LinkBackGraphicsType))
-                         || (arg == "emf" &&  (type = Clipboard::EmfGraphicsType))
-                         || (arg == "wmf" &&  (type = Clipboard::WmfGraphicsType))) {
-                       enable = theClipboard().hasGraphicsContents(type);
+               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 {
+                       // unknown argument
+                       LYXERR0("Unrecognized graphics type: " << arg);
+                       // we don't want to assert if the user just mistyped the LFUN
+                       LATTEST(cmd.origin() != FuncRequest::INTERNAL);
+                       enable = false;
                        break;
                }
-
-               // unknown argument
-               LYXERR0("Unrecognized graphics type: " << arg);
-               // we don't want to assert if the user just mistyped the LFUN
-               LATTEST(cmd.origin() != FuncRequest::INTERNAL);
-               enable = false;
+               enable = theClipboard().hasGraphicsContents(type);
                break;
-        }
+       }
 
        case LFUN_CLIPBOARD_PASTE:
        case LFUN_CLIPBOARD_PASTE_SIMPLE: