]> git.lyx.org Git - features.git/blobdiff - src/insets/InsetText.cpp
Typo
[features.git] / src / insets / InsetText.cpp
index 7bb0c0c8dfd22941dbddd530762d86439a8dfca1..4cecec8cd7ec31019ca85795a67b609ffd5363dd 100644 (file)
@@ -63,6 +63,7 @@
 
 #include "support/convert.h"
 #include "support/debug.h"
+#include "support/filetools.h"
 #include "support/gettext.h"
 #include "support/lassert.h"
 #include "support/lstrings.h"
@@ -72,8 +73,6 @@
 #include <algorithm>
 #include <stack>
 
-#include <QCryptographicHash>
-
 
 using namespace std;
 using namespace lyx::support;
@@ -486,6 +485,7 @@ void InsetText::latex(otexstream & os, OutputParams const & runparams) const
        // environment. Standard collapsible insets should not
        // redefine this, non-standard ones may call this.
        InsetLayout const & il = getLayout();
+
        if (il.forceOwnlines())
                os << breakln;
        bool needendgroup = false;
@@ -665,6 +665,8 @@ void InsetText::docbookRenderAsImage(XMLStream & xs, OutputParams const & rp, XH
        // TODO: no real support for Unicode. This code is very similar to RenderPreview::addPreview, the same gotcha applies.
 
        graphics::PreviewLoader* loader = buffer().loader();
+       // This should be OK because we are exporting
+       LASSERT(loader != nullptr, return);
        loader->add(snippet);
        loader->startLoading(true); // Generate the image and wait until done.
        graphics::PreviewImage const * img = loader->preview(snippet);
@@ -679,17 +681,7 @@ void InsetText::docbookRenderAsImage(XMLStream & xs, OutputParams const & rp, XH
        // same hash (by design of cryptographic hash functions). Computing a hash
        // is typically slow, but extremely fast compared to compilation of the
        // preview and image rendering.
-       QString snippetQ = QString(snippet.c_str());
-#if QT_VERSION >= 0x050000
-       QByteArray hash = QCryptographicHash::hash(snippetQ.toLocal8Bit(), QCryptographicHash::Sha256);
-#else
-       QByteArray hash = QCryptographicHash::hash(snippetQ.toLocal8Bit(), QCryptographicHash::Sha1);
-#endif
-       auto newFileBase = QString(hash.toBase64())
-                       .replace("/", "")
-                       .replace("+", "")
-                       .replace("=", "");
-       std::string newFileName = "lyx_" + newFileBase.toStdString() + "." + filename.extension();
+       std::string newFileName = "lyx_" + sanitizeFileName(toHexHash(snippet)) + "." + filename.extension();
 
        // Copy the image into the right folder.
        rp.exportdata->addExternalFile("docbook5", filename, newFileName);
@@ -1048,6 +1040,10 @@ bool InsetText::insetAllowed(InsetCode code) const
        case QUOTE_CODE:
        case COUNTER_CODE:
                return true;
+       // These are only allowed in index insets
+       case INDEXMACRO_CODE:
+       case INDEXMACRO_SORTKEY_CODE:
+               return false;
        default:
                return !isPassThru();
        }
@@ -1126,7 +1122,7 @@ void InsetText::updateBuffer(ParIterator const & it, UpdateType utype, bool cons
                tclass.counters().current_float(savecnt.current_float());
                tclass.counters().isSubfloat(savecnt.isSubfloat());
                buffer().updateBuffer(it2, utype, deleted);
-               tclass.counters() = move(savecnt);
+               tclass.counters() = std::move(savecnt);
        }
 }
 
@@ -1330,13 +1326,12 @@ docstring InsetText::completionPrefix(Cursor const & cur) const
 }
 
 
-bool InsetText::insertCompletion(Cursor & cur, docstring const & s,
-       bool finished)
+bool InsetText::insertCompletion(Cursor & cur, docstring const & s, bool /*finished*/)
 {
        if (!completionSupported(cur))
                return false;
 
-       return text_.insertCompletion(cur, s, finished);
+       return text_.insertCompletion(cur, s);
 }