#include "support/convert.h"
#include "support/debug.h"
+#include "support/filetools.h"
#include "support/gettext.h"
#include "support/lassert.h"
#include "support/lstrings.h"
#include <algorithm>
#include <stack>
-#include <QCryptographicHash>
-
using namespace std;
using namespace lyx::support;
// 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;
// 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);
// 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);
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();
}
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);
}
}
}
-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);
}