From 8f05f21b1642cb3d2355b06b9dd8a3aec8ff7ebe Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月11日 14:11:42 +0100 Subject: [PATCH 01/20] Add OpenSSL 3.x compatibility to common_openssl --- .../3dParty/openssl/common/common_openssl.cpp | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Common/3dParty/openssl/common/common_openssl.cpp b/Common/3dParty/openssl/common/common_openssl.cpp index 5b733819279..40287fbc058 100644 --- a/Common/3dParty/openssl/common/common_openssl.cpp +++ b/Common/3dParty/openssl/common/common_openssl.cpp @@ -31,6 +31,7 @@ */ #include "./common_openssl.h" +#include #include #include #include @@ -138,18 +139,24 @@ namespace NSOpenSSL publicKey = NULL; privateKey = NULL; - RSA* rsa = RSA_new(); - BIGNUM *exponent = BN_new(); + EVP_PKEY* pkey = NULL; + EVP_PKEY_CTX* pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, NULL); + if (!pctx) + return false; - BN_set_word(exponent, RSA_F4); - int result = RSA_generate_multi_prime_key(rsa, 2048, 2, exponent, NULL); - if (0 == result) + if (EVP_PKEY_keygen_init(pctx) <= 0 || + EVP_PKEY_CTX_set_rsa_keygen_bits(pctx, 2048) <= 0 || + EVP_PKEY_keygen(pctx, &pkey) <= 0) + { + EVP_PKEY_CTX_free(pctx); return false; + } + EVP_PKEY_CTX_free(pctx); if (true) { BIO* bio = BIO_new(BIO_s_mem()); - if (PEM_write_bio_RSAPrivateKey(bio, rsa, NULL, NULL, 0, NULL, NULL)) + if (PEM_write_bio_PrivateKey(bio, pkey, NULL, NULL, 0, NULL, NULL)) { int key_length = BIO_pending(bio); privateKey = openssl_alloc(key_length + 1); @@ -168,7 +175,7 @@ namespace NSOpenSSL if (true) { BIO* bio = BIO_new(BIO_s_mem()); - if (PEM_write_bio_RSA_PUBKEY(bio, rsa)) + if (PEM_write_bio_PUBKEY(bio, pkey)) { int key_length = BIO_pending(bio); publicKey = openssl_alloc(key_length + 1); @@ -185,8 +192,7 @@ namespace NSOpenSSL BIO_free_all(bio); } - BN_free(exponent); - RSA_free(rsa); + EVP_PKEY_free(pkey); return (NULL != publicKey && NULL != privateKey) ? true : false; } @@ -551,7 +557,6 @@ namespace NSOpenSSL bool AES_Encrypt(int type, const unsigned char* key, const unsigned char* iv, const unsigned char* data, const unsigned int& size, unsigned char*& data_crypt, unsigned int& data_crypt_len) { EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new(); - EVP_CIPHER_CTX_init(ctx); EVP_EncryptInit_ex(ctx, _get_cipher_aes(type), NULL, key, iv); EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, 16, NULL); int out_len1 = (int)size + AES_BLOCK_SIZE; @@ -561,13 +566,11 @@ namespace NSOpenSSL EVP_EncryptFinal_ex(ctx, data_crypt + out_len1, &out_len2); data_crypt_len = out_len1 + out_len2; EVP_CIPHER_CTX_free(ctx); - EVP_cleanup(); return true; } bool AES_Decrypt(int type, const unsigned char* key, const unsigned char* iv, const unsigned char* data, const unsigned int& size, unsigned char*& data_decrypt, unsigned int& data_decrypt_len) { EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new(); - EVP_CIPHER_CTX_init(ctx); EVP_DecryptInit_ex(ctx, _get_cipher_aes(type), NULL, key, iv); EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, 16, NULL); int out_len1 = (int)size; @@ -577,7 +580,6 @@ namespace NSOpenSSL EVP_DecryptFinal_ex(ctx, data_decrypt + out_len1, &out_len2); data_decrypt_len = out_len1 + out_len2; EVP_CIPHER_CTX_free(ctx); - EVP_cleanup(); return true; } From 336e87b9a1ec4c46f5ec04668e36c9bbea7fb4a9 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月11日 14:41:17 +0100 Subject: [PATCH 02/20] Add OpenSSL 3.x compatibility to Certificate_openssl --- .../xmlsec/src/src/Certificate_openssl.h | 53 +++++++++++++------ 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/DesktopEditor/xmlsec/src/src/Certificate_openssl.h b/DesktopEditor/xmlsec/src/src/Certificate_openssl.h index 11c09e5bf58..f2bd62874f4 100644 --- a/DesktopEditor/xmlsec/src/src/Certificate_openssl.h +++ b/DesktopEditor/xmlsec/src/src/Certificate_openssl.h @@ -11,6 +11,7 @@ #include #endif +#include #include #include #include @@ -21,10 +22,15 @@ #include #include #include -#include #include #include #include +#if OPENSSL_VERSION_MAJOR>= 3 +#include +#include +#else +#include +#endif #include
    #include @@ -126,9 +132,11 @@ class CCertificate_openssl : public ICertificate if (!g_is_initialize) { g_is_initialize = true; +#if OPENSSL_VERSION_MAJOR < 3 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); OPENSSL_config(NULL); +#endif } m_cert = NULL; @@ -146,9 +154,11 @@ class CCertificate_openssl : public ICertificate if (g_is_initialize) { g_is_initialize = false; +#if OPENSSL_VERSION_MAJOR < 3 EVP_cleanup(); CRYPTO_cleanup_all_ex_data(); ERR_free_strings(); +#endif } } @@ -188,6 +198,17 @@ class CCertificate_openssl : public ICertificate m_alg = OOXML_HASH_ALG_ECDSA_512; } +#if OPENSSL_VERSION_MAJOR>= 3 + pctx = EVP_PKEY_CTX_new_from_name(NULL, "EC", NULL); + if (!pctx) + return false; + EVP_PKEY_keygen_init(pctx); + OSSL_PARAM params[2]; + const char* group_name = OBJ_nid2sn(crypto_nid); + params[0] = OSSL_PARAM_construct_utf8_string("group", (char*)group_name, 0); + params[1] = OSSL_PARAM_construct_end(); + EVP_PKEY_CTX_set_params(pctx, params); +#else EC_GROUP* group = EC_GROUP_new_by_curve_name(crypto_nid); EC_GROUP_set_asn1_flag(group, OPENSSL_EC_NAMED_CURVE); @@ -204,6 +225,7 @@ class CCertificate_openssl : public ICertificate EVP_PKEY_free(tmp); EC_GROUP_free(group); +#endif } else if (0 == key_alg.find("rsa")) { @@ -380,10 +402,10 @@ class CCertificate_openssl : public ICertificate return ""; } - if (asn1_serial->type == V_ASN1_NEG_INTEGER) + if (BN_is_negative(bn)) { std::string sPositive = "1"; - for (int i = 0; i < asn1_serial->length; ++i) + for (int i = 0; i < ASN1_STRING_length(asn1_serial); ++i) sPositive += "00"; BIGNUM* pn = NULL; int res = BN_hex2bn(&pn, sPositive.c_str()); @@ -564,18 +586,18 @@ class CCertificate_openssl : public ICertificate return true; } - EVP_MD_CTX* pCtx = EVP_MD_CTX_create(); + EVP_MD_CTX* pCtx = EVP_MD_CTX_new(); const EVP_MD* pDigest = Get_EVP_MD(nHashAlg); - int nError = EVP_SignInit(pCtx, pDigest); - nError = EVP_SignUpdate(pCtx, pData, nSize); + int nError = EVP_DigestSignInit(pCtx, NULL, pDigest, NULL, m_key); + nError = EVP_DigestSignUpdate(pCtx, pData, nSize); BYTE pSignature[4096]; - unsigned int nSignatureLen = 0; + size_t nSignatureLen = sizeof(pSignature); - nError = EVP_SignFinal(pCtx, pSignature, &nSignatureLen, m_key); + nError = EVP_DigestSignFinal(pCtx, pSignature, &nSignatureLen); - EVP_MD_CTX_destroy(pCtx); + EVP_MD_CTX_free(pCtx); if (nSignatureLen> 0) { @@ -830,22 +852,21 @@ class CCertificate_openssl : public ICertificate return (1 == nVer) ? true : false; } - EVP_MD_CTX* pCtx = EVP_MD_CTX_create(); + EVP_MD_CTX* pCtx = EVP_MD_CTX_new(); const EVP_MD* pDigest = Get_EVP_MD(nAlg); - int n1 = EVP_VerifyInit(pCtx, pDigest); + EVP_PKEY* pubkey = X509_get_pubkey(m_cert); BYTE* pDigestValue = NULL; int nDigestLen = 0; NSFile::CBase64Converter::Decode(sXmlSignature.c_str(), (int)sXmlSignature.length(), pDigestValue, nDigestLen); - int n2 = EVP_VerifyUpdate(pCtx, (BYTE*)sXml.c_str(), (size_t)sXml.length()); - - EVP_PKEY* pubkey = X509_get_pubkey(m_cert); + EVP_DigestVerifyInit(pCtx, NULL, pDigest, NULL, pubkey); + EVP_DigestVerifyUpdate(pCtx, (BYTE*)sXml.c_str(), (size_t)sXml.length()); - int n3 = EVP_VerifyFinal(pCtx, pDigestValue, (unsigned int)nDigestLen, pubkey); + int n3 = EVP_DigestVerifyFinal(pCtx, pDigestValue, (size_t)nDigestLen); - EVP_MD_CTX_destroy(pCtx); + EVP_MD_CTX_free(pCtx); EVP_PKEY_FREE(pubkey); RELEASEARRAYOBJECTS(pDigestValue); From 8cd2325c40461b742d5c9b7b554182adf9329296 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月11日 14:42:21 +0100 Subject: [PATCH 03/20] Add OpenSSL 3.x compatibility to osign certificate --- .../xmlsec/src/osign/lib/src/certificate.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/DesktopEditor/xmlsec/src/osign/lib/src/certificate.cpp b/DesktopEditor/xmlsec/src/osign/lib/src/certificate.cpp index 8813a1da534..c6db51e1c68 100644 --- a/DesktopEditor/xmlsec/src/osign/lib/src/certificate.cpp +++ b/DesktopEditor/xmlsec/src/osign/lib/src/certificate.cpp @@ -2,6 +2,7 @@ #include "./utils.h" #include "../../../../../../Common/3dParty/openssl/common/common_openssl.h" +#include #include #include #include @@ -12,9 +13,11 @@ #include #include #include -#include #include #include +#if OPENSSL_VERSION_MAJOR < 3 +#include +#endif #include #include @@ -39,12 +42,13 @@ namespace OSign tm ASN1_GetTimeT(ASN1_TIME* time) { struct tm t; - const char* str = (const char*) time->data; + const char* str = (const char*)ASN1_STRING_get0_data(time); size_t i = 0; + int tag = ASN1_STRING_type(time); memset(&t, 0, sizeof(t)); - if (time->type == V_ASN1_UTCTIME) + if (tag == V_ASN1_UTCTIME) { /* two digit year */ t.tm_year = (str[i++] - '0') * 10; @@ -52,7 +56,7 @@ namespace OSign if (t.tm_year < 70) t.tm_year += 100; } - else if (time->type == V_ASN1_GENERALIZEDTIME) + else if (tag == V_ASN1_GENERALIZEDTIME) { /* four digit year */ t.tm_year = (str[i++] - '0') * 1000; @@ -104,8 +108,10 @@ namespace OSign if (!g_is_initialize) { g_is_initialize = true; +#if OPENSSL_VERSION_MAJOR < 3 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); +#endif } } @@ -285,7 +291,7 @@ namespace OSign X509_EXTENSION* ext = X509_get_ext(m_internal->m_cert, subjectAltNameLoc); ASN1_OCTET_STRING* oData = X509_EXTENSION_get_data(ext); - std::string sDataString = std::string((char*)oData->data, oData->length); + std::string sDataString = std::string((const char*)ASN1_STRING_get0_data(oData), ASN1_STRING_length(oData)); std::string::size_type posStart = 0; std::string::size_type posEnd = sDataString.find(';'); From fc31de6a0d2fb2278259cbf7238a41f4adac4659 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月11日 14:47:56 +0100 Subject: [PATCH 04/20] Add OpenSSL 3.x compatibility to doctrenderer hash --- DesktopEditor/doctrenderer/hash.cpp | 296 +++++++++++----------------- 1 file changed, 116 insertions(+), 180 deletions(-) diff --git a/DesktopEditor/doctrenderer/hash.cpp b/DesktopEditor/doctrenderer/hash.cpp index c7ea04d8123..36a29dd0f6a 100644 --- a/DesktopEditor/doctrenderer/hash.cpp +++ b/DesktopEditor/doctrenderer/hash.cpp @@ -4,17 +4,59 @@ #include "../common/Base64.h" #endif -#include "openssl/sha.h" -#include "openssl/md2.h" -#include "openssl/md4.h" -#include "openssl/md5.h" -#include "openssl/whrlpool.h" -#include "openssl/ripemd.h" +#include +#include + +#if OPENSSL_VERSION_MAJOR < 3 +#include +#include +#include +#include +#include +#ifndef OPENSSL_NO_MD2 +#include +#endif +#endif #include #include #include +/* + * OpenSSL 3.x deprecates the low-level one-shot hash functions (MD4(), MD5(), + * SHA1(), RIPEMD160(), WHIRLPOOL()) and removes MD2 entirely. Use EVP_Digest() + * as the single entry point for all algorithms. On OpenSSL 1.x the legacy + * one-shot functions are still available and used directly. + */ +#if OPENSSL_VERSION_MAJOR>= 3 +static const EVP_MD* hash_alg_to_evp_md(int alg) +{ + switch (alg) + { + case CHash::haMD4: return EVP_md4(); + case CHash::haMD5: return EVP_md5(); + case CHash::haRMD160: return EVP_ripemd160(); + case CHash::haSHA1: return EVP_sha1(); + case CHash::haSHA256: return EVP_sha256(); + case CHash::haSHA384: return EVP_sha384(); + case CHash::haSHA512: return EVP_sha512(); + /* MD2 and WHIRLPOOL are not available in the default OpenSSL 3.x provider. + * haMD2 falls through to default and returns NULL. */ + default: return NULL; + } +} + +static bool evp_digest(const unsigned char* data, size_t len, + unsigned char* out, int alg) +{ + const EVP_MD* md = hash_alg_to_evp_md(alg); + if (!md) + return false; + unsigned int md_len = 0; + return EVP_Digest(data, len, out, &md_len, md, NULL) == 1; +} +#endif + int CHash::getDigestLength(HashAlgs alg) { static const int aDigestLengths[] = { 16, 16, 16, 20, 20, 32, 48, 64, 64 }; @@ -35,74 +77,35 @@ unsigned char* CHash::hash(const unsigned char* data, int size, int alg) unsigned char* pBufData = NULL; size_t d = (size_t)size; - switch (alg) - { - case haMD2: - { - nBufLen = 16; - pBufData = (unsigned char*)m_fAllocator(nBufLen); - MD2(data, d, pBufData); - break; - } - case haMD4: - { - nBufLen = 16; - pBufData = (unsigned char*)m_fAllocator(nBufLen); - MD4(data, d, pBufData); - break; - } - case haMD5: - { - nBufLen = 16; - pBufData = (unsigned char*)m_fAllocator(nBufLen); - MD5(data, d, pBufData); - break; - } - case haRMD160: - { - nBufLen = 20; - pBufData = (unsigned char*)m_fAllocator(nBufLen); - RIPEMD160(data, d, pBufData); - break; - } - case haSHA1: - { - nBufLen = 20; - pBufData = (unsigned char*)m_fAllocator(nBufLen); - SHA1(data, d, pBufData); - break; - } - case haSHA256: - { - nBufLen = 32; - pBufData = (unsigned char*)m_fAllocator(nBufLen); - SHA256(data, d, pBufData); - break; - } - case haSHA384: - { - nBufLen = 48; - pBufData = (unsigned char*)m_fAllocator(nBufLen); - SHA384(data, d, pBufData); - break; - } - case haSHA512: + nBufLen = getDigestLength((HashAlgs)alg); + if (0 == nBufLen) + return NULL; + + pBufData = (unsigned char*)m_fAllocator(nBufLen); + +#if OPENSSL_VERSION_MAJOR>= 3 + if (!evp_digest(data, d, pBufData, alg)) { - nBufLen = 64; - pBufData = (unsigned char*)m_fAllocator(nBufLen); - SHA512(data, d, pBufData); - break; + /* Algorithm not available (e.g. MD2 on OpenSSL 3.x). */ + return NULL; } - case haWHIRLPOOL: +#else + switch (alg) { - nBufLen = 64; - pBufData = (unsigned char*)m_fAllocator(nBufLen); - WHIRLPOOL(data, d, pBufData); - break; - } - default: - break; +#ifndef OPENSSL_NO_MD2 + case haMD2: MD2(data, d, pBufData); break; +#endif + case haMD4: MD4(data, d, pBufData); break; + case haMD5: MD5(data, d, pBufData); break; + case haRMD160: RIPEMD160(data, d, pBufData); break; + case haSHA1: SHA1(data, d, pBufData); break; + case haSHA256: SHA256(data, d, pBufData); break; + case haSHA384: SHA384(data, d, pBufData); break; + case haSHA512: SHA512(data, d, pBufData); break; + case haWHIRLPOOL: WHIRLPOOL(data, d, pBufData); break; + default: return NULL; } +#endif return pBufData; } @@ -244,56 +247,25 @@ void hash_iteration(unsigned char*& input, int iter, unsigned char*& tmp, int al input[alg_size + 2] = 0xFF & (iter>> 16); input[alg_size + 3] = 0xFF & (iter>> 24); +#if OPENSSL_VERSION_MAJOR>= 3 + evp_digest(input, alg_size + 4, tmp, alg); +#else switch (alg) { - case CHash::haMD2: - { - MD2(input, alg_size + 4, tmp); - break; - } - case CHash::haMD4: - { - MD4(input, alg_size + 4, tmp); - break; - } - case CHash::haMD5: - { - MD5(input, alg_size + 4, tmp); - break; - } - case CHash::haRMD160: - { - RIPEMD160(input, alg_size + 4, tmp); - break; - } - case CHash::haSHA1: - { - SHA1(input, alg_size + 4, tmp); - break; - } - case CHash::haSHA256: - { - SHA256(input, alg_size + 4, tmp); - break; - } - case CHash::haSHA384: - { - SHA384(input, alg_size + 4, tmp); - break; - } - case CHash::haSHA512: - { - SHA512(input, alg_size + 4, tmp); - break; - } - case CHash::haWHIRLPOOL: - { - WHIRLPOOL(input, alg_size + 4, tmp); - break; - } - default: - break; +#ifndef OPENSSL_NO_MD2 + case CHash::haMD2: MD2(input, alg_size + 4, tmp); break; +#endif + case CHash::haMD4: MD4(input, alg_size + 4, tmp); break; + case CHash::haMD5: MD5(input, alg_size + 4, tmp); break; + case CHash::haRMD160: RIPEMD160(input, alg_size + 4, tmp); break; + case CHash::haSHA1: SHA1(input, alg_size + 4, tmp); break; + case CHash::haSHA256: SHA256(input, alg_size + 4, tmp); break; + case CHash::haSHA384: SHA384(input, alg_size + 4, tmp); break; + case CHash::haSHA512: SHA512(input, alg_size + 4, tmp); break; + case CHash::haWHIRLPOOL: WHIRLPOOL(input, alg_size + 4, tmp); break; + default: break; } +#endif unsigned char* mem = input; input = tmp; @@ -315,76 +287,40 @@ unsigned char* CHash::hash2(const char* password, const char* salt, int spinCoun free(passwordUtf16); - size_t alg_size = 0; - unsigned char* pBuffer1 = NULL; - switch (alg) + size_t alg_size = getDigestLength((HashAlgs)alg); + if (0 == alg_size) { - case haMD2: - { - alg_size = 16; - pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4); - MD2(inputData, inputDataLen, pBuffer1); - break; - } - case haMD4: - { - alg_size = 16; - pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4); - MD4(inputData, inputDataLen, pBuffer1); - break; - } - case haMD5: - { - alg_size = 16; - pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4); - MD5(inputData, inputDataLen, pBuffer1); - break; + free(inputData); + return NULL; } - case haRMD160: - { - alg_size = 20; - pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4); - RIPEMD160(inputData, inputDataLen, pBuffer1); - break; - } - case haSHA1: - { - alg_size = 20; - pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4); - SHA1(inputData, inputDataLen, pBuffer1); - break; - } - case haSHA256: - { - alg_size = 32; - pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4); - SHA256(inputData, inputDataLen, pBuffer1); - break; - } - case haSHA384: - { - alg_size = 48; - pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4); - SHA384(inputData, inputDataLen, pBuffer1); - break; - } - case haSHA512: + + unsigned char* pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4); + +#if OPENSSL_VERSION_MAJOR>= 3 + if (!evp_digest(inputData, inputDataLen, pBuffer1, alg)) { - alg_size = 64; - pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4); - SHA512(inputData, inputDataLen, pBuffer1); - break; + free(inputData); + return NULL; } - case haWHIRLPOOL: +#else + switch (alg) { - alg_size = 64; - pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4); - WHIRLPOOL(inputData, inputDataLen, pBuffer1); - break; - } +#ifndef OPENSSL_NO_MD2 + case haMD2: MD2(inputData, inputDataLen, pBuffer1); break; +#endif + case haMD4: MD4(inputData, inputDataLen, pBuffer1); break; + case haMD5: MD5(inputData, inputDataLen, pBuffer1); break; + case haRMD160: RIPEMD160(inputData, inputDataLen, pBuffer1); break; + case haSHA1: SHA1(inputData, inputDataLen, pBuffer1); break; + case haSHA256: SHA256(inputData, inputDataLen, pBuffer1); break; + case haSHA384: SHA384(inputData, inputDataLen, pBuffer1); break; + case haSHA512: SHA512(inputData, inputDataLen, pBuffer1); break; + case haWHIRLPOOL: WHIRLPOOL(inputData, inputDataLen, pBuffer1); break; default: - break; + free(inputData); + return NULL; } +#endif free(inputData); From 603127d11b62f97ec0acdc8ee7ca6d12be28067d Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月11日 14:57:03 +0100 Subject: [PATCH 05/20] Handle unsupported hash algorithms in HashEmbed --- DesktopEditor/doctrenderer/embed/HashEmbed.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/DesktopEditor/doctrenderer/embed/HashEmbed.cpp b/DesktopEditor/doctrenderer/embed/HashEmbed.cpp index e298240018c..a839da4100d 100644 --- a/DesktopEditor/doctrenderer/embed/HashEmbed.cpp +++ b/DesktopEditor/doctrenderer/embed/HashEmbed.cpp @@ -6,6 +6,8 @@ JSSmart CHashEmbed::hash(JSSmart data, JSSmart siz int _size = size->toInt32(); int _alg = alg->toInt32(); unsigned char* pData = m_pHash->hash(reinterpret_cast(_data.c_str()), _size, _alg); + if (!pData) + return CJSContext::createNull(); return CJSContext::createUint8Array(pData, CHash::getDigestLength(static_cast(_alg)), false); } @@ -16,5 +18,7 @@ JSSmart CHashEmbed::hash2(JSSmart password, JSSmarttoInt32(); int _alg = alg->toInt32(); unsigned char* pData = m_pHash->hash2(reinterpret_cast(_password.c_str()), reinterpret_cast(_salt.c_str()), _spinCount, _alg); + if (!pData) + return CJSContext::createNull(); return CJSContext::createUint8Array(pData, CHash::getDigestLength(static_cast(_alg)), false); } From a4b236dd38526070c4eb0e54874d8b4de1c45187 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月11日 15:09:46 +0100 Subject: [PATCH 06/20] Allow using system OpenSSL via CONFIG+=use_system_openssl --- Common/3dParty/openssl/openssl.pri | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Common/3dParty/openssl/openssl.pri b/Common/3dParty/openssl/openssl.pri index cb565d46210..b19a2bfc80d 100644 --- a/Common/3dParty/openssl/openssl.pri +++ b/Common/3dParty/openssl/openssl.pri @@ -28,12 +28,15 @@ core_ios { } -core_windows { - LIBS += $$OPENSSL_LIBS_DIRECTORY/libssl.lib - LIBS += $$OPENSSL_LIBS_DIRECTORY/libcrypto.lib +use_system_openssl { + LIBS += -lssl -lcrypto } else { - LIBS += $$OPENSSL_LIBS_DIRECTORY/libssl.a - LIBS += $$OPENSSL_LIBS_DIRECTORY/libcrypto.a + core_windows { + LIBS += $$OPENSSL_LIBS_DIRECTORY/libssl.lib + LIBS += $$OPENSSL_LIBS_DIRECTORY/libcrypto.lib + } else { + LIBS += $$OPENSSL_LIBS_DIRECTORY/libssl.a + LIBS += $$OPENSSL_LIBS_DIRECTORY/libcrypto.a + } + INCLUDEPATH += $$OPENSSL_LIBS_DIRECTORY/../include } - -INCLUDEPATH += $$OPENSSL_LIBS_DIRECTORY/../include From ea3c718b79de0e5f0735de2df6aeb7fdfee64a54 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月12日 09:00:28 +0100 Subject: [PATCH 07/20] Remove redundant vendored zlib.h include from ioapibuf.h ioapibuf.h already gets all needed zlib types (uLong, voidpf, zlib_filefunc_def, OF macro) through ioapi.h which includes zlib.h. The relative ../../zlib.h include was a duplicate and creates an unnecessary hard dependency on the vendored zlib directory layout. --- OfficeUtils/src/zlib-1.2.11/contrib/minizip/ioapibuf.h | 1 - 1 file changed, 1 deletion(-) diff --git a/OfficeUtils/src/zlib-1.2.11/contrib/minizip/ioapibuf.h b/OfficeUtils/src/zlib-1.2.11/contrib/minizip/ioapibuf.h index aadaee5c4b9..bef7e82dd9c 100644 --- a/OfficeUtils/src/zlib-1.2.11/contrib/minizip/ioapibuf.h +++ b/OfficeUtils/src/zlib-1.2.11/contrib/minizip/ioapibuf.h @@ -1,6 +1,5 @@ #include -#include "../../zlib.h" #include "ioapi.h" #ifdef __cplusplus From 8c11d67622551c30e4afde5060991fa63cce5f0c Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月12日 09:06:29 +0100 Subject: [PATCH 08/20] Allow using system zlib via CONFIG+=use_system_zlib When use_system_zlib is set, link against system -lz and force-include zlib_addon.h so the patched vendored minizip sources still see the addon flags. The vendored minizip is kept as it has OnlyOffice-specific patches (ioapibuf, disabled CRC check, read-only open mode flag). --- OfficeUtils/OfficeUtils.pri | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/OfficeUtils/OfficeUtils.pri b/OfficeUtils/OfficeUtils.pri index b4e1f497a84..ca74932e673 100644 --- a/OfficeUtils/OfficeUtils.pri +++ b/OfficeUtils/OfficeUtils.pri @@ -12,9 +12,19 @@ build_zlib_as_sources { INCLUDEPATH += \ $$PWD/src/zlib-1.2.11/contrib/minizip \ - $$PWD/src/zlib-1.2.11 \ $$PWD/src +use_system_zlib { + # Force-include zlib_addon.h so vendored minizip sources (unzip.c, + # iowin32.c) see the addon flags that the vendored zlib.h normally + # pulls in. + QMAKE_CFLAGS += -include $$PWD/src/zlib_addon.h + QMAKE_CXXFLAGS += -include $$PWD/src/zlib_addon.h + LIBS += -lz +} else { + INCLUDEPATH += $$PWD/src/zlib-1.2.11 +} + SOURCES += \ $$PWD/src/OfficeUtils.cpp \ $$PWD/src/ZipBuffer.cpp \ @@ -31,7 +41,7 @@ core_windows { SOURCES += \ $$PWD/src/zlib-1.2.11/contrib/minizip/iowin32.c } -build_all_zlib { +!use_system_zlib:build_all_zlib { SOURCES += \ $$PWD/src/zlib-1.2.11/adler32.c \ $$PWD/src/zlib-1.2.11/compress.c \ From 5a8f8ab71416d63b49d4a1dfdcc2476fe3147417 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月12日 10:38:01 +0100 Subject: [PATCH 09/20] Allow using system Crypto++ via CONFIG+=use_system_cryptopp Create centralized cryptopp.pri with use_system_cryptopp flag, replacing ad-hoc CRYPTOPP_DISABLE_ASM defines and -lCryptoPPLib links scattered across 7 consumer .pro files. Change all #include paths from relative vendored paths to portable form, which works for both vendored (via INCLUDEPATH pointing to Common/3dParty/) and system (/usr/include/cryptopp/) headers. CRYPTOPP_DISABLE_ASM is only defined for vendored builds to avoid ODR violations when linking against a system library built with ASM enabled. --- Common/3dParty/cryptopp/cryptopp.pri | 7 ++++ Common/base.pri | 1 - .../graphics/pro/js/qt/nativegraphics.pro | 3 +- HwpFile/HWPFile.pro | 5 ++- HwpFile/HwpDoc/HWPFile.cpp | 6 ++-- OdfFile/Writer/Format/object_package.cpp | 2 +- OfficeCryptReader/Test/test.pro | 5 ++- OfficeCryptReader/ooxml_crypt/ooxml_crypt.pro | 5 ++- OfficeCryptReader/source/CryptTransform.cpp | 32 +++++++++---------- PdfFile/PdfFile.pro | 5 ++- PdfFile/SrcWriter/Encrypt.cpp | 14 ++++---- PdfFile/SrcWriter/EncryptDictionary.cpp | 2 +- .../PptxTxtConverterTest.pro | 2 +- .../test/TestOOOXml2Odf/TestOOOXml2Odf.pro | 2 +- 14 files changed, 46 insertions(+), 45 deletions(-) create mode 100644 Common/3dParty/cryptopp/cryptopp.pri diff --git a/Common/3dParty/cryptopp/cryptopp.pri b/Common/3dParty/cryptopp/cryptopp.pri new file mode 100644 index 00000000000..9b8717a3e8a --- /dev/null +++ b/Common/3dParty/cryptopp/cryptopp.pri @@ -0,0 +1,7 @@ +use_system_cryptopp { + LIBS += -lcryptopp +} else { + DEFINES += CRYPTOPP_DISABLE_ASM + INCLUDEPATH += $$PWD/.. + LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib +} diff --git a/Common/base.pri b/Common/base.pri index 7d212c49ff5..7057a141632 100644 --- a/Common/base.pri +++ b/Common/base.pri @@ -630,7 +630,6 @@ core_windows { QMAKE_CXXFLAGS += -Wall -Wno-ignored-qualifiers } -DEFINES += CRYPTOPP_DISABLE_ASM } core_ios|core_mac { diff --git a/DesktopEditor/graphics/pro/js/qt/nativegraphics.pro b/DesktopEditor/graphics/pro/js/qt/nativegraphics.pro index 0ea0d05a09f..c73010aaa72 100644 --- a/DesktopEditor/graphics/pro/js/qt/nativegraphics.pro +++ b/DesktopEditor/graphics/pro/js/qt/nativegraphics.pro @@ -668,8 +668,7 @@ HEADERS +=\ $$PDF_ROOT_DIR/SrcReader/PdfFont.h \ $$PDF_ROOT_DIR/SrcReader/PdfAnnot.h -DEFINES += CRYPTOPP_DISABLE_ASM -LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib +include($$CORE_ROOT_DIR/Common/3dParty/cryptopp/cryptopp.pri) # PdfWriter HEADERS += \ diff --git a/HwpFile/HWPFile.pro b/HwpFile/HWPFile.pro index 09a8f553d5a..84462720902 100644 --- a/HwpFile/HWPFile.pro +++ b/HwpFile/HWPFile.pro @@ -12,12 +12,11 @@ PWD_ROOT_DIR = $$PWD include($$CORE_ROOT_DIR/Common/base.pri) -LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib +include($$CORE_ROOT_DIR/Common/3dParty/cryptopp/cryptopp.pri) ADD_DEPENDENCY(kernel, UnicodeConverter, graphics, StarMathConverter) -DEFINES += HWPFILE_USE_DYNAMIC_LIBRARY \ - CRYPTOPP_DISABLE_ASM +DEFINES += HWPFILE_USE_DYNAMIC_LIBRARY SOURCES += \ diff --git a/HwpFile/HwpDoc/HWPFile.cpp b/HwpFile/HwpDoc/HWPFile.cpp index 65fd1e7d4fa..1697e160f55 100644 --- a/HwpFile/HwpDoc/HWPFile.cpp +++ b/HwpFile/HwpDoc/HWPFile.cpp @@ -5,9 +5,9 @@ #include "../DesktopEditor/common/Directory.h" // For decrypt -#include "../../Common/3dParty/cryptopp/modes.h" -#include "../../Common/3dParty/cryptopp/aes.h" -#include "../../Common/3dParty/cryptopp/filters.h" +#include +#include +#include // ---------- #define DEFAULT_BUFFER_SIZE 8096 diff --git a/OdfFile/Writer/Format/object_package.cpp b/OdfFile/Writer/Format/object_package.cpp index 73d60d4f0c4..5dbd4c5298d 100644 --- a/OdfFile/Writer/Format/object_package.cpp +++ b/OdfFile/Writer/Format/object_package.cpp @@ -41,7 +41,7 @@ #include "../../../DesktopEditor/common/SystemUtils.h" #include "../../../OOXML/SystemUtility/SystemUtility.h" -#include "../../../Common/3dParty/cryptopp/osrng.h" +#include namespace cpdoccore { diff --git a/OfficeCryptReader/Test/test.pro b/OfficeCryptReader/Test/test.pro index 7a12ed84d10..3440c683c0a 100644 --- a/OfficeCryptReader/Test/test.pro +++ b/OfficeCryptReader/Test/test.pro @@ -10,15 +10,14 @@ PWD_ROOT_DIR = $$PWD include($$CORE_ROOT_DIR/Common/base.pri) include($$CORE_ROOT_DIR/Common/3dParty/boost/boost.pri) -LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib -lCompoundFileLib +include($$CORE_ROOT_DIR/Common/3dParty/cryptopp/cryptopp.pri) +LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCompoundFileLib ADD_DEPENDENCY(UnicodeConverter, kernel) include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri) CONFIG += open_ssl_common include($$CORE_ROOT_DIR/Common/3dParty/openssl/openssl.pri) - -DEFINES += CRYPTOPP_DISABLE_ASM DESTDIR = $$CORE_BUILDS_BINARY_PATH HEADERS += \ diff --git a/OfficeCryptReader/ooxml_crypt/ooxml_crypt.pro b/OfficeCryptReader/ooxml_crypt/ooxml_crypt.pro index df66d25d18b..0536da10519 100644 --- a/OfficeCryptReader/ooxml_crypt/ooxml_crypt.pro +++ b/OfficeCryptReader/ooxml_crypt/ooxml_crypt.pro @@ -10,15 +10,14 @@ PWD_ROOT_DIR = $$PWD include($$CORE_ROOT_DIR/Common/base.pri) include($$CORE_ROOT_DIR/Common/3dParty/boost/boost.pri) -LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib -lCompoundFileLib +include($$CORE_ROOT_DIR/Common/3dParty/cryptopp/cryptopp.pri) +LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCompoundFileLib ADD_DEPENDENCY(UnicodeConverter, kernel) include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri) CONFIG += open_ssl_common include($$CORE_ROOT_DIR/Common/3dParty/openssl/openssl.pri) - -DEFINES += CRYPTOPP_DISABLE_ASM DESTDIR = $$CORE_BUILDS_BINARY_PATH HEADERS += \ diff --git a/OfficeCryptReader/source/CryptTransform.cpp b/OfficeCryptReader/source/CryptTransform.cpp index f822ef48bc4..fb0ee731fd5 100644 --- a/OfficeCryptReader/source/CryptTransform.cpp +++ b/OfficeCryptReader/source/CryptTransform.cpp @@ -36,22 +36,22 @@ #include "CryptTransform.h" -#include "../../Common/3dParty/cryptopp/modes.h" -#include "../../Common/3dParty/cryptopp/aes.h" -#include "../../Common/3dParty/cryptopp/des.h" -#include "../../Common/3dParty/cryptopp/sha.h" -#include "../../Common/3dParty/cryptopp/md5.h" -#include "../../Common/3dParty/cryptopp/rsa.h" -#include "../../Common/3dParty/cryptopp/rc2.h" -#include "../../Common/3dParty/cryptopp/arc4.h" -#include "../../Common/3dParty/cryptopp/rc5.h" -#include "../../Common/3dParty/cryptopp/pwdbased.h" -#include "../../Common/3dParty/cryptopp/filters.h" -#include "../../Common/3dParty/cryptopp/osrng.h" -#include "../../Common/3dParty/cryptopp/hex.h" -#include "../../Common/3dParty/cryptopp/blowfish.h" -#include "../../Common/3dParty/cryptopp/zinflate.h" -#include "../../Common/3dParty/cryptopp/zdeflate.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "../../OOXML/Base/unicode_util.h" #include "../../OOXML/Base/Base.h" diff --git a/PdfFile/PdfFile.pro b/PdfFile/PdfFile.pro index 44bf8291d0a..9037c9948cf 100644 --- a/PdfFile/PdfFile.pro +++ b/PdfFile/PdfFile.pro @@ -109,9 +109,8 @@ use_external_jpeg2000 { } # PdfWriter -DEFINES += CRYPTOPP_DISABLE_ASM \ - NOMINMAX -LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib +DEFINES += NOMINMAX +include($$CORE_ROOT_DIR/Common/3dParty/cryptopp/cryptopp.pri) core_linux { DEFINES += HAVE_UNISTD_H \ diff --git a/PdfFile/SrcWriter/Encrypt.cpp b/PdfFile/SrcWriter/Encrypt.cpp index 86f71d138d3..eaa57835430 100644 --- a/PdfFile/SrcWriter/Encrypt.cpp +++ b/PdfFile/SrcWriter/Encrypt.cpp @@ -32,13 +32,13 @@ #include "Encrypt.h" #include "Objects.h" -#include "../../Common/3dParty/cryptopp/modes.h" -#include "../../Common/3dParty/cryptopp/aes.h" -#include "../../Common/3dParty/cryptopp/sha.h" -#include "../../Common/3dParty/cryptopp/md5.h" -#include "../../Common/3dParty/cryptopp/arc4.h" -#include "../../Common/3dParty/cryptopp/filters.h" -#include "../../Common/3dParty/cryptopp/osrng.h" +#include +#include +#include +#include +#include +#include +#include namespace PdfWriter { diff --git a/PdfFile/SrcWriter/EncryptDictionary.cpp b/PdfFile/SrcWriter/EncryptDictionary.cpp index 31341e1ef4a..059bfd6e7e1 100644 --- a/PdfFile/SrcWriter/EncryptDictionary.cpp +++ b/PdfFile/SrcWriter/EncryptDictionary.cpp @@ -36,7 +36,7 @@ #include -#include "../../Common/3dParty/cryptopp/md5.h" +#include #include "../../UnicodeConverter/UnicodeConverter.h" #define SET_BINARY_PARAM(Name, set_func, max_len) \ diff --git a/TxtFile/Source/PptxTxtConverterTest/PptxTxtConverterTest.pro b/TxtFile/Source/PptxTxtConverterTest/PptxTxtConverterTest.pro index 23b6527ad7c..1b6596f00fa 100644 --- a/TxtFile/Source/PptxTxtConverterTest/PptxTxtConverterTest.pro +++ b/TxtFile/Source/PptxTxtConverterTest/PptxTxtConverterTest.pro @@ -36,7 +36,7 @@ LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lDocxFormatLib LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lXlsbFormatLib LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lXlsFormatLib LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCompoundFileLib -LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib +include($$CORE_ROOT_DIR/Common/3dParty/cryptopp/cryptopp.pri) ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, kernel_network, Fb2File, PdfFile, HtmlFile2, EpubFile, XpsFile, OFDFile, DjVuFile, doctrenderer, DocxRenderer, IWorkFile, HWPFile) diff --git a/X2tConverter/test/TestOOOXml2Odf/TestOOOXml2Odf.pro b/X2tConverter/test/TestOOOXml2Odf/TestOOOXml2Odf.pro index 8d5d82658c0..f86586e513f 100644 --- a/X2tConverter/test/TestOOOXml2Odf/TestOOOXml2Odf.pro +++ b/X2tConverter/test/TestOOOXml2Odf/TestOOOXml2Odf.pro @@ -27,7 +27,7 @@ INCLUDEPATH += $$CORE_ROOT_DIR/Common INCLUDEPATH += $$CORE_ROOT_DIR/OOXML/PPTXFormat/Logic -LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib +include($$CORE_ROOT_DIR/Common/3dParty/cryptopp/cryptopp.pri) LIBS += -L$$CORE_BOOST_LIBS win32 { From 15549d401886c1ab431cf448923a0f9c3323f569 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月12日 10:58:27 +0100 Subject: [PATCH 10/20] Allow using system Boost via CONFIG+=use_system_boost Wrap vendored include/library paths in !use_system_boost guard. When using system boost, link without -L paths since system libs are in the default search path. Compiler flags (enum constexpr warnings, ARM64 defines) remain unconditional as they apply regardless of boost source. --- Common/3dParty/boost/boost.pri | 80 +++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/Common/3dParty/boost/boost.pri b/Common/3dParty/boost/boost.pri index fdc4aaf8175..9626294c9d3 100644 --- a/Common/3dParty/boost/boost.pri +++ b/Common/3dParty/boost/boost.pri @@ -1,53 +1,61 @@ -INCLUDEPATH += $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/include -CORE_BOOST_LIBS = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib +!use_system_boost { + INCLUDEPATH += $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/include + CORE_BOOST_LIBS = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib + + core_android { + INCLUDEPATH += $$PWD/build/android/include + CORE_BOOST_LIBS = $$PWD/build/android/lib/$$CORE_BUILDS_PLATFORM_PREFIX + + DEFINES += "_HAS_AUTO_PTR_ETC=0" + } + + bundle_xcframeworks { + xcframework_platform_ios_simulator { + CORE_BOOST_LIBS = $$PWD/build/ios_xcframework/ios_simulator/lib/$$CORE_BUILDS_PLATFORM_PREFIX + } else { + CORE_BOOST_LIBS = $$PWD/build/ios_xcframework/ios/lib/$$CORE_BUILDS_PLATFORM_PREFIX + } + } +} core_ios:CONFIG += disable_enum_constexpr_conversion core_android:CONFIG += disable_enum_constexpr_conversion core_mac:CONFIG += disable_enum_constexpr_conversion core_linux_clang:CONFIG += disable_enum_constexpr_conversion -core_android { - INCLUDEPATH += $$PWD/build/android/include - CORE_BOOST_LIBS = $$PWD/build/android/lib/$$CORE_BUILDS_PLATFORM_PREFIX - - DEFINES += "_HAS_AUTO_PTR_ETC=0" -} - disable_enum_constexpr_conversion { QMAKE_CFLAGS += -Wno-enum-constexpr-conversion QMAKE_CXXFLAGS += -Wno-enum-constexpr-conversion } -bundle_xcframeworks { - xcframework_platform_ios_simulator { - CORE_BOOST_LIBS = $$PWD/build/ios_xcframework/ios_simulator/lib/$$CORE_BUILDS_PLATFORM_PREFIX - } else { - CORE_BOOST_LIBS = $$PWD/build/ios_xcframework/ios/lib/$$CORE_BUILDS_PLATFORM_PREFIX - } -} - core_win_arm64 { DEFINES += MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS=0 } -core_windows { - VS_VERSION=140 - VS_DEBUG= - VS_ARCH=x64 - core_debug:VS_DEBUG=gd- - core_win_32:VS_ARCH=x32 - core_win_arm64:VS_ARCH=a64 - vs2019:VS_VERSION=142 - - DEFINES += BOOST_USE_WINDOWS_H BOOST_WINAPI_NO_REDECLARATIONS - - BOOST_POSTFIX = -vc$${VS_VERSION}-mt-$${VS_DEBUG}$${VS_ARCH}-1_72 - - core_boost_libs:LIBS += -L$$CORE_BOOST_LIBS -llibboost_system$$BOOST_POSTFIX -llibboost_filesystem$$BOOST_POSTFIX - core_boost_regex:LIBS += -L$$CORE_BOOST_LIBS -llibboost_regex$$BOOST_POSTFIX - core_boost_date_time:LIBS += -L$$CORE_BOOST_LIBS -llibboost_date_time$$BOOST_POSTFIX +use_system_boost { + core_boost_libs:LIBS += -lboost_system -lboost_filesystem + core_boost_regex:LIBS += -lboost_regex + core_boost_date_time:LIBS += -lboost_date_time } else { - core_boost_libs:LIBS += -L$$CORE_BOOST_LIBS -lboost_system -lboost_filesystem - core_boost_regex:LIBS += -L$$CORE_BOOST_LIBS -lboost_regex - core_boost_date_time:LIBS += -L$$CORE_BOOST_LIBS -lboost_date_time + core_windows { + VS_VERSION=140 + VS_DEBUG= + VS_ARCH=x64 + core_debug:VS_DEBUG=gd- + core_win_32:VS_ARCH=x32 + core_win_arm64:VS_ARCH=a64 + vs2019:VS_VERSION=142 + + DEFINES += BOOST_USE_WINDOWS_H BOOST_WINAPI_NO_REDECLARATIONS + + BOOST_POSTFIX = -vc$${VS_VERSION}-mt-$${VS_DEBUG}$${VS_ARCH}-1_72 + + core_boost_libs:LIBS += -L$$CORE_BOOST_LIBS -llibboost_system$$BOOST_POSTFIX -llibboost_filesystem$$BOOST_POSTFIX + core_boost_regex:LIBS += -L$$CORE_BOOST_LIBS -llibboost_regex$$BOOST_POSTFIX + core_boost_date_time:LIBS += -L$$CORE_BOOST_LIBS -llibboost_date_time$$BOOST_POSTFIX + } else { + core_boost_libs:LIBS += -L$$CORE_BOOST_LIBS -lboost_system -lboost_filesystem + core_boost_regex:LIBS += -L$$CORE_BOOST_LIBS -lboost_regex + core_boost_date_time:LIBS += -L$$CORE_BOOST_LIBS -lboost_date_time + } } From 7f24264791c0f62cb943fee76ea0bc4455793b7c Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月12日 10:59:01 +0100 Subject: [PATCH 11/20] Allow using system ICU via CONFIG+=use_system_icu When use_system_icu is set, link against system -licuuc -licudata without vendored include/library paths. All platform-specific vendored ICU configuration (Windows, Linux, macOS, iOS, Android) is wrapped in the else branch. --- Common/3dParty/icu/icu.pri | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Common/3dParty/icu/icu.pri b/Common/3dParty/icu/icu.pri index 187c8ce0443..2cea6feb9a8 100644 --- a/Common/3dParty/icu/icu.pri +++ b/Common/3dParty/icu/icu.pri @@ -1,3 +1,7 @@ +use_system_icu { + LIBS += -licuuc -licudata +} else { + ICU_MAJOR_VER = 74 core_windows { @@ -62,3 +66,5 @@ core_android { LIBS += $$PWD/android/build/$$CORE_BUILDS_PLATFORM_PREFIX_DST/libicuuc.a LIBS += $$PWD/android/build/$$CORE_BUILDS_PLATFORM_PREFIX_DST/libicudata.a } + +} # !use_system_icu From 06d07199d65ba98fbd4bf975e66d85e52884d3f8 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月12日 11:07:30 +0100 Subject: [PATCH 12/20] Allow using system HarfBuzz via CONFIG+=use_system_harfbuzz Create harfbuzz.pri with use_system_harfbuzz guard. When set, link against system -lharfbuzz. Otherwise include the generated harfbuzz_sources.pri from make.py. Update make.py to write to harfbuzz_sources.pri instead of harfbuzz.pri so the git-tracked file is not overwritten. Update .gitignore to track harfbuzz.pri and ignore the generated harfbuzz_sources.pri. --- Common/3dParty/harfbuzz/.gitignore | 2 +- Common/3dParty/harfbuzz/harfbuzz.pri | 6 ++++++ Common/3dParty/harfbuzz/make.py | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 Common/3dParty/harfbuzz/harfbuzz.pri diff --git a/Common/3dParty/harfbuzz/.gitignore b/Common/3dParty/harfbuzz/.gitignore index 6096c5eddf1..597143fed90 100644 --- a/Common/3dParty/harfbuzz/.gitignore +++ b/Common/3dParty/harfbuzz/.gitignore @@ -1,3 +1,3 @@ harfbuzz/ -harfbuzz.pri +harfbuzz_sources.pri module.version diff --git a/Common/3dParty/harfbuzz/harfbuzz.pri b/Common/3dParty/harfbuzz/harfbuzz.pri new file mode 100644 index 00000000000..310088cbc84 --- /dev/null +++ b/Common/3dParty/harfbuzz/harfbuzz.pri @@ -0,0 +1,6 @@ +use_system_harfbuzz { + INCLUDEPATH += /usr/include/harfbuzz + LIBS += -lharfbuzz +} else { + include($$PWD/harfbuzz_sources.pri) +} diff --git a/Common/3dParty/harfbuzz/make.py b/Common/3dParty/harfbuzz/make.py index fbee78e985b..4ca910f7b46 100755 --- a/Common/3dParty/harfbuzz/make.py +++ b/Common/3dParty/harfbuzz/make.py @@ -121,10 +121,10 @@ def clear_module(): else: qmake_content_lines.append("") - if (base.is_file("./harfbuzz.pri")): - base.delete_file("./harfbuzz.pri") + if (base.is_file("./harfbuzz_sources.pri")): + base.delete_file("./harfbuzz_sources.pri") - with open("./harfbuzz.pri", "w") as file: + with open("./harfbuzz_sources.pri", "w") as file: file.write("\n".join(qmake_content_lines)) #base.delete_file("./harfbuzz/src/hb-ft.cc") From cd81b64fa9d9ab968abfbb33b2d36f7b09a6f1e1 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月12日 11:07:39 +0100 Subject: [PATCH 13/20] Allow using system libheif via CONFIG+=use_system_heif When use_system_heif is set, link against system -lheif -lde265 -lx265 without vendored paths or static build defines. All platform-specific vendored library paths (Windows, Linux/Android, macOS/iOS) are wrapped in the else branch. --- Common/3dParty/heif/heif.pri | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Common/3dParty/heif/heif.pri b/Common/3dParty/heif/heif.pri index 65d55e9026a..7a55737e18b 100644 --- a/Common/3dParty/heif/heif.pri +++ b/Common/3dParty/heif/heif.pri @@ -1,3 +1,7 @@ +use_system_heif { + LIBS += -lheif -lde265 -lx265 +} else { + DEFINES += LIBHEIF_STATIC_BUILD HEIF_BUILDS_PLATFORM_PREFIX = $$CORE_BUILDS_PLATFORM_PREFIX @@ -40,3 +44,5 @@ core_mac | core_ios { -L$$PWD/libde265/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX/libde265 -lde265 \ -L$$HEIF_BUILD_PATH/libheif -lheif } + +} # !use_system_heif From 1e72d7ee30e4372fbe4d0416764a8fbbaf1e0411 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月12日 11:12:36 +0100 Subject: [PATCH 14/20] Allow using system V8 via CONFIG+=use_system_v8 When use_system_v8 is set, link against system libv8_monolith from /usr/lib with headers from /usr/include/v8 (as provided by the chromium-v8-dev package). Defines V8_VERSION_89_PLUS, V8_VERSION_121_PLUS, V8_COMPRESS_POINTERS, and DISABLE_MEMORY_LIMITATION for compatibility with modern V8 (12.1+). Add V8_VERSION_121_PLUS guards for API changes: - Inspector connect() requires additional trust/debugger params - VisitHandlesWithClassIds() was removed --- Common/3dParty/v8/v8.pri | 14 ++++++++++++++ .../v8/inspector/v8_inspector_client.cpp | 6 ++++++ .../doctrenderer/js_internal/v8/v8_base.cpp | 2 ++ 3 files changed, 22 insertions(+) diff --git a/Common/3dParty/v8/v8.pri b/Common/3dParty/v8/v8.pri index 11c7c72d1b1..6b62b3a46dd 100644 --- a/Common/3dParty/v8/v8.pri +++ b/Common/3dParty/v8/v8.pri @@ -1,3 +1,15 @@ +use_system_v8 { + CONFIG += c++2a + CONFIG += use_v8_monolith + DEFINES += V8_VERSION_89_PLUS + DEFINES += V8_VERSION_121_PLUS + DEFINES += V8_COMPRESS_POINTERS + DEFINES += DISABLE_MEMORY_LIMITATION + + INCLUDEPATH += /usr/include/v8 + LIBS += -lv8_monolith -lpthread +} else { + CORE_V8_PATH_OVERRIDE=$$PWD !v8_version_60:CONFIG += v8_version_89 @@ -86,3 +98,5 @@ core_mac { core_android { LIBS += -L$$CORE_V8_PATH_LIBS -lv8_monolith } + +} # !use_system_v8 diff --git a/DesktopEditor/doctrenderer/js_internal/v8/inspector/v8_inspector_client.cpp b/DesktopEditor/doctrenderer/js_internal/v8/inspector/v8_inspector_client.cpp index dbfda9807c9..cba7db56974 100644 --- a/DesktopEditor/doctrenderer/js_internal/v8/inspector/v8_inspector_client.cpp +++ b/DesktopEditor/doctrenderer/js_internal/v8/inspector/v8_inspector_client.cpp @@ -22,7 +22,13 @@ namespace NSJSBase // initialize all V8 inspector stuff m_pChannel.reset(new CV8InspectorChannelImpl(m_pIsolate, fOnResponse)); m_pInspector = v8_inspector::V8Inspector::create(m_pIsolate, this); +#ifdef V8_VERSION_121_PLUS + m_pSession = m_pInspector->connect(m_nContextGroupId, m_pChannel.get(), v8_inspector::StringView(), + v8_inspector::V8Inspector::kFullyTrusted, + v8_inspector::V8Inspector::kNotWaitingForDebugger); +#else m_pSession = m_pInspector->connect(m_nContextGroupId, m_pChannel.get(), v8_inspector::StringView()); +#endif context->SetAlignedPointerInEmbedderData(1, this); v8_inspector::StringView oContextName = convertToStringView("inspector" + std::to_string(nContextGroupId)); diff --git a/DesktopEditor/doctrenderer/js_internal/v8/v8_base.cpp b/DesktopEditor/doctrenderer/js_internal/v8/v8_base.cpp index 5192bda717d..ba3a35f66e0 100644 --- a/DesktopEditor/doctrenderer/js_internal/v8/v8_base.cpp +++ b/DesktopEditor/doctrenderer/js_internal/v8/v8_base.cpp @@ -259,10 +259,12 @@ namespace NSJSBase m_internal->m_contextPersistent.Reset(); // destroy native object in the weak handles before isolate disposal v8::Isolate* isolate = m_internal->m_isolate; +#ifndef V8_VERSION_121_PLUS { v8::Isolate::Scope scope(isolate); isolate->VisitHandlesWithClassIds(WeakHandleVisitor::getInstance()); } +#endif isolate->Dispose(); m_internal->m_isolate = NULL; } From c92f6949814ad850f120c02dc53a3c9e7d13cff5 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月12日 11:50:59 +0100 Subject: [PATCH 15/20] Use portable include path for libheif header Change from vendored relative path to which works with both system libheif (/usr/include/libheif/heif.h) and vendored libheif (via INCLUDEPATH from heif.pri). --- DesktopEditor/raster/heif/heif.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesktopEditor/raster/heif/heif.h b/DesktopEditor/raster/heif/heif.h index bf516c22ffe..e340e6bc107 100644 --- a/DesktopEditor/raster/heif/heif.h +++ b/DesktopEditor/raster/heif/heif.h @@ -1,5 +1,5 @@ #include "../BgraFrame.h" -#include "../../Common/3dParty/heif/libheif/libheif/api/libheif/heif.h" +#include #include "../../UnicodeConverter/UnicodeConverter.h" namespace NSHeif { From 78a425006d4ddd911a1638178fa0c087bb8ad179 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月12日 11:54:20 +0100 Subject: [PATCH 16/20] Fix incompatible pointer types in vendored jasper JPEG-2000 GCC 14+ treats -Wincompatible-pointer-types as an error. The jasper code used int* where jpc_fix_t* (long int* on 64-bit) was expected. Fix the function declarations, definitions, and struct typedef to use jpc_fix_t consistently: - jpc_ft_synthesize() parameter in jpc_qmfb.c - analyze/synthesize function pointers in jpc_qmfb2d_t struct - jpc_tsfb_analyze2/synthesize2() parameters in jpc_tsfb.c These changes are backward compatible with older GCC as they correct the types to match actual usage on all architectures. --- DesktopEditor/cximage/jasper/jpc/jpc_qmfb.c | 5 +++-- DesktopEditor/cximage/jasper/jpc/jpc_qmfb.h | 6 ++++-- DesktopEditor/cximage/jasper/jpc/jpc_tsfb.c | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/DesktopEditor/cximage/jasper/jpc/jpc_qmfb.c b/DesktopEditor/cximage/jasper/jpc/jpc_qmfb.c index 00d406d948e..afe72833730 100644 --- a/DesktopEditor/cximage/jasper/jpc/jpc_qmfb.c +++ b/DesktopEditor/cximage/jasper/jpc/jpc_qmfb.c @@ -83,6 +83,7 @@ #include "jasper/jas_malloc.h" #include "jasper/jas_math.h" +#include "jpc_fix.h" #include "jpc_qmfb.h" #include "jpc_tsfb.h" #include "jpc_math.h" @@ -96,7 +97,7 @@ int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height, int stride); -int jpc_ft_synthesize(int *a, int xstart, int ystart, int width, int height, +int jpc_ft_synthesize(jpc_fix_t *a, int xstart, int ystart, int width, int height, int stride); int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height, @@ -1592,7 +1593,7 @@ int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height, } -int jpc_ft_synthesize(int *a, int xstart, int ystart, int width, int height, +int jpc_ft_synthesize(jpc_fix_t *a, int xstart, int ystart, int width, int height, int stride) { int numrows = height; diff --git a/DesktopEditor/cximage/jasper/jpc/jpc_qmfb.h b/DesktopEditor/cximage/jasper/jpc/jpc_qmfb.h index 4f43440bca6..eb431d4213b 100644 --- a/DesktopEditor/cximage/jasper/jpc/jpc_qmfb.h +++ b/DesktopEditor/cximage/jasper/jpc/jpc_qmfb.h @@ -76,6 +76,8 @@ #include "jasper/jas_seq.h" +#include "jpc_fix.h" + /******************************************************************************\ * Constants. \******************************************************************************/ @@ -101,8 +103,8 @@ any particular platform. Hopefully, it is not too unreasonable, however. */ #endif typedef struct { - int (*analyze)(int *, int, int, int, int, int); - int (*synthesize)(int *, int, int, int, int, int); + int (*analyze)(jpc_fix_t *, int, int, int, int, int); + int (*synthesize)(jpc_fix_t *, int, int, int, int, int); double *lpenergywts; double *hpenergywts; } jpc_qmfb2d_t; diff --git a/DesktopEditor/cximage/jasper/jpc/jpc_tsfb.c b/DesktopEditor/cximage/jasper/jpc/jpc_tsfb.c index 2a4eaee6702..f5ac889c211 100644 --- a/DesktopEditor/cximage/jasper/jpc/jpc_tsfb.c +++ b/DesktopEditor/cximage/jasper/jpc/jpc_tsfb.c @@ -119,7 +119,7 @@ void jpc_tsfb_destroy(jpc_tsfb_t *tsfb) free(tsfb); } -int jpc_tsfb_analyze2(jpc_tsfb_t *tsfb, int *a, int xstart, int ystart, +int jpc_tsfb_analyze2(jpc_tsfb_t *tsfb, jpc_fix_t *a, int xstart, int ystart, int width, int height, int stride, int numlvls) { if (width> 0 && height> 0) { @@ -150,7 +150,7 @@ int jpc_tsfb_analyze(jpc_tsfb_t *tsfb, jas_seq2d_t *a) #endif } -int jpc_tsfb_synthesize2(jpc_tsfb_t *tsfb, int *a, int xstart, int ystart, +int jpc_tsfb_synthesize2(jpc_tsfb_t *tsfb, jpc_fix_t *a, int xstart, int ystart, int width, int height, int stride, int numlvls) { if (numlvls> 0) { From 704e7b6a63f4c80fcfc5eaf74b325a6d36969b8a Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月12日 12:37:28 +0100 Subject: [PATCH 17/20] Fix GCC 15 and V8 12.1+ compatibility issues pole.cpp: Replace wide string literals (L"...") with narrow ones when outputting to std::cout. GCC 15 libstdc++ deletes the operator<<(ostream, wchar_t*) overload as mixing narrow/wide streams is undefined behavior. v8_base: Add V8Holder compat macro that maps to This() on V8 12.1+ (where Holder() was removed) and Holder() on older V8. Replace all Holder() calls in v8_base.h and v8_base.cpp. inspector/utils.cpp: Use v8::Isolate::GetCurrent() instead of Context::GetIsolate() which was removed in newer V8. --- Common/3dParty/pole/pole.cpp | 22 ++++++------- .../js_internal/v8/inspector/utils.cpp | 4 +++ .../doctrenderer/js_internal/v8/v8_base.cpp | 2 +- .../doctrenderer/js_internal/v8/v8_base.h | 31 +++++++++++-------- 4 files changed, 34 insertions(+), 25 deletions(-) diff --git a/Common/3dParty/pole/pole.cpp b/Common/3dParty/pole/pole.cpp index fbbd2a4b3df..b03e9111c58 100644 --- a/Common/3dParty/pole/pole.cpp +++ b/Common/3dParty/pole/pole.cpp @@ -1283,19 +1283,19 @@ void DirTree::debug() DirEntry* e = entry( i ); if( !e ) continue; std::cout << i << ": "; - if( !e->valid ) std::cout << L"INVALID "; + if( !e->valid ) std::cout << "INVALID "; std::wcout << e->name << L" "; - if( e->dir ) std::cout << L"(Dir) "; - else std::cout << L"(File) "; - std::cout << e->size << L" "; - std::cout << L"s:" << e->start << L" "; - std::cout << L"("; - if( e->child == End ) std::cout << L"-"; else std::cout << e->child; + if( e->dir ) std::cout << "(Dir) "; + else std::cout << "(File) "; + std::cout << e->size << " "; + std::cout << "s:" << e->start << " "; + std::cout << "("; + if( e->child == End ) std::cout << "-"; else std::cout << e->child; std::cout << " "; - if( e->prev == End ) std::cout << L"-"; else std::cout << e->prev; - std::cout << L":"; - if( e->next == End ) std::cout << L"-"; else std::cout << e->next; - std::cout << L")"; + if( e->prev == End ) std::cout << "-"; else std::cout << e->prev; + std::cout << ":"; + if( e->next == End ) std::cout << "-"; else std::cout << e->next; + std::cout << ")"; std::cout << std::endl; } } diff --git a/DesktopEditor/doctrenderer/js_internal/v8/inspector/utils.cpp b/DesktopEditor/doctrenderer/js_internal/v8/inspector/utils.cpp index 6979a078f7b..a9be2dff16e 100644 --- a/DesktopEditor/doctrenderer/js_internal/v8/inspector/utils.cpp +++ b/DesktopEditor/doctrenderer/js_internal/v8/inspector/utils.cpp @@ -26,7 +26,11 @@ namespace NSJSBase v8::Local parseJson(const v8::Local& context, const std::string& sJson) { +#ifdef V8_VERSION_121_PLUS + v8::MaybeLocal jsonValue = v8::JSON::Parse(context, CreateV8String(v8::Isolate::GetCurrent(), sJson)); +#else v8::MaybeLocal jsonValue = v8::JSON::Parse(context, CreateV8String(context->GetIsolate(), sJson)); +#endif if (jsonValue.IsEmpty()) { return v8::Local(); diff --git a/DesktopEditor/doctrenderer/js_internal/v8/v8_base.cpp b/DesktopEditor/doctrenderer/js_internal/v8/v8_base.cpp index ba3a35f66e0..926967d05b4 100644 --- a/DesktopEditor/doctrenderer/js_internal/v8/v8_base.cpp +++ b/DesktopEditor/doctrenderer/js_internal/v8/v8_base.cpp @@ -618,7 +618,7 @@ namespace NSJSBase // this function is called when method from embedded object is called void _Call(const v8::FunctionCallbackInfo& args) { - CJSEmbedObject* _this = (CJSEmbedObject*)unwrap_native(args.Holder()); + CJSEmbedObject* _this = (CJSEmbedObject*)unwrap_native(args.V8Holder()); CJSFunctionArgumentsV8 _args(&args, 0); JSSmart funcIndex = js_value(args.Data()); CJSEmbedObjectAdapterV8* _adapter = static_cast(_this->getAdapter()); diff --git a/DesktopEditor/doctrenderer/js_internal/v8/v8_base.h b/DesktopEditor/doctrenderer/js_internal/v8/v8_base.h index 367904b2e2a..0582e32cbb0 100644 --- a/DesktopEditor/doctrenderer/js_internal/v8/v8_base.h +++ b/DesktopEditor/doctrenderer/js_internal/v8/v8_base.h @@ -35,6 +35,11 @@ #define V8IsolateFirstArg CV8Worker::GetCurrent(), #define V8IsolateOneArg CV8Worker::GetCurrent() #define V8ToChecked ToChecked +#ifdef V8_VERSION_121_PLUS +#define V8Holder This +#else +#define V8Holder Holder +#endif #else #define kV8NormalString v8::NewStringType::kNormal #define kV8ProduceCodeCache v8::ScriptCompiler::kProduceCodeCache @@ -1009,7 +1014,7 @@ inline void js_return(const v8::PropertyCallbackInfo& info, JSSmart _name, const v8::PropertyCallbackInfo& info) \ { \ - CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(info.Holder())); \ + CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(info.V8Holder())); \ if (!_this) return; \ JSSmart ret = _this->NAME_EMBED(); \ js_return(info, ret); \ @@ -1018,7 +1023,7 @@ inline void js_return(const v8::PropertyCallbackInfo& info, JSSmart& args) \ { \ - CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.Holder())); \ + CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.V8Holder())); \ if (!_this) return; \ JSSmart ret = _this->NAME_EMBED(); \ js_return(args, ret); \ @@ -1029,7 +1034,7 @@ inline void js_return(const v8::PropertyCallbackInfo& info, JSSmart& args) \ { \ - CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.Holder())); \ + CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.V8Holder())); \ if (!_this) return; \ JSSmart ret = _this->NAME_EMBED(js_value(args[0])); \ js_return(args, ret); \ @@ -1037,7 +1042,7 @@ inline void js_return(const v8::PropertyCallbackInfo& info, JSSmart& args) \ { \ - CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.Holder())); \ + CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.V8Holder())); \ if (!_this) return; \ JSSmart ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1])); \ js_return(args, ret); \ @@ -1045,7 +1050,7 @@ inline void js_return(const v8::PropertyCallbackInfo& info, JSSmart& args) \ { \ - CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.Holder())); \ + CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.V8Holder())); \ if (!_this) return; \ JSSmart ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2])); \ js_return(args, ret); \ @@ -1053,7 +1058,7 @@ inline void js_return(const v8::PropertyCallbackInfo& info, JSSmart& args) \ { \ - CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.Holder())); \ + CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.V8Holder())); \ if (!_this) return; \ JSSmart ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3])); \ js_return(args, ret); \ @@ -1061,7 +1066,7 @@ inline void js_return(const v8::PropertyCallbackInfo& info, JSSmart& args) \ { \ - CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.Holder())); \ + CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.V8Holder())); \ if (!_this) return; \ JSSmart ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4])); \ js_return(args, ret); \ @@ -1069,7 +1074,7 @@ inline void js_return(const v8::PropertyCallbackInfo& info, JSSmart& args) \ { \ - CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.Holder())); \ + CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.V8Holder())); \ if (!_this) return; \ JSSmart ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), js_value(args[5])); \ js_return(args, ret); \ @@ -1077,7 +1082,7 @@ inline void js_return(const v8::PropertyCallbackInfo& info, JSSmart& args) \ { \ - CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.Holder())); \ + CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.V8Holder())); \ if (!_this) return; \ JSSmart ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), \ js_value(args[5]), js_value(args[6])); \ @@ -1086,7 +1091,7 @@ inline void js_return(const v8::PropertyCallbackInfo& info, JSSmart& args) \ { \ - CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.Holder())); \ + CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.V8Holder())); \ if (!_this) return; \ JSSmart ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), \ js_value(args[5]), js_value(args[6]), js_value(args[7])); \ @@ -1095,7 +1100,7 @@ inline void js_return(const v8::PropertyCallbackInfo& info, JSSmart& args) \ { \ - CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.Holder())); \ + CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.V8Holder())); \ if (!_this) return; \ JSSmart ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), \ js_value(args[5]), js_value(args[6]), js_value(args[7]), js_value(args[8])); \ @@ -1104,7 +1109,7 @@ inline void js_return(const v8::PropertyCallbackInfo& info, JSSmart& args) \ { \ - CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.Holder())); \ + CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.V8Holder())); \ if (!_this) return; \ JSSmart ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), js_value(args[5]), \ js_value(args[6]), js_value(args[7]), js_value(args[8]), js_value(args[9])); \ @@ -1113,7 +1118,7 @@ inline void js_return(const v8::PropertyCallbackInfo& info, JSSmart& args) \ { \ - CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.Holder())); \ + CURRENTWRAPPER* _this = dynamic_cast(unwrap_native(args.V8Holder())); \ if (!_this) return; \ JSSmart ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), js_value(args[5]), \ js_value(args[6]), js_value(args[7]), js_value(args[8]), js_value(args[9]), js_value(args[10]), js_value(args[11]), \ From f22a1fbfddae95274f93086d72a685cc2c0e5277 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月13日 07:48:15 +0100 Subject: [PATCH 18/20] Allow using system V8 via CONFIG+=use_system_v8 When use_system_v8 is set, link against system libv8 from /usr/lib with headers from /usr/include/v8 (as provided by the nodejs-22-libv8 package which extracts V8 from Node.js). Defines V8_VERSION_89_PLUS, V8_VERSION_121_PLUS, and DISABLE_MEMORY_LIMITATION for compatibility with modern V8 (12.1+). Node.js V8 does not enable pointer compression by default, so V8_COMPRESS_POINTERS is not defined. V8_SUPPORT_SNAPSHOTS is also not defined as snapshots require sdkjs compiled from source. --- Common/3dParty/v8/v8.pri | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Common/3dParty/v8/v8.pri b/Common/3dParty/v8/v8.pri index 6b62b3a46dd..fe9d1cb4d5d 100644 --- a/Common/3dParty/v8/v8.pri +++ b/Common/3dParty/v8/v8.pri @@ -3,11 +3,13 @@ use_system_v8 { CONFIG += use_v8_monolith DEFINES += V8_VERSION_89_PLUS DEFINES += V8_VERSION_121_PLUS - DEFINES += V8_COMPRESS_POINTERS DEFINES += DISABLE_MEMORY_LIMITATION + # Node.js V8 does not enable pointer compression by default + # and snapshots require sdkjs compiled from source + # so neither V8_COMPRESS_POINTERS nor V8_SUPPORT_SNAPSHOTS are defined INCLUDEPATH += /usr/include/v8 - LIBS += -lv8_monolith -lpthread + LIBS += -lv8 -lpthread } else { CORE_V8_PATH_OVERRIDE=$$PWD From 30f03ae2884e407915199cb3a09c3bb01a03165c Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月13日 23:21:59 +0100 Subject: [PATCH 19/20] Export zlib_addon symbols for shared library visibility The zlip_set_addition_flag and zlip_get_addition_flag functions are used across shared library boundaries (defined in libkernel.so, called by consumers). Add extern "C" guards so C++ callers use the correct C linkage, and add explicit default visibility to ensure they are exported from the shared library built with -fvisibility=hidden. --- OfficeUtils/src/zlib_addon.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/OfficeUtils/src/zlib_addon.h b/OfficeUtils/src/zlib_addon.h index 6956ea32cdf..5940aafd445 100644 --- a/OfficeUtils/src/zlib_addon.h +++ b/OfficeUtils/src/zlib_addon.h @@ -37,5 +37,19 @@ #define ZLIB_ADDON_FLAG_WINDOWS_SHARED_WRITE 2 #endif -void zlip_set_addition_flag(int flag); -int zlip_get_addition_flag(); +#if defined(__GNUC__) && __GNUC__>= 4 +#define ZLIB_ADDON_EXPORT __attribute__((visibility("default"))) +#else +#define ZLIB_ADDON_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +ZLIB_ADDON_EXPORT void zlip_set_addition_flag(int flag); +ZLIB_ADDON_EXPORT int zlip_get_addition_flag(); + +#ifdef __cplusplus +} +#endif From c75ccef18871b949201a6adca032e901851335ba Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: 2026年3月16日 09:55:47 +0100 Subject: [PATCH 20/20] Allow using system googletest via CONFIG+=use_system_googletest When use_system_googletest is set, link against system -lgtest (and optionally -lgtest_main, -lgmock) instead of compiling vendored sources. All vendored source compilation is wrapped in the else branch. Add core_no_gtest_main and core_gmock config flags to control gtest_main and gmock inclusion, replacing per-project SOURCES -= hacks that break under use_system_googletest. Migrate cfcpp/test, OOXML/test, and OdfFile/Test/test_odf to use the central googletest.pri with the new config flags. --- Common/3dParty/googletest/googletest.pri | 31 ++++++++++++++++++------ Common/cfcpp/test/test.pro | 4 +-- OOXML/test/test.pro | 2 +- OdfFile/Test/test_odf/test_odf.pro | 2 +- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/Common/3dParty/googletest/googletest.pri b/Common/3dParty/googletest/googletest.pri index 30cd6956933..89e9246cd50 100644 --- a/Common/3dParty/googletest/googletest.pri +++ b/Common/3dParty/googletest/googletest.pri @@ -1,12 +1,27 @@ -CORE_GTEST_PATH=$$PWD/googletest/googletest +use_system_googletest { + LIBS += -lgtest + !core_no_gtest_main:LIBS += -lgtest_main + core_gmock:LIBS += -lgmock +} else { + CORE_GTEST_PATH=$$PWD/googletest/googletest -CONFIG += c++14 + CONFIG += c++14 -CORE_GTEST_PATH_INCLUDE = $$CORE_GTEST_PATH/include + CORE_GTEST_PATH_INCLUDE = $$CORE_GTEST_PATH/include -INCLUDEPATH += $$CORE_GTEST_PATH -INCLUDEPATH += $$CORE_GTEST_PATH_INCLUDE + INCLUDEPATH += $$CORE_GTEST_PATH + INCLUDEPATH += $$CORE_GTEST_PATH_INCLUDE -SOURCES += \ - $$CORE_GTEST_PATH/src/gtest-all.cc \ - $$CORE_GTEST_PATH/src/gtest_main.cc + SOURCES += \ + $$CORE_GTEST_PATH/src/gtest-all.cc + !core_no_gtest_main:SOURCES += $$CORE_GTEST_PATH/src/gtest_main.cc + + core_gmock { + CORE_GMOCK_PATH=$$PWD/googletest/googlemock + + INCLUDEPATH += $$CORE_GMOCK_PATH + INCLUDEPATH += $$CORE_GMOCK_PATH/include + + SOURCES += $$CORE_GMOCK_PATH/src/gmock-all.cc + } +} diff --git a/Common/cfcpp/test/test.pro b/Common/cfcpp/test/test.pro index 92742ac79ea..6eea191fe25 100755 --- a/Common/cfcpp/test/test.pro +++ b/Common/cfcpp/test/test.pro @@ -1,15 +1,15 @@ -include(gtest_dependency.pri) - TARGET = test TEMPLATE = app CONFIG += console c++11 CONFIG -= app_bundle CONFIG += thread CONFIG -= qt +CONFIG += core_no_gtest_main core_gmock CORE_ROOT_DIR = $$PWD/../../.. PWD_ROOT_DIR = $$PWD include(../../base.pri) +include($$CORE_ROOT_DIR/Common/3dParty/googletest/googletest.pri) ADD_DEPENDENCY(UnicodeConverter, kernel, CompoundFileLib) diff --git a/OOXML/test/test.pro b/OOXML/test/test.pro index 1f7e92961a1..390b08cd543 100644 --- a/OOXML/test/test.pro +++ b/OOXML/test/test.pro @@ -6,6 +6,7 @@ DEFINES += BUILD_X2T_AS_LIBRARY_DYLIB X2T_DIR = $$PWD/../../X2tConverter +CONFIG += core_no_gtest_main include($$X2T_DIR/build/Qt/X2tConverter.pri) include($$X2T_DIR/../Common/3dParty/googletest/googletest.pri) @@ -22,7 +23,6 @@ HEADERS += common.h DESTDIR = $$CORE_BUILDS_BINARY_PATH -SOURCES -= $$CORE_GTEST_PATH/src/gtest_main.cc SOURCES -= ../../../Common/OfficeFileFormatChecker2.cpp SOURCES -= ../../src/cextracttools.cpp SOURCES -= ../../src/ASCConverters.cpp diff --git a/OdfFile/Test/test_odf/test_odf.pro b/OdfFile/Test/test_odf/test_odf.pro index c3abc950884..3fc8a8fd52b 100644 --- a/OdfFile/Test/test_odf/test_odf.pro +++ b/OdfFile/Test/test_odf/test_odf.pro @@ -9,6 +9,7 @@ CONFIG -= app_bundle CONFIG += core_static_link_libstd CONFIG += build_x2t_as_library +CONFIG += core_no_gtest_main CORE_ROOT_DIR = $$PWD/../../../../core @@ -37,4 +38,3 @@ SOURCES += \ # audio.cpp\ # interactions.cpp -SOURCES -= $$CORE_GTEST_PATH/src/gtest_main.cc

    AltStyle によって変換されたページ (->オリジナル) /