mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
284 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ace3e2e80 | |||
| 1baf789bb5 | |||
| c239040756 | |||
| b89d16691a | |||
| 9788d38a69 | |||
| bf6d4b00e3 | |||
| 4a452ee47f | |||
| 3a46d8a909 | |||
| 8539dc168b | |||
| d651d5166b | |||
| 699acd0516 | |||
| 5e9e15be57 | |||
| 2eec32df98 | |||
| 77ea7fd3df | |||
| cb40323b31 | |||
| 85817c68c1 | |||
| 7a822494aa | |||
| 284d2730e2 | |||
| 7a36d76298 | |||
| c3b7447c04 | |||
| e0cc9c0409 | |||
| 075d6c849b | |||
| a0ff455786 | |||
| c4f475167d | |||
| d72d03d449 | |||
| 322c7af962 | |||
| 879ce1a66d | |||
| a01b535609 | |||
| 25a909d7a7 | |||
| 2c081fedc9 | |||
| 9fc7aa5bca | |||
| 35e10ff9cd | |||
| bce86077af | |||
| ed46c8521d | |||
| 7d18fa5753 | |||
| bdddc1ac67 | |||
| a02bd8f383 | |||
| 07e8cda08d | |||
| 53e8fa7731 | |||
| cc4056a18b | |||
| 63b425763e | |||
| bf859f9763 | |||
| 650c993fa0 | |||
| abba98d9d3 | |||
| e85923d94e | |||
| 6d548d27bc | |||
| 29167e6267 | |||
| 80e2c75a54 | |||
| 9c67404b69 | |||
| c82b5c9994 | |||
| e6205fcff9 | |||
| 1ec0142c25 | |||
| f65463c96f | |||
| 133ad365f4 | |||
| 4c077a28b8 | |||
| 1bd7c77ead | |||
| 26e5245cf6 | |||
| 672b9fd118 | |||
| c96b59cbbf | |||
| 81ec34b6f9 | |||
| f29d83a80b | |||
| b5c44805fb | |||
| 01bfa49aba | |||
| 7c0bef3c04 | |||
| 7aeaec211a | |||
| a3de9703bf | |||
| af743b7e25 | |||
| d4b6a05717 | |||
| de51600d34 | |||
| c64379636e | |||
| d2f9c59b5f | |||
| 30675ab8b9 | |||
| fbadc56797 | |||
| a568aa02c4 | |||
| 099d49b3a7 | |||
| 55a200e71d | |||
| c6586a9a17 | |||
| fbcf56be9e | |||
| 83fdc52baf | |||
| 966eac2367 | |||
| 32c185c089 | |||
| cb66e15faf | |||
| f6a102353d | |||
| 2247d47e4b | |||
| cb77b0989c | |||
| 5832049ebc | |||
| 43bc3c92b3 | |||
| 50007b47ee | |||
| b98c51b020 | |||
| 0c5e670ad1 | |||
| e41b892b58 | |||
| 527af6f669 | |||
| 5e6f84ec74 | |||
| 3c7d05a33e | |||
| c2d48fdd32 | |||
| ebf6e9e995 | |||
| f87f2a47d5 | |||
| 5728bcda76 | |||
| ceadb68bc6 | |||
| 3aa94ae6ae | |||
| b8095b3f82 | |||
| 7448a331e9 | |||
| 940bb840be | |||
| 967b0aec72 | |||
| 852989d0c9 | |||
| c733399b88 | |||
| 8c92a944ad | |||
| 0456f9b362 | |||
| 4ec7942649 | |||
| 13410416a5 | |||
| b4d00a7a47 | |||
| 9d497e48c9 | |||
| 759a159005 | |||
| 92e6fa06b5 | |||
| 7b93de3e8a | |||
| ca3e65468b | |||
| 5d378ddb41 | |||
| ba05993073 | |||
| 6438c1cd4b | |||
| 07ad714d3a | |||
| 1c87c34db9 | |||
| 8f4956102a | |||
| 0d8fcd1bef | |||
| 4db5c55544 | |||
| 709ac0b868 | |||
| dd73d3347f | |||
| e98f981a46 | |||
| d6b7aefe51 | |||
| f612ca64e0 | |||
| e3a582ee67 | |||
| fa68ba2f0d | |||
| 3387f67f7e | |||
| 383e9bc971 | |||
| c67aea9543 | |||
| 0e64e3467b | |||
| cc2027edab | |||
| da3739942f | |||
| 80d5783b3b | |||
| dbd5aeadd2 | |||
| d57b69731b | |||
| 248f9a5362 | |||
| 204ef06b1a | |||
| f9171cb342 | |||
| 6d80b8537f | |||
| c5a09b75d6 | |||
| 1c8687e07f | |||
| 28745ae49f | |||
| d6b5523406 | |||
| fc1d61799b | |||
| 358903d331 | |||
| 46e8d03eeb | |||
| 554ad261cf | |||
| 78c662ea55 | |||
| 98a02441de | |||
| efb3075e0e | |||
| da703d88ca | |||
| dc73c8b2b6 | |||
| 1404829b68 | |||
| be9f8ba8e6 | |||
| f858b76fd4 | |||
| 3914b9a9d5 | |||
| e19d1c6735 | |||
| 041d8a3dc4 | |||
| 31ee203b92 | |||
| 3d7eefcd3d | |||
| 82db1cd0d1 | |||
| 14ea99e880 | |||
| 7363c995dd | |||
| 66a2edf5d2 | |||
| 36e5cada88 | |||
| 01e9bb8cef | |||
| 9887883626 | |||
| 3d828f9683 | |||
| 2d890247ab | |||
| 5acc2513c8 | |||
| d3dc902f23 | |||
| 11ae76f9f0 | |||
| 7340469a8c | |||
| 92e03fd7b6 | |||
| 7a12a4d43e | |||
| c59f679043 | |||
| 3cb1503632 | |||
| b2b0c74cd4 | |||
| a1376d647f | |||
| dc17f5fe2e | |||
| 6d45b90ac0 | |||
| 7130c2d1bb | |||
| e19db2847f | |||
| 2e8bb7177c | |||
| c8ca57ea40 | |||
| e7931e73d1 | |||
| b096ce8098 | |||
| ffc3149d4b | |||
| f4cc9ec38a | |||
| 5c3760a907 | |||
| 6320c543c0 | |||
| 324dd2de49 | |||
| e07fd5ed24 | |||
| 19295c1037 | |||
| 7ad0e7e9fe | |||
| ce9ede6820 | |||
| 379f474739 | |||
| a2662a6f2b | |||
| c52893306d | |||
| 3a9a2b5ee7 | |||
| 8df04c48ad | |||
| f7b0565233 | |||
| ef7fb15efe | |||
| e32b53d662 | |||
| 0b683226e9 | |||
| 73924f3ae0 | |||
| e8ecef51dd | |||
| 5bf730e1d6 | |||
| 091f3a3a8e | |||
| ffa8467c9e | |||
| 398c69c01e | |||
| a48ed74102 | |||
| 45628154d9 | |||
| 2921e476c3 | |||
| e97fd44489 | |||
| 1dba0723c7 | |||
| 217ec901ed | |||
| 68723a5e81 | |||
| 53810c07ac | |||
| 14fcc4dfac | |||
| b4b1cae18e | |||
| ab74e3fce7 | |||
| 4f48287d28 | |||
| 3b20ac3825 | |||
| 3f782ab389 | |||
| c22d4c60c0 | |||
| 9349ddf604 | |||
| 70c4f045ea | |||
| d955de5bdb | |||
| 0bd9cead65 | |||
| c282e86832 | |||
| cd91baaabe | |||
| 727a7722bb | |||
| 0d47bdc47d | |||
| cd458b81ec | |||
| 4beb4c8d70 | |||
| aa56efb495 | |||
| 44016b4ccc | |||
| d2158ded6f | |||
| 34790c680a | |||
| 4dfa989980 | |||
| 99ba013151 | |||
| 857957e824 | |||
| c0972a5b4a | |||
| c0f231fa92 | |||
| 6ec0609de3 | |||
| 43aacc8dd9 | |||
| f75d977661 | |||
| 48d19d9aa0 | |||
| 16448245b8 | |||
| c8a03fec41 | |||
| db05f4d373 | |||
| b6e741c4a5 | |||
| ff75d14e29 | |||
| ed0bcfc642 | |||
| 33e6c14a04 | |||
| f7b3ab2411 | |||
| ea49ffe242 | |||
| 471f739a66 | |||
| a710a7b77c | |||
| 13ff65c6e9 | |||
| 5050726d47 | |||
| 3296d32168 | |||
| 11b59048cd | |||
| 6b0513cd81 | |||
| e335a237a5 | |||
| af6802e035 | |||
| 01f01ec85f | |||
| a3f7e83ccf | |||
| 09d87538e7 | |||
| 2f9726e455 | |||
| 5178cf0cb7 | |||
| 0a517af106 | |||
| 76fea998ea | |||
| 721805535e | |||
| 1f5025b136 | |||
| a61c267941 | |||
| 4910d69a40 | |||
| fa85b389f2 |
2
Common/3dParty/googletest/.gitignore
vendored
Normal file
2
Common/3dParty/googletest/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
googletest/
|
||||
build/
|
||||
12
Common/3dParty/googletest/googletest.pri
Normal file
12
Common/3dParty/googletest/googletest.pri
Normal file
@ -0,0 +1,12 @@
|
||||
CORE_GTEST_PATH=$$PWD/googletest/googletest
|
||||
|
||||
CONFIG += c++14
|
||||
|
||||
CORE_GTEST_PATH_INCLUDE = $$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
|
||||
@ -1,38 +0,0 @@
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/../openssl/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib
|
||||
|
||||
core_android {
|
||||
|
||||
OPENSSL_ABI_PATH = $$replace(CORE_BUILDS_PLATFORM_PREFIX, "android_", "")
|
||||
contains(OPENSSL_ABI_PATH, "armv7" ) {
|
||||
OPENSSL_ABI_PATH = $$replace(OPENSSL_ABI_PATH, "armv7", "armeabi-v7a")
|
||||
}
|
||||
contains(OPENSSL_ABI_PATH, "arm64_v8a" ) {
|
||||
OPENSSL_ABI_PATH = $$replace(OPENSSL_ABI_PATH, "arm64_v8a", "arm64-v8a")
|
||||
}
|
||||
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/../openssl/build/android/$$OPENSSL_ABI_PATH/lib
|
||||
}
|
||||
|
||||
core_ios {
|
||||
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/../openssl/build/ios/openssl-universal/lib
|
||||
|
||||
bundle_xcframeworks {
|
||||
xcframework_platform_ios_simulator {
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/../openssl/build/ios/openssl-xc/simulator/lib
|
||||
} else {
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/../openssl/build/ios/openssl-xc/lib
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
@ -83,19 +83,19 @@ function configure_make() {
|
||||
|
||||
if [[ "${ARCH}" == "x86_64" ]]; then
|
||||
|
||||
./Configure android-x86_64 --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method
|
||||
./Configure android-x86_64 --prefix="${PREFIX_DIR}" no-shared no-tests enable-ssl3 enable-ssl3-method enable-md2 no-asm
|
||||
|
||||
elif [[ "${ARCH}" == "x86" ]]; then
|
||||
|
||||
./Configure android-x86 --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method
|
||||
./Configure android-x86 --prefix="${PREFIX_DIR}" no-shared no-tests enable-ssl3 enable-ssl3-method enable-md2 no-asm
|
||||
|
||||
elif [[ "${ARCH}" == "arm" ]]; then
|
||||
|
||||
./Configure android-arm --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method
|
||||
./Configure android-arm --prefix="${PREFIX_DIR}" no-shared no-tests enable-ssl3 enable-ssl3-method enable-md2 no-asm
|
||||
|
||||
elif [[ "${ARCH}" == "arm64" ]]; then
|
||||
|
||||
./Configure android-arm64 --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method
|
||||
./Configure android-arm64 --prefix="${PREFIX_DIR}" no-shared no-tests enable-ssl3 enable-ssl3-method enable-md2 no-asm
|
||||
|
||||
else
|
||||
log_error "not support" && exit 1
|
||||
@ -103,6 +103,9 @@ function configure_make() {
|
||||
|
||||
log_info "make $ABI start..."
|
||||
|
||||
sed -ie 's/LIB_CFLAGS=/LIB_CFLAGS=-fvisibility=hidden /g' ./Makefile
|
||||
sed -ie 's/LIB_CXXFLAGS=/LIB_CXXFLAGS=-fvisibility=hidden /g' ./Makefile
|
||||
|
||||
make clean >"${OUTPUT_ROOT}/log/${ABI}.log"
|
||||
if make -j$(get_cpu_count) >>"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1; then
|
||||
make install_sw >>"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
|
||||
|
||||
@ -100,32 +100,32 @@ function configure_make() {
|
||||
if [[ "${ARCH_NAME}" == "x86_64" ]]; then
|
||||
|
||||
# openssl1.1.1d can be set normally, 1.1.0f does not take effect
|
||||
./Configure darwin64-x86_64-cc no-shared --prefix="${PREFIX_DIR}"
|
||||
./Configure darwin64-x86_64-cc no-shared --prefix="${PREFIX_DIR}" enable-md2
|
||||
sed -i -e 's/-mtune=intel//g' "Makefile"
|
||||
|
||||
elif [[ "${ARCH_NAME}" == "armv7" ]]; then
|
||||
|
||||
# openssl1.1.1d can be set normally, 1.1.0f does not take effect
|
||||
./Configure iphoneos-cross no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method
|
||||
./Configure iphoneos-cross no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method enable-md2
|
||||
sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
|
||||
elif [[ "${ARCH_NAME}" == "arm64" ]]; then
|
||||
|
||||
# openssl1.1.1d can be set normally, 1.1.0f does not take effect
|
||||
./Configure iphoneos-cross no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method
|
||||
./Configure iphoneos-cross no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method enable-md2
|
||||
sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
|
||||
elif [[ "${ARCH_NAME}" == "i386" ]]; then
|
||||
|
||||
# openssl1.1.1d can be set normally, 1.1.0f does not take effect
|
||||
./Configure darwin-i386-cc no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method
|
||||
./Configure darwin-i386-cc no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method enable-md2
|
||||
sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
sed -i -e 's/-mtune=intel//g' "Makefile"
|
||||
|
||||
elif [[ "${ARCH_NAME}" == "sim_arm64" ]]; then
|
||||
|
||||
# openssl1.1.1d can be set normally, 1.1.0f does not take effect
|
||||
./Configure iphoneos-cross no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method
|
||||
./Configure iphoneos-cross no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method enable-md2
|
||||
sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
|
||||
else
|
||||
|
||||
@ -1,14 +1,48 @@
|
||||
OPEN_SSL_PLATFORM=$$CORE_BUILDS_PLATFORM_PREFIX
|
||||
build_xp:OPEN_SSL_PLATFORM=$$join(OPEN_SSL_PLATFORM, OPEN_SSL_PLATFORM, "", "_xp")
|
||||
|
||||
INCLUDEPATH += $$PWD/build/$$OPEN_SSL_PLATFORM/include
|
||||
|
||||
core_windows:LIBS += -L$$PWD/build/$$OPEN_SSL_PLATFORM/lib -llibcrypto -llibssl
|
||||
!core_windows:LIBS += -L$$PWD/build/$$OPEN_SSL_PLATFORM/lib -lcrypto -lssl
|
||||
|
||||
open_ssl_common {
|
||||
DEFINES += COMMON_OPENSSL_BUILDING
|
||||
|
||||
HEADERS += $$PWD/common/common_openssl.h
|
||||
SOURCES += $$PWD/common/common_openssl.cpp
|
||||
}
|
||||
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/build/$$OPEN_SSL_PLATFORM/lib
|
||||
|
||||
core_android {
|
||||
|
||||
OPENSSL_ABI_PATH = $$replace(CORE_BUILDS_PLATFORM_PREFIX, "android_", "")
|
||||
contains(OPENSSL_ABI_PATH, "armv7" ) {
|
||||
OPENSSL_ABI_PATH = $$replace(OPENSSL_ABI_PATH, "armv7", "armeabi-v7a")
|
||||
}
|
||||
contains(OPENSSL_ABI_PATH, "arm64_v8a" ) {
|
||||
OPENSSL_ABI_PATH = $$replace(OPENSSL_ABI_PATH, "arm64_v8a", "arm64-v8a")
|
||||
}
|
||||
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/build/android/$$OPENSSL_ABI_PATH/lib
|
||||
}
|
||||
|
||||
core_ios {
|
||||
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/ios/openssl-universal/lib
|
||||
|
||||
bundle_xcframeworks {
|
||||
xcframework_platform_ios_simulator {
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/build/ios/openssl-xc/simulator/lib
|
||||
} else {
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/build/ios/openssl-xc/lib
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
# Based on Ubuntu
|
||||
############################################################
|
||||
# Set the base image to Ubuntu
|
||||
FROM ubuntu:14.04
|
||||
FROM ubuntu:18.04
|
||||
# File Author / Maintainer
|
||||
MAINTAINER onlyoffice.com
|
||||
################## BEGIN INSTALLATION ######################
|
||||
@ -23,12 +23,25 @@ RUN sudo apt-get install -y \
|
||||
curl \
|
||||
wget \
|
||||
xz-utils \
|
||||
zip
|
||||
zip \
|
||||
python2.7 \
|
||||
python3 \
|
||||
autoconf \
|
||||
build-essential \
|
||||
cmake \
|
||||
pkg-config \
|
||||
libc6-i386 \
|
||||
gcc-multilib \
|
||||
software-properties-common
|
||||
WORKDIR /home/docker
|
||||
RUN mkdir v8
|
||||
WORKDIR /home/docker/v8
|
||||
COPY ./build.sh ./build.sh
|
||||
RUN ./build.sh
|
||||
COPY ./build.py ./build.py
|
||||
RUN sudo add-apt-repository -y ppa:deadsnakes/ppa
|
||||
RUN sudo apt install -y python3.8
|
||||
RUN sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1000
|
||||
RUN sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1000
|
||||
RUN python ./build.py
|
||||
RUN zip -r ./build.zip ./build/*
|
||||
RUN ls -al /home/docker/v8/build.zip
|
||||
#End of docker Command
|
||||
199
Common/3dParty/v8/android/build.py
Normal file
199
Common/3dParty/v8/android/build.py
Normal file
@ -0,0 +1,199 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import platform
|
||||
import os
|
||||
import subprocess
|
||||
import glob
|
||||
import shutil
|
||||
import codecs
|
||||
|
||||
# BASE --------------------------------------------
|
||||
def host_platform():
|
||||
ret = platform.system().lower()
|
||||
if (ret == "darwin"):
|
||||
return "mac"
|
||||
return ret
|
||||
|
||||
def get_path(path):
|
||||
if "windows" == host_platform():
|
||||
return path.replace("/", "\\")
|
||||
return path
|
||||
|
||||
def is_file(path):
|
||||
return os.path.isfile(get_path(path))
|
||||
|
||||
def is_dir(path):
|
||||
return os.path.isdir(get_path(path))
|
||||
|
||||
def copy_file(src, dst):
|
||||
if is_file(dst):
|
||||
delete_file(dst)
|
||||
if not is_file(src):
|
||||
print("copy warning [file not exist]: " + src)
|
||||
return
|
||||
return shutil.copy2(get_path(src), get_path(dst))
|
||||
|
||||
def delete_file(path):
|
||||
if not is_file(path):
|
||||
print("delete warning [file not exist]: " + path)
|
||||
return
|
||||
return os.remove(get_path(path))
|
||||
|
||||
def create_dir(path):
|
||||
path2 = get_path(path)
|
||||
if not os.path.exists(path2):
|
||||
os.makedirs(path2)
|
||||
return
|
||||
|
||||
def copy_dir(src, dst):
|
||||
if is_dir(dst):
|
||||
delete_dir(dst)
|
||||
try:
|
||||
shutil.copytree(get_path(src), get_path(dst))
|
||||
except OSError as e:
|
||||
print('Directory not copied. Error: %s' % e)
|
||||
return
|
||||
|
||||
def delete_dir(path):
|
||||
if not is_dir(path):
|
||||
print("delete warning [folder not exist]: " + path)
|
||||
return
|
||||
shutil.rmtree(get_path(path), ignore_errors=True)
|
||||
return
|
||||
|
||||
def cmd(prog, args=[], is_no_errors=False):
|
||||
ret = 0
|
||||
command = prog
|
||||
for arg in args:
|
||||
command += (" \"" + arg + "\"")
|
||||
ret = subprocess.call(command, stderr=subprocess.STDOUT, shell=True)
|
||||
if ret != 0 and True != is_no_errors:
|
||||
sys.exit("Error (" + prog + "): " + str(ret))
|
||||
return ret
|
||||
|
||||
def cmd2(prog, args=[], is_no_errors=False):
|
||||
ret = 0
|
||||
command = get_path(prog)
|
||||
for arg in args:
|
||||
command += (" " + arg)
|
||||
print(command)
|
||||
ret = subprocess.call(command, stderr=subprocess.STDOUT, shell=True)
|
||||
if ret != 0 and True != is_no_errors:
|
||||
sys.exit("Error (" + prog + "): " + str(ret))
|
||||
return ret
|
||||
|
||||
def get_script_dir():
|
||||
test_file = __file__
|
||||
scriptPath = os.path.realpath(test_file)
|
||||
scriptDir = os.path.dirname(scriptPath)
|
||||
return scriptDir
|
||||
|
||||
def get_env(name):
|
||||
return os.getenv(name, "")
|
||||
|
||||
def set_env(name, value):
|
||||
os.environ[name] = value
|
||||
return
|
||||
|
||||
def replaceInFile(path, text, textReplace):
|
||||
if not is_file(path):
|
||||
print("[replaceInFile] file not exist: " + path)
|
||||
return
|
||||
filedata = ""
|
||||
with open(get_path(path), "r") as file:
|
||||
filedata = file.read()
|
||||
filedata = filedata.replace(text, textReplace)
|
||||
delete_file(path)
|
||||
with open(get_path(path), "w") as file:
|
||||
file.write(filedata)
|
||||
return
|
||||
|
||||
# -------------------------------------------------
|
||||
|
||||
def get_android_args(platform, sdk_ver=21):
|
||||
gn_args = ["is_component_build=false",
|
||||
"is_clang=true",
|
||||
"is_debug=false",
|
||||
"use_sysroot=true",
|
||||
"target_os=\\\"android\\\"",
|
||||
"target_cpu=\\\"" + platform + "\\\"",
|
||||
"v8_target_cpu=\\\"" + platform + "\\\"",
|
||||
"v8_enable_i18n_support=true",
|
||||
"v8_static_library=true",
|
||||
"v8_monolithic=true",
|
||||
"use_custom_libcxx=false",
|
||||
"android_ndk_version=\\\"21.1.6352462\\\"",
|
||||
"android_sdk_version=\\\"" + str(sdk_ver) + "\\\"",
|
||||
"clang_use_chrome_plugins=false",
|
||||
"v8_use_external_startup_data=false",
|
||||
"treat_warnings_as_errors=false"]
|
||||
return gn_args
|
||||
|
||||
def deploy_libs():
|
||||
if is_dir("../build"):
|
||||
delete_dir("../build")
|
||||
create_dir("../build")
|
||||
|
||||
platforms = ["arm64", "arm", "x86_64", "x86"]
|
||||
dirs = ["arm64-v8a", "armeabi-v7a", "x86_64", "x86"]
|
||||
|
||||
for index, item in enumerate(platforms):
|
||||
input_dir = "./out.gn/android/" + platforms[index]
|
||||
output_dir = "../build/" + dirs[index]
|
||||
create_dir(output_dir)
|
||||
copy_file(input_dir + "/icudtl.dat", output_dir + "/icudtl.dat")
|
||||
copy_file(input_dir + "/icudtl_extra.dat", output_dir + "/icudtl_extra.dat")
|
||||
copy_file(input_dir + "/obj/libv8_monolith.a", output_dir + "/libv8_monolith.a")
|
||||
|
||||
create_dir("../build/v8")
|
||||
copy_dir("./include", "../build/v8/include")
|
||||
copy_dir("./src", "../build/v8/src")
|
||||
return
|
||||
|
||||
def make():
|
||||
old_env = dict(os.environ)
|
||||
old_cur = os.getcwd()
|
||||
|
||||
base_dir = get_script_dir()
|
||||
|
||||
os.chdir(base_dir)
|
||||
if not is_dir("depot_tools"):
|
||||
cmd("git", ["clone", "https://chromium.googlesource.com/chromium/tools/depot_tools.git"])
|
||||
|
||||
os.environ["PATH"] = base_dir + "/depot_tools" + os.pathsep + os.environ["PATH"]
|
||||
|
||||
if not is_dir("v8"):
|
||||
cmd("./depot_tools/fetch", ["v8"], True)
|
||||
copy_dir("./v8/third_party", "./v8/third_party_new")
|
||||
v8_branch_version = "remotes/branch-heads/8.9"
|
||||
cmd("./depot_tools/gclient", ["sync", "-r", v8_branch_version], True)
|
||||
replaceInFile("./.gclient", "]", "];target_os=['android'];")
|
||||
cmd("gclient", ["sync", "--force"], True)
|
||||
copy_dir("./v8/third_party_new/ninja", "./v8/third_party/ninja")
|
||||
|
||||
if not is_file("v8/third_party/jinja2/tests.py.bak"):
|
||||
copy_file("v8/third_party/jinja2/tests.py", "v8/third_party/jinja2/tests.py.bak")
|
||||
replaceInFile("v8/third_party/jinja2/tests.py", "from collections import Mapping", "try:\n from collections.abc import Mapping\nexcept ImportError:\n from collections import Mapping")
|
||||
|
||||
os.chdir("v8")
|
||||
|
||||
cmd2("gn", ["gen", "out.gn/android/arm64", "--args=\"" + " ".join(get_android_args("arm64")) + "\""])
|
||||
cmd("ninja", ["-C", "out.gn/android/arm64"])
|
||||
|
||||
cmd2("gn", ["gen", "out.gn/android/arm", "--args=\"" + " ".join(get_android_args("arm")) + "\""])
|
||||
cmd("ninja", ["-C", "out.gn/android/arm"])
|
||||
|
||||
cmd2("gn", ["gen", "out.gn/android/x86_64", "--args=\"" + " ".join(get_android_args("x64", 16)) + "\""])
|
||||
cmd("ninja", ["-C", "out.gn/android/x86_64"])
|
||||
|
||||
cmd2("gn", ["gen", "out.gn/android/x86", "--args=\"" + " ".join(get_android_args("x86", 16)) + "\""])
|
||||
cmd("ninja", ["-C", "out.gn/android/x86"])
|
||||
|
||||
deploy_libs()
|
||||
|
||||
os.chdir(old_cur)
|
||||
os.environ.clear()
|
||||
os.environ.update(old_env)
|
||||
|
||||
make()
|
||||
@ -48,7 +48,7 @@ restore_build_gn()
|
||||
|
||||
if [ ! -d "v8" ]
|
||||
then
|
||||
fetch v8
|
||||
./depot_tools/fetch v8
|
||||
cd v8
|
||||
git checkout -b 6.0 branch-heads/6.0
|
||||
|
||||
|
||||
@ -3,23 +3,34 @@ sys.path.append('./../../../../../build_tools/scripts')
|
||||
import base
|
||||
import os
|
||||
|
||||
if ("linux" == base.host_platform()):
|
||||
if not base.is_dir("./build"):
|
||||
base.bash("./build")
|
||||
def build_func():
|
||||
if ("linux" == base.host_platform()):
|
||||
if not base.is_dir("./build"):
|
||||
base.cmd("python", ["./build.py"])
|
||||
|
||||
if ("mac" == base.host_platform()):
|
||||
if not base.is_file("./build.zip"):
|
||||
base.bash("./run_docker")
|
||||
if not base.is_dir("./build"):
|
||||
base.configure_common_apps("./../../../../../build_tools/scripts/base.py")
|
||||
base.extract("./build.zip", "./")
|
||||
if not base.is_dir("v8"):
|
||||
if not base.is_dir("depot_tools"):
|
||||
base.cmd("git", ["clone", "https://chromium.googlesource.com/chromium/tools/depot_tools.git"])
|
||||
old_cur = os.getcwd()
|
||||
os.environ["PATH"] = old_cur + "/depot_tools" + os.pathsep + os.environ["PATH"]
|
||||
base.cmd("./depot_tools/fetch", ["v8"], True)
|
||||
os.chdir(old_cur + "/v8")
|
||||
base.cmd("git", ["checkout", "-b", "6.0", "branch-heads/6.0"], True)
|
||||
os.chdir(old_cur)
|
||||
base.cmd("gclient", ["sync"])
|
||||
if ("mac" == base.host_platform()):
|
||||
if not base.is_file("./build.zip"):
|
||||
base.bash("./run_docker")
|
||||
if not base.is_dir("./build"):
|
||||
base.configure_common_apps("./../../../../../build_tools/scripts/base.py")
|
||||
base.extract("./build.zip", "./")
|
||||
if not base.is_dir("v8"):
|
||||
if not base.is_dir("depot_tools"):
|
||||
base.cmd("git", ["clone", "https://chromium.googlesource.com/chromium/tools/depot_tools.git"])
|
||||
old_cur = os.getcwd()
|
||||
os.environ["PATH"] = old_cur + "/depot_tools" + os.pathsep + os.environ["PATH"]
|
||||
base.cmd("./depot_tools/fetch", ["v8"], True)
|
||||
base.cmd("./depot_tools/gclient", ["sync", "-r", "remotes/branch-heads/8.9"], True)
|
||||
base.cmd("gclient", ["sync", "--force"], True)
|
||||
return
|
||||
|
||||
# build function. for speed we just download the build archive
|
||||
# archive built with this func
|
||||
if False:
|
||||
build_func()
|
||||
else:
|
||||
if not base.is_file("./build.7z"):
|
||||
base.download("http://d2ettrnqo7v976.cloudfront.net/v8/android/build.7z", "./build.7z")
|
||||
base.extract("./build.7z", "./")
|
||||
base.copy_dir("./build/v8", "./v8")
|
||||
base.delete_dir("./build/v8")
|
||||
|
||||
@ -10,6 +10,7 @@ for image in $(docker images --format "{{.ID}}"); do
|
||||
done
|
||||
|
||||
docker rm v8docker
|
||||
docker build . -t v8_docker --build-arg CACHEBUST=0 --no-cache=true
|
||||
#add --progress=plain for full logs from build.sh
|
||||
docker build . -t v8_docker --build-arg CACHEBUST=0 --no-cache=true --platform linux/amd64
|
||||
docker run -d --name v8docker v8_docker:latest
|
||||
docker cp v8docker:/home/docker/v8/build.zip .
|
||||
@ -1,5 +1,4 @@
|
||||
CORE_V8_PATH_OVERRIDE=$$PWD
|
||||
|
||||
!v8_version_60:CONFIG += v8_version_89
|
||||
|
||||
v8_version_89 {
|
||||
@ -9,6 +8,12 @@ v8_version_89 {
|
||||
|
||||
core_win_32:CONFIG += build_platform_32
|
||||
core_linux_32:CONFIG += build_platform_32
|
||||
|
||||
core_android {
|
||||
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_armv7):CONFIG += build_platform_32
|
||||
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_x86):CONFIG += build_platform_32
|
||||
}
|
||||
|
||||
!build_platform_32:DEFINES += V8_COMPRESS_POINTERS
|
||||
|
||||
CORE_V8_PATH_OVERRIDE = $$PWD/../v8_89
|
||||
@ -17,6 +22,16 @@ v8_version_89 {
|
||||
CORE_V8_PATH_INCLUDE = $$CORE_V8_PATH_OVERRIDE/v8
|
||||
CORE_V8_PATH_LIBS = $$CORE_V8_PATH_INCLUDE/out.gn/$$CORE_BUILDS_PLATFORM_PREFIX/obj
|
||||
|
||||
core_android {
|
||||
CORE_V8_PATH_INCLUDE = $$PWD/android/v8
|
||||
CORE_V8_PATH_LIBS = $$PWD/android/build
|
||||
|
||||
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_arm64_v8a):CORE_V8_PATH_LIBS=$$CORE_V8_PATH_LIBS/arm64-v8a
|
||||
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_armv7): CORE_V8_PATH_LIBS=$$CORE_V8_PATH_LIBS/armeabi-v7a
|
||||
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_x86): CORE_V8_PATH_LIBS=$$CORE_V8_PATH_LIBS/x86
|
||||
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_x86_64): CORE_V8_PATH_LIBS=$$CORE_V8_PATH_LIBS/x86_64
|
||||
}
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$CORE_V8_PATH_INCLUDE \
|
||||
$$CORE_V8_PATH_INCLUDE/include
|
||||
@ -66,3 +81,7 @@ core_mac {
|
||||
QMAKE_CXXFLAGS += -Wall -Wno-inconsistent-missing-override
|
||||
QMAKE_CFLAGS += -Wall -Wno-inconsistent-missing-override
|
||||
}
|
||||
|
||||
core_android {
|
||||
LIBS += -L$$CORE_V8_PATH_LIBS -lv8_monolith
|
||||
}
|
||||
|
||||
@ -524,6 +524,7 @@ public:
|
||||
m_mapLCID2DefCodePage.insert(std::make_pair(0x40E, 1250));
|
||||
m_mapLCID2DefCodePage.insert(std::make_pair(0x40F, 1252));
|
||||
m_mapLCID2DefCodePage.insert(std::make_pair(0x410, 1252));
|
||||
m_mapLCID2DefCodePage.insert(std::make_pair(0x412, 949));
|
||||
m_mapLCID2DefCodePage.insert(std::make_pair(0x413, 1252));
|
||||
m_mapLCID2DefCodePage.insert(std::make_pair(0x414, 1252));
|
||||
m_mapLCID2DefCodePage.insert(std::make_pair(0x415, 1250));
|
||||
|
||||
@ -24,6 +24,8 @@ core_linux {
|
||||
SOURCES += $$PWD/src/FileTransporter_curl.cpp
|
||||
}
|
||||
core_mac {
|
||||
use_v8:DEFINES += OLD_MACOS_SYSTEM
|
||||
|
||||
OBJECTIVE_SOURCES += $$PWD/src/FileTransporter_mac.mm
|
||||
LIBS += -framework AppKit
|
||||
}
|
||||
|
||||
@ -49,323 +49,350 @@
|
||||
|
||||
namespace NSNetwork
|
||||
{
|
||||
namespace NSFileTransport
|
||||
{
|
||||
std::string wget_url_validate(const std::string& url)
|
||||
{
|
||||
std::string::size_type pos = 0;
|
||||
const char* url_ptr = url.c_str();
|
||||
while ('-' == *url_ptr++) // '\0' => break
|
||||
++pos;
|
||||
if (*url_ptr == '\0')
|
||||
return "";
|
||||
namespace NSFileTransport
|
||||
{
|
||||
std::string wget_url_validate(const std::string& url)
|
||||
{
|
||||
std::string::size_type pos = 0;
|
||||
const char* url_ptr = url.c_str();
|
||||
while ('-' == *url_ptr++) // '\0' => break
|
||||
++pos;
|
||||
if (*url_ptr == '\0')
|
||||
return "";
|
||||
|
||||
return url.substr(pos);
|
||||
}
|
||||
return url.substr(pos);
|
||||
}
|
||||
|
||||
int download_external(const std::wstring& sUrl, const std::wstring& sOutput, std::function<void(int)> func_onProgress = nullptr, std::function<bool(void)> func_checkAborted = nullptr)
|
||||
{
|
||||
pid_t pid;
|
||||
int nReturnCode = -1;
|
||||
std::string sUrlA = U_TO_UTF8(sUrl);
|
||||
//sUrlA =("\"" + sUrlA + "\"");
|
||||
std::string sOutputA = U_TO_UTF8(sOutput);
|
||||
//sOutputA =("\"" + sOutputA + "\"");
|
||||
int download_external(const std::wstring& sUrl, const std::wstring& sOutput, std::function<void(int)> func_onProgress = nullptr, std::function<bool(void)> func_checkAborted = nullptr)
|
||||
{
|
||||
pid_t pid;
|
||||
int nReturnCode = -1;
|
||||
std::string sUrlA = U_TO_UTF8(sUrl);
|
||||
//sUrlA =("\"" + sUrlA + "\"");
|
||||
std::string sOutputA = U_TO_UTF8(sOutput);
|
||||
//sOutputA =("\"" + sOutputA + "\"");
|
||||
|
||||
if (0 != nReturnCode && NSFile::CFileBinary::Exists(L"/usr/bin/curl"))
|
||||
{
|
||||
int pipefd[2];
|
||||
if(func_onProgress)
|
||||
pipe(pipefd);
|
||||
std::wstring sCurlBin = L"";
|
||||
if (NSFile::CFileBinary::Exists(L"/usr/bin/curl"))
|
||||
sCurlBin = L"/usr/bin/curl";
|
||||
if (NSFile::CFileBinary::Exists(L"/usr/local/bin/curl"))
|
||||
sCurlBin = L"/usr/local/bin/curl";
|
||||
|
||||
pid = fork(); // create child process
|
||||
int status;
|
||||
if (0 != nReturnCode && !sCurlBin.empty())
|
||||
{
|
||||
int pipefd[2];
|
||||
if(func_onProgress)
|
||||
pipe(pipefd);
|
||||
|
||||
switch (pid)
|
||||
{
|
||||
case -1: // error
|
||||
break;
|
||||
pid = fork(); // create child process
|
||||
int status;
|
||||
|
||||
case 0: // child process
|
||||
{
|
||||
const char* nargs[10];
|
||||
nargs[0] = "/usr/bin/curl";
|
||||
nargs[1] = "--url";
|
||||
nargs[2] = sUrlA.c_str();
|
||||
nargs[3] = "--output";
|
||||
nargs[4] = sOutputA.c_str();
|
||||
func_onProgress == NULL ? nargs[5] = "--silent" : nargs[5] = "--progress-bar";
|
||||
nargs[6] = "-L";
|
||||
nargs[7] = "--connect-timeout";
|
||||
nargs[8] = "10";
|
||||
nargs[9] = NULL;
|
||||
switch (pid)
|
||||
{
|
||||
case -1: // error
|
||||
break;
|
||||
|
||||
const char* nenv[3];
|
||||
nenv[0] = "LD_PRELOAD=";
|
||||
nenv[1] = "LD_LIBRARY_PATH=";
|
||||
nenv[2] = NULL;
|
||||
case 0: // child process
|
||||
{
|
||||
std::string sProgramBinA = U_TO_UTF8(sCurlBin);
|
||||
|
||||
if(func_onProgress)
|
||||
{
|
||||
close(pipefd[0]); // close reading end in the child
|
||||
const char* nargs[10];
|
||||
nargs[0] = sProgramBinA.c_str();
|
||||
nargs[1] = "--url";
|
||||
nargs[2] = sUrlA.c_str();
|
||||
nargs[3] = "--output";
|
||||
nargs[4] = sOutputA.c_str();
|
||||
func_onProgress == NULL ? nargs[5] = "--silent" : nargs[5] = "--progress-bar";
|
||||
nargs[6] = "-L";
|
||||
nargs[7] = "--connect-timeout";
|
||||
nargs[8] = "10";
|
||||
nargs[9] = NULL;
|
||||
|
||||
dup2(pipefd[1], 1); // send stdout to the pipe
|
||||
dup2(pipefd[1], 2); // send stderr to the pipe
|
||||
const char* nenv[3];
|
||||
nenv[0] = "LD_PRELOAD=";
|
||||
nenv[1] = "LD_LIBRARY_PATH=";
|
||||
nenv[2] = NULL;
|
||||
|
||||
close(pipefd[1]); // this descriptor is no longer needed
|
||||
}
|
||||
if(func_onProgress)
|
||||
{
|
||||
close(pipefd[0]); // close reading end in the child
|
||||
|
||||
execve("/usr/bin/curl", (char * const *)nargs, (char * const *)nenv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
default: // parent process, pid now contains the child pid
|
||||
if(func_onProgress)
|
||||
{
|
||||
close(pipefd[1]);
|
||||
// close the write end of the pipe in the parent
|
||||
size_t size = 81;
|
||||
char buffer[size];
|
||||
std::string str;
|
||||
ssize_t res = 1;
|
||||
std::regex r(R"(\d+(?:\.\d+)?%)");
|
||||
std::smatch sm;
|
||||
std::string percentFull;
|
||||
std::string percent;
|
||||
int percentInt;
|
||||
dup2(pipefd[1], 1); // send stdout to the pipe
|
||||
dup2(pipefd[1], 2); // send stderr to the pipe
|
||||
|
||||
while (1)
|
||||
{
|
||||
if(func_checkAborted && func_checkAborted())
|
||||
{
|
||||
kill(pid, SIGTERM);
|
||||
//while (-1 == waitpid(pid, &status, 0)); // wait for child to complete
|
||||
return nReturnCode;
|
||||
}
|
||||
close(pipefd[1]); // this descriptor is no longer needed
|
||||
}
|
||||
|
||||
str.clear();
|
||||
res = read(pipefd[0], buffer, sizeof(buffer));
|
||||
execve(sProgramBinA.c_str(), (char * const *)nargs, (char * const *)nenv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
default: // parent process, pid now contains the child pid
|
||||
if(func_onProgress)
|
||||
{
|
||||
close(pipefd[1]);
|
||||
// close the write end of the pipe in the parent
|
||||
size_t size = 81;
|
||||
char buffer[size];
|
||||
std::string str;
|
||||
ssize_t res = 1;
|
||||
std::regex r(R"(\d+(?:\.\d+)?%)");
|
||||
std::smatch sm;
|
||||
std::string percentFull;
|
||||
std::string percent;
|
||||
int percentInt;
|
||||
|
||||
if(res == 0)
|
||||
break;
|
||||
while (1)
|
||||
{
|
||||
if(func_checkAborted && func_checkAborted())
|
||||
{
|
||||
kill(pid, SIGTERM);
|
||||
//while (-1 == waitpid(pid, &status, 0)); // wait for child to complete
|
||||
return nReturnCode;
|
||||
}
|
||||
|
||||
str.append(buffer);
|
||||
str.clear();
|
||||
res = read(pipefd[0], buffer, sizeof(buffer));
|
||||
|
||||
if(regex_search(str, sm, r))
|
||||
{
|
||||
percentFull = sm.str();
|
||||
percent = percentFull.substr(0, percentFull.find("."));
|
||||
percentInt = std::stoi(percent);
|
||||
if(res == 0)
|
||||
break;
|
||||
|
||||
if(percentInt >= 0 && percentInt <= 100)
|
||||
func_onProgress(percentInt);
|
||||
}
|
||||
str.append(buffer);
|
||||
|
||||
if(str.find("100.0%") != std::string::npos)
|
||||
break;
|
||||
if(regex_search(str, sm, r))
|
||||
{
|
||||
percentFull = sm.str();
|
||||
percent = percentFull.substr(0, percentFull.find("."));
|
||||
percentInt = std::stoi(percent);
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
int waitres;
|
||||
while (1) // wait for child to complete
|
||||
{
|
||||
if(func_checkAborted && func_checkAborted())
|
||||
{
|
||||
kill(pid, SIGTERM);
|
||||
return nReturnCode;
|
||||
}
|
||||
else if((waitres = waitpid(pid, &status, WNOHANG)) > 0)
|
||||
{
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
nReturnCode = WEXITSTATUS(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(percentInt >= 0 && percentInt <= 100)
|
||||
func_onProgress(percentInt);
|
||||
}
|
||||
|
||||
if (0 != nReturnCode && NSFile::CFileBinary::Exists(L"/usr/bin/wget"))
|
||||
{
|
||||
std::string sUrlValidateA = wget_url_validate(sUrlA);
|
||||
if(str.find("100.0%") != std::string::npos)
|
||||
break;
|
||||
|
||||
pid = fork(); // create child process
|
||||
int status;
|
||||
}
|
||||
}
|
||||
else {
|
||||
int waitres;
|
||||
while (1) // wait for child to complete
|
||||
{
|
||||
if(func_checkAborted && func_checkAborted())
|
||||
{
|
||||
kill(pid, SIGTERM);
|
||||
return nReturnCode;
|
||||
}
|
||||
else if((waitres = waitpid(pid, &status, WNOHANG)) > 0)
|
||||
{
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
nReturnCode = WEXITSTATUS(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (pid)
|
||||
{
|
||||
case -1: // error
|
||||
break;
|
||||
std::wstring sWgetBin = L"";
|
||||
if (NSFile::CFileBinary::Exists(L"/usr/bin/wget"))
|
||||
sWgetBin = L"/usr/bin/wget";
|
||||
if (NSFile::CFileBinary::Exists(L"/usr/local/bin/wget"))
|
||||
sWgetBin = L"/usr/local/bin/wget";
|
||||
|
||||
case 0: // child process
|
||||
{
|
||||
const char* nargs[8];
|
||||
nargs[0] = "/usr/bin/wget";
|
||||
nargs[1] = sUrlValidateA.c_str();
|
||||
nargs[2] = "-O";
|
||||
nargs[3] = sOutputA.c_str();
|
||||
nargs[4] = "-q";
|
||||
nargs[5] = "--connect-timeout=10";
|
||||
nargs[6] = "--tries=2";
|
||||
nargs[7] = NULL;
|
||||
if (0 != nReturnCode && !sWgetBin.empty())
|
||||
{
|
||||
std::string sUrlValidateA = wget_url_validate(sUrlA);
|
||||
|
||||
const char* nenv[2];
|
||||
nenv[0] = "LD_PRELOAD=";
|
||||
nenv[1] = NULL;
|
||||
pid = fork(); // create child process
|
||||
int status;
|
||||
|
||||
execve("/usr/bin/wget", (char * const *)nargs, (char * const *)nenv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
default: // parent process, pid now contains the child pid
|
||||
int waitres;
|
||||
while (1) // wait for child to complete
|
||||
{
|
||||
if(func_checkAborted && func_checkAborted())
|
||||
{
|
||||
kill(pid, SIGTERM);
|
||||
return nReturnCode;
|
||||
}
|
||||
else if((waitres = waitpid(pid, &status, WNOHANG)) > 0)
|
||||
{
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
nReturnCode = WEXITSTATUS(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (pid)
|
||||
{
|
||||
case -1: // error
|
||||
break;
|
||||
|
||||
if (0 == nReturnCode)
|
||||
{
|
||||
if (!NSFile::CFileBinary::Exists(sOutput))
|
||||
nReturnCode = -1;
|
||||
}
|
||||
case 0: // child process
|
||||
{
|
||||
std::string sProgramBinA = U_TO_UTF8(sWgetBin);
|
||||
|
||||
return nReturnCode;
|
||||
}
|
||||
#ifndef OLD_MACOS_SYSTEM
|
||||
const char* nargs[8];
|
||||
#else
|
||||
const char* nargs[9];
|
||||
#endif
|
||||
|
||||
int uploaddata_external(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize)
|
||||
{
|
||||
int nReturnCode = -1;
|
||||
NSFile::CFileBinary oFileData;
|
||||
std::wstring tempFileName = NSFile::CFileBinary::GetTempPath() + L"/tmpFileForUpload";
|
||||
oFileData.CreateFileW(tempFileName);
|
||||
oFileData.WriteFile(cData, nSize);
|
||||
oFileData.CloseFile();
|
||||
nargs[0] = sProgramBinA.c_str();
|
||||
nargs[1] = sUrlValidateA.c_str();
|
||||
nargs[2] = "-O";
|
||||
nargs[3] = sOutputA.c_str();
|
||||
nargs[4] = "-q";
|
||||
nargs[5] = "--connect-timeout=10";
|
||||
nargs[6] = "--tries=2";
|
||||
|
||||
std::string sUploadUrlA = U_TO_UTF8(sUploadUrl);
|
||||
#ifndef OLD_MACOS_SYSTEM
|
||||
nargs[7] = NULL;
|
||||
#else
|
||||
nargs[7] = "--no-check-certificate";
|
||||
nargs[8] = NULL;
|
||||
#endif
|
||||
|
||||
const char* nenv[2];
|
||||
nenv[0] = "LD_PRELOAD=";
|
||||
nenv[1] = NULL;
|
||||
|
||||
execve(sProgramBinA.c_str(), (char * const *)nargs, (char * const *)nenv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
default: // parent process, pid now contains the child pid
|
||||
int waitres;
|
||||
while (1) // wait for child to complete
|
||||
{
|
||||
if(func_checkAborted && func_checkAborted())
|
||||
{
|
||||
kill(pid, SIGTERM);
|
||||
return nReturnCode;
|
||||
}
|
||||
else if((waitres = waitpid(pid, &status, WNOHANG)) > 0)
|
||||
{
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
nReturnCode = WEXITSTATUS(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == nReturnCode)
|
||||
{
|
||||
if (!NSFile::CFileBinary::Exists(sOutput))
|
||||
nReturnCode = -1;
|
||||
}
|
||||
|
||||
return nReturnCode;
|
||||
}
|
||||
|
||||
int uploaddata_external(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize)
|
||||
{
|
||||
int nReturnCode = -1;
|
||||
NSFile::CFileBinary oFileData;
|
||||
std::wstring tempFileName = NSFile::CFileBinary::GetTempPath() + L"/tmpFileForUpload";
|
||||
oFileData.CreateFileW(tempFileName);
|
||||
oFileData.WriteFile(cData, nSize);
|
||||
oFileData.CloseFile();
|
||||
|
||||
std::string sUploadUrlA = U_TO_UTF8(sUploadUrl);
|
||||
|
||||
|
||||
if (0 != nReturnCode && NSFile::CFileBinary::Exists(L"/usr/bin/curl"))
|
||||
{
|
||||
pid_t pid = fork(); // create child process
|
||||
int status;
|
||||
if (0 != nReturnCode && NSFile::CFileBinary::Exists(L"/usr/bin/curl"))
|
||||
{
|
||||
pid_t pid = fork(); // create child process
|
||||
int status;
|
||||
|
||||
switch (pid)
|
||||
{
|
||||
case -1: // error
|
||||
break;
|
||||
switch (pid)
|
||||
{
|
||||
case -1: // error
|
||||
break;
|
||||
|
||||
case 0: // child process
|
||||
{
|
||||
//curl --request POST --data-binary "@template_entry.xml" $URL
|
||||
auto pathTofile(std::string("@") + std::string(tempFileName.begin(), tempFileName.end()));
|
||||
const char* nargs[9];
|
||||
nargs[0] = "/usr/bin/curl";
|
||||
nargs[1] = "--request";
|
||||
nargs[2] = "POST";
|
||||
nargs[3] = "--data-binary";
|
||||
nargs[4] = pathTofile.c_str();
|
||||
nargs[5] = sUploadUrlA.c_str();
|
||||
nargs[6] = "--connect-timeout";
|
||||
nargs[7] = "10";
|
||||
nargs[8] = NULL;
|
||||
case 0: // child process
|
||||
{
|
||||
//curl --request POST --data-binary "@template_entry.xml" $URL
|
||||
auto pathTofile(std::string("@") + std::string(tempFileName.begin(), tempFileName.end()));
|
||||
const char* nargs[9];
|
||||
nargs[0] = "/usr/bin/curl";
|
||||
nargs[1] = "--request";
|
||||
nargs[2] = "POST";
|
||||
nargs[3] = "--data-binary";
|
||||
nargs[4] = pathTofile.c_str();
|
||||
nargs[5] = sUploadUrlA.c_str();
|
||||
nargs[6] = "--connect-timeout";
|
||||
nargs[7] = "10";
|
||||
nargs[8] = NULL;
|
||||
|
||||
const char* nenv[3];
|
||||
nenv[0] = "LD_PRELOAD=";
|
||||
nenv[1] = "LD_LIBRARY_PATH=";
|
||||
nenv[2] = NULL;
|
||||
const char* nenv[3];
|
||||
nenv[0] = "LD_PRELOAD=";
|
||||
nenv[1] = "LD_LIBRARY_PATH=";
|
||||
nenv[2] = NULL;
|
||||
|
||||
execve("/usr/bin/curl", (char * const *)nargs, (char * const *)nenv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
default: // parent process, pid now contains the child pid
|
||||
while (-1 == waitpid(pid, &status, 0)); // wait for child to complete
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
nReturnCode = WEXITSTATUS(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
NSFile::CFileBinary::Remove(tempFileName);
|
||||
execve("/usr/bin/curl", (char * const *)nargs, (char * const *)nenv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
default: // parent process, pid now contains the child pid
|
||||
while (-1 == waitpid(pid, &status, 0)); // wait for child to complete
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
nReturnCode = WEXITSTATUS(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
NSFile::CFileBinary::Remove(tempFileName);
|
||||
|
||||
return nReturnCode;
|
||||
}
|
||||
return nReturnCode;
|
||||
}
|
||||
|
||||
int uploadfile_external(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath)
|
||||
{
|
||||
int nReturnCode = -1;
|
||||
int uploadfile_external(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath)
|
||||
{
|
||||
int nReturnCode = -1;
|
||||
|
||||
std::string sUploadUrlA = U_TO_UTF8(sUploadUrl);
|
||||
std::string sUploadFilePathA = U_TO_UTF8(sUploadFilePath);
|
||||
std::string sUploadFileNameA = U_TO_UTF8(NSFile::GetFileName(sUploadFilePath));
|
||||
std::string sUploadUrlA = U_TO_UTF8(sUploadUrl);
|
||||
std::string sUploadFilePathA = U_TO_UTF8(sUploadFilePath);
|
||||
std::string sUploadFileNameA = U_TO_UTF8(NSFile::GetFileName(sUploadFilePath));
|
||||
|
||||
if (0 != nReturnCode && NSFile::CFileBinary::Exists(L"/usr/bin/curl"))
|
||||
{
|
||||
pid_t pid = fork(); // create child process
|
||||
int status;
|
||||
if (0 != nReturnCode && NSFile::CFileBinary::Exists(L"/usr/bin/curl"))
|
||||
{
|
||||
pid_t pid = fork(); // create child process
|
||||
int status;
|
||||
|
||||
switch (pid)
|
||||
{
|
||||
case -1: // error
|
||||
break;
|
||||
switch (pid)
|
||||
{
|
||||
case -1: // error
|
||||
break;
|
||||
|
||||
case 0: // child process
|
||||
{
|
||||
//curl -v -F filename=image.jpg -F upload=@/home/vladimir/Pictures/Test.png $URL
|
||||
auto filename(std::string("filename=") + sUploadFileNameA);
|
||||
auto upload(std::string("upload=@") + sUploadFilePathA);
|
||||
const char* nargs[10];
|
||||
nargs[0] = "/usr/bin/curl";
|
||||
nargs[1] = "-v";
|
||||
nargs[2] = "-F";
|
||||
nargs[3] = filename.c_str();
|
||||
nargs[4] = "-F";
|
||||
nargs[5] = upload.c_str();
|
||||
nargs[6] = sUploadUrlA.c_str();
|
||||
nargs[7] = "--connect-timeout";
|
||||
nargs[8] = "10";
|
||||
nargs[9] = NULL;
|
||||
case 0: // child process
|
||||
{
|
||||
//curl -v -F filename=image.jpg -F upload=@/home/vladimir/Pictures/Test.png $URL
|
||||
auto filename(std::string("filename=") + sUploadFileNameA);
|
||||
auto upload(std::string("upload=@") + sUploadFilePathA);
|
||||
const char* nargs[10];
|
||||
nargs[0] = "/usr/bin/curl";
|
||||
nargs[1] = "-v";
|
||||
nargs[2] = "-F";
|
||||
nargs[3] = filename.c_str();
|
||||
nargs[4] = "-F";
|
||||
nargs[5] = upload.c_str();
|
||||
nargs[6] = sUploadUrlA.c_str();
|
||||
nargs[7] = "--connect-timeout";
|
||||
nargs[8] = "10";
|
||||
nargs[9] = NULL;
|
||||
|
||||
const char* nenv[3];
|
||||
nenv[0] = "LD_PRELOAD=";
|
||||
nenv[1] = "LD_LIBRARY_PATH=";
|
||||
nenv[2] = NULL;
|
||||
const char* nenv[3];
|
||||
nenv[0] = "LD_PRELOAD=";
|
||||
nenv[1] = "LD_LIBRARY_PATH=";
|
||||
nenv[2] = NULL;
|
||||
|
||||
execve("/usr/bin/curl", (char * const *)nargs, (char * const *)nenv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
default: // parent process, pid now contains the child pid
|
||||
while (-1 == waitpid(pid, &status, 0)); // wait for child to complete
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
nReturnCode = WEXITSTATUS(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
execve("/usr/bin/curl", (char * const *)nargs, (char * const *)nenv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
default: // parent process, pid now contains the child pid
|
||||
while (-1 == waitpid(pid, &status, 0)); // wait for child to complete
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
nReturnCode = WEXITSTATUS(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return nReturnCode;
|
||||
}
|
||||
}
|
||||
return nReturnCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -49,6 +49,7 @@ namespace NSNetwork
|
||||
virtual void send(const std::string& message) = 0;
|
||||
virtual void close() = 0;
|
||||
virtual void setUrl(const std::string& url) = 0;
|
||||
virtual bool setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax) { return false; }
|
||||
virtual ~IWebSocket() {}
|
||||
};
|
||||
|
||||
|
||||
@ -64,5 +64,11 @@ namespace NSNetwork
|
||||
{
|
||||
delete m_internal;
|
||||
}
|
||||
|
||||
bool CIOWebSocket::setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax)
|
||||
{
|
||||
m_internal->setReconnectInfo(attemtCount, delay, delayMax);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,6 +63,7 @@ namespace NSNetwork
|
||||
virtual void open(const std::map<std::string, std::string>& query) = 0;
|
||||
virtual void send(const std::string& message) = 0;
|
||||
virtual void close() = 0;
|
||||
virtual void setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax) = 0;
|
||||
};
|
||||
|
||||
class CIOWebSocket: public CWebWorkerBase
|
||||
@ -78,6 +79,7 @@ namespace NSNetwork
|
||||
virtual void open(const std::map<std::string, std::string>& query) override;
|
||||
virtual void send(const std::string& message) override;
|
||||
virtual void close() override;
|
||||
virtual bool setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax);
|
||||
|
||||
friend class CIOWebSocket_private;
|
||||
friend class CIOWebSocket_private_tls;
|
||||
|
||||
@ -230,6 +230,13 @@ namespace NSNetwork
|
||||
|
||||
m_socket.reset();
|
||||
}
|
||||
|
||||
virtual void setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax) override
|
||||
{
|
||||
m_socket->set_reconnect_attempts(attemtCount);
|
||||
m_socket->set_reconnect_delay(delay);
|
||||
m_socket->set_reconnect_delay_max(delayMax);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,6 +234,13 @@ namespace NSNetwork
|
||||
|
||||
m_socket.reset();
|
||||
}
|
||||
|
||||
virtual void setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax) override
|
||||
{
|
||||
m_socket->set_reconnect_attempts(attemtCount);
|
||||
m_socket->set_reconnect_delay(delay);
|
||||
m_socket->set_reconnect_delay_max(delayMax);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ libsocketio:CONFIG += use_openssl
|
||||
ixwebsocket:CONFIG += use_openssl
|
||||
|
||||
use_openssl {
|
||||
include($$PWD/../../3dParty/ixwebsocket/openssl.pri)
|
||||
include($$PWD/../../3dParty/openssl/openssl.pri)
|
||||
}
|
||||
|
||||
libsocketio {
|
||||
@ -59,7 +59,8 @@ libsocketio {
|
||||
_WEBSOCKETPP_CPP11_CHRONO_ \
|
||||
\
|
||||
"SIO_TLS=1" \
|
||||
"SIO_TLS_NO=0"
|
||||
"SIO_TLS_NO=0" \
|
||||
"PING_TIMEOUT_INTERVAL=20000"
|
||||
|
||||
include($$PWD/../../3dParty/boost/boost.pri)
|
||||
|
||||
@ -73,6 +74,11 @@ libsocketio {
|
||||
SOURCES += $$PWD/src/socketio/socketio_internal.cpp
|
||||
|
||||
core_linux:LIBS += -lpthread
|
||||
|
||||
core_windows {
|
||||
LIBS += -lcrypt32
|
||||
LIBS += -lUser32
|
||||
}
|
||||
}
|
||||
|
||||
HEADERS += \
|
||||
|
||||
@ -11,11 +11,19 @@ BUILD_NUMBER = $$(BUILD_NUMBER)
|
||||
|
||||
DEFINES += INTVER=$$VERSION
|
||||
|
||||
WIN_VERSION = $$replace(VERSION, \., ",")
|
||||
DEFINES += WIN_INTVER=$$WIN_VERSION
|
||||
|
||||
PUBLISHER_NAME = $$(PUBLISHER_NAME)
|
||||
isEmpty(PUBLISHER_NAME){
|
||||
PUBLISHER_NAME = $$cat(copyright.txt)
|
||||
}
|
||||
|
||||
APPLICATION_NAME_DEFAULT = $$(APPLICATION_NAME_DEFAULT)
|
||||
!isEmpty(APPLICATION_NAME_DEFAULT){
|
||||
DEFINES += "APPLICATION_NAME_DEFAULT=$${APPLICATION_NAME_DEFAULT}"
|
||||
}
|
||||
|
||||
OO_BUILD_BRANDING = $$(OO_BRANDING)
|
||||
OO_DESTDIR_BUILD_OVERRIDE = $$(DESTDIR_BUILD_OVERRIDE)
|
||||
|
||||
@ -31,6 +39,8 @@ win32 {
|
||||
CURRENT_YEAR = $$system(date +%Y)
|
||||
}
|
||||
|
||||
DEFINES += COPYRIGHT_YEAR=$${CURRENT_YEAR}
|
||||
|
||||
QMAKE_TARGET_COMPANY = $$PUBLISHER_NAME
|
||||
QMAKE_TARGET_COPYRIGHT = Copyright (C) $${PUBLISHER_NAME} $${CURRENT_YEAR}. All rights reserved
|
||||
|
||||
@ -137,7 +147,8 @@ mac {
|
||||
|
||||
gcc {
|
||||
COMPILER_VERSION = $$system($$QMAKE_CXX " -dumpversion")
|
||||
COMPILER_MAJOR_VERSION = $$str_member($$COMPILER_VERSION)
|
||||
COMPILER_MAJOR_VERSION_ARRAY = $$split(COMPILER_VERSION, ".")
|
||||
COMPILER_MAJOR_VERSION = $$member(COMPILER_MAJOR_VERSION_ARRAY, 0)
|
||||
lessThan(COMPILER_MAJOR_VERSION, 5): CONFIG += build_gcc_less_5
|
||||
lessThan(COMPILER_MAJOR_VERSION, 6): CONFIG += build_gcc_less_6
|
||||
}
|
||||
@ -387,28 +398,34 @@ core_static_link_libstd {
|
||||
message(core_static_link_libstd)
|
||||
}
|
||||
plugin {
|
||||
QMAKE_CXXFLAGS += -fvisibility=hidden
|
||||
QMAKE_CFLAGS += -fvisibility=hidden
|
||||
|
||||
TARGET_EXT = .so
|
||||
}
|
||||
}
|
||||
|
||||
core_mac {
|
||||
plugin {
|
||||
QMAKE_CXXFLAGS += -fvisibility=hidden
|
||||
QMAKE_CFLAGS += -fvisibility=hidden
|
||||
}
|
||||
}
|
||||
|
||||
core_windows {
|
||||
plugin {
|
||||
TARGET_EXT = .dll
|
||||
}
|
||||
}
|
||||
|
||||
core_disable_all_warnings {
|
||||
CONFIG += warn_off
|
||||
!core_windows {
|
||||
plugin:CONFIG += config_hidden_symbols
|
||||
staticlib:CONFIG += config_hidden_symbols
|
||||
}
|
||||
|
||||
config_hidden_symbols {
|
||||
QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
|
||||
QMAKE_CFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
|
||||
|
||||
core_mac:CONFIG += clang_no_exclude_libs
|
||||
core_ios:CONFIG += clang_no_exclude_libs
|
||||
|
||||
!clang_no_exclude_libs {
|
||||
plugin:QMAKE_LFLAGS += -Wl,--exclude-libs,ALL
|
||||
equals(TEMPLATE, app) {
|
||||
QMAKE_LFLAGS += -Wl,--exclude-libs,ALL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# BUILD_PATHS
|
||||
@ -545,3 +562,11 @@ defineTest(ADD_DEPENDENCY) {
|
||||
|
||||
ADD_INC_PATH = $$(ADDITIONAL_INCLUDE_PATH)
|
||||
!isEmpty(ADD_INC_PATH):INCLUDEPATH += $$ADD_INC_PATH
|
||||
|
||||
!core_enable_all_warnings {
|
||||
core_disable_all_warnings {
|
||||
QMAKE_CXXFLAGS_WARN_OFF = -w
|
||||
QMAKE_CFLAGS_WARN_OFF = -w
|
||||
CONFIG += warn_off
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,6 +68,9 @@ public:
|
||||
inline void close() override {
|
||||
std::fstream::close();
|
||||
}
|
||||
inline bool isError() override {
|
||||
return (std::fstream::bad() || std::fstream::fail());
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -48,6 +48,7 @@ namespace CFCPP
|
||||
virtual void write (const char* buffer, _INT64 len) = 0;
|
||||
virtual void flush() = 0;
|
||||
virtual void close() = 0;
|
||||
virtual bool isError() = 0;
|
||||
};
|
||||
|
||||
using Stream = std::shared_ptr<IStream>;
|
||||
|
||||
@ -67,9 +67,9 @@ std::shared_ptr<CFStorage> CompoundFile::RootStorage()
|
||||
{
|
||||
return _impl->RootStorage();
|
||||
}
|
||||
void CompoundFile::Save(std::wstring wFileName)
|
||||
bool CompoundFile::Save(std::wstring wFileName)
|
||||
{
|
||||
_impl->Save(wFileName);
|
||||
return _impl->Save(wFileName);
|
||||
}
|
||||
void CompoundFile::Save(Stream stream)
|
||||
{
|
||||
@ -316,15 +316,23 @@ void CompoundFile_impl::Load(Stream stream)
|
||||
}
|
||||
}
|
||||
|
||||
void CompoundFile_impl::Save(std::wstring wFileName)
|
||||
{
|
||||
if (isDisposed)
|
||||
throw CFException("Compound File closed: cannot save data");
|
||||
bool CompoundFile_impl::Save(std::wstring wFileName)
|
||||
{
|
||||
if (isDisposed)
|
||||
{
|
||||
//throw CFException("Compound File closed: cannot save data");
|
||||
return false;
|
||||
}
|
||||
|
||||
Stream file = OpenFileStream(wFileName, true, true);
|
||||
file->seek(0, std::ios::beg);
|
||||
|
||||
try
|
||||
if (!file) return false;
|
||||
if (file->isError()) return false;
|
||||
|
||||
file->seek(0, std::ios::beg);
|
||||
|
||||
bool result = true;
|
||||
try
|
||||
{
|
||||
Save(file);
|
||||
|
||||
@ -343,7 +351,9 @@ void CompoundFile_impl::Save(std::wstring wFileName)
|
||||
file->close();
|
||||
|
||||
throw CFException("Error saving file [" + fileName + "]", ex);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ public:
|
||||
|
||||
std::shared_ptr<CFStorage> RootStorage();
|
||||
|
||||
void Save(std::wstring wFileName);
|
||||
bool Save(std::wstring wFileName);
|
||||
void Save(Stream stream);
|
||||
|
||||
void Commit(bool releaseMemory = false);
|
||||
|
||||
@ -59,7 +59,7 @@ public:
|
||||
// Main methods
|
||||
std::shared_ptr<CFStorage> RootStorage();
|
||||
|
||||
void Save(std::wstring wFileName);
|
||||
bool Save(std::wstring wFileName);
|
||||
void Save(Stream stream);
|
||||
|
||||
void Commit(bool releaseMemory = false);
|
||||
|
||||
@ -123,6 +123,14 @@ void StreamView::close()
|
||||
if (std::dynamic_pointer_cast<std::iostream>(stream) != nullptr)
|
||||
stream->close();
|
||||
}
|
||||
bool StreamView::isError()
|
||||
{
|
||||
if (std::dynamic_pointer_cast<std::iostream>(stream) == nullptr) return true;
|
||||
if ((std::dynamic_pointer_cast<std::iostream>(stream))->bad()) return true;
|
||||
if ((std::dynamic_pointer_cast<std::iostream>(stream))->fail()) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
_INT64 StreamView::read(char *buffer, _INT64 len)
|
||||
{
|
||||
|
||||
@ -46,14 +46,13 @@ public:
|
||||
StreamView(const SVector<Sector> §orChain, _INT32 sectorSize, _INT64 length,
|
||||
SList<Sector> &availableSectors, Stream stream, bool isFatStream = false);
|
||||
|
||||
|
||||
_INT64 tell() override;
|
||||
_INT64 seek(_INT64 offset, std::ios_base::seekdir mode = std::ios::beg) override;
|
||||
_INT64 read(char *buffer, _INT64 count) override;
|
||||
void write(const char *buffer, _INT64 count) override;
|
||||
void flush() override {}
|
||||
void close() override;
|
||||
|
||||
bool isError() override;
|
||||
|
||||
_INT64 getPosition() const;
|
||||
void SetLength(_INT64 value);
|
||||
|
||||
@ -18,14 +18,7 @@ DEFINES += GRAPHICS_USE_DYNAMIC_LIBRARY
|
||||
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter)
|
||||
|
||||
core_windows {
|
||||
DEFINES += \
|
||||
JAS_WIN_MSVC_BUILD \
|
||||
WIN32
|
||||
|
||||
DEFINES -= UNICODE
|
||||
DEFINES -= _DEBUG
|
||||
|
||||
message(windows)
|
||||
|
||||
LIBS += -lAdvapi32
|
||||
LIBS += -lShell32
|
||||
|
||||
@ -1070,6 +1070,8 @@ namespace NSEditorApi
|
||||
js_wrapper<int> m_nInsertPageNum;
|
||||
|
||||
js_wrapper<CAscShadow> m_oShadow;
|
||||
|
||||
js_wrapper<int> m_nVerticalTextAlign;
|
||||
|
||||
public:
|
||||
CAscShapeProp()
|
||||
@ -1094,6 +1096,8 @@ namespace NSEditorApi
|
||||
LINK_PROPERTY_INT_JS(InsertPageNum)
|
||||
|
||||
LINK_PROPERTY_OBJECT_JS(CAscShadow, Shadow)
|
||||
|
||||
LINK_PROPERTY_INT_JS(VerticalTextAlign)
|
||||
};
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -414,8 +414,8 @@ int main(int argc, char** argv)
|
||||
NSStringUtils::CStringBuilder oBuilderJS;
|
||||
oBuilderJS.WriteString(L"[");
|
||||
|
||||
#define COUNT_FONTS_SCALE 5
|
||||
double support_scales[COUNT_FONTS_SCALE] = { 1, 1.25, 1.5, 1.75, 2 };
|
||||
#define COUNT_FONTS_SCALE 11
|
||||
double support_scales[COUNT_FONTS_SCALE] = { 1, 1.25, 1.5, 1.75, 2, 2.5, 3, 3.5, 4, 4.5, 5 };
|
||||
|
||||
int nThemeIndex = 0;
|
||||
for (std::vector<std::wstring>::iterator iter = arThemes.begin(); iter != arThemes.end(); iter++)
|
||||
|
||||
@ -230,11 +230,11 @@ namespace NSStringExt
|
||||
}
|
||||
static inline void ToLower(std::string& wsString)
|
||||
{
|
||||
std::transform(wsString.begin(), wsString.end(), wsString.begin(), ::towlower);
|
||||
std::transform(wsString.begin(), wsString.end(), wsString.begin(), ::tolower);
|
||||
}
|
||||
static inline void ToUpper(std::string& wsString)
|
||||
{
|
||||
std::transform(wsString.begin(), wsString.end(), wsString.begin(), ::towupper);
|
||||
std::transform(wsString.begin(), wsString.end(), wsString.begin(), ::toupper);
|
||||
}
|
||||
static inline void ToLower(std::wstring& wsString)
|
||||
{
|
||||
|
||||
@ -35,12 +35,23 @@
|
||||
#include <string>
|
||||
#include "../../Common/kernel_config.h"
|
||||
|
||||
#define VALUE_STRINGIFY(d) L##d
|
||||
#define VALUE_TO_STR(v) VALUE_STRINGIFY(v)
|
||||
|
||||
namespace NSSystemUtils
|
||||
{
|
||||
static const wchar_t* gc_EnvApplicationName = L"APPLICATION_NAME";
|
||||
#ifndef APPLICATION_NAME_DEFAULT
|
||||
static const wchar_t* gc_EnvApplicationNameDefault = L"ONLYOFFICE";
|
||||
#else
|
||||
static const wchar_t* gc_EnvApplicationNameDefault = VALUE_TO_STR(APPLICATION_NAME_DEFAULT);
|
||||
#endif
|
||||
static const wchar_t* gc_EnvCompanyName = L"COMPANY_NAME";
|
||||
#ifndef COMPANY_NAME_DEFAULT
|
||||
static const wchar_t* gc_EnvCompanyNameDefault = L"Ascensio System SIA Copyright (c) 2022";
|
||||
#else
|
||||
static const wchar_t* gc_EnvCompanyNameDefault = VALUE_TO_STR(COMPANY_NAME_DEFAULT);
|
||||
#endif
|
||||
static const wchar_t* gc_EnvMethodEncrypt = L"METHOD_CRYPT";
|
||||
static const wchar_t* gc_EnvMethodEncryptDefault = L"Strong";
|
||||
static const wchar_t* gc_EnvCreator = L"CREATOR";
|
||||
|
||||
@ -155,7 +155,7 @@ _TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c)
|
||||
return (memcmp(p1, p2, (size_t) c));
|
||||
}
|
||||
|
||||
#ifndef _IOS
|
||||
#if !defined(_IOS) && !defined(DISABLE_IMAGE_EXCEPTIONS)
|
||||
static void
|
||||
Win32WarningHandler(const char* module, const char* fmt, va_list ap)
|
||||
{
|
||||
|
||||
@ -5,18 +5,6 @@ TARGET = docbuilder
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
PRODUCT_VERSION=$$(PRODUCT_VERSION)
|
||||
BUILD_NUMBER=$$(BUILD_NUMBER)
|
||||
|
||||
isEmpty(PRODUCT_VERSION) {
|
||||
BINARYVERSION = 0.0.0.0
|
||||
}
|
||||
else {
|
||||
BINARYVERSION = $$(PRODUCT_VERSION).$$(BUILD_NUMBER)
|
||||
}
|
||||
|
||||
DEFINES += INTVER=$$BINARYVERSION
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../../core
|
||||
|
||||
@ -50,32 +50,32 @@ void parse_args(NSDoctRenderer::CDocBuilder* builder, int argc, wchar_t *argv[])
|
||||
void parse_args(NSDoctRenderer::CDocBuilder* builder, int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
#ifdef WIN32
|
||||
std::wstring sW(argv[i]);
|
||||
std::string sParam = U_TO_UTF8(sW);
|
||||
std::wstring sW(argv[i]);
|
||||
std::string sParam = U_TO_UTF8(sW);
|
||||
#else
|
||||
std::string sParam(argv[i]);
|
||||
std::string sParam(argv[i]);
|
||||
#endif
|
||||
|
||||
if (sParam.find("--") == 0)
|
||||
{
|
||||
std::string::size_type _pos = sParam.find('=');
|
||||
if (std::string::npos == _pos)
|
||||
builder->SetProperty(sParam.c_str(), L"");
|
||||
else
|
||||
{
|
||||
std::string sName = sParam.substr(0, _pos);
|
||||
std::string sValue = sParam.substr(_pos + 1);
|
||||
if (sParam.find("--") == 0)
|
||||
{
|
||||
std::string::size_type _pos = sParam.find('=');
|
||||
if (std::string::npos == _pos)
|
||||
builder->SetProperty(sParam.c_str(), L"");
|
||||
else
|
||||
{
|
||||
std::string sName = sParam.substr(0, _pos);
|
||||
std::string sValue = sParam.substr(_pos + 1);
|
||||
|
||||
std::wstring sValueW = UTF8_TO_U(sValue);
|
||||
builder->SetProperty(sName.c_str(), sValueW.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
std::wstring sValueW = UTF8_TO_U(sValue);
|
||||
builder->SetProperty(sName.c_str(), sValueW.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
@ -84,102 +84,84 @@ int wmain(int argc, wchar_t *argv[])
|
||||
int main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
if (argc <= 0)
|
||||
return 0;
|
||||
if (argc <= 0)
|
||||
return 0;
|
||||
|
||||
bool bIsHelp = false;
|
||||
bool bIsFonts = false;
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
bool bIsHelp = false;
|
||||
bool bIsFonts = false;
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
#ifdef WIN32
|
||||
std::wstring sW(argv[i]);
|
||||
std::string sParam(sW.begin(), sW.end());
|
||||
std::wstring sW(argv[i]);
|
||||
std::string sParam(sW.begin(), sW.end());
|
||||
#else
|
||||
std::string sParam(argv[i]);
|
||||
std::string sParam(argv[i]);
|
||||
#endif
|
||||
if (sParam == "-v" || sParam == "-version")
|
||||
{
|
||||
std::cout << "v" VALUE(INTVER) << std::endl;
|
||||
NSDoctRenderer::CDocBuilder oBuilder;
|
||||
oBuilder.ExecuteCommand(L"checkL");
|
||||
if (sParam == "-v" || sParam == "-version")
|
||||
{
|
||||
std::cout << "v" VALUE(INTVER) << std::endl;
|
||||
NSDoctRenderer::CDocBuilder oBuilder;
|
||||
oBuilder.ExecuteCommand(L"checkL");
|
||||
|
||||
char* sSdkVer = oBuilder.GetVersion();
|
||||
if (NULL != sSdkVer)
|
||||
{
|
||||
std::string sSdkVerStd(sSdkVer);
|
||||
std::cout << "sdk version: " << sSdkVerStd << std::endl;
|
||||
delete [] sSdkVer;
|
||||
}
|
||||
char* sSdkVer = oBuilder.GetVersion();
|
||||
if (NULL != sSdkVer)
|
||||
{
|
||||
std::string sSdkVerStd(sSdkVer);
|
||||
std::cout << "sdk version: " << sSdkVerStd << std::endl;
|
||||
delete [] sSdkVer;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
if (sParam == "-h" || sParam == "-help")
|
||||
{
|
||||
bIsHelp = true;
|
||||
}
|
||||
else if (sParam == "-f" || sParam == "-fonts")
|
||||
{
|
||||
bIsFonts = true;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (sParam == "-h" || sParam == "-help")
|
||||
{
|
||||
bIsHelp = true;
|
||||
}
|
||||
else if (sParam == "-f" || sParam == "-fonts")
|
||||
{
|
||||
bIsFonts = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (bIsFonts)
|
||||
{
|
||||
NSDoctRenderer::CDocBuilder oBuilder;
|
||||
parse_args(&oBuilder, argc, argv);
|
||||
if (bIsFonts)
|
||||
{
|
||||
NSDoctRenderer::CDocBuilder oBuilder;
|
||||
parse_args(&oBuilder, argc, argv);
|
||||
|
||||
oBuilder.ExecuteCommand(L"checkL");
|
||||
return 0;
|
||||
}
|
||||
oBuilder.ExecuteCommand(L"checkL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc < 2 || bIsHelp)
|
||||
{
|
||||
std::cout << "USAGE: documentbuilder \"path_to_script_file\"" << std::endl;
|
||||
NSDoctRenderer::CDocBuilder oBuilder;
|
||||
oBuilder.ExecuteCommand(L"checkL");
|
||||
return 0;
|
||||
}
|
||||
if (argc < 2 || bIsHelp)
|
||||
{
|
||||
std::cout << "USAGE: documentbuilder \"path_to_script_file\"" << std::endl;
|
||||
NSDoctRenderer::CDocBuilder oBuilder;
|
||||
oBuilder.ExecuteCommand(L"checkL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
std::wstring sBuildFile(argv[argc - 1]);
|
||||
std::wstring sBuildFile(argv[argc - 1]);
|
||||
#else
|
||||
std::string sBuildFileA(argv[argc - 1]);
|
||||
std::wstring sBuildFile = UTF8_TO_U(sBuildFileA);
|
||||
std::string sBuildFileA(argv[argc - 1]);
|
||||
std::wstring sBuildFile = UTF8_TO_U(sBuildFileA);
|
||||
#endif
|
||||
|
||||
if (true)
|
||||
{
|
||||
NSDoctRenderer::CDocBuilder::Initialize(L"/home/mihail/main/build_tools/out/linux_64/onlyoffice/documentbuilder");
|
||||
NSDoctRenderer::CDocBuilder oBuilder;
|
||||
if (true)
|
||||
{
|
||||
NSDoctRenderer::CDocBuilder oBuilder;
|
||||
|
||||
// если отключена эта опция - то она отключится на parse_args
|
||||
// если отключена эта опция - то она отключится на parse_args
|
||||
oBuilder.SetProperty("--check-fonts", L"");
|
||||
oBuilder.SetProperty("--cache-scripts", L"false");
|
||||
oBuilder.SetTmpFolder(L"tmp");
|
||||
|
||||
//oBuilder.SetProperty("--use-doctrenderer-scheme", L"");
|
||||
//oBuilder.SetProperty("--work-directory", L"builder");
|
||||
|
||||
parse_args(&oBuilder, argc - 1, argv);
|
||||
parse_args(&oBuilder, argc - 1, argv);
|
||||
|
||||
// oBuilder.WriteData(L"result.log", L"Alert!", false);
|
||||
|
||||
// формируем документ SampleTetxt2.docx - с одним вырезанным из SampleDocument.docx абзаца
|
||||
oBuilder.Run(sBuildFile.c_str());
|
||||
// включаем вторую схему сохранения
|
||||
oBuilder.SetProperty("--use-doctrenderer-scheme", L"");
|
||||
// перекрашиваем абзац в красный цвет
|
||||
oBuilder.Run(L"/home/mihail/script2.docbuilder");
|
||||
// oBuilder.OpenFile(L"SampleText2.docx", L"");
|
||||
// oBuilder.ExecuteCommand(L"var oParagraph = Api.GetDocument().GetElement(1);\n"
|
||||
// L"oParagraph.SetColor(255, 0, 0);\n"
|
||||
// L"\n");
|
||||
// // сохраняем
|
||||
// oBuilder.SaveFile(OFFICESTUDIO_FILE_DOCUMENT_DOCX, L"SampleText2.docx");
|
||||
// oBuilder.CloseFile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NSDoctRenderer::CDocBuilder::Dispose();
|
||||
return 0;
|
||||
NSDoctRenderer::CDocBuilder::Dispose();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1,14 +1,17 @@
|
||||
#ifndef VERSION_H
|
||||
#define VERSION_H
|
||||
|
||||
#define VER_FILEVERSION 1,0,0,2
|
||||
#define VER_FILEVERSION_STR "1.0.0.2\0"
|
||||
#define VER_STRINGIFY(d) #d
|
||||
#define TO_STR(v) VER_STRINGIFY(v)
|
||||
|
||||
#define VER_FILEVERSION WIN_INTVER
|
||||
#define VER_FILEVERSION_STR TO_STR(WIN_INTVER)"\0"
|
||||
|
||||
#define VER_PRODUCTVERSION VER_FILEVERSION
|
||||
#define VER_PRODUCTVERSION_STR "1.0\0"
|
||||
|
||||
#define VER_COMPANYNAME_STR "Ascensio System SIA\0"
|
||||
#define VER_LEGALCOPYRIGHT_STR "Ascensio System SIA 2016\0"
|
||||
#define VER_LEGALCOPYRIGHT_STR "Ascensio System SIA " TO_STR(COPYRIGHT_YEAR) "\0"
|
||||
#define VER_COMPANYDOMAIN_STR "www.onlyoffice.com\0"
|
||||
#define ABOUT_COPYRIGHT_STR VER_LEGALCOPYRIGHT_STR
|
||||
|
||||
|
||||
@ -33,6 +33,15 @@
|
||||
#ifndef _BUILDER_COMMON_H
|
||||
#define _BUILDER_COMMON_H
|
||||
|
||||
#include "./../common/base_export.h"
|
||||
#ifdef DOCTRENDERER_NO_USE_DYNAMIC_LIBRARY
|
||||
#define BUILDER_DECL
|
||||
#else
|
||||
#include "../common/base_export.h"
|
||||
#ifdef DOCTRENDERER_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
#define BUILDER_DECL Q_DECL_EXPORT
|
||||
#else
|
||||
#define BUILDER_DECL Q_DECL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // _BUILDER_COMMON_H
|
||||
#endif // _BUILDER_COMMON_H
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#define OFFICESTUDIO_FILE_DOCUMENT_TXT OFFICESTUDIO_FILE_DOCUMENT + 0x0005
|
||||
#define OFFICESTUDIO_FILE_DOCUMENT_DOTX OFFICESTUDIO_FILE_DOCUMENT + 0x000c
|
||||
#define OFFICESTUDIO_FILE_DOCUMENT_OTT OFFICESTUDIO_FILE_DOCUMENT + 0x000f
|
||||
#define OFFICESTUDIO_FILE_DOCUMENT_HTML OFFICESTUDIO_FILE_DOCUMENT + 0x0012
|
||||
|
||||
#define OFFICESTUDIO_FILE_PRESENTATION 0x0080
|
||||
#define OFFICESTUDIO_FILE_PRESENTATION_PPTX OFFICESTUDIO_FILE_PRESENTATION + 0x0001
|
||||
|
||||
@ -114,6 +114,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
}
|
||||
|
||||
bool bIsAbsoluteFontsPath = false;
|
||||
if (!m_bIsNotUseConfigAllFontsDir)
|
||||
{
|
||||
std::wstring sAllFontsPath = oNode.ReadNodeText(L"allfonts");
|
||||
@ -129,7 +130,11 @@ namespace NSDoctRenderer
|
||||
{
|
||||
std::wstring sAppDir = NSSystemUtils::GetAppDataDir();
|
||||
if (NSDirectory::CreateDirectory(sAppDir + L"/docbuilder"))
|
||||
{
|
||||
m_strAllFonts = sAppDir + L"/docbuilder/AllFonts.js";
|
||||
// файл может не существовать пока - и тогда private_GetFile не учтет его
|
||||
bIsAbsoluteFontsPath = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -138,7 +143,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
}
|
||||
}
|
||||
m_arrFiles.push_back(private_GetFile(sConfigDir, m_strAllFonts));
|
||||
m_arrFiles.push_back(bIsAbsoluteFontsPath ? m_strAllFonts : private_GetFile(sConfigDir, m_strAllFonts));
|
||||
}
|
||||
|
||||
std::wstring sSdkPath = oNode.ReadNodeText(L"sdkjs");
|
||||
|
||||
@ -60,11 +60,11 @@ BEGIN
|
||||
BEGIN
|
||||
BLOCK "040904e4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Ascensio System SIA 2022"
|
||||
VALUE "CompanyName", "Ascensio System SIA 2023"
|
||||
VALUE "FileDescription", "ONLYOFFICE docbuilder ActiveX DLL"
|
||||
VALUE "FileVersion", "1.0.0.1"
|
||||
VALUE "InternalName", "docbuilder.com.dll"
|
||||
VALUE "LegalCopyright", "Copyright (C) Ascensio System SIA 2022. All rights reserved."
|
||||
VALUE "LegalCopyright", "Copyright (C) Ascensio System SIA 2023. All rights reserved."
|
||||
VALUE "OriginalFilename", "docbuilder.com.dll"
|
||||
VALUE "ProductName", "docbuilder.com"
|
||||
VALUE "ProductVersion", "1.0.0.1"
|
||||
|
||||
@ -787,14 +787,7 @@ public:
|
||||
if (NULL == m_pBuilder)
|
||||
return S_FALSE;
|
||||
|
||||
int nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
|
||||
CStringW sType = (CString)type;
|
||||
if (L"pptx" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX;
|
||||
else if (L"xlsx" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
|
||||
|
||||
bool bRet = m_pBuilder->CreateFile(nType);
|
||||
bool bRet = m_pBuilder->CreateFile(type);
|
||||
*result = bRet ? VARIANT_TRUE : VARIANT_FALSE;
|
||||
return S_OK;
|
||||
}
|
||||
@ -811,41 +804,8 @@ public:
|
||||
if (NULL == m_pBuilder)
|
||||
return S_FALSE;
|
||||
|
||||
int nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
|
||||
CStringW sType = (CString)type;
|
||||
if (L"docx" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
|
||||
else if (L"doc" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC;
|
||||
else if (L"odt" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT;
|
||||
else if (L"rtf" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF;
|
||||
else if (L"txt" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT;
|
||||
else if (L"pptx" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX;
|
||||
else if (L"odp" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP;
|
||||
else if (L"xlsx" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
|
||||
else if (L"xls" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS;
|
||||
else if (L"ods" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS;
|
||||
else if (L"csv" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
|
||||
else if (L"pdf" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF;
|
||||
else if (L"image" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_IMAGE;
|
||||
else if (L"jpg" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_IMAGE;
|
||||
else if (L"png" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_IMAGE;
|
||||
|
||||
bool bRet = m_pBuilder->SaveFile(nType, path);
|
||||
*result = bRet ? VARIANT_TRUE : VARIANT_FALSE;
|
||||
int nRet = m_pBuilder->SaveFile(type, path);
|
||||
*result = (nRet == 0) ? VARIANT_TRUE : VARIANT_FALSE;
|
||||
return S_OK;
|
||||
}
|
||||
STDMETHOD(CloseFile)()
|
||||
|
||||
255
DesktopEditor/doctrenderer/docbuilder.com/src/docbuilder_midl.h
Normal file
255
DesktopEditor/doctrenderer/docbuilder.com/src/docbuilder_midl.h
Normal file
@ -0,0 +1,255 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error "C++ compiler required"
|
||||
#endif
|
||||
|
||||
#include "rpc.h"
|
||||
#include "rpcndr.h"
|
||||
|
||||
#ifdef CreateFile
|
||||
#undef CreateFile
|
||||
#endif
|
||||
|
||||
/* Forward Declarations */
|
||||
typedef interface IONLYOFFICEDocBuilderValue IONLYOFFICEDocBuilderValue;
|
||||
typedef interface IONLYOFFICEDocBuilderContextScope IONLYOFFICEDocBuilderContextScope;
|
||||
typedef interface IONLYOFFICEDocBuilderContext IONLYOFFICEDocBuilderContext;
|
||||
typedef interface IONLYOFFICEDocBuilder IONLYOFFICEDocBuilder;
|
||||
|
||||
typedef class CONLYOFFICEDocBuilderValue CONLYOFFICEDocBuilderValue;
|
||||
typedef class CONLYOFFICEDocBuilderContextScope CONLYOFFICEDocBuilderContextScope;
|
||||
typedef class CONLYOFFICEDocBuilderContext CONLYOFFICEDocBuilderContext;
|
||||
typedef class CONLYOFFICEDocBuilder CONLYOFFICEDocBuilder;
|
||||
|
||||
MIDL_INTERFACE("2637FDFA-8473-4CB8-B90B-C23CB949D009")
|
||||
IONLYOFFICEDocBuilderValue : public IDispatch
|
||||
{
|
||||
public:
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateInstance(
|
||||
/* [optional][in] */ VARIANT value) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsEmpty(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Clear( void) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsNull(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsUndefined(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsBool(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsInt(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsDouble(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsString(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsFunction(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsObject(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsArray(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsTypedArray(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetLength(
|
||||
/* [retval][out] */ long *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE ToBool(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE ToInt(
|
||||
/* [retval][out] */ long *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE ToDouble(
|
||||
/* [retval][out] */ double *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE ToString(
|
||||
/* [retval][out] */ BSTR *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetProperty(
|
||||
/* [in] */ BSTR name,
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Get(
|
||||
/* [in] */ long index,
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetProperty(
|
||||
/* [in] */ BSTR name,
|
||||
/* [in] */ IONLYOFFICEDocBuilderValue *value) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Set(
|
||||
/* [in] */ long index,
|
||||
/* [in] */ IONLYOFFICEDocBuilderValue *value) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Call(
|
||||
/* [in] */ BSTR name,
|
||||
/* [optional][in] */ VARIANT val1,
|
||||
/* [optional][in] */ VARIANT val2,
|
||||
/* [optional][in] */ VARIANT val3,
|
||||
/* [optional][in] */ VARIANT val4,
|
||||
/* [optional][in] */ VARIANT val5,
|
||||
/* [optional][in] */ VARIANT val6,
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
};
|
||||
|
||||
MIDL_INTERFACE("656ae95c-ae91-4dc0-88bf-0b770fc2d552")
|
||||
IONLYOFFICEDocBuilderContextScope : public IDispatch
|
||||
{
|
||||
public:
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Close( void) = 0;
|
||||
|
||||
};
|
||||
|
||||
MIDL_INTERFACE("0416975a-65c3-4015-85e4-55d9dafec5fc")
|
||||
IONLYOFFICEDocBuilderContext : public IDispatch
|
||||
{
|
||||
public:
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateUndefined(
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateNull(
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateObject(
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateArray(
|
||||
/* [in] */ long length,
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateTypedArray(
|
||||
/* [in] */ VARIANT buffer,
|
||||
/* [in] */ long length,
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetGlobal(
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateScope(
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderContextScope **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsError(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
};
|
||||
|
||||
MIDL_INTERFACE("0C07B7E7-86A4-42E1-8E42-2FA961992E0F")
|
||||
IONLYOFFICEDocBuilder : public IDispatch
|
||||
{
|
||||
public:
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateInstance( void) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE OpenFile(
|
||||
/* [in] */ BSTR path,
|
||||
/* [in] */ BSTR params,
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateFile(
|
||||
/* [in] */ BSTR type,
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetTmpFolder(
|
||||
/* [in] */ BSTR folder) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE SaveFile(
|
||||
/* [in] */ BSTR type,
|
||||
/* [in] */ BSTR path,
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CloseFile( void) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE ExecuteCommand(
|
||||
/* [in] */ BSTR command,
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Run(
|
||||
/* [in] */ BSTR path,
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE RunText(
|
||||
/* [in] */ BSTR commands,
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetProperty(
|
||||
/* [in] */ BSTR key,
|
||||
/* [in] */ BSTR value) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Execute(
|
||||
/* [in] */ BSTR command,
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE WriteData(
|
||||
/* [in] */ BSTR path,
|
||||
/* [in] */ BSTR value,
|
||||
/* [in] */ VARIANT_BOOL append) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsSaveWithDoctrendererMode(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetContext(
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderContext **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Initialize( void) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Dispose( void) = 0;
|
||||
|
||||
};
|
||||
|
||||
class DECLSPEC_UUID("85C41585-25D7-40F1-9CC6-FA17052650F4")
|
||||
CONLYOFFICEDocBuilderValue;
|
||||
|
||||
class DECLSPEC_UUID("c54e2b15-ff5b-45a2-aa15-89a02605c30c")
|
||||
CONLYOFFICEDocBuilderContextScope;
|
||||
|
||||
class DECLSPEC_UUID("299250bb-16c2-4ab4-8a49-a0c350d66bb5")
|
||||
CONLYOFFICEDocBuilderContext;
|
||||
|
||||
class DECLSPEC_UUID("9BF69F3C-1506-41B9-B8EE-2839948C02E9")
|
||||
CONLYOFFICEDocBuilder;
|
||||
@ -3,37 +3,25 @@
|
||||
#include <atlcomcli.h>
|
||||
#include <atlsafe.h>
|
||||
|
||||
#include "../../src/_docbuilder.h"
|
||||
#include "../../src/_docbuilder_i.c"
|
||||
#include "../../src/docbuilder_midl.h"
|
||||
|
||||
#ifdef _NATIVE_WCHAR_T_DEFINED
|
||||
# ifdef _DEBUG
|
||||
# pragma comment(lib, "comsuppwd.lib")
|
||||
# else
|
||||
#ifdef _UNICODE
|
||||
# pragma comment(lib, "comsuppw.lib")
|
||||
# endif
|
||||
#else
|
||||
# ifdef _DEBUG
|
||||
# pragma comment(lib, "comsuppd.lib")
|
||||
# else
|
||||
# pragma comment(lib, "comsupp.lib")
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#define RELEASEINTERFACE(pinterface)\
|
||||
{\
|
||||
if (pinterface!=NULL)\
|
||||
{\
|
||||
pinterface->Release();\
|
||||
pinterface=NULL;\
|
||||
}\
|
||||
#define RELEASEINTERFACE(pinterface) \
|
||||
{ \
|
||||
if (NULL != pinterface) \
|
||||
{ \
|
||||
pinterface->Release(); \
|
||||
pinterface = NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
wchar_t result_path[] = L"result.docx";
|
||||
CoInitialize(NULL);
|
||||
|
||||
IONLYOFFICEDocBuilder* oBuilder = NULL;
|
||||
@ -46,21 +34,18 @@ int main(int argc, char *argv[])
|
||||
IONLYOFFICEDocBuilderValue* oParagraph = NULL;
|
||||
IONLYOFFICEDocBuilderValue* oContent = NULL;
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
hr = CoCreateInstance(__uuidof(CONLYOFFICEDocBuilder), NULL, CLSCTX_ALL,
|
||||
__uuidof(IONLYOFFICEDocBuilder), (void**)&oBuilder);
|
||||
HRESULT hr = CoCreateInstance(__uuidof(CONLYOFFICEDocBuilder), NULL, CLSCTX_ALL, __uuidof(IONLYOFFICEDocBuilder), (void**)&oBuilder);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
std::cout << "Failed!" << std::endl;
|
||||
exit(1);
|
||||
CoUninitialize(); \
|
||||
return 1;
|
||||
}
|
||||
|
||||
VARIANT_BOOL b;
|
||||
|
||||
oBuilder->Initialize();
|
||||
oBuilder->CreateFileW(result_path, &b);
|
||||
oBuilder->CreateFile(_bstr_t("docx"), &b);
|
||||
oBuilder->GetContext(&oContext);
|
||||
|
||||
oContext->CreateScope(&oScope);
|
||||
@ -69,18 +54,17 @@ int main(int argc, char *argv[])
|
||||
oGlobal->GetProperty(_bstr_t("Api"), &oApi);
|
||||
oContext->CreateArray(1, &oContent);
|
||||
|
||||
oApi->Call(_bstr_t(L"GetDocument"), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), &oDocument);
|
||||
oApi->Call(_bstr_t(L"CreateParagraph"), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), &oParagraph);
|
||||
oApi->Call(_bstr_t("GetDocument"), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), &oDocument);
|
||||
oApi->Call(_bstr_t("CreateParagraph"), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), &oParagraph);
|
||||
oContext->CreateArray(1, &oContent);
|
||||
|
||||
|
||||
oParagraph->Call(_bstr_t(L"SetSpacingAfter"), ATL::CComVariant(1000), ATL::CComVariant(VARIANT_FALSE), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), NULL);
|
||||
oParagraph->Call(_bstr_t(L"AddText"), ATL::CComVariant(L"Hello from COM!"), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), NULL);
|
||||
oParagraph->Call(_bstr_t("SetSpacingAfter"), ATL::CComVariant(1000), ATL::CComVariant(VARIANT_FALSE), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), NULL);
|
||||
oParagraph->Call(_bstr_t("AddText"), ATL::CComVariant("Hello from COM!"), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), NULL);
|
||||
oContent->Set(0, oParagraph);
|
||||
|
||||
oDocument->Call(_bstr_t(L"InsertContent"), ATL::CComVariant(oContent), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), NULL);
|
||||
oDocument->Call(_bstr_t("InsertContent"), ATL::CComVariant(oContent), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), NULL);
|
||||
|
||||
oBuilder->SaveFile(_bstr_t(".docx"), result_path, &b);
|
||||
oBuilder->SaveFile(_bstr_t("docx"), _bstr_t("result.docx"), &b);
|
||||
|
||||
RELEASEINTERFACE(oContent);
|
||||
|
||||
|
||||
119
DesktopEditor/doctrenderer/docbuilder.com/test/cpp/main2.cpp
Normal file
119
DesktopEditor/doctrenderer/docbuilder.com/test/cpp/main2.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
#include <iostream>
|
||||
#include <comutil.h>
|
||||
#include <atlcomcli.h>
|
||||
#include <atlsafe.h>
|
||||
#include <string>
|
||||
|
||||
#include "../../src/docbuilder_midl.h"
|
||||
|
||||
#ifdef _UNICODE
|
||||
# pragma comment(lib, "comsuppw.lib")
|
||||
#else
|
||||
# pragma comment(lib, "comsupp.lib")
|
||||
#endif
|
||||
|
||||
#define RELEASEINTERFACE(pinterface) \
|
||||
{ \
|
||||
if (NULL != pinterface) \
|
||||
{ \
|
||||
pinterface->Release(); \
|
||||
pinterface = NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define EMPTY_PARAM ATL::CComVariant()
|
||||
#define _B(x) _bstr_t(L##x)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// uncomment for debug js
|
||||
//SetEnvironmentVariableA("V8_USE_INSPECTOR", "1");
|
||||
|
||||
CoInitialize(NULL);
|
||||
|
||||
IONLYOFFICEDocBuilder* pBuilder = NULL;
|
||||
if (FAILED(CoCreateInstance(__uuidof(CONLYOFFICEDocBuilder), NULL, CLSCTX_ALL, __uuidof(IONLYOFFICEDocBuilder), (void**)&pBuilder)))
|
||||
{
|
||||
CoUninitialize();
|
||||
return 1;
|
||||
}
|
||||
|
||||
VARIANT_BOOL bRes;
|
||||
pBuilder->Initialize();
|
||||
pBuilder->OpenFile(_B("file.docx"), _B(""), &bRes);
|
||||
//pBuilder->SaveFile(_B("html"), _B("D:/FILES/images.html"), &bRes);
|
||||
|
||||
IONLYOFFICEDocBuilderContext* pContext = NULL;
|
||||
pBuilder->GetContext(&pContext);
|
||||
|
||||
IONLYOFFICEDocBuilderContextScope* pScope = NULL;
|
||||
pContext->CreateScope(&pScope);
|
||||
|
||||
IONLYOFFICEDocBuilderValue* pGlobal = NULL;
|
||||
pContext->GetGlobal(&pGlobal);
|
||||
|
||||
IONLYOFFICEDocBuilderValue* pApi = NULL;
|
||||
pGlobal->GetProperty(_B("Api"), &pApi);
|
||||
IONLYOFFICEDocBuilderValue* pDocument = NULL;
|
||||
pApi->Call(_B("GetDocument"), EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, &pDocument);
|
||||
|
||||
IONLYOFFICEDocBuilderValue* pRanges = NULL;
|
||||
pDocument->Call(_B("Search"), ATL::CComVariant("year"), EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, &pRanges);
|
||||
|
||||
if (pRanges)
|
||||
{
|
||||
VARIANT_BOOL vbIsArray = VARIANT_FALSE;
|
||||
pRanges->IsArray(&vbIsArray);
|
||||
|
||||
if (VARIANT_TRUE == vbIsArray)
|
||||
{
|
||||
long nCount = 0;
|
||||
pRanges->GetLength(&nCount);
|
||||
|
||||
if (0 < nCount)
|
||||
{
|
||||
IONLYOFFICEDocBuilderValue* pSearchRange = NULL;
|
||||
pRanges->Get(0, &pSearchRange);
|
||||
|
||||
IONLYOFFICEDocBuilderValue* pComment = NULL;
|
||||
pSearchRange->Call(_B("AddComment"), ATL::CComVariant("Comment Text"), ATL::CComVariant("Author"),
|
||||
EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, &pComment);
|
||||
|
||||
IONLYOFFICEDocBuilderValue* pCommentID = NULL;
|
||||
pComment->Call(_B("GetId"), EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, &pCommentID);
|
||||
|
||||
// get comment id.
|
||||
// work with comment:
|
||||
// https://api.onlyoffice.com/docbuilder/textdocumentapi/apidocument/getcommentbyid
|
||||
// https://api.onlyoffice.com/docbuilder/textdocumentapi/apicomment
|
||||
|
||||
BSTR bsCommentId = NULL;
|
||||
pCommentID->ToString(&bsCommentId);
|
||||
SysFreeString(bsCommentId);
|
||||
|
||||
RELEASEINTERFACE(pCommentID);
|
||||
RELEASEINTERFACE(pComment);
|
||||
RELEASEINTERFACE(pSearchRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RELEASEINTERFACE(pRanges);
|
||||
RELEASEINTERFACE(pDocument);
|
||||
RELEASEINTERFACE(pApi);
|
||||
|
||||
RELEASEINTERFACE(pGlobal);
|
||||
RELEASEINTERFACE(pScope);
|
||||
RELEASEINTERFACE(pContext);
|
||||
|
||||
pBuilder->SaveFile(_B("docx"), _B("file.docx"), &bRes);
|
||||
|
||||
pBuilder->CloseFile();
|
||||
pBuilder->Dispose();
|
||||
|
||||
RELEASEINTERFACE(pBuilder);
|
||||
|
||||
CoUninitialize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -59,6 +59,10 @@ namespace NSDoctRenderer
|
||||
{
|
||||
return m_pInternal->SaveFile(type, path, params);
|
||||
}
|
||||
int CDocBuilder::SaveFile(const wchar_t* extension, const wchar_t* path, const wchar_t* params)
|
||||
{
|
||||
return m_pInternal->SaveFile(extension, path, params);
|
||||
}
|
||||
bool CDocBuilder::ExecuteCommand(const wchar_t* command, CDocBuilderValue* retValue)
|
||||
{
|
||||
return m_pInternal->ExecuteCommand(command, retValue);
|
||||
|
||||
@ -41,7 +41,7 @@ namespace NSDoctRenderer
|
||||
* The string class with the wchar_t* property.
|
||||
*/
|
||||
class CString_Private;
|
||||
class Q_DECL_EXPORT CString
|
||||
class BUILDER_DECL CString
|
||||
{
|
||||
public:
|
||||
CString();
|
||||
@ -61,7 +61,7 @@ namespace NSDoctRenderer
|
||||
* It represents a wrapper for a JS object.
|
||||
*/
|
||||
class CDocBuilderValue_Private;
|
||||
class Q_DECL_EXPORT CDocBuilderValue
|
||||
class BUILDER_DECL CDocBuilderValue
|
||||
{
|
||||
public:
|
||||
CDocBuilderValue();
|
||||
@ -238,7 +238,7 @@ namespace NSDoctRenderer
|
||||
* All opened scopes will be closed automatically when the builder CloseFile method is called.
|
||||
*/
|
||||
class CDocBuilderContextScope_Private;
|
||||
class Q_DECL_EXPORT CDocBuilderContextScope
|
||||
class BUILDER_DECL CDocBuilderContextScope
|
||||
{
|
||||
public:
|
||||
CDocBuilderContextScope();
|
||||
@ -261,7 +261,7 @@ namespace NSDoctRenderer
|
||||
* Class for getting JS context for working.
|
||||
*/
|
||||
class CDocBuilderContext_Private;
|
||||
class Q_DECL_EXPORT CDocBuilderContext
|
||||
class BUILDER_DECL CDocBuilderContext
|
||||
{
|
||||
public:
|
||||
CDocBuilderContext();
|
||||
@ -333,7 +333,7 @@ namespace NSDoctRenderer
|
||||
* Base class used by ONLYOFFICE Document Builder for the document file (text document, spreadsheet, presentation, form document, PDF) to be generated.
|
||||
*/
|
||||
class CDocBuilder_Private;
|
||||
class Q_DECL_EXPORT CDocBuilder
|
||||
class BUILDER_DECL CDocBuilder
|
||||
{
|
||||
public:
|
||||
CDocBuilder();
|
||||
@ -355,6 +355,7 @@ namespace NSDoctRenderer
|
||||
* @return True if the operation is successful
|
||||
*/
|
||||
bool CreateFile(const int& type);
|
||||
bool CreateFile(const wchar_t* extension);
|
||||
/**
|
||||
* Sets the path to the folder where the program will temporarily save files needed for the program correct work.
|
||||
* After the successful document file creation, all the files will be deleted from the folder. If no temporary folder is set, the system one will be used.
|
||||
@ -380,6 +381,7 @@ namespace NSDoctRenderer
|
||||
* @return Process x2t return code
|
||||
*/
|
||||
int SaveFile(const int& type, const wchar_t* path, const wchar_t* params = 0);
|
||||
int SaveFile(const wchar_t* extension, const wchar_t* path, const wchar_t* params = 0);
|
||||
/**
|
||||
* Closes the file to stop working with it. You can use a single ONLYOFFICE Document Builder instance
|
||||
* to work with all your files, but you need to close the previous file before you can
|
||||
|
||||
@ -49,7 +49,8 @@ namespace docbuilder_net
|
||||
RTF = MASK + 0x0004,
|
||||
TXT = MASK + 0x0005,
|
||||
DOTX = MASK + 0x000c,
|
||||
OTT = MASK + 0x000f
|
||||
OTT = MASK + 0x000f,
|
||||
HTML = MASK + 0x0012
|
||||
};
|
||||
|
||||
public enum class Spreadsheet : int
|
||||
|
||||
@ -71,7 +71,7 @@ BEGIN
|
||||
VALUE "FileDescription", "Document Builder .NET"
|
||||
VALUE "FileVersion", "1.0.0.1"
|
||||
VALUE "InternalName", "docbuilder.net"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2023"
|
||||
VALUE "LegalCopyright", "Copyright (C) Ascensio System SIA 2023. All rights reserved."
|
||||
VALUE "OriginalFilename", "docbuilder.net"
|
||||
VALUE "ProductName", "docbuilder.net"
|
||||
VALUE "ProductVersion", "1.0.0.1"
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{10124551-28B8-4CA0-8FBA-420CF9602CF3}</ProjectGuid>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
<RootNamespace>doctrendererwrapper</RootNamespace>
|
||||
<ProjectName>docbuilder.net</ProjectName>
|
||||
|
||||
@ -128,6 +128,69 @@ std::wstring CV8RealTimeWorker::GetJSVariable(std::wstring sParam)
|
||||
return L"jsValue(" + sParam + L")";
|
||||
}
|
||||
|
||||
std::string GetCorrectArgument(const std::string& sInput)
|
||||
{
|
||||
if (sInput.empty())
|
||||
return "{}";
|
||||
|
||||
const char* input = sInput.c_str();
|
||||
std::string::size_type len = sInput.length();
|
||||
|
||||
std::string sResult;
|
||||
sResult.reserve(len);
|
||||
|
||||
bool bIsInsideString = false;
|
||||
int nQouteMarkCounter = 0;
|
||||
for (std::string::size_type pos = 0; pos < len; ++pos)
|
||||
{
|
||||
char cur = input[pos];
|
||||
if (bIsInsideString)
|
||||
{
|
||||
if ('\\' == cur)
|
||||
++nQouteMarkCounter;
|
||||
else if ('\"' == cur)
|
||||
{
|
||||
if (nQouteMarkCounter & 1)
|
||||
{
|
||||
// внутренняя кавычка - ничего не делаем
|
||||
}
|
||||
else
|
||||
{
|
||||
bIsInsideString = false;
|
||||
nQouteMarkCounter = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nQouteMarkCounter = 0;
|
||||
}
|
||||
sResult += cur;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (cur)
|
||||
{
|
||||
case '\\':
|
||||
{
|
||||
while (pos < (len - 1) && isalpha(input[pos + 1]))
|
||||
++pos;
|
||||
break;
|
||||
}
|
||||
case '\n':
|
||||
case '\r':
|
||||
case '\t':
|
||||
break;
|
||||
case '\"':
|
||||
bIsInsideString = true;
|
||||
default:
|
||||
sResult += cur;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sResult;
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstring& path, const std::string& sString, const std::wstring& sCachePath, CV8Params* pParams)
|
||||
{
|
||||
LOGGER_SPEED_START();
|
||||
@ -145,9 +208,8 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri
|
||||
|
||||
if (true)
|
||||
{
|
||||
std::string sArg = m_sUtf8ArgumentJSON;
|
||||
if (sArg.empty())
|
||||
sArg = "{}";
|
||||
std::string sArg = GetCorrectArgument(m_sUtf8ArgumentJSON);
|
||||
|
||||
NSStringUtils::string_replaceA(sArg, "\\", "\\\\");
|
||||
NSStringUtils::string_replaceA(sArg, "\"", "\\\"");
|
||||
std::string sArgument = "var Argument = JSON.parse(\"" + sArg + "\");";
|
||||
@ -239,6 +301,8 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri
|
||||
bIsBreak = !this->ExecuteCommand(L"Api.asc_nativeInitBuilder();");
|
||||
if (!bIsBreak)
|
||||
bIsBreak = !this->ExecuteCommand(L"Api.asc_SetSilentMode(true);");
|
||||
if (!bIsBreak)
|
||||
bIsBreak = !this->ExecuteCommand(L"Api.asc_showComments();");
|
||||
|
||||
LOGGER_SPEED_LAP("open");
|
||||
|
||||
@ -252,8 +316,10 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
_formatDst = NSDoctRenderer::DoctRendererFormat::PPTT;
|
||||
else if (type & AVS_OFFICESTUDIO_FILE_SPREADSHEET)
|
||||
_formatDst = NSDoctRenderer::DoctRendererFormat::XLST;
|
||||
else if ((type & AVS_OFFICESTUDIO_FILE_CROSSPLATFORM) || (type & AVS_OFFICESTUDIO_FILE_IMAGE))
|
||||
else if (type & AVS_OFFICESTUDIO_FILE_CROSSPLATFORM)
|
||||
_formatDst = NSDoctRenderer::DoctRendererFormat::PDF;
|
||||
else if (type & AVS_OFFICESTUDIO_FILE_IMAGE)
|
||||
_formatDst = NSDoctRenderer::DoctRendererFormat::IMAGE;
|
||||
|
||||
CJSContextScope scope(m_context);
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
@ -278,7 +344,12 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
if (pNative == NULL)
|
||||
return false;
|
||||
|
||||
if (_formatDst == NSDoctRenderer::DoctRendererFormat::PDF)
|
||||
bool bIsSilentMode = false;
|
||||
if (_formatDst == NSDoctRenderer::DoctRendererFormat::PDF ||
|
||||
_formatDst == NSDoctRenderer::DoctRendererFormat::IMAGE)
|
||||
bIsSilentMode = true;
|
||||
|
||||
if (bIsSilentMode)
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(false);");
|
||||
|
||||
std::wstring strError;
|
||||
@ -290,7 +361,7 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
strError,
|
||||
sJsonParams);
|
||||
|
||||
if (_formatDst == NSDoctRenderer::DoctRendererFormat::PDF)
|
||||
if (bIsSilentMode)
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(true);");
|
||||
|
||||
return bIsError;
|
||||
@ -1104,6 +1175,19 @@ namespace NSDoctRenderer
|
||||
|
||||
return m_pInternal->CreateFile(type);
|
||||
}
|
||||
bool CDocBuilder::CreateFile(const wchar_t* extension)
|
||||
{
|
||||
std::wstring sType = (NULL != extension) ? std::wstring(extension) : L"docx";
|
||||
int type = AVS_OFFICESTUDIO_FILE_DOCUMENT;
|
||||
|
||||
if (L"pptx" == sType)
|
||||
type = AVS_OFFICESTUDIO_FILE_PRESENTATION;
|
||||
else if (L"xlsx" == sType)
|
||||
type = AVS_OFFICESTUDIO_FILE_SPREADSHEET;
|
||||
|
||||
return CreateFile(type);
|
||||
}
|
||||
|
||||
void CDocBuilder::SetTmpFolder(const wchar_t* folder)
|
||||
{
|
||||
if (m_pInternal->m_bIsServerSafeVersion)
|
||||
|
||||
@ -58,6 +58,7 @@
|
||||
#endif
|
||||
|
||||
#include "../fontengine/ApplicationFontsWorker.h"
|
||||
#include "../../OfficeUtils/src/OfficeUtils.h"
|
||||
|
||||
#ifdef CreateFile
|
||||
#undef CreateFile
|
||||
@ -1159,6 +1160,27 @@ namespace NSDoctRenderer
|
||||
}
|
||||
#endif
|
||||
|
||||
// html correct (TODO: move to x2t)
|
||||
if (0 == nReturnCode && type == AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML_IN_CONTAINER)
|
||||
{
|
||||
COfficeUtils oUtils;
|
||||
if (S_OK == oUtils.IsArchive(_path))
|
||||
{
|
||||
std::wstring sTmpFile = sDstTmpDir + L"/tmp_html";
|
||||
NSDirectory::CreateDirectory(sTmpFile);
|
||||
if (S_OK == oUtils.ExtractToDirectory(_path, sTmpFile, NULL, 0))
|
||||
{
|
||||
std::vector<std::wstring> arFiles = NSDirectory::GetFiles(sTmpFile);
|
||||
if (arFiles.size() == 1)
|
||||
{
|
||||
NSFile::CFileBinary::Remove(_path);
|
||||
NSFile::CFileBinary::Move(arFiles[0], _path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NSDirectory::DeleteDirectory(sDstTmpDir);
|
||||
NSFile::CFileBinary::Remove(sTempFileForParams);
|
||||
|
||||
@ -1202,6 +1224,45 @@ namespace NSDoctRenderer
|
||||
return true;
|
||||
}
|
||||
|
||||
int SaveFile(const std::wstring& ext, const std::wstring& path, const wchar_t* params = NULL)
|
||||
{
|
||||
int nType = -1;
|
||||
if (L"docx" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
|
||||
else if (L"doc" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC;
|
||||
else if (L"odt" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT;
|
||||
else if (L"rtf" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF;
|
||||
else if (L"txt" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT;
|
||||
else if (L"pptx" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX;
|
||||
else if (L"odp" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP;
|
||||
else if (L"xlsx" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
|
||||
else if (L"xls" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS;
|
||||
else if (L"ods" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS;
|
||||
else if (L"csv" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
|
||||
else if (L"pdf" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF;
|
||||
else if (L"image" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_IMAGE;
|
||||
else if (L"jpg" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_IMAGE;
|
||||
else if (L"png" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_IMAGE;
|
||||
else if (L"html" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML_IN_CONTAINER;
|
||||
|
||||
return SaveFile(nType, path, params);
|
||||
}
|
||||
|
||||
bool ExecuteCommand(const std::wstring& command, CDocBuilderValue* retValue = NULL)
|
||||
{
|
||||
if (command.length() < 7 && !retValue) // minimum command (!!!)
|
||||
|
||||
@ -391,6 +391,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
case DoctRendererFormat::PDF:
|
||||
case DoctRendererFormat::PPTX_THEME_THUMBNAIL:
|
||||
case DoctRendererFormat::IMAGE:
|
||||
{
|
||||
// CALCULATE
|
||||
if (pParams->m_sJsonParams.empty())
|
||||
@ -423,14 +424,28 @@ namespace NSDoctRenderer
|
||||
}
|
||||
|
||||
// RENDER
|
||||
if (!bIsBreak && DoctRendererFormat::PDF == pParams->m_eDstFormat)
|
||||
if (!bIsBreak &&
|
||||
(DoctRendererFormat::PDF == pParams->m_eDstFormat || DoctRendererFormat::IMAGE == pParams->m_eDstFormat))
|
||||
{
|
||||
if (pParams->m_sJsonParams.empty())
|
||||
args[0] = CJSContext::createNull();
|
||||
{
|
||||
if (DoctRendererFormat::IMAGE == pParams->m_eDstFormat)
|
||||
{
|
||||
args[0] = context->JSON_Parse("{ \"saveFormat\" : \"image\" }");
|
||||
}
|
||||
else
|
||||
args[0] = CJSContext::createNull();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string sTmp = U_TO_UTF8((pParams->m_sJsonParams));
|
||||
args[0] = context->JSON_Parse(sTmp.c_str());
|
||||
|
||||
if (DoctRendererFormat::IMAGE == pParams->m_eDstFormat)
|
||||
{
|
||||
JSSmart<CJSObject> argObj = args[0]->toObject();
|
||||
argObj->set("saveFormat", CJSContext::createString("image"));
|
||||
}
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> js_result2 = js_objectApi->call_func("asc_nativeGetPDF", 1, args);
|
||||
@ -886,6 +901,7 @@ namespace NSDoctRenderer
|
||||
{
|
||||
case DoctRendererFormat::DOCT:
|
||||
case DoctRendererFormat::PDF:
|
||||
case DoctRendererFormat::IMAGE:
|
||||
case DoctRendererFormat::HTML:
|
||||
{
|
||||
arSdkFiles = &m_pInternal->m_arDoctSDK;
|
||||
@ -903,6 +919,7 @@ namespace NSDoctRenderer
|
||||
{
|
||||
case DoctRendererFormat::PPTT:
|
||||
case DoctRendererFormat::PDF:
|
||||
case DoctRendererFormat::IMAGE:
|
||||
case DoctRendererFormat::PPTX_THEME_THUMBNAIL:
|
||||
{
|
||||
arSdkFiles = &m_pInternal->m_arPpttSDK;
|
||||
@ -920,6 +937,7 @@ namespace NSDoctRenderer
|
||||
{
|
||||
case DoctRendererFormat::XLST:
|
||||
case DoctRendererFormat::PDF:
|
||||
case DoctRendererFormat::IMAGE:
|
||||
{
|
||||
arSdkFiles = &m_pInternal->m_arXlstSDK;
|
||||
m_pInternal->m_strEditorType = L"spreadsheet";
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../common/base_export.h"
|
||||
#include "./common.h"
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
@ -48,6 +48,7 @@ namespace NSDoctRenderer
|
||||
PDF = 3,
|
||||
HTML = 4,
|
||||
PPTX_THEME_THUMBNAIL = 5,
|
||||
IMAGE = 6,
|
||||
|
||||
INVALID = 255
|
||||
};
|
||||
@ -57,7 +58,7 @@ namespace NSDoctRenderer
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
class CDoctRenderer_Private;
|
||||
class Q_DECL_EXPORT CDoctrenderer
|
||||
class BUILDER_DECL CDoctrenderer
|
||||
{
|
||||
public:
|
||||
CDoctrenderer(const std::wstring& sAllFontsPath = L"");
|
||||
|
||||
@ -12,21 +12,12 @@ CORE_ROOT_DIR = $$PWD/../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include(../../Common/base.pri)
|
||||
|
||||
DEFINES += DOCTRENDERER_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, kernel_network)
|
||||
|
||||
#CONFIG += build_xp
|
||||
core_android:DEFINES += DISABLE_MEMORY_LIMITATION
|
||||
|
||||
core_ios {
|
||||
CONFIG += doct_renderer_empty
|
||||
}
|
||||
core_android {
|
||||
DEFINES += DISABLE_MEMORY_LIMITATION
|
||||
CONFIG += doct_renderer_empty
|
||||
}
|
||||
|
||||
doct_renderer_empty {
|
||||
SOURCES += doctrenderer_empty.cpp
|
||||
} else {
|
||||
HEADERS += \
|
||||
config.h \
|
||||
doctrenderer.h \
|
||||
@ -37,7 +28,8 @@ SOURCES += \
|
||||
doctrenderer.cpp \
|
||||
docbuilder.cpp \
|
||||
docbuilder_p.cpp \
|
||||
graphics.cpp
|
||||
graphics.cpp \
|
||||
hash.cpp
|
||||
|
||||
SOURCES += \
|
||||
../../Common/OfficeFileFormatChecker2.cpp \
|
||||
@ -47,7 +39,8 @@ SOURCES += \
|
||||
HEADERS += \
|
||||
docbuilder_p.h \
|
||||
nativecontrol.h \
|
||||
graphics.h
|
||||
graphics.h \
|
||||
hash.h
|
||||
|
||||
HEADERS += \
|
||||
embed/PointerEmbed.h \
|
||||
@ -57,6 +50,7 @@ HEADERS += \
|
||||
embed/NativeControlEmbed.h \
|
||||
embed/NativeBuilderEmbed.h \
|
||||
embed/TextMeasurerEmbed.h \
|
||||
embed/HashEmbed.h \
|
||||
embed/Default.h \
|
||||
js_internal/js_base.h
|
||||
|
||||
@ -68,12 +62,9 @@ SOURCES += \
|
||||
embed/NativeControlEmbed.cpp \
|
||||
embed/NativeBuilderEmbed.cpp \
|
||||
embed/TextMeasurerEmbed.cpp \
|
||||
embed/HashEmbed.cpp \
|
||||
embed/Default.cpp
|
||||
|
||||
core_mac {
|
||||
!use_v8:CONFIG += use_javascript_core
|
||||
}
|
||||
|
||||
include($$PWD/js_internal/js_base.pri)
|
||||
|
||||
!use_javascript_core {
|
||||
@ -83,8 +74,9 @@ include($$PWD/js_internal/js_base.pri)
|
||||
embed/v8/v8_NativeBuilder.cpp \
|
||||
embed/v8/v8_Graphics.cpp \
|
||||
embed/v8/v8_Zip.cpp \
|
||||
embed/v8/v8_Pointer.cpp \
|
||||
embed/v8/v8_TextMeasurer.cpp
|
||||
embed/v8/v8_Pointer.cpp \
|
||||
embed/v8/v8_TextMeasurer.cpp \
|
||||
embed/v8/v8_Hash.cpp
|
||||
|
||||
build_xp:DESTDIR=$$DESTDIR/xp
|
||||
} else {
|
||||
@ -95,14 +87,15 @@ include($$PWD/js_internal/js_base.pri)
|
||||
embed/jsc/jsc_NativeControl.mm \
|
||||
embed/jsc/jsc_NativeBuilder.mm \
|
||||
embed/jsc/jsc_Zip.mm \
|
||||
embed/jsc/jsc_Pointer.mm \
|
||||
embed/jsc/jsc_TextMeasurer.mm
|
||||
embed/jsc/jsc_Pointer.mm \
|
||||
embed/jsc/jsc_TextMeasurer.mm \
|
||||
embed/jsc/jsc_Hash.mm
|
||||
|
||||
LIBS += -framework Foundation
|
||||
}
|
||||
}
|
||||
|
||||
include(../graphics/pro/textshaper.pri)
|
||||
include(../../Common/3dParty/openssl/openssl.pri)
|
||||
|
||||
# downloader
|
||||
DEFINES += BUIDLER_OPEN_DOWNLOAD_ENABLED
|
||||
|
||||
@ -1,195 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#include "doctrenderer.h"
|
||||
#include "docbuilder.h"
|
||||
|
||||
#ifdef BOOL
|
||||
#undef BOOL
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
CString::CString() {}
|
||||
CString::CString(const CString& src) {}
|
||||
CString& CString::operator=(const CString& src) { return *this; }
|
||||
wchar_t* CString::c_str() const { return NULL; }
|
||||
|
||||
CDocBuilderValue::CDocBuilderValue() {}
|
||||
CDocBuilderValue::CDocBuilderValue(const CDocBuilderValue& src) {}
|
||||
CDocBuilderValue& CDocBuilderValue::operator=(const CDocBuilderValue& src) { return *this; }
|
||||
CDocBuilderValue::~CDocBuilderValue() {}
|
||||
void* private_get_internal() { return NULL; }
|
||||
|
||||
bool CDocBuilderValue::IsEmpty() { return true; }
|
||||
void CDocBuilderValue::Clear() {}
|
||||
|
||||
bool CDocBuilderValue::IsNull() { return false; }
|
||||
bool CDocBuilderValue::IsUndefined() { return false; }
|
||||
bool CDocBuilderValue::IsBool() { return false; }
|
||||
bool CDocBuilderValue::IsInt() { return false; }
|
||||
bool CDocBuilderValue::IsDouble() { return false; }
|
||||
bool CDocBuilderValue::IsString() { return false; }
|
||||
bool CDocBuilderValue::IsFunction() { return false; }
|
||||
bool CDocBuilderValue::IsObject() { return false; }
|
||||
bool CDocBuilderValue::IsArray() { return false; }
|
||||
bool CDocBuilderValue::IsTypedArray() { return false; }
|
||||
|
||||
unsigned int CDocBuilderValue::GetLength() { return 0; }
|
||||
bool CDocBuilderValue::ToBool() { return false; }
|
||||
int CDocBuilderValue::ToInt() { return 0; }
|
||||
double CDocBuilderValue::ToDouble() { return 0; }
|
||||
CString CDocBuilderValue::ToString() { return CString(); }
|
||||
|
||||
CDocBuilderValue CDocBuilderValue::GetProperty(const wchar_t* name) { CDocBuilderValue ret; return ret; }
|
||||
|
||||
CDocBuilderValue CDocBuilderValue::Get(const char* name) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Get(const wchar_t* name) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::operator[](const char* name) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::operator[](const wchar_t* name) { CDocBuilderValue ret; return ret; }
|
||||
|
||||
CDocBuilderValue CDocBuilderValue::Get(const int& index) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::operator[](const int& index) { CDocBuilderValue ret; return ret; }
|
||||
|
||||
void CDocBuilderValue::SetProperty(const wchar_t* name, CDocBuilderValue value) {}
|
||||
void CDocBuilderValue::Set(const wchar_t* name, CDocBuilderValue value) {}
|
||||
void CDocBuilderValue::Set(const int& index, CDocBuilderValue value) {}
|
||||
|
||||
// primitives
|
||||
CDocBuilderValue::CDocBuilderValue(const bool& value) {}
|
||||
CDocBuilderValue::CDocBuilderValue(const int& value) {}
|
||||
CDocBuilderValue::CDocBuilderValue(const unsigned int& value) {}
|
||||
CDocBuilderValue::CDocBuilderValue(const double& value) {}
|
||||
CDocBuilderValue::CDocBuilderValue(const char* value) {}
|
||||
CDocBuilderValue::CDocBuilderValue(const wchar_t* value) {}
|
||||
|
||||
CDocBuilderValue CDocBuilderValue::CreateUndefined() { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::CreateNull() { CDocBuilderValue ret; return ret; }
|
||||
|
||||
CDocBuilderValue CDocBuilderValue::Call(const char* name) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1, CDocBuilderValue p2) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4, CDocBuilderValue p5) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4, CDocBuilderValue p5, CDocBuilderValue p6) { CDocBuilderValue ret; return ret; }
|
||||
|
||||
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1, CDocBuilderValue p2) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4, CDocBuilderValue p5) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4, CDocBuilderValue p5, CDocBuilderValue p6) { CDocBuilderValue ret; return ret; }
|
||||
|
||||
CDocBuilderContextScope::CDocBuilderContextScope() {}
|
||||
CDocBuilderContextScope::CDocBuilderContextScope(const CDocBuilderContextScope& src) {}
|
||||
CDocBuilderContextScope& CDocBuilderContextScope::operator=(const CDocBuilderContextScope& src) { return *this; }
|
||||
CDocBuilderContextScope::~CDocBuilderContextScope() {}
|
||||
void CDocBuilderContextScope::Close() {}
|
||||
|
||||
CDocBuilderContext::CDocBuilderContext() {}
|
||||
CDocBuilderContext::CDocBuilderContext(const CDocBuilderContext& src) {}
|
||||
CDocBuilderContext& CDocBuilderContext::operator=(const CDocBuilderContext& src) { return *this; }
|
||||
CDocBuilderContext::~CDocBuilderContext() {}
|
||||
|
||||
CDocBuilderValue CDocBuilderContext::CreateUndefined() { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderContext::CreateNull() { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderContext::CreateObject() { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderContext::CreateArray(const int& length) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderContext::CreateTypedArray(unsigned char* buffer, const int& length, const bool& externalize) { CDocBuilderValue ret; return ret; }
|
||||
|
||||
CDocBuilderValue CDocBuilderContext::GetGlobal() { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderContextScope CDocBuilderContext::CreateScope() { CDocBuilderContextScope ret; return ret; }
|
||||
bool CDocBuilderContext::IsError() { return true; }
|
||||
}
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
CDocBuilder::CDocBuilder() {}
|
||||
CDocBuilder::~CDocBuilder() {}
|
||||
|
||||
int CDocBuilder::OpenFile(const wchar_t* path, const wchar_t* params) { return 0; }
|
||||
bool CDocBuilder::CreateFile(const int& type) { return false; }
|
||||
void CDocBuilder::SetTmpFolder(const wchar_t* folder) {}
|
||||
int CDocBuilder::SaveFile(const int& type, const wchar_t* path, const wchar_t* params) { return 0; }
|
||||
void CDocBuilder::CloseFile() {}
|
||||
bool CDocBuilder::ExecuteCommand(const wchar_t* command, CDocBuilderValue* retValue) { return false; }
|
||||
|
||||
bool CDocBuilder::Run(const wchar_t* path) { return false; }
|
||||
|
||||
bool CDocBuilder::RunTextW(const wchar_t* commands) { return false; }
|
||||
bool CDocBuilder::RunTextA(const char* commands) { return false; }
|
||||
|
||||
void CDocBuilder::SetProperty(const char* param, const wchar_t* value) {}
|
||||
void CDocBuilder::SetPropertyW(const wchar_t* param, const wchar_t* value) {}
|
||||
|
||||
void CDocBuilder::WriteData(const wchar_t* path, const wchar_t* value, const bool& append) {}
|
||||
bool CDocBuilder::IsSaveWithDoctrendererMode() { return false; }
|
||||
|
||||
char* CDocBuilder::GetVersion() { return "0.0"; }
|
||||
|
||||
CDocBuilderContext CDocBuilder::GetContext()
|
||||
{
|
||||
return CDocBuilderContext();
|
||||
}
|
||||
|
||||
void CDocBuilder::Initialize(const wchar_t* directory) {}
|
||||
void CDocBuilder::Dispose() {}
|
||||
}
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
CDoctrenderer::CDoctrenderer(const std::wstring& sAllFontsPath) {}
|
||||
|
||||
CDoctrenderer::~CDoctrenderer() {}
|
||||
|
||||
void CDoctrenderer::LoadConfig(const std::wstring& sConfigDir, const std::wstring& sAllFontsPath)
|
||||
{
|
||||
}
|
||||
|
||||
bool CDoctrenderer::Execute(const std::wstring& strXml, std::wstring& strError)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::wstring> CDoctrenderer::GetImagesInChanges()
|
||||
{
|
||||
std::vector<std::wstring> stub;
|
||||
return stub;
|
||||
}
|
||||
|
||||
void CDoctrenderer::CreateCache(const std::wstring& sAllFontsPath, const std::wstring& sCacheDir)
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@
|
||||
#include "./ZipEmbed.h"
|
||||
#include "./TextMeasurerEmbed.h"
|
||||
#include "./MemoryStreamEmbed.h"
|
||||
#include "./HashEmbed.h"
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
@ -11,5 +12,6 @@ namespace NSJSBase
|
||||
CZipEmbed::CreateObjectInContext("CreateNativeZip", context);
|
||||
CTextMeasurerEmbed::CreateObjectInContext("CreateNativeTextMeasurer", context);
|
||||
CMemoryStreamEmbed::CreateObjectInContext("CreateNativeMemoryStream", context);
|
||||
CHashEmbed::CreateObjectInContext("CreateNativeHash", context);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
void Q_DECL_EXPORT CreateDefaults(JSSmart<CJSContext>& context);
|
||||
void JS_DECL CreateDefaults(JSSmart<CJSContext>& context);
|
||||
}
|
||||
|
||||
#endif // _BUILD_NATIVE_DEFAULT_EMBED_H_
|
||||
|
||||
20
DesktopEditor/doctrenderer/embed/HashEmbed.cpp
Normal file
20
DesktopEditor/doctrenderer/embed/HashEmbed.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include "HashEmbed.h"
|
||||
|
||||
JSSmart<CJSValue> CHashEmbed::hash(JSSmart<CJSValue> data, JSSmart<CJSValue> size, JSSmart<CJSValue> alg)
|
||||
{
|
||||
std::string _data = data->toStringA();
|
||||
int _size = size->toInt32();
|
||||
int _alg = alg->toInt32();
|
||||
unsigned char* pData = m_pHash->hash(reinterpret_cast<const unsigned char*>(_data.c_str()), _size, _alg);
|
||||
return CJSContext::createUint8Array(pData, CHash::getDigestLength(static_cast<CHash::HashAlgs>(_alg)), false);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CHashEmbed::hash2(JSSmart<CJSValue> password, JSSmart<CJSValue> salt, JSSmart<CJSValue> spinCount, JSSmart<CJSValue> alg)
|
||||
{
|
||||
std::string _password = password->toStringA();
|
||||
std::string _salt = salt->toStringA();
|
||||
int _spinCount = spinCount->toInt32();
|
||||
int _alg = alg->toInt32();
|
||||
unsigned char* pData = m_pHash->hash2(reinterpret_cast<const char*>(_password.c_str()), reinterpret_cast<const char*>(_salt.c_str()), _spinCount, _alg);
|
||||
return CJSContext::createUint8Array(pData, CHash::getDigestLength(static_cast<CHash::HashAlgs>(_alg)), false);
|
||||
}
|
||||
31
DesktopEditor/doctrenderer/embed/HashEmbed.h
Normal file
31
DesktopEditor/doctrenderer/embed/HashEmbed.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef _BUILD_NATIVE_HASH_EMBED_H_
|
||||
#define _BUILD_NATIVE_HASH_EMBED_H_
|
||||
|
||||
#include "../js_internal/js_base.h"
|
||||
#include "../hash.h"
|
||||
|
||||
using namespace NSJSBase;
|
||||
class CHashEmbed : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
CHash* m_pHash;
|
||||
|
||||
CHashEmbed() : m_pHash(new CHash(NSJSBase::NSAllocator::Alloc))
|
||||
{
|
||||
}
|
||||
|
||||
~CHashEmbed()
|
||||
{
|
||||
RELEASEOBJECT(m_pHash);
|
||||
}
|
||||
|
||||
virtual void* getObject() override { return (void*)m_pHash; }
|
||||
|
||||
JSSmart<CJSValue> hash(JSSmart<CJSValue> data, JSSmart<CJSValue> size, JSSmart<CJSValue> alg);
|
||||
JSSmart<CJSValue> hash2(JSSmart<CJSValue> password, JSSmart<CJSValue> salt, JSSmart<CJSValue> spinCount, JSSmart<CJSValue> alg);
|
||||
|
||||
public:
|
||||
static void CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context);
|
||||
};
|
||||
|
||||
#endif // _BUILD_NATIVE_HASH_EMBED_H_
|
||||
31
DesktopEditor/doctrenderer/embed/jsc/jsc_Hash.mm
Normal file
31
DesktopEditor/doctrenderer/embed/jsc/jsc_Hash.mm
Normal file
@ -0,0 +1,31 @@
|
||||
#include "../HashEmbed.h"
|
||||
#include "../../js_internal/jsc/jsc_base.h"
|
||||
|
||||
@protocol IJSCHash <JSExport>
|
||||
-(JSValue*) hash : (JSValue*)data : (JSValue*)size : (JSValue*)alg;
|
||||
-(JSValue*) hash2 : (JSValue*)password : (JSValue*)salt : (JSValue*)spinCount : (JSValue*)alg;
|
||||
|
||||
@end
|
||||
|
||||
@interface CJSCHash : NSObject<IJSCHash, JSEmbedObjectProtocol>
|
||||
{
|
||||
@public
|
||||
CHashEmbed* m_internal;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation CJSCHash
|
||||
|
||||
EMBED_OBJECT_WRAPPER_METHODS(CHashEmbed)
|
||||
|
||||
FUNCTION_WRAPPER_JS_3(hash, hash)
|
||||
FUNCTION_WRAPPER_JS_4(hash2, hash2)
|
||||
|
||||
@end
|
||||
|
||||
void CHashEmbed::CreateObjectInContext(const std::string &name, JSSmart<CJSContext> context)
|
||||
{
|
||||
context->m_internal->context[[NSString stringWithAString:name]] = ^(){
|
||||
return [[CJSCHash alloc] init];
|
||||
};
|
||||
}
|
||||
34
DesktopEditor/doctrenderer/embed/v8/v8_Hash.cpp
Normal file
34
DesktopEditor/doctrenderer/embed/v8/v8_Hash.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include "../HashEmbed.h"
|
||||
#include "../../js_internal/v8/v8_base.h"
|
||||
|
||||
namespace NSHash
|
||||
{
|
||||
#define CURRENTWRAPPER CHashEmbed
|
||||
|
||||
FUNCTION_WRAPPER_V8_3(_hash, hash)
|
||||
FUNCTION_WRAPPER_V8_4(_hash2, hash2)
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> CreateHashTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
v8::EscapableHandleScope handle_scope(isolate);
|
||||
|
||||
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(isolate);
|
||||
result->SetInternalFieldCount(1);
|
||||
|
||||
// methods
|
||||
NSV8Objects::Template_Set(result, "hash", _hash);
|
||||
NSV8Objects::Template_Set(result, "hash2", _hash2);
|
||||
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
|
||||
void CreateNativeHash(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
CreateNativeInternalField(new CHashEmbed(), NSHash::CreateHashTemplate, args);
|
||||
}
|
||||
}
|
||||
|
||||
void CHashEmbed::CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context)
|
||||
{
|
||||
InsertToGlobal(name, context, NSHash::CreateNativeHash);
|
||||
}
|
||||
402
DesktopEditor/doctrenderer/hash.cpp
Normal file
402
DesktopEditor/doctrenderer/hash.cpp
Normal file
@ -0,0 +1,402 @@
|
||||
#include "hash.h"
|
||||
|
||||
#ifndef OWN_BASE_64
|
||||
#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 <cstring>
|
||||
#include <memory>
|
||||
#include <stdlib.h>
|
||||
|
||||
int CHash::getDigestLength(HashAlgs alg)
|
||||
{
|
||||
static const int aDigestLengths[] = { 16, 16, 16, 20, 20, 32, 48, 64, 64 };
|
||||
return aDigestLengths[alg];
|
||||
}
|
||||
|
||||
CHash::CHash(std::function<void*(size_t)> allocator) : m_fAllocator(allocator)
|
||||
{
|
||||
}
|
||||
|
||||
CHash::~CHash()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned char* CHash::hash(const unsigned char* data, int size, int alg)
|
||||
{
|
||||
unsigned int nBufLen = 0;
|
||||
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 = 64;
|
||||
pBufData = (unsigned char*)m_fAllocator(nBufLen);
|
||||
SHA512(data, d, pBufData);
|
||||
break;
|
||||
}
|
||||
case haWHIRLPOOL:
|
||||
{
|
||||
nBufLen = 64;
|
||||
pBufData = (unsigned char*)m_fAllocator(nBufLen);
|
||||
WHIRLPOOL(data, d, pBufData);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return pBufData;
|
||||
}
|
||||
|
||||
namespace NSUtfs
|
||||
{
|
||||
#define WriteUtf16_byte(code, p) \
|
||||
*p++ = code & 0xFF; \
|
||||
*p++ = (code >> 8) & 0xFF;
|
||||
|
||||
#define WriteUtf16(code, p) \
|
||||
if (code < 0x10000) \
|
||||
{ \
|
||||
WriteUtf16_byte(code, p) \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
code -= 0x10000; \
|
||||
WriteUtf16_byte((0xD800 | ((code >> 10) & 0x03FF)), p); \
|
||||
WriteUtf16_byte((0xDC00 | (code & 0x03FF)), p); \
|
||||
}
|
||||
|
||||
void Utf8_to_utf16le(const char* utf8, unsigned char*& utf16, size_t& utf16_len)
|
||||
{
|
||||
size_t utf8_count = std::strlen(utf8);
|
||||
utf16 = (unsigned char*)malloc(utf8_count * 2);
|
||||
unsigned char* utf16_cur = utf16;
|
||||
|
||||
size_t index = 0;
|
||||
while (index < utf8_count)
|
||||
{
|
||||
unsigned char byteMain = utf8[index];
|
||||
if (0x00 == (byteMain & 0x80))
|
||||
{
|
||||
// 1 byte
|
||||
WriteUtf16(byteMain, utf16_cur);
|
||||
++index;
|
||||
}
|
||||
else if (0x00 == (byteMain & 0x20))
|
||||
{
|
||||
// 2 byte
|
||||
int val = 0;
|
||||
if ((index + 1) < utf8_count)
|
||||
{
|
||||
val = (int)(((byteMain & 0x1F) << 6) |
|
||||
(utf8[index + 1] & 0x3F));
|
||||
}
|
||||
|
||||
WriteUtf16(val, utf16_cur);
|
||||
index += 2;
|
||||
}
|
||||
else if (0x00 == (byteMain & 0x10))
|
||||
{
|
||||
// 3 byte
|
||||
int val = 0;
|
||||
if ((index + 2) < utf8_count)
|
||||
{
|
||||
val = (int)(((byteMain & 0x0F) << 12) |
|
||||
((utf8[index + 1] & 0x3F) << 6) |
|
||||
(utf8[index + 2] & 0x3F));
|
||||
}
|
||||
|
||||
WriteUtf16(val, utf16_cur);
|
||||
index += 3;
|
||||
}
|
||||
else if (0x00 == (byteMain & 0x0F))
|
||||
{
|
||||
// 4 byte
|
||||
int val = 0;
|
||||
if ((index + 3) < utf8_count)
|
||||
{
|
||||
val = (int)(((byteMain & 0x07) << 18) |
|
||||
((utf8[index + 1] & 0x3F) << 12) |
|
||||
((utf8[index + 2] & 0x3F) << 6) |
|
||||
(utf8[index + 3] & 0x3F));
|
||||
}
|
||||
|
||||
WriteUtf16(val, utf16_cur);
|
||||
index += 4;
|
||||
}
|
||||
else if (0x00 == (byteMain & 0x08))
|
||||
{
|
||||
// 4 byte
|
||||
int val = 0;
|
||||
if ((index + 3) < utf8_count)
|
||||
{
|
||||
val = (int)(((byteMain & 0x07) << 18) |
|
||||
((utf8[index + 1] & 0x3F) << 12) |
|
||||
((utf8[index + 2] & 0x3F) << 6) |
|
||||
(utf8[index + 3] & 0x3F));
|
||||
}
|
||||
|
||||
WriteUtf16(val, utf16_cur);
|
||||
index += 4;
|
||||
}
|
||||
else if (0x00 == (byteMain & 0x04))
|
||||
{
|
||||
// 5 byte
|
||||
int val = 0;
|
||||
if ((index + 4) < utf8_count)
|
||||
{
|
||||
val = (int)(((byteMain & 0x03) << 24) |
|
||||
((utf8[index + 1] & 0x3F) << 18) |
|
||||
((utf8[index + 2] & 0x3F) << 12) |
|
||||
((utf8[index + 3] & 0x3F) << 6) |
|
||||
(utf8[index + 4] & 0x3F));
|
||||
}
|
||||
|
||||
WriteUtf16(val, utf16_cur);
|
||||
index += 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 6 byte
|
||||
int val = 0;
|
||||
if ((index + 5) < utf8_count)
|
||||
{
|
||||
val = (int)(((byteMain & 0x01) << 30) |
|
||||
((utf8[index + 1] & 0x3F) << 24) |
|
||||
((utf8[index + 2] & 0x3F) << 18) |
|
||||
((utf8[index + 3] & 0x3F) << 12) |
|
||||
((utf8[index + 4] & 0x3F) << 6) |
|
||||
(utf8[index + 5] & 0x3F));
|
||||
}
|
||||
|
||||
WriteUtf16(val, utf16_cur);
|
||||
index += 5;
|
||||
}
|
||||
}
|
||||
|
||||
utf16_len = (int)(utf16_cur - utf16);
|
||||
}
|
||||
}
|
||||
|
||||
void hash_iteration(unsigned char*& input, int iter, unsigned char*& tmp, int alg, size_t alg_size)
|
||||
{
|
||||
input[alg_size] = 0xFF & (iter >> 0);
|
||||
input[alg_size + 1] = 0xFF & (iter >> 8);
|
||||
input[alg_size + 2] = 0xFF & (iter >> 16);
|
||||
input[alg_size + 3] = 0xFF & (iter >> 24);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
unsigned char* mem = input;
|
||||
input = tmp;
|
||||
tmp = mem;
|
||||
}
|
||||
|
||||
unsigned char* CHash::hash2(const char* password, const char* salt, int spinCount, int alg)
|
||||
{
|
||||
int inputSaltLen = std::strlen(salt);
|
||||
unsigned char* passwordUtf16 = NULL;
|
||||
size_t passwordUtf16Len = 0;
|
||||
NSUtfs::Utf8_to_utf16le(password, passwordUtf16, passwordUtf16Len);
|
||||
|
||||
int inputDataLen = inputSaltLen + passwordUtf16Len;
|
||||
unsigned char* inputData = (unsigned char*)malloc(inputDataLen);
|
||||
NSBase64::Base64Decode(salt, inputSaltLen, inputData, &inputDataLen);
|
||||
memcpy(inputData + inputDataLen, passwordUtf16, passwordUtf16Len);
|
||||
inputDataLen += passwordUtf16Len;
|
||||
|
||||
free(passwordUtf16);
|
||||
|
||||
size_t alg_size = 0;
|
||||
unsigned char* pBuffer1 = NULL;
|
||||
switch (alg)
|
||||
{
|
||||
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;
|
||||
}
|
||||
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:
|
||||
{
|
||||
alg_size = 64;
|
||||
pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4);
|
||||
SHA512(inputData, inputDataLen, pBuffer1);
|
||||
break;
|
||||
}
|
||||
case haWHIRLPOOL:
|
||||
{
|
||||
alg_size = 64;
|
||||
pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4);
|
||||
WHIRLPOOL(inputData, inputDataLen, pBuffer1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
free(inputData);
|
||||
|
||||
if (0 == spinCount)
|
||||
return pBuffer1;
|
||||
|
||||
unsigned char* pBuffer2 = (unsigned char*)malloc(alg_size + 4);
|
||||
for (int i = 0; i < spinCount; ++i)
|
||||
{
|
||||
hash_iteration(pBuffer1, i, pBuffer2, alg, alg_size);
|
||||
}
|
||||
|
||||
free(pBuffer2);
|
||||
return pBuffer1;
|
||||
}
|
||||
42
DesktopEditor/doctrenderer/hash.h
Normal file
42
DesktopEditor/doctrenderer/hash.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef NSHASH_H
|
||||
#define NSHASH_H
|
||||
|
||||
#include <functional>
|
||||
#include "./common.h"
|
||||
|
||||
// hide algs into lib
|
||||
namespace NSHash
|
||||
{
|
||||
void BUILDER_DECL hash_internal(const unsigned char* src, unsigned char* dst, size_t size, int alg);
|
||||
}
|
||||
|
||||
class BUILDER_DECL CHash
|
||||
{
|
||||
public:
|
||||
enum HashAlgs
|
||||
{
|
||||
haMD2 = 0,
|
||||
haMD4 = 1,
|
||||
haMD5 = 2,
|
||||
haRMD160 = 3,
|
||||
haSHA1 = 4,
|
||||
haSHA256 = 5,
|
||||
haSHA384 = 6,
|
||||
haSHA512 = 7,
|
||||
haWHIRLPOOL = 8
|
||||
};
|
||||
|
||||
static int getDigestLength(HashAlgs alg);
|
||||
|
||||
public:
|
||||
CHash(std::function<void*(size_t)> allocator);
|
||||
~CHash();
|
||||
|
||||
unsigned char* hash(const unsigned char* data, int size, int alg);
|
||||
unsigned char* hash2(const char* password, const char* salt, int spinCount, int alg);
|
||||
|
||||
private:
|
||||
std::function<void*(size_t)> m_fAllocator;
|
||||
};
|
||||
|
||||
#endif // NSHASH_H
|
||||
@ -6,6 +6,20 @@
|
||||
#include "../../../OOXML/Base/SmartPtr.h"
|
||||
#include "../../graphics/BaseThread.h"
|
||||
|
||||
// disable export (ios/android problem (external embed objects))
|
||||
#define JSBASE_NO_USE_DYNAMIC_LIBRARY
|
||||
|
||||
#ifdef JSBASE_NO_USE_DYNAMIC_LIBRARY
|
||||
#define JS_DECL
|
||||
#else
|
||||
#include "../../common/base_export.h"
|
||||
#ifdef JSBASE_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
#define JS_DECL Q_DECL_EXPORT
|
||||
#else
|
||||
#define JS_DECL Q_DECL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define JS_VALUE_EXIST(value) (value.is_init() && !value->isNull() && !value->isUndefined())
|
||||
#define JS_IS_VALUE_ARRAY(value) (value.is_init() && !value->isNull() && !value->isUndefined() && value->isArray())
|
||||
|
||||
@ -19,7 +33,7 @@ namespace NSJSBase
|
||||
class CJSTypedArray;
|
||||
class CJSFunction;
|
||||
|
||||
class Q_DECL_EXPORT CJSValue
|
||||
class JS_DECL CJSValue
|
||||
{
|
||||
public:
|
||||
CJSValue();
|
||||
@ -54,14 +68,14 @@ namespace NSJSBase
|
||||
virtual JSSmart<CJSObject> toObjectSmart();
|
||||
};
|
||||
|
||||
class Q_DECL_EXPORT CJSEmbedObjectPrivateBase
|
||||
class JS_DECL CJSEmbedObjectPrivateBase
|
||||
{
|
||||
public:
|
||||
CJSEmbedObjectPrivateBase();
|
||||
virtual ~CJSEmbedObjectPrivateBase();
|
||||
};
|
||||
|
||||
class Q_DECL_EXPORT CJSEmbedObject
|
||||
class JS_DECL CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
CJSEmbedObject();
|
||||
@ -77,7 +91,7 @@ namespace NSJSBase
|
||||
friend class CJSEmbedObjectPrivate;
|
||||
};
|
||||
|
||||
class Q_DECL_EXPORT CJSObject : public CJSValue
|
||||
class JS_DECL CJSObject : public CJSValue
|
||||
{
|
||||
public:
|
||||
CJSObject();
|
||||
@ -95,7 +109,7 @@ namespace NSJSBase
|
||||
virtual JSSmart<CJSValue> toValue() = 0;
|
||||
};
|
||||
|
||||
class Q_DECL_EXPORT CJSArray : public CJSValue
|
||||
class JS_DECL CJSArray : public CJSValue
|
||||
{
|
||||
public:
|
||||
CJSArray();
|
||||
@ -126,7 +140,7 @@ namespace NSJSBase
|
||||
void Free(unsigned char* data, const size_t& size);
|
||||
}
|
||||
|
||||
class Q_DECL_EXPORT CJSDataBuffer
|
||||
class JS_DECL CJSDataBuffer
|
||||
{
|
||||
public:
|
||||
BYTE* Data;
|
||||
@ -140,7 +154,7 @@ namespace NSJSBase
|
||||
void Free();
|
||||
};
|
||||
|
||||
class Q_DECL_EXPORT CJSTypedArray : public CJSValue
|
||||
class JS_DECL CJSTypedArray : public CJSValue
|
||||
{
|
||||
public:
|
||||
CJSTypedArray(BYTE* data = NULL, int count = 0);
|
||||
@ -151,7 +165,7 @@ namespace NSJSBase
|
||||
virtual JSSmart<CJSValue> toValue() = 0;
|
||||
};
|
||||
|
||||
class Q_DECL_EXPORT CJSFunction : public CJSValue
|
||||
class JS_DECL CJSFunction : public CJSValue
|
||||
{
|
||||
public:
|
||||
CJSFunction();
|
||||
@ -160,7 +174,7 @@ namespace NSJSBase
|
||||
virtual CJSValue* Call(CJSValue* recv, int argc, JSSmart<CJSValue> argv[]) = 0;
|
||||
};
|
||||
|
||||
class Q_DECL_EXPORT CJSTryCatch
|
||||
class JS_DECL CJSTryCatch
|
||||
{
|
||||
public:
|
||||
CJSTryCatch();
|
||||
@ -169,7 +183,7 @@ namespace NSJSBase
|
||||
};
|
||||
|
||||
class CJSContextPrivate;
|
||||
class Q_DECL_EXPORT CJSContext
|
||||
class JS_DECL CJSContext
|
||||
{
|
||||
public:
|
||||
CJSContextPrivate* m_internal;
|
||||
@ -224,7 +238,7 @@ namespace NSJSBase
|
||||
};
|
||||
|
||||
class CJSLocalScopePrivate;
|
||||
class Q_DECL_EXPORT CJSLocalScope
|
||||
class JS_DECL CJSLocalScope
|
||||
{
|
||||
public:
|
||||
CJSLocalScopePrivate* m_internal;
|
||||
@ -234,7 +248,7 @@ namespace NSJSBase
|
||||
~CJSLocalScope();
|
||||
};
|
||||
|
||||
class Q_DECL_EXPORT CJSContextScope
|
||||
class JS_DECL CJSContextScope
|
||||
{
|
||||
public:
|
||||
JSSmart<CJSContext> m_context;
|
||||
|
||||
@ -18,9 +18,15 @@ SOURCES += $$PWD/js_logger.cpp
|
||||
HEADERS += $$PWD/v8/v8_base.h
|
||||
SOURCES += $$PWD/v8/v8_base.cpp
|
||||
|
||||
core_mac:CONFIG += disable_v8_use_inspector
|
||||
core_android:CONFIG += disable_v8_use_inspector
|
||||
linux_arm64:CONFIG += disable_v8_use_inspector
|
||||
build_xp::CONFIG += disable_v8_use_inspector
|
||||
|
||||
!disable_v8_use_inspector:CONFIG += v8_use_inspector
|
||||
|
||||
!build_xp {
|
||||
include($$PWD/../../../Common/3dParty/v8/v8.pri)
|
||||
CONFIG += v8_use_inspector
|
||||
} else {
|
||||
DEFINES += V8_OS_XP
|
||||
include($$PWD/../../../Common/3dParty/v8/v8_xp/v8.pri)
|
||||
|
||||
@ -181,6 +181,9 @@ namespace NSJSBase
|
||||
}
|
||||
CJSContext::~CJSContext()
|
||||
{
|
||||
if (m_internal->m_contextPersistent.IsEmpty())
|
||||
return;
|
||||
|
||||
if (m_internal->m_isolate)
|
||||
Dispose();
|
||||
RELEASEOBJECT(m_internal);
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
v8::Local<v8::String> CreateV8String(v8::Isolate* i, const char* str, const int& len = -1);
|
||||
v8::Local<v8::String> CreateV8String(v8::Isolate* i, const std::string& str);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#ifdef ANDROID_LOGS
|
||||
#include <JniLogUtils.h>
|
||||
#endif
|
||||
|
||||
@ -164,11 +164,9 @@ public:
|
||||
v8::V8::InitializeICU();
|
||||
#endif
|
||||
|
||||
char* strEnv = std::getenv("V8_USE_INSPECTOR");
|
||||
if (strEnv && std::strcmp(strEnv, "0"))
|
||||
{
|
||||
std::string sInspectorEnabled = NSSystemUtils::GetEnvVariableA(L"V8_USE_INSPECTOR");
|
||||
if (!sInspectorEnabled.empty() && "0" != sInspectorEnabled)
|
||||
m_bUseInspector = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Dispose()
|
||||
@ -644,6 +642,17 @@ namespace NSJSBase
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef V8_VERSION_89_PLUS
|
||||
#define V8_ARRAY_BUFFER_USE_BACKING_STORE
|
||||
#endif
|
||||
|
||||
#ifdef V8_ARRAY_BUFFER_USE_BACKING_STORE
|
||||
static void V8AllocatorDeleter(void* data, size_t length, void*)
|
||||
{
|
||||
NSAllocator::Free((unsigned char*)data, length);
|
||||
}
|
||||
#endif
|
||||
|
||||
class CJSTypedArrayV8 : public CJSValueV8Template<v8::Uint8Array, CJSTypedArray>
|
||||
{
|
||||
public:
|
||||
@ -651,9 +660,18 @@ namespace NSJSBase
|
||||
{
|
||||
if (0 < count)
|
||||
{
|
||||
#ifdef V8_ARRAY_BUFFER_USE_BACKING_STORE
|
||||
std::shared_ptr<v8::BackingStore> backing_store =
|
||||
v8::ArrayBuffer::NewBackingStore((void*)data, (size_t)count,
|
||||
isExternalize ? v8::BackingStore::EmptyDeleter : V8AllocatorDeleter,
|
||||
nullptr);
|
||||
v8::Local<v8::ArrayBuffer> oArrayBuffer = v8::ArrayBuffer::New(CV8Worker::GetCurrent(), backing_store);
|
||||
value = v8::Uint8Array::New(oArrayBuffer, 0, (size_t)count);
|
||||
#else
|
||||
v8::Local<v8::ArrayBuffer> _buffer = v8::ArrayBuffer::New(CV8Worker::GetCurrent(), (void*)data, (size_t)count,
|
||||
isExternalize ? v8::ArrayBufferCreationMode::kExternalized : v8::ArrayBufferCreationMode::kInternalized);
|
||||
value = v8::Uint8Array::New(_buffer, 0, (size_t)count);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
virtual ~CJSTypedArrayV8()
|
||||
@ -668,10 +686,16 @@ namespace NSJSBase
|
||||
|
||||
virtual CJSDataBuffer getData()
|
||||
{
|
||||
v8::ArrayBuffer::Contents contents = value->Buffer()->GetContents();
|
||||
CJSDataBuffer buffer;
|
||||
#ifdef V8_ARRAY_BUFFER_USE_BACKING_STORE
|
||||
std::shared_ptr<v8::BackingStore> contents = value->Buffer()->GetBackingStore();
|
||||
buffer.Data = (BYTE*)contents->Data();
|
||||
buffer.Len = contents->ByteLength();
|
||||
#else
|
||||
v8::ArrayBuffer::Contents contents = value->Buffer()->GetContents();
|
||||
buffer.Data = (BYTE*)contents.Data();
|
||||
buffer.Len = contents.ByteLength();
|
||||
#endif
|
||||
buffer.IsExternalize = false;
|
||||
return buffer;
|
||||
}
|
||||
@ -798,9 +822,7 @@ namespace NSJSBase
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __ANDROID__
|
||||
std::cerr << strException << std::endl;
|
||||
#else
|
||||
#ifdef ANDROID_LOGS
|
||||
LOGE("NSJSBase::CV8TryCatch::Check() - error:");
|
||||
LOGE(std::to_string(nLineNumber).c_str());
|
||||
LOGE(strCode.c_str());
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
<Settings>
|
||||
<file>../../../../../OfficeWeb/Common/Native/native.js</file>
|
||||
<file>../../../../../OfficeWeb/Common/Native/jquery_native.js</file>
|
||||
<file>../../../../../OfficeWeb/Common/3rdparty/XRegExp/xregexp-all-min.js</file>
|
||||
<file>../../../../../OfficeWeb/Common/AllFonts.js</file>
|
||||
<htmlfile>../../../../../OfficeWeb/Common/3rdparty/jquery/jquery.min.js</htmlfile>
|
||||
<DoctSdk>../../../../../OfficeWeb/Word/sdk-all.js</DoctSdk>
|
||||
<PpttSdk>../../../../../OfficeWeb/PowerPoint/sdk-all.js</PpttSdk>
|
||||
<XlstSdk>../../../../../OfficeWeb/Excel/sdk-all.js</XlstSdk>
|
||||
</Settings>
|
||||
@ -1,48 +0,0 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2015-01-19T14:14:33
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core
|
||||
|
||||
QT -= gui
|
||||
|
||||
TARGET = doctrenderer_test
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include(../../../Common/base.pri)
|
||||
|
||||
################################################
|
||||
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -ldoctrenderer
|
||||
|
||||
linux-g++ {
|
||||
LIBS += -ldl
|
||||
}
|
||||
|
||||
#################### PDF ######################
|
||||
#DEFINES += USE_PDF_RENDERER
|
||||
#
|
||||
#DEFINES += PDFWRITER_USE_DYNAMIC_LIBRARY
|
||||
#LIBS += -L$$DESTINATION_SDK_PATH_DOCTRENDERER -lPdfWriter
|
||||
#
|
||||
#INCLUDEPATH += \
|
||||
# ../../agg-2.4/include \
|
||||
# ../../freetype-2.5.2/include \
|
||||
# ../../cximage/jasper/include \
|
||||
# ../../cximage/jpeg \
|
||||
# ../../cximage/png \
|
||||
# ../../cximage/zlib
|
||||
#LIBS += -L$$DESTINATION_SDK_PATH_DOCTRENDERER -lgraphics
|
||||
#win32 {
|
||||
# LIBS += -lShell32 -lAdvapi32
|
||||
#}
|
||||
###############################################
|
||||
|
||||
SOURCES += main.cpp
|
||||
650
DesktopEditor/doctrenderer/test/embed/test.cpp
Normal file
650
DesktopEditor/doctrenderer/test/embed/test.cpp
Normal file
@ -0,0 +1,650 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "embed/Default.h"
|
||||
#include "hash.h"
|
||||
#include "js_internal/js_base.h"
|
||||
|
||||
using namespace NSJSBase;
|
||||
|
||||
static std::string typedArrayToString(JSSmart<CJSTypedArray> oData)
|
||||
{
|
||||
std::stringstream ss;
|
||||
for (int i = 0; i < oData->getCount(); i++)
|
||||
{
|
||||
ss << std::setw(2) << std::setfill('0') << std::hex << static_cast<unsigned>(oData->getData().Data[i]);
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
class CHashEmbedTest : public testing::Test
|
||||
{
|
||||
public:
|
||||
void SetUp() override
|
||||
{
|
||||
// create context
|
||||
m_pContext = new CJSContext;
|
||||
m_pContext->CreateContext();
|
||||
|
||||
m_pContext->Enter();
|
||||
// create default embeded objects for context
|
||||
CreateDefaults(m_pContext);
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_pContext->Exit();
|
||||
}
|
||||
|
||||
std::string getHash(const std::string& str, CHash::HashAlgs alg)
|
||||
{
|
||||
std::string sAlg = std::to_string(static_cast<int>(alg));
|
||||
JSSmart<CJSValue> oRes1 = m_pContext->runScript(
|
||||
"var oHash = new CreateNativeHash;\n"
|
||||
"var str = '" + str + "';\n"
|
||||
"var alg = " + sAlg + ";\n"
|
||||
"var hash = oHash.hash(str, str.length, alg);");
|
||||
|
||||
// Print first result
|
||||
JSSmart<CJSObject> oGlobal = m_pContext->GetGlobal();
|
||||
JSSmart<CJSTypedArray> oHash = oGlobal->get("hash")->toTypedArray();
|
||||
return typedArrayToString(oHash);
|
||||
}
|
||||
|
||||
std::string getHash2(const std::string& sPassword, const std::string& sSalt, int nSpinCount, CHash::HashAlgs alg)
|
||||
{
|
||||
std::string sSpinCount = std::to_string(nSpinCount);
|
||||
std::string sAlg = std::to_string(static_cast<int>(alg));
|
||||
JSSmart<CJSValue> oRes1 = m_pContext->runScript(
|
||||
"var oHash = new CreateNativeHash;\n"
|
||||
"var sPassword = '" + sPassword + "';\n"
|
||||
"var sSalt = '" + sSalt + "';\n"
|
||||
"var nSpinCount = " + sSpinCount + ";\n"
|
||||
"var alg = " + sAlg + ";\n"
|
||||
"var hash = oHash.hash2(sPassword, sSalt, nSpinCount, alg);");
|
||||
|
||||
// Print first result
|
||||
JSSmart<CJSObject> oGlobal = m_pContext->GetGlobal();
|
||||
JSSmart<CJSTypedArray> oHash = oGlobal->get("hash")->toTypedArray();
|
||||
return typedArrayToString(oHash);
|
||||
}
|
||||
|
||||
public:
|
||||
JSSmart<CJSContext> m_pContext;
|
||||
};
|
||||
|
||||
// =============== HASH TESTS ===============
|
||||
|
||||
// MD2
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_MD2_empty)
|
||||
{
|
||||
std::string sRes = getHash("", CHash::haMD2);
|
||||
std::string sHashExp = "8350e5a3e24c153df2275c9f80692773";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_MD2_simple)
|
||||
{
|
||||
std::string sRes = getHash("test", CHash::haMD2);
|
||||
std::string sHashExp = "dd34716876364a02d0195e2fb9ae2d1b";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_MD2_numbers)
|
||||
{
|
||||
std::string sRes = getHash("1234567890", CHash::haMD2);
|
||||
std::string sHashExp = "38e53522a2e67fc5ea57bae1575a3107";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_MD2_long_with_whitespaces)
|
||||
{
|
||||
std::string sRes = getHash("lorem ipsum dolor sit", CHash::haMD2);
|
||||
std::string sHashExp = "5083c7cafb55fc975ebd3570a42b17c7";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
// MD4
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_MD4_empty)
|
||||
{
|
||||
std::string sRes = getHash("", CHash::haMD4);
|
||||
std::string sHashExp = "31d6cfe0d16ae931b73c59d7e0c089c0";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_MD4_simple)
|
||||
{
|
||||
std::string sRes = getHash("abc", CHash::haMD4);
|
||||
std::string sHashExp = "a448017aaf21d8525fc10ae87aa6729d";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_MD4_mixed_with_numbers)
|
||||
{
|
||||
std::string sRes = getHash("A4B5C6", CHash::haMD4);
|
||||
std::string sHashExp = "347e02b911bfd871f3c6dbaa7ec18e8e";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_MD4_long_with_whitespaces)
|
||||
{
|
||||
std::string sRes = getHash("lorem ipsum dolor sit", CHash::haMD4);
|
||||
std::string sHashExp = "ce870262b108914603a976ada0190465";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
// MD5
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_MD5_empty)
|
||||
{
|
||||
std::string sRes = getHash("", CHash::haMD5);
|
||||
std::string sHashExp = "d41d8cd98f00b204e9800998ecf8427e";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_MD5_simple)
|
||||
{
|
||||
std::string sRes = getHash("somePasswordPhrase", CHash::haMD5);
|
||||
std::string sHashExp = "22f441c16585c77afc197135d9a182d0";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_MD5_special)
|
||||
{
|
||||
std::string sRes = getHash("%!#$@12&0%#!()/", CHash::haMD5);
|
||||
std::string sHashExp = "a650f10669ec12b8649171a303c15191";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_MD5_long_with_whitespaces)
|
||||
{
|
||||
std::string sRes = getHash("lorem ipsum dolor sit", CHash::haMD5);
|
||||
std::string sHashExp = "4468ef6e8e0cd5c8648c5833d1df035b";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
// RMD160
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_RMD160_empty)
|
||||
{
|
||||
std::string sRes = getHash("", CHash::haRMD160);
|
||||
std::string sHashExp = "9c1185a5c5e9fc54612808977ee8f548b2258d31";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_RMD160_simple)
|
||||
{
|
||||
std::string sRes = getHash("someTestWord", CHash::haRMD160);
|
||||
std::string sHashExp = "23a0e1377bf02e69418bd6799fc6aa7d920bc241";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_RMD160_numbers_and_special)
|
||||
{
|
||||
std::string sRes = getHash("100%number#1&^", CHash::haRMD160);
|
||||
std::string sHashExp = "532fe6a1af143b7d6a9f0762274d5c370e7e3db7";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_RMD160_long_with_whitespaces)
|
||||
{
|
||||
std::string sRes = getHash("lorem ipsum dolor sit", CHash::haRMD160);
|
||||
std::string sHashExp = "90dc47410bbc09c1ad572e0405a65077436f6522";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
// SHA1
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_SHA1_empty)
|
||||
{
|
||||
std::string sRes = getHash("", CHash::haSHA1);
|
||||
std::string sHashExp = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_SHA1_simple)
|
||||
{
|
||||
std::string sRes = getHash("TEST", CHash::haSHA1);
|
||||
std::string sHashExp = "984816fd329622876e14907634264e6f332e9fb3";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_SHA1_numbers_and_special)
|
||||
{
|
||||
std::string sRes = getHash("100%number#1&^", CHash::haSHA1);
|
||||
std::string sHashExp = "75f5abe89b9d46fb7c202a71ecb7ad5c22c8f00e";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_SHA1_long_with_whitespaces)
|
||||
{
|
||||
std::string sRes = getHash("lorem ipsum dolor sit", CHash::haSHA1);
|
||||
std::string sHashExp = "93b80998357e6ca4b1c0007ba8847810874785ef";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
// SHA256
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_SHA256_empty)
|
||||
{
|
||||
std::string sRes = getHash("", CHash::haSHA256);
|
||||
std::string sHashExp = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_SHA256_simple)
|
||||
{
|
||||
std::string sRes = getHash("thisIsATest", CHash::haSHA256);
|
||||
std::string sHashExp = "295c70476a0d7e57cc34f6548d4677bc8b3802cbe5e77d7fb542ab4fe027415a";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_SHA256_numbers_and_special)
|
||||
{
|
||||
std::string sRes = getHash("100%number#1&^//@", CHash::haSHA256);
|
||||
std::string sHashExp = "7bdedbcf7ef0edffbc8667beb414a28fcc90e5b02d99689666aa0032ac16cabc";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_SHA256_long_with_whitespaces)
|
||||
{
|
||||
std::string sRes = getHash("lorem ipsum dolor sit", CHash::haSHA256);
|
||||
std::string sHashExp = "fbf4333ef3b1c0aeb7e1d3a82978cb5d410ebc13d5512d894a01fdcd623516ad";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
// SHA384
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_SHA384_empty)
|
||||
{
|
||||
std::string sRes = getHash("", CHash::haSHA384);
|
||||
std::string sHashExp = "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_SHA384_simple)
|
||||
{
|
||||
std::string sRes = getHash("simple", CHash::haSHA384);
|
||||
std::string sHashExp = "309435df62b71bc1c9cdce1a865e397dc94fc7cc19ebf03e8c972a01f3106c187b90787861a8fe8ebad632c1ccc5a6b7";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_SHA384_numbers_and_special)
|
||||
{
|
||||
std::string sRes = getHash("100%number#1&^//@", CHash::haSHA384);
|
||||
std::string sHashExp = "af3c0c66f44eba9338e7ff0ec53d678aa80fb8ba1677be22cc0a70c896e3f18df5ff1dba925ef9ea94ec5609f438b37b";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_SHA384_long_with_whitespaces)
|
||||
{
|
||||
std::string sRes = getHash("lorem ipsum dolor sit", CHash::haSHA384);
|
||||
std::string sHashExp = "cb73fc5737123ec4bfad644b51646600b57c0cfe70fa59bbf2d2d422be4b5abbd8c144aeb54570008c0a38732afaea7e";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
// SHA512
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_SHA512_empty)
|
||||
{
|
||||
std::string sRes = getHash("", CHash::haSHA512);
|
||||
std::string sHashExp = "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_SHA512_simple)
|
||||
{
|
||||
std::string sRes = getHash("bestSha", CHash::haSHA512);
|
||||
std::string sHashExp = "76547bbaf925128849fbbbae49d2cc22e7244495c15399fd27534a9ce9bd62f2eaf2f2aa6f6aed8ecd281260739ad755e241860b4adcf3440fabd34dad89de7c";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_SHA512_numbers_and_special)
|
||||
{
|
||||
std::string sRes = getHash("100%number#1&^//@", CHash::haSHA512);
|
||||
std::string sHashExp = "c28516318aa24f37b5e6448e49f747d95eaaea726498d1e0a017be8b289c73598363cd622492113b65a0b92b37250482d1511fa7db9e7012243e57950f04dc93";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_SHA512_long_with_whitespaces)
|
||||
{
|
||||
std::string sRes = getHash("lorem ipsum dolor sit", CHash::haSHA512);
|
||||
std::string sHashExp = "48a6898c48655bbd42b588c40ec3ef86fd0bf30c981fd543a03e21e176af1cb5ff2c4ae9a012b924a9696b9ac615018c62c73786cbbc9ea5b5154fd9d69134d2";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
// WHIRLPOOL
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_WHIRLPOOL_empty)
|
||||
{
|
||||
std::string sRes = getHash("", CHash::haWHIRLPOOL);
|
||||
std::string sHashExp = "19fa61d75522a4669b44e39c1d2e1726c530232130d407f89afee0964997f7a73e83be698b288febcf88e3e03c4f0757ea8964e59b63d93708b138cc42a66eb3";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_WHIRLPOOL_simple)
|
||||
{
|
||||
std::string sRes = getHash("wHiRlPooL", CHash::haWHIRLPOOL);
|
||||
std::string sHashExp = "35f76e47d8ac40a1431c9d26df5c96fba1ae04a2f53d3a8775261f5133b4f68c95f3bd710a5109def44c659f8407b88016ccba43ba4f974b8d003d429298c79d";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_WHIRLPOOL_numbers_and_special)
|
||||
{
|
||||
std::string sRes = getHash("100%number#1&^//@", CHash::haWHIRLPOOL);
|
||||
std::string sHashExp = "6b65f878b4b5292253c40544b572bf381b981d9cdc2d4864c23ac706ba8bf5306c78456487ff7c4f3b3d0d91f29ec6599f1f6b578a1007e5b7029d68330ca31b";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash_WHIRLPOOL_long_with_whitespaces)
|
||||
{
|
||||
std::string sRes = getHash("lorem ipsum dolor sit", CHash::haWHIRLPOOL);
|
||||
std::string sHashExp = "6bc062ea83003d44c2dbff2f9cbd2385806f6450171410fca4f189ed5c44726c4dc0330030af2c647082975b41f1c83bcc0722576d7e8cb2aabb5ff0ba38aaa9";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
|
||||
// =============== HASH2 TESTS ===============
|
||||
|
||||
// MD2
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_MD2_empty_both)
|
||||
{
|
||||
std::string sRes = getHash2("", "", 0, CHash::haMD2);
|
||||
std::string sHashExp = "8350e5a3e24c153df2275c9f80692773";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_MD2_empty_salt)
|
||||
{
|
||||
std::string sRes = getHash2("test", "", 0, CHash::haMD2);
|
||||
std::string sHashExp = "4b3991628dcc0d99c21a3e16bae371a1";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_MD2_empty_password)
|
||||
{
|
||||
std::string sRes = getHash2("", "test", 0, CHash::haMD2);
|
||||
std::string sHashExp = "f8b4e92bbb2cfb8978ee457ff2e1c52c";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_MD2_normal_zero_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw==", 0, CHash::haMD2);
|
||||
std::string sHashExp = "4910f7ccbf97e8692cec700c81be028a";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_MD2_normal_one_spin)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw", 1, CHash::haMD2);
|
||||
std::string sHashExp = "dad6d472390d1d4b8e24a6ab6e79ee09";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_MD2_normal_large_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw", 100000, CHash::haMD2);
|
||||
std::string sHashExp = "9e32a6c3776cbe9649799bbb6ef4a30b";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_MD2_special_salt_symbols)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw+===.@#!", 42, CHash::haMD2);
|
||||
std::string sHashExp = getHash2("test", "yrGivlyCImiWnryRee1OJw+", 42, CHash::haMD2);
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_MD2_long_password_with_special_symbols)
|
||||
{
|
||||
std::string sRes = getHash2("l#*Rem / .Ip$uM. +dol@r_ S!t", "ZUdHa+D8F/OAKP3I7ssUnQ==", 100, CHash::haMD2);
|
||||
std::string sHashExp = "6d5a4f44884908bf330a89c2e0b4dfb1";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
// MD4
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_MD4_empty_both)
|
||||
{
|
||||
std::string sRes = getHash2("", "", 0, CHash::haMD4);
|
||||
std::string sHashExp = "31d6cfe0d16ae931b73c59d7e0c089c0";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_MD4_normal_zero_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw==", 0, CHash::haMD4);
|
||||
std::string sHashExp = "c7604219b6ebceabecc90e812b0a79d5";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_MD4_normal_large_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw", 100000, CHash::haMD4);
|
||||
std::string sHashExp = "0f159ffad2f023cfda82806e0cc0f567";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_MD4_long_password_with_special_symbols)
|
||||
{
|
||||
std::string sRes = getHash2("l#*Rem / .Ip$uM. +dol@r_ S!t", "ZUdHa+D8F/OAKP3I7ssUnQ==", 100, CHash::haMD4);
|
||||
std::string sHashExp = "294c29798c2b737387b933e93f449bce";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
// MD5
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_MD5_empty_both)
|
||||
{
|
||||
std::string sRes = getHash2("", "", 0, CHash::haMD5);
|
||||
std::string sHashExp = "d41d8cd98f00b204e9800998ecf8427e";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_MD5_normal_zero_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw==", 0, CHash::haMD5);
|
||||
std::string sHashExp = "32549585b3be9154133ffad540c5c64e";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_MD5_normal_large_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw", 100000, CHash::haMD5);
|
||||
std::string sHashExp = "e3f91c932542ddc2665e83b084e976d5";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_MD5_long_password_with_special_symbols)
|
||||
{
|
||||
std::string sRes = getHash2("l#*Rem / .Ip$uM. +dol@r_ S!t", "ZUdHa+D8F/OAKP3I7ssUnQ==", 100, CHash::haMD5);
|
||||
std::string sHashExp = "eff44f503d10050fa4d3021b7a8bf342";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
// RMD160
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_RMD160_empty_both)
|
||||
{
|
||||
std::string sRes = getHash2("", "", 0, CHash::haRMD160);
|
||||
std::string sHashExp = "9c1185a5c5e9fc54612808977ee8f548b2258d31";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_RMD160_normal_zero_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw==", 0, CHash::haRMD160);
|
||||
std::string sHashExp = "4bf3966337fbff161ff716fc84ec6d4d07b3a97a";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_RMD160_normal_large_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw", 100000, CHash::haRMD160);
|
||||
std::string sHashExp = "30c5d71c1b5155828201fb4eacfc55b7b7d4659c";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_RMD160_long_password_with_special_symbols)
|
||||
{
|
||||
std::string sRes = getHash2("l#*Rem / .Ip$uM. +dol@r_ S!t", "ZUdHa+D8F/OAKP3I7ssUnQ==", 100, CHash::haRMD160);
|
||||
std::string sHashExp = "16b740428b7b54ac5731e69b935c017dcc46f41e";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
// SHA1
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_SHA1_empty_both)
|
||||
{
|
||||
std::string sRes = getHash2("", "", 0, CHash::haSHA1);
|
||||
std::string sHashExp = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_SHA1_normal_zero_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw==", 0, CHash::haSHA1);
|
||||
std::string sHashExp = "8ade9b306c150b75355d2c41eccbaaeade367c68";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_SHA1_normal_large_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw", 100000, CHash::haSHA1);
|
||||
std::string sHashExp = "f22e440294cf8d3a17762e1b7e3c85da7653bfc0";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_SHA1_long_password_with_special_symbols)
|
||||
{
|
||||
std::string sRes = getHash2("l#*Rem / .Ip$uM. +dol@r_ S!t", "ZUdHa+D8F/OAKP3I7ssUnQ==", 100, CHash::haSHA1);
|
||||
std::string sHashExp = "baef83ca25d011bc8abef8db4eeb7797be882dcf";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
// SHA256
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_SHA256_empty_both)
|
||||
{
|
||||
std::string sRes = getHash2("", "", 0, CHash::haSHA256);
|
||||
std::string sHashExp = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_SHA256_normal_zero_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw==", 0, CHash::haSHA256);
|
||||
std::string sHashExp = "49e56631385352e25bd1832c976c1cb2d16fc890c08b0afa5330ac7b357e4dd2";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_SHA256_normal_large_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw", 100000, CHash::haSHA256);
|
||||
std::string sHashExp = "dfb1016fc7df9962c139649f274a013fdcb3acfe58e45a0158b343b682c6be66";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_SHA256_long_password_with_special_symbols)
|
||||
{
|
||||
std::string sRes = getHash2("l#*Rem / .Ip$uM. +dol@r_ S!t", "ZUdHa+D8F/OAKP3I7ssUnQ==", 100, CHash::haSHA256);
|
||||
std::string sHashExp = "5a2a9b61a11fd847428817c5e3f801f0890ecbba4c7ff30d6c7148dab5350707";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
// SHA384
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_SHA384_empty_both)
|
||||
{
|
||||
std::string sRes = getHash2("", "", 0, CHash::haSHA384);
|
||||
std::string sHashExp = "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_SHA384_normal_zero_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw==", 0, CHash::haSHA384);
|
||||
std::string sHashExp = "30acca7905d036c16212d93e910677e35abd7075c83686ef068da98cac2c3e7bd53a00f7630c618a8612a71319c70a69";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_SHA384_normal_large_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw", 100000, CHash::haSHA384);
|
||||
std::string sHashExp = "b67220f2f7e058067f37e467fd4022fccdcff9068a90721128cff07161be3d22e4b8f7b7f2a92e2799df361d2fad581f";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_SHA384_long_password_with_special_symbols)
|
||||
{
|
||||
std::string sRes = getHash2("l#*Rem / .Ip$uM. +dol@r_ S!t", "ZUdHa+D8F/OAKP3I7ssUnQ==", 100, CHash::haSHA384);
|
||||
std::string sHashExp = "e44475f25135de740b04ac297987e58e65aa1eb87dd6a3825636c82e160f9bd504ce59073777b16f152e35be8086f491";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
// SHA512
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_SHA512_empty_both)
|
||||
{
|
||||
std::string sRes = getHash2("", "", 0, CHash::haSHA512);
|
||||
std::string sHashExp = "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_SHA512_normal_zero_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw==", 0, CHash::haSHA512);
|
||||
std::string sHashExp = "4a1e8ca6c732f73083a598d4a125b6b86968b879d67f9220b745f81319649d97bf7ed9560da0f8a84b6950902f1dd8357c215624d0e7681724c81b3d402042eb";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_SHA512_normal_large_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw", 100000, CHash::haSHA512);
|
||||
std::string sHashExp = "79d7f29cbe4bf98ab6844bf2f1e1c98a9ac9f402fe97ae19cf625fee2baa8eacf51f790c2b9a6318685e36c8662b9deaca8096715e2b1c7cc746177b1a36da12";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_SHA512_long_password_with_special_symbols)
|
||||
{
|
||||
std::string sRes = getHash2("l#*Rem / .Ip$uM. +dol@r_ S!t", "ZUdHa+D8F/OAKP3I7ssUnQ==", 100, CHash::haSHA512);
|
||||
std::string sHashExp = "306fb41c2ac84cbda4a0cd8b504cd6e642ad24219d3abbbb8371c02e34768f893f32030c99ee26d6f3dfffbf644f5cf864d1054d0ff9c4d0fc35b70638561817";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
// WHIRLPOOL
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_WHIRLPOOL_empty_both)
|
||||
{
|
||||
std::string sRes = getHash2("", "", 0, CHash::haWHIRLPOOL);
|
||||
std::string sHashExp = "19fa61d75522a4669b44e39c1d2e1726c530232130d407f89afee0964997f7a73e83be698b288febcf88e3e03c4f0757ea8964e59b63d93708b138cc42a66eb3";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_WHIRLPOOL_normal_zero_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw==", 0, CHash::haWHIRLPOOL);
|
||||
std::string sHashExp = "4579bac0b569f64f8d6c5787b1a3bf4b98175cffce14b12e7571729622845978f5078fb43816f7ea48d1342f1c2440acf8fabe49c98a7e493ceb363a180031e9";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_WHIRLPOOL_normal_large_spin_count)
|
||||
{
|
||||
std::string sRes = getHash2("test", "yrGivlyCImiWnryRee1OJw", 100000, CHash::haWHIRLPOOL);
|
||||
std::string sHashExp = "adbe7de286ebede2d81b5c184cb31753de27fd7212895016d9cad0baadfae9f98e2452b29d8425e35d140d33bde2d9c45f7251beddd551bfb381fbced0275908";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
|
||||
TEST_F(CHashEmbedTest, hash2_WHIRLPOOL_long_password_with_special_symbols)
|
||||
{
|
||||
std::string sRes = getHash2("l#*Rem / .Ip$uM. +dol@r_ S!t", "ZUdHa+D8F/OAKP3I7ssUnQ==", 100, CHash::haWHIRLPOOL);
|
||||
std::string sHashExp = "eab4cefa2c1479d71b7b8c0416efb2890a592dc293692117270d579f4d72aee4d166d750ab601066f9e88fd78a83d7981057e6b46550bd00bd6afec9ecf413ae";
|
||||
EXPECT_EQ(sRes, sHashExp);
|
||||
}
|
||||
32
DesktopEditor/doctrenderer/test/embed/test_embed.pro
Normal file
32
DesktopEditor/doctrenderer/test/embed/test_embed.pro
Normal file
@ -0,0 +1,32 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
TARGET = test
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += core_static_link_libstd
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../../../core
|
||||
CORE_3DPARTY_DIR = $$CORE_ROOT_DIR/Common/3dParty
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
include($$CORE_3DPARTY_DIR/googletest/googletest.pri)
|
||||
|
||||
DESTDIR = $$PWD/build
|
||||
|
||||
INCLUDEPATH += ../..
|
||||
|
||||
ADD_DEPENDENCY(doctrenderer)
|
||||
|
||||
core_linux {
|
||||
LIBS += -Wl,-unresolved-symbols=ignore-in-shared-libs
|
||||
LIBS += -ldl
|
||||
}
|
||||
|
||||
SOURCES += \
|
||||
test.cpp
|
||||
|
||||
@ -32,8 +32,8 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "../../embed/Default.h"
|
||||
#include "../js_base.h"
|
||||
#include "embed/Default.h"
|
||||
#include "js_internal/js_base.h"
|
||||
|
||||
using namespace NSJSBase;
|
||||
int main(int argc, char *argv[])
|
||||
@ -99,7 +99,9 @@ int main(int argc, char *argv[])
|
||||
// oContext1->Dispose();
|
||||
oContext2->Dispose();
|
||||
|
||||
#else
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// CZipEmbed example
|
||||
|
||||
JSSmart<CJSContext> oContext1 = new CJSContext;
|
||||
@ -153,5 +155,49 @@ int main(int argc, char *argv[])
|
||||
oContext1->Exit();
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// CHashEmbed example
|
||||
|
||||
JSSmart<CJSContext> oContext1 = new CJSContext;
|
||||
|
||||
// Create first context
|
||||
oContext1->CreateContext();
|
||||
|
||||
// Call hash() on first context
|
||||
CJSContextScope scope(oContext1);
|
||||
CreateDefaults(oContext1);
|
||||
JSSmart<CJSValue> oRes1 = oContext1->runScript(
|
||||
"var oHash = new CreateNativeHash;\n"
|
||||
"var str = 'test';\n"
|
||||
"var hash = oHash.hash(str, str.length, 0);");
|
||||
|
||||
// Print first result
|
||||
JSSmart<CJSObject> oGlobal1 = oContext1->GetGlobal();
|
||||
JSSmart<CJSTypedArray> oHash = oGlobal1->get("hash")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH:\n";
|
||||
for (int i = 0; i < oHash->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(oHash->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
// Call hash2() on first context
|
||||
CreateDefaults(oContext1);
|
||||
JSSmart<CJSValue> oRes2 = oContext1->runScript(
|
||||
"var str2 = 'test';\n"
|
||||
"var hash2 = oHash.hash2(str2, 'yrGivlyCImiWnryRee1OJw==', 100000, 7);");
|
||||
|
||||
// Print first result
|
||||
JSSmart<CJSTypedArray> oHash2 = oGlobal1->get("hash2")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH2:\n";
|
||||
for (int i = 0; i < oHash2->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(oHash2->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -17,6 +17,7 @@ include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
############### destination path ###############
|
||||
DESTDIR = $$PWD/build
|
||||
################################################
|
||||
INCLUDEPATH += ../..
|
||||
|
||||
ADD_DEPENDENCY(doctrenderer)
|
||||
|
||||
@ -1,107 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#include "../doctrenderer.h"
|
||||
|
||||
#ifdef USE_PDF_RENDERER
|
||||
#include "../../../PdfWriter/PdfRenderer.h"
|
||||
#include "../../graphics/pro/Fonts.h"
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#if 1
|
||||
|
||||
#if 1
|
||||
std::wstring strXml = L"<Settings>\
|
||||
<SrcFileType>1</SrcFileType>\
|
||||
<DstFileType>1</DstFileType>\
|
||||
<SrcFilePath>D:\\source</SrcFilePath>\
|
||||
<DstFilePath>D:\\source\\EditorWithChanges.bin</DstFilePath>\
|
||||
<FontsDirectory>D:\\activex\\AVS\\Sources\\TeamlabOffice\\trunk\\ServerComponents\\DesktopEditor\\ChromiumBasedEditors2\\app\\test\\src\\build\\win64\\Debug\\Local\\converter\\fonts\\</FontsDirectory>\
|
||||
<ImagesDirectory>D:\\source\\media</ImagesDirectory>\
|
||||
<ThemesDirectory>D:\\activex\\AVS\\Sources\\TeamlabOffice\\trunk\\ServerComponents\\Test\\Applications\\TestAVSOfficeDocxFile2\\TestAVSOfficeDocxFile2\\bin\\x86\\presentationthemes</ThemesDirectory>\
|
||||
<Changes TopItem=\"-1\">\
|
||||
<Change>D:\\source\\changes\\changes0.json</Change>\
|
||||
</Changes>\
|
||||
</Settings>";
|
||||
|
||||
#else
|
||||
|
||||
std::wstring strXml = L"<Settings>\
|
||||
<SrcFileType>0</SrcFileType>\
|
||||
<DstFileType>0</DstFileType>\
|
||||
<SrcFilePath>D:\\build_doc</SrcFilePath>\
|
||||
<DstFilePath>D:\\build_doc\\destination</DstFilePath>\
|
||||
<FontsDirectory>D:\\activex\\AVS\\Sources\\TeamlabOffice\\trunk\\OfficeWeb\\Fonts\\native</FontsDirectory>\
|
||||
<ImagesDirectory>D:\\build_doc\\media</ImagesDirectory>\
|
||||
<ThemesDirectory>D:\\activex\\AVS\\Sources\\TeamlabOffice\\trunk\\ServerComponents\\Test\\Applications\\TestAVSOfficeDocxFile2\\TestAVSOfficeDocxFile2\\bin\\x86\\presentationthemes</ThemesDirectory>\
|
||||
<MailMergeData DatabasePath=\"D:\\build_doc\\mm.json\" Start=\"0\" End=\"17\" Field=\"email\" />\
|
||||
</Settings>";
|
||||
#endif
|
||||
|
||||
#else
|
||||
std::wstring strXml = L"<Settings>\
|
||||
<SrcFileType>0</SrcFileType>\
|
||||
<DstFileType>0</DstFileType>\
|
||||
<SrcFilePath>/home/oleg/build_doc</SrcFilePath>\
|
||||
<DstFilePath>/home/oleg/build_doc/EditorWithChanges.bin</DstFilePath>\
|
||||
<FontsDirectory>/home/oleg/AVS/Sources/TeamlabOffice/trunk/OfficeWeb/Fonts/native</FontsDirectory>\
|
||||
<ImagesDirectory>/home/oleg/build_doc/media</ImagesDirectory>\
|
||||
<ThemesDirectory>/home/oleg/presentationthemes</ThemesDirectory>\
|
||||
<Changes TopItem=\"-1\">\
|
||||
<Change>/home/oleg/build_doc/changes/changes0.json</Change>\
|
||||
</Changes>\
|
||||
</Settings>";
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
|
||||
NSDoctRenderer::CDoctrenderer oRenderer(L"C:/ProgramData/ONLYOFFICE/webdata/cloud/fonts/AllFonts.js");
|
||||
|
||||
std::wstring sError;
|
||||
oRenderer.Execute(strXml, sError);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_PDF_RENDERER
|
||||
|
||||
CApplicationFonts oFonts;
|
||||
oFonts.Initialize();
|
||||
CPdfRenderer oPDF(&oFonts);
|
||||
oPDF.SetTempFolder(L"D:\\test_pdf");
|
||||
|
||||
oPDF.OnlineWordToPdfFromBinary(L"D:\\DE_CAD4\\EditorWithChanges.bin", L"D:\\test_pdf\\123.pdf");
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -50,7 +50,8 @@ namespace NSFontDictionary
|
||||
|
||||
for (int i = 0; i < nNameLen; ++i)
|
||||
{
|
||||
if (pName[i] > 255 || pName[i] < 0)
|
||||
// not 255
|
||||
if (pName[i] > 128 || pName[i] < 0)
|
||||
{
|
||||
bIsAscii = false;
|
||||
break;
|
||||
@ -75,19 +76,19 @@ namespace NSFontDictionary
|
||||
bool bIsEqual = true;
|
||||
for (int j = 1; j < nNameLen; ++j)
|
||||
{
|
||||
if ('\0' == _name[j]) // короче чем нужно
|
||||
{
|
||||
bIsEqual = false;
|
||||
break;
|
||||
}
|
||||
if (pName[j] != (wchar_t)_name[j])
|
||||
if ('\0' == _name[j]) // короче чем нужно
|
||||
{
|
||||
bIsEqual = false;
|
||||
break;
|
||||
}
|
||||
if (pName[j] != (wchar_t)_name[j])
|
||||
{
|
||||
bIsEqual = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bIsEqual && _name[nNameLen] == '\0') // чтобы не длиннее, чем нужно
|
||||
if (bIsEqual && _name[nNameLen] == '\0') // чтобы не длиннее, чем нужно
|
||||
{
|
||||
nIndex = i;
|
||||
break;
|
||||
@ -108,54 +109,54 @@ namespace NSFontDictionary
|
||||
switch (nStyle)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
if (pRec->m_index_i != -1)
|
||||
nFontIndex = pRec->m_index_i;
|
||||
else if (pRec->m_index_bi != -1)
|
||||
nFontIndex = pRec->m_index_bi;
|
||||
else if (pRec->m_index_r != -1)
|
||||
nFontIndex = pRec->m_index_r;
|
||||
else
|
||||
nFontIndex = pRec->m_index_b;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (pRec->m_index_i != -1)
|
||||
nFontIndex = pRec->m_index_i;
|
||||
else if (pRec->m_index_bi != -1)
|
||||
nFontIndex = pRec->m_index_bi;
|
||||
else if (pRec->m_index_r != -1)
|
||||
nFontIndex = pRec->m_index_r;
|
||||
else
|
||||
nFontIndex = pRec->m_index_b;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (pRec->m_index_b != -1)
|
||||
nFontIndex = pRec->m_index_b;
|
||||
else if (pRec->m_index_bi != -1)
|
||||
nFontIndex = pRec->m_index_bi;
|
||||
else if (pRec->m_index_r != -1)
|
||||
nFontIndex = pRec->m_index_r;
|
||||
else
|
||||
nFontIndex = pRec->m_index_i;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (pRec->m_index_b != -1)
|
||||
nFontIndex = pRec->m_index_b;
|
||||
else if (pRec->m_index_bi != -1)
|
||||
nFontIndex = pRec->m_index_bi;
|
||||
else if (pRec->m_index_r != -1)
|
||||
nFontIndex = pRec->m_index_r;
|
||||
else
|
||||
nFontIndex = pRec->m_index_i;
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
if (pRec->m_index_bi != -1)
|
||||
nFontIndex = pRec->m_index_bi;
|
||||
else if (pRec->m_index_b != -1)
|
||||
nFontIndex = pRec->m_index_b;
|
||||
else if (pRec->m_index_i != -1)
|
||||
nFontIndex = pRec->m_index_i;
|
||||
else
|
||||
nFontIndex = pRec->m_index_r;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (pRec->m_index_bi != -1)
|
||||
nFontIndex = pRec->m_index_bi;
|
||||
else if (pRec->m_index_b != -1)
|
||||
nFontIndex = pRec->m_index_b;
|
||||
else if (pRec->m_index_i != -1)
|
||||
nFontIndex = pRec->m_index_i;
|
||||
else
|
||||
nFontIndex = pRec->m_index_r;
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
default:
|
||||
{
|
||||
if (pRec->m_index_r != -1)
|
||||
nFontIndex = pRec->m_index_r;
|
||||
else if (pRec->m_index_i != -1)
|
||||
nFontIndex = pRec->m_index_i;
|
||||
else if (pRec->m_index_b != -1)
|
||||
nFontIndex = pRec->m_index_b;
|
||||
else
|
||||
nFontIndex = pRec->m_index_bi;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (pRec->m_index_r != -1)
|
||||
nFontIndex = pRec->m_index_r;
|
||||
else if (pRec->m_index_i != -1)
|
||||
nFontIndex = pRec->m_index_i;
|
||||
else if (pRec->m_index_b != -1)
|
||||
nFontIndex = pRec->m_index_b;
|
||||
else
|
||||
nFontIndex = pRec->m_index_bi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nFontIndex != -1)
|
||||
@ -175,7 +176,7 @@ namespace NSFontDictionary
|
||||
bool bIsEqual = true;
|
||||
for (int j = 1; j < nNameLen; ++j)
|
||||
{
|
||||
if ('\0' == _name[j]) // короче чем нужно
|
||||
if ('\0' == _name[j]) // короче чем нужно
|
||||
{
|
||||
bIsEqual = false;
|
||||
break;
|
||||
@ -187,7 +188,7 @@ namespace NSFontDictionary
|
||||
}
|
||||
}
|
||||
|
||||
if (bIsEqual && _name[nNameLen] == '\0') // чтобы не длиннее, чем нужно
|
||||
if (bIsEqual && _name[nNameLen] == '\0') // чтобы не длиннее, чем нужно
|
||||
{
|
||||
nIndex = i;
|
||||
break;
|
||||
@ -208,54 +209,54 @@ namespace NSFontDictionary
|
||||
switch (nStyle)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
if (pRec->m_index_i != -1)
|
||||
nFontIndex = pRec->m_index_i;
|
||||
else if (pRec->m_index_bi != -1)
|
||||
nFontIndex = pRec->m_index_bi;
|
||||
else if (pRec->m_index_r != -1)
|
||||
nFontIndex = pRec->m_index_r;
|
||||
else
|
||||
nFontIndex = pRec->m_index_b;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (pRec->m_index_i != -1)
|
||||
nFontIndex = pRec->m_index_i;
|
||||
else if (pRec->m_index_bi != -1)
|
||||
nFontIndex = pRec->m_index_bi;
|
||||
else if (pRec->m_index_r != -1)
|
||||
nFontIndex = pRec->m_index_r;
|
||||
else
|
||||
nFontIndex = pRec->m_index_b;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (pRec->m_index_b != -1)
|
||||
nFontIndex = pRec->m_index_b;
|
||||
else if (pRec->m_index_bi != -1)
|
||||
nFontIndex = pRec->m_index_bi;
|
||||
else if (pRec->m_index_r != -1)
|
||||
nFontIndex = pRec->m_index_r;
|
||||
else
|
||||
nFontIndex = pRec->m_index_i;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (pRec->m_index_b != -1)
|
||||
nFontIndex = pRec->m_index_b;
|
||||
else if (pRec->m_index_bi != -1)
|
||||
nFontIndex = pRec->m_index_bi;
|
||||
else if (pRec->m_index_r != -1)
|
||||
nFontIndex = pRec->m_index_r;
|
||||
else
|
||||
nFontIndex = pRec->m_index_i;
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
if (pRec->m_index_bi != -1)
|
||||
nFontIndex = pRec->m_index_bi;
|
||||
else if (pRec->m_index_b != -1)
|
||||
nFontIndex = pRec->m_index_b;
|
||||
else if (pRec->m_index_i != -1)
|
||||
nFontIndex = pRec->m_index_i;
|
||||
else
|
||||
nFontIndex = pRec->m_index_r;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (pRec->m_index_bi != -1)
|
||||
nFontIndex = pRec->m_index_bi;
|
||||
else if (pRec->m_index_b != -1)
|
||||
nFontIndex = pRec->m_index_b;
|
||||
else if (pRec->m_index_i != -1)
|
||||
nFontIndex = pRec->m_index_i;
|
||||
else
|
||||
nFontIndex = pRec->m_index_r;
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
default:
|
||||
{
|
||||
if (pRec->m_index_r != -1)
|
||||
nFontIndex = pRec->m_index_r;
|
||||
else if (pRec->m_index_i != -1)
|
||||
nFontIndex = pRec->m_index_i;
|
||||
else if (pRec->m_index_b != -1)
|
||||
nFontIndex = pRec->m_index_b;
|
||||
else
|
||||
nFontIndex = pRec->m_index_bi;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (pRec->m_index_r != -1)
|
||||
nFontIndex = pRec->m_index_r;
|
||||
else if (pRec->m_index_i != -1)
|
||||
nFontIndex = pRec->m_index_i;
|
||||
else if (pRec->m_index_b != -1)
|
||||
nFontIndex = pRec->m_index_b;
|
||||
else
|
||||
nFontIndex = pRec->m_index_bi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nFontIndex != -1)
|
||||
|
||||
@ -37,6 +37,8 @@ var AscFonts = window['AscFonts'];
|
||||
if (window["NATIVE_EDITOR_ENJINE"])
|
||||
window.setImmediate = function(fn) { fn(); };
|
||||
|
||||
var setImmediate = window.setImmediate;
|
||||
|
||||
//desktop_fetch
|
||||
|
||||
//polyfill
|
||||
|
||||
@ -495,9 +495,11 @@ static const int FD_Ascii_Names_Offsets[256] =
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
||||
};
|
||||
|
||||
#define FONTS_DICT_UNICODE_NAMES_COUNT 91
|
||||
static const FD_FontMapRecW FD_Unicode_Names[FONTS_DICT_UNICODE_NAMES_COUNT] =
|
||||
#define FONTS_DICT_UNICODE_NAMES_COUNT 93
|
||||
static const FD_FontMapRecW FD_Unicode_Names[FONTS_DICT_UNICODE_NAMES_COUNT] =
|
||||
{
|
||||
{ L"@ËÎÌå", 579, -1, -1, -1 },
|
||||
{ L"ËÎÌå", 579, -1, -1, -1 },
|
||||
{ L"HGP創英角ゴシックUB", 336, -1, -1, -1 },
|
||||
{ L"HGP創英角ポップ体", 330, -1, -1, -1 },
|
||||
{ L"HGP創英プレゼンスEB", 333, -1, -1, -1 },
|
||||
@ -588,7 +590,7 @@ static const FD_FontMapRecW FD_Unicode_Names[FONTS_DICT_UNICODE_NAMES_COUNT] =
|
||||
{ L"MS ゴシック", 452, -1, -1, -1 },
|
||||
{ L"MS 明朝", 459, -1, -1, -1 },
|
||||
{ L"MS Pゴシック", 454, -1, -1, -1 },
|
||||
{ L"MS P明朝", 460, -1, -1, -1 },
|
||||
{ L"MS P明朝", 460, -1, -1, -1 }
|
||||
};
|
||||
|
||||
typedef struct FD_Font_Rec
|
||||
@ -1320,4 +1322,4 @@ static const FD_Font FD_Ascii_Files[FONTS_DICT_ASCII_FONTS_COUNT] =
|
||||
|
||||
// error : 0
|
||||
|
||||
#endif /* _FONT_DICTIONARY_H */
|
||||
#endif /* _FONT_DICTIONARY_H */
|
||||
|
||||
@ -382,6 +382,35 @@ bool CFormFieldInfo::CSignatureFormPr::GetDate() const
|
||||
return m_bDate;
|
||||
}
|
||||
|
||||
//
|
||||
CFormFieldInfo::CDateTimeFormPr::CDateTimeFormPr()
|
||||
{
|
||||
}
|
||||
void CFormFieldInfo::CDateTimeFormPr::SetValue(const std::wstring& wsValue)
|
||||
{
|
||||
m_wsValue = wsValue;
|
||||
}
|
||||
void CFormFieldInfo::CDateTimeFormPr::SetPlaceHolder(const std::wstring& wsValue)
|
||||
{
|
||||
m_wsPlaceHolder = wsValue;
|
||||
}
|
||||
void CFormFieldInfo::CDateTimeFormPr::SetFormat(const std::wstring& wsValue)
|
||||
{
|
||||
m_wsFormat = wsValue;
|
||||
}
|
||||
const std::wstring& CFormFieldInfo::CDateTimeFormPr::GetValue() const
|
||||
{
|
||||
return m_wsValue;
|
||||
}
|
||||
const std::wstring& CFormFieldInfo::CDateTimeFormPr::GetPlaceHolder() const
|
||||
{
|
||||
return m_wsPlaceHolder;
|
||||
}
|
||||
const std::wstring& CFormFieldInfo::CDateTimeFormPr::GetFormat() const
|
||||
{
|
||||
return m_wsFormat;
|
||||
}
|
||||
|
||||
//
|
||||
CFormFieldInfo::CFormFieldInfo()
|
||||
{
|
||||
@ -542,6 +571,10 @@ bool CFormFieldInfo::IsSignature() const
|
||||
{
|
||||
return (m_nType == 5);
|
||||
}
|
||||
bool CFormFieldInfo::IsDateTime() const
|
||||
{
|
||||
return (m_nType == 6);
|
||||
};
|
||||
CFormFieldInfo::CTextFormPr* CFormFieldInfo::GetTextFormPr()
|
||||
{
|
||||
return &m_oTextPr;
|
||||
@ -582,3 +615,11 @@ const CFormFieldInfo::CSignatureFormPr* CFormFieldInfo::GetSignaturePr() const
|
||||
{
|
||||
return &m_oSignaturePr;
|
||||
}
|
||||
CFormFieldInfo::CDateTimeFormPr* CFormFieldInfo::GetDateTimeFormPr()
|
||||
{
|
||||
return &m_oDateTimePr;
|
||||
}
|
||||
const CFormFieldInfo::CDateTimeFormPr* CFormFieldInfo::GetDateTimePr() const
|
||||
{
|
||||
return &m_oDateTimePr;
|
||||
}
|
||||
|
||||
@ -241,6 +241,26 @@ public:
|
||||
std::wstring m_wsCert;
|
||||
bool m_bDate;
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CDateTimeFormPr
|
||||
{
|
||||
public:
|
||||
CDateTimeFormPr();
|
||||
|
||||
void SetValue(const std::wstring& wsValue);
|
||||
void SetPlaceHolder(const std::wstring& wsValue);
|
||||
void SetFormat(const std::wstring& wsValue);
|
||||
|
||||
const std::wstring& GetValue() const;
|
||||
const std::wstring& GetPlaceHolder() const;
|
||||
const std::wstring& GetFormat() const;
|
||||
|
||||
private:
|
||||
|
||||
std::wstring m_wsValue;
|
||||
std::wstring m_wsPlaceHolder;
|
||||
std::wstring m_wsFormat;
|
||||
};
|
||||
|
||||
public:
|
||||
CFormFieldInfo();
|
||||
@ -285,6 +305,7 @@ public:
|
||||
bool IsCheckBox() const;
|
||||
bool IsPicture() const;
|
||||
bool IsSignature() const;
|
||||
bool IsDateTime() const;
|
||||
|
||||
CTextFormPr* GetTextFormPr();
|
||||
const CTextFormPr* GetTextPr() const;
|
||||
@ -300,7 +321,10 @@ public:
|
||||
|
||||
CSignatureFormPr* GetSignatureFormPr();
|
||||
const CSignatureFormPr* GetSignaturePr() const;
|
||||
|
||||
|
||||
CDateTimeFormPr* GetDateTimeFormPr();
|
||||
const CDateTimeFormPr* GetDateTimePr() const;
|
||||
|
||||
private:
|
||||
int m_nType;
|
||||
double m_dX;
|
||||
@ -324,6 +348,7 @@ private:
|
||||
CCheckBoxFormPr m_oCheckBoxPr;
|
||||
CPictureFormPr m_oPicturePr;
|
||||
CSignatureFormPr m_oSignaturePr;
|
||||
CDateTimeFormPr m_oDateTimePr;
|
||||
};
|
||||
|
||||
#endif // _BUILD_FORMFIELD_H_
|
||||
|
||||
@ -125,222 +125,227 @@ const long c_nHtmlRendrerer3 = 0x0011;
|
||||
const long c_nHtmlRendrererText = 0x0012;
|
||||
const long c_nQRenderer = 0x0013;
|
||||
|
||||
const int c_nAdditionalParamBreak = 0x00;
|
||||
|
||||
// типы команд
|
||||
const long c_nCommandLongTypeOnlyText = 0x1000;
|
||||
|
||||
class IFormField
|
||||
{
|
||||
public:
|
||||
IFormField() {}
|
||||
virtual ~IFormField() {}
|
||||
IFormField() {}
|
||||
virtual ~IFormField() {}
|
||||
};
|
||||
|
||||
// IRenderer
|
||||
class IRenderer : public IGrObject
|
||||
{
|
||||
public:
|
||||
bool m_bUseTransformCoordsToIdentity;
|
||||
bool m_bUseTransformCoordsToIdentity;
|
||||
|
||||
public:
|
||||
IRenderer()
|
||||
{
|
||||
m_bUseTransformCoordsToIdentity = false;
|
||||
}
|
||||
IRenderer()
|
||||
{
|
||||
m_bUseTransformCoordsToIdentity = false;
|
||||
}
|
||||
|
||||
public:
|
||||
// тип рендерера-----------------------------------------------------------------------------
|
||||
virtual HRESULT get_Type(LONG* lType) = 0;
|
||||
//-------- Функции для работы со страницей --------------------------------------------------
|
||||
virtual HRESULT NewPage() = 0;
|
||||
virtual HRESULT get_Height(double* dHeight) = 0;
|
||||
virtual HRESULT put_Height(const double& dHeight) = 0;
|
||||
virtual HRESULT get_Width(double* dWidth) = 0;
|
||||
virtual HRESULT put_Width(const double& dWidth) = 0;
|
||||
virtual HRESULT get_DpiX(double* dDpiX) = 0;
|
||||
virtual HRESULT get_DpiY(double* dDpiY) = 0;
|
||||
// тип рендерера-----------------------------------------------------------------------------
|
||||
virtual HRESULT get_Type(LONG* lType) = 0;
|
||||
//-------- Функции для работы со страницей --------------------------------------------------
|
||||
virtual HRESULT NewPage() = 0;
|
||||
virtual HRESULT get_Height(double* dHeight) = 0;
|
||||
virtual HRESULT put_Height(const double& dHeight) = 0;
|
||||
virtual HRESULT get_Width(double* dWidth) = 0;
|
||||
virtual HRESULT put_Width(const double& dWidth) = 0;
|
||||
virtual HRESULT get_DpiX(double* dDpiX) = 0;
|
||||
virtual HRESULT get_DpiY(double* dDpiY) = 0;
|
||||
|
||||
// pen --------------------------------------------------------------------------------------
|
||||
virtual HRESULT get_PenColor(LONG* lColor) = 0;
|
||||
virtual HRESULT put_PenColor(const LONG& lColor) = 0;
|
||||
virtual HRESULT get_PenAlpha(LONG* lAlpha) = 0;
|
||||
virtual HRESULT put_PenAlpha(const LONG& lAlpha) = 0;
|
||||
virtual HRESULT get_PenSize(double* dSize) = 0;
|
||||
virtual HRESULT put_PenSize(const double& dSize) = 0;
|
||||
virtual HRESULT get_PenDashStyle(BYTE* val) = 0;
|
||||
virtual HRESULT put_PenDashStyle(const BYTE& val) = 0;
|
||||
virtual HRESULT get_PenLineStartCap(BYTE* val) = 0;
|
||||
virtual HRESULT put_PenLineStartCap(const BYTE& val) = 0;
|
||||
virtual HRESULT get_PenLineEndCap(BYTE* val) = 0;
|
||||
virtual HRESULT put_PenLineEndCap(const BYTE& val) = 0;
|
||||
virtual HRESULT get_PenLineJoin(BYTE* val) = 0;
|
||||
virtual HRESULT put_PenLineJoin(const BYTE& val) = 0;
|
||||
virtual HRESULT get_PenDashOffset(double* dOffset) = 0;
|
||||
virtual HRESULT put_PenDashOffset(const double& dOffset) = 0;
|
||||
virtual HRESULT get_PenAlign(LONG* lAlign) = 0;
|
||||
virtual HRESULT put_PenAlign(const LONG& lAlign) = 0;
|
||||
virtual HRESULT get_PenMiterLimit(double* dOffset) = 0;
|
||||
virtual HRESULT put_PenMiterLimit(const double& dOffset) = 0;
|
||||
virtual HRESULT PenDashPattern(double* pPattern, LONG lCount)= 0;
|
||||
// pen --------------------------------------------------------------------------------------
|
||||
virtual HRESULT get_PenColor(LONG* lColor) = 0;
|
||||
virtual HRESULT put_PenColor(const LONG& lColor) = 0;
|
||||
virtual HRESULT get_PenAlpha(LONG* lAlpha) = 0;
|
||||
virtual HRESULT put_PenAlpha(const LONG& lAlpha) = 0;
|
||||
virtual HRESULT get_PenSize(double* dSize) = 0;
|
||||
virtual HRESULT put_PenSize(const double& dSize) = 0;
|
||||
virtual HRESULT get_PenDashStyle(BYTE* val) = 0;
|
||||
virtual HRESULT put_PenDashStyle(const BYTE& val) = 0;
|
||||
virtual HRESULT get_PenLineStartCap(BYTE* val) = 0;
|
||||
virtual HRESULT put_PenLineStartCap(const BYTE& val) = 0;
|
||||
virtual HRESULT get_PenLineEndCap(BYTE* val) = 0;
|
||||
virtual HRESULT put_PenLineEndCap(const BYTE& val) = 0;
|
||||
virtual HRESULT get_PenLineJoin(BYTE* val) = 0;
|
||||
virtual HRESULT put_PenLineJoin(const BYTE& val) = 0;
|
||||
virtual HRESULT get_PenDashOffset(double* dOffset) = 0;
|
||||
virtual HRESULT put_PenDashOffset(const double& dOffset) = 0;
|
||||
virtual HRESULT get_PenAlign(LONG* lAlign) = 0;
|
||||
virtual HRESULT put_PenAlign(const LONG& lAlign) = 0;
|
||||
virtual HRESULT get_PenMiterLimit(double* dOffset) = 0;
|
||||
virtual HRESULT put_PenMiterLimit(const double& dOffset) = 0;
|
||||
virtual HRESULT PenDashPattern(double* pPattern, LONG lCount) = 0;
|
||||
|
||||
// brush ------------------------------------------------------------------------------------
|
||||
virtual HRESULT get_BrushType(LONG* lType) = 0;
|
||||
virtual HRESULT put_BrushType(const LONG& lType) = 0;
|
||||
virtual HRESULT get_BrushColor1(LONG* lColor) = 0;
|
||||
virtual HRESULT put_BrushColor1(const LONG& lColor) = 0;
|
||||
virtual HRESULT get_BrushAlpha1(LONG* lAlpha) = 0;
|
||||
virtual HRESULT put_BrushAlpha1(const LONG& lAlpha) = 0;
|
||||
virtual HRESULT get_BrushColor2(LONG* lColor) = 0;
|
||||
virtual HRESULT put_BrushColor2(const LONG& lColor) = 0;
|
||||
virtual HRESULT get_BrushAlpha2(LONG* lAlpha) = 0;
|
||||
virtual HRESULT put_BrushAlpha2(const LONG& lAlpha) = 0;
|
||||
virtual HRESULT get_BrushTexturePath(std::wstring* bsPath) = 0;
|
||||
virtual HRESULT put_BrushTexturePath(const std::wstring& bsPath) = 0;
|
||||
virtual HRESULT get_BrushTextureMode(LONG* lMode) = 0;
|
||||
virtual HRESULT put_BrushTextureMode(const LONG& lMode) = 0;
|
||||
virtual HRESULT get_BrushTextureAlpha(LONG* lTxAlpha) = 0;
|
||||
virtual HRESULT put_BrushTextureAlpha(const LONG& lTxAlpha) = 0;
|
||||
virtual HRESULT get_BrushLinearAngle(double* dAngle) = 0;
|
||||
virtual HRESULT put_BrushLinearAngle(const double& dAngle) = 0;
|
||||
virtual HRESULT BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height) = 0;
|
||||
virtual HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height) = 0;
|
||||
// brush ------------------------------------------------------------------------------------
|
||||
virtual HRESULT get_BrushType(LONG* lType) = 0;
|
||||
virtual HRESULT put_BrushType(const LONG& lType) = 0;
|
||||
virtual HRESULT get_BrushColor1(LONG* lColor) = 0;
|
||||
virtual HRESULT put_BrushColor1(const LONG& lColor) = 0;
|
||||
virtual HRESULT get_BrushAlpha1(LONG* lAlpha) = 0;
|
||||
virtual HRESULT put_BrushAlpha1(const LONG& lAlpha) = 0;
|
||||
virtual HRESULT get_BrushColor2(LONG* lColor) = 0;
|
||||
virtual HRESULT put_BrushColor2(const LONG& lColor) = 0;
|
||||
virtual HRESULT get_BrushAlpha2(LONG* lAlpha) = 0;
|
||||
virtual HRESULT put_BrushAlpha2(const LONG& lAlpha) = 0;
|
||||
virtual HRESULT get_BrushTexturePath(std::wstring* bsPath) = 0;
|
||||
virtual HRESULT put_BrushTexturePath(const std::wstring& bsPath) = 0;
|
||||
virtual HRESULT get_BrushTextureMode(LONG* lMode) = 0;
|
||||
virtual HRESULT put_BrushTextureMode(const LONG& lMode) = 0;
|
||||
virtual HRESULT get_BrushTextureAlpha(LONG* lTxAlpha) = 0;
|
||||
virtual HRESULT put_BrushTextureAlpha(const LONG& lTxAlpha) = 0;
|
||||
virtual HRESULT get_BrushLinearAngle(double* dAngle) = 0;
|
||||
virtual HRESULT put_BrushLinearAngle(const double& dAngle) = 0;
|
||||
virtual HRESULT BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height) = 0;
|
||||
virtual HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height) = 0;
|
||||
|
||||
virtual HRESULT put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount) = 0;
|
||||
//virtual void put_BrushGradInfo(const NSStructures::GradientInfo &_ginfo) {};
|
||||
virtual HRESULT put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount) = 0;
|
||||
//virtual void put_BrushGradInfo(const NSStructures::GradientInfo &_ginfo) {};
|
||||
|
||||
// font -------------------------------------------------------------------------------------
|
||||
virtual HRESULT get_FontName(std::wstring* bsName) = 0;
|
||||
virtual HRESULT put_FontName(const std::wstring& bsName) = 0;
|
||||
virtual HRESULT get_FontPath(std::wstring* bsName) = 0;
|
||||
virtual HRESULT put_FontPath(const std::wstring& bsName) = 0;
|
||||
virtual HRESULT get_FontSize(double* dSize) = 0;
|
||||
virtual HRESULT put_FontSize(const double& dSize) = 0;
|
||||
virtual HRESULT get_FontStyle(LONG* lStyle) = 0;
|
||||
virtual HRESULT put_FontStyle(const LONG& lStyle) = 0;
|
||||
virtual HRESULT get_FontStringGID(INT* bGID) = 0;
|
||||
virtual HRESULT put_FontStringGID(const INT& bGID) = 0;
|
||||
virtual HRESULT get_FontCharSpace(double* dSpace) = 0;
|
||||
virtual HRESULT put_FontCharSpace(const double& dSpace) = 0;
|
||||
virtual HRESULT get_FontFaceIndex(int* lFaceIndex) = 0;
|
||||
virtual HRESULT put_FontFaceIndex(const int& lFaceIndex) = 0;
|
||||
// font -------------------------------------------------------------------------------------
|
||||
virtual HRESULT get_FontName(std::wstring* bsName) = 0;
|
||||
virtual HRESULT put_FontName(const std::wstring& bsName) = 0;
|
||||
virtual HRESULT get_FontPath(std::wstring* bsName) = 0;
|
||||
virtual HRESULT put_FontPath(const std::wstring& bsName) = 0;
|
||||
virtual HRESULT get_FontSize(double* dSize) = 0;
|
||||
virtual HRESULT put_FontSize(const double& dSize) = 0;
|
||||
virtual HRESULT get_FontStyle(LONG* lStyle) = 0;
|
||||
virtual HRESULT put_FontStyle(const LONG& lStyle) = 0;
|
||||
virtual HRESULT get_FontStringGID(INT* bGID) = 0;
|
||||
virtual HRESULT put_FontStringGID(const INT& bGID) = 0;
|
||||
virtual HRESULT get_FontCharSpace(double* dSpace) = 0;
|
||||
virtual HRESULT put_FontCharSpace(const double& dSpace) = 0;
|
||||
virtual HRESULT get_FontFaceIndex(int* lFaceIndex) = 0;
|
||||
virtual HRESULT put_FontFaceIndex(const int& lFaceIndex) = 0;
|
||||
|
||||
//-------- Функции для вывода текста --------------------------------------------------------
|
||||
virtual HRESULT CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
//-------- Функции для вывода текста --------------------------------------------------------
|
||||
virtual HRESULT CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
|
||||
virtual HRESULT CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT CommandDrawTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT CommandDrawTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
|
||||
virtual HRESULT CommandDrawTextCHAR2(unsigned int* codepoints, const unsigned int& codepointscount, const unsigned int& gid, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
LONG c = (NULL == codepoints) ? 32 : codepoints[0];
|
||||
return CommandDrawTextExCHAR(c, (LONG)gid, x, y, w, h);
|
||||
}
|
||||
virtual HRESULT CommandDrawTextCHAR2(unsigned int* codepoints, const unsigned int& codepointscount, const unsigned int& gid, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
LONG c = (NULL == codepoints) ? 32 : codepoints[0];
|
||||
return CommandDrawTextExCHAR(c, (LONG)gid, x, y, w, h);
|
||||
}
|
||||
|
||||
//-------- Маркеры для команд ---------------------------------------------------------------
|
||||
virtual HRESULT BeginCommand(const DWORD& lType) = 0;
|
||||
virtual HRESULT EndCommand(const DWORD& lType) = 0;
|
||||
//-------- Маркеры для команд ---------------------------------------------------------------
|
||||
virtual HRESULT BeginCommand(const DWORD& lType) = 0;
|
||||
virtual HRESULT EndCommand(const DWORD& lType) = 0;
|
||||
|
||||
//-------- Функции для работы с Graphics Path -----------------------------------------------
|
||||
virtual HRESULT PathCommandMoveTo(const double& x, const double& y) = 0;
|
||||
virtual HRESULT PathCommandLineTo(const double& x, const double& y) = 0;
|
||||
virtual HRESULT PathCommandLinesTo(double* points, const int& count) = 0;
|
||||
virtual HRESULT PathCommandCurveTo(const double& x1, const double& y1, const double& x2, const double& y2, const double& x3, const double& y3) = 0;
|
||||
virtual HRESULT PathCommandCurvesTo(double* points, const int& count) = 0;
|
||||
virtual HRESULT PathCommandArcTo(const double& x, const double& y, const double& w, const double& h, const double& startAngle, const double& sweepAngle) = 0;
|
||||
virtual HRESULT PathCommandClose() = 0;
|
||||
virtual HRESULT PathCommandEnd() = 0;
|
||||
virtual HRESULT DrawPath(const LONG& nType) = 0;
|
||||
virtual HRESULT PathCommandStart() = 0;
|
||||
virtual HRESULT PathCommandGetCurrentPoint(double* x, double* y) = 0;
|
||||
//-------- Функции для работы с Graphics Path -----------------------------------------------
|
||||
virtual HRESULT PathCommandMoveTo(const double& x, const double& y) = 0;
|
||||
virtual HRESULT PathCommandLineTo(const double& x, const double& y) = 0;
|
||||
virtual HRESULT PathCommandLinesTo(double* points, const int& count) = 0;
|
||||
virtual HRESULT PathCommandCurveTo(const double& x1, const double& y1, const double& x2, const double& y2, const double& x3, const double& y3) = 0;
|
||||
virtual HRESULT PathCommandCurvesTo(double* points, const int& count) = 0;
|
||||
virtual HRESULT PathCommandArcTo(const double& x, const double& y, const double& w, const double& h, const double& startAngle, const double& sweepAngle) = 0;
|
||||
virtual HRESULT PathCommandClose() = 0;
|
||||
virtual HRESULT PathCommandEnd() = 0;
|
||||
virtual HRESULT DrawPath(const LONG& nType) = 0;
|
||||
virtual HRESULT PathCommandStart() = 0;
|
||||
virtual HRESULT PathCommandGetCurrentPoint(double* x, double* y) = 0;
|
||||
|
||||
virtual HRESULT PathCommandTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT PathCommandText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT PathCommandTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT PathCommandText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
|
||||
virtual HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT PathCommandTextEx(const std::wstring& sText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT PathCommandTextEx(const std::wstring& sText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
|
||||
//-------- Функции для вывода изображений ---------------------------------------------------
|
||||
virtual HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT DrawImageFromFile(const std::wstring&, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha = 255) = 0;
|
||||
//-------- Функции для вывода изображений ---------------------------------------------------
|
||||
virtual HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT DrawImageFromFile(const std::wstring&, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha = 255) = 0;
|
||||
|
||||
// transform --------------------------------------------------------------------------------
|
||||
virtual HRESULT GetCommandParams(double* dAngle, double* dLeft, double* dTop, double* dWidth, double* dHeight, DWORD* lFlags)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT SetCommandParams(double dAngle, double dLeft, double dTop, double dWidth, double dHeight, DWORD lFlags)
|
||||
{
|
||||
if ((dWidth <= 1) || (dHeight <= 1))
|
||||
lFlags = 0;
|
||||
// transform --------------------------------------------------------------------------------
|
||||
virtual HRESULT GetCommandParams(double* dAngle, double* dLeft, double* dTop, double* dWidth, double* dHeight, DWORD* lFlags)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT SetCommandParams(double dAngle, double dLeft, double dTop, double dWidth, double dHeight, DWORD lFlags)
|
||||
{
|
||||
if ((dWidth <= 1) || (dHeight <= 1))
|
||||
lFlags = 0;
|
||||
|
||||
INT bFlipX = (0 != (c_nParamFlipX & lFlags));
|
||||
INT bFlipY = (0 != (c_nParamFlipY & lFlags));
|
||||
INT bFlipX = (0 != (c_nParamFlipX & lFlags));
|
||||
INT bFlipY = (0 != (c_nParamFlipY & lFlags));
|
||||
|
||||
float m11 = bFlipX ? -1.0f : 1.0f;
|
||||
float m22 = bFlipY ? -1.0f : 1.0f;
|
||||
float m11 = bFlipX ? -1.0f : 1.0f;
|
||||
float m22 = bFlipY ? -1.0f : 1.0f;
|
||||
|
||||
Aggplus::CMatrix oMatrix(1, 0, 0, 1, 0, 0);
|
||||
Aggplus::CMatrix oMatrix(1, 0, 0, 1, 0, 0);
|
||||
|
||||
if ((0 != dAngle) || (0 != lFlags))
|
||||
{
|
||||
double dCentreX = (double)(dLeft + dWidth / 2.0);
|
||||
double dCentreY = (double)(dTop + dHeight / 2.0);
|
||||
if ((0 != dAngle) || (0 != lFlags))
|
||||
{
|
||||
double dCentreX = (double)(dLeft + dWidth / 2.0);
|
||||
double dCentreY = (double)(dTop + dHeight / 2.0);
|
||||
|
||||
oMatrix.Translate(-dCentreX, -dCentreY , Aggplus::MatrixOrderAppend);
|
||||
oMatrix.Translate(-dCentreX, -dCentreY , Aggplus::MatrixOrderAppend);
|
||||
|
||||
oMatrix.Rotate(dAngle , Aggplus::MatrixOrderAppend);
|
||||
oMatrix.Scale(m11, m22 , Aggplus::MatrixOrderAppend);
|
||||
oMatrix.Rotate(dAngle , Aggplus::MatrixOrderAppend);
|
||||
oMatrix.Scale(m11, m22 , Aggplus::MatrixOrderAppend);
|
||||
|
||||
oMatrix.Translate(dCentreX, dCentreY , Aggplus::MatrixOrderAppend);
|
||||
}
|
||||
double mass[6];
|
||||
oMatrix.GetElements(mass);
|
||||
SetTransform(mass[0], mass[1], mass[2], mass[3], mass[4], mass[5]);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT SetBaseTransform(const double& m1, const double& m2, const double& m3, const double& m4, const double& m5, const double& m6) { return S_OK; }
|
||||
virtual HRESULT SetTransform(const double& m1, const double& m2, const double& m3, const double& m4, const double& m5, const double& m6) = 0;
|
||||
virtual HRESULT GetTransform(double *pdA, double *pdB, double *pdC, double *pdD, double *pdE, double *pdF) = 0;
|
||||
virtual HRESULT ResetTransform() = 0;
|
||||
oMatrix.Translate(dCentreX, dCentreY , Aggplus::MatrixOrderAppend);
|
||||
}
|
||||
double mass[6];
|
||||
oMatrix.GetElements(mass);
|
||||
SetTransform(mass[0], mass[1], mass[2], mass[3], mass[4], mass[5]);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT SetBaseTransform(const double& m1, const double& m2, const double& m3, const double& m4, const double& m5, const double& m6) { return S_OK; }
|
||||
virtual HRESULT SetTransform(const double& m1, const double& m2, const double& m3, const double& m4, const double& m5, const double& m6) = 0;
|
||||
virtual HRESULT GetTransform(double *pdA, double *pdB, double *pdC, double *pdD, double *pdE, double *pdF) = 0;
|
||||
virtual HRESULT ResetTransform() = 0;
|
||||
|
||||
// -----------------------------------------------------------------------------------------
|
||||
virtual HRESULT get_ClipMode(LONG* plMode) = 0;
|
||||
virtual HRESULT put_ClipMode(const LONG& lMode) = 0;
|
||||
// -----------------------------------------------------------------------------------------
|
||||
virtual HRESULT get_ClipMode(LONG* plMode) = 0;
|
||||
virtual HRESULT put_ClipMode(const LONG& lMode) = 0;
|
||||
|
||||
// additiaonal params ----------------------------------------------------------------------
|
||||
virtual HRESULT CommandLong(const LONG& lType, const LONG& lCommand) = 0;
|
||||
virtual HRESULT CommandDouble(const LONG& lType, const double& dCommand) = 0;
|
||||
virtual HRESULT CommandString(const LONG& lType, const std::wstring& sCommand) = 0;
|
||||
// additiaonal params ----------------------------------------------------------------------
|
||||
virtual HRESULT CommandLong(const LONG& lType, const LONG& lCommand) = 0;
|
||||
virtual HRESULT CommandDouble(const LONG& lType, const double& dCommand) = 0;
|
||||
virtual HRESULT CommandString(const LONG& lType, const std::wstring& sCommand) = 0;
|
||||
|
||||
virtual HRESULT StartConvertCoordsToIdentity()
|
||||
{
|
||||
m_bUseTransformCoordsToIdentity = true;
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT EndConvertCoordsToIdentity()
|
||||
{
|
||||
m_bUseTransformCoordsToIdentity = false;
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT AddHyperlink(const double& dX, const double& dY, const double& dW, const double& dH, const std::wstring& wsUrl, const std::wstring& wsTooltip) {return S_OK;}
|
||||
virtual HRESULT AddLink(const double& dX, const double& dY, const double& dW, const double& dH, const double& dDestX, const double& dDestY, const int& nPage) {return S_OK;}
|
||||
virtual HRESULT AddFormField(IFormField* pField) {return S_OK;}
|
||||
virtual HRESULT DocInfo(const std::wstring& wsTitle, const std::wstring& wsCreator, const std::wstring& wsSubject, const std::wstring& wsKeywords) {return S_OK;}
|
||||
virtual HRESULT StartConvertCoordsToIdentity()
|
||||
{
|
||||
m_bUseTransformCoordsToIdentity = true;
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT EndConvertCoordsToIdentity()
|
||||
{
|
||||
m_bUseTransformCoordsToIdentity = false;
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT AddHyperlink(const double& dX, const double& dY, const double& dW, const double& dH, const std::wstring& wsUrl, const std::wstring& wsTooltip) {return S_OK;}
|
||||
virtual HRESULT AddLink(const double& dX, const double& dY, const double& dW, const double& dH, const double& dDestX, const double& dDestY, const int& nPage) {return S_OK;}
|
||||
virtual HRESULT AddFormField(IFormField* pField) {return S_OK;}
|
||||
virtual HRESULT DocInfo(const std::wstring& wsTitle, const std::wstring& wsCreator, const std::wstring& wsSubject, const std::wstring& wsKeywords) {return S_OK;}
|
||||
|
||||
virtual HRESULT IsExistAdditionalParam(const int& type) {return S_FALSE;}
|
||||
virtual HRESULT GetAdditionalParam(const int& type, std::string& result) {return S_FALSE;}
|
||||
};
|
||||
|
||||
#define PROPERTY_RENDERER(NameBase, Name, Type) \
|
||||
STDMETHOD(get_##NameBase##Name)(Type* pVal) \
|
||||
{ \
|
||||
if (NULL == pVal) \
|
||||
return S_FALSE; \
|
||||
*pVal = m_o##NameBase.##Name; \
|
||||
return S_OK; \
|
||||
} \
|
||||
STDMETHOD(put_##NameBase##Name)(Type Val) \
|
||||
{ \
|
||||
m_o##NameBase.##Name = Val; \
|
||||
return S_OK; \
|
||||
}
|
||||
#define PROPERTY_RENDERER(NameBase, Name, Type) \
|
||||
STDMETHOD(get_##NameBase##Name)(Type* pVal) \
|
||||
{ \
|
||||
if (NULL == pVal) \
|
||||
return S_FALSE; \
|
||||
*pVal = m_o##NameBase.##Name; \
|
||||
return S_OK; \
|
||||
} \
|
||||
STDMETHOD(put_##NameBase##Name)(Type Val) \
|
||||
{ \
|
||||
m_o##NameBase.##Name = Val; \
|
||||
return S_OK; \
|
||||
}
|
||||
|
||||
// exapmle:
|
||||
// PROPERTY_RENDERER(Pen, Color, LONG)
|
||||
|
||||
@ -36,257 +36,289 @@
|
||||
|
||||
namespace NSOnlineOfficeBinToPdf
|
||||
{
|
||||
class CMetafileToRenderterRaster_private
|
||||
{
|
||||
public:
|
||||
class CMetafileToRenderterRaster_private
|
||||
{
|
||||
public:
|
||||
NSFonts::IApplicationFonts* appFonts;
|
||||
|
||||
int m_nRasterFormat;
|
||||
int m_nSaveType; // 0 = stretch, 1 = aspect (width == maxsize)
|
||||
bool m_bIsOnlyFirst;
|
||||
std::wstring m_sFileName;
|
||||
int m_nRasterW;
|
||||
int m_nRasterH;
|
||||
int m_nRasterFormat;
|
||||
|
||||
double m_dDpiX;
|
||||
double m_dDpiY;
|
||||
// save_type - combined integer
|
||||
// saveType = save_type & 0x0F
|
||||
// saveFlags = (save_type & 0xF0) >> 1
|
||||
// saveType:
|
||||
// 0 - stretch
|
||||
// 1 - делаем максимально большую картинку с аспектом как у страницы и вписанную в [m_nRasterW x m_nRasterH]
|
||||
// 2 - nRasterW = (int)((pageW * m_internal->m_dDpiX / 25.4) + 0.5);
|
||||
// nRasterH = (int)((pageH * m_internal->m_dDpiY / 25.4) + 0.5);
|
||||
// 3 - special mode for clouds (see code)
|
||||
//
|
||||
// saveFlags & 1: change w/h by orientation
|
||||
int m_nSaveType;
|
||||
bool m_bIsOnlyFirst;
|
||||
std::wstring m_sFileName;
|
||||
int m_nRasterW;
|
||||
int m_nRasterH;
|
||||
|
||||
public:
|
||||
CMetafileToRenderterRaster_private()
|
||||
{
|
||||
appFonts = NULL;
|
||||
double m_dDpiX;
|
||||
double m_dDpiY;
|
||||
|
||||
m_nRasterFormat = 4;
|
||||
m_nSaveType = 2;
|
||||
m_bIsOnlyFirst = true;
|
||||
m_sFileName = L"";
|
||||
public:
|
||||
CMetafileToRenderterRaster_private()
|
||||
{
|
||||
appFonts = NULL;
|
||||
|
||||
m_nRasterW = 100;
|
||||
m_nRasterH = 100;
|
||||
m_nRasterFormat = 4;
|
||||
m_nSaveType = 2;
|
||||
m_bIsOnlyFirst = true;
|
||||
m_sFileName = L"";
|
||||
|
||||
m_dDpiX = 96.0;
|
||||
m_dDpiY = 96.0;
|
||||
}
|
||||
m_nRasterW = 100;
|
||||
m_nRasterH = 100;
|
||||
|
||||
m_dDpiX = 96.0;
|
||||
m_dDpiY = 96.0;
|
||||
}
|
||||
|
||||
~CMetafileToRenderterRaster_private()
|
||||
{
|
||||
}
|
||||
};
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
CMetafileToRenderterRaster::CMetafileToRenderterRaster(IRenderer* pRenderer) : IMetafileToRenderter(pRenderer)
|
||||
{
|
||||
m_internal = new CMetafileToRenderterRaster_private();
|
||||
}
|
||||
CMetafileToRenderterRaster::~CMetafileToRenderterRaster()
|
||||
{
|
||||
RELEASEOBJECT(m_internal);
|
||||
}
|
||||
CMetafileToRenderterRaster::CMetafileToRenderterRaster(IRenderer* pRenderer) : IMetafileToRenderter(pRenderer)
|
||||
{
|
||||
m_internal = new CMetafileToRenderterRaster_private();
|
||||
}
|
||||
CMetafileToRenderterRaster::~CMetafileToRenderterRaster()
|
||||
{
|
||||
RELEASEOBJECT(m_internal);
|
||||
}
|
||||
|
||||
bool CMetafileToRenderterRaster::ConvertBuffer(BYTE* pBuffer, LONG lBufferLen)
|
||||
{
|
||||
std::wstring sMain = m_internal->m_sFileName;
|
||||
std::wstring sExt = L"";
|
||||
if (!m_internal->m_bIsOnlyFirst)
|
||||
{
|
||||
std::wstring::size_type pos = m_internal->m_sFileName.find_last_of('.');
|
||||
if (std::wstring::npos == pos)
|
||||
return false;
|
||||
bool CMetafileToRenderterRaster::ConvertBuffer(BYTE* pBuffer, LONG lBufferLen)
|
||||
{
|
||||
std::wstring sMain = m_internal->m_sFileName;
|
||||
std::wstring sExt = L"";
|
||||
if (!m_internal->m_bIsOnlyFirst)
|
||||
{
|
||||
std::wstring::size_type pos = m_internal->m_sFileName.find_last_of('.');
|
||||
if (std::wstring::npos == pos)
|
||||
return false;
|
||||
|
||||
sMain = m_internal->m_sFileName.substr(0, pos);
|
||||
sExt = m_internal->m_sFileName.substr(pos);
|
||||
}
|
||||
sMain = m_internal->m_sFileName.substr(0, pos);
|
||||
sExt = m_internal->m_sFileName.substr(pos);
|
||||
}
|
||||
|
||||
CMetafilePagesInfo oInfo;
|
||||
oInfo.CheckBuffer(pBuffer, lBufferLen);
|
||||
CMetafilePagesInfo oInfo;
|
||||
oInfo.CheckBuffer(pBuffer, lBufferLen);
|
||||
|
||||
int nPagesCount = oInfo.PagesCount;
|
||||
if (0 == nPagesCount)
|
||||
return false;
|
||||
int nPagesCount = oInfo.PagesCount;
|
||||
if (0 == nPagesCount)
|
||||
return false;
|
||||
|
||||
if (m_internal->m_bIsOnlyFirst)
|
||||
nPagesCount = 1;
|
||||
if (m_internal->m_bIsOnlyFirst)
|
||||
nPagesCount = 1;
|
||||
|
||||
NSFonts::IFontManager* pFontManager = m_internal->appFonts->GenerateFontManager();
|
||||
NSFonts::IFontsCache* pFontsCache = NSFonts::NSFontCache::Create();
|
||||
pFontsCache->SetStreams(m_internal->appFonts->GetStreams());
|
||||
pFontManager->SetOwnerCache(pFontsCache);
|
||||
pFontsCache->SetStreams(m_internal->appFonts->GetStreams());
|
||||
pFontManager->SetOwnerCache(pFontsCache);
|
||||
|
||||
CImageFilesCache* pImagesCache = new CImageFilesCache(m_internal->appFonts);
|
||||
CImageFilesCache* pImagesCache = new CImageFilesCache(m_internal->appFonts);
|
||||
|
||||
for (int nPageIndex = 0; nPageIndex < nPagesCount; ++nPageIndex)
|
||||
{
|
||||
CBgraFrame oFrame;
|
||||
int nRasterW = m_internal->m_nRasterW;
|
||||
int nRasterH = m_internal->m_nRasterH;
|
||||
for (int nPageIndex = 0; nPageIndex < nPagesCount; ++nPageIndex)
|
||||
{
|
||||
CBgraFrame oFrame;
|
||||
int nRasterW = m_internal->m_nRasterW;
|
||||
int nRasterH = m_internal->m_nRasterH;
|
||||
|
||||
int nOffsetX = 0;
|
||||
int nResultW = nRasterW;
|
||||
int nResultH = nRasterH;
|
||||
int nOffsetX = 0;
|
||||
int nResultW = nRasterW;
|
||||
int nResultH = nRasterH;
|
||||
|
||||
if (1 == m_internal->m_nSaveType)
|
||||
{
|
||||
double w = oInfo.arSizes[nPageIndex].width;
|
||||
double h = oInfo.arSizes[nPageIndex].height;
|
||||
int nSaveType = m_internal->m_nSaveType & 0x0F;
|
||||
int nSaveFlags = (m_internal->m_nSaveType & 0xF0) >> 4;
|
||||
|
||||
double dKoef1 = nRasterW / w;
|
||||
double dKoef2 = nRasterH / h;
|
||||
if (dKoef1 > dKoef2)
|
||||
dKoef1 = dKoef2;
|
||||
if (nSaveFlags & 0x01)
|
||||
{
|
||||
// change w/h if needed
|
||||
double w = oInfo.arSizes[nPageIndex].width;
|
||||
double h = oInfo.arSizes[nPageIndex].height;
|
||||
if ((w > h && nResultH > nResultW) || (w < h && nResultW > nResultH))
|
||||
{
|
||||
int nTmp = nResultW;
|
||||
nResultW = nResultH;
|
||||
nResultH = nTmp;
|
||||
|
||||
nRasterW = (int)(w * dKoef1 + 0.5);
|
||||
nRasterH = (int)(h * dKoef1 + 0.5);
|
||||
}
|
||||
else if (2 == m_internal->m_nSaveType)
|
||||
{
|
||||
double w = oInfo.arSizes[nPageIndex].width;
|
||||
double h = oInfo.arSizes[nPageIndex].height;
|
||||
nTmp = nRasterW;
|
||||
nRasterW = nRasterH;
|
||||
nRasterH = nTmp;
|
||||
}
|
||||
}
|
||||
|
||||
nRasterW = (int)((w * m_internal->m_dDpiX / 25.4) + 0.5);
|
||||
nRasterH = (int)((h * m_internal->m_dDpiY / 25.4) + 0.5);
|
||||
}
|
||||
else if (3 == m_internal->m_nSaveType)
|
||||
{
|
||||
double w = oInfo.arSizes[nPageIndex].width;
|
||||
double h = oInfo.arSizes[nPageIndex].height;
|
||||
if (1 == nSaveType)
|
||||
{
|
||||
double w = oInfo.arSizes[nPageIndex].width;
|
||||
double h = oInfo.arSizes[nPageIndex].height;
|
||||
|
||||
double dKoef1 = nRasterW / w;
|
||||
double dKoef2 = nRasterH / h;
|
||||
double dKoef1 = nRasterW / w;
|
||||
double dKoef2 = nRasterH / h;
|
||||
if (dKoef1 > dKoef2)
|
||||
dKoef1 = dKoef2;
|
||||
|
||||
if (dKoef1 > dKoef2)
|
||||
{
|
||||
nRasterH = (int)(dKoef1 * h) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
nRasterW = (int)(dKoef2 * w) + 1;
|
||||
nOffsetX = (nRasterW - nResultW) >> 1;
|
||||
}
|
||||
}
|
||||
nRasterW = (int)(w * dKoef1 + 0.5);
|
||||
nRasterH = (int)(h * dKoef1 + 0.5);
|
||||
}
|
||||
else if (2 == nSaveType)
|
||||
{
|
||||
double w = oInfo.arSizes[nPageIndex].width;
|
||||
double h = oInfo.arSizes[nPageIndex].height;
|
||||
|
||||
oFrame.put_Width(nRasterW);
|
||||
oFrame.put_Height(nRasterH);
|
||||
oFrame.put_Stride(4 * nRasterW);
|
||||
nRasterW = (int)((w * m_internal->m_dDpiX / 25.4) + 0.5);
|
||||
nRasterH = (int)((h * m_internal->m_dDpiY / 25.4) + 0.5);
|
||||
}
|
||||
else if (3 == nSaveType)
|
||||
{
|
||||
double w = oInfo.arSizes[nPageIndex].width;
|
||||
double h = oInfo.arSizes[nPageIndex].height;
|
||||
|
||||
BYTE* pDataRaster = new BYTE[4 * nRasterW * nRasterH];
|
||||
memset(pDataRaster, 0xFF, 4 * nRasterW * nRasterH);
|
||||
oFrame.put_Data(pDataRaster);
|
||||
double dKoef1 = nRasterW / w;
|
||||
double dKoef2 = nRasterH / h;
|
||||
|
||||
CGraphicsRenderer oRenderer;
|
||||
oRenderer.SetFontManager(pFontManager);
|
||||
oRenderer.SetImageCache(pImagesCache);
|
||||
if (dKoef1 > dKoef2)
|
||||
{
|
||||
nRasterH = (int)(dKoef1 * h) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
nRasterW = (int)(dKoef2 * w) + 1;
|
||||
nOffsetX = (nRasterW - nResultW) >> 1;
|
||||
}
|
||||
}
|
||||
|
||||
oRenderer.CreateFromBgraFrame(&oFrame);
|
||||
oRenderer.SetTileImageDpi(96.0);
|
||||
oRenderer.SetSwapRGB(false);
|
||||
oFrame.put_Width(nRasterW);
|
||||
oFrame.put_Height(nRasterH);
|
||||
oFrame.put_Stride(4 * nRasterW);
|
||||
|
||||
this->m_pRenderer = &oRenderer;
|
||||
BYTE* pBufferPage = oInfo.arSizes[nPageIndex].data;
|
||||
LONG nLen = lBufferLen - ((LONG)(pBufferPage - pBuffer));
|
||||
NSOnlineOfficeBinToPdf::ConvertBufferToRenderer(pBufferPage, nLen, this);
|
||||
BYTE* pDataRaster = new BYTE[4 * nRasterW * nRasterH];
|
||||
memset(pDataRaster, 0xFF, 4 * nRasterW * nRasterH);
|
||||
oFrame.put_Data(pDataRaster);
|
||||
|
||||
if (3 == m_internal->m_nSaveType)
|
||||
{
|
||||
int nStride = 4 * nResultW;
|
||||
BYTE* pDataResult = new BYTE[nStride * nResultH];
|
||||
CGraphicsRenderer oRenderer;
|
||||
oRenderer.SetFontManager(pFontManager);
|
||||
oRenderer.SetImageCache(pImagesCache);
|
||||
|
||||
if (0 == nOffsetX)
|
||||
{
|
||||
memcpy(pDataResult, pDataRaster, nStride * nResultH);
|
||||
}
|
||||
else
|
||||
{
|
||||
BYTE* pDataCopy = pDataRaster + 4 * nOffsetX;
|
||||
BYTE* pDataDst = pDataResult;
|
||||
int nStrideSrc = 4 * nRasterW;
|
||||
for (int i = 0; i < nResultH; ++i)
|
||||
{
|
||||
memcpy(pDataDst, pDataCopy, nStride);
|
||||
pDataCopy += nStrideSrc;
|
||||
pDataDst += nStride;
|
||||
}
|
||||
}
|
||||
oRenderer.CreateFromBgraFrame(&oFrame);
|
||||
oRenderer.SetTileImageDpi(96.0);
|
||||
oRenderer.SetSwapRGB(false);
|
||||
|
||||
oFrame.put_Data(pDataResult);
|
||||
oFrame.put_Width(nResultW);
|
||||
oFrame.put_Height(nResultH);
|
||||
oFrame.put_Stride(nStride);
|
||||
this->m_pRenderer = &oRenderer;
|
||||
BYTE* pBufferPage = oInfo.arSizes[nPageIndex].data;
|
||||
LONG nLen = lBufferLen - ((LONG)(pBufferPage - pBuffer));
|
||||
NSOnlineOfficeBinToPdf::ConvertBufferToRenderer(pBufferPage, nLen, this);
|
||||
|
||||
RELEASEARRAYOBJECTS(pDataRaster);
|
||||
}
|
||||
if (3 == nSaveType)
|
||||
{
|
||||
int nStride = 4 * nResultW;
|
||||
BYTE* pDataResult = new BYTE[nStride * nResultH];
|
||||
|
||||
if (m_internal->m_bIsOnlyFirst)
|
||||
oFrame.SaveFile(sMain + sExt, m_internal->m_nRasterFormat);
|
||||
else
|
||||
oFrame.SaveFile(sMain + std::to_wstring(nPageIndex + 1) + sExt, m_internal->m_nRasterFormat);
|
||||
}
|
||||
if (0 == nOffsetX)
|
||||
{
|
||||
memcpy(pDataResult, pDataRaster, nStride * nResultH);
|
||||
}
|
||||
else
|
||||
{
|
||||
BYTE* pDataCopy = pDataRaster + 4 * nOffsetX;
|
||||
BYTE* pDataDst = pDataResult;
|
||||
int nStrideSrc = 4 * nRasterW;
|
||||
for (int i = 0; i < nResultH; ++i)
|
||||
{
|
||||
memcpy(pDataDst, pDataCopy, nStride);
|
||||
pDataCopy += nStrideSrc;
|
||||
pDataDst += nStride;
|
||||
}
|
||||
}
|
||||
|
||||
RELEASEINTERFACE(pFontManager);
|
||||
RELEASEINTERFACE(pImagesCache);
|
||||
oFrame.put_Data(pDataResult);
|
||||
oFrame.put_Width(nResultW);
|
||||
oFrame.put_Height(nResultH);
|
||||
oFrame.put_Stride(nStride);
|
||||
|
||||
return true;
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pDataRaster);
|
||||
}
|
||||
|
||||
std::wstring CMetafileToRenderterRaster::GetFileName()
|
||||
{
|
||||
return m_internal->m_sFileName;
|
||||
}
|
||||
void CMetafileToRenderterRaster::SetFileName(const std::wstring& value)
|
||||
{
|
||||
m_internal->m_sFileName = value;
|
||||
}
|
||||
if (m_internal->m_bIsOnlyFirst)
|
||||
oFrame.SaveFile(sMain + sExt, m_internal->m_nRasterFormat);
|
||||
else
|
||||
oFrame.SaveFile(sMain + std::to_wstring(nPageIndex + 1) + sExt, m_internal->m_nRasterFormat);
|
||||
}
|
||||
|
||||
void CMetafileToRenderterRaster::SetApplication(NSFonts::IApplicationFonts* pFonts)
|
||||
{
|
||||
RELEASEINTERFACE(pFontManager);
|
||||
RELEASEINTERFACE(pImagesCache);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::wstring CMetafileToRenderterRaster::GetFileName()
|
||||
{
|
||||
return m_internal->m_sFileName;
|
||||
}
|
||||
void CMetafileToRenderterRaster::SetFileName(const std::wstring& value)
|
||||
{
|
||||
m_internal->m_sFileName = value;
|
||||
}
|
||||
|
||||
void CMetafileToRenderterRaster::SetApplication(NSFonts::IApplicationFonts* pFonts)
|
||||
{
|
||||
m_internal->appFonts = pFonts;
|
||||
}
|
||||
}
|
||||
|
||||
int CMetafileToRenderterRaster::GetRasterFormat()
|
||||
{
|
||||
return m_internal->m_nRasterFormat;
|
||||
}
|
||||
void CMetafileToRenderterRaster::SetRasterFormat(const int& value)
|
||||
{
|
||||
m_internal->m_nRasterFormat = value;
|
||||
}
|
||||
int CMetafileToRenderterRaster::GetRasterFormat()
|
||||
{
|
||||
return m_internal->m_nRasterFormat;
|
||||
}
|
||||
void CMetafileToRenderterRaster::SetRasterFormat(const int& value)
|
||||
{
|
||||
m_internal->m_nRasterFormat = value;
|
||||
}
|
||||
|
||||
int CMetafileToRenderterRaster::GetSaveType()
|
||||
{
|
||||
return m_internal->m_nSaveType;
|
||||
}
|
||||
void CMetafileToRenderterRaster::SetSaveType(const int& value)
|
||||
{
|
||||
m_internal->m_nSaveType = value;
|
||||
}
|
||||
int CMetafileToRenderterRaster::GetSaveType()
|
||||
{
|
||||
return m_internal->m_nSaveType;
|
||||
}
|
||||
void CMetafileToRenderterRaster::SetSaveType(const int& value)
|
||||
{
|
||||
m_internal->m_nSaveType = value;
|
||||
}
|
||||
|
||||
int CMetafileToRenderterRaster::GetRasterW()
|
||||
{
|
||||
return m_internal->m_nRasterW;
|
||||
}
|
||||
void CMetafileToRenderterRaster::SetRasterW(const int& value)
|
||||
{
|
||||
m_internal->m_nRasterW = value;
|
||||
}
|
||||
int CMetafileToRenderterRaster::GetRasterW()
|
||||
{
|
||||
return m_internal->m_nRasterW;
|
||||
}
|
||||
void CMetafileToRenderterRaster::SetRasterW(const int& value)
|
||||
{
|
||||
m_internal->m_nRasterW = value;
|
||||
}
|
||||
|
||||
int CMetafileToRenderterRaster::GetRasterH()
|
||||
{
|
||||
return m_internal->m_nRasterH;
|
||||
}
|
||||
void CMetafileToRenderterRaster::SetRasterH(const int& value)
|
||||
{
|
||||
m_internal->m_nRasterH = value;
|
||||
}
|
||||
int CMetafileToRenderterRaster::GetRasterH()
|
||||
{
|
||||
return m_internal->m_nRasterH;
|
||||
}
|
||||
void CMetafileToRenderterRaster::SetRasterH(const int& value)
|
||||
{
|
||||
m_internal->m_nRasterH = value;
|
||||
}
|
||||
|
||||
bool CMetafileToRenderterRaster::GetIsOnlyFirst()
|
||||
{
|
||||
return m_internal->m_bIsOnlyFirst;
|
||||
}
|
||||
void CMetafileToRenderterRaster::SetIsOnlyFirst(const bool& value)
|
||||
{
|
||||
m_internal->m_bIsOnlyFirst = value;
|
||||
}
|
||||
void CMetafileToRenderterRaster::SetOutputDpi(const double& dDpiX, const double& dDpiY)
|
||||
{
|
||||
m_internal->m_dDpiX = dDpiX;
|
||||
m_internal->m_dDpiY = dDpiY;
|
||||
}
|
||||
bool CMetafileToRenderterRaster::GetIsOnlyFirst()
|
||||
{
|
||||
return m_internal->m_bIsOnlyFirst;
|
||||
}
|
||||
void CMetafileToRenderterRaster::SetIsOnlyFirst(const bool& value)
|
||||
{
|
||||
m_internal->m_bIsOnlyFirst = value;
|
||||
}
|
||||
void CMetafileToRenderterRaster::SetOutputDpi(const double& dDpiX, const double& dDpiY)
|
||||
{
|
||||
m_internal->m_dDpiX = dDpiX;
|
||||
m_internal->m_dDpiY = dDpiY;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1212,6 +1212,19 @@ namespace NSOnlineOfficeBinToPdf
|
||||
if (nFlags & (1 << 25))
|
||||
pPr->SetCert(ReadString(current, curindex));
|
||||
}
|
||||
else if (oInfo.IsDateTime())
|
||||
{
|
||||
CFormFieldInfo::CDateTimeFormPr* pPr = oInfo.GetDateTimeFormPr();
|
||||
|
||||
if (nFlags & (1 << 22))
|
||||
pPr->SetValue(ReadString(current, curindex));
|
||||
|
||||
if (nFlags & (1 << 25))
|
||||
pPr->SetPlaceHolder(ReadString(current, curindex));
|
||||
|
||||
if (nFlags & (1 << 26))
|
||||
pPr->SetFormat(ReadString(current, curindex));
|
||||
}
|
||||
|
||||
if (oInfo.IsValid())
|
||||
pRenderer->AddFormField(&oInfo);
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
|
||||
namespace NSOnlineOfficeBinToPdf
|
||||
{
|
||||
class CMetafilePageInfo
|
||||
class CMetafilePageInfo
|
||||
{
|
||||
public:
|
||||
double width;
|
||||
@ -57,11 +57,11 @@ namespace NSOnlineOfficeBinToPdf
|
||||
}
|
||||
};
|
||||
|
||||
class CMetafilePagesInfo
|
||||
class GRAPHICS_DECL CMetafilePagesInfo
|
||||
{
|
||||
public:
|
||||
int PagesCount;
|
||||
std::vector<CMetafilePageInfo> arSizes;
|
||||
std::vector<CMetafilePageInfo> arSizes;
|
||||
|
||||
public:
|
||||
CMetafilePagesInfo()
|
||||
@ -73,11 +73,11 @@ namespace NSOnlineOfficeBinToPdf
|
||||
inline void AddPage()
|
||||
{
|
||||
++PagesCount;
|
||||
arSizes.push_back(CMetafilePageInfo());
|
||||
arSizes.push_back(CMetafilePageInfo());
|
||||
}
|
||||
|
||||
void CheckBuffer(BYTE* pBuffer, LONG lBufferLen);
|
||||
};
|
||||
void CheckBuffer(BYTE* pBuffer, LONG lBufferLen);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _BUILD_METAFILE_TO_IRENDERER_H_
|
||||
|
||||
@ -2,6 +2,7 @@ LIB_GRAPHICS_PRI_PATH=$$PWD/../..
|
||||
|
||||
DEFINES -= UNICODE
|
||||
DEFINES -= _UNICODE
|
||||
DEFINES += DISABLE_IMAGE_EXCEPTIONS
|
||||
|
||||
DEFINES += \
|
||||
_QT \
|
||||
|
||||
143
DesktopEditor/pluginsmanager/help.h
Normal file
143
DesktopEditor/pluginsmanager/help.h
Normal file
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
// Commands
|
||||
std::wstring sCmdHelp = L"--h";
|
||||
std::wstring sCmdHelpFull = L"--help";
|
||||
|
||||
std::wstring sCmdPluginsDir = L"--directory";
|
||||
std::wstring sCmdMarketplaceUrl = L"--marketplace";
|
||||
|
||||
std::wstring sCmdPrintInstalled = L"--print-installed";
|
||||
std::wstring sCmdPrintRemoved = L"--print-removed";
|
||||
std::wstring sCmdPrintMarketplace = L"--print-marketplace";
|
||||
std::wstring sCmdPrintBackup = L"--print-backup";
|
||||
|
||||
std::wstring sCmdReset = L"--reset";
|
||||
std::wstring sCmdInstall = L"--install";
|
||||
std::wstring sCmdRestore = L"--restore";
|
||||
std::wstring sCmdUpdate = L"--update";
|
||||
std::wstring sCmdUpdateAll = L"--update-all";
|
||||
std::wstring sCmdAutorename = L"--autorename";
|
||||
std::wstring sCmdRemove = L"--remove";
|
||||
std::wstring sCmdRemoveAll = L"--remove-all";
|
||||
std::wstring sCmdIgnore = L"--ignore";
|
||||
|
||||
// Settings
|
||||
std::wstring sSetRemoved = L"--removed=";
|
||||
|
||||
std::vector<std::wstring> arrCommands {sCmdHelp, sCmdHelpFull, sCmdPluginsDir, sCmdMarketplaceUrl,
|
||||
sCmdPrintInstalled, sCmdPrintRemoved, sCmdPrintMarketplace, sCmdPrintBackup,
|
||||
sCmdReset, sCmdInstall, sCmdRestore, sCmdUpdate, sCmdUpdateAll, sCmdAutorename,
|
||||
sCmdRemove, sCmdRemoveAll, sCmdIgnore};
|
||||
|
||||
bool IsCommandExists(std::wstring sCommand)
|
||||
{
|
||||
return std::find(arrCommands.begin(), arrCommands.end(), sCommand) != arrCommands.end();
|
||||
}
|
||||
|
||||
bool IsNeedSetValue(std::wstring sParam)
|
||||
{
|
||||
return sParam == sCmdPluginsDir ||
|
||||
sParam == sCmdInstall ||
|
||||
sParam == sCmdRestore ||
|
||||
sParam == sCmdUpdate ||
|
||||
sParam == sCmdRemove ||
|
||||
sParam == sCmdIgnore;
|
||||
}
|
||||
|
||||
std::wstring sHelpText =
|
||||
L"\nPlugins Manager Options\n\n" \
|
||||
|
||||
L" --h \n" \
|
||||
L" --help = Print usage information.\n\n" \
|
||||
|
||||
L" --directory = Required parameter. Set plugins folder in quotes.\n" \
|
||||
L" For example, --directory=\"/home/mark/plugins\"\n" \
|
||||
L" The symbol = can be skipped for all parameters.\n" \
|
||||
L" Must be first on the command line.\n\n" \
|
||||
|
||||
L" --marketplace = Optional parameter. Set plugins marketplace URL in quotes.\n" \
|
||||
L" Default is https://onlyoffice.github.io\n\n" \
|
||||
|
||||
L" --print-installed = Optional parameter without value. Print installed plugins.\n\n" \
|
||||
|
||||
L" --print-removed = Optional parameter without value. Print removed plugins.\n\n" \
|
||||
|
||||
L" --print-marketplace = Optional parameter without value. Print available plugins from the marketplace.\n\n" \
|
||||
|
||||
L" --print-backup = Optional parameter without value. Print backup plugins.\n" \
|
||||
L" Backup plugins can be restored using --restore option\n\n" \
|
||||
|
||||
L" --reset = Optional parameter without value. Reset user setting.\n\n" \
|
||||
|
||||
L" --install = Optional parameter. Set comma-separated quoted list of plugins to install.\n" \
|
||||
L" Installing by plugin name, for example, --install=\"photo editor\"\n" \
|
||||
L" GUID, for example, --install=\"{7327FC95-16DA-41D9-9AF2-0E7F449F6800}\"\n" \
|
||||
L" URL, for example, --install=\"https://anysite.com/deploy/chess.plugin\"\n" \
|
||||
L" file path, for example, --install=\"/home/mark/work/speech.plugin\"\n" \
|
||||
L" config path, for example, --install=\"/home/mark/work/plugins.json\"\n" \
|
||||
L" is supported.\n" \
|
||||
L" Combined installation is supported, for example, --install=\"photo editor, {7327FC95-16DA-41D9-9AF2-0E7F449F6800}, etc\".\n" \
|
||||
L" File paths without quotes, plugin extensions: .zip, .plugin.\n\n" \
|
||||
|
||||
L" --restore = Optional parameter. Set comma-separated quoted list of plugins to restore.\n" \
|
||||
L" Print backup plugins using --print-backup option.\n" \
|
||||
L" Restoring by plugin name or GUID is supported.\n" \
|
||||
L" For example, --restore=\"Youtube, {7327FC95-16DA-41D9-9AF2-0E7F449F6800}\"\n\n" \
|
||||
|
||||
L" --update = Optional parameter. Set comma-separated quoted list of plugins to update.\n" \
|
||||
L" Updating by plugin name, GUID, config path is supported.\n" \
|
||||
L" For example, --update=\"Youtube, PhotoEditor, {7327FC95-16DA-41D9-9AF2-0E7F449F6800}\"\n\n" \
|
||||
|
||||
L" --update-all = Optional parameter without value. Update all installed plugins from marketplace.\n\n" \
|
||||
|
||||
L" --autorename = Optional parameter without value.\n" \
|
||||
L" Rename installed plugins folders from name to GUID.\n" \
|
||||
L" For example, youtube -> {38E022EA-AD92-45FC-B22B-49DF39746DB4}\n\n" \
|
||||
|
||||
L" --remove = Optional parameter. Set comma-separated quoted list of plugins to remove.\n" \
|
||||
L" Removing by plugin name, GUID, config path is supported.\n" \
|
||||
L" For example, --remove=\"Youtube, PhotoEditor, {7327FC95-16DA-41D9-9AF2-0E7F449F6800}\"\n\n" \
|
||||
|
||||
L" --remove-all = Optional parameter without value. Remove all installed plugins.\n\n" \
|
||||
|
||||
L" --ignore = Optional parameter. Set comma-separated quoted list of plugins to ignore actions,\n" \
|
||||
L" such as update, remove, rename or restore.\n" \
|
||||
L" For example, --ignore=\"youtube, {7327FC95-16DA-41D9-9AF2-0E7F449F6800}\"\n" \
|
||||
;
|
||||
1559
DesktopEditor/pluginsmanager/main.cpp
Normal file
1559
DesktopEditor/pluginsmanager/main.cpp
Normal file
File diff suppressed because it is too large
Load Diff
36
DesktopEditor/pluginsmanager/pluginsmanager.pro
Normal file
36
DesktopEditor/pluginsmanager/pluginsmanager.pro
Normal file
@ -0,0 +1,36 @@
|
||||
TEMPLATE = app
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
CONFIG -= qt
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
|
||||
DESTDIR = $$CORE_BUILDS_BINARY_PATH
|
||||
|
||||
TARGET = pluginsmanager
|
||||
|
||||
DEFINES += KERNEL_USE_DYNAMIC_LIBRARY
|
||||
|
||||
ADD_DEPENDENCY(kernel, kernel_network, UnicodeConverter)
|
||||
|
||||
core_windows {
|
||||
DEFINES += \
|
||||
WIN32
|
||||
|
||||
DEFINES -= UNICODE
|
||||
DEFINES -= _DEBUG
|
||||
|
||||
message(windows)
|
||||
|
||||
LIBS += -lAdvapi32
|
||||
LIBS += -lShell32
|
||||
LIBS += -lGdi32
|
||||
LIBS += -lUser32
|
||||
}
|
||||
|
||||
SOURCES += main.cpp
|
||||
HEADERS += help.h
|
||||
@ -278,17 +278,21 @@ namespace MetaFile
|
||||
double dLogicalFontHeight = std::fabs(pFont->GetHeight());
|
||||
|
||||
double dM11, dM12, dM21, dM22, dRx, dRy;
|
||||
m_pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dRx, &dRy);
|
||||
|
||||
if (dLogicalFontHeight < M_MINFONTSIZE)
|
||||
{
|
||||
m_pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dRx, &dRy);
|
||||
dFontScale = dM22;
|
||||
dLogicalFontHeight *= dFontScale;
|
||||
m_pRenderer->SetTransform(dM11 / std::fabs(dM11), dM12, dM21, dM22 / std::fabs(dM22), dRx, dRy);
|
||||
|
||||
dM11 /= std::fabs(dM11);
|
||||
dM22 /= std::fabs(dM22);
|
||||
|
||||
m_pRenderer->SetTransform(dM11, dM12, dM21, dM22, dRx, dRy);
|
||||
}
|
||||
|
||||
m_pRenderer->put_FontName(pFont->GetFaceName());
|
||||
m_pRenderer->put_FontSize(fabs(dLogicalFontHeight * m_dScaleX / 25.4 * 72. * m_pFile->GetTransform()->M11));
|
||||
m_pRenderer->put_FontSize(fabs(dLogicalFontHeight * m_dScaleX / 25.4 * 72.) * dM22);
|
||||
|
||||
int lStyle = 0;
|
||||
if (pFont->GetWeight() > 550)
|
||||
@ -1209,12 +1213,8 @@ namespace MetaFile
|
||||
std::vector<double> arDashes(unSizeDash);
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < unSizeDash; ++unIndex)
|
||||
{
|
||||
if (PS_STARTCAP_ROUND == ulPenStartCap)
|
||||
arDashes[unIndex] = pDataDash[unIndex] * ((0 == unIndex % 2) ? (dWidth / 4) : (1.5 * dWidth));
|
||||
else
|
||||
arDashes[unIndex] = pDataDash[unIndex] * dWidth;
|
||||
}
|
||||
|
||||
m_pRenderer->PenDashPattern(arDashes.data(), unSizeDash);
|
||||
|
||||
nDashStyle = Aggplus::DashStyleCustom;
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
#include <math.h>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
#ifndef DIB_RGB_COLORS
|
||||
#define DIB_RGB_COLORS 0x00
|
||||
@ -1015,10 +1016,10 @@ namespace MetaFile
|
||||
return sTmpFile;
|
||||
}
|
||||
|
||||
std::wstring StringNormalization(std::wstring wsString)
|
||||
std::wstring StringNormalization(const std::wstring& wsString)
|
||||
{
|
||||
std::wstring wsText;
|
||||
for (wchar_t wChar : wsString)
|
||||
for (const wchar_t& wChar : wsString)
|
||||
if (wChar == L'<')
|
||||
wsText += L"<";
|
||||
else if (wChar == L'>')
|
||||
@ -1036,6 +1037,30 @@ namespace MetaFile
|
||||
return wsText;
|
||||
}
|
||||
|
||||
bool StringEquals(const std::wstring& wsFirst, const std::wstring& wsSecond)
|
||||
{
|
||||
#if 0
|
||||
// since c++14!
|
||||
return std::equal(wsFirst.begin(), wsFirst.end(),
|
||||
wsSecond.begin(), wsSecond.end(),
|
||||
[](wchar_t wchFirst, wchar_t wchSecond) {
|
||||
return tolower(wchFirst) == tolower(wchSecond);
|
||||
});
|
||||
#else
|
||||
size_t sizeFirst = wsFirst.length();
|
||||
size_t sizeSecond = wsSecond.length();
|
||||
if (sizeFirst != sizeSecond)
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < sizeFirst; ++i)
|
||||
{
|
||||
if (tolower(wsFirst[i]) != tolower(wsSecond[i]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int GetMinAccuracy(double dValue)
|
||||
{
|
||||
if (dValue == (int)dValue)
|
||||
|
||||
@ -1229,7 +1229,8 @@ namespace MetaFile
|
||||
void ProcessRasterOperation(unsigned int unRasterOperation, BYTE** ppBgra, unsigned int unWidth, unsigned int unHeight);
|
||||
std::wstring GetTempFilename(const std::wstring& sFolder = L"");
|
||||
|
||||
std::wstring StringNormalization(std::wstring wsString);
|
||||
std::wstring StringNormalization(const std::wstring& wsString);
|
||||
bool StringEquals(const std::wstring& wsFirstString, const std::wstring& wsSecondString);
|
||||
|
||||
std::wstring ConvertToWString(double dValue, int nAccuracy = -1);
|
||||
std::wstring ConvertToWString(const std::vector<double>& arValues, int nAccuracy = -1);
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
#include "CEmfInterpretatorSvg.h"
|
||||
|
||||
#include "../../Common/MetaFileUtils.h"
|
||||
|
||||
#include "../../../../graphics/Image.h"
|
||||
|
||||
#include "../../../BgraFrame.h"
|
||||
|
||||
#include <algorithm>
|
||||
@ -1130,6 +1127,11 @@ namespace MetaFile
|
||||
if (NULL == pFont)
|
||||
return;
|
||||
|
||||
const std::wstring wsText = StringNormalization(wsString);
|
||||
|
||||
if (wsText.empty())
|
||||
return;
|
||||
|
||||
NodeAttributes arNodeAttributes;
|
||||
|
||||
TXForm oTransform;
|
||||
@ -1147,10 +1149,21 @@ namespace MetaFile
|
||||
|
||||
arNodeAttributes.push_back({L"font-size", ConvertToWString(dFontHeight)});
|
||||
|
||||
std::wstring wsFaceName = pFont->GetFaceName();
|
||||
std::wstring wsFontName = pFont->GetFaceName();
|
||||
|
||||
if (!wsFaceName.empty())
|
||||
arNodeAttributes.push_back({L"font-family", wsFaceName});
|
||||
if (!wsFontName.empty())
|
||||
{
|
||||
NSFonts::CFontSelectFormat oFormat;
|
||||
oFormat.wsName = new std::wstring(pFont->GetFaceName());
|
||||
|
||||
NSFonts::CFontInfo *pFontInfo = m_pParser->GetFontManager()->GetFontInfoByParams(oFormat);
|
||||
|
||||
if (NULL != pFontInfo && !StringEquals(wsFontName, pFontInfo->m_wsFontName))
|
||||
wsFontName = L"'" + wsFontName + L"', '" + pFontInfo->m_wsFontName + L"'";
|
||||
}
|
||||
|
||||
if (!wsFontName.empty())
|
||||
arNodeAttributes.push_back({L"font-family", wsFontName});
|
||||
|
||||
if (pFont->GetWeight() > 550)
|
||||
arNodeAttributes.push_back({L"font-weight", L"bold"});
|
||||
@ -1182,7 +1195,7 @@ namespace MetaFile
|
||||
arNodeAttributes.push_back({L"x", wsX});
|
||||
arNodeAttributes.push_back({L"y", wsY});
|
||||
|
||||
WriteNode(L"text", arNodeAttributes, wsString);
|
||||
WriteNode(L"text", arNodeAttributes, wsText);
|
||||
}
|
||||
|
||||
void CEmfInterpretatorSvg::HANDLE_EMFPLUS_DRAWELLIPSE(short shOgjectIndex, const TEmfPlusRectF &oRect)
|
||||
|
||||
@ -253,6 +253,9 @@ namespace MetaFile
|
||||
|
||||
IFont *pFont = m_pParser->GetFont();
|
||||
|
||||
if (NULL == pFont)
|
||||
return;
|
||||
|
||||
double dFontHeight = std::fabs(pFont->GetHeight());
|
||||
|
||||
if (dFontHeight < 0.01)
|
||||
@ -260,12 +263,21 @@ namespace MetaFile
|
||||
|
||||
arNodeAttributes.push_back({L"font-size", ConvertToWString(dFontHeight)});
|
||||
|
||||
std::wstring wsFaceName = pFont->GetFaceName();
|
||||
std::transform(wsFaceName.begin(), wsFaceName.end(), wsFaceName.begin(), towlower);
|
||||
EraseWords(wsFaceName, {L" bold", L" italic"});
|
||||
std::wstring wsFontName = pFont->GetFaceName();
|
||||
|
||||
if (!wsFaceName.empty())
|
||||
arNodeAttributes.push_back({L"font-family", wsFaceName});
|
||||
if (!wsFontName.empty())
|
||||
{
|
||||
NSFonts::CFontSelectFormat oFormat;
|
||||
oFormat.wsName = new std::wstring(pFont->GetFaceName());
|
||||
|
||||
NSFonts::CFontInfo *pFontInfo = m_pParser->GetFontManager()->GetFontInfoByParams(oFormat);
|
||||
|
||||
if (NULL != pFontInfo && !StringEquals(wsFontName, pFontInfo->m_wsFontName))
|
||||
wsFontName = L"'" + wsFontName + L"', '" + pFontInfo->m_wsFontName + L"'";
|
||||
}
|
||||
|
||||
if (!wsFontName.empty())
|
||||
arNodeAttributes.push_back({L"font-family", wsFontName});
|
||||
|
||||
if (pFont->GetWeight() > 550)
|
||||
arNodeAttributes.push_back({L"font-weight", L"bold"});
|
||||
@ -319,14 +331,14 @@ namespace MetaFile
|
||||
if (arDx.empty())
|
||||
arNodeAttributes.push_back({L"text-anchor", L"end"});
|
||||
else
|
||||
dXCoord -= std::accumulate(arDx.begin(), arDx.end(), 0);
|
||||
dXCoord -= std::accumulate(arDx.begin(), arDx.end(), 0.0);
|
||||
}
|
||||
else if (ulTextAlign == TA_CENTER)
|
||||
{
|
||||
if (arDx.empty())
|
||||
arNodeAttributes.push_back({L"text-anchor", L"middle"});
|
||||
else
|
||||
dXCoord -= std::accumulate(arDx.begin(), arDx.end(), 0) / 2;
|
||||
dXCoord -= std::accumulate(arDx.begin(), arDx.end(), 0.0) / 2;
|
||||
}
|
||||
else //if (ulTextAlign & TA_LEFT)
|
||||
{
|
||||
@ -351,10 +363,15 @@ namespace MetaFile
|
||||
|
||||
double dSin = std::sin(dEscapement * M_PI / 180.);
|
||||
|
||||
dXCoord -= dFontHeight * dSin;
|
||||
dYCoord -= dFontHeight * dSin;
|
||||
|
||||
if (oScale.y < -0.00001)
|
||||
dXCoord -= dFontHeight * dSin;
|
||||
|
||||
arNodeAttributes.push_back({L"transform", L"rotate(" + ConvertToWString(dEscapement) + L' ' + ConvertToWString(dXCoord) + L' ' + ConvertToWString(dYCoord) + L')'});
|
||||
|
||||
if (oScale.y > 0.00001)
|
||||
dXCoord -= dFontHeight * dSin;
|
||||
}
|
||||
|
||||
AddTransform(arNodeAttributes, &oTransform);
|
||||
@ -395,10 +412,8 @@ namespace MetaFile
|
||||
|
||||
do
|
||||
{
|
||||
std::wstring wsTemp = StringNormalization(wsNormalizedText.substr(unStart, unPosLineBreak - unStart));
|
||||
|
||||
WriteNode(L"tspan", {{L"x", wsXCoord},
|
||||
{L"y", ConvertToWString(dYNewCoord)}}, StringNormalization(wsNormalizedText.substr(unStart, unPosLineBreak - unStart)));
|
||||
{L"y", ConvertToWString(dYNewCoord)}}, wsNormalizedText.substr(unStart, unPosLineBreak - unStart));
|
||||
|
||||
dYNewCoord += dFontHeight * 1.6;
|
||||
unStart = wsNormalizedText.find_first_not_of(L"\n", unPosLineBreak);
|
||||
@ -489,15 +504,27 @@ namespace MetaFile
|
||||
unsigned int unMetaPenStyle = pPen->GetStyle();
|
||||
unsigned int ulPenStyle = unMetaPenStyle & PS_STYLE_MASK;
|
||||
unsigned int ulPenStartCap = unMetaPenStyle & PS_STARTCAP_MASK;
|
||||
unsigned int ulPenEndCap = unMetaPenStyle & PS_ENDCAP_MASK;
|
||||
unsigned int ulPenJoin = unMetaPenStyle & PS_JOIN_MASK;
|
||||
|
||||
// svg не поддерживает разные стили для разных сторон линии
|
||||
std::wstring wsLineCap;
|
||||
|
||||
if (PS_ENDCAP_ROUND == ulPenEndCap)
|
||||
wsLineCap = L"round";
|
||||
else if (PS_ENDCAP_SQUARE == ulPenEndCap)
|
||||
wsLineCap = L"square";
|
||||
else if (PS_ENDCAP_FLAT == ulPenEndCap)
|
||||
wsLineCap = L"butt";
|
||||
|
||||
if (PS_STARTCAP_FLAT == ulPenStartCap)
|
||||
arAttributes.push_back({L"stroke-linecap", L"butt"});
|
||||
wsLineCap = L"butt";
|
||||
else if (PS_STARTCAP_SQUARE == ulPenStartCap)
|
||||
arAttributes.push_back({L"stroke-linecap", L"square"});
|
||||
wsLineCap = L"square";
|
||||
else if (PS_STARTCAP_ROUND == ulPenStartCap)
|
||||
arAttributes.push_back({L"stroke-linecap", L"round"});
|
||||
wsLineCap = L"round";
|
||||
|
||||
arAttributes.push_back({L"stroke-linecap", wsLineCap});
|
||||
|
||||
if (PS_JOIN_MITER == ulPenJoin)
|
||||
arAttributes.push_back({L"stroke-linejoin", L"miter"});
|
||||
|
||||
@ -89,15 +89,23 @@ namespace MetaFile
|
||||
double dXRadius = std::fabs(oNewRect.dRight - oNewRect.dLeft) / 2;
|
||||
double dYRadius = std::fabs(oNewRect.dBottom - oNewRect.dTop) / 2;
|
||||
|
||||
std::wstring wsValue = L"M " + ConvertToWString(shXStartArc) + L' ' + ConvertToWString(shYStartArc);
|
||||
double dStartAngle = GetEllipseAngle(oNewRect.dLeft, oNewRect.dTop, oNewRect.dRight, oNewRect.dBottom, shXStartArc, shYStartArc) / 180. * M_PI;
|
||||
double dEndAngle = GetEllipseAngle(oNewRect.dLeft, oNewRect.dTop, oNewRect.dRight, oNewRect.dBottom, shXEndArc, shYEndArc) / 180. * M_PI;
|
||||
|
||||
double dX1 = std::cos(dStartAngle) * dXRadius;
|
||||
double dY1 = std::sin(dStartAngle) * dXRadius;
|
||||
double dX2 = std::cos(dEndAngle) * dXRadius;
|
||||
double dY2 = std::sin(dEndAngle) * dYRadius;
|
||||
|
||||
std::wstring wsValue = L"M " + ConvertToWString(dX1 + (shRight + shLeft) / 2.) + L' ' + ConvertToWString(dY1 + (shBottom + shTop) / 2.);
|
||||
|
||||
wsValue += L" A " + ConvertToWString(dXRadius) + L' ' +
|
||||
ConvertToWString(dYRadius) + L' ' +
|
||||
L"0 0 1 " +
|
||||
// ((std::fabs(dSweepAngle - dStartAngle) <= 180) ? L"0" : L"1") + L' ' +
|
||||
// ((std::fabs(dSweepAngle - dStartAngle) <= 180) ? L"1" : L"0") + L' ' +
|
||||
ConvertToWString(shXEndArc) + L' ' +
|
||||
ConvertToWString(shYEndArc);
|
||||
ConvertToWString(dYRadius) + L' ' +
|
||||
L"0 0 0 " +
|
||||
// ((std::fabs(dSweepAngle - dStartAngle) <= 180) ? L"0" : L"1") + L' ' +
|
||||
// ((std::fabs(dSweepAngle - dStartAngle) <= 180) ? L"1" : L"0") + L' ' +
|
||||
ConvertToWString(dX2 + (shRight + shLeft) / 2.) + L' ' +
|
||||
ConvertToWString(dY2 + (shBottom + shTop) / 2.);
|
||||
|
||||
NodeAttributes arAttributes = {{L"d", wsValue}};
|
||||
|
||||
|
||||
@ -957,14 +957,29 @@ namespace MetaFile
|
||||
if (NULL != m_pInterpretator)
|
||||
m_pInterpretator->HANDLE_META_ARC(shYEndArc, shXEndArc, shYStartArc, shXStartArc, shBottom, shRight, shTop, shLeft);
|
||||
|
||||
double dStartAngle = GetEllipseAngle((int)shLeft, (int)shTop, (int)shRight, (int)shBottom, (int)shXStartArc, (int)shYStartArc);
|
||||
double dEndAngle = GetEllipseAngle((int)shLeft, (int)shTop, (int)shRight, (int)shBottom, (int)shXEndArc, (int)shYEndArc);
|
||||
double dXC = (shRight + shLeft) / 2.;
|
||||
double dYC = (shTop + shBottom) / 2.;
|
||||
|
||||
double dXRadius = std::fabs(shRight - shLeft) / 2;
|
||||
double dYRadius = std::fabs(shBottom - shTop) / 2;
|
||||
|
||||
double dStartAngle = agg::rad2deg(std::atan2(shYStartArc - dYC, shXStartArc - dXC));
|
||||
double dEndAngle = agg::rad2deg(std::atan2(shYEndArc - dYC, shXEndArc - dXC));
|
||||
|
||||
if ((shXStartArc - dXC) < 0 && (shYStartArc - dYC) < 0)
|
||||
dStartAngle += 360;
|
||||
|
||||
if ((shXEndArc - dXC) < 0 && (shYEndArc - dYC) < 0)
|
||||
dEndAngle += 360;
|
||||
|
||||
double dX1 = dXC + std::cos(agg::deg2rad(dStartAngle)) * dXRadius;
|
||||
double dY1 = dYC + std::sin(agg::deg2rad(dStartAngle)) * dYRadius;
|
||||
|
||||
double dSweepAngle = GetSweepAngle(dStartAngle, dEndAngle);
|
||||
|
||||
m_pDC->SetCurPos(shXStartArc, shYStartArc);
|
||||
MoveTo(dX1, dY1);
|
||||
ArcTo(shLeft, shTop, shRight, shBottom, dStartAngle, dSweepAngle);
|
||||
DrawPath(true, false);
|
||||
m_pDC->SetCurPos(shXEndArc, shYEndArc);
|
||||
}
|
||||
|
||||
void CWmfParserBase::HANDLE_META_CHORD(short shYEndArc, short shXEndArc, short shYStartArc, short shXStartArc, short shBottom, short shRight, short shTop, short shLeft)
|
||||
|
||||
@ -208,7 +208,7 @@ namespace SVG
|
||||
|
||||
const wchar_t* buf = Rgb.c_str();
|
||||
size_t len = Rgb.length();
|
||||
for ( size_t i = 0; i < len; ++i )
|
||||
for ( size_t i = 0; i < len && IndCol < 4; ++i )
|
||||
{
|
||||
if ( isdigit ( buf [ i ] ) )
|
||||
{
|
||||
@ -247,7 +247,7 @@ namespace SVG
|
||||
if (0 == Color[3])
|
||||
return -2;
|
||||
|
||||
return ( ( (int) (Color [ 2 ]) << 16 ) | ( (int) (Color [ 1 ]) << 8 ) | (int) (Color [ 1 ]) );
|
||||
return ( ( (int) (Color [ 2 ]) << 16 ) | ( (int) (Color [ 1 ]) << 8 ) | (int) (Color [ 0 ]) );
|
||||
}
|
||||
long ColorParser::ColorFromHexString(const std::wstring& Hex)
|
||||
{
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
SET SCRIPTPATH=%~dp0
|
||||
CD /D %~dp0
|
||||
|
||||
call hg clone https://hg.mozilla.org/projects/nspr
|
||||
call hg clone https://hg.mozilla.org/projects/nss
|
||||
|
||||
cd nss
|
||||
export USE_64=1
|
||||
make nss_build_all
|
||||
|
||||
git clone https://github.com/openssl/openssl.git openssl
|
||||
cd openssl
|
||||
perl ./Configure linux-64
|
||||
./config
|
||||
make
|
||||
|
||||
#call git clone -b master https://github.com/lsh123/xmlsec.git
|
||||
#download from http://www.aleksey.com/xmlsec/download/xmlsec1-1.2.23.tar.gz
|
||||
# get from our git repository
|
||||
@ -1,312 +0,0 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2014-10-10T14:24:04
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT -= core gui
|
||||
|
||||
TARGET = libxmlsec
|
||||
TEMPLATE = lib
|
||||
QMAKE_CXXFLAGS += -Wall -g
|
||||
|
||||
#CONFIG += shared
|
||||
#CONFIG += plugin
|
||||
CONFIG += staticlib
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$PWD_ROOT_DIR/xmlsec/include \
|
||||
$$CORE_ROOT_DIR/DesktopEditor/xml/build/qt
|
||||
|
||||
DEFINES += \
|
||||
LIBXML_READER_ENABLED \
|
||||
LIBXML_PUSH_ENABLED \
|
||||
LIBXML_HTML_ENABLED \
|
||||
LIBXML_XPATH_ENABLED \
|
||||
LIBXML_OUTPUT_ENABLED \
|
||||
LIBXML_C14N_ENABLED \
|
||||
LIBXML_SAX1_ENABLED \
|
||||
LIBXML_TREE_ENABLED \
|
||||
LIBXML_XPTR_ENABLED \
|
||||
IN_LIBXML \
|
||||
LIBXML_STATIC
|
||||
|
||||
include($$CORE_ROOT_DIR/DesktopEditor/xml/build/qt/libxml2_src.pri)
|
||||
|
||||
DEFINES += PACKAGE=\\\"xmlsec1\\\"
|
||||
DEFINES += VERSION=\\\"1.2.23\\\"
|
||||
DEFINES += XMLSEC_DEFAULT_CRYPTO=\\\"openssl\\\"
|
||||
|
||||
DEFINES += \
|
||||
IN_XMLSEC \
|
||||
XMLSEC_STATIC
|
||||
|
||||
core_linux {
|
||||
#CONFIG += use_gcrypt
|
||||
#CONFIG += use_gnutls
|
||||
#CONFIG += use_mscrypto
|
||||
#CONFIG += use_nss
|
||||
CONFIG += use_openssl
|
||||
#CONFIG += use_skeleton
|
||||
#CONFIG += use_xslt
|
||||
}
|
||||
|
||||
core_windows {
|
||||
CONFIG += use_mscrypto
|
||||
}
|
||||
|
||||
HEADERS += \
|
||||
xmlsec/include/xmlsec/app.h \
|
||||
xmlsec/include/xmlsec/base64.h \
|
||||
xmlsec/include/xmlsec/bn.h \
|
||||
xmlsec/include/xmlsec/buffer.h \
|
||||
xmlsec/include/xmlsec/crypto.h \
|
||||
xmlsec/include/xmlsec/dl.h \
|
||||
xmlsec/include/xmlsec/errors.h \
|
||||
xmlsec/include/xmlsec/exports.h \
|
||||
xmlsec/include/xmlsec/io.h \
|
||||
xmlsec/include/xmlsec/keyinfo.h \
|
||||
xmlsec/include/xmlsec/keys.h \
|
||||
xmlsec/include/xmlsec/keysdata.h \
|
||||
xmlsec/include/xmlsec/keysmngr.h \
|
||||
xmlsec/include/xmlsec/list.h \
|
||||
xmlsec/include/xmlsec/membuf.h \
|
||||
xmlsec/include/xmlsec/nodeset.h \
|
||||
xmlsec/include/xmlsec/parser.h \
|
||||
xmlsec/include/xmlsec/private.h \
|
||||
xmlsec/include/xmlsec/soap.h \
|
||||
xmlsec/include/xmlsec/strings.h \
|
||||
xmlsec/include/xmlsec/templates.h \
|
||||
xmlsec/include/xmlsec/transforms.h \
|
||||
xmlsec/include/xmlsec/version.h \
|
||||
xmlsec/include/xmlsec/version.h.in \
|
||||
xmlsec/include/xmlsec/x509.h \
|
||||
xmlsec/include/xmlsec/xmldsig.h \
|
||||
xmlsec/include/xmlsec/xmlenc.h \
|
||||
xmlsec/include/xmlsec/xmlsec.h \
|
||||
xmlsec/include/xmlsec/xmltree.h \
|
||||
xmlsec/src/globals.h \
|
||||
xmlsec/src/kw_aes_des.h
|
||||
|
||||
SOURCES += \
|
||||
xmlsec/src/app.c \
|
||||
xmlsec/src/base64.c \
|
||||
xmlsec/src/bn.c \
|
||||
xmlsec/src/buffer.c \
|
||||
xmlsec/src/c14n.c \
|
||||
xmlsec/src/dl.c \
|
||||
xmlsec/src/enveloped.c \
|
||||
xmlsec/src/errors.c \
|
||||
xmlsec/src/io.c \
|
||||
xmlsec/src/keyinfo.c \
|
||||
xmlsec/src/keys.c \
|
||||
xmlsec/src/keysdata.c \
|
||||
xmlsec/src/keysmngr.c \
|
||||
xmlsec/src/kw_aes_des.c \
|
||||
xmlsec/src/list.c \
|
||||
xmlsec/src/membuf.c \
|
||||
xmlsec/src/nodeset.c \
|
||||
xmlsec/src/parser.c \
|
||||
xmlsec/src/relationship.c \
|
||||
xmlsec/src/soap.c \
|
||||
xmlsec/src/strings.c \
|
||||
xmlsec/src/templates.c \
|
||||
xmlsec/src/transforms.c \
|
||||
xmlsec/src/x509.c \
|
||||
xmlsec/src/xmldsig.c \
|
||||
xmlsec/src/xmlenc.c \
|
||||
xmlsec/src/xmlsec.c \
|
||||
xmlsec/src/xmltree.c \
|
||||
xmlsec/src/xpath.c
|
||||
|
||||
use_gcrypt {
|
||||
|
||||
HEADERS += \
|
||||
xmlsec/include/xmlsec/gcrypt/app.h \
|
||||
xmlsec/include/xmlsec/gcrypt/crypto.h \
|
||||
xmlsec/include/xmlsec/gcrypt/symbols.h \
|
||||
\
|
||||
xmlsec/src/gcrypt/asn1.h \
|
||||
xmlsec/src/gcrypt/globals.h
|
||||
|
||||
|
||||
SOURCES += \
|
||||
xmlsec/src/gcrypt/app.c \
|
||||
xmlsec/src/gcrypt/asn1.c \
|
||||
xmlsec/src/gcrypt/asymkeys.c \
|
||||
xmlsec/src/gcrypt/ciphers.c \
|
||||
xmlsec/src/gcrypt/crypto.c \
|
||||
xmlsec/src/gcrypt/digests.c \
|
||||
xmlsec/src/gcrypt/hmac.c \
|
||||
xmlsec/src/gcrypt/kw_aes.c \
|
||||
xmlsec/src/gcrypt/kw_des.c \
|
||||
xmlsec/src/gcrypt/signatures.c \
|
||||
xmlsec/src/gcrypt/symkeys.c
|
||||
|
||||
}
|
||||
|
||||
use_gnutls {
|
||||
|
||||
HEADERS += \
|
||||
xmlsec/include/xmlsec/gnutls/app.h \
|
||||
xmlsec/include/xmlsec/gnutls/crypto.h \
|
||||
xmlsec/include/xmlsec/gnutls/symbols.h \
|
||||
xmlsec/include/xmlsec/gnutls/x509.h \
|
||||
\
|
||||
xmlsec/src/gnutls/globals.h \
|
||||
xmlsec/src/gnutls/x509utils.h
|
||||
|
||||
SOURCES += \
|
||||
xmlsec/src/gnutls/app.c \
|
||||
xmlsec/src/gnutls/asymkeys.c \
|
||||
xmlsec/src/gnutls/ciphers.c \
|
||||
xmlsec/src/gnutls/crypto.c \
|
||||
xmlsec/src/gnutls/digests.c \
|
||||
xmlsec/src/gnutls/hmac.c \
|
||||
xmlsec/src/gnutls/kw_aes.c \
|
||||
xmlsec/src/gnutls/kw_des.c \
|
||||
xmlsec/src/gnutls/signatures.c \
|
||||
xmlsec/src/gnutls/symkeys.c \
|
||||
xmlsec/src/gnutls/x509.c \
|
||||
xmlsec/src/gnutls/x509utils.c \
|
||||
xmlsec/src/gnutls/x509vfy.c
|
||||
|
||||
}
|
||||
|
||||
use_mscrypto {
|
||||
|
||||
DEFINES += XMLSEC_CRYPTO_MSCRYPTO
|
||||
|
||||
HEADERS += \
|
||||
xmlsec/include/xmlsec/mscrypto/app.h \
|
||||
xmlsec/include/xmlsec/mscrypto/certkeys.h \
|
||||
xmlsec/include/xmlsec/mscrypto/crypto.h \
|
||||
xmlsec/include/xmlsec/mscrypto/keysstore.h \
|
||||
xmlsec/include/xmlsec/mscrypto/symbols.h \
|
||||
xmlsec/include/xmlsec/mscrypto/x509.h \
|
||||
\
|
||||
xmlsec/src/mscrypto/csp_calg.h \
|
||||
xmlsec/src/mscrypto/csp_oid.h \
|
||||
xmlsec/src/mscrypto/globals.h \
|
||||
xmlsec/src/mscrypto/private.h \
|
||||
xmlsec/src/mscrypto/xmlsec-mingw.h
|
||||
|
||||
SOURCES += \
|
||||
xmlsec/src/mscrypto/app.c \
|
||||
xmlsec/src/mscrypto/certkeys.c \
|
||||
xmlsec/src/mscrypto/ciphers.c \
|
||||
xmlsec/src/mscrypto/crypto.c \
|
||||
xmlsec/src/mscrypto/digests.c \
|
||||
xmlsec/src/mscrypto/hmac.c \
|
||||
xmlsec/src/mscrypto/keysstore.c \
|
||||
xmlsec/src/mscrypto/kt_rsa.c \
|
||||
xmlsec/src/mscrypto/kw_aes.c \
|
||||
xmlsec/src/mscrypto/kw_des.c \
|
||||
xmlsec/src/mscrypto/signatures.c \
|
||||
xmlsec/src/mscrypto/symkeys.c \
|
||||
xmlsec/src/mscrypto/x509.c \
|
||||
xmlsec/src/mscrypto/x509vfy.c
|
||||
|
||||
}
|
||||
|
||||
use_nss {
|
||||
|
||||
HEADERS += \
|
||||
xmlsec/include/xmlsec/nss/app.h \
|
||||
xmlsec/include/xmlsec/nss/bignum.h \
|
||||
xmlsec/include/xmlsec/nss/crypto.h \
|
||||
xmlsec/include/xmlsec/nss/keysstore.h \
|
||||
xmlsec/include/xmlsec/nss/pkikeys.h \
|
||||
xmlsec/include/xmlsec/nss/symbols.h \
|
||||
xmlsec/include/xmlsec/nss/x509.h \
|
||||
\
|
||||
xmlsec/src/nss/globals.h
|
||||
|
||||
SOURCES += \
|
||||
xmlsec/src/nss/app.c \
|
||||
xmlsec/src/nss/bignum.c \
|
||||
xmlsec/src/nss/ciphers.c \
|
||||
xmlsec/src/nss/crypto.c \
|
||||
xmlsec/src/nss/digests.c \
|
||||
xmlsec/src/nss/hmac.c \
|
||||
xmlsec/src/nss/keysstore.c \
|
||||
xmlsec/src/nss/keytrans.c \
|
||||
xmlsec/src/nss/kw_aes.c \
|
||||
xmlsec/src/nss/kw_des.c \
|
||||
xmlsec/src/nss/pkikeys.c \
|
||||
xmlsec/src/nss/signatures.c \
|
||||
xmlsec/src/nss/symkeys.c \
|
||||
xmlsec/src/nss/x509.c \
|
||||
xmlsec/src/nss/x509vfy.c
|
||||
|
||||
}
|
||||
|
||||
use_openssl {
|
||||
|
||||
DEFINES += XMLSEC_OPENSSL_110
|
||||
|
||||
INCLUDEPATH += $$PWD/openssl/include
|
||||
|
||||
HEADERS += \
|
||||
xmlsec/include/xmlsec/openssl/app.h \
|
||||
xmlsec/include/xmlsec/openssl/bn.h \
|
||||
xmlsec/include/xmlsec/openssl/crypto.h \
|
||||
xmlsec/include/xmlsec/openssl/evp.h \
|
||||
xmlsec/include/xmlsec/openssl/symbols.h \
|
||||
xmlsec/include/xmlsec/openssl/x509.h \
|
||||
\
|
||||
xmlsec/src/openssl/globals.h \
|
||||
xmlsec/src/openssl/openssl11_wrapper.h
|
||||
|
||||
SOURCES += \
|
||||
xmlsec/src/openssl/_app.c \
|
||||
xmlsec/src/openssl/_bn.c \
|
||||
xmlsec/src/openssl/_ciphers.c \
|
||||
xmlsec/src/openssl/_crypto.c \
|
||||
xmlsec/src/openssl/_digests.c \
|
||||
xmlsec/src/openssl/_evp.c \
|
||||
xmlsec/src/openssl/_evp_signatures.c \
|
||||
xmlsec/src/openssl/_hmac.c \
|
||||
xmlsec/src/openssl/_kt_rsa.c \
|
||||
xmlsec/src/openssl/_kw_aes.c \
|
||||
xmlsec/src/openssl/_kw_des.c \
|
||||
xmlsec/src/openssl/_signatures.c \
|
||||
xmlsec/src/openssl/_symkeys.c \
|
||||
xmlsec/src/openssl/_x509.c \
|
||||
xmlsec/src/openssl/_x509vfy.c
|
||||
|
||||
}
|
||||
|
||||
use_skeleton {
|
||||
|
||||
HEADERS += \
|
||||
xmlsec/include/xmlsec/skeleton/app.h \
|
||||
xmlsec/include/xmlsec/skeleton/crypto.h \
|
||||
xmlsec/include/xmlsec/skeleton/symbols.h \
|
||||
\
|
||||
xmlsec/src/skeleton/globals.h
|
||||
|
||||
SOURCES += \
|
||||
xmlsec/src/skeleton/app.c \
|
||||
xmlsec/src/skeleton/crypto.c
|
||||
|
||||
}
|
||||
|
||||
use_xslt {
|
||||
|
||||
HEADERS += \
|
||||
xmlsec/include/xmlsec/private/xslt.h
|
||||
|
||||
SOURCES += \
|
||||
xmlsec/src/xslt.c
|
||||
|
||||
} else {
|
||||
|
||||
DEFINES += \
|
||||
XMLSEC_NO_XSLT
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user