[LyX/master] DocBook: use the new refactorings in InsetText.

Thibaut Cuvelier tcuvelier at lyx.org
Tue Oct 19 06:52:24 UTC 2021


commit 279e0a68393cca17c6d23a7f90eb6954d8ca7286
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Tue Oct 19 02:31:36 2021 +0200

    DocBook: use the new refactorings in InsetText.
    
    InsetText::docbookRenderAsImage directly used Qt to compute hashes, use the same code as support/FileName (now living in support/filetools).
---
 src/insets/InsetText.cpp |   15 ++-------------
 1 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index 7bb0c0c..626818c 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -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;
@@ -679,17 +678,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);


More information about the lyx-cvs mailing list