Add CryptoPP to drawingfile

This commit is contained in:
Svetlana Kulikova
2025-03-10 15:40:16 +03:00
parent 8791f446b7
commit 7a3815bc5f
4 changed files with 51 additions and 34 deletions

View File

@ -2,7 +2,7 @@
"name": "drawingfile",
"res_folder": "./deploy",
"wasm": true,
"asm": false,
"asm": true,
"embed_mem_file": true,
"run_before": "before.py",
"run_after": "after.py",
@ -29,7 +29,6 @@
"_GetType",
"_Open",
"_Close",
"_AddPDF",
"_GetErrorCode",
"_GetInfo",
"_GetPixmap",
@ -52,6 +51,8 @@
"_IsNeedCMap",
"_SetCMapData",
"_ScanPage",
"_SplitPages",
"_MergePages",
"_GetImageBase64",
"_GetImageBase64Len",
"_GetImageBase64Ptr",
@ -87,7 +88,7 @@
"NO_CONSOLE_IO", "USE_EXTERNAL_JPEG2000", "USE_JPIP", "OPJ_STATIC", "FONT_ENGINE_DISABLE_FILESYSTEM",
"IMAGE_CHECKER_DISABLE_XML",
"USE_OPENSSL_HASH",
"DISABLE_FULL_DOCUMENT_CREATION", "DISABLE_FILESYSTEM"
"DISABLE_FULL_DOCUMENT_CREATION", "DISABLE_FILESYSTEM", "CRYPTOPP_DISABLE_ASM", "DISABLE_TYPE_MISMATCH"
],
"compile_files_array": [
{
@ -144,7 +145,7 @@
},
{
"folder": "../../",
"files": ["GraphicsRenderer.cpp", "pro/pro_Graphics.cpp", "pro/pro_Fonts.cpp", "pro/pro_Image.cpp", "Graphics.cpp", "Brush.cpp", "BaseThread.cpp", "GraphicsPath.cpp", "BooleanOperations.cpp", "Image.cpp", "Matrix.cpp", "Clip.cpp", "TemporaryCS.cpp", "AlphaMask.cpp", "GraphicsLayer.cpp", "commands/DocInfo.cpp", "commands/AnnotField.cpp", "commands/FormField.cpp", "MetafileToRenderer.cpp"]
"files": ["GraphicsRenderer.cpp", "pro/pro_Graphics.cpp", "pro/pro_Fonts.cpp", "pro/pro_Image.cpp", "Graphics.cpp", "Brush.cpp", "BaseThread.cpp", "GraphicsPath.cpp", "BooleanOperations.cpp", "Image.cpp", "Matrix.cpp", "Clip.cpp", "TemporaryCS.cpp", "AlphaMask.cpp", "GraphicsLayer.cpp", "commands/DocInfo.cpp", "commands/AnnotField.cpp", "commands/FormField.cpp", "MetafileToRenderer.cpp", "MetafileToRendererReader.cpp"]
},
{
"folder": "../../../fontengine/",
@ -162,6 +163,10 @@
"folder": "../../../../Common/3dParty/icu/icu/source/common/",
"files": ["ucnv.c", "ustr_wcs.cpp", "ucnv_err.c", "ucnv_bld.cpp", "ustrtrns.cpp", "ucnv_cb.c", "udata.cpp", "ucnv_io.cpp", "uhash.c", "udatamem.c", "cmemory.c", "ustring.cpp", "umutex.cpp", "putil.cpp", "ustr_cnv.cpp", "ucnvmbcs.cpp", "ucnvlat1.c", "ucnv_u16.c", "ucnv_u8.c", "ucnv_u32.c", "ucnv_u7.c", "ucln_cmn.cpp", "ucnv2022.cpp", "ucnv_lmb.c", "ucnvhz.c", "ucnvscsu.c", "ucnvisci.c", "ucnvbocu.cpp", "ucnv_ct.c", "ucnv_cnv.c", "stringpiece.cpp", "charstr.cpp", "umapfile.c", "ucmndata.c", "ucnv_ext.cpp", "uobject.cpp", "umath.c", "ubidi_props.c", "uchar.c", "uinvchar.c", "usprep.cpp", "unistr.cpp", "uniset_props.cpp", "loadednormalizer2impl.cpp", "filterednormalizer2.cpp", "utrie2.cpp", "normalizer2.cpp", "normalizer2impl.cpp", "utrie.cpp", "ucase.cpp", "uniset.cpp", "ruleiter.cpp", "parsepos.cpp", "util.cpp", "uprops.cpp", "uvector.cpp", "unames.cpp", "propname.cpp", "utrie2_builder.cpp", "unifunct.cpp", "bmpset.cpp", "unisetspan.cpp", "unifilt.cpp", "patternprops.cpp", "utf_impl.c", "ustrcase.cpp", "cstring.c", "bytestrie.cpp"]
},
{
"folder": "../../../../Common/3dParty/cryptopp/",
"files": ["cryptlib.cpp", "cpu.cpp", "integer.cpp", "3way.cpp", "adler32.cpp", "algebra.cpp", "algparam.cpp", "allocate.cpp", "arc4.cpp", "aria.cpp", "aria_simd.cpp", "ariatab.cpp", "asn.cpp", "authenc.cpp", "base32.cpp", "base64.cpp", "basecode.cpp", "bfinit.cpp", "blake2.cpp", "blake2s_simd.cpp", "blake2b_simd.cpp", "blowfish.cpp", "blumshub.cpp", "camellia.cpp", "cast.cpp", "casts.cpp", "cbcmac.cpp", "ccm.cpp", "chacha.cpp", "chacha_simd.cpp", "chacha_avx.cpp", "chachapoly.cpp", "cham.cpp", "cham_simd.cpp", "channels.cpp", "cmac.cpp", "crc.cpp", "crc_simd.cpp", "darn.cpp", "default.cpp", "des.cpp", "dessp.cpp", "dh.cpp", "dh2.cpp", "dll.cpp", "donna_32.cpp", "donna_64.cpp", "donna_sse.cpp", "dsa.cpp", "eax.cpp", "ec2n.cpp", "ecp.cpp", "eccrypto.cpp", "eprecomp.cpp", "elgamal.cpp", "emsa2.cpp", "eprecomp.cpp", "esign.cpp", "files.cpp", "filters.cpp", "fips140.cpp", "gcm.cpp", "gcm_simd.cpp", "gf256.cpp", "gf2_32.cpp", "gf2n.cpp", "gf2n_simd.cpp", "gfpcrypt.cpp", "gost.cpp", "gzip.cpp", "hc128.cpp", "hc256.cpp", "hex.cpp", "hight.cpp", "hmac.cpp", "hrtimer.cpp", "ida.cpp", "idea.cpp", "iterhash.cpp", "kalyna.cpp", "md5.cpp", "randpool.cpp", "osrng.cpp", "rijndael.cpp", "modes.cpp", "misc.cpp", "rdtables.cpp", "sha.cpp", "mqueue.cpp", "queue.cpp"]
},
{
"folder": "../../../../OfficeUtils/src/",
"files": ["OfficeUtils.cpp", "ZipBuffer.cpp", "ZipUtilsCP.cpp", "zlib_addon.c"]

View File

@ -145,10 +145,36 @@ CFile.prototype["isNeedPassword"] = function()
{
return this._isNeedPassword;
};
CFile.prototype["addPDF"] = function(arrayBuffer, password)
CFile.prototype["SplitPages"] = function(arrPageIndex)
{
return this._addPDF(arrayBuffer, password);
let ptr = this._SplitPages(arrPageIndex);
if (!ptr)
return null;
let lenArr = new Int32Array(Module["HEAP8"].buffer, ptr, 1);
if (!lenArr)
{
Module["_free"](ptr);
return null;
}
let len = lenArr[0];
if (len <= 4)
{
Module["_free"](ptr);
return null;
}
len -= 4;
let buffer = new Uint8Array(len);
buffer.set(new Uint8Array(Module["HEAP8"].buffer, ptr + 4, len));
Module["_free"](ptr);
return buffer;
};
CFile.prototype["MergePages"] = function(arrayBuffer)
{
return this._MergePages(arrayBuffer);
};
// INFO DOCUMENT

View File

@ -121,31 +121,30 @@ CFile.prototype._getError = function()
return Module["_GetErrorCode"](this.nativeFile);
};
CFile.prototype._addPDF = function(buffer, password)
CFile.prototype._SplitPages = function(memoryBuffer)
{
let pointer = Module["_malloc"](memoryBuffer.length * 4);
Module["HEAP32"].set(memoryBuffer, pointer >> 2);
let ptr = Module["_SplitPages"](this.nativeFile, pointer, memoryBuffer.length);
Module["_free"](pointer);
return ptr;
};
CFile.prototype._MergePages = function(buffer)
{
if (!buffer)
return false;
let data = new Uint8Array(buffer);
let data = (undefined !== buf.byteLength) ? new Uint8Array(buffer) : buffer;
let stream2 = Module["_malloc"](data.length);
Module["HEAP8"].set(data, stream2);
let passwordPtr = 0;
if (password)
{
let passwordBuf = password.toUtf8();
passwordPtr = Module["_malloc"](passwordBuf.length);
Module["HEAP8"].set(passwordBuf, passwordPtr);
}
let bRes = Module["_AddPDF"](this.nativeFile, stream2, data.length, passwordPtr);
let bRes = Module["_MergePages"](this.nativeFile, stream2, data.length);
if (bRes == 1)
this.stream.push(stream2);
else
Module["_free"](stream2);
if (passwordPtr)
Module["_free"](passwordPtr);
return bRes == 1;
};