mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
365 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 182cd8d74a | |||
| 361bc70fe3 | |||
| 6d68d7aee5 | |||
| 61e6b54710 | |||
| 65ba8ffd3b | |||
| d2713d0cfd | |||
| 099ebc3de9 | |||
| 8ad76e4e1f | |||
| 029e6c6df7 | |||
| 2f525c1e4f | |||
| e979defdee | |||
| cc585185dd | |||
| 9a5240cbba | |||
| ab2ab7a407 | |||
| 62c401ae5b | |||
| c470363ec0 | |||
| 25be50f058 | |||
| 10931f937a | |||
| 647c8a3cde | |||
| 1d4f9b5c41 | |||
| 3de464a31e | |||
| 3429e8b345 | |||
| 485dcb5272 | |||
| 1c9a9f53e3 | |||
| ebaf0eb43a | |||
| eab40d6bb2 | |||
| 8e51f9bdbb | |||
| ac8c99415f | |||
| 5a6a2f800f | |||
| 1286dbaaaf | |||
| 1dbeea42b8 | |||
| a5ea301e3e | |||
| fb40437d21 | |||
| b00fbeff53 | |||
| 819d1fad17 | |||
| ce88c4ca95 | |||
| a69a992a0d | |||
| 949aed7bb4 | |||
| 6ec4191483 | |||
| 3401c2b02e | |||
| 0dd0ad0023 | |||
| 1c2501eeb1 | |||
| 0d443743a8 | |||
| 8c7a22b726 | |||
| a14b3eb8e2 | |||
| 6eaf590844 | |||
| fac279ba81 | |||
| 571a7ee2d1 | |||
| adb6d7bbc2 | |||
| f7fa638591 | |||
| edfa558a38 | |||
| b80ada4b4e | |||
| 492b821472 | |||
| a8ce7eaad3 | |||
| 8cf78b9e58 | |||
| 28bcfafcc6 | |||
| e527db9515 | |||
| db2660a1a3 | |||
| 03919dcb33 | |||
| 46588b05b1 | |||
| dc0ea6a7f3 | |||
| a84c8cc471 | |||
| cd1bb3b658 | |||
| cd71bc0672 | |||
| 14c9896773 | |||
| 19694bf32d | |||
| 96e1280082 | |||
| ce41e42851 | |||
| b414fb961e | |||
| 0370948e98 | |||
| ccbd9da871 | |||
| cec8402adc | |||
| fd90f73c19 | |||
| 6447aeafa5 | |||
| aa3e0759d7 | |||
| 3db4bdc93f | |||
| 5692bee77a | |||
| d6864e044a | |||
| ad69100d3f | |||
| b05a95d54e | |||
| 87a09faefb | |||
| 5e35517d71 | |||
| ca94882699 | |||
| 77ece713ee | |||
| 5b44611560 | |||
| d43a724ee6 | |||
| f57af6ecc1 | |||
| af77bf3f77 | |||
| 4578731001 | |||
| 72566e8064 | |||
| 346f0e9dd0 | |||
| e32bd8fd96 | |||
| de51108ba7 | |||
| 83a6e52df2 | |||
| 4eb761eec3 | |||
| baf9fb4a93 | |||
| 0b8e833e77 | |||
| 94bb0f5306 | |||
| fc3ce62ec7 | |||
| 3fac5441cb | |||
| 32bd8166d7 | |||
| 4acdd6dd20 | |||
| 518a4ddb2b | |||
| 895082cc93 | |||
| f16fa656e9 | |||
| f16318aebb | |||
| a5c28b72bb | |||
| 290d50ebcc | |||
| 3de1152a3f | |||
| 109c891c1b | |||
| 1b2d803976 | |||
| 9f4613b15c | |||
| ab7e8a07be | |||
| 7603aceee1 | |||
| 7ea66d0bee | |||
| 0e8230cc7f | |||
| 0229d928ab | |||
| 4bdea2d154 | |||
| 751a5d4d7d | |||
| 4b1bd2fb70 | |||
| cbbf650c56 | |||
| b55cd751d1 | |||
| c7d5b60637 | |||
| 666f5c2f9e | |||
| 42b432b4de | |||
| 08ca60091c | |||
| 88d9827d3f | |||
| bae672f718 | |||
| 00344df9ad | |||
| cfb060e142 | |||
| 0565e6164b | |||
| 306cc3f985 | |||
| 2739dd3abd | |||
| 70e6df5aae | |||
| 96030aa322 | |||
| fee801eeeb | |||
| 750273b526 | |||
| cfdb541c28 | |||
| 11121961d9 | |||
| 45828709ee | |||
| 40916e5ccc | |||
| 319610c58d | |||
| 1837a2737e | |||
| 686fc60860 | |||
| 51216f27f4 | |||
| 2eb33ddd22 | |||
| 58c80b052b | |||
| 5eee408eeb | |||
| b6ae1f272c | |||
| 045f23d921 | |||
| d06b52988c | |||
| 4717b47388 | |||
| 31ce9f6a18 | |||
| e44c9fa4c9 | |||
| 3c59ba7a13 | |||
| 42e84249e8 | |||
| e2dbde8722 | |||
| 36c67d79d5 | |||
| cdc14d22f0 | |||
| baed05236b | |||
| c644f94c0b | |||
| 087e4433f2 | |||
| bc11a5cf5f | |||
| d86303e290 | |||
| 51f1faa51a | |||
| 6775dccc2c | |||
| ee3b4c612d | |||
| 1144bb166c | |||
| a9752208f6 | |||
| 84016cf8cf | |||
| cb7edc373c | |||
| d1e43d68dc | |||
| b5ab5f9b2b | |||
| 761c5bec53 | |||
| 8cc7034c22 | |||
| ee1c385b54 | |||
| ded640825b | |||
| 84301531c8 | |||
| 310cd6d8fd | |||
| 2d37cf634a | |||
| 04880b4e1d | |||
| 1000b5d5bd | |||
| c324b4a11c | |||
| a51fe4134c | |||
| 985d258bc1 | |||
| fee5c112b4 | |||
| 9b50f9fbc2 | |||
| 10f770fdbc | |||
| eb53c40135 | |||
| ded1655a04 | |||
| 20c11889aa | |||
| 910c2418d6 | |||
| e6ffdc0ae8 | |||
| 0335d330b8 | |||
| af2e86e777 | |||
| bcf7d08c51 | |||
| 11886dcdf7 | |||
| 615d0b682c | |||
| 535028fa0e | |||
| 5a6386e08b | |||
| 7ca8b22160 | |||
| ec16e247e9 | |||
| 9a76575082 | |||
| c1a586cb56 | |||
| 7707aeb914 | |||
| 50a8540f75 | |||
| cc2e755bca | |||
| 9c1efdeac2 | |||
| ea1538bc11 | |||
| c0d0fb6f5c | |||
| 5e5e07b406 | |||
| 9b5f762420 | |||
| 7020548f06 | |||
| 2d2e15671a | |||
| 00ad32d420 | |||
| ba2cf66c31 | |||
| 57ed9d0c32 | |||
| 40d82f3287 | |||
| 9bdcbf0d89 | |||
| c1774219ec | |||
| 2a6f0bb1b6 | |||
| a23ce22950 | |||
| b4f0d32b6d | |||
| 83db7f2165 | |||
| 3ce03d897d | |||
| be12237042 | |||
| cf7252b92d | |||
| 523f3f24f9 | |||
| 0196a4bb57 | |||
| 9ee9192cd4 | |||
| 5df63a58b7 | |||
| d107bd5df2 | |||
| f51c1fced2 | |||
| 86cba0bdcd | |||
| cceec83568 | |||
| f733543b44 | |||
| bb9d777c14 | |||
| 694dd852d0 | |||
| 18a18eaa40 | |||
| fb021b33ec | |||
| 95ecd8468a | |||
| fbb57d7009 | |||
| 22e9873208 | |||
| 2581e9235d | |||
| 270fd0601f | |||
| 5f69b4f8e6 | |||
| bdaf9fa10b | |||
| 77e64af80c | |||
| 6e3beac6bf | |||
| 641297ac48 | |||
| dcca1f06f4 | |||
| 22d7cfb240 | |||
| fa51ea21b4 | |||
| 7632be9f2f | |||
| cbf40d36f5 | |||
| 2b8e70e67f | |||
| 4b05eb9a50 | |||
| 3221e41e89 | |||
| 58cc6cf6e8 | |||
| c86a8edd30 | |||
| db1d6a935f | |||
| cb9589f6b4 | |||
| cbad285a9f | |||
| 82a3fa6132 | |||
| 0821eefbd3 | |||
| 38a9dfcd14 | |||
| 0f222c15e9 | |||
| d0a554c701 | |||
| acfec0ceb1 | |||
| 899b27d697 | |||
| 5a5db3e8c6 | |||
| 57fdf7eed5 | |||
| 7f13020f2f | |||
| 020298b023 | |||
| 8eb249056b | |||
| 2ed7e803ca | |||
| b9230ef5ff | |||
| 3907110e44 | |||
| 787575a53f | |||
| b58554a3da | |||
| 9e8c0dfb16 | |||
| 6831820dd4 | |||
| cac79cb66e | |||
| 323213a63d | |||
| 473ef17be3 | |||
| 5e56d26a06 | |||
| a390c1ee18 | |||
| 4158ebcd98 | |||
| 7fc65a84ab | |||
| 69ffd656af | |||
| cb929fc5c5 | |||
| 7cd7c9f98f | |||
| 015c10495c | |||
| e973c8f70b | |||
| a77987488b | |||
| 1cfd17e2f3 | |||
| b4c6f69cee | |||
| 67194499a8 | |||
| 9ec6489083 | |||
| 3971400c78 | |||
| e21ed47019 | |||
| 2cf83df7d0 | |||
| 7f96336e75 | |||
| 99da1e3b8c | |||
| 6d152880bd | |||
| dd9fca2a5c | |||
| 67043cf718 | |||
| ba239f139d | |||
| a99733c5a1 | |||
| a60bc542c7 | |||
| 97d36fa1cd | |||
| 87fa0f93be | |||
| 29a48da730 | |||
| e0352541be | |||
| 2e26a3697d | |||
| cd124d5112 | |||
| 4242d32d95 | |||
| a6b5e7e010 | |||
| 57800ec8dd | |||
| 0f3de35eb4 | |||
| 8c83b18216 | |||
| e1c2bf19d9 | |||
| f38767ccbb | |||
| fc94de8549 | |||
| 812fae8f6c | |||
| c938e2756e | |||
| 5679a7902f | |||
| 056bfb84ce | |||
| 2d745de7e2 | |||
| a5c73127fd | |||
| f0f4e39f5c | |||
| b536d6eb41 | |||
| 0af65b1137 | |||
| 5c3a697880 | |||
| 1b8c59ff87 | |||
| 6b4b645180 | |||
| 30868b81bc | |||
| 4c44edc9c9 | |||
| 60f9021bdd | |||
| fd90fbae21 | |||
| c4979075aa | |||
| 6c067ba6ee | |||
| 2456501f1d | |||
| 07c0c58375 | |||
| db28751875 | |||
| 81c9ae120f | |||
| 830c5ec12c | |||
| 375f79cdac | |||
| 33627ab79c | |||
| 9f81e37196 | |||
| 32a409bb13 | |||
| b53a1b3cd6 | |||
| f5f0630b2d | |||
| 312a95d9e1 | |||
| 4378becd0b | |||
| 8c62dc448a | |||
| 3c16ba01f0 | |||
| 0b16086ff5 | |||
| 5904bb3507 | |||
| 6a2d3838ae | |||
| f6c48c1edb | |||
| 4c9c79628f | |||
| 58c35139ea | |||
| 7d804f1c70 | |||
| 5b156d72c0 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -46,3 +46,5 @@ DesktopEditor/fontengine/js/common/freetype-2.10.4
|
||||
|
||||
.qtc_clangd
|
||||
Common/3dParty/openssl/openssl/
|
||||
|
||||
msvc_make.bat
|
||||
|
||||
@ -27,7 +27,7 @@ CLEAN=
|
||||
BOOST_VERSION=1.72.0
|
||||
BOOST_VERSION2=1_72_0
|
||||
MIN_IOS_VERSION=8.0
|
||||
IOS_SDK_VERSION=`xcodebuild BITCODE_GENERATION_MODE="bitcode" ENABLE_BITCODE="YES" OTHER_CFLAGS="-fembed-bitcode" -showsdks | grep iphoneos | \
|
||||
IOS_SDK_VERSION=`xcodebuild BITCODE_GENERATION_MODE="bitcode" ENABLE_BITCODE="NO" -showsdks | grep iphoneos | \
|
||||
egrep "[[:digit:]]+\.[[:digit:]]+" -o | tail -1`
|
||||
OSX_SDK_VERSION=`xcodebuild BITCODE_GENERATION_MODE="bitcode" ENABLE_BITCODE="YES" OTHER_CFLAGS="-fembed-bitcode" -showsdks | grep macosx | \
|
||||
egrep "[[:digit:]]+\.[[:digit:]]+" -o | tail -1`
|
||||
@ -42,7 +42,7 @@ XCODE_ROOT=`xcode-select -print-path`
|
||||
#
|
||||
# Should perhaps also consider/use instead: -BOOST_SP_USE_PTHREADS
|
||||
EXTRA_CPPFLAGS="-DBOOST_AC_USE_PTHREADS -DBOOST_SP_USE_PTHREADS -g -DNDEBUG \
|
||||
-std=c++11 -stdlib=libc++ -fvisibility=hidden -fvisibility-inlines-hidden -fembed-bitcode"
|
||||
-std=c++11 -stdlib=libc++ -fvisibility=hidden -fvisibility-inlines-hidden"
|
||||
EXTRA_IOS_CPPFLAGS="$EXTRA_CPPFLAGS -mios-version-min=$MIN_IOS_VERSION"
|
||||
EXTRA_OSX_CPPFLAGS="$EXTRA_CPPFLAGS"
|
||||
|
||||
@ -259,20 +259,17 @@ buildBoost()
|
||||
echo Building Boost for iPhone
|
||||
# Install this one so we can copy the headers for the frameworks...
|
||||
./b2 -j16 --build-dir=iphone-build --stagedir=iphone-build/stage \
|
||||
cxxflags="-fembed-bitcode" \
|
||||
--prefix=$PREFIXDIR toolset=darwin architecture=arm target-os=iphone \
|
||||
macosx-version=iphone-${IOS_SDK_VERSION} define=_LITTLE_ENDIAN \
|
||||
link=static stage
|
||||
./b2 -j16 --build-dir=iphone-build --stagedir=iphone-build/stage \
|
||||
--prefix=$PREFIXDIR toolset=darwin architecture=arm \
|
||||
cxxflags="-fembed-bitcode" \
|
||||
target-os=iphone macosx-version=iphone-${IOS_SDK_VERSION} \
|
||||
define=_LITTLE_ENDIAN link=static install
|
||||
doneSection
|
||||
|
||||
echo Building Boost for iPhoneSimulator
|
||||
./b2 -j16 --build-dir=iphonesim-build --stagedir=iphonesim-build/stage \
|
||||
cxxflags="-fembed-bitcode" \
|
||||
toolset=darwin-${IOS_SDK_VERSION}~iphonesim architecture=x86 \
|
||||
target-os=iphone macosx-version=iphonesim-${IOS_SDK_VERSION} \
|
||||
link=static stage
|
||||
|
||||
@ -78,24 +78,24 @@ function set_ios_cpu_feature() {
|
||||
armv7)
|
||||
export CC="xcrun -sdk iphoneos clang -arch armv7"
|
||||
export CXX="xcrun -sdk iphoneos clang++ -arch armv7"
|
||||
export CFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -isysroot ${sysroot} -fembed-bitcode -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -fstrict-aliasing -fembed-bitcode -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export CFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -isysroot ${sysroot} -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -fstrict-aliasing -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
;;
|
||||
arm64)
|
||||
export CC="xcrun -sdk iphoneos clang -arch arm64"
|
||||
export CXX="xcrun -sdk iphoneos clang++ -arch arm64"
|
||||
export CFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -isysroot ${sysroot} -fembed-bitcode -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -fstrict-aliasing -fembed-bitcode -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export CFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -isysroot ${sysroot} -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -fstrict-aliasing -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
;;
|
||||
arm64e)
|
||||
# -march=armv8.3 ???
|
||||
export CC="xcrun -sdk iphoneos clang -arch arm64e"
|
||||
export CXX="xcrun -sdk iphoneos clang++ -arch arm64e"
|
||||
export CFLAGS="-arch arm64e -target aarch64-ios-darwin -Wno-unused-function -fstrict-aliasing -DIOS -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch arm64e -target aarch64-ios-darwin -isysroot ${sysroot} -fembed-bitcode -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch arm64e -target aarch64-ios-darwin -fstrict-aliasing -fembed-bitcode -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export CFLAGS="-arch arm64e -target aarch64-ios-darwin -Wno-unused-function -fstrict-aliasing -DIOS -isysroot ${sysroot} -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch arm64e -target aarch64-ios-darwin -isysroot ${sysroot} -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch arm64e -target aarch64-ios-darwin -fstrict-aliasing -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
;;
|
||||
i386)
|
||||
export CC="xcrun -sdk iphonesimulator clang -arch i386"
|
||||
|
||||
@ -18,12 +18,12 @@ namespace NSCSS
|
||||
{
|
||||
typedef std::map<std::wstring, std::wstring>::const_iterator styles_iterator;
|
||||
|
||||
CCompiledStyle::CCompiledStyle() : m_nDpi(96), m_UnitMeasure(Point)
|
||||
CCompiledStyle::CCompiledStyle() : m_nDpi(96), m_UnitMeasure(Point), m_dCoreFontSize(DEFAULT_FONT_SIZE)
|
||||
{}
|
||||
|
||||
CCompiledStyle::CCompiledStyle(const CCompiledStyle& oStyle) :
|
||||
m_arParentsStyles(oStyle.m_arParentsStyles), m_sId(oStyle.m_sId),
|
||||
m_nDpi(oStyle.m_nDpi), m_UnitMeasure(oStyle.m_UnitMeasure),
|
||||
m_nDpi(oStyle.m_nDpi), m_UnitMeasure(oStyle.m_UnitMeasure), m_dCoreFontSize(oStyle.m_dCoreFontSize),
|
||||
m_oFont(oStyle.m_oFont), m_oMargin(oStyle.m_oMargin), m_oPadding(oStyle.m_oPadding), m_oBackground(oStyle.m_oBackground),
|
||||
m_oText(oStyle.m_oText), m_oBorder(oStyle.m_oBorder), m_oDisplay(oStyle.m_oDisplay){}
|
||||
|
||||
@ -116,7 +116,10 @@ namespace NSCSS
|
||||
void CCompiledStyle::AddStyle(const std::map<std::wstring, std::wstring>& mStyle, const unsigned int unLevel, const bool& bHardMode)
|
||||
{
|
||||
const bool bIsThereBorder = (m_oBorder.Empty()) ? false : true;
|
||||
const double dFontSize = (!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Point) : DEFAULT_FONT_SIZE;
|
||||
const double dParentFontSize = (!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Point) : DEFAULT_FONT_SIZE;
|
||||
|
||||
if (0 == unLevel)
|
||||
m_dCoreFontSize = dParentFontSize;
|
||||
|
||||
for (std::pair<std::wstring, std::wstring> pPropertie : mStyle)
|
||||
{
|
||||
@ -128,15 +131,15 @@ namespace NSCSS
|
||||
CASE(L"font"):
|
||||
{
|
||||
m_oFont.SetValue(pPropertie.second, unLevel, bHardMode);
|
||||
m_oFont.UpdateSize(dFontSize);
|
||||
m_oFont.UpdateLineHeight(dFontSize);
|
||||
m_oFont.UpdateSize(dParentFontSize, m_dCoreFontSize);
|
||||
m_oFont.UpdateLineHeight(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"font-size"):
|
||||
CASE(L"font-size-adjust"):
|
||||
{
|
||||
m_oFont.SetSize(pPropertie.second, unLevel, bHardMode);
|
||||
m_oFont.UpdateSize(dFontSize);
|
||||
m_oFont.UpdateSize(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"font-stretch"):
|
||||
@ -176,7 +179,7 @@ namespace NSCSS
|
||||
break;
|
||||
|
||||
m_oMargin.SetValues(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateAll(dFontSize);
|
||||
m_oMargin.UpdateAll(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"margin-top"):
|
||||
@ -196,7 +199,7 @@ namespace NSCSS
|
||||
break;
|
||||
|
||||
m_oMargin.SetRight(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateRight(dFontSize);
|
||||
m_oMargin.UpdateRight(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"margin-bottom"):
|
||||
@ -206,7 +209,7 @@ namespace NSCSS
|
||||
break;
|
||||
|
||||
m_oMargin.SetBottom(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateBottom(dFontSize);
|
||||
m_oMargin.UpdateBottom(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"margin-left"):
|
||||
@ -217,7 +220,7 @@ namespace NSCSS
|
||||
break;
|
||||
|
||||
m_oMargin.SetLeft(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateLeft(dFontSize);
|
||||
m_oMargin.UpdateLeft(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
//PADDING
|
||||
@ -225,35 +228,35 @@ namespace NSCSS
|
||||
CASE(L"mso-padding-alt"):
|
||||
{
|
||||
m_oPadding.SetValues(pPropertie.second, unLevel, bHardMode);
|
||||
m_oPadding.UpdateAll(dFontSize);
|
||||
m_oPadding.UpdateAll(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"padding-top"):
|
||||
CASE(L"mso-padding-top-alt"):
|
||||
{
|
||||
m_oPadding.SetTop(pPropertie.second, unLevel, bHardMode);
|
||||
m_oPadding.UpdateTop(dFontSize);
|
||||
m_oPadding.UpdateTop(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"padding-right"):
|
||||
CASE(L"mso-padding-right-alt"):
|
||||
{
|
||||
m_oPadding.SetRight(pPropertie.second, unLevel, bHardMode);
|
||||
m_oPadding.UpdateRight(dFontSize);
|
||||
m_oPadding.UpdateRight(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"padding-bottom"):
|
||||
CASE(L"mso-padding-bottom-alt"):
|
||||
{
|
||||
m_oPadding.SetBottom(pPropertie.second, unLevel, bHardMode);
|
||||
m_oPadding.UpdateBottom(dFontSize);
|
||||
m_oPadding.UpdateBottom(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"padding-left"):
|
||||
CASE(L"mso-padding-left-alt"):
|
||||
{
|
||||
m_oPadding.SetLeft(pPropertie.second, unLevel, bHardMode);
|
||||
m_oPadding.UpdateLeft(dFontSize);
|
||||
m_oPadding.UpdateLeft(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
// TEXT
|
||||
|
||||
@ -22,6 +22,7 @@ namespace NSCSS
|
||||
unsigned short int m_nDpi;
|
||||
UnitMeasure m_UnitMeasure;
|
||||
|
||||
double m_dCoreFontSize;
|
||||
public:
|
||||
NSProperties::CFont m_oFont;
|
||||
NSProperties::CIndent m_oMargin;
|
||||
|
||||
@ -14,6 +14,15 @@ namespace NSCSS
|
||||
return m_wsName.empty() && m_wsClass.empty() && m_wsId.empty() && m_wsStyle.empty();
|
||||
}
|
||||
|
||||
void CNode::Clear()
|
||||
{
|
||||
m_wsName .clear();
|
||||
m_wsClass .clear();
|
||||
m_wsId .clear();
|
||||
m_wsStyle .clear();
|
||||
m_mAttributes.clear();
|
||||
}
|
||||
|
||||
std::vector<std::wstring> CNode::GetData() const
|
||||
{
|
||||
std::vector<std::wstring> arValues;
|
||||
|
||||
@ -22,6 +22,8 @@ namespace NSCSS
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
void Clear();
|
||||
|
||||
std::vector<std::wstring> GetData() const;
|
||||
bool operator< (const CNode& oNode) const;
|
||||
bool operator== (const CNode& oNode) const;
|
||||
|
||||
@ -7,12 +7,18 @@ namespace NSCSS
|
||||
return sValue < oStatistickElement.sValue;
|
||||
}
|
||||
|
||||
void CTree::Clear()
|
||||
{
|
||||
m_arrChild.clear();
|
||||
m_oNode.Clear();
|
||||
}
|
||||
|
||||
void CTree::CountingNumberRepetitions(const CTree &oTree, std::map<StatistickElement, unsigned int> &mStatictics)
|
||||
{
|
||||
if (!oTree.m_oNode.m_wsId.empty())
|
||||
++mStatictics[StatistickElement{StatistickElement::IsId, L'#' + oTree.m_oNode.m_wsId}];
|
||||
if (!oTree.m_oNode.m_wsStyle.empty())
|
||||
++mStatictics[StatistickElement{StatistickElement::IsStyle, oTree.m_oNode.m_wsStyle}];
|
||||
if (!oTree.m_oNode.m_wsStyle.empty())
|
||||
++mStatictics[StatistickElement{StatistickElement::IsStyle, oTree.m_oNode.m_wsStyle}];
|
||||
|
||||
if (!oTree.m_arrChild.empty())
|
||||
for (const CTree& oChildren : oTree.m_arrChild)
|
||||
@ -82,7 +88,7 @@ namespace NSCSS
|
||||
{L"gainsboro", L"DCDCDC"}, {L"lightgray", L"D3D3D3"}, {L"silver", L"C0C0C0"},
|
||||
{L"darkgray", L"A9A9A9"}, {L"gray", L"808080"}, {L"dimgray", L"696969"},
|
||||
{L"lightslategray", L"778899"}, {L"slategray", L"708090"}, {L"darkslategray", L"2F4F4F"},
|
||||
{L"black", L"000000"},
|
||||
{L"black", L"000000"}, {L"grey", L"808080"},
|
||||
/* Outdated */
|
||||
{L"windowtext", L"000000"}, {L"transparent", L"000000"}
|
||||
};
|
||||
|
||||
@ -33,6 +33,8 @@ namespace NSCSS
|
||||
NSCSS::CNode m_oNode;
|
||||
std::vector<CTree> m_arrChild;
|
||||
|
||||
void Clear();
|
||||
|
||||
static void CountingNumberRepetitions(const CTree &oTree, std::map<StatistickElement, unsigned int> &mStatictics);
|
||||
};
|
||||
|
||||
|
||||
@ -614,11 +614,11 @@ namespace NSCSS
|
||||
|
||||
void CColor::SetHEX(const std::wstring &wsValue)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if (6 != wsValue.length() && 3 != wsValue.length())
|
||||
return;
|
||||
|
||||
Clear();
|
||||
|
||||
if (6 == wsValue.length())
|
||||
m_oValue = new std::wstring(wsValue);
|
||||
else
|
||||
@ -632,8 +632,6 @@ namespace NSCSS
|
||||
|
||||
void CColor::SetUrl(const std::wstring &wsValue)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if (wsValue.empty())
|
||||
return;
|
||||
|
||||
@ -648,6 +646,8 @@ namespace NSCSS
|
||||
return;
|
||||
}
|
||||
|
||||
Clear();
|
||||
|
||||
m_oValue = pURL;
|
||||
m_enType = ColorUrl;
|
||||
}
|
||||
@ -659,6 +659,16 @@ namespace NSCSS
|
||||
m_enType = ColorNone;
|
||||
}
|
||||
|
||||
char NormalizeNegativeColorValue(INT nValue)
|
||||
{
|
||||
if (nValue > 255)
|
||||
return 0xff;
|
||||
else if (nValue < 0)
|
||||
return (char)(std::abs(nValue) % 255);
|
||||
|
||||
return (char)nValue;
|
||||
}
|
||||
|
||||
bool CColor::SetValue(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
if ((CHECK_CONDITIONS && !bHardMode) || (wsValue.empty() && unLevel == m_unLevel))
|
||||
@ -692,6 +702,16 @@ namespace NSCSS
|
||||
SetNone();
|
||||
bResult = true;
|
||||
}
|
||||
else if (L"context-stroke" == wsNewValue)
|
||||
{
|
||||
Clear();
|
||||
m_enType = ColorContextStroke;
|
||||
}
|
||||
else if (L"context-fill" == wsNewValue)
|
||||
{
|
||||
Clear();
|
||||
m_enType = ColorContextFill;
|
||||
}
|
||||
else if (10 <= wsNewValue.length() && wsNewValue.substr(0, 3) == L"rgb")
|
||||
{
|
||||
size_t unEnd = wsNewValue.find(L')', 4);
|
||||
@ -704,29 +724,18 @@ namespace NSCSS
|
||||
if (3 > arValues.size())
|
||||
return false;
|
||||
|
||||
INT nRed = std::ceil(NS_STATIC_FUNCTIONS::CalculatePersentage(arValues[0], 255));
|
||||
INT nGreen = std::ceil(NS_STATIC_FUNCTIONS::CalculatePersentage(arValues[1], 255));
|
||||
INT nBlue = std::ceil(NS_STATIC_FUNCTIONS::CalculatePersentage(arValues[2], 255));
|
||||
const char chRed = NormalizeNegativeColorValue(std::ceil(NS_STATIC_FUNCTIONS::CalculatePersentage(arValues[0], 255)));
|
||||
const char chGreen = NormalizeNegativeColorValue(std::ceil(NS_STATIC_FUNCTIONS::CalculatePersentage(arValues[1], 255)));
|
||||
const char chBlue = NormalizeNegativeColorValue(std::ceil(NS_STATIC_FUNCTIONS::CalculatePersentage(arValues[2], 255)));
|
||||
|
||||
if (nRed < 0 || nGreen < 0 || nBlue < 0)
|
||||
{
|
||||
SetEmpty(unLevel);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (255 < nRed) nRed = 255;
|
||||
if (255 < nGreen) nGreen = 255;
|
||||
if (255 < nBlue) nBlue = 255;
|
||||
|
||||
SetRGB(nRed, nGreen, nBlue);
|
||||
SetRGB(chRed, chGreen, chBlue);
|
||||
|
||||
if (wsNewValue.substr(0, 4) == L"rgba" && 4 == arValues.size())
|
||||
m_oOpacity.SetValue(arValues[3], unLevel, bHardMode);
|
||||
|
||||
bResult = true;
|
||||
}
|
||||
|
||||
if (5 <= wsNewValue.length())
|
||||
else if (5 <= wsNewValue.length())
|
||||
{
|
||||
SetUrl(wsValue);
|
||||
|
||||
@ -2292,32 +2301,32 @@ namespace NSCSS
|
||||
return m_oLeft.SetValue(dValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
void CIndent::UpdateAll(double dFontSize)
|
||||
void CIndent::UpdateAll(const double& dParentFontSize, const double& dCoreFontSize)
|
||||
{
|
||||
UpdateTop (dFontSize);
|
||||
UpdateRight (dFontSize);
|
||||
UpdateBottom(dFontSize);
|
||||
UpdateLeft (dFontSize);
|
||||
UpdateTop (dParentFontSize, dCoreFontSize);
|
||||
UpdateRight (dParentFontSize, dCoreFontSize);
|
||||
UpdateBottom(dParentFontSize, dCoreFontSize);
|
||||
UpdateLeft (dParentFontSize, dCoreFontSize);
|
||||
}
|
||||
|
||||
void CIndent::UpdateTop(double dFontSize)
|
||||
void CIndent::UpdateTop(const double& dParentFontSize, const double& dCoreFontSize)
|
||||
{
|
||||
UpdateSide(m_oTop, dFontSize);
|
||||
UpdateSide(m_oTop, dParentFontSize, dCoreFontSize);
|
||||
}
|
||||
|
||||
void CIndent::UpdateRight(double dFontSize)
|
||||
void CIndent::UpdateRight(const double& dParentFontSize, const double& dCoreFontSize)
|
||||
{
|
||||
UpdateSide(m_oRight, dFontSize);
|
||||
UpdateSide(m_oRight, dParentFontSize, dCoreFontSize);
|
||||
}
|
||||
|
||||
void CIndent::UpdateBottom(double dFontSize)
|
||||
void CIndent::UpdateBottom(const double& dParentFontSize, const double& dCoreFontSize)
|
||||
{
|
||||
UpdateSide(m_oBottom, dFontSize);
|
||||
UpdateSide(m_oBottom, dParentFontSize, dCoreFontSize);
|
||||
}
|
||||
|
||||
void CIndent::UpdateLeft(double dFontSize)
|
||||
void CIndent::UpdateLeft(const double& dParentFontSize, const double& dCoreFontSize)
|
||||
{
|
||||
UpdateSide(m_oLeft, dFontSize);
|
||||
UpdateSide(m_oLeft, dParentFontSize, dCoreFontSize);
|
||||
}
|
||||
|
||||
const CDigit &CIndent::GetTop() const
|
||||
@ -2386,13 +2395,15 @@ namespace NSCSS
|
||||
return bTopResult || bRightResult || bBottomResult || bLeftResult;
|
||||
}
|
||||
|
||||
void CIndent::UpdateSide(CDigit &oSide, double dFontSize)
|
||||
void CIndent::UpdateSide(CDigit &oSide, const double& dParentFontSize, const double& dCoreFontSize)
|
||||
{
|
||||
if (oSide.Empty())
|
||||
return;
|
||||
|
||||
if (NSCSS::Em == oSide.GetUnitMeasure() || NSCSS::Rem == oSide.GetUnitMeasure())
|
||||
oSide.ConvertTo(NSCSS::Twips, dFontSize);
|
||||
if (NSCSS::Em == oSide.GetUnitMeasure())
|
||||
oSide.ConvertTo(NSCSS::Twips, dParentFontSize);
|
||||
else if (NSCSS::Rem == oSide.GetUnitMeasure())
|
||||
oSide.ConvertTo(NSCSS::Twips, dCoreFontSize);
|
||||
}
|
||||
|
||||
// FONT
|
||||
@ -2635,16 +2646,20 @@ namespace NSCSS
|
||||
std::make_pair(L"700", L"bold"), std::make_pair(L"800", L"bold"), std::make_pair(L"900", L"bold")}, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
void CFont::UpdateSize(double dFontSize)
|
||||
void CFont::UpdateSize(const double& dParentFontSize, const double& dCoreFontSize)
|
||||
{
|
||||
if (NSCSS::Em == m_oSize.GetUnitMeasure() || NSCSS::Rem == m_oSize.GetUnitMeasure() || NSCSS::Percent == m_oSize.GetUnitMeasure())
|
||||
m_oSize.ConvertTo(NSCSS::Point, dFontSize);
|
||||
if (NSCSS::Em == m_oSize.GetUnitMeasure() || NSCSS::Percent == m_oSize.GetUnitMeasure())
|
||||
m_oSize.ConvertTo(NSCSS::Point, dParentFontSize);
|
||||
else if (NSCSS::Rem == m_oSize.GetUnitMeasure())
|
||||
m_oSize.ConvertTo(NSCSS::Point, dCoreFontSize);
|
||||
}
|
||||
|
||||
void CFont::UpdateLineHeight(double dFontSize)
|
||||
void CFont::UpdateLineHeight(const double& dParentFontSize, const double& dCoreFontSize)
|
||||
{
|
||||
if (NSCSS::Em == m_oLineHeight.GetUnitMeasure() || NSCSS::Rem == m_oLineHeight.GetUnitMeasure())
|
||||
m_oLineHeight.ConvertTo(NSCSS::Twips, dFontSize);
|
||||
if (NSCSS::Em == m_oLineHeight.GetUnitMeasure())
|
||||
m_oLineHeight.ConvertTo(NSCSS::Twips, dParentFontSize);
|
||||
else if (NSCSS::Rem == m_oLineHeight.GetUnitMeasure())
|
||||
m_oLineHeight.ConvertTo(NSCSS::Twips, dCoreFontSize);
|
||||
}
|
||||
|
||||
bool CFont::Bold() const
|
||||
|
||||
@ -215,7 +215,9 @@ namespace NSCSS
|
||||
ColorNone,
|
||||
ColorRGB,
|
||||
ColorHEX,
|
||||
ColorUrl
|
||||
ColorUrl,
|
||||
ColorContextStroke,
|
||||
ColorContextFill
|
||||
} ColorType;
|
||||
|
||||
class CColor : public CValue<void*>
|
||||
@ -654,11 +656,11 @@ namespace NSCSS
|
||||
bool SetLeft (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetLeft (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
void UpdateAll (double dFontSize);
|
||||
void UpdateTop (double dFontSize);
|
||||
void UpdateRight (double dFontSize);
|
||||
void UpdateBottom(double dFontSize);
|
||||
void UpdateLeft (double dFontSize);
|
||||
void UpdateAll (const double& dParentFontSize, const double& dCoreFontSize);
|
||||
void UpdateTop (const double& dParentFontSize, const double& dCoreFontSize);
|
||||
void UpdateRight (const double& dParentFontSize, const double& dCoreFontSize);
|
||||
void UpdateBottom(const double& dParentFontSize, const double& dCoreFontSize);
|
||||
void UpdateLeft (const double& dParentFontSize, const double& dCoreFontSize);
|
||||
|
||||
const CDigit& GetTop () const;
|
||||
const CDigit& GetRight () const;
|
||||
@ -673,7 +675,7 @@ namespace NSCSS
|
||||
bool operator!=(const CIndent& oIndent) const;
|
||||
private:
|
||||
bool SetValues(const std::wstring& wsTopValue, const std::wstring& wsRightValue, const std::wstring& wsBottomValue, const std::wstring& wsLeftValue, unsigned int unLevel, bool bHardMode = false);
|
||||
void UpdateSide(CDigit& oSide, double dFontSize);
|
||||
void UpdateSide(CDigit& oSide, const double& dParentFontSize, const double& dCoreFontSize);
|
||||
|
||||
CDigit m_oLeft;
|
||||
CDigit m_oTop;
|
||||
@ -700,8 +702,8 @@ namespace NSCSS
|
||||
bool SetVariant (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWeight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
void UpdateSize(double dFontSize);
|
||||
void UpdateLineHeight(double dFontSize);
|
||||
void UpdateSize(const double& dParentFontSize, const double& dCoreFontSize);
|
||||
void UpdateLineHeight(const double& dParentFontSize, const double& dCoreFontSize);
|
||||
|
||||
void Clear();
|
||||
|
||||
|
||||
@ -55,6 +55,11 @@ static void replace_all(std::string& s, const std::string& s1, const std::string
|
||||
}
|
||||
}
|
||||
|
||||
static bool NodeIsUnprocessed(const std::string& wsTagName)
|
||||
{
|
||||
return "xml" == wsTagName;
|
||||
}
|
||||
|
||||
static bool IsUnckeckedNodes(const std::string& sValue)
|
||||
{
|
||||
return unchecked_nodes_new.end() != std::find(unchecked_nodes_new.begin(), unchecked_nodes_new.end(), sValue);
|
||||
@ -592,6 +597,9 @@ static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilde
|
||||
|
||||
std::string tagname = get_tag_name(node);
|
||||
|
||||
if (NodeIsUnprocessed(tagname))
|
||||
return;
|
||||
|
||||
if (bCheckValidNode)
|
||||
bCheckValidNode = !IsUnckeckedNodes(tagname);
|
||||
|
||||
|
||||
1
Common/3dParty/hunspell/.gitignore
vendored
1
Common/3dParty/hunspell/.gitignore
vendored
@ -2,3 +2,4 @@ emsdk/
|
||||
hunspell/
|
||||
deploy/
|
||||
o
|
||||
hunspell.data
|
||||
|
||||
@ -14,6 +14,12 @@ def get_hunspell(stable_commit):
|
||||
base.replaceInFile("./src/hunspell/csutil.cxx", "void free_utf_tbl() {", "void free_utf_tbl() { \n return;\n")
|
||||
# bug fix, we need to keep this utf table
|
||||
# free_utf_tbl doesnt delete anything so we can destroy hunspell object
|
||||
|
||||
# replace & add defines to easy control of time limits (CUSTOM_LIMIT)
|
||||
default_tl_defines = "#define TIMELIMIT_GLOBAL (CLOCKS_PER_SEC / 4)\n#define TIMELIMIT_SUGGESTION (CLOCKS_PER_SEC / 10)\n#define TIMELIMIT (CLOCKS_PER_SEC / 20)\n"
|
||||
custom_tl_defines_tl = "#define TIMELIMIT_GLOBAL CUSTOM_TIMELIMIT_GLOBAL\n#define TIMELIMIT_SUGGESTION CUSTOM_TIMELIMIT_SUGGESTION\n#define TIMELIMIT CUSTOM_TIMELIMIT\n"
|
||||
tl_defines = "#ifndef CUSTOM_TIMELIMITS\n" + default_tl_defines + "#else\n" + custom_tl_defines_tl + "#endif\n"
|
||||
base.replaceInFile("./src/hunspell/atypes.hxx", default_tl_defines, tl_defines)
|
||||
os.chdir("../")
|
||||
|
||||
|
||||
|
||||
@ -14,12 +14,32 @@ DEFINES += KERNEL_USE_DYNAMIC_LIBRARY
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += hunspell_build_static
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/hunspell/qt/hunspell.pri)
|
||||
|
||||
ADD_DEPENDENCY(UnicodeConverter kernel hunspell)
|
||||
# custom time limits of hunspell in clocks (if before.py was executed)
|
||||
# when increasing the limit for each case, it is important to consider that the total time will
|
||||
# also increase, so it is good to increase the global limit. this works the same for the candidate limit with suggest limit
|
||||
DEFINES += CUSTOM_TIMELIMITS
|
||||
|
||||
escape_bracket=
|
||||
!core_windows:escape_bracket=\\
|
||||
|
||||
# total time limit per word for all cases. (default is CLOCKS_PER_SEC/4)
|
||||
DEFINES += "CUSTOM_TIMELIMIT_GLOBAL=$${escape_bracket}(20*CLOCKS_PER_SEC$${escape_bracket})"
|
||||
|
||||
# total time limit per "1 case" - forgotten char, double char, moved char and so on for all candidates. (default is CLOCKS_PER_SEC/10)
|
||||
DEFINES += "CUSTOM_TIMELIMIT_SUGGESTION=$${escape_bracket}(5*CLOCKS_PER_SEC$${escape_bracket})"
|
||||
|
||||
# time limit per candidate (default is CLOCKS_PER_SEC/20)
|
||||
DEFINES += "CUSTOM_TIMELIMIT=$${escape_bracket}(CLOCKS_PER_SEC$${escape_bracket}\)"
|
||||
|
||||
ADD_DEPENDENCY(UnicodeConverter kernel)
|
||||
|
||||
core_windows:LIBS += -lgdi32 -ladvapi32 -luser32 -lshell32
|
||||
|
||||
|
||||
@ -20,9 +20,9 @@ CONFIG_PREFIX=" --enable-extras=yes \
|
||||
--enable-dyload=no \
|
||||
--with-data-packaging=static"
|
||||
|
||||
CFLAGS="-O3 -D__STDC_INT64__ -fno-exceptions -fno-short-wchar -fno-short-enums -fembed-bitcode"
|
||||
CFLAGS="-O3 -D__STDC_INT64__ -fno-exceptions -fno-short-wchar -fno-short-enums"
|
||||
|
||||
CXXFLAGS="${CFLAGS} -std=c++11 -fembed-bitcode"
|
||||
CXXFLAGS="${CFLAGS} -std=c++11"
|
||||
|
||||
#will set value to 1
|
||||
defines_config_set_1=(
|
||||
@ -215,9 +215,9 @@ function build() {
|
||||
|
||||
export CXX="$(xcrun -find clang++)"
|
||||
export CC="$(xcrun -find clang)"
|
||||
export CFLAGS="-fembed-bitcode -isysroot $SDKROOT -I$SDKROOT/usr/include/ -I./include/ -arch $ARCH $IOS_MIN_VER $ICU_FLAGS $CFLAGS ${ADDITION_FLAG}"
|
||||
export CXXFLAGS="${CXXFLAGS} -fembed-bitcode -stdlib=libc++ -isysroot $SDKROOT -I$SDKROOT/usr/include/ -I./include/ -arch $ARCH $IOS_MIN_VER $ICU_FLAGS ${ADDITION_FLAG}"
|
||||
export LDFLAGS="-fembed-bitcode -stdlib=libc++ -L$SDKROOT/usr/lib/ -isysroot $SDKROOT -Wl,-dead_strip $IOS_MIN_VER -lstdc++ ${ADDITION_FLAG}"
|
||||
export CFLAGS="-isysroot $SDKROOT -I$SDKROOT/usr/include/ -I./include/ -arch $ARCH $IOS_MIN_VER $ICU_FLAGS $CFLAGS ${ADDITION_FLAG}"
|
||||
export CXXFLAGS="${CXXFLAGS} -stdlib=libc++ -isysroot $SDKROOT -I$SDKROOT/usr/include/ -I./include/ -arch $ARCH $IOS_MIN_VER $ICU_FLAGS ${ADDITION_FLAG}"
|
||||
export LDFLAGS="-stdlib=libc++ -L$SDKROOT/usr/lib/ -isysroot $SDKROOT -Wl,-dead_strip $IOS_MIN_VER -lstdc++ ${ADDITION_FLAG}"
|
||||
|
||||
mkdir -p ${BUILD_DIR}
|
||||
cd ${BUILD_DIR}
|
||||
|
||||
@ -84,24 +84,24 @@ function set_ios_cpu_feature() {
|
||||
armv7)
|
||||
export CC="xcrun -sdk iphoneos clang -arch armv7"
|
||||
export CXX="xcrun -sdk iphoneos clang++ -arch armv7"
|
||||
export CFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -isysroot ${sysroot} -fembed-bitcode -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -fstrict-aliasing -fembed-bitcode -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export CFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -isysroot ${sysroot} -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -fstrict-aliasing -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
;;
|
||||
arm64)
|
||||
export CC="xcrun -sdk iphoneos clang -arch arm64"
|
||||
export CXX="xcrun -sdk iphoneos clang++ -arch arm64"
|
||||
export CFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -isysroot ${sysroot} -fembed-bitcode -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -fstrict-aliasing -fembed-bitcode -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export CFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -isysroot ${sysroot} -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -fstrict-aliasing -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
;;
|
||||
arm64e)
|
||||
# -march=armv8.3 ???
|
||||
export CC="xcrun -sdk iphoneos clang -arch arm64e"
|
||||
export CXX="xcrun -sdk iphoneos clang++ -arch arm64e"
|
||||
export CFLAGS="-arch arm64e -target aarch64-ios-darwin -Wno-unused-function -fstrict-aliasing -DIOS -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch arm64e -target aarch64-ios-darwin -isysroot ${sysroot} -fembed-bitcode -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch arm64e -target aarch64-ios-darwin -fstrict-aliasing -fembed-bitcode -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export CFLAGS="-arch arm64e -target aarch64-ios-darwin -Wno-unused-function -fstrict-aliasing -DIOS -isysroot ${sysroot} -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch arm64e -target aarch64-ios-darwin -isysroot ${sysroot} -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch arm64e -target aarch64-ios-darwin -fstrict-aliasing -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
;;
|
||||
i386)
|
||||
export CC="xcrun -sdk iphonesimulator clang -arch i386"
|
||||
@ -120,9 +120,9 @@ function set_ios_cpu_feature() {
|
||||
sim-arm64)
|
||||
export CC="xcrun -sdk iphonesimulator clang -arch arm64"
|
||||
export CXX="xcrun -sdk iphonesimulator clang++ -arch arm64"
|
||||
export CFLAGS="-arch arm64 -target aarch64-apple-darwin -march=armv8 -mcpu=generic -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -fembed-bitcode -mios-simulator-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch arm64 -target aaarch64-apple-darwin -march=armv8 -isysroot ${sysroot} -fembed-bitcode -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch arm64 -target aarch64-apple-darwin -march=armv8 -mcpu=generic -fstrict-aliasing -fembed-bitcode -DIOS -mios-simulator-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export CFLAGS="-arch arm64 -target aarch64-apple-darwin -march=armv8 -mcpu=generic -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -mios-simulator-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch arm64 -target aaarch64-apple-darwin -march=armv8 -isysroot ${sysroot} -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch arm64 -target aarch64-apple-darwin -march=armv8 -mcpu=generic -fstrict-aliasing -DIOS -mios-simulator-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
;;
|
||||
*)
|
||||
log_error "not support" && exit 1
|
||||
|
||||
@ -107,26 +107,26 @@ function configure_make() {
|
||||
|
||||
# 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 enable-md2
|
||||
sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
#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 enable-md2
|
||||
sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
#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 enable-md2
|
||||
sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
#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 enable-md2
|
||||
sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
#sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
|
||||
else
|
||||
log_error "not support" && exit 1
|
||||
|
||||
@ -238,11 +238,24 @@ bool COfficeFileFormatChecker::isPdfFormatFile(unsigned char *pBuffer, int dwByt
|
||||
|
||||
if (NULL == pFirst)
|
||||
{
|
||||
//skip special
|
||||
_UINT16 sz = pBuffer[0] + (pBuffer[1] << 8);
|
||||
if (sz < dwBytes - 8)
|
||||
char* pData = (char*)pBuffer;
|
||||
for (int i = 0; i < dwBytes - 5; ++i)
|
||||
{
|
||||
pFirst = strstr((char*)(pBuffer + sz), "%PDF-");
|
||||
int nPDF = strncmp(&pData[i], "%PDF-", 5);
|
||||
if (!nPDF)
|
||||
{
|
||||
pFirst = (char*)pBuffer + i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (NULL == pFirst)
|
||||
{
|
||||
//skip special
|
||||
_UINT16 sz = pBuffer[0] + (pBuffer[1] << 8);
|
||||
if (sz < dwBytes - 8)
|
||||
{
|
||||
pFirst = strstr((char*)(pBuffer + sz), "%PDF-");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NULL != pFirst)
|
||||
|
||||
@ -148,7 +148,7 @@ mac {
|
||||
CONFIG += core_mac
|
||||
CONFIG += core_mac_64
|
||||
|
||||
DEFINES += _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
|
||||
DEFINES += _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ core_mac {
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.11
|
||||
QMAKE_LFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH
|
||||
|
||||
# xcode15 add new linker
|
||||
# xcode15 add new linker
|
||||
QMAKE_LFLAGS += -Wl,-ld_classic
|
||||
|
||||
QMAKE_CFLAGS += "-Wno-implicit-function-declaration"
|
||||
@ -301,22 +301,25 @@ linux_arm64 {
|
||||
core_ios {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = ios
|
||||
|
||||
!versionAtLeast(QMAKE_XCODE_VERSION, 16.0) {
|
||||
QMAKE_CFLAGS += -fembed-bitcode
|
||||
QMAKE_CXXFLAGS += -fembed-bitcode
|
||||
QMAKE_LFLAGS += -fembed-bitcode
|
||||
} else {
|
||||
CONFIG -= bitcode
|
||||
}
|
||||
|
||||
|
||||
CONFIG(iphonesimulator, iphoneos|iphonesimulator): {
|
||||
message("iphonesimulator")
|
||||
CORE_BUILDS_PLATFORM_PREFIX = ios_simulator
|
||||
|
||||
QMAKE_CFLAGS += -fembed-bitcode
|
||||
QMAKE_CXXFLAGS += -fembed-bitcode
|
||||
QMAKE_LFLAGS += -fembed-bitcode
|
||||
QMAKE_CFLAGS += -fobjc-arc
|
||||
QMAKE_CXXFLAGS += -fobjc-arc
|
||||
} else {
|
||||
|
||||
QMAKE_IOS_DEPLOYMENT_TARGET = 11.0
|
||||
|
||||
QMAKE_CFLAGS += -fembed-bitcode
|
||||
QMAKE_CXXFLAGS += -fembed-bitcode
|
||||
QMAKE_LFLAGS += -fembed-bitcode
|
||||
QMAKE_CFLAGS += -fobjc-arc
|
||||
QMAKE_CXXFLAGS += -fobjc-arc
|
||||
|
||||
@ -573,7 +576,7 @@ defineTest(ADD_DEPENDENCY) {
|
||||
libs = $$ARGS
|
||||
for(lib, libs) {
|
||||
CORE_BUILDS_LIBRARIES_PATH_DST=$$CORE_BUILDS_LIBRARIES_PATH
|
||||
|
||||
|
||||
isEqual(lib, videoplayer) {
|
||||
libvlc {
|
||||
CORE_BUILDS_LIBRARIES_PATH_DST=$$CORE_BUILDS_LIBRARIES_PATH/mediaplayer
|
||||
@ -586,7 +589,7 @@ defineTest(ADD_DEPENDENCY) {
|
||||
isEqual(lib, qtascdocumentscore):CORE_BUILDS_LIBRARIES_PATH_DST=$$CORE_BUILDS_LIBRARIES_PATH_DST/xp
|
||||
isEqual(lib, videoplayer):CORE_BUILDS_LIBRARIES_PATH_DST=$$CORE_BUILDS_LIBRARIES_PATH_DST/xp
|
||||
isEqual(lib, ooxmlsignature):CORE_BUILDS_LIBRARIES_PATH_DST=$$CORE_BUILDS_LIBRARIES_PATH_DST/xp
|
||||
}
|
||||
}
|
||||
!bundle_dylibs:LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH_DST -l$$lib
|
||||
bundle_dylibs:LIBS += -F$$CORE_BUILDS_LIBRARIES_PATH_DST -framework $$lib
|
||||
}
|
||||
|
||||
@ -847,40 +847,10 @@ namespace agg
|
||||
if (calculate_tensor_coefs)
|
||||
calculate_tensor();
|
||||
|
||||
float minxres = m_oGradientInfo.shading.patch[0][0].x;
|
||||
float minyres = m_oGradientInfo.shading.patch[0][0].y;
|
||||
float maxxres = m_oGradientInfo.shading.patch[0][0].x;
|
||||
float maxyres = m_oGradientInfo.shading.patch[0][0].y;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
if (m_oGradientInfo.shading.patch[i][j].x > maxxres)
|
||||
{
|
||||
maxxres = m_oGradientInfo.shading.patch[i][j].x;
|
||||
}
|
||||
if (m_oGradientInfo.shading.patch[i][j].y > maxyres)
|
||||
{
|
||||
maxyres = m_oGradientInfo.shading.patch[i][j].y;
|
||||
}
|
||||
if (m_oGradientInfo.shading.patch[i][j].x < minxres)
|
||||
{
|
||||
minxres = m_oGradientInfo.shading.patch[i][j].x;
|
||||
}
|
||||
if (m_oGradientInfo.shading.patch[i][j].y < minyres)
|
||||
{
|
||||
minyres = m_oGradientInfo.shading.patch[i][j].y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RES = std::max(1.0f, std::max(maxxres - minxres, maxyres - minyres) / 3);
|
||||
float delta = 1.0 / RES;
|
||||
float u = 0, v = 0;
|
||||
auto start_p = get_p_curve(u, v);
|
||||
xmax_curve = xmin_curve = start_p.x;
|
||||
ymax_curve = ymin_curve = start_p.y;
|
||||
precalc = std::vector<std::vector<ColorT>>(RES, std::vector<ColorT>(RES, {0, 0, 0, 0}));
|
||||
|
||||
/*
|
||||
* Небольшая оптимизация основанная на том, что данная фигура не выходит за границы своих опорных точек.
|
||||
@ -918,7 +888,7 @@ namespace agg
|
||||
RES = nRES;
|
||||
}
|
||||
precalc = std::vector<std::vector<ColorT>>(RES, std::vector<ColorT>(RES, {0, 0, 0, 0}));
|
||||
delta = 1.0f / RES;
|
||||
float delta = 1.0f / RES;
|
||||
std::vector<std::pair<int, int>> next_indexes(RES + 1);
|
||||
u = 0;
|
||||
for (int i = 0; i < RES; ++i)
|
||||
@ -956,8 +926,6 @@ namespace agg
|
||||
}
|
||||
ColorT ifswapRGB(const ColorT &c)
|
||||
{
|
||||
|
||||
|
||||
if (m_bSwapRGB) {
|
||||
return c;
|
||||
}
|
||||
|
||||
@ -250,3 +250,123 @@ namespace NSBase64
|
||||
return Base64DecodeBase(szSrc, nSrcLen, pbDest, pnDestLen);
|
||||
}
|
||||
}
|
||||
|
||||
#include <cstring>
|
||||
namespace NSBase32
|
||||
{
|
||||
const unsigned char PADDING_CHAR_32 = '=';
|
||||
|
||||
inline void pad(unsigned char* buf, int len)
|
||||
{
|
||||
for (int i = 0; i < len; i++)
|
||||
buf[i] = PADDING_CHAR_32;
|
||||
}
|
||||
inline unsigned char shift_right(unsigned char byte, signed char offset)
|
||||
{
|
||||
if (offset > 0)
|
||||
return byte >> offset;
|
||||
else
|
||||
return byte << -offset;
|
||||
}
|
||||
inline unsigned char shift_left(unsigned char byte, signed char offset)
|
||||
{
|
||||
return shift_right(byte, - offset);
|
||||
}
|
||||
|
||||
unsigned char encode_char(unsigned char c)
|
||||
{
|
||||
static unsigned char base32[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
||||
return base32[c & 0x1F];
|
||||
}
|
||||
|
||||
int decode_char(unsigned char c)
|
||||
{
|
||||
char retval = -2;
|
||||
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
retval = c - 'A';
|
||||
else if (c >= '2' && c <= '7')
|
||||
retval = c - '2' + 26;
|
||||
else if (c == PADDING_CHAR_32)
|
||||
retval = -1;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int decode_sequence(const unsigned char* coded, unsigned char* plain)
|
||||
{
|
||||
plain[0] = 0;
|
||||
for (int block = 0; block < 8; block++)
|
||||
{
|
||||
int offset = (8 - 5 - (5*block) % 8);
|
||||
int octet = (block*5) / 8;
|
||||
|
||||
int c = decode_char(coded[block]);
|
||||
if (c < 0)
|
||||
return c;
|
||||
|
||||
plain[octet] |= shift_left(c, offset);
|
||||
if (offset < 0)
|
||||
{ // does this block overflows to next octet?
|
||||
plain[octet+1] = shift_left(c, 8 + offset);
|
||||
}
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
|
||||
bool Decode(unsigned char* in, int inLen, unsigned char* out)
|
||||
{
|
||||
for (size_t i = 0, j = 0; (i + 8) <= inLen; i += 8, j += 5)
|
||||
{
|
||||
int n = decode_sequence(&in[i], &out[j]);
|
||||
if (n == -2)
|
||||
return false;
|
||||
if (n < 5)
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void encode_sequence(const unsigned char* plain, int len, unsigned char* coded)
|
||||
{
|
||||
for (int block = 0; block < 8; block++)
|
||||
{
|
||||
int octet = (block*5) / 8;
|
||||
int junk = (8 - 5 - (5*block) % 8);
|
||||
|
||||
if (octet >= len)
|
||||
{
|
||||
pad(&coded[block], 8 - block);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char c = shift_right(plain[octet], junk); // first part
|
||||
|
||||
if (junk < 0 // is there a second part?
|
||||
&& octet < len - 1) // is there still something to read?
|
||||
{
|
||||
c |= shift_right(plain[octet+1], 8 + junk);
|
||||
}
|
||||
coded[block] = encode_char(c);
|
||||
}
|
||||
}
|
||||
|
||||
bool Encode(unsigned char* src, int len, unsigned char* dst)
|
||||
{
|
||||
for (int i = 0, j = 0; i < len; i += 5, j += 8)
|
||||
{
|
||||
int tmpLen = len - i;
|
||||
encode_sequence(&src[i], tmpLen > 5 ? 5 : tmpLen, &dst[j]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int DecodeGetRequiredLength(int bytes)
|
||||
{
|
||||
return (((bytes)/8)*5);
|
||||
}
|
||||
int EncodeGetRequiredLength(int bytes)
|
||||
{
|
||||
return (((bytes)/5)*8 + ((bytes) % 5 ? 8 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,4 +58,13 @@ namespace NSBase64
|
||||
KERNEL_DECL int Base64Decode(const wchar_t* szSrc, int nSrcLen, BYTE *pbDest, int *pnDestLen);
|
||||
}
|
||||
|
||||
namespace NSBase32
|
||||
{
|
||||
KERNEL_DECL bool Decode(unsigned char* in, int inLen, unsigned char* out);
|
||||
KERNEL_DECL bool Encode(unsigned char* in, int inLen, unsigned char* out);
|
||||
|
||||
KERNEL_DECL int DecodeGetRequiredLength(int bytes);
|
||||
KERNEL_DECL int EncodeGetRequiredLength(int bytes);
|
||||
}
|
||||
|
||||
#endif//_BUILD_BASE64_CROSSPLATFORM_DEFINE
|
||||
|
||||
@ -1535,6 +1535,11 @@ namespace NSFile
|
||||
return bIsSuccess;
|
||||
}
|
||||
|
||||
bool CFileBinary::IsGlobalTempPathUse()
|
||||
{
|
||||
return g_overrideTmpPath.empty() ? false : true;
|
||||
}
|
||||
|
||||
std::wstring CFileBinary::GetTempPath()
|
||||
{
|
||||
if (!g_overrideTmpPath.empty())
|
||||
|
||||
@ -189,6 +189,7 @@ namespace NSFile
|
||||
|
||||
static void SetTempPath(const std::wstring& strTempPath);
|
||||
static std::wstring GetTempPath();
|
||||
static bool IsGlobalTempPathUse();
|
||||
|
||||
static std::wstring CreateTempFileWithUniqueName(const std::wstring& strFolderPathRoot, const std::wstring& Prefix);
|
||||
static bool OpenTempFile(std::wstring *pwsName, FILE **ppFile, wchar_t *wsMode, wchar_t *wsExt, wchar_t *wsFolder, wchar_t* wsName = NULL);
|
||||
|
||||
@ -648,7 +648,7 @@ namespace NSStringUtils
|
||||
}
|
||||
void CStringBuilder::AddInt(int val)
|
||||
{
|
||||
AddSize(10);
|
||||
AddSize(11);
|
||||
AddIntNoCheck(val);
|
||||
}
|
||||
void CStringBuilder::AddUInt(unsigned int val)
|
||||
@ -682,7 +682,11 @@ namespace NSStringUtils
|
||||
}
|
||||
if (val < 0)
|
||||
{
|
||||
val = -val;
|
||||
if (val == -2147483648)
|
||||
val = 2147483647;
|
||||
else
|
||||
val = -val;
|
||||
|
||||
*m_pDataCur++ = (wchar_t)'-';
|
||||
++m_lSizeCur;
|
||||
}
|
||||
|
||||
@ -145,13 +145,23 @@ namespace NSDoctRenderer
|
||||
NSHyphen::CEngine::Init(private_GetFile(sConfigDir, oNodeDict.GetText()));
|
||||
}
|
||||
|
||||
bool bIsAbsoluteFontsPath = false;
|
||||
if (!m_bIsNotUseConfigAllFontsDir)
|
||||
{
|
||||
std::wstring sAllFontsPath = oNode.ReadNodeText(L"allfonts");
|
||||
if (!sAllFontsPath.empty())
|
||||
{
|
||||
m_strAllFonts = private_GetFile(sConfigDir, sAllFontsPath);
|
||||
if (NSFile::CFileBinary::Exists(sConfigDir + sAllFontsPath))
|
||||
m_strAllFonts = sConfigDir + sAllFontsPath;
|
||||
else if (NSFile::CFileBinary::Exists(sAllFontsPath))
|
||||
m_strAllFonts = sAllFontsPath;
|
||||
else
|
||||
{
|
||||
std::wstring sAllFontsDir = NSFile::GetDirectoryName(sAllFontsPath);
|
||||
if (NSDirectory::Exists(sConfigDir + sAllFontsDir))
|
||||
m_strAllFonts = sConfigDir + sAllFontsPath;
|
||||
else
|
||||
m_strAllFonts = sAllFontsPath;
|
||||
}
|
||||
|
||||
// на папку может не быть прав
|
||||
if (!NSFile::CFileBinary::Exists(m_strAllFonts))
|
||||
@ -163,20 +173,16 @@ namespace NSDoctRenderer
|
||||
if (NSDirectory::CreateDirectory(sAppDir + L"/docbuilder"))
|
||||
{
|
||||
m_strAllFonts = sAppDir + L"/docbuilder/AllFonts.js";
|
||||
// файл может не существовать пока - и тогда private_GetFile не учтет его
|
||||
bIsAbsoluteFontsPath = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose(pFileNative);
|
||||
NSFile::CFileBinary::Remove(m_strAllFonts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bIsAbsoluteFontsPath)
|
||||
m_strAllFonts = private_GetFile(sConfigDir, m_strAllFonts);
|
||||
}
|
||||
|
||||
m_strSdkPath = oNode.ReadNodeText(L"sdkjs");
|
||||
|
||||
@ -68,8 +68,8 @@ namespace NSDoctRenderer
|
||||
return m_pInternal->ExecuteCommand(command, retValue);
|
||||
}
|
||||
|
||||
CDocBuilderContext CDocBuilder::GetContext()
|
||||
CDocBuilderContext CDocBuilder::GetContext(bool enterContext)
|
||||
{
|
||||
return m_pInternal->GetContext();
|
||||
return m_pInternal->GetContext(enterContext);
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,6 +204,11 @@ namespace NSDoctRenderer
|
||||
* Creates an array. This method returns the current context and calls its CreateArray method.
|
||||
*/
|
||||
static CDocBuilderValue CreateArray(const int& length);
|
||||
/**
|
||||
* Please use CDocBuilderContext::CreateObject
|
||||
* Creates an object. This method returns the current context and calls its CreateObject method.
|
||||
*/
|
||||
static CDocBuilderValue CreateObject();
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -492,9 +497,10 @@ namespace NSDoctRenderer
|
||||
|
||||
/**
|
||||
* Returns the current JS context.
|
||||
* @param enterContext Whether returned context should be entered or not.
|
||||
* @return The current JS context
|
||||
*/
|
||||
CDocBuilderContext GetContext();
|
||||
CDocBuilderContext GetContext(bool enterContext = true);
|
||||
|
||||
public:
|
||||
/**
|
||||
|
||||
@ -83,6 +83,10 @@ public class CDocBuilder {
|
||||
return new CDocBuilderContext(c_GetContext(c_internal));
|
||||
}
|
||||
|
||||
public CDocBuilderContext getContext(boolean enterContext) {
|
||||
return new CDocBuilderContext(c_GetContextWithEnterParam(c_internal, enterContext));
|
||||
}
|
||||
|
||||
public static void initialize() {
|
||||
c_Initialize();
|
||||
}
|
||||
@ -135,6 +139,7 @@ public class CDocBuilder {
|
||||
private static native String c_GetVersion(long self);
|
||||
|
||||
private static native long c_GetContext(long self);
|
||||
private static native long c_GetContextWithEnterParam(long self, boolean enterContext);
|
||||
|
||||
private static native void c_Initialize();
|
||||
private static native void c_InitializeWithDirectory(String directory);
|
||||
|
||||
@ -40,7 +40,7 @@ public class NativeLibraryLoader {
|
||||
throw new RuntimeException("Unsupported OS");
|
||||
}
|
||||
|
||||
String[] libs = {"UnicodeConverter", "kernel", "kernel_network", "graphics", "doctrenderer", "docbuilder.jni"};
|
||||
String[] libs = {"UnicodeConverter", "kernel", "kernel_network", "graphics", "PdfFile", "XpsFile", "DjVuFile", "DocxRenderer", "doctrenderer", "docbuilder.jni"};
|
||||
|
||||
String prefix = "";
|
||||
if (OSChecker.isMac() || OSChecker.isLinux()) {
|
||||
|
||||
@ -162,6 +162,12 @@ jlong Java_docbuilder_CDocBuilder_c_1GetContext(JNIEnv* env, jclass cls, jlong s
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext(pSelf->GetContext()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilder_c_1GetContextWithEnterParam(JNIEnv* env, jclass cls, jlong self, jboolean enterContext)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext(pSelf->GetContext((bool)enterContext)));
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1Initialize(JNIEnv* env, jclass cls)
|
||||
{
|
||||
CDocBuilder::Initialize();
|
||||
|
||||
@ -167,6 +167,14 @@ JNIEXPORT jstring JNICALL Java_docbuilder_CDocBuilder_c_1GetVersion
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1GetContext
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_GetContextWithEnterParam
|
||||
* Signature: (JZ)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1GetContextWithEnterParam
|
||||
(JNIEnv *, jclass, jlong, jboolean);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_Initialize
|
||||
|
||||
@ -17,7 +17,6 @@ public class Program {
|
||||
builder.createFile(FileTypes.Document.DOCX);
|
||||
|
||||
CDocBuilderContext context = builder.getContext();
|
||||
CDocBuilderContextScope scope = context.createScope();
|
||||
|
||||
CDocBuilderValue global = context.getGlobal();
|
||||
|
||||
|
||||
@ -121,6 +121,9 @@ def _loadLibrary(path):
|
||||
_lib.CDocBuilderValue_CreateArray.argtypes = [ctypes.c_int]
|
||||
_lib.CDocBuilderValue_CreateArray.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_CreateObject.argtypes = []
|
||||
_lib.CDocBuilderValue_CreateObject.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_Call0.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p]
|
||||
_lib.CDocBuilderValue_Call0.restype = OBJECT_HANDLE
|
||||
|
||||
@ -200,7 +203,7 @@ def _loadLibrary(path):
|
||||
_lib.CDocBuilder_GetVersion.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilder_GetVersion.restype = STRING_HANDLE
|
||||
|
||||
_lib.CDocBuilder_GetContext.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilder_GetContext.argtypes = [OBJECT_HANDLE, ctypes.c_bool]
|
||||
_lib.CDocBuilder_GetContext.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilder_Initialize.argtypes = []
|
||||
@ -280,6 +283,12 @@ class CDocBuilderValue:
|
||||
self._internal = _lib.CDocBuilderValue_CreateArray(length)
|
||||
for i in range(length):
|
||||
self.Set(i, value[i])
|
||||
elif isinstance(value, dict):
|
||||
self._internal = _lib.CDocBuilderValue_CreateObject()
|
||||
for key in value.keys():
|
||||
if not isinstance(key, str):
|
||||
raise TypeError("CDocBuilderValue constructor supports only str keys in dict")
|
||||
self.SetProperty(key, value[key])
|
||||
elif isinstance(value, CDocBuilderValue):
|
||||
self._internal = _lib.CDocBuilderValue_Copy(value._internal)
|
||||
elif isinstance(value, OBJECT_HANDLE):
|
||||
@ -385,6 +394,10 @@ class CDocBuilderValue:
|
||||
def CreateArray(length):
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_CreateArray(length)))
|
||||
|
||||
@staticmethod
|
||||
def CreateObject():
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_CreateObject()))
|
||||
|
||||
def Call(self, name, *args):
|
||||
if len(args) == 0:
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_Call0(self._internal, ctypes.c_wchar_p(name))))
|
||||
@ -479,8 +492,8 @@ class CDocBuilder:
|
||||
_lib.DeleteCharP(ctypes.cast(strVersion, ctypes.c_char_p))
|
||||
return version
|
||||
|
||||
def GetContext(self):
|
||||
return CDocBuilderContext(OBJECT_HANDLE(_lib.CDocBuilder_GetContext(self._internal)))
|
||||
def GetContext(self, enterContext=True):
|
||||
return CDocBuilderContext(OBJECT_HANDLE(_lib.CDocBuilder_GetContext(self._internal, ctypes.c_bool(enterContext))))
|
||||
|
||||
@classmethod
|
||||
def Initialize(cls, directory=None):
|
||||
|
||||
@ -164,6 +164,11 @@ CDocBuilderValue* CDocBuilderValue_CreateArray(int length)
|
||||
return new CDocBuilderValue(CDocBuilderValue::CreateArray(length));
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_CreateObject()
|
||||
{
|
||||
return new CDocBuilderValue(CDocBuilderValue::CreateObject());
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_Call0(CDocBuilderValue* self, const wchar_t* name)
|
||||
{
|
||||
return new CDocBuilderValue(self->Call(name));
|
||||
@ -296,9 +301,9 @@ char* CDocBuilder_GetVersion(CDocBuilder* self)
|
||||
return self->GetVersion();
|
||||
}
|
||||
|
||||
CDocBuilderContext* CDocBuilder_GetContext(CDocBuilder* self)
|
||||
CDocBuilderContext* CDocBuilder_GetContext(CDocBuilder* self, bool enterContext)
|
||||
{
|
||||
return new CDocBuilderContext(self->GetContext());
|
||||
return new CDocBuilderContext(self->GetContext(enterContext));
|
||||
}
|
||||
|
||||
void CDocBuilder_Initialize()
|
||||
|
||||
@ -56,6 +56,7 @@ DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_CreateWithString(const w
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_CreateUndefined();
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_CreateNull();
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_CreateArray(int length);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_CreateObject();
|
||||
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_Call0(CDocBuilderValue* self, const wchar_t* name);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_Call1(CDocBuilderValue* self, const wchar_t* name, CDocBuilderValue* p1);
|
||||
@ -96,7 +97,7 @@ DOCBUILDER_FUNC_DECL bool CDocBuilder_IsSaveWithDoctrendererMode(CDocBuilder* se
|
||||
|
||||
DOCBUILDER_FUNC_DECL char* CDocBuilder_GetVersion(CDocBuilder* self);
|
||||
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderContext* CDocBuilder_GetContext(CDocBuilder* self);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderContext* CDocBuilder_GetContext(CDocBuilder* self, bool enterContext);
|
||||
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilder_Initialize();
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilder_InitializeWithDirectory(const wchar_t* directory);
|
||||
|
||||
@ -56,7 +56,6 @@ CV8RealTimeWorker::CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder, cons
|
||||
CJSContextScope scope(m_context);
|
||||
|
||||
CJSContext::Embed<CNativeControlEmbed>(false);
|
||||
CJSContext::Embed<CGraphicsEmbed>();
|
||||
NSJSBase::CreateDefaults();
|
||||
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
@ -821,6 +820,14 @@ namespace NSDoctRenderer
|
||||
return ret;
|
||||
}
|
||||
|
||||
CDocBuilderValue CDocBuilderValue::CreateObject()
|
||||
{
|
||||
CDocBuilderValue ret;
|
||||
ret.m_internal->m_context = NSJSBase::CJSContext::GetCurrent();
|
||||
ret.m_internal->m_value = NSJSBase::CJSContext::createObject();
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Functions
|
||||
CDocBuilderValue CDocBuilderValue::Call(const char* name)
|
||||
{
|
||||
|
||||
@ -407,6 +407,11 @@ public:
|
||||
{
|
||||
m_scopes.push_back(scope);
|
||||
}
|
||||
|
||||
void AddNewScope(NSDoctRenderer::CDocBuilderContextScopeWrap* scope)
|
||||
{
|
||||
m_scopes.emplace_back(scope);
|
||||
}
|
||||
};
|
||||
|
||||
class CV8RealTimeWorker
|
||||
@ -723,22 +728,13 @@ namespace NSDoctRenderer
|
||||
oBuilder.WriteEncodeXmlString(sFolder);
|
||||
oBuilder.WriteString(L"/Editor.bin</m_sFileTo><m_nFormatTo>8192</m_nFormatTo>");
|
||||
|
||||
if (!m_bIsNotUseConfigAllFontsDir)
|
||||
{
|
||||
oBuilder.WriteString(L"<m_sFontDir>");
|
||||
oBuilder.WriteEncodeXmlString(m_sX2tPath + L"/sdkjs/common");
|
||||
oBuilder.WriteString(L"</m_sFontDir>");
|
||||
}
|
||||
else
|
||||
{
|
||||
oBuilder.WriteString(L"<m_sFontDir>");
|
||||
oBuilder.WriteEncodeXmlString(NSFile::GetDirectoryName(m_strAllFonts));
|
||||
oBuilder.WriteString(L"</m_sFontDir>");
|
||||
oBuilder.WriteString(L"<m_sFontDir>");
|
||||
oBuilder.WriteEncodeXmlString(NSFile::GetDirectoryName(m_strAllFonts));
|
||||
oBuilder.WriteString(L"</m_sFontDir>");
|
||||
|
||||
oBuilder.WriteString(L"<m_sAllFontsPath>");
|
||||
oBuilder.WriteEncodeXmlString(m_strAllFonts);
|
||||
oBuilder.WriteString(L"</m_sAllFontsPath>");
|
||||
}
|
||||
oBuilder.WriteString(L"<m_sAllFontsPath>");
|
||||
oBuilder.WriteEncodeXmlString(m_strAllFonts);
|
||||
oBuilder.WriteString(L"</m_sAllFontsPath>");
|
||||
|
||||
oBuilder.WriteString(L"<m_bIsNoBase64>true</m_bIsNoBase64>");
|
||||
oBuilder.WriteString(L"<m_sThemeDir>./sdkjs/slide/themes</m_sThemeDir><m_bDontSaveAdditional>true</m_bDontSaveAdditional>");
|
||||
@ -1049,22 +1045,13 @@ namespace NSDoctRenderer
|
||||
oBuilder.WriteString(L"</m_sThemeDir><m_bFromChanges>true</m_bFromChanges><m_bDontSaveAdditional>true</m_bDontSaveAdditional>");
|
||||
oBuilder.WriteString(L"<m_nCsvTxtEncoding>46</m_nCsvTxtEncoding><m_nCsvDelimiter>4</m_nCsvDelimiter>");
|
||||
|
||||
if (!m_bIsNotUseConfigAllFontsDir)
|
||||
{
|
||||
oBuilder.WriteString(L"<m_sFontDir>");
|
||||
oBuilder.WriteEncodeXmlString(m_sX2tPath + L"/sdkjs/common");
|
||||
oBuilder.WriteString(L"</m_sFontDir>");
|
||||
}
|
||||
else
|
||||
{
|
||||
oBuilder.WriteString(L"<m_sFontDir>");
|
||||
oBuilder.WriteEncodeXmlString(NSFile::GetDirectoryName(m_strAllFonts));
|
||||
oBuilder.WriteString(L"</m_sFontDir>");
|
||||
oBuilder.WriteString(L"<m_sFontDir>");
|
||||
oBuilder.WriteEncodeXmlString(NSFile::GetDirectoryName(m_strAllFonts));
|
||||
oBuilder.WriteString(L"</m_sFontDir>");
|
||||
|
||||
oBuilder.WriteString(L"<m_sAllFontsPath>");
|
||||
oBuilder.WriteEncodeXmlString(m_strAllFonts);
|
||||
oBuilder.WriteString(L"</m_sAllFontsPath>");
|
||||
}
|
||||
oBuilder.WriteString(L"<m_sAllFontsPath>");
|
||||
oBuilder.WriteEncodeXmlString(m_strAllFonts);
|
||||
oBuilder.WriteString(L"</m_sAllFontsPath>");
|
||||
|
||||
if (!sConvertionParams.empty())
|
||||
{
|
||||
@ -1284,7 +1271,7 @@ namespace NSDoctRenderer
|
||||
return m_pWorker->ExecuteCommand(command, retValue);
|
||||
}
|
||||
|
||||
CDocBuilderContext GetContext()
|
||||
CDocBuilderContext GetContext(bool enterContext)
|
||||
{
|
||||
CDocBuilderContext ctx;
|
||||
|
||||
@ -1292,6 +1279,14 @@ namespace NSDoctRenderer
|
||||
|
||||
ctx.m_internal->m_context = m_pWorker->m_context;
|
||||
ctx.m_internal->m_context_data = &m_pWorker->m_oContextData;
|
||||
|
||||
if (enterContext)
|
||||
{
|
||||
CDocBuilderContextScopeWrap* scopeWrap = new CDocBuilderContextScopeWrap();
|
||||
scopeWrap->m_scope = new CJSContextScope(m_pWorker->m_context);
|
||||
m_pWorker->m_oContextData.AddNewScope(scopeWrap);
|
||||
}
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
@ -445,7 +445,7 @@ namespace NSDoctRenderer
|
||||
strError = L"code=\"save\"";
|
||||
bIsBreak = true;
|
||||
}
|
||||
else
|
||||
else if (!js_result2->isNull())
|
||||
{
|
||||
JSSmart<CJSTypedArray> typedArray = js_result2->toTypedArray();
|
||||
NSJSBase::CJSDataBuffer oBuffer = typedArray->getData();
|
||||
@ -575,7 +575,6 @@ namespace NSDoctRenderer
|
||||
{
|
||||
CJSContextScope scope(context);
|
||||
CJSContext::Embed<CNativeControlEmbed>(false);
|
||||
CJSContext::Embed<CGraphicsEmbed>();
|
||||
NSJSBase::CreateDefaults();
|
||||
|
||||
JSSmart<CJSTryCatch> try_catch = context->GetExceptions();
|
||||
@ -1067,7 +1066,6 @@ namespace NSDoctRenderer
|
||||
{
|
||||
CJSContextScope scope(context);
|
||||
CJSContext::Embed<CNativeControlEmbed>();
|
||||
CJSContext::Embed<CGraphicsEmbed>();
|
||||
NSJSBase::CreateDefaults();
|
||||
|
||||
JSSmart<CJSObject> global = context->GetGlobal();
|
||||
|
||||
@ -42,6 +42,8 @@
|
||||
#include "../../HtmlRenderer/include/HTMLRendererText.h"
|
||||
#include "../../DocxRenderer/DocxRenderer.h"
|
||||
|
||||
#define CHECKER_FILE_BUFFER_LEN 4096
|
||||
|
||||
class CDrawingFile
|
||||
{
|
||||
private:
|
||||
@ -122,18 +124,38 @@ public:
|
||||
{
|
||||
CloseFile();
|
||||
|
||||
if (NULL == m_pFile)
|
||||
int nType = DetectFormat(sFile);
|
||||
|
||||
switch (nType)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_pFile = new CPdfFile(m_pApplicationFonts);
|
||||
if (!m_pFile->LoadFromFile(sFile, L"", sPassword, sPassword))
|
||||
{
|
||||
if (4 != ((CPdfFile*)m_pFile)->GetError())
|
||||
{
|
||||
RELEASEOBJECT(m_pFile);
|
||||
}
|
||||
else
|
||||
m_nType = 0;
|
||||
}
|
||||
else
|
||||
m_nType = 0;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
m_pFile = new CDjVuFile(m_pApplicationFonts);
|
||||
if (!m_pFile->LoadFromFile(sFile, L"", sPassword, sPassword))
|
||||
{
|
||||
RELEASEOBJECT(m_pFile);
|
||||
}
|
||||
else
|
||||
m_nType = 0;
|
||||
m_nType = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (NULL == m_pFile)
|
||||
case 2:
|
||||
{
|
||||
m_pFile = new CXpsFile(m_pApplicationFonts);
|
||||
if (!m_pFile->LoadFromFile(sFile, L"", sPassword, sPassword))
|
||||
@ -143,16 +165,8 @@ public:
|
||||
else
|
||||
m_nType = 2;
|
||||
}
|
||||
|
||||
if (NULL == m_pFile)
|
||||
{
|
||||
m_pFile = new CDjVuFile(m_pApplicationFonts);
|
||||
if (!m_pFile->LoadFromFile(sFile, L"", sPassword, sPassword))
|
||||
{
|
||||
RELEASEOBJECT(m_pFile);
|
||||
}
|
||||
else
|
||||
m_nType = 1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return m_pFile ? true : false;
|
||||
@ -162,37 +176,48 @@ public:
|
||||
{
|
||||
CloseFile();
|
||||
|
||||
if (NULL == m_pFile)
|
||||
int nType = DetectFormat(data, size);
|
||||
switch (nType)
|
||||
{
|
||||
m_pFile = new CPdfFile(m_pApplicationFonts);
|
||||
if (!m_pFile->LoadFromMemory(data, size, L"", sPassword, sPassword))
|
||||
case 0:
|
||||
{
|
||||
RELEASEOBJECT(m_pFile);
|
||||
m_pFile = new CPdfFile(m_pApplicationFonts);
|
||||
if (!m_pFile->LoadFromMemory(data, size, L"", sPassword, sPassword))
|
||||
{
|
||||
if (4 != ((CPdfFile*)m_pFile)->GetError())
|
||||
{
|
||||
RELEASEOBJECT(m_pFile);
|
||||
}
|
||||
else
|
||||
m_nType = 0;
|
||||
}
|
||||
else
|
||||
m_nType = 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
m_nType = 0;
|
||||
}
|
||||
|
||||
if (NULL == m_pFile)
|
||||
{
|
||||
m_pFile = new CXpsFile(m_pApplicationFonts);
|
||||
if (!m_pFile->LoadFromMemory(data, size, L"", sPassword, sPassword))
|
||||
case 1:
|
||||
{
|
||||
RELEASEOBJECT(m_pFile);
|
||||
m_pFile = new CDjVuFile(m_pApplicationFonts);
|
||||
if (!m_pFile->LoadFromMemory(data, size, L"", sPassword, sPassword))
|
||||
{
|
||||
RELEASEOBJECT(m_pFile);
|
||||
}
|
||||
else
|
||||
m_nType = 1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
m_nType = 2;
|
||||
}
|
||||
|
||||
if (NULL == m_pFile)
|
||||
{
|
||||
m_pFile = new CDjVuFile(m_pApplicationFonts);
|
||||
if (!m_pFile->LoadFromMemory(data, size, L"", sPassword, sPassword))
|
||||
case 2:
|
||||
{
|
||||
RELEASEOBJECT(m_pFile);
|
||||
m_pFile = new CXpsFile(m_pApplicationFonts);
|
||||
if (!m_pFile->LoadFromMemory(data, size, L"", sPassword, sPassword))
|
||||
{
|
||||
RELEASEOBJECT(m_pFile);
|
||||
}
|
||||
else
|
||||
m_nType = 2;
|
||||
}
|
||||
else
|
||||
m_nType = 1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return m_pFile ? true : false;
|
||||
@ -484,6 +509,14 @@ public:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::wstring GetFontBinaryNative(const std::wstring& sName)
|
||||
{
|
||||
if (0 != m_nType)
|
||||
return L"";
|
||||
|
||||
return ((CPdfFile*)m_pFile)->GetEmbeddedFontPath(sName);
|
||||
}
|
||||
|
||||
private:
|
||||
int GetPagesCount()
|
||||
{
|
||||
@ -514,7 +547,44 @@ private:
|
||||
nPageDpiX = dPageDpiX;
|
||||
}
|
||||
|
||||
int DetectFormat(const std::wstring& sFile)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (oFile.OpenFile(sFile))
|
||||
{
|
||||
LONG size = oFile.GetFileSize();
|
||||
if (size > CHECKER_FILE_BUFFER_LEN)
|
||||
size = CHECKER_FILE_BUFFER_LEN;
|
||||
|
||||
BYTE* data = new BYTE[size];
|
||||
oFile.ReadFile(data, size);
|
||||
|
||||
int nType = DetectFormat(data, size);
|
||||
|
||||
RELEASEARRAYOBJECTS(data);
|
||||
return nType;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int DetectFormat(BYTE* data, LONG size)
|
||||
{
|
||||
// 0 - PDF
|
||||
// 1 - DJVU
|
||||
// 2 - XPS
|
||||
LONG nSize = size < CHECKER_FILE_BUFFER_LEN ? size : CHECKER_FILE_BUFFER_LEN;
|
||||
char* pData = (char*)data;
|
||||
for (int i = 0; i < nSize - 5; ++i)
|
||||
{
|
||||
int nPDF = strncmp(&pData[i], "%PDF-", 5);
|
||||
if (!nPDF)
|
||||
return 0;
|
||||
}
|
||||
if ( (8 <= size) && (0x41 == data[0] && 0x54 == data[1] && 0x26 == data[2] && 0x54 == data[3] &&
|
||||
0x46 == data[4] && 0x4f == data[5] && 0x52 == data[6] && 0x4d == data[7]))
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // DRAWINGFILE_H
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "./MemoryStreamEmbed.h"
|
||||
#include "./TextMeasurerEmbed.h"
|
||||
#include "./HashEmbed.h"
|
||||
#include "./GraphicsEmbed.h"
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
@ -13,5 +14,6 @@ namespace NSJSBase
|
||||
CJSContext::Embed<CMemoryStreamEmbed>();
|
||||
CJSContext::Embed<CTextMeasurerEmbed>();
|
||||
CJSContext::Embed<CHashEmbed>();
|
||||
CJSContext::Embed<CGraphicsEmbed>();
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,6 +71,19 @@ JSSmart<CJSValue> CDrawingFileEmbed::DestroyPixmap(JSSmart<CJSValue> typedArray)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetFontBinary(JSSmart<CJSValue> Id)
|
||||
{
|
||||
if (0 != m_pFile->GetType())
|
||||
return NULL;
|
||||
|
||||
std::wstring sName = Id->toStringW();
|
||||
std::wstring sFile = m_pFile->GetFontBinaryNative(sName);
|
||||
if (sFile.empty())
|
||||
return NULL;
|
||||
|
||||
return CJSContext::createUint8Array(sFile);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetGlyphs(JSSmart<CJSValue> nPageIndex)
|
||||
{
|
||||
return WasmMemoryToJS(m_pFile->GetGlyphs(nPageIndex->toInt32()));
|
||||
|
||||
@ -40,6 +40,7 @@ public:
|
||||
JSSmart<CJSValue> GetAnnotationsInfo(JSSmart<CJSValue> nPageIndex);
|
||||
JSSmart<CJSValue> GetAnnotationsAP(JSSmart<CJSValue> nRasterW, JSSmart<CJSValue> nRasterH, JSSmart<CJSValue> nBackgroundColor, JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> nAnnot, JSSmart<CJSValue> nView);
|
||||
|
||||
JSSmart<CJSValue> GetFontBinary(JSSmart<CJSValue> Id);
|
||||
JSSmart<CJSValue> GetGlyphs(JSSmart<CJSValue> nPageIndex);
|
||||
JSSmart<CJSValue> DestroyTextInfo();
|
||||
|
||||
|
||||
@ -1,8 +1,178 @@
|
||||
#include "GraphicsEmbed.h"
|
||||
#include "../graphics.h"
|
||||
#include <map>
|
||||
#include "../../../Common/Network/FileTransporter/include/FileTransporter.h"
|
||||
|
||||
// APPLICATION INFO
|
||||
class CGraphicsAppImage_private
|
||||
{
|
||||
public:
|
||||
NSFonts::IApplicationFonts* m_pFonts;
|
||||
std::wstring m_sFontsDirectory;
|
||||
std::wstring m_sImagesDirectory;
|
||||
std::wstring m_sThemesDirectory;
|
||||
bool m_bIsRgba;
|
||||
|
||||
std::map<std::wstring, std::wstring> m_mapDownloads;
|
||||
|
||||
CGraphicsAppImage_private()
|
||||
{
|
||||
m_pFonts = NULL;
|
||||
m_sFontsDirectory = L"";
|
||||
m_sImagesDirectory = L"";
|
||||
m_sThemesDirectory = L"";
|
||||
m_bIsRgba = false;
|
||||
}
|
||||
~CGraphicsAppImage_private()
|
||||
{
|
||||
RELEASEINTERFACE(m_pFonts);
|
||||
|
||||
for (std::map<std::wstring, std::wstring>::iterator i = m_mapDownloads.begin(); i != m_mapDownloads.end(); i++)
|
||||
{
|
||||
std::wstring sTmp = i->second;
|
||||
if (NSFile::CFileBinary::Exists(sTmp))
|
||||
NSFile::CFileBinary::Remove(sTmp);
|
||||
}
|
||||
}
|
||||
|
||||
bool IsNeedDownload(const std::wstring& sUrl)
|
||||
{
|
||||
if ((0 == sUrl.find(L"www.")) ||
|
||||
(0 == sUrl.find(L"http://")) ||
|
||||
(0 == sUrl.find(L"https://")))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::wstring GetImagePath(const std::wstring& sUrl)
|
||||
{
|
||||
std::map<std::wstring, std::wstring>::iterator find = m_mapDownloads.find(sUrl);
|
||||
if (find != m_mapDownloads.end())
|
||||
return find->second;
|
||||
|
||||
NSNetwork::NSFileTransport::CFileDownloader oDownloader(sUrl, false);
|
||||
|
||||
std::wstring sTmpFile = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"IMG");
|
||||
if (NSFile::CFileBinary::Exists(sTmpFile))
|
||||
NSFile::CFileBinary::Remove(sTmpFile);
|
||||
sTmpFile = sTmpFile + L".png";
|
||||
|
||||
oDownloader.SetFilePath(sTmpFile);
|
||||
oDownloader.Start(0);
|
||||
while ( oDownloader.IsRunned() )
|
||||
{
|
||||
NSThreads::Sleep( 10 );
|
||||
}
|
||||
bool bIsDownloaded = oDownloader.IsFileDownloaded();
|
||||
|
||||
if (bIsDownloaded)
|
||||
{
|
||||
m_mapDownloads.insert(std::pair<std::wstring, std::wstring>(sUrl, sTmpFile));
|
||||
return sTmpFile;
|
||||
}
|
||||
|
||||
return sUrl;
|
||||
}
|
||||
};
|
||||
|
||||
CGraphicsAppImage::CGraphicsAppImage()
|
||||
{
|
||||
m_internal = new CGraphicsAppImage_private();
|
||||
}
|
||||
CGraphicsAppImage::~CGraphicsAppImage()
|
||||
{
|
||||
delete m_internal;
|
||||
}
|
||||
|
||||
void CGraphicsAppImage::SetFontsDirectory(const std::wstring& dir)
|
||||
{
|
||||
m_internal->m_sFontsDirectory = dir;
|
||||
}
|
||||
std::wstring CGraphicsAppImage::GetFontsDirectory()
|
||||
{
|
||||
return m_internal->m_sFontsDirectory;
|
||||
}
|
||||
|
||||
void CGraphicsAppImage::SetImagesDirectory(const std::wstring& dir)
|
||||
{
|
||||
m_internal->m_sImagesDirectory = dir;
|
||||
}
|
||||
std::wstring CGraphicsAppImage::GetImagesDirectory()
|
||||
{
|
||||
return m_internal->m_sImagesDirectory;
|
||||
}
|
||||
|
||||
void CGraphicsAppImage::SetThemesDirectory(const std::wstring& dir)
|
||||
{
|
||||
m_internal->m_sThemesDirectory = dir;
|
||||
}
|
||||
std::wstring CGraphicsAppImage::GetThemesDirectory()
|
||||
{
|
||||
return m_internal->m_sThemesDirectory;
|
||||
}
|
||||
|
||||
void CGraphicsAppImage::SetFonts(NSFonts::IApplicationFonts* fonts)
|
||||
{
|
||||
m_internal->m_pFonts = fonts;
|
||||
ADDREFINTERFACE(fonts);
|
||||
}
|
||||
NSFonts::IApplicationFonts* CGraphicsAppImage::GetFonts()
|
||||
{
|
||||
return m_internal->m_pFonts;
|
||||
}
|
||||
|
||||
void CGraphicsAppImage::SetRgba(const bool& isRgba)
|
||||
{
|
||||
m_internal->m_bIsRgba = isRgba;
|
||||
}
|
||||
bool CGraphicsAppImage::GetRgba()
|
||||
{
|
||||
return m_internal->m_bIsRgba;
|
||||
}
|
||||
|
||||
unsigned char* CGraphicsAppImage::GetBits(int& w, int& h)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
unsigned char* CGraphicsAppImage::AllocBits(const int& w, const int& h)
|
||||
{
|
||||
return new unsigned char[4 * w * h];
|
||||
}
|
||||
|
||||
// APPLICATION INFO END
|
||||
|
||||
CGraphicsEmbed::CGraphicsEmbed() : m_pInternal(new NSGraphics::CGraphics())
|
||||
{
|
||||
}
|
||||
CGraphicsEmbed::~CGraphicsEmbed()
|
||||
{
|
||||
RELEASEOBJECT(m_pInternal);
|
||||
}
|
||||
|
||||
CGraphicsAppImage* CGraphicsEmbed::GetAppImage()
|
||||
{
|
||||
return m_pInternal->m_pAppImage;
|
||||
}
|
||||
|
||||
void CGraphicsEmbed::SetAppImage(CGraphicsAppImage* appImage)
|
||||
{
|
||||
m_pInternal->m_pAppImage = appImage;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CGraphicsEmbed::create(JSSmart<CJSValue> Native, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm)
|
||||
{
|
||||
m_pInternal->init((NSNativeControl::CNativeControl*)Native->toObject()->getNative()->getObject(), width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble());
|
||||
NSNativeControl::CNativeControl* pControl = NULL;
|
||||
if (!Native->isNull())
|
||||
{
|
||||
pControl = (NSNativeControl::CNativeControl*)Native->toObject()->getNative()->getObject();
|
||||
|
||||
if (m_pInternal->m_pAppImage)
|
||||
delete m_pInternal->m_pAppImage;
|
||||
m_pInternal->m_pAppImage = new CGraphicsAppImage();
|
||||
m_pInternal->m_pAppImage->SetFontsDirectory(pControl->m_strFontsDirectory);
|
||||
m_pInternal->m_pAppImage->SetImagesDirectory(pControl->m_strImagesDirectory);
|
||||
}
|
||||
|
||||
m_pInternal->init(width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::Destroy()
|
||||
@ -150,11 +320,19 @@ JSSmart<CJSValue> CGraphicsEmbed::ClearLastFont()
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::drawImage2(JSSmart<CJSValue> img, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> alpha, JSSmart<CJSValue> srcRect)
|
||||
{
|
||||
m_pInternal->drawImage(img->toStringW(), x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32());
|
||||
std::wstring sUrl = img->toStringW();
|
||||
if (m_pInternal->m_pAppImage && m_pInternal->m_pAppImage->m_internal->IsNeedDownload(sUrl))
|
||||
sUrl = m_pInternal->m_pAppImage->m_internal->GetImagePath(sUrl);
|
||||
|
||||
m_pInternal->drawImage(sUrl, x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::drawImage (JSSmart<CJSValue> img, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> alpha, JSSmart<CJSValue> srcRect, JSSmart<CJSValue> nativeImage)
|
||||
{
|
||||
std::wstring sUrl = img->toStringW();
|
||||
if (m_pInternal->m_pAppImage && m_pInternal->m_pAppImage->m_internal->IsNeedDownload(sUrl))
|
||||
sUrl = m_pInternal->m_pAppImage->m_internal->GetImagePath(sUrl);
|
||||
|
||||
m_pInternal->drawImage(img->toStringW(), x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
@ -459,7 +637,11 @@ JSSmart<CJSValue> CGraphicsEmbed::GetBrushColor()
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::put_brushTexture(JSSmart<CJSValue> src, JSSmart<CJSValue> type)
|
||||
{
|
||||
m_pInternal->put_brushTexture(src->toStringW(), type->toInt32());
|
||||
std::wstring sUrl = src->toStringW();
|
||||
if (m_pInternal->m_pAppImage && m_pInternal->m_pAppImage->m_internal->IsNeedDownload(sUrl))
|
||||
sUrl = m_pInternal->m_pAppImage->m_internal->GetImagePath(sUrl);
|
||||
|
||||
m_pInternal->put_brushTexture(sUrl, type->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::put_brushTextureMode(JSSmart<CJSValue> mode)
|
||||
|
||||
@ -1,21 +1,57 @@
|
||||
#ifndef _BUILD_NATIVE_GRAPHICS_EMBED_H_
|
||||
#define _BUILD_NATIVE_GRAPHICS_EMBED_H_
|
||||
|
||||
#include "../graphics.h"
|
||||
#include "../../graphics/pro/Fonts.h"
|
||||
#include "../js_internal/js_base.h"
|
||||
|
||||
class CGraphicsAppImage_private;
|
||||
class JS_DECL CGraphicsAppImage
|
||||
{
|
||||
public:
|
||||
CGraphicsAppImage();
|
||||
virtual ~CGraphicsAppImage();
|
||||
public:
|
||||
void SetFontsDirectory(const std::wstring& dir);
|
||||
std::wstring GetFontsDirectory();
|
||||
|
||||
void SetImagesDirectory(const std::wstring& dir);
|
||||
std::wstring GetImagesDirectory();
|
||||
|
||||
void SetThemesDirectory(const std::wstring& dir);
|
||||
std::wstring GetThemesDirectory();
|
||||
|
||||
void SetFonts(NSFonts::IApplicationFonts* fonts);
|
||||
NSFonts::IApplicationFonts* GetFonts();
|
||||
|
||||
void SetRgba(const bool& isRgba);
|
||||
bool GetRgba();
|
||||
|
||||
virtual unsigned char* GetBits(int& w, int& h);
|
||||
virtual unsigned char* AllocBits(const int& w, const int& h);
|
||||
|
||||
private:
|
||||
CGraphicsAppImage_private* m_internal;
|
||||
|
||||
friend class CGraphicsEmbed;
|
||||
};
|
||||
|
||||
namespace NSGraphics { class CGraphics; }
|
||||
|
||||
using namespace NSJSBase;
|
||||
class CGraphicsEmbed : public CJSEmbedObject
|
||||
class JS_DECL CGraphicsEmbed : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
NSGraphics::CGraphics* m_pInternal;
|
||||
|
||||
public:
|
||||
CGraphicsEmbed() : m_pInternal(new NSGraphics::CGraphics()) {}
|
||||
~CGraphicsEmbed() { RELEASEOBJECT(m_pInternal); }
|
||||
CGraphicsEmbed();
|
||||
~CGraphicsEmbed();
|
||||
|
||||
virtual void* getObject() override { return (void*)m_pInternal; }
|
||||
|
||||
CGraphicsAppImage* GetAppImage();
|
||||
void SetAppImage(CGraphicsAppImage* appImage);
|
||||
|
||||
public:
|
||||
JSSmart<CJSValue> create(JSSmart<CJSValue> Native, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm);
|
||||
JSSmart<CJSValue> Destroy();
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#include "./../docbuilder_p.h"
|
||||
|
||||
#include "../../common/Directory.h"
|
||||
#include "../server.h"
|
||||
|
||||
JSSmart<CJSValue> CBuilderDocumentEmbed::IsValid()
|
||||
{
|
||||
@ -68,13 +69,23 @@ void CBuilderDocumentEmbed::_OpenFile(const std::wstring& sFile, const std::wstr
|
||||
int nConvertResult = pBuilder->ConvertToInternalFormat(m_sFolder, sFileCopy, sParams);
|
||||
|
||||
if (0 == nConvertResult)
|
||||
{
|
||||
if (CServerInstance::getInstance().IsEnable())
|
||||
CServerInstance::getInstance().AddTmpFile(m_sFolder);
|
||||
m_bIsValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CBuilderDocumentEmbed::_CloseFile()
|
||||
{
|
||||
if (!m_sFolder.empty())
|
||||
{
|
||||
NSDirectory::DeleteDirectory(m_sFolder);
|
||||
|
||||
if (m_bIsValid && CServerInstance::getInstance().IsEnable())
|
||||
CServerInstance::getInstance().RemoveTmpFile(m_sFolder);
|
||||
}
|
||||
|
||||
m_bIsValid = false;
|
||||
m_sFolder = L"";
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
-(JSValue*) GetButtonIcons : (JSValue*)nBackgroundColor : (JSValue*)nPageIndex : (JSValue*)bBase64 : (JSValue*)nButtonWidget : (JSValue*)nIconView;
|
||||
-(JSValue*) GetAnnotationsInfo : (JSValue*)nPageIndex;
|
||||
-(JSValue*) GetAnnotationsAP : (JSValue*)nRasterW : (JSValue*)nRasterH : (JSValue*)nBackgroundColor : (JSValue*)nPageIndex : (JSValue*)nAnnot : (JSValue*)nView;
|
||||
-(JSValue*) GetFontBinary : (JSValue*)Id;
|
||||
-(JSValue*) GetGlyphs : (JSValue*)nPageIndex;
|
||||
-(JSValue*) DestroyTextInfo;
|
||||
-(JSValue*) IsNeedCMap;
|
||||
@ -53,6 +54,7 @@ FUNCTION_WRAPPER_JS_7(GetInteractiveFormsAP, GetInteractiveFormsAP)
|
||||
FUNCTION_WRAPPER_JS_5(GetButtonIcons, GetButtonIcons)
|
||||
FUNCTION_WRAPPER_JS_1(GetAnnotationsInfo, GetAnnotationsInfo)
|
||||
FUNCTION_WRAPPER_JS_6(GetAnnotationsAP, GetAnnotationsAP)
|
||||
FUNCTION_WRAPPER_JS_1(GetFontBinary, GetFontBinary)
|
||||
FUNCTION_WRAPPER_JS_1(GetGlyphs, GetGlyphs)
|
||||
FUNCTION_WRAPPER_JS_0(DestroyTextInfo, DestroyTextInfo)
|
||||
FUNCTION_WRAPPER_JS_0(IsNeedCMap, IsNeedCMap)
|
||||
|
||||
@ -23,6 +23,7 @@ namespace NSDrawingFileEmbed
|
||||
FUNCTION_WRAPPER_V8_5(_GetButtonIcons, GetButtonIcons)
|
||||
FUNCTION_WRAPPER_V8_1(_GetAnnotationsInfo, GetAnnotationsInfo)
|
||||
FUNCTION_WRAPPER_V8_6(_GetAnnotationsAP, GetAnnotationsAP)
|
||||
FUNCTION_WRAPPER_V8_1(_GetFontBinary, GetFontBinary)
|
||||
FUNCTION_WRAPPER_V8_1(_GetGlyphs, GetGlyphs)
|
||||
FUNCTION_WRAPPER_V8_0(_DestroyTextInfo, DestroyTextInfo)
|
||||
FUNCTION_WRAPPER_V8_0(_IsNeedCMap, IsNeedCMap)
|
||||
@ -51,6 +52,7 @@ namespace NSDrawingFileEmbed
|
||||
NSV8Objects::Template_Set(result, "GetButtonIcons", _GetButtonIcons);
|
||||
NSV8Objects::Template_Set(result, "GetAnnotationsInfo", _GetAnnotationsInfo);
|
||||
NSV8Objects::Template_Set(result, "GetAnnotationsAP", _GetAnnotationsAP);
|
||||
NSV8Objects::Template_Set(result, "GetFontBinary", _GetFontBinary);
|
||||
NSV8Objects::Template_Set(result, "GetGlyphs", _GetGlyphs);
|
||||
NSV8Objects::Template_Set(result, "DestroyTextInfo", _DestroyTextInfo);
|
||||
NSV8Objects::Template_Set(result, "IsNeedCMap", _IsNeedCMap);
|
||||
|
||||
@ -10,18 +10,35 @@
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
//#define ENABLE_GR_LOGS
|
||||
#endif
|
||||
|
||||
namespace NSGraphics
|
||||
{
|
||||
void CGraphics::init(NSNativeControl::CNativeControl* oNative, double width_px, double height_px, double width_mm, double height_mm)
|
||||
void CGraphics::init(double width_px, double height_px, double width_mm, double height_mm)
|
||||
{
|
||||
m_sApplicationImagesDirectory = oNative->m_strImagesDirectory;
|
||||
m_sApplicationFontsDirectory = oNative->m_strFontsDirectory;
|
||||
#ifdef _DEBUG
|
||||
std::wcout << L"init "<< m_sApplicationImagesDirectory << L" " << m_sApplicationFontsDirectory << L" " << width_px << L" " << height_px << L" " << width_mm << L" " << height_mm << std::endl;
|
||||
if (!m_pAppImage)
|
||||
return;
|
||||
|
||||
if (NULL == m_pAppImage->GetFonts())
|
||||
{
|
||||
NSFonts::IApplicationFonts* pFonts = NSFonts::NSApplication::Create();
|
||||
std::wstring sFontsDir = m_pAppImage->GetFontsDirectory();
|
||||
pFonts->InitializeFromFolder(sFontsDir.empty() ? NSFile::GetProcessDirectory() : sFontsDir);
|
||||
m_pAppImage->SetFonts(pFonts);
|
||||
RELEASEINTERFACE(pFonts);
|
||||
}
|
||||
|
||||
NSFonts::IFontManager* pManager = m_pAppImage->GetFonts()->GenerateFontManager();
|
||||
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"init "<<
|
||||
m_pAppImage->GetImagesDirectory() << L" " <<
|
||||
m_pAppImage->GetFontsDirectory() << L" " <<
|
||||
width_px << L" " << height_px << L" " <<
|
||||
width_mm << L" " << height_mm << std::endl;
|
||||
#endif
|
||||
m_pApplicationFonts = NSFonts::NSApplication::Create();
|
||||
m_pApplicationFonts->InitializeFromFolder(m_sApplicationFontsDirectory.empty() ? NSFile::GetProcessDirectory() : m_sApplicationFontsDirectory);
|
||||
NSFonts::IFontManager* pManager = m_pApplicationFonts->GenerateFontManager();
|
||||
|
||||
m_pRenderer = NSGraphics::Create();
|
||||
m_pRenderer->SetFontManager(pManager);
|
||||
@ -42,7 +59,19 @@ namespace NSGraphics
|
||||
if (nRasterH < 1) nRasterH = 0;
|
||||
}
|
||||
|
||||
BYTE* pData = new BYTE[4 * nRasterW * nRasterH];
|
||||
int nExistW = 0;
|
||||
int nExistH = 0;
|
||||
BYTE* pData = m_pAppImage->GetBits(nExistW, nExistH);
|
||||
if (pData != NULL)
|
||||
{
|
||||
nRasterW = nExistW;
|
||||
nRasterH = nExistH;
|
||||
}
|
||||
else
|
||||
{
|
||||
pData = m_pAppImage->AllocBits(nRasterW, nRasterH);
|
||||
}
|
||||
|
||||
unsigned int back = 0xffffff;
|
||||
unsigned int* pData32 = (unsigned int*)pData;
|
||||
unsigned int* pData32End = pData32 + nRasterW * nRasterH;
|
||||
@ -55,21 +84,21 @@ namespace NSGraphics
|
||||
m_oFrame.put_Stride(4 * nRasterW);
|
||||
|
||||
m_pRenderer->CreateFromBgraFrame(&m_oFrame);
|
||||
m_pRenderer->SetSwapRGB(false);
|
||||
m_pRenderer->SetSwapRGB(m_pAppImage->GetRgba());
|
||||
|
||||
m_pRenderer->put_Width(width_mm);
|
||||
m_pRenderer->put_Height(height_mm);
|
||||
}
|
||||
void CGraphics::put_GlobalAlpha(bool enable, double alpha)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_GlobalAlpha " << enable << " " << alpha << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_GlobalAlphaEnabled(enable, alpha);
|
||||
}
|
||||
void CGraphics::End_GlobalAlpha()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "End_GlobalAlpha " << std::endl;
|
||||
#endif
|
||||
bool bIsInteger = m_pRenderer->get_IntegerGrid();
|
||||
@ -86,7 +115,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::p_color(int r, int g, int b, int a)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "p_color " << r << " " << g << " " << b << " " << a << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_PenColor(r | (g << 8) | (b << 16));
|
||||
@ -94,14 +123,14 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::p_width(double w)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "p_width " << w << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_PenSize(w / 1000.0);
|
||||
}
|
||||
void CGraphics::p_dash(size_t length, double* dash)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "p_dash " << length << std::endl;
|
||||
#endif
|
||||
if(length > 0)
|
||||
@ -119,7 +148,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::b_color1(int r, int g, int b, int a)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "b_color1 " << r << " " << g << " " << b << " " << a << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_BrushType(c_BrushTypeSolid);
|
||||
@ -128,7 +157,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::b_color2(int r, int g, int b, int a)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "b_color2 " << r << " " << g << " " << b << " " << a << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_BrushColor2(r | (g << 8) | (b << 16));
|
||||
@ -136,42 +165,42 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::transform(double sx, double shy, double shx, double sy, double tx, double ty)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "transform " << sx << " " << shy << " " << shx << " " << sy << " " << tx << " " << ty << std::endl;
|
||||
#endif
|
||||
m_pRenderer->SetTransform(sx, shy, shx, sy, tx, ty);
|
||||
}
|
||||
void CGraphics::CalculateFullTransform()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "CalculateFullTransform " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->CalculateFullTransform();
|
||||
}
|
||||
void CGraphics::_s()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_s " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
}
|
||||
void CGraphics::_e()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_e " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
}
|
||||
void CGraphics::_z()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_z " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandClose();
|
||||
}
|
||||
void CGraphics::_m(double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_m " << x << " " << y << std::endl;
|
||||
#endif
|
||||
if (!m_pRenderer->get_IntegerGrid())
|
||||
@ -184,7 +213,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::_l(double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_l " << x << " " << y << std::endl;
|
||||
#endif
|
||||
if (!m_pRenderer->get_IntegerGrid())
|
||||
@ -197,7 +226,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::_c (double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_c " << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << std::endl;
|
||||
#endif
|
||||
if (!m_pRenderer->get_IntegerGrid())
|
||||
@ -212,7 +241,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::_c2(double x1, double y1, double x2, double y2)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_c2 " << x1 << " " << y1 << " " << x2 << " " << y2 << std::endl;
|
||||
#endif
|
||||
if (!m_pRenderer->get_IntegerGrid())
|
||||
@ -226,28 +255,28 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::ds()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "ds " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->Stroke();
|
||||
}
|
||||
void CGraphics::df()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "df " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->Fill();
|
||||
}
|
||||
void CGraphics::save()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "save " << std::endl;
|
||||
#endif
|
||||
m_oFrame.SaveFile(m_sApplicationImagesDirectory + L"/img.png", _CXIMAGE_FORMAT_PNG);
|
||||
m_oFrame.SaveFile(m_pAppImage->GetImagesDirectory() + L"/img.png", _CXIMAGE_FORMAT_PNG);
|
||||
}
|
||||
void CGraphics::restore()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "restore " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->BeginCommand(c_nResetClipType);
|
||||
@ -255,7 +284,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::clip()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "clip " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->BeginCommand(c_nClipType);
|
||||
@ -263,43 +292,46 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::reset()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "reset " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->ResetTransform();
|
||||
}
|
||||
void CGraphics::FreeFont()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "FreeFont " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->CloseFont();
|
||||
}
|
||||
void CGraphics::ClearLastFont()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "ClearLastFont " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->ClearInstallFont();
|
||||
}
|
||||
void CGraphics::drawImage(const std::wstring& img, double x, double y, double w, double h, BYTE alpha)
|
||||
{
|
||||
std::wstring strImage = (0 == img.find(L"theme") ? m_sApplicationThemesDirectory : m_sApplicationImagesDirectory) + L'/' + img;
|
||||
#ifdef _DEBUG
|
||||
std::wstring strImage = img;
|
||||
if (!NSFile::CFileBinary::Exists(img))
|
||||
strImage = (0 == img.find(L"theme") ? m_pAppImage->GetThemesDirectory() : m_pAppImage->GetImagesDirectory()) + L'/' + img;
|
||||
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"drawImage " << strImage << L" " << x << " " << y << L" " << w << L" " << h << L" " << alpha << std::endl;
|
||||
#endif
|
||||
m_pRenderer->DrawImageFromFile(strImage, x, y, w, h, alpha);
|
||||
}
|
||||
std::wstring CGraphics::GetFont()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "GetFont " << std::endl;
|
||||
#endif
|
||||
return m_pRenderer->GetFontManager()->GetName();
|
||||
}
|
||||
void CGraphics::SetFont(const std::wstring& name, int face, double size, int style)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"SetFont " << name << L" " << face << L" " << size << L" " << style << std::endl;
|
||||
#endif
|
||||
double DpiX, DpiY;
|
||||
@ -314,21 +346,21 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::FillText(double x, double y, int text)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"FillText " << (wchar_t)text << L" " << x << L" " << y << std::endl;
|
||||
#endif
|
||||
m_pRenderer->CommandDrawTextCHAR(text, x, y, 0, 0);
|
||||
}
|
||||
void CGraphics::t(double x, double y, const std::wstring& text)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"t " << text << L" " << x << L" " << y << std::endl;
|
||||
#endif
|
||||
m_pRenderer->CommandDrawText(text, x, y, 0, 0);
|
||||
}
|
||||
void CGraphics::tg(int text, double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"tg " << text << L" " << x << L" " << y << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_FontStringGID(TRUE);
|
||||
@ -337,21 +369,21 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::SetIntegerGrid(bool param)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "SetIntegerGrid " << param << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_IntegerGrid(param);
|
||||
}
|
||||
bool CGraphics::GetIntegerGrid()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "GetIntegerGrid " << std::endl;
|
||||
#endif
|
||||
return m_pRenderer->get_IntegerGrid();
|
||||
}
|
||||
void CGraphics::DrawStringASCII (const std::wstring& text, double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"DrawStringASCII " << text << L" " << x << L" " << y << std::endl;
|
||||
#endif
|
||||
double DpiY;
|
||||
@ -373,7 +405,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawHeaderEdit(double yPos)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawHeaderEdit " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
@ -416,7 +448,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawFooterEdit(double yPos)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawFooterEdit " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
@ -459,7 +491,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawLockParagraph (double x, double y1, double y2)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawLockParagraph " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
@ -531,7 +563,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawLockObjectRect(double x, double y, double w, double h)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawLockObjectRect " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
@ -557,7 +589,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawEmptyTableLine(double x1, double y1, double x2, double y2)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawEmptyTableLine " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
@ -642,7 +674,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawSpellingLine (double y0, double x0, double x1, double w)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawSpellingLine " << std::endl;
|
||||
#endif
|
||||
Aggplus::CMatrix* pMatrix = m_pRenderer->GetTransformMatrix();
|
||||
@ -988,7 +1020,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::SaveGrState()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "SaveGrState " << std::endl;
|
||||
#endif
|
||||
CGrStateState* pState = new CGrStateState();
|
||||
@ -1004,7 +1036,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::RestoreGrState()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "RestoreGrState " << std::endl;
|
||||
#endif
|
||||
if (m_oGrState.States.empty())
|
||||
@ -1068,14 +1100,14 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::StartClipPath()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "StartClipPath " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->BeginCommand(c_nClipType);
|
||||
}
|
||||
void CGraphics::EndClipPath()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "EndClipPath " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->EndCommand(c_nClipType);
|
||||
@ -1133,7 +1165,7 @@ namespace NSGraphics
|
||||
}
|
||||
std::string CGraphics::toDataURL(std::wstring type)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << "toDataURL " << type << std::endl;
|
||||
#endif
|
||||
std::wstring sFormat = (type.length() > 6) ? type.substr(6) : type;
|
||||
@ -1178,11 +1210,11 @@ namespace NSGraphics
|
||||
{
|
||||
if (src.find(L"data:") == 0)
|
||||
{
|
||||
std::wstring strImage = m_sApplicationImagesDirectory + L"/texture.png";
|
||||
std::wstring strImage = m_pAppImage->GetImagesDirectory() + L"/texture.png";
|
||||
bool bIsOnlyOfficeHatch = false;
|
||||
if(src.find(L"onlyoffice_hatch") != std::wstring::npos)
|
||||
bIsOnlyOfficeHatch = true;
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"put_brushTexture " << src << L" " << type << std::endl;
|
||||
#endif
|
||||
src.erase(0, src.find(L',') + 1);
|
||||
@ -1221,7 +1253,10 @@ namespace NSGraphics
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring strImage = (0 == src.find(L"theme") ? m_sApplicationThemesDirectory : m_sApplicationImagesDirectory) + L'/' + src;
|
||||
std::wstring strImage = src;
|
||||
if (!NSFile::CFileBinary::Exists(src))
|
||||
strImage = (0 == src.find(L"theme") ? m_pAppImage->GetThemesDirectory() : m_pAppImage->GetImagesDirectory()) + L'/' + src;
|
||||
|
||||
std::wstring sName = strImage.substr(0, strImage.rfind(L'.') + 1);
|
||||
std::wstring sExt = src.substr(src.rfind(L'.') + 1);
|
||||
if (sExt == L"svg")
|
||||
@ -1231,7 +1266,7 @@ namespace NSGraphics
|
||||
else if (NSFile::CFileBinary::Exists(sName + L"emf") && src.find(L"display") == 0)
|
||||
strImage = sName + L"emf";
|
||||
|
||||
MetaFile::IMetaFile* pMetafile = MetaFile::Create(m_pApplicationFonts);
|
||||
MetaFile::IMetaFile* pMetafile = MetaFile::Create(m_pAppImage->GetFonts());
|
||||
pMetafile->LoadFromFile(strImage.c_str());
|
||||
|
||||
double x = 0, y = 0, w = 0, h = 0;
|
||||
@ -1244,7 +1279,7 @@ namespace NSGraphics
|
||||
}
|
||||
else
|
||||
sName += sExt;
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"put_brushTexture " << sName << L" " << type << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_BrushType(c_BrushTypeTexture);
|
||||
@ -1254,21 +1289,21 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::put_brushTextureMode(int mode)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_brushTextureMode " << mode << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_BrushTextureMode(mode);
|
||||
}
|
||||
void CGraphics::put_BrushTextureAlpha(int a)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_BrushTextureAlpha " << a << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_BrushTextureAlpha(a == 0 ? 255 : a);
|
||||
}
|
||||
void CGraphics::put_BrushGradient(LONG* pColors, double* pPositions, size_t nCount, double x0, double y0, double x1, double y1, double r0, double r1)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_BrushGradient " << nCount << " " << x0 << " " << y0 << " " << x1 << " " << y1 << " " << r0 << " " << r1 << std::endl;
|
||||
for (size_t i = 0; i < nCount; i++)
|
||||
std::cout << pPositions[i] << " " << pColors[i] << " ";
|
||||
@ -1293,7 +1328,7 @@ namespace NSGraphics
|
||||
}
|
||||
double CGraphics::TransformPointX(double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "TransformPointX " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->GetFullTransform()->TransformPoint(x, y);
|
||||
@ -1301,7 +1336,7 @@ namespace NSGraphics
|
||||
}
|
||||
double CGraphics::TransformPointY(double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "TransformPointY " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->GetFullTransform()->TransformPoint(x, y);
|
||||
@ -1309,14 +1344,14 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::put_LineJoin(int nJoin)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_LineJoin " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_PenLineJoin(nJoin);
|
||||
}
|
||||
int CGraphics::GetLineJoin()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "GetLineJoin " << std::endl;
|
||||
#endif
|
||||
BYTE nRes;
|
||||
@ -1325,7 +1360,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::put_TextureBounds(double x, double y, double w, double h)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_TextureBounds " << x << " " << y << " " << w << " " << h << std::endl;
|
||||
#endif
|
||||
if(m_pRenderer->get_IntegerGrid())
|
||||
@ -1341,7 +1376,7 @@ namespace NSGraphics
|
||||
}
|
||||
double CGraphics::GetlineWidth()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "GetlineWidth " << std::endl;
|
||||
#endif
|
||||
double nRes;
|
||||
@ -1350,7 +1385,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawPath(int path)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawPath " << path << std::endl;
|
||||
#endif
|
||||
if(path == 257)
|
||||
@ -1363,7 +1398,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::CoordTransformOffset(double tx, double ty)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "CoordTransformOffset " << tx << " " << ty << std::endl;
|
||||
#endif
|
||||
m_pRenderer->SetCoordTransformOffset(tx, ty);
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "../common/File.h"
|
||||
#include "nativecontrol.h"
|
||||
#include "../graphics/pro/Graphics.h"
|
||||
#include "embed/GraphicsEmbed.h"
|
||||
|
||||
namespace NSGraphics
|
||||
{
|
||||
@ -114,28 +115,32 @@ namespace NSGraphics
|
||||
class CGraphics
|
||||
{
|
||||
public:
|
||||
std::wstring m_sApplicationFontsDirectory;
|
||||
std::wstring m_sApplicationImagesDirectory;
|
||||
std::wstring m_sApplicationThemesDirectory;
|
||||
CGraphicsAppImage* m_pAppImage;
|
||||
CBgraFrame m_oFrame;
|
||||
|
||||
private:
|
||||
NSFonts ::IApplicationFonts* m_pApplicationFonts;
|
||||
NSGraphics::IGraphicsRenderer* m_pRenderer;
|
||||
CBgraFrame m_oFrame;
|
||||
CGrState m_oGrState;
|
||||
|
||||
public:
|
||||
CGraphics() {}
|
||||
CGraphics()
|
||||
{
|
||||
m_pAppImage = NULL;
|
||||
}
|
||||
~CGraphics()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void init(NSNativeControl::CNativeControl* oNative, double width_px, double height_px, double width_mm, double height_mm);
|
||||
void init(double width_px, double height_px, double width_mm, double height_mm);
|
||||
void Destroy()
|
||||
{
|
||||
int w, h;
|
||||
if (m_pAppImage && m_pAppImage->GetBits(w, h))
|
||||
m_oFrame.put_Data(NULL);
|
||||
|
||||
RELEASEINTERFACE(m_pRenderer);
|
||||
RELEASEINTERFACE(m_pApplicationFonts);
|
||||
RELEASEOBJECT(m_pAppImage);
|
||||
}
|
||||
void EndDraw() {}
|
||||
void put_GlobalAlpha(bool enable, double globalAlpha);
|
||||
|
||||
@ -54,9 +54,9 @@ v8::Local<v8::String> CreateV8String(v8::Isolate* i, const std::string& str);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
||||
#ifdef _DEBUG
|
||||
//#ifdef _DEBUG
|
||||
#define ANDROID_LOGS
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
#ifdef ANDROID_LOGS
|
||||
#include <android/log.h>
|
||||
@ -488,7 +488,11 @@ namespace NSJSBase
|
||||
|
||||
virtual CJSEmbedObject* getNative()
|
||||
{
|
||||
if (0 == value->InternalFieldCount())
|
||||
return NULL;
|
||||
v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(value->GetInternalField(0));
|
||||
if (field.IsEmpty())
|
||||
return NULL;
|
||||
return (CJSEmbedObject*)field->Value();
|
||||
}
|
||||
|
||||
@ -991,67 +995,76 @@ inline void js_return(const v8::PropertyCallbackInfo<v8::Value>& info, JSSmart<N
|
||||
#define PROPERTY_GET(NAME, NAME_EMBED) \
|
||||
void NAME(v8::Local<v8::String> _name, const v8::PropertyCallbackInfo<v8::Value>& info) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(info.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(info.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(); \
|
||||
js_return(info, ret); \
|
||||
}
|
||||
|
||||
#define FUNCTION_WRAPPER_V8_0(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(); \
|
||||
js_return(args, ret); \
|
||||
#define FUNCTION_WRAPPER_V8_0(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(); \
|
||||
js_return(args, ret); \
|
||||
}
|
||||
|
||||
#define FUNCTION_WRAPPER_V8(NAME, NAME_EMBED) FUNCTION_WRAPPER_V8_0(NAME, NAME_EMBED)
|
||||
|
||||
#define FUNCTION_WRAPPER_V8_1(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0])); \
|
||||
js_return(args, ret); \
|
||||
#define FUNCTION_WRAPPER_V8_1(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0])); \
|
||||
js_return(args, ret); \
|
||||
}
|
||||
#define FUNCTION_WRAPPER_V8_2(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1])); \
|
||||
js_return(args, ret); \
|
||||
#define FUNCTION_WRAPPER_V8_2(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1])); \
|
||||
js_return(args, ret); \
|
||||
}
|
||||
#define FUNCTION_WRAPPER_V8_3(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2])); \
|
||||
js_return(args, ret); \
|
||||
}
|
||||
#define FUNCTION_WRAPPER_V8_4(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3])); \
|
||||
js_return(args, ret); \
|
||||
}
|
||||
#define FUNCTION_WRAPPER_V8_5(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4])); \
|
||||
js_return(args, ret); \
|
||||
}
|
||||
#define FUNCTION_WRAPPER_V8_6(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), js_value(args[5])); \
|
||||
js_return(args, ret); \
|
||||
}
|
||||
#define FUNCTION_WRAPPER_V8_7(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), \
|
||||
js_value(args[5]), js_value(args[6])); \
|
||||
js_return(args, ret); \
|
||||
@ -1059,7 +1072,8 @@ inline void js_return(const v8::PropertyCallbackInfo<v8::Value>& info, JSSmart<N
|
||||
#define FUNCTION_WRAPPER_V8_8(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), \
|
||||
js_value(args[5]), js_value(args[6]), js_value(args[7])); \
|
||||
js_return(args, ret); \
|
||||
@ -1067,7 +1081,8 @@ inline void js_return(const v8::PropertyCallbackInfo<v8::Value>& info, JSSmart<N
|
||||
#define FUNCTION_WRAPPER_V8_9(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), \
|
||||
js_value(args[5]), js_value(args[6]), js_value(args[7]), js_value(args[8])); \
|
||||
js_return(args, ret); \
|
||||
@ -1075,7 +1090,8 @@ inline void js_return(const v8::PropertyCallbackInfo<v8::Value>& info, JSSmart<N
|
||||
#define FUNCTION_WRAPPER_V8_10(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), js_value(args[5]), \
|
||||
js_value(args[6]), js_value(args[7]), js_value(args[8]), js_value(args[9])); \
|
||||
js_return(args, ret); \
|
||||
@ -1083,7 +1099,8 @@ inline void js_return(const v8::PropertyCallbackInfo<v8::Value>& info, JSSmart<N
|
||||
#define FUNCTION_WRAPPER_V8_13(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), js_value(args[5]), \
|
||||
js_value(args[6]), js_value(args[7]), js_value(args[8]), js_value(args[9]), js_value(args[10]), js_value(args[11]), \
|
||||
js_value(args[12])); \
|
||||
|
||||
@ -99,6 +99,11 @@ namespace NSJSON
|
||||
return m_internal->m_type == CTypedValue::vtObject;
|
||||
}
|
||||
|
||||
bool IValue::IsImage() const
|
||||
{
|
||||
return m_internal->m_type == CTypedValue::vtImage;
|
||||
}
|
||||
|
||||
bool IValue::ToBool() const
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtPrimitive)
|
||||
@ -350,6 +355,11 @@ namespace NSJSON
|
||||
strRes += "}";
|
||||
break;
|
||||
}
|
||||
case CTypedValue::vtImage:
|
||||
{
|
||||
// TODO: implement like typed array?
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return strRes;
|
||||
@ -497,6 +507,82 @@ namespace NSJSON
|
||||
return static_cast<CObject*>(m_internal->m_value.get())->getPropertyNames();
|
||||
}
|
||||
|
||||
const BYTE* IValue::GetImageBits() const
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
return static_cast<CImage*>(m_internal->m_value.get())->getBits();
|
||||
}
|
||||
|
||||
BYTE* IValue::GetImageBits()
|
||||
{
|
||||
return const_cast<BYTE*>(static_cast<const CValue&>(*this).GetImageBits());
|
||||
}
|
||||
|
||||
int IValue::GetImageWidth() const
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
return static_cast<CImage*>(m_internal->m_value.get())->getWidth();
|
||||
}
|
||||
|
||||
int IValue::GetImageHeight() const
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
return static_cast<CImage*>(m_internal->m_value.get())->getHeight();
|
||||
}
|
||||
|
||||
ImageFormat IValue::GetImageFormat() const
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return ImageFormat::ifInvalid;
|
||||
}
|
||||
return static_cast<CImage*>(m_internal->m_value.get())->getFormat();
|
||||
}
|
||||
|
||||
void IValue::ImageExternalize()
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
static_cast<CImage*>(m_internal->m_value.get())->externalize();
|
||||
}
|
||||
|
||||
void IValue::ImageAlloc(const int& width, const int& height, const ImageFormat& format)
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
static_cast<CImage*>(m_internal->m_value.get())->alloc(width, height, format);
|
||||
}
|
||||
|
||||
CValue::CValue() : IValue()
|
||||
{
|
||||
@ -590,6 +676,35 @@ namespace NSJSON
|
||||
NSJSBase::NSAllocator::Free(data, size);
|
||||
}
|
||||
|
||||
CValue CValue::CreateImage(BYTE* bits, int width, int height, ImageFormat format, bool isExternalize)
|
||||
{
|
||||
CValue ret;
|
||||
if (width <= 0 || height <= 0)
|
||||
return ret;
|
||||
|
||||
ret.m_internal->m_value = std::make_shared<CImage>(bits, width, height, format, isExternalize);
|
||||
ret.m_internal->m_type = CTypedValue::vtImage;
|
||||
return ret;
|
||||
}
|
||||
|
||||
CValue CValue::CreateEmptyImage(ImageFormat format)
|
||||
{
|
||||
CValue ret;
|
||||
ret.m_internal->m_value = std::make_shared<CImage>((BYTE*)NULL, 0, 0, format, false);
|
||||
ret.m_internal->m_type = CTypedValue::vtImage;
|
||||
return ret;
|
||||
}
|
||||
|
||||
BYTE* CValue::AllocImageBits(int width, int height)
|
||||
{
|
||||
return new BYTE[4 * width * height];
|
||||
}
|
||||
|
||||
void CValue::FreeImageBits(BYTE* bits)
|
||||
{
|
||||
delete[] bits;
|
||||
}
|
||||
|
||||
CValue CValue::CreateObject()
|
||||
{
|
||||
CValue ret;
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
#endif
|
||||
|
||||
// uncomment to enable exceptions throwing
|
||||
//#define JSON_DEBUG
|
||||
// #define JSON_DEBUG
|
||||
|
||||
#ifdef JSON_DEBUG
|
||||
#include <stdexcept>
|
||||
@ -29,6 +29,14 @@
|
||||
namespace NSJSON
|
||||
{
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
enum class ImageFormat
|
||||
{
|
||||
ifRGBA,
|
||||
ifBGRA,
|
||||
ifARGB,
|
||||
ifInvalid
|
||||
};
|
||||
|
||||
class CValue;
|
||||
class CValueRef;
|
||||
@ -88,6 +96,10 @@ namespace NSJSON
|
||||
* Returns true if the value is an object.
|
||||
*/
|
||||
bool IsObject() const;
|
||||
/**
|
||||
* Returns true if the value is an image.
|
||||
*/
|
||||
bool IsImage() const;
|
||||
|
||||
// FUNCTIONS FOR WORKING WITH PRIMITIVE VALUES
|
||||
/**
|
||||
@ -193,6 +205,39 @@ namespace NSJSON
|
||||
*/
|
||||
std::vector<std::string> GetPropertyNames() const;
|
||||
|
||||
// FUNCTIONS FOR WORKING WITH IMAGES
|
||||
/**
|
||||
* Gets bits of image.
|
||||
* @return the pointer to memory, allocated for the image. If current value is not an image, returns nullptr.
|
||||
*/
|
||||
const BYTE* GetImageBits() const;
|
||||
BYTE* GetImageBits();
|
||||
/**
|
||||
* Gets width of the image.
|
||||
* @returns Returns the width of the image. If current value is not an image, returns 0.
|
||||
*/
|
||||
int GetImageWidth() const;
|
||||
/**
|
||||
* Gets height of the image.
|
||||
* @returns Returns the height of the image. If current value is not an image, returns 0.
|
||||
*/
|
||||
int GetImageHeight() const;
|
||||
/**
|
||||
* Gets format of the image.
|
||||
* @returns Returns the image format. If current value is not an image, returns ImageFormat::ifInvalid.
|
||||
*/
|
||||
ImageFormat GetImageFormat() const;
|
||||
|
||||
/**
|
||||
* Make image bits external.
|
||||
*/
|
||||
void ImageExternalize();
|
||||
|
||||
/**
|
||||
* Alloc image bits as internal.
|
||||
*/
|
||||
void ImageAlloc(const int& width, const int& height, const ImageFormat& format);
|
||||
|
||||
protected:
|
||||
std::shared_ptr<CTypedValue> m_internal;
|
||||
};
|
||||
@ -251,6 +296,30 @@ namespace NSJSON
|
||||
*/
|
||||
static void FreeTypedArray(BYTE* data, size_t size);
|
||||
|
||||
// IMAGE
|
||||
/**
|
||||
* Creates and returns new image object.
|
||||
* @param bits The pointer to image data. The pointer should be acquired with AllocImageBits().
|
||||
* @param width The width of the image.
|
||||
* @param height The height of the image.
|
||||
* @param format The format of the image.
|
||||
* @param isExternalize If true the memory will not be reclaimed when the created image is destroyed.
|
||||
* If this parameter is false then the memory will be released using FreeImageBits() during the image object destruction.
|
||||
*/
|
||||
static CValue CreateImage(BYTE* bits, int width, int height, ImageFormat format = ImageFormat::ifBGRA, bool isExternalize = true);
|
||||
static CValue CreateEmptyImage(ImageFormat format = ImageFormat::ifBGRA);
|
||||
/**
|
||||
* Allocates the memory for an image.
|
||||
* @param width The width of the image.
|
||||
* @param height The height of the image.
|
||||
*/
|
||||
static BYTE* AllocImageBits(int width, int height);
|
||||
/**
|
||||
* Frees the memory for a image bits.
|
||||
* @param data The allocated memory to be released.
|
||||
*/
|
||||
static void FreeImageBits(BYTE* bits);
|
||||
|
||||
// OBJECT CONSTRUCTOR
|
||||
/**
|
||||
* Creates and returns empty object.
|
||||
|
||||
@ -17,7 +17,8 @@ namespace NSJSON
|
||||
vtPrimitive,
|
||||
vtArray,
|
||||
vtTypedArray,
|
||||
vtObject
|
||||
vtObject,
|
||||
vtImage
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
@ -211,4 +211,56 @@ namespace NSJSON
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
CImage::CImage(BYTE* bits, const int& width, const int& height, const ImageFormat& format, const bool& isExternalize) :
|
||||
m_bits(bits), m_width(width), m_height(height), m_format(format), m_isExternalize(isExternalize)
|
||||
{
|
||||
}
|
||||
|
||||
CImage::~CImage()
|
||||
{
|
||||
if (!m_isExternalize)
|
||||
{
|
||||
CValue::FreeImageBits(m_bits);
|
||||
}
|
||||
}
|
||||
|
||||
void CImage::alloc(const int& width, const int& height, const ImageFormat& format)
|
||||
{
|
||||
if (!m_isExternalize && m_bits)
|
||||
{
|
||||
CValue::FreeImageBits(m_bits);
|
||||
}
|
||||
|
||||
m_bits = CValue::AllocImageBits(width, height);
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
m_format = format;
|
||||
m_isExternalize = false;
|
||||
}
|
||||
|
||||
BYTE* CImage::getBits()
|
||||
{
|
||||
return m_bits;
|
||||
}
|
||||
|
||||
int CImage::getWidth()
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
|
||||
int CImage::getHeight()
|
||||
{
|
||||
return m_height;
|
||||
}
|
||||
|
||||
ImageFormat CImage::getFormat()
|
||||
{
|
||||
return m_format;
|
||||
}
|
||||
|
||||
void CImage::externalize()
|
||||
{
|
||||
m_isExternalize = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,6 +113,28 @@ namespace NSJSON
|
||||
private:
|
||||
storage_t m_values;
|
||||
};
|
||||
}
|
||||
|
||||
class CImage : public IBaseValue
|
||||
{
|
||||
public:
|
||||
CImage(BYTE* bits, const int& width, const int& height, const ImageFormat& format, const bool& isExternalize = true);
|
||||
~CImage();
|
||||
|
||||
public:
|
||||
BYTE* getBits();
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
ImageFormat getFormat();
|
||||
void externalize();
|
||||
void alloc(const int& width, const int& height, const ImageFormat& format);
|
||||
|
||||
private:
|
||||
BYTE* m_bits;
|
||||
int m_width;
|
||||
int m_height;
|
||||
ImageFormat m_format;
|
||||
bool m_isExternalize;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#endif // JSON_VALUES_H_
|
||||
|
||||
@ -3,9 +3,75 @@
|
||||
|
||||
#include "json.h"
|
||||
#include "../js_internal/js_base.h"
|
||||
#include "../embed/GraphicsEmbed.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
class CAppImageTo : public CGraphicsAppImage
|
||||
{
|
||||
private:
|
||||
NSJSON::CValueRef* m_image;
|
||||
|
||||
public:
|
||||
CAppImageTo(const NSJSON::CValue& image) : CGraphicsAppImage()
|
||||
{
|
||||
m_image = new NSJSON::CValueRef(image);
|
||||
}
|
||||
virtual ~CAppImageTo()
|
||||
{
|
||||
if (m_image)
|
||||
delete m_image;
|
||||
}
|
||||
|
||||
public:
|
||||
virtual unsigned char* GetBits(int& w, int& h)
|
||||
{
|
||||
unsigned char* bits = m_image->GetImageBits();
|
||||
if (NULL != bits)
|
||||
{
|
||||
w = m_image->GetImageWidth();
|
||||
h = m_image->GetImageHeight();
|
||||
}
|
||||
return bits;
|
||||
}
|
||||
virtual unsigned char* AllocBits(const int& w, const int& h)
|
||||
{
|
||||
m_image->ImageAlloc(w, h, GetRgba() ? NSJSON::ImageFormat::ifRGBA : NSJSON::ImageFormat::ifBGRA);
|
||||
return m_image->GetImageBits();
|
||||
}
|
||||
};
|
||||
|
||||
class CAppImageFrom : public CGraphicsAppImage
|
||||
{
|
||||
public:
|
||||
unsigned char* m_pData;
|
||||
int m_nW;
|
||||
int m_nH;
|
||||
public:
|
||||
CAppImageFrom() : CGraphicsAppImage()
|
||||
{
|
||||
m_pData = NULL;
|
||||
m_nW = 0;
|
||||
m_nH = 0;
|
||||
}
|
||||
virtual ~CAppImageFrom()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual unsigned char* GetBits(int& w, int& h)
|
||||
{
|
||||
return m_pData;
|
||||
}
|
||||
virtual unsigned char* AllocBits(const int& w, const int& h)
|
||||
{
|
||||
m_nW = w;
|
||||
m_nH = h;
|
||||
m_pData = NSJSON::CValue::AllocImageBits(w, h);
|
||||
return m_pData;
|
||||
}
|
||||
};
|
||||
|
||||
namespace NSJSON
|
||||
{
|
||||
static JSSmart<NSJSBase::CJSValue> toJS(const CValue& value)
|
||||
@ -50,6 +116,12 @@ namespace NSJSON
|
||||
JSSmart<NSJSBase::CJSTypedArray> jsTypedArr = NSJSBase::CJSContext::createUint8Array(const_cast<BYTE*>(value.GetData()), value.GetCount());
|
||||
ret = jsTypedArr->toValue();
|
||||
}
|
||||
else if (value.IsImage())
|
||||
{
|
||||
JSSmart<CJSObject> wrap = CJSContext::createEmbedObject("CGraphicsEmbed");
|
||||
((CGraphicsEmbed*)wrap->getNative())->SetAppImage(new CAppImageTo(value));
|
||||
ret = wrap->toValue();
|
||||
}
|
||||
// objects (there is no need for IsObject())
|
||||
else
|
||||
{
|
||||
@ -130,6 +202,25 @@ namespace NSJSON
|
||||
else if (jsValue->isObject())
|
||||
{
|
||||
JSSmart<NSJSBase::CJSObject> jsObj = jsValue->toObject();
|
||||
|
||||
CJSEmbedObject* pNative = jsObj->getNative();
|
||||
if (pNative != NULL)
|
||||
{
|
||||
CGraphicsEmbed* pGrEmbed = dynamic_cast<CGraphicsEmbed*>(pNative);
|
||||
if (pGrEmbed)
|
||||
{
|
||||
CAppImageFrom* pAppImage = dynamic_cast<CAppImageFrom*>(pGrEmbed->GetAppImage());
|
||||
if (pAppImage)
|
||||
{
|
||||
return NSJSON::CValue::CreateImage(pAppImage->m_pData,
|
||||
pAppImage->m_nW,
|
||||
pAppImage->m_nH,
|
||||
pAppImage->GetRgba() ? ImageFormat::ifRGBA : ImageFormat::ifBGRA,
|
||||
false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> properties = jsObj->getPropertyNames();
|
||||
ret = CValue::CreateObject();
|
||||
for (const std::string& name : properties)
|
||||
|
||||
@ -44,7 +44,10 @@ CImagesWorker::CImagesWorker(const std::wstring& sFolder)
|
||||
std::wstring CImagesWorker::GetImageLocal(const std::wstring& sUrl)
|
||||
{
|
||||
if (CServerInstance::getInstance().IsEnable())
|
||||
return L"error";
|
||||
{
|
||||
if (!CServerInstance::getInstance().CheckTmpDirectory(sUrl))
|
||||
return L"error";
|
||||
}
|
||||
std::wstring sExt = NSFile::GetFileExtention(sUrl);
|
||||
std::wstring sRet = L"image" + std::to_wstring(m_nIndex++) + L"." + sExt;
|
||||
m_mapImages.insert(std::make_pair(sUrl, sRet));
|
||||
|
||||
@ -32,11 +32,19 @@
|
||||
#ifndef SERVER_SETTINGS_H
|
||||
#define SERVER_SETTINGS_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "../common/File.h"
|
||||
#include "../common/StringBuilder.h"
|
||||
#include <iostream>
|
||||
|
||||
// class for server version (disable local files and etc)
|
||||
class CServerInstance
|
||||
{
|
||||
private:
|
||||
bool m_bIsEnabled;
|
||||
std::map<std::wstring, bool> m_arMapTmpFiles;
|
||||
|
||||
CServerInstance()
|
||||
{
|
||||
m_bIsEnabled = false;
|
||||
@ -58,6 +66,32 @@ public:
|
||||
{
|
||||
return m_bIsEnabled;
|
||||
}
|
||||
|
||||
void AddTmpFile(const std::wstring& sFolder)
|
||||
{
|
||||
std::wstring sDirectory = sFolder + L"/media";
|
||||
NSStringUtils::string_replace(sDirectory, L"\\", L"/");
|
||||
std::map<std::wstring, bool>::iterator findDir = m_arMapTmpFiles.find(sDirectory);
|
||||
if (findDir == m_arMapTmpFiles.end())
|
||||
m_arMapTmpFiles.insert(std::make_pair(sDirectory, true));
|
||||
}
|
||||
|
||||
void RemoveTmpFile(const std::wstring& sFolder)
|
||||
{
|
||||
std::wstring sDirectory = sFolder + L"/media";
|
||||
NSStringUtils::string_replace(sDirectory, L"\\", L"/");
|
||||
std::map<std::wstring, bool>::iterator findDir = m_arMapTmpFiles.find(sDirectory);
|
||||
if (findDir != m_arMapTmpFiles.end())
|
||||
m_arMapTmpFiles.erase(findDir);
|
||||
}
|
||||
|
||||
bool CheckTmpDirectory(const std::wstring& sFile)
|
||||
{
|
||||
std::wstring sDirectory = NSFile::GetDirectoryName(sFile);
|
||||
NSStringUtils::string_replace(sDirectory, L"\\", L"/");
|
||||
std::map<std::wstring, bool>::iterator findDir = m_arMapTmpFiles.find(sDirectory);
|
||||
return (findDir != m_arMapTmpFiles.end()) ? true : false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -467,6 +467,62 @@ TEST_F(CJSONTest, object)
|
||||
EXPECT_FALSE(compare(obj, jsObj->toValue(), false));
|
||||
}
|
||||
|
||||
TEST_F(CJSONTest, image_externalize)
|
||||
{
|
||||
int width = 1080;
|
||||
int height = 480;
|
||||
BYTE* bits = CValue::AllocImageBits(width, height);
|
||||
CValue img = CValue::CreateImage(bits, width, height, ifBGRA);
|
||||
|
||||
EXPECT_TRUE(img.IsImage());
|
||||
EXPECT_EQ(img.GetImageBits(), bits);
|
||||
EXPECT_EQ(img.GetImageWidth(), width);
|
||||
EXPECT_EQ(img.GetImageHeight(), height);
|
||||
EXPECT_EQ(img.GetImageFormat(), ifBGRA);
|
||||
|
||||
CValue::FreeImageBits(bits);
|
||||
|
||||
width = 50;
|
||||
height = 100;
|
||||
bits = CValue::AllocImageBits(width, height);
|
||||
img = CValue::CreateImage(bits, width, height, ifRGBA);
|
||||
|
||||
EXPECT_TRUE(img.IsImage());
|
||||
EXPECT_EQ(img.GetImageBits(), bits);
|
||||
EXPECT_EQ(img.GetImageWidth(), width);
|
||||
EXPECT_EQ(img.GetImageHeight(), height);
|
||||
EXPECT_EQ(img.GetImageFormat(), ifRGBA);
|
||||
|
||||
CValue::FreeImageBits(bits);
|
||||
}
|
||||
|
||||
TEST_F(CJSONTest, image_not_externalize)
|
||||
{
|
||||
int width = 320;
|
||||
int height = 480;
|
||||
BYTE* bits = CValue::AllocImageBits(width, height);
|
||||
CValue img = CValue::CreateImage(bits, width, height, ifARGB, false);
|
||||
|
||||
EXPECT_TRUE(img.IsImage());
|
||||
EXPECT_EQ(img.GetImageBits(), bits);
|
||||
EXPECT_EQ(img.GetImageWidth(), width);
|
||||
EXPECT_EQ(img.GetImageHeight(), height);
|
||||
EXPECT_EQ(img.GetImageFormat(), ifARGB);
|
||||
}
|
||||
|
||||
TEST_F(CJSONTest, image_wrong_size)
|
||||
{
|
||||
BYTE* bits = CValue::AllocImageBits(100, 100);
|
||||
CValue img = CValue::CreateImage(bits, 0, 100, ifARGB, false);
|
||||
EXPECT_TRUE(img.IsUndefined());
|
||||
img = CValue::CreateImage(bits, -1, 100, ifARGB, false);
|
||||
EXPECT_TRUE(img.IsUndefined());
|
||||
img = CValue::CreateImage(bits, 0, 0, ifARGB, false);
|
||||
EXPECT_TRUE(img.IsUndefined());
|
||||
img = CValue::CreateImage(bits, -100, -100, ifARGB, false);
|
||||
EXPECT_TRUE(img.IsUndefined());
|
||||
}
|
||||
|
||||
TEST_F(CJSONTest, references)
|
||||
{
|
||||
CValue val = 42;
|
||||
@ -526,12 +582,20 @@ TEST_F(CJSONTest, wrong_usage)
|
||||
EXPECT_THROW(val.GetPropertyNames(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetCount(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetData(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetImageBits(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetImageFormat(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetImageHeight(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetImageWidth(), std::bad_cast);
|
||||
#else
|
||||
EXPECT_TRUE(val["name"].IsUndefined());
|
||||
EXPECT_TRUE(val[0].IsUndefined());
|
||||
EXPECT_TRUE(val.GetPropertyNames().empty());
|
||||
EXPECT_EQ(val.GetCount(), 0);
|
||||
EXPECT_EQ(val.GetData(), nullptr);
|
||||
EXPECT_EQ(val.GetImageBits(), nullptr);
|
||||
EXPECT_EQ(val.GetImageFormat(), ifInvalid);
|
||||
EXPECT_EQ(val.GetImageHeight(), 0);
|
||||
EXPECT_EQ(val.GetImageWidth(), 0);
|
||||
#endif
|
||||
EXPECT_DOUBLE_EQ(val.ToDouble(), 42.0);
|
||||
#ifdef JSON_DEBUG
|
||||
@ -1601,7 +1665,11 @@ TEST_F(CJSONTest, FromJSON_arrays)
|
||||
CValue val = CValue::FromJSON(strJson);
|
||||
EXPECT_TRUE(val.IsArray());
|
||||
EXPECT_EQ(val.GetCount(), 0);
|
||||
#ifndef JSON_DEBUG
|
||||
EXPECT_TRUE(val[0].IsUndefined());
|
||||
#else
|
||||
EXPECT_THROW(val[0], std::out_of_range);
|
||||
#endif
|
||||
|
||||
strJson = "[1, 2, 3]";
|
||||
val = CValue::FromJSON(strJson);
|
||||
|
||||
@ -109,7 +109,7 @@ FT_Error FT_Load_Glyph_Wrapper( FT_Face face,
|
||||
FT_Err_Invalid_Reference = 0x86;
|
||||
*/
|
||||
|
||||
if ((bHintsSupport == TRUE) && ((nErr > 0x10 && nErr < 0x28) || nErr == 0x83 || nErr == 0x86))
|
||||
if ((bHintsSupport == TRUE) && ((nErr > 0x10 && nErr < 0x28) || (nErr >= 0x83 && nErr <= 0x8D)))
|
||||
{
|
||||
int nErr2 = FT_Load_Glyph(face, glyph_index, 40970);
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#include "AlphaMask.h"
|
||||
#include <string.h>
|
||||
#include "AlphaMask_p.h"
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
@ -33,7 +32,6 @@ namespace Aggplus
|
||||
{
|
||||
case EMaskDataType::ImageBuffer: return 4;
|
||||
case EMaskDataType::AlphaBuffer: return 1;
|
||||
case EMaskDataType::Alpha4Buffer: return 4;
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,130 +63,26 @@ namespace Aggplus
|
||||
return Ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CSoftMask::CSoftMask() : m_unWidth(0), m_unHeight(0), m_pImageData(NULL), m_pAlphaBufferData(NULL) {}
|
||||
CSoftMask::CSoftMask(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bExternalBuffer, bool bFlip) : m_pImageData(NULL), m_pAlphaBufferData(NULL)
|
||||
CSoftMask::CSoftMask(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bFlip, bool bRGB, bool bAlpha)
|
||||
{
|
||||
LoadFromBuffer(pBuffer, unWidth, unHeight, enDataType, bExternalBuffer, bFlip);
|
||||
if (bAlpha)
|
||||
m_pInternal = new CSoftMaskAlpha(pBuffer, unWidth, unHeight, false, bFlip);
|
||||
else
|
||||
{
|
||||
if (bRGB)
|
||||
m_pInternal = new CSoftMaskBGRAgray(pBuffer, unWidth, unHeight, false, bFlip);
|
||||
else
|
||||
m_pInternal = new CSoftMaskRGBAgray(pBuffer, unWidth, unHeight, false, bFlip);
|
||||
}
|
||||
}
|
||||
CSoftMask::~CSoftMask()
|
||||
{
|
||||
BYTE* pBuffer = m_oRenderingBuffer.buf();
|
||||
if (NULL != pBuffer)
|
||||
{
|
||||
if (!m_bExternalBuffer)
|
||||
RELEASEARRAYOBJECTS(pBuffer);
|
||||
|
||||
m_oRenderingBuffer.attach(NULL, 0, 0, 0);
|
||||
}
|
||||
|
||||
RELEASEOBJECT(m_pImageData);
|
||||
RELEASEOBJECT(m_pAlphaBufferData);
|
||||
RELEASEOBJECT(m_pInternal);
|
||||
}
|
||||
|
||||
EMaskDataType CSoftMask::GetDataType() const { return m_enDataType; }
|
||||
unsigned int CSoftMask::GetStep() const
|
||||
{
|
||||
switch(m_enDataType)
|
||||
{
|
||||
case EMaskDataType::ImageBuffer: return 4;
|
||||
case EMaskDataType::AlphaBuffer: return 1;
|
||||
case EMaskDataType::Alpha4Buffer: return 4;
|
||||
}
|
||||
}
|
||||
unsigned int CSoftMask::GetWidth() const { return m_unWidth; }
|
||||
unsigned int CSoftMask::GetHeight() const { return m_unHeight; }
|
||||
|
||||
void CSoftMask::SetType(EMaskDataType enDataType)
|
||||
{
|
||||
m_enDataType = enDataType;
|
||||
|
||||
RELEASEOBJECT(m_pImageData);
|
||||
RELEASEOBJECT(m_pAlphaBufferData);
|
||||
|
||||
switch (enDataType)
|
||||
{
|
||||
case EMaskDataType::ImageBuffer:
|
||||
{
|
||||
m_pImageData = new AMaskFromImage(m_oRenderingBuffer);
|
||||
m_pImageData->m_oRendererBase.attach(m_pImageData->m_oPixfmt);
|
||||
m_pImageData->m_oAlphaMask.attach(m_oRenderingBuffer);
|
||||
break;
|
||||
}
|
||||
case EMaskDataType::Alpha4Buffer:
|
||||
{
|
||||
m_pAlphaBufferData = new AMaskFromABuffer(m_oRenderingBuffer);
|
||||
m_pAlphaBufferData->m_oRendererBase.attach(m_pAlphaBufferData->m_oPixfmt);
|
||||
m_pAlphaBufferData->m_oAlphaMask.attach(m_oRenderingBuffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Status CSoftMask::Create(UINT unWidth, UINT unHeight, EMaskDataType enDataType)
|
||||
{
|
||||
if (0 == unWidth || 0 == unHeight)
|
||||
return InvalidParameter;
|
||||
|
||||
m_bExternalBuffer = false;
|
||||
|
||||
UINT unSize = unWidth * unHeight * GetStep();
|
||||
BYTE* pAlphaBufffer = new BYTE[unSize];
|
||||
if (!pAlphaBufffer)
|
||||
return OutOfMemory;
|
||||
|
||||
memset(pAlphaBufffer, 0x00, unSize);
|
||||
|
||||
Set(pAlphaBufffer, unWidth, unHeight, enDataType);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CSoftMask::LoadFromBuffer(BYTE *pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bExternalBuffer, bool bFlip)
|
||||
{
|
||||
if (NULL == pBuffer || 0 == unWidth || 0 == unHeight)
|
||||
return InvalidParameter;
|
||||
|
||||
m_bExternalBuffer = bExternalBuffer;
|
||||
|
||||
Set(pBuffer, unWidth, unHeight, enDataType, bFlip);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
RenBaseBGRA32& CSoftMask::GetRendererBaseImage()
|
||||
{
|
||||
return m_pImageData->m_oRendererBase;
|
||||
}
|
||||
|
||||
ScanlineBGRA32Gray& CSoftMask::GetScanlineImage()
|
||||
{
|
||||
return m_pImageData->m_oScanLine;
|
||||
}
|
||||
|
||||
ScanlineBGRA32A& CSoftMask::GetScanlineABuffer()
|
||||
{
|
||||
return m_pAlphaBufferData->m_oScanLine;
|
||||
}
|
||||
|
||||
BYTE* CSoftMask::GetBuffer()
|
||||
{
|
||||
return m_oRenderingBuffer.buf();
|
||||
}
|
||||
|
||||
agg::rendering_buffer& CSoftMask::GetRenderingBuffer()
|
||||
{
|
||||
return m_oRenderingBuffer;
|
||||
}
|
||||
|
||||
void CSoftMask::Set(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bFlip)
|
||||
{
|
||||
m_enDataType = enDataType;
|
||||
m_unWidth = unWidth;
|
||||
m_unHeight = unHeight;
|
||||
m_oRenderingBuffer.attach(pBuffer, unWidth, unHeight, (bFlip ? -1 : 1) * GetStep() * unWidth);
|
||||
|
||||
SetType(enDataType);
|
||||
}
|
||||
unsigned int CSoftMask::GetStep() const { return m_pInternal->GetStep(); }
|
||||
unsigned int CSoftMask::GetWidth() const { return m_pInternal->GetWidth(); }
|
||||
unsigned int CSoftMask::GetHeight() const { return m_pInternal->GetHeight(); }
|
||||
BYTE* CSoftMask::GetBuffer() { return m_pInternal->GetBuffer(); }
|
||||
ESoftMaskType CSoftMask::GetDataType() { return m_pInternal->GetDataType(); }
|
||||
}
|
||||
|
||||
@ -1,23 +1,16 @@
|
||||
#ifndef _BUILD_ALPHAMASK_H_
|
||||
#define _BUILD_ALPHAMASK_H_
|
||||
|
||||
#include <string>
|
||||
#include "aggplustypes.h"
|
||||
#include "../common/IGrObject.h"
|
||||
#include "./config.h"
|
||||
|
||||
#include "../agg-2.4/include/agg_renderer_base.h"
|
||||
#include "../agg-2.4/include/agg_pixfmt_rgba.h"
|
||||
#include "../agg-2.4/include/agg_scanline_u.h"
|
||||
#include "../agg-2.4/include/agg_alpha_mask_u8.h"
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
enum class EMaskDataType
|
||||
{
|
||||
ImageBuffer,
|
||||
AlphaBuffer,
|
||||
Alpha4Buffer
|
||||
AlphaBuffer
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CAlphaMask : public IGrObject
|
||||
@ -39,56 +32,30 @@ namespace Aggplus
|
||||
bool m_bExternalBuffer;
|
||||
};
|
||||
|
||||
template <class PixelFormat, class AlphaMask>
|
||||
struct TAlphaMaskData
|
||||
enum class ESoftMaskType
|
||||
{
|
||||
TAlphaMaskData(agg::rendering_buffer& oRenderingBuffer) : m_oPixfmt(oRenderingBuffer), m_oScanLine(m_oAlphaMask) {};
|
||||
|
||||
PixelFormat m_oPixfmt;
|
||||
agg::renderer_base<PixelFormat> m_oRendererBase;
|
||||
AlphaMask m_oAlphaMask;
|
||||
agg::scanline_u8_am<AlphaMask> m_oScanLine;
|
||||
RGBGrayBuffer,
|
||||
BGRGrayBuffer,
|
||||
Alpha4Buffer
|
||||
};
|
||||
|
||||
typedef agg::renderer_base<agg::pixfmt_bgra32> RenBaseBGRA32;
|
||||
typedef agg::scanline_u8_am<agg::alpha_mask_bgra32gray> ScanlineBGRA32Gray;
|
||||
typedef agg::scanline_u8_am<agg::alpha_mask_bgra32a> ScanlineBGRA32A;
|
||||
|
||||
class CSoftMask_private;
|
||||
class GRAPHICS_DECL CSoftMask : public IGrObject
|
||||
{
|
||||
public:
|
||||
CSoftMask();
|
||||
CSoftMask(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bExternalBuffer = true, bool bFlip = false);
|
||||
virtual ~CSoftMask();
|
||||
CSoftMask(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bFlip, bool bRGB, bool bAlpha);
|
||||
~CSoftMask();
|
||||
|
||||
EMaskDataType GetDataType() const;
|
||||
unsigned int GetStep() const;
|
||||
unsigned int GetWidth() const;
|
||||
unsigned int GetHeight() const;
|
||||
BYTE* GetBuffer();
|
||||
ESoftMaskType GetDataType();
|
||||
|
||||
void SetType(EMaskDataType enDataType);
|
||||
Status Create(UINT unWidth, UINT unHeight, EMaskDataType enDataType);
|
||||
Status LoadFromBuffer(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bExternalBuffer = true, bool bFlip = false);
|
||||
|
||||
agg::rendering_buffer& GetRenderingBuffer();
|
||||
RenBaseBGRA32& GetRendererBaseImage();
|
||||
ScanlineBGRA32Gray& GetScanlineImage();
|
||||
ScanlineBGRA32A& GetScanlineABuffer();
|
||||
BYTE* GetBuffer();
|
||||
private:
|
||||
void Set(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bFlip = false);
|
||||
CSoftMask_private* m_pInternal;
|
||||
|
||||
agg::rendering_buffer m_oRenderingBuffer;
|
||||
EMaskDataType m_enDataType;
|
||||
bool m_bExternalBuffer;
|
||||
unsigned int m_unWidth;
|
||||
unsigned int m_unHeight;
|
||||
|
||||
typedef TAlphaMaskData<agg::pixfmt_bgra32, agg::alpha_mask_bgra32gray> AMaskFromImage;
|
||||
typedef TAlphaMaskData<agg::pixfmt_bgra32, agg::alpha_mask_bgra32a> AMaskFromABuffer;
|
||||
|
||||
AMaskFromImage* m_pImageData;
|
||||
AMaskFromABuffer* m_pAlphaBufferData;
|
||||
friend class CGraphics;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
96
DesktopEditor/graphics/AlphaMask_p.h
Normal file
96
DesktopEditor/graphics/AlphaMask_p.h
Normal file
@ -0,0 +1,96 @@
|
||||
#ifndef _BUILD_ALPHAMASK_P_H_
|
||||
#define _BUILD_ALPHAMASK_P_H_
|
||||
|
||||
#include "AlphaMask.h"
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
|
||||
#include "../agg-2.4/include/agg_rendering_buffer.h"
|
||||
#include "../agg-2.4/include/agg_scanline_u.h"
|
||||
#include "../agg-2.4/include/agg_alpha_mask_u8.h"
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
class CSoftMask_private
|
||||
{
|
||||
public:
|
||||
virtual ~CSoftMask_private()
|
||||
{
|
||||
BYTE* pBuffer = m_oRenderingBuffer.buf();
|
||||
if (NULL != pBuffer)
|
||||
{
|
||||
if (!m_bExternalBuffer)
|
||||
RELEASEARRAYOBJECTS(pBuffer);
|
||||
|
||||
m_oRenderingBuffer.attach(NULL, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int GetStep() const { return 4; }
|
||||
unsigned int GetWidth() const { return m_unWidth; }
|
||||
unsigned int GetHeight() const { return m_unHeight; }
|
||||
BYTE* GetBuffer() { return m_oRenderingBuffer.buf(); }
|
||||
|
||||
virtual ESoftMaskType GetDataType() const = 0;
|
||||
virtual bool GetSwapRGB() const { return true; };
|
||||
|
||||
protected:
|
||||
CSoftMask_private(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bExternalBuffer, bool bFlip)
|
||||
{
|
||||
m_bExternalBuffer = bExternalBuffer;
|
||||
m_unWidth = unWidth;
|
||||
m_unHeight = unHeight;
|
||||
m_oRenderingBuffer.attach(pBuffer, unWidth, unHeight, (bFlip ? -1 : 1) * GetStep() * unWidth);
|
||||
}
|
||||
|
||||
agg::rendering_buffer m_oRenderingBuffer;
|
||||
bool m_bExternalBuffer;
|
||||
unsigned int m_unWidth;
|
||||
unsigned int m_unHeight;
|
||||
};
|
||||
|
||||
class CSoftMaskBGRAgray : public CSoftMask_private
|
||||
{
|
||||
public:
|
||||
CSoftMaskBGRAgray(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bExternalBuffer, bool bFlip)
|
||||
: CSoftMask_private(pBuffer, unWidth, unHeight, bExternalBuffer, bFlip), m_oAlphaMask(m_oRenderingBuffer), m_oScanLine(m_oAlphaMask) {}
|
||||
|
||||
agg::scanline_u8_am<agg::alpha_mask_bgra32gray>& GetScanline() { return m_oScanLine; }
|
||||
virtual ESoftMaskType GetDataType() const override { return ESoftMaskType::BGRGrayBuffer; }
|
||||
|
||||
private:
|
||||
agg::alpha_mask_bgra32gray m_oAlphaMask;
|
||||
agg::scanline_u8_am<agg::alpha_mask_bgra32gray> m_oScanLine;
|
||||
};
|
||||
|
||||
class CSoftMaskRGBAgray : public CSoftMask_private
|
||||
{
|
||||
public:
|
||||
CSoftMaskRGBAgray(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bExternalBuffer, bool bFlip)
|
||||
: CSoftMask_private(pBuffer, unWidth, unHeight, bExternalBuffer, bFlip), m_oAlphaMask(m_oRenderingBuffer), m_oScanLine(m_oAlphaMask) {}
|
||||
|
||||
agg::scanline_u8_am<agg::alpha_mask_rgba32gray>& GetScanline() { return m_oScanLine; }
|
||||
virtual bool GetSwapRGB() const override { return false; };
|
||||
virtual ESoftMaskType GetDataType() const override { return ESoftMaskType::RGBGrayBuffer; }
|
||||
|
||||
private:
|
||||
agg::alpha_mask_rgba32gray m_oAlphaMask;
|
||||
agg::scanline_u8_am<agg::alpha_mask_rgba32gray> m_oScanLine;
|
||||
};
|
||||
|
||||
class CSoftMaskAlpha : public CSoftMask_private
|
||||
{
|
||||
public:
|
||||
CSoftMaskAlpha(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bExternalBuffer, bool bFlip)
|
||||
: CSoftMask_private(pBuffer, unWidth, unHeight, bExternalBuffer, bFlip), m_oAlphaMask(m_oRenderingBuffer), m_oScanLine(m_oAlphaMask) {}
|
||||
|
||||
agg::scanline_u8_am<agg::alpha_mask_rgba32a>& GetScanline() { return m_oScanLine; }
|
||||
virtual ESoftMaskType GetDataType() const override { return ESoftMaskType::Alpha4Buffer; }
|
||||
|
||||
private:
|
||||
agg::alpha_mask_rgba32a m_oAlphaMask;
|
||||
agg::scanline_u8_am<agg::alpha_mask_rgba32a> m_oScanLine;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _BUILD_ALPHAMASK_P_H_
|
||||
@ -107,9 +107,14 @@ namespace NSThreads
|
||||
{
|
||||
if (i->ID == nThreadId)
|
||||
{
|
||||
CBaseThreadInfo last;
|
||||
last.ID = i->ID;
|
||||
last.Instance = i->Instance;
|
||||
|
||||
m_listThreads.erase(i);
|
||||
m_listThreads.insert(m_listThreads.begin(), *i);
|
||||
return i->Instance;
|
||||
m_listThreads.insert(m_listThreads.begin(), last);
|
||||
|
||||
return last.Instance;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
1946
DesktopEditor/graphics/BooleanOperations.cpp
Normal file
1946
DesktopEditor/graphics/BooleanOperations.cpp
Normal file
File diff suppressed because it is too large
Load Diff
181
DesktopEditor/graphics/BooleanOperations.h
Normal file
181
DesktopEditor/graphics/BooleanOperations.h
Normal file
@ -0,0 +1,181 @@
|
||||
#ifndef BOOLEANOPERATIONS_H
|
||||
#define BOOLEANOPERATIONS_H
|
||||
|
||||
#include "GraphicsPath.h"
|
||||
#include <memory>
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
struct Location;
|
||||
|
||||
struct Segment
|
||||
{
|
||||
PointD P{};
|
||||
PointD HI{};
|
||||
PointD HO{};
|
||||
|
||||
bool IsCurve = false;
|
||||
bool Visited = false;
|
||||
bool PolyClosed = false;
|
||||
|
||||
int Index = -1;
|
||||
int Id = 0;
|
||||
int Winding = 0;
|
||||
|
||||
std::shared_ptr<Location> Inters{nullptr};
|
||||
|
||||
Segment() noexcept;
|
||||
Segment(const std::vector<PointD>& points, const bool& isCurve,
|
||||
const int& index, const int& id, const bool& polyClosed) noexcept;
|
||||
Segment(const PointD& point, const bool& isCurve, const int& index,
|
||||
const int& id, const bool& polyClosed) noexcept;
|
||||
Segment(const PointD& p) noexcept;
|
||||
Segment(const PointD& p, const PointD& hi, const PointD& ho) noexcept;
|
||||
|
||||
void SetHandles(const PointD& hi, const PointD& ho) noexcept;
|
||||
void UpdateHandles(const PointD& hi, const PointD& ho) noexcept;
|
||||
|
||||
bool IsValid(const BooleanOpType& op) const noexcept;
|
||||
bool IsEmpty() const noexcept;
|
||||
bool operator==(const Segment& other) const noexcept;
|
||||
bool operator!=(const Segment& other) const noexcept;
|
||||
};
|
||||
|
||||
struct Curve
|
||||
{
|
||||
Segment Segment1{};
|
||||
Segment Segment2{};
|
||||
|
||||
Curve() noexcept;
|
||||
Curve(const Segment& segment1, const Segment& segment2) noexcept;
|
||||
Curve(const std::vector<double>& values) noexcept;
|
||||
Curve(const double& x0, const double& y0, const double& x1, const double& y1,
|
||||
const double& x2, const double& y2, const double& x3, const double& y3) noexcept;
|
||||
|
||||
std::vector<double> GetXValues() const noexcept;
|
||||
std::vector<double> GetYValues() const noexcept;
|
||||
std::vector<double> GetPeeks() const;
|
||||
double GetLength(double a = 0, double b = 1) const;
|
||||
double GetSquaredLineLength() const noexcept;
|
||||
double GetTimeOf(const PointD& point) const noexcept;
|
||||
double GetTimeAt(const double& offset) const noexcept;
|
||||
PointD Get(const double& t, const int& type) const noexcept;
|
||||
PointD GetPoint(const double& t) const noexcept;
|
||||
PointD GetTangent(const double& t) const noexcept;
|
||||
PointD GetTangent(const double& t, const double& offset,
|
||||
const bool& inside, const PointD& p) const noexcept;
|
||||
Curve GetPart(double from, double to) const noexcept;
|
||||
std::vector<Curve> GetMonoCurves(const bool& dir) const noexcept;
|
||||
std::vector<double> GetCurveLineIntersection(const double& px, const double& py,
|
||||
const double& vx, const double& vy) const noexcept;
|
||||
std::vector<std::pair<double, double>> GetOverlaps(const Curve& curve) const noexcept;
|
||||
|
||||
std::vector<Curve> Subdivide(const double& t) const noexcept;
|
||||
Curve DivideAtTime(const double& time) noexcept;
|
||||
|
||||
int SolveCubic(const int& coord, const double& value, std::vector<double>& roots,
|
||||
const double& mn, const double& mx) const noexcept;
|
||||
int SolveCubic(double a, double b, double c, double d, std::vector<double>& roots,
|
||||
const double& mn, const double& mx) const noexcept;
|
||||
|
||||
void Flip() noexcept;
|
||||
|
||||
bool IsStraight() const noexcept;
|
||||
bool HasHandle() const noexcept;
|
||||
bool operator==(const Curve& other) const noexcept;
|
||||
bool operator!=(const Curve& other) const noexcept;
|
||||
};
|
||||
|
||||
struct Location
|
||||
{
|
||||
Curve C{};
|
||||
Segment S{};
|
||||
double Time = -1.0;
|
||||
bool Overlap = false;
|
||||
bool Ends = false;
|
||||
|
||||
std::shared_ptr<Location> Inters{nullptr};
|
||||
std::shared_ptr<Location> Next{nullptr};
|
||||
std::shared_ptr<Location> Prev{nullptr};
|
||||
|
||||
Location() noexcept;
|
||||
Location(const Curve& curve, const double& time, const bool& overlap, const bool& ends) noexcept;
|
||||
|
||||
bool IsTouching() noexcept;
|
||||
};
|
||||
|
||||
class CBooleanOperations
|
||||
{
|
||||
public:
|
||||
CBooleanOperations(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op, long fillType = c_nWindingFillMode);
|
||||
~CBooleanOperations();
|
||||
CGraphicsPath&& GetResult();
|
||||
|
||||
// BooleanOp
|
||||
void TraceBoolean();
|
||||
void TraceOneInters();
|
||||
void TraceAllOverlap();
|
||||
void TracePaths();
|
||||
|
||||
// Path
|
||||
void PreparePath(const CGraphicsPath& path, int id, std::vector<Segment>& segments,
|
||||
std::vector<Curve>& curves, bool reverse = false);
|
||||
void InsertSegment(Segment& segment, const Segment& handles, bool updateHandles);
|
||||
Curve GetCurve(const Segment& segment) const noexcept;
|
||||
Curve GetPreviousCurve(const Curve& curve) const noexcept;
|
||||
Curve GetNextCurve(const Curve& curve) const noexcept;
|
||||
Segment GetNextSegment(const Segment& segment) const noexcept;
|
||||
void SetVisited(const Segment& segment);
|
||||
|
||||
// Bounds
|
||||
std::vector<std::vector<double>> GetBoundsForCurves(const std::vector<Curve>& curves) const noexcept;
|
||||
std::vector<std::vector<int>> FindBoundsCollisions();
|
||||
|
||||
// Intersection
|
||||
bool IsCrossing(std::shared_ptr<Location> loc) noexcept;
|
||||
bool FilterIntersections(std::shared_ptr<Location> loc) noexcept;
|
||||
bool IntersectsBounds() noexcept;
|
||||
void GetIntersection();
|
||||
void GetCurveIntersection(const Curve& curve1, const Curve& curve2);
|
||||
void LinkIntersection(std::shared_ptr<Location> form, std::shared_ptr<Location> to);
|
||||
void AddLineIntersection(const Curve& curve1, const Curve& curve2);
|
||||
void AddCurveLineIntersection(const Curve& curve1, const Curve& curve2, bool flip);
|
||||
int AddCurveIntersection(const Curve& curve1, const Curve& curve2, const Curve& startCurve1, const Curve& startCurve2, bool flip,
|
||||
int recursion = 0, int calls = 0, double tMin = 0.0, double tMax = 1.0, double uMin = 0.0, double uMax = 1.0);
|
||||
int CheckInters(const PointD& point, const Segment& segment, const Curve& curve, int& touchCount) const;
|
||||
void SetWinding();
|
||||
|
||||
// Location
|
||||
void DivideLocations();
|
||||
void AddLocation(Curve curve1, Curve curve2, double t1, double t2, bool overlap = false, bool filter = true, bool bothEnds = false);
|
||||
void InsertLocation(std::shared_ptr<Location> loc, bool overlap);
|
||||
bool AllOverlap() const noexcept;
|
||||
bool AllInters(const std::vector<Segment>& segments) const noexcept;
|
||||
void AddOffsets(std::vector<double>& offsets, const Curve& curve, bool end);
|
||||
|
||||
private:
|
||||
BooleanOpType Op = Intersection;
|
||||
|
||||
bool Close1 = true;
|
||||
bool Close2 = true;
|
||||
|
||||
// c_nStroke, c_nWindingFillMode, c_nEvenOddFillMode
|
||||
long FillType = c_nWindingFillMode;
|
||||
|
||||
CGraphicsPath Path1;
|
||||
CGraphicsPath Path2;
|
||||
CGraphicsPath Result;
|
||||
|
||||
std::vector<Segment> Segments1;
|
||||
std::vector<Segment> Segments2;
|
||||
|
||||
std::vector<Curve> OriginCurves1;
|
||||
std::vector<Curve> OriginCurves2;
|
||||
std::vector<Curve> Curves1;
|
||||
std::vector<Curve> Curves2;
|
||||
|
||||
std::vector<std::shared_ptr<Location>> Locations;
|
||||
};
|
||||
} // namespace Aggplus
|
||||
|
||||
#endif // BOOLEANOPERATIONS_H
|
||||
@ -1297,7 +1297,9 @@ namespace Aggplus
|
||||
RELEASEINTERFACE(pCurrentGraphicsLayer);
|
||||
RELEASEINTERFACE(m_pSoftMask);
|
||||
|
||||
m_pSoftMask = new CSoftMask(pBuffer, m_frame_buffer.ren_buf().width(), m_frame_buffer.ren_buf().height(), bAlpha ? EMaskDataType::Alpha4Buffer : EMaskDataType::ImageBuffer, false, m_frame_buffer.ren_buf().stride() < 0);
|
||||
unsigned int unWidth = m_frame_buffer.ren_buf().width(), unHeight = m_frame_buffer.ren_buf().height();
|
||||
bool bFlip = m_frame_buffer.ren_buf().stride() < 0;
|
||||
m_pSoftMask = new CSoftMask(pBuffer, unWidth, unHeight, bFlip, m_bSwapRGB, bAlpha);
|
||||
|
||||
pBuffer = m_arLayers.empty() ? m_pPixels : m_arLayers.top()->GetBuffer();
|
||||
if (!pBuffer)
|
||||
@ -1306,7 +1308,7 @@ namespace Aggplus
|
||||
return NULL;
|
||||
}
|
||||
|
||||
m_frame_buffer.ren_buf().attach(pBuffer, m_frame_buffer.ren_buf().width(), m_frame_buffer.ren_buf().height(), m_frame_buffer.ren_buf().stride());
|
||||
m_frame_buffer.ren_buf().attach(pBuffer, unWidth, unHeight, m_frame_buffer.ren_buf().stride());
|
||||
|
||||
return m_pSoftMask;
|
||||
}
|
||||
@ -1401,19 +1403,13 @@ namespace Aggplus
|
||||
}
|
||||
else if (m_pSoftMask)
|
||||
{
|
||||
switch(m_pSoftMask->GetDataType())
|
||||
{
|
||||
case EMaskDataType::ImageBuffer:
|
||||
{
|
||||
ESoftMaskType nType = m_pSoftMask->GetDataType();
|
||||
if (nType == ESoftMaskType::RGBGrayBuffer)
|
||||
Aggplus::BlendTo<agg::rgb_to_gray_mask_u8<0, 1, 2>>(pCurrentGraphicsLayer, m_frame_buffer.pixfmt(), m_pSoftMask->GetBuffer(), m_pSoftMask->GetStep());
|
||||
else if (nType == ESoftMaskType::BGRGrayBuffer)
|
||||
Aggplus::BlendTo<agg::rgb_to_gray_mask_u8<2, 1, 0>>(pCurrentGraphicsLayer, m_frame_buffer.pixfmt(), m_pSoftMask->GetBuffer(), m_pSoftMask->GetStep());
|
||||
break;
|
||||
}
|
||||
case EMaskDataType::Alpha4Buffer:
|
||||
{
|
||||
else if (nType == ESoftMaskType::Alpha4Buffer)
|
||||
Aggplus::BlendTo<agg::one_component_mask_u8>(pCurrentGraphicsLayer, m_frame_buffer.pixfmt(), m_pSoftMask->GetBuffer() + 3, m_pSoftMask->GetStep());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1549,10 +1545,13 @@ namespace Aggplus
|
||||
{
|
||||
if (m_pSoftMask)
|
||||
{
|
||||
if (m_pSoftMask->GetDataType() == EMaskDataType::ImageBuffer)
|
||||
return render_scanlines_3(ras, ren, m_pSoftMask->GetScanlineImage());
|
||||
if (m_pSoftMask->GetDataType() == EMaskDataType::Alpha4Buffer)
|
||||
return render_scanlines_3(ras, ren, m_pSoftMask->GetScanlineABuffer());
|
||||
ESoftMaskType nType = m_pSoftMask->GetDataType();
|
||||
if (nType == ESoftMaskType::RGBGrayBuffer)
|
||||
return render_scanlines_3(ras, ren, ((CSoftMaskRGBAgray*)m_pSoftMask->m_pInternal)->GetScanline());
|
||||
if (nType == ESoftMaskType::BGRGrayBuffer)
|
||||
return render_scanlines_3(ras, ren, ((CSoftMaskBGRAgray*)m_pSoftMask->m_pInternal)->GetScanline());
|
||||
if (nType == ESoftMaskType::Alpha4Buffer)
|
||||
return render_scanlines_3(ras, ren, ((CSoftMaskAlpha*)m_pSoftMask->m_pInternal)->GetScanline());
|
||||
}
|
||||
render_scanlines_3(ras, ren, m_rasterizer.get_scanline());
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@
|
||||
#include "Matrix.h"
|
||||
#include "GraphicsLayerBlend.h"
|
||||
#include "GraphicsPath.h"
|
||||
#include "AlphaMask.h"
|
||||
#include "AlphaMask_p.h"
|
||||
#include "Clip.h"
|
||||
#include "Brush.h"
|
||||
#include "Image.h"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -42,125 +42,155 @@
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
class CGraphicsPath_private;
|
||||
class GRAPHICS_DECL CGraphicsPath : public NSFonts::ISimpleGraphicsPath
|
||||
{
|
||||
public:
|
||||
CGraphicsPath();
|
||||
~CGraphicsPath();
|
||||
class CGraphicsPath_private;
|
||||
class GRAPHICS_DECL CGraphicsPath : public NSFonts::ISimpleGraphicsPath
|
||||
{
|
||||
public:
|
||||
CGraphicsPath();
|
||||
CGraphicsPath(const CGraphicsPath& other) noexcept;
|
||||
CGraphicsPath(CGraphicsPath&& other) noexcept;
|
||||
CGraphicsPath(const std::vector<CGraphicsPath>& paths) noexcept;
|
||||
virtual ~CGraphicsPath();
|
||||
|
||||
CGraphicsPath* Clone();
|
||||
CGraphicsPath* Clone();
|
||||
|
||||
Status Reset();
|
||||
void SetRuler(bool bEvenOdd);
|
||||
Status Reset();
|
||||
void SetRuler(bool bEvenOdd);
|
||||
|
||||
Status StartFigure();
|
||||
Status CloseFigure();
|
||||
bool Is_poly_closed();
|
||||
Status MoveTo(double x, double y);
|
||||
Status LineTo(double x, double y);
|
||||
Status CurveTo(double x1, double y1, double x2, double y2, double x3, double y3);
|
||||
Status StartFigure();
|
||||
Status CloseFigure();
|
||||
bool Is_poly_closed() const;
|
||||
Status MoveTo(double x, double y);
|
||||
Status LineTo(double x, double y);
|
||||
Status CurveTo(double x1, double y1, double x2, double y2, double x3, double y3);
|
||||
|
||||
// методы, которые просто будем сводить к трем основным
|
||||
Status AddLine(double x1, double y1, double x2, double y2);
|
||||
Status AddLines(double* pPoints, int nCount);
|
||||
Status AddBezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);
|
||||
Status AddBeziers(double* pPoints, int nCount);
|
||||
Status AddCurve(double* pPoints, int nCount);
|
||||
Status AddEllipse(double x, double y, double width, double height);
|
||||
Status AddRectangle(double x, double y, double width, double height);
|
||||
Status AddPolygon(double* pPoints, int nCount);
|
||||
Status AddPath(const CGraphicsPath& oPath);
|
||||
Status AddArc(double x, double y, double width, double height, double startAngle, double sweepAngle);
|
||||
// методы, которые просто будем сводить к трем основным
|
||||
Status AddLine(double x1, double y1, double x2, double y2);
|
||||
Status AddLines(double* pPoints, int nCount);
|
||||
Status AddBezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);
|
||||
Status AddBeziers(double* pPoints, int nCount);
|
||||
Status AddCurve(double* pPoints, int nCount);
|
||||
Status AddEllipse(double x, double y, double width, double height);
|
||||
Status AddRectangle(double x, double y, double width, double height);
|
||||
Status AddPolygon(double* pPoints, int nCount);
|
||||
Status AddPath(const CGraphicsPath& oPath);
|
||||
Status AddArc(double x, double y, double width, double height, double startAngle, double sweepAngle);
|
||||
|
||||
ULONG GetPointCount() const;
|
||||
Status GetPathPoints(PointF* points, int count) const;
|
||||
Status GetLastPoint(double& x, double& y);
|
||||
Status GetPathPoints(double* points, int count) const;
|
||||
void GetBounds(double& left, double& top, double& width, double& height);
|
||||
ULONG GetPointCount() const;
|
||||
Status GetPathPoints(PointF* points, int count) const;
|
||||
Status GetLastPoint(double& x, double& y);
|
||||
Status GetPathPoints(double* points, int count) const;
|
||||
void GetBounds(double& left, double& top, double& width, double& height) const;
|
||||
void GetBoundsAccurate(double& left, double& top, double& width, double& height) const;
|
||||
|
||||
Status Transform(const CMatrix* matrix);
|
||||
virtual bool _MoveTo(double x, double y);
|
||||
virtual bool _LineTo(double x, double y);
|
||||
virtual bool _CurveTo(double x1, double y1, double x2, double y2, double x3, double y3);
|
||||
virtual bool _Close();
|
||||
Status Transform(const CMatrix* matrix);
|
||||
virtual bool _MoveTo(double x, double y);
|
||||
virtual bool _LineTo(double x, double y);
|
||||
virtual bool _CurveTo(double x1, double y1, double x2, double y2, double x3, double y3);
|
||||
virtual bool _Close();
|
||||
|
||||
Status AddString(const std::wstring& strText, NSFonts::IFontManager* pFont, double x, double y);
|
||||
Status AddString(const unsigned int* pGids, const unsigned int nGidsCount, NSFonts::IFontManager* pFont, double x, double y);
|
||||
Status AddStringC(const LONG& lText, NSFonts::IFontManager* pFont, double x, double y);
|
||||
void z_Stroke(const double& size);
|
||||
void Widen(const double& size, const Aggplus::LineJoin& join, const CMatrix* matrix, float flatness);
|
||||
Status AddString(const std::wstring& strText, NSFonts::IFontManager* pFont, double x, double y);
|
||||
Status AddString(const unsigned int* pGids, const unsigned int nGidsCount, NSFonts::IFontManager* pFont, double x, double y);
|
||||
Status AddStringC(const LONG& lText, NSFonts::IFontManager* pFont, double x, double y);
|
||||
void z_Stroke(const double& size);
|
||||
void Widen(const double& size, const Aggplus::LineJoin& join, const CMatrix* matrix, float flatness);
|
||||
|
||||
int EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
|
||||
double AngToEllPrm(double fAngle, double fXRad, double fYRad);
|
||||
int EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
|
||||
int EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double *pfXCur, double *pfYCur, INT bClockDirection = FALSE);
|
||||
int Ellipse(double fX, double fY, double fXRad, double fYRad);
|
||||
Status AddArc2(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle);
|
||||
bool IsPointInPath(const double& x, const double& y);
|
||||
int EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
|
||||
double AngToEllPrm(double fAngle, double fXRad, double fYRad);
|
||||
int EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
|
||||
int EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double* pfXCur, double* pfYCur, INT bClockDirection = FALSE);
|
||||
int Ellipse(double fX, double fY, double fXRad, double fYRad);
|
||||
Status AddArc2(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle);
|
||||
bool IsPointInPath(const double& x, const double& y);
|
||||
|
||||
public:
|
||||
CGraphicsPath_private* m_internal;
|
||||
};
|
||||
// Methods for Path Clip
|
||||
unsigned GetCloseCount() const noexcept;
|
||||
unsigned GetMoveCount() const noexcept;
|
||||
bool IsClockwise() const noexcept;
|
||||
bool IsMovePoint(unsigned idx) const noexcept;
|
||||
bool IsCurvePoint(unsigned idx) const noexcept;
|
||||
bool IsLinePoint(unsigned idx) const noexcept;
|
||||
bool IsClosePoint(unsigned idx) const noexcept;
|
||||
double GetArea() const noexcept;
|
||||
double GetArea(unsigned idx, bool isCurve) const noexcept;
|
||||
std::vector<PointD> GetPoints(unsigned idx, unsigned count) const noexcept;
|
||||
std::vector<CGraphicsPath> GetSubPaths() const;
|
||||
|
||||
class CGraphicsPathSimpleConverter_private;
|
||||
class GRAPHICS_DECL CGraphicsPathSimpleConverter : public NSFonts::ISimpleGraphicsPath
|
||||
{
|
||||
private:
|
||||
IRenderer* m_pRenderer;
|
||||
CGraphicsPathSimpleConverter_private* m_internal;
|
||||
CGraphicsPath& operator=(const CGraphicsPath& other) noexcept;
|
||||
CGraphicsPath& operator=(CGraphicsPath&& other) noexcept;
|
||||
bool operator==(const CGraphicsPath& other) noexcept;
|
||||
|
||||
public:
|
||||
CGraphicsPathSimpleConverter();
|
||||
~CGraphicsPathSimpleConverter();
|
||||
public:
|
||||
CGraphicsPath_private* m_internal;
|
||||
};
|
||||
|
||||
public:
|
||||
void SetRenderer(IRenderer* pRenderer);
|
||||
IRenderer* GetRenderer(INT bIsAddref = FALSE);
|
||||
class CGraphicsPathSimpleConverter_private;
|
||||
class GRAPHICS_DECL CGraphicsPathSimpleConverter : public NSFonts::ISimpleGraphicsPath
|
||||
{
|
||||
private:
|
||||
IRenderer* m_pRenderer;
|
||||
CGraphicsPathSimpleConverter_private* m_internal;
|
||||
|
||||
public:
|
||||
bool PathCommandMoveTo(double fX, double fY);
|
||||
bool PathCommandLineTo(double fX, double fY);
|
||||
bool PathCommandLinesTo(double* pPoints, LONG lCount);
|
||||
bool PathCommandCurveTo(double fX1, double fY1, double fX2, double fY2, double fX3, double fY3);
|
||||
bool PathCommandCurvesTo(double* pData, LONG lCount);
|
||||
bool PathCommandArcTo(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle);
|
||||
bool PathCommandClose();
|
||||
bool PathCommandEnd();
|
||||
bool PathCommandStart();
|
||||
bool PathCommandGetCurrentPoint(double* fX, double* fY);
|
||||
bool PathCommandText(const std::wstring& bsText, NSFonts::IFontManager* pManager, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset);
|
||||
bool PathCommandTextEx(std::wstring& bsText, std::wstring& bsGidText, NSFonts::IFontManager* pManager, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset, DWORD lFlags);
|
||||
public:
|
||||
CGraphicsPathSimpleConverter();
|
||||
~CGraphicsPathSimpleConverter();
|
||||
|
||||
bool PathCommandText2(const int* pUnicodes, const int* pGids, const int& nCount, NSFonts::IFontManager* pManager,
|
||||
const double& x, const double& y, const double& w, const double& h);
|
||||
bool PathCommandText2(const std::wstring& sUnicodes, const int* pGids, const int& nCount, NSFonts::IFontManager* pManager,
|
||||
const double& x, const double& y, const double& w, const double& h);
|
||||
public:
|
||||
void SetRenderer(IRenderer* pRenderer);
|
||||
IRenderer* GetRenderer(INT bIsAddref = FALSE);
|
||||
|
||||
bool PathCommandGetBounds(double& left, double& top, double& width, double &height);
|
||||
public:
|
||||
bool PathCommandMoveTo(double fX, double fY);
|
||||
bool PathCommandLineTo(double fX, double fY);
|
||||
bool PathCommandLinesTo(double* pPoints, LONG lCount);
|
||||
bool PathCommandCurveTo(double fX1, double fY1, double fX2, double fY2, double fX3, double fY3);
|
||||
bool PathCommandCurvesTo(double* pData, LONG lCount);
|
||||
bool PathCommandArcTo(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle);
|
||||
bool PathCommandClose();
|
||||
bool PathCommandEnd();
|
||||
bool PathCommandStart();
|
||||
bool PathCommandGetCurrentPoint(double* fX, double* fY);
|
||||
bool PathCommandText(const std::wstring& bsText, NSFonts::IFontManager* pManager, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset);
|
||||
bool
|
||||
PathCommandTextEx(std::wstring& bsText, std::wstring& bsGidText, NSFonts::IFontManager* pManager, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset, DWORD lFlags);
|
||||
|
||||
public:
|
||||
bool PathCommandText2(const int* pUnicodes, const int* pGids, const int& nCount, NSFonts::IFontManager* pManager, const double& x, const double& y, const double& w, const double& h);
|
||||
bool PathCommandText2(const std::wstring& sUnicodes, const int* pGids, const int& nCount, NSFonts::IFontManager* pManager, const double& x, const double& y, const double& w, const double& h);
|
||||
|
||||
virtual bool _MoveTo(double x, double y);
|
||||
virtual bool _LineTo(double x, double y);
|
||||
virtual bool _CurveTo(double x1, double y1, double x2, double y2, double x3, double y3);
|
||||
virtual bool _Close();
|
||||
bool _Reset();
|
||||
bool _Start();
|
||||
bool PathCommandGetBounds(double& left, double& top, double& width, double& height);
|
||||
|
||||
protected:
|
||||
bool AddString(const std::wstring& bstrText, NSFonts::IFontManager* pFont, double x, double y);
|
||||
public:
|
||||
virtual bool _MoveTo(double x, double y);
|
||||
virtual bool _LineTo(double x, double y);
|
||||
virtual bool _CurveTo(double x1, double y1, double x2, double y2, double x3, double y3);
|
||||
virtual bool _Close();
|
||||
bool _Reset();
|
||||
bool _Start();
|
||||
|
||||
int EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
|
||||
double AngToEllPrm(double fAngle, double fXRad, double fYRad);
|
||||
int EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
|
||||
int EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double *pfXCur, double *pfYCur, INT bClockDirection = FALSE);
|
||||
int Ellipse(double fX, double fY, double fXRad, double fYRad);
|
||||
protected:
|
||||
bool AddString(const std::wstring& bstrText, NSFonts::IFontManager* pFont, double x, double y);
|
||||
|
||||
bool AddArc(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle);
|
||||
int EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
|
||||
double AngToEllPrm(double fAngle, double fXRad, double fYRad);
|
||||
int EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
|
||||
int EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double* pfXCur, double* pfYCur, INT bClockDirection = FALSE);
|
||||
int Ellipse(double fX, double fY, double fXRad, double fYRad);
|
||||
|
||||
bool Is_poly_closed();
|
||||
};
|
||||
}
|
||||
bool AddArc(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle);
|
||||
|
||||
bool Is_poly_closed();
|
||||
};
|
||||
|
||||
enum BooleanOpType
|
||||
{
|
||||
Intersection = 1,
|
||||
Union = 0,
|
||||
Subtraction = 2,
|
||||
Exclusion = 3
|
||||
};
|
||||
|
||||
GRAPHICS_DECL CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op, long fillType = c_nWindingFillMode);
|
||||
|
||||
} // namespace Aggplus
|
||||
|
||||
#endif // _BUILD_GRAPHICSPATH_H_
|
||||
|
||||
@ -955,61 +955,62 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
|
||||
}
|
||||
|
||||
Aggplus::CBrushTexture* pTextureBrush = NULL;
|
||||
|
||||
if (NULL != m_pCache)
|
||||
{
|
||||
pCacheImage = (CCacheImage*)m_pCache->Lock(m_oBrush.TexturePath);
|
||||
|
||||
pTextureBrush = new Aggplus::CBrushTexture(pCacheImage->GetImage(), oMode);
|
||||
if (NULL != m_oBrush.Image)
|
||||
{
|
||||
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.Image, oMode);
|
||||
}
|
||||
else if (m_oBrush.TexturePath.find(L"data:") == 0)
|
||||
{
|
||||
bool bIsOnlyOfficeHatch = false;
|
||||
if (m_oBrush.TexturePath.find(L"onlyoffice_hatch") != std::wstring::npos)
|
||||
bIsOnlyOfficeHatch = true;
|
||||
|
||||
int countErase = (int)(m_oBrush.TexturePath.find(',') + 1);
|
||||
int nInputSize = (int)(m_oBrush.TexturePath.length() - countErase);
|
||||
const wchar_t* pInputSrc = m_oBrush.TexturePath.c_str() + countErase;
|
||||
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nInputSize);
|
||||
BYTE* pImageData = new BYTE[nDecodeLen];
|
||||
if (TRUE == NSBase64::Base64Decode(pInputSrc, nInputSize, pImageData, &nDecodeLen))
|
||||
{
|
||||
CBgraFrame oFrame;
|
||||
if (bIsOnlyOfficeHatch)
|
||||
{
|
||||
int nSize = (int)sqrt(nDecodeLen >> 2);
|
||||
oFrame.put_IsRGBA(true);
|
||||
oFrame.put_Data(pImageData);
|
||||
oFrame.put_Width(nSize);
|
||||
oFrame.put_Height(nSize);
|
||||
oFrame.put_Stride(4 * nSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
oFrame.put_IsRGBA(false);
|
||||
oFrame.Decode(pImageData, nDecodeLen);
|
||||
RELEASEARRAYOBJECTS(pImageData);
|
||||
}
|
||||
// pImage отдается pTextureBrush и освобождается вместе с pBrush
|
||||
Aggplus::CImage* pImage = new Aggplus::CImage();
|
||||
pImage->Create(oFrame.get_Data(), oFrame.get_Width(), oFrame.get_Height(), oFrame.get_Stride());
|
||||
oFrame.ClearNoAttack();
|
||||
pTextureBrush = new Aggplus::CBrushTexture(pImage, oMode);
|
||||
pTextureBrush->m_bReleaseImage = TRUE;
|
||||
}
|
||||
else
|
||||
RELEASEARRAYOBJECTS(pImageData);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef BUILDING_WASM_MODULE
|
||||
if (NULL != m_oBrush.Image)
|
||||
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.Image, oMode);
|
||||
else if (m_oBrush.TexturePath.find(L"data:") == 0)
|
||||
if (NULL != m_pCache)
|
||||
{
|
||||
bool bIsOnlyOfficeHatch = false;
|
||||
if (m_oBrush.TexturePath.find(L"onlyoffice_hatch") != std::wstring::npos)
|
||||
bIsOnlyOfficeHatch = true;
|
||||
std::string sBase64MultyByte(m_oBrush.TexturePath.begin(), m_oBrush.TexturePath.end());
|
||||
sBase64MultyByte.erase(0, sBase64MultyByte.find(',') + 1);
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(sBase64MultyByte.length());
|
||||
BYTE* pImageData = new BYTE[nDecodeLen + 64];
|
||||
if (TRUE == NSBase64::Base64Decode(sBase64MultyByte.c_str(), sBase64MultyByte.length(), pImageData, &nDecodeLen))
|
||||
{
|
||||
CBgraFrame oFrame;
|
||||
if (bIsOnlyOfficeHatch)
|
||||
{
|
||||
int nSize = (int)sqrt(nDecodeLen >> 2);
|
||||
oFrame.put_IsRGBA(true);
|
||||
oFrame.put_Data(pImageData);
|
||||
oFrame.put_Width(nSize);
|
||||
oFrame.put_Height(nSize);
|
||||
oFrame.put_Stride(4 * nSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
oFrame.put_IsRGBA(false);
|
||||
oFrame.Decode(pImageData, nDecodeLen);
|
||||
RELEASEARRAYOBJECTS(pImageData);
|
||||
}
|
||||
// pImage отдается pTextureBrush и освобождается вместе с pBrush
|
||||
Aggplus::CImage* pImage = new Aggplus::CImage();
|
||||
pImage->Create(oFrame.get_Data(), oFrame.get_Width(), oFrame.get_Height(), oFrame.get_Stride());
|
||||
oFrame.ClearNoAttack();
|
||||
pTextureBrush = new Aggplus::CBrushTexture(pImage, oMode);
|
||||
pTextureBrush->m_bReleaseImage = TRUE;
|
||||
}
|
||||
else
|
||||
RELEASEARRAYOBJECTS(pImageData);
|
||||
pCacheImage = (CCacheImage*)m_pCache->Lock(m_oBrush.TexturePath);
|
||||
pTextureBrush = new Aggplus::CBrushTexture(pCacheImage->GetImage(), oMode);
|
||||
}
|
||||
#else
|
||||
if (NULL != m_oBrush.Image)
|
||||
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.Image, oMode);
|
||||
else
|
||||
{
|
||||
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.TexturePath, oMode);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if( pTextureBrush )
|
||||
|
||||
@ -123,8 +123,10 @@ public:
|
||||
PointF_T(T x, T y) : X(x), Y(y) { }
|
||||
//~PointF() { }
|
||||
INT Equals(const PointF_T& point) const { return(X==point.X && Y==point.Y); }
|
||||
bool IsZero() const noexcept { return X == 0.0 && Y == 0.0; }
|
||||
PointF_T operator+(const PointF_T& point) const { return PointF_T(X + point.X, Y + point.Y); }
|
||||
PointF_T operator-(const PointF_T& point) const { return PointF_T(X - point.X, Y - point.Y); }
|
||||
PointF_T& operator=(const PointF_T& other) noexcept {X = other.X; Y = other.Y; return *this;}
|
||||
public:
|
||||
T X, Y;
|
||||
};
|
||||
|
||||
516
DesktopEditor/graphics/boolean_operations_math.h
Normal file
516
DesktopEditor/graphics/boolean_operations_math.h
Normal file
@ -0,0 +1,516 @@
|
||||
#ifndef CLIPMATH_H
|
||||
#define CLIPMATH_H
|
||||
|
||||
#include "aggplustypes.h"
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
constexpr double EPSILON = 1e-12;
|
||||
constexpr double POINT_EPSILON = 1e-2;
|
||||
constexpr double GEOMETRIC_EPSILON = 1e-7;
|
||||
constexpr double LOCATION_EPSILON = 1e-7;
|
||||
constexpr double TIME_EPSILON = 1e-8;
|
||||
constexpr double MACHINE_EPSILON = 1.12e-16;
|
||||
constexpr double TRIGANOMETRIC_EPSILON = 1e-8;
|
||||
constexpr double CURVETIME_EPSILON = 1e-8;
|
||||
constexpr double LINE_EPSILON = 1e-9;
|
||||
constexpr double MIN = std::numeric_limits<double>::min();
|
||||
constexpr double MAX = std::numeric_limits<double>::max();
|
||||
const Aggplus::PointD MIN_POINT = Aggplus::PointD(-100000.0, -100000.0);
|
||||
|
||||
const std::vector<double> ABSCISSAS[16] = {
|
||||
{0.5773502691896257645091488},
|
||||
{0,0.7745966692414833770358531},
|
||||
{0.3399810435848562648026658,0.8611363115940525752239465},
|
||||
{0,0.5384693101056830910363144,0.9061798459386639927976269},
|
||||
{0.2386191860831969086305017,0.6612093864662645136613996,0.9324695142031520278123016},
|
||||
{0,0.4058451513773971669066064,0.7415311855993944398638648,0.9491079123427585245261897},
|
||||
{0.1834346424956498049394761,0.5255324099163289858177390,0.7966664774136267395915539,
|
||||
0.9602898564975362316835609},
|
||||
{0,0.3242534234038089290385380,0.6133714327005903973087020,0.8360311073266357942994298,
|
||||
0.9681602395076260898355762},
|
||||
{0.1488743389816312108848260,0.4333953941292471907992659,0.6794095682990244062343274,
|
||||
0.8650633666889845107320967,0.9739065285171717200779640},
|
||||
{0,0.2695431559523449723315320,0.5190961292068118159257257,0.7301520055740493240934163,
|
||||
0.8870625997680952990751578,0.9782286581460569928039380},
|
||||
{0.1252334085114689154724414,0.3678314989981801937526915,0.5873179542866174472967024,
|
||||
0.7699026741943046870368938,0.9041172563704748566784659,0.9815606342467192506905491},
|
||||
{0,0.2304583159551347940655281,0.4484927510364468528779129,0.6423493394403402206439846,
|
||||
0.8015780907333099127942065,0.9175983992229779652065478,0.9841830547185881494728294},
|
||||
{0.1080549487073436620662447,0.3191123689278897604356718,0.5152486363581540919652907,
|
||||
0.6872929048116854701480198,0.8272013150697649931897947,0.9284348836635735173363911,
|
||||
0.9862838086968123388415973},
|
||||
{0,0.2011940939974345223006283,0.3941513470775633698972074,0.5709721726085388475372267,
|
||||
0.7244177313601700474161861,0.8482065834104272162006483,0.9372733924007059043077589,
|
||||
0.9879925180204854284895657},
|
||||
{0.0950125098376374401853193,0.2816035507792589132304605,0.4580167776572273863424194,
|
||||
0.6178762444026437484466718,0.7554044083550030338951012,0.8656312023878317438804679,
|
||||
0.9445750230732325760779884,0.9894009349916499325961542}
|
||||
};
|
||||
|
||||
const std::vector<double> WEIGHT[16] {
|
||||
{1},
|
||||
{0.8888888888888888888888889,0.5555555555555555555555556},
|
||||
{0.6521451548625461426269361,0.3478548451374538573730639},
|
||||
{0.5688888888888888888888889,0.4786286704993664680412915,0.2369268850561890875142640},
|
||||
{0.4679139345726910473898703,0.3607615730481386075698335,0.1713244923791703450402961},
|
||||
{0.4179591836734693877551020,0.3818300505051189449503698,0.2797053914892766679014678,
|
||||
0.1294849661688696932706114},
|
||||
{0.3626837833783619829651504,0.3137066458778872873379622,0.2223810344533744705443560,
|
||||
0.1012285362903762591525314},
|
||||
{0.3302393550012597631645251,0.3123470770400028400686304,0.2606106964029354623187429,
|
||||
0.1806481606948574040584720,0.0812743883615744119718922},
|
||||
{0.2955242247147528701738930,0.2692667193099963550912269,0.2190863625159820439955349,
|
||||
0.1494513491505805931457763,0.0666713443086881375935688},
|
||||
{0.2729250867779006307144835,0.2628045445102466621806889,0.2331937645919904799185237,
|
||||
0.1862902109277342514260976,0.1255803694649046246346943,0.0556685671161736664827537},
|
||||
{0.2491470458134027850005624,0.2334925365383548087608499,0.2031674267230659217490645,
|
||||
0.1600783285433462263346525,0.1069393259953184309602547,0.0471753363865118271946160},
|
||||
{0.2325515532308739101945895,0.2262831802628972384120902,0.2078160475368885023125232,
|
||||
0.1781459807619457382800467,0.1388735102197872384636018,0.0921214998377284479144218,
|
||||
0.0404840047653158795200216},
|
||||
{0.2152638534631577901958764,0.2051984637212956039659241,0.1855383974779378137417166,
|
||||
0.1572031671581935345696019,0.1215185706879031846894148,0.0801580871597602098056333,
|
||||
0.0351194603317518630318329},
|
||||
{0.2025782419255612728806202,0.1984314853271115764561183,0.1861610000155622110268006,
|
||||
0.1662692058169939335532009,0.1395706779261543144478048,0.1071592204671719350118695,
|
||||
0.0703660474881081247092674,0.0307532419961172683546284},
|
||||
{0.1894506104550684962853967,0.1826034150449235888667637,0.1691565193950025381893121,
|
||||
0.1495959888165767320815017,0.1246289712555338720524763,0.0951585116824927848099251,
|
||||
0.0622535239386478928628438,0.0271524594117540948517806}
|
||||
};
|
||||
|
||||
inline double max(const double& v1, const double& v2, const double& v3, const double& v4)
|
||||
{
|
||||
return std::max(std::max(v1, v2), std::max(v3, v4));
|
||||
}
|
||||
|
||||
inline double max(const double& v1, const double& v2, const double& v3)
|
||||
{
|
||||
return std::max(std::max(v1, v2), v3);
|
||||
}
|
||||
|
||||
inline double min(const double& v1, const double& v2, const double& v3, const double& v4)
|
||||
{
|
||||
return std::min(std::min(v1, v2), std::min(v3, v4));
|
||||
}
|
||||
|
||||
inline double min(const double& v1, const double& v2, const double& v3)
|
||||
{
|
||||
return std::min(std::min(v1, v2), v3);
|
||||
}
|
||||
|
||||
inline bool isZero(const double& value)
|
||||
{
|
||||
return value >= -EPSILON && value <= EPSILON;
|
||||
}
|
||||
|
||||
inline bool isMachineZero(const double& value)
|
||||
{
|
||||
return value >= -MACHINE_EPSILON && value <= MACHINE_EPSILON;
|
||||
}
|
||||
|
||||
inline bool isInRange(const double& angle, const double& mn, const double& mx)
|
||||
{
|
||||
return (mn < mx) ? (angle > mn && angle < mx) : (angle > mn || angle < mx);
|
||||
}
|
||||
|
||||
inline double clamp(const double& value, const double& mn, const double& mx)
|
||||
{
|
||||
return value < mn ? mn : value > mx ? mx : value;
|
||||
}
|
||||
|
||||
inline bool isCollinear(const Aggplus::PointD& p1, const Aggplus::PointD& p2)
|
||||
{
|
||||
return fabs(p1.X * p2.X + p1.Y * p2.Y) <= sqrt((p1.X * p1.X + p1.Y * p1.Y) * (p2.X * p2.X + p2.Y * p2.Y)) * TRIGANOMETRIC_EPSILON;
|
||||
}
|
||||
|
||||
inline int getIterations(const double& a, const double& b)
|
||||
{
|
||||
double n1 = 2.0, n2 = 16.0;
|
||||
|
||||
return std::max(n1, std::min(n2, ceil(fabs(b - a) * 32)));
|
||||
}
|
||||
|
||||
inline double CurveLength(const double& t, const double& ax, const double& bx, const double& cx,
|
||||
const double& ay, const double& by, const double& cy)
|
||||
{
|
||||
return sqrt((((ax * t) + bx) * t + cx) * (((ax * t) + bx) * t + cx) + (((ay * t) + by) * t + cy) * (((ay * t) + by) * t + cy));
|
||||
}
|
||||
|
||||
inline double integrate(const double& ax, const double& bx, const double& cx, const double& ay,
|
||||
const double& by, const double& cy, const double& a, const double& b, size_t n = 16)
|
||||
{
|
||||
std::vector<double> x = ABSCISSAS[n - 2],
|
||||
w = WEIGHT[n - 2];
|
||||
|
||||
double A = (b - a) * 0.5,
|
||||
B = A + a;
|
||||
double sum = n & 1 ? CurveLength(B, ax, bx, cx, ay, by, cy) : 0.0;
|
||||
|
||||
for (size_t i = 0; i < (n + 1) >> 1; i++)
|
||||
{
|
||||
double Ax = A * x[i];
|
||||
sum += w[i] * (CurveLength(B + Ax, ax, bx, cx, ay, by, cy) +
|
||||
CurveLength(B - Ax, ax, bx, cx, ay, by, cy));
|
||||
}
|
||||
|
||||
return A * sum;
|
||||
}
|
||||
|
||||
double fLength(const double& t, double& length, double& start, const double& offset,
|
||||
const double& ax, const double& bx, const double& cx, const double& ay,
|
||||
const double& by, const double& cy)
|
||||
{
|
||||
length += integrate(ax, bx, cx, ay, by, cy, start, t, getIterations(start, t));
|
||||
start = t;
|
||||
|
||||
return length - offset;
|
||||
}
|
||||
|
||||
double findRoot(double& length, double& start, const double& offset, const double& ax,
|
||||
const double& bx, const double& cx, const double& ay, const double& by,
|
||||
const double& cy, double x, double a, double b)
|
||||
{
|
||||
for (size_t i = 0; i < 32; i++)
|
||||
{
|
||||
double fx = fLength(x, length, start, offset, ax, bx, cx, ay, by, cy),
|
||||
dx = fx / CurveLength(x, ax, bx, cx, ay, by, cy),
|
||||
nx = x - dx;
|
||||
|
||||
if (fabs(dx) < EPSILON)
|
||||
{
|
||||
x = nx;
|
||||
break;
|
||||
}
|
||||
|
||||
if (fx > 0)
|
||||
{
|
||||
b = x;
|
||||
x = nx <= a ? (a + b) * 0.5 : nx;
|
||||
}
|
||||
else{
|
||||
a = x;
|
||||
x = nx >= b ? (a + b) * 0.5 : nx;
|
||||
}
|
||||
}
|
||||
|
||||
return clamp(x, a, b);
|
||||
}
|
||||
|
||||
bool intersect(std::vector<double> v, Aggplus::PointD& res)
|
||||
{
|
||||
v[2] -= v[0];
|
||||
v[3] -= v[1];
|
||||
v[6] -= v[4];
|
||||
v[7] -= v[5];
|
||||
|
||||
double cross = v[2] * v[7] - v[3] * v[6];
|
||||
if (!isMachineZero(cross))
|
||||
{
|
||||
double dx = v[0] - v[4],
|
||||
dy = v[1] - v[5],
|
||||
u1 = (v[6] * dy - v[7] * dx) / cross,
|
||||
u2 = (v[2] * dy - v[3] * dx) / cross,
|
||||
uMin = -EPSILON,
|
||||
uMax = 1 + EPSILON;
|
||||
|
||||
if (uMin < u1 && u1 < uMax && uMin < u2 && u2 < uMax)
|
||||
{
|
||||
u1 = u1 <= 0 ? 0 : u1 >= 1 ? 1 : u1;
|
||||
res = Aggplus::PointD(v[0] + u1 * v[2], v[1] + u1 * v[3]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void getConvexHull(const double& dq0, const double& dq1,
|
||||
const double& dq2, const double& dq3,
|
||||
std::vector<Aggplus::PointD>& top,
|
||||
std::vector<Aggplus::PointD>& bottom)
|
||||
{
|
||||
Aggplus::PointD p0 = Aggplus::PointD(0.0, dq0),
|
||||
p1 = Aggplus::PointD(1.0 / 3.0, dq1),
|
||||
p2 = Aggplus::PointD(2.0 / 3.0, dq2),
|
||||
p3 = Aggplus::PointD(1.0, dq3);
|
||||
|
||||
double dist1 = dq1 - (2.0 * dq0 + dq3) / 3.0,
|
||||
dist2 = dq2 - (dq0 + 2.0 * dq3) / 3.0;
|
||||
|
||||
if (dist1 * dist2 < 0.0)
|
||||
{
|
||||
top.reserve(3);
|
||||
top.push_back(p0);
|
||||
top.push_back(p1);
|
||||
top.push_back(p3);
|
||||
|
||||
bottom.reserve(3);
|
||||
bottom.push_back(p0);
|
||||
bottom.push_back(p2);
|
||||
bottom.push_back(p3);
|
||||
}
|
||||
else
|
||||
{
|
||||
double distRatio = dist1 / dist2;
|
||||
if (distRatio >= 2.0)
|
||||
{
|
||||
top.reserve(3);
|
||||
top.push_back(p0);
|
||||
top.push_back(p1);
|
||||
top.push_back(p3);
|
||||
|
||||
bottom.reserve(2);
|
||||
bottom.push_back(p0);
|
||||
bottom.push_back(p3);
|
||||
}
|
||||
else if (distRatio <= 0.5)
|
||||
{
|
||||
top.reserve(3);
|
||||
top.push_back(p0);
|
||||
top.push_back(p2);
|
||||
top.push_back(p3);
|
||||
|
||||
bottom.reserve(2);
|
||||
bottom.push_back(p0);
|
||||
bottom.push_back(p3);
|
||||
}
|
||||
else
|
||||
{
|
||||
top.reserve(4);
|
||||
top.push_back(p0);
|
||||
top.push_back(p1);
|
||||
top.push_back(p2);
|
||||
top.push_back(p3);
|
||||
|
||||
bottom.reserve(2);
|
||||
bottom.push_back(p0);
|
||||
bottom.push_back(p3);
|
||||
}
|
||||
}
|
||||
|
||||
if (dist1 < 0.0 || dist2 < 0.0)
|
||||
std::swap(top, bottom);
|
||||
}
|
||||
|
||||
double clipConvexHullPart(const std::vector<Aggplus::PointD>& part, const bool& top,
|
||||
const double& threshold)
|
||||
{
|
||||
double px = part[0].X,
|
||||
py = part[0].Y;
|
||||
for (size_t i = 1; i < part.size(); i++)
|
||||
{
|
||||
double qx = part[i].X,
|
||||
qy = part[i].Y;
|
||||
|
||||
if (top ? qy >= threshold : qy <= threshold)
|
||||
return qy == threshold ? qx : px + (threshold - py) * (qx - px) / (qy - py);
|
||||
|
||||
px = qx;
|
||||
py = qy;
|
||||
}
|
||||
|
||||
return MIN;
|
||||
}
|
||||
|
||||
inline double clipConvexHull(const std::vector<Aggplus::PointD>& top,
|
||||
const std::vector<Aggplus::PointD>& bottom,
|
||||
const double& dMin, const double& dMax)
|
||||
{
|
||||
if (top[0].Y < dMin)
|
||||
return clipConvexHullPart(top, true, dMin);
|
||||
else if (bottom[0].Y > dMax)
|
||||
return clipConvexHullPart(bottom, false, dMax);
|
||||
else
|
||||
return top[0].X;
|
||||
}
|
||||
|
||||
inline int binarySearch(const std::vector<std::vector<double>>& allBounds,
|
||||
const std::vector<int>& indices, const size_t& coord, const double& value)
|
||||
{
|
||||
int lo = 0,
|
||||
hi = static_cast<int>(indices.size());
|
||||
|
||||
while(lo < hi)
|
||||
{
|
||||
int mid = (hi + lo) >> 1;
|
||||
if (allBounds[indices[mid]][coord] < value)
|
||||
lo = mid + 1;
|
||||
else
|
||||
hi = mid;
|
||||
}
|
||||
|
||||
return lo - 1;
|
||||
}
|
||||
|
||||
inline double getSignedDistance(const double& px, const double& py, double vx, double vy,
|
||||
const double& x, const double& y, bool asVector = false)
|
||||
{
|
||||
if (!asVector)
|
||||
{
|
||||
vx -= px;
|
||||
vy -= py;
|
||||
}
|
||||
|
||||
bool vx0 = vx == 0.0,
|
||||
vyG = vy > 0.0,
|
||||
vxL = vx < 0.0,
|
||||
vy0 = vy == 0.0,
|
||||
vyGvx = vy > vx;
|
||||
|
||||
double distX = vyG ? x - px : px - x,
|
||||
distY = vxL ? y - py : py - y,
|
||||
distGY = vy * sqrt(1.0 + (vx * vx) / (vy * vy)),
|
||||
distGX = vx * sqrt(1.0 + (vy * vy) / (vx * vx)),
|
||||
distXY = ((x - px) * vy - (y - py) * vx) / (vyGvx ? distGY : distGX);
|
||||
|
||||
return vx0 ? distX : vy0 ? distY : distXY;
|
||||
}
|
||||
|
||||
inline double getDistance(const double& px, const double& py, const double& vx, const double& vy,
|
||||
const double& x, const double& y, const bool& asVector)
|
||||
{
|
||||
return fabs(getSignedDistance(px, py, vx, vy, x, y, asVector));
|
||||
}
|
||||
|
||||
inline double getDistance(const double& px, const double& py, const double& vx, const double& vy,
|
||||
const double& x, const double& y)
|
||||
{
|
||||
if (vx == 0)
|
||||
{
|
||||
if (vy > 0)
|
||||
return std::abs(x - px);
|
||||
else
|
||||
return std::abs(px - x);
|
||||
}
|
||||
if (vy == 0)
|
||||
{
|
||||
if (vx < 0)
|
||||
return std::abs(y - py);
|
||||
else
|
||||
return std::abs(py -y);
|
||||
}
|
||||
|
||||
bool dir = vy > vx;
|
||||
double dist = (x- px) * vy - (y - py) * vx,
|
||||
epsY = vy * sqrt(1 + (vx * vx) / (vy * vy)),
|
||||
epsX = vx * sqrt(1 + (vy * vy) / (vx * vx));
|
||||
|
||||
return dist / (dir ? epsY : epsX);
|
||||
}
|
||||
|
||||
inline double getDistance(const double& x1, const double& y1, const double& x2, const double& y2)
|
||||
{
|
||||
return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
||||
}
|
||||
|
||||
inline double getDistance(const Aggplus::PointD& point1, const Aggplus::PointD& point2)
|
||||
{
|
||||
return getDistance(point1.X, point1.Y, point2.X, point2.Y);
|
||||
}
|
||||
|
||||
inline std::pair<double, double> split(const double& v)
|
||||
{
|
||||
double x = v * 134217729.0,
|
||||
y = v - x,
|
||||
hi = y + x,
|
||||
lo = v - hi;
|
||||
|
||||
return std::pair<double, double>(hi, lo);
|
||||
}
|
||||
|
||||
inline double getDiscriminant(const double& a, const double& b, const double& c)
|
||||
{
|
||||
double D = b * b - a * c,
|
||||
E = b * b + a * c;
|
||||
|
||||
if (fabs(D) * 3 < E)
|
||||
{
|
||||
std::pair<double, double> ad = split(a),
|
||||
bd = split(b),
|
||||
cd = split(c);
|
||||
|
||||
double p = b * b,
|
||||
dp = (bd.first * bd.first -
|
||||
p + 2 * bd.first * bd.second) +
|
||||
bd.second * bd.second,
|
||||
q = a * c,
|
||||
dq = (ad.first * cd.first -
|
||||
q + ad.first * cd.second +
|
||||
ad.second * cd.first) +
|
||||
ad.second * cd.second;
|
||||
|
||||
D = (p - q) + (dp - dq);
|
||||
}
|
||||
|
||||
return D;
|
||||
}
|
||||
|
||||
int solveQuadratic(double a, double b, double c, std::vector<double>& roots,
|
||||
const double& mn, const double& mx)
|
||||
{
|
||||
double x1 = MAX, x2 = MAX;
|
||||
if (fabs(a) < EPSILON)
|
||||
{
|
||||
if (fabs(b) < EPSILON)
|
||||
return fabs(c) < EPSILON ? -1 : 0;
|
||||
x1 = -c / b;
|
||||
}
|
||||
else
|
||||
{
|
||||
b *= -0.5;
|
||||
|
||||
double D = getDiscriminant(a, b, c);
|
||||
if (D != 0 && fabs(D) < MACHINE_EPSILON)
|
||||
{
|
||||
double f = max(fabs(a), fabs(b), fabs(c));
|
||||
if ((f != 0) && (f < 1e-8 || f < 1e8))
|
||||
{
|
||||
f = pow(2, -round(log2(f)));
|
||||
a *= f;
|
||||
b *= f;
|
||||
c *= f;
|
||||
D = getDiscriminant(a, b, c);
|
||||
}
|
||||
}
|
||||
|
||||
if (D >= -MACHINE_EPSILON)
|
||||
{
|
||||
double Q = D < 0 ? 0 : sqrt(D),
|
||||
R = b + (b < 0 ? -Q : Q);
|
||||
if (R == 0)
|
||||
{
|
||||
x1 = c / a;
|
||||
x2 = -x1;
|
||||
}
|
||||
else
|
||||
{
|
||||
x1 = R / a;
|
||||
x2 = c / R;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
double minB = mn - EPSILON,
|
||||
maxB = mx + EPSILON;
|
||||
if (x1 != MAX && x1 > minB && x1 < maxB)
|
||||
{
|
||||
roots.push_back(clamp(x1, mn, mx));
|
||||
count++;
|
||||
}
|
||||
|
||||
if (x2 != x1 && x2 != MAX && x2 > minB && x2 < maxB)
|
||||
{
|
||||
roots.push_back(clamp(x2, mn, mx));
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#endif //CLIPMATH_H
|
||||
@ -221,6 +221,7 @@ BYTE* CAnnotFieldInfo::GetRender(LONG& nLen)
|
||||
}
|
||||
const std::wstring& CAnnotFieldInfo::GetNM() { return m_wsNM; }
|
||||
const std::wstring& CAnnotFieldInfo::GetLM() { return m_wsLM; }
|
||||
const std::wstring& CAnnotFieldInfo::GetOUserID() { return m_wsOUserID; }
|
||||
const std::wstring& CAnnotFieldInfo::GetContents() { return m_wsContents; }
|
||||
const std::vector<double>& CAnnotFieldInfo::GetC() { return m_arrC; }
|
||||
|
||||
@ -348,6 +349,8 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
m_pRender = pReader->GetCurrentBuffer();
|
||||
pReader->Skip(m_nRenderLen);
|
||||
}
|
||||
if (nFlags & (1 << 7))
|
||||
m_wsOUserID = pReader->ReadString();
|
||||
|
||||
if (IsMarkup())
|
||||
{
|
||||
@ -931,6 +934,11 @@ int CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::GetMaxLen() const { return m
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::GetV() { return m_wsV; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::GetRV() { return m_wsRV; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::GetAPV() { return m_wsAPV; }
|
||||
BYTE* CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::GetRender(LONG& nLen)
|
||||
{
|
||||
nLen = m_nRenderLen;
|
||||
return m_pRender;
|
||||
}
|
||||
void CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags, int nWidgetFlag)
|
||||
{
|
||||
if (nFlags & (1 << 9))
|
||||
@ -941,6 +949,12 @@ void CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::Read(NSOnlineOfficeBinToPdf
|
||||
m_wsRV = pReader->ReadString();
|
||||
if (nFlags & (1 << 12))
|
||||
m_wsAPV = pReader->ReadString();
|
||||
if (nFlags & (1 << 13))
|
||||
{
|
||||
m_nRenderLen = pReader->ReadInt() - 4;
|
||||
m_pRender = pReader->GetCurrentBuffer();
|
||||
pReader->Skip(m_nRenderLen);
|
||||
}
|
||||
}
|
||||
|
||||
int CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::GetTI() const { return m_nTI; }
|
||||
@ -949,6 +963,11 @@ const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::GetAPV() {
|
||||
const std::vector<int>& CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::GetI() { return m_arrI; }
|
||||
const std::vector<std::wstring>& CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::GetArrV() { return m_arrV; }
|
||||
const std::vector< std::pair<std::wstring, std::wstring> >& CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::GetOpt() { return m_arrOpt; }
|
||||
BYTE* CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::GetRender(LONG& nLen)
|
||||
{
|
||||
nLen = m_nRenderLen;
|
||||
return m_pRender;
|
||||
}
|
||||
void CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags)
|
||||
{
|
||||
if (nFlags & (1 << 9))
|
||||
@ -979,6 +998,12 @@ void CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::Read(NSOnlineOfficeBinToP
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrI.push_back(pReader->ReadInt());
|
||||
}
|
||||
if (nFlags & (1 << 15))
|
||||
{
|
||||
m_nRenderLen = pReader->ReadInt() - 4;
|
||||
m_pRender = pReader->GetCurrentBuffer();
|
||||
pReader->Skip(m_nRenderLen);
|
||||
}
|
||||
}
|
||||
|
||||
CAnnotFieldDelete::CAnnotFieldDelete() : IAdvancedCommand(AdvancedCommandType::DeleteAnnot) {}
|
||||
|
||||
@ -86,6 +86,7 @@ public:
|
||||
const std::wstring& GetV();
|
||||
const std::wstring& GetRV();
|
||||
const std::wstring& GetAPV();
|
||||
BYTE* GetRender(LONG& nLen);
|
||||
|
||||
void Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags, int nWidgetFlag);
|
||||
|
||||
@ -94,6 +95,8 @@ public:
|
||||
std::wstring m_wsV;
|
||||
std::wstring m_wsRV;
|
||||
std::wstring m_wsAPV;
|
||||
LONG m_nRenderLen;
|
||||
BYTE* m_pRender;
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CChoiceWidgetPr
|
||||
@ -105,6 +108,7 @@ public:
|
||||
const std::vector<int>& GetI();
|
||||
const std::vector<std::wstring>& GetArrV();
|
||||
const std::vector< std::pair<std::wstring, std::wstring> >& GetOpt();
|
||||
BYTE* GetRender(LONG& nLen);
|
||||
|
||||
void Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags);
|
||||
|
||||
@ -115,6 +119,8 @@ public:
|
||||
std::vector<int> m_arrI;
|
||||
std::vector<std::wstring> m_arrV;
|
||||
std::vector< std::pair<std::wstring, std::wstring> > m_arrOpt;
|
||||
LONG m_nRenderLen;
|
||||
BYTE* m_pRender;
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CSignatureWidgetPr
|
||||
@ -414,6 +420,7 @@ public:
|
||||
BYTE* GetRender(LONG& nLen);
|
||||
const std::wstring& GetNM();
|
||||
const std::wstring& GetLM();
|
||||
const std::wstring& GetOUserID();
|
||||
const std::wstring& GetContents();
|
||||
const std::vector<double>& GetC();
|
||||
|
||||
@ -466,6 +473,7 @@ private:
|
||||
int m_nPage;
|
||||
std::wstring m_wsNM;
|
||||
std::wstring m_wsLM;
|
||||
std::wstring m_wsOUserID;
|
||||
std::wstring m_wsContents;
|
||||
std::pair<BYTE, double> m_pBE;
|
||||
std::vector<double> m_arrC;
|
||||
|
||||
@ -49,14 +49,18 @@ SOURCES += \
|
||||
# paths
|
||||
HEADERS += \
|
||||
./../GraphicsPath_private.h \
|
||||
./../GraphicsPath.h
|
||||
./../GraphicsPath.h \
|
||||
./../BooleanOperations.h \
|
||||
./../boolean_operations_math.h
|
||||
|
||||
SOURCES += \
|
||||
./../GraphicsPath.cpp
|
||||
./../GraphicsPath.cpp \
|
||||
./../BooleanOperations.cpp
|
||||
|
||||
# alpha mask
|
||||
HEADERS += \
|
||||
./../AlphaMask.h
|
||||
./../AlphaMask.h \
|
||||
./../AlphaMask_p.h
|
||||
|
||||
SOURCES += \
|
||||
./../AlphaMask.cpp
|
||||
|
||||
@ -143,7 +143,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../",
|
||||
"files": ["GraphicsRenderer.cpp", "pro/pro_Graphics.cpp", "pro/pro_Fonts.cpp", "pro/pro_Image.cpp", "Graphics.cpp", "Brush.cpp", "BaseThread.cpp", "GraphicsPath.cpp", "Image.cpp", "Matrix.cpp", "Clip.cpp", "TemporaryCS.cpp", "AlphaMask.cpp", "GraphicsLayer.cpp", "commands/DocInfo.cpp", "commands/AnnotField.cpp", "commands/FormField.cpp"]
|
||||
"files": ["GraphicsRenderer.cpp", "pro/pro_Graphics.cpp", "pro/pro_Fonts.cpp", "pro/pro_Image.cpp", "Graphics.cpp", "Brush.cpp", "BaseThread.cpp", "GraphicsPath.cpp", "BooleanOperations.cpp", "Image.cpp", "Matrix.cpp", "Clip.cpp", "TemporaryCS.cpp", "AlphaMask.cpp", "GraphicsLayer.cpp", "commands/DocInfo.cpp", "commands/AnnotField.cpp", "commands/FormField.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../fontengine/",
|
||||
|
||||
@ -53,6 +53,8 @@ HEADERS += \
|
||||
../../../Matrix.h \
|
||||
../../../Matrix_private.h \
|
||||
../../../GraphicsPath.h \
|
||||
../../../BooleanOperations.h \
|
||||
../../../boolean_operations_math.h \
|
||||
../../../GraphicsPath_private.h \
|
||||
../../../AlphaMask.h \
|
||||
\
|
||||
@ -105,6 +107,7 @@ HEADERS += \
|
||||
SOURCES += \
|
||||
../../../Matrix.cpp \
|
||||
../../../GraphicsPath.cpp \
|
||||
../../../BooleanOperations.cpp \
|
||||
../../../AlphaMask.cpp \
|
||||
../../../../raster/BgraFrame.cpp \
|
||||
../../../../raster/ImageFileFormatChecker.cpp \
|
||||
@ -680,6 +683,7 @@ HEADERS += \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Paragraph.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Shape.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/TextLine.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/ExternalImageStorage.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/FontStyleManager.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/ImageManager.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/FontManager.h \
|
||||
|
||||
@ -73,9 +73,9 @@ CFile.prototype.getOriginPage = function(originIndex)
|
||||
for (let i = 0; i < this.pages.length; ++i)
|
||||
{
|
||||
if (this.pages[i]["originIndex"] == originIndex)
|
||||
return this.pages[i];
|
||||
return i;
|
||||
}
|
||||
return null;
|
||||
return -1;
|
||||
};
|
||||
|
||||
CFile.prototype["getPages"] = function()
|
||||
@ -115,7 +115,7 @@ CFile.prototype["loadFromDataWithPassword"] = function(password)
|
||||
if (0 != this.nativeFile)
|
||||
this._closeFile();
|
||||
|
||||
let isSuccess = this._openFile(arrayBuffer, password);
|
||||
let isSuccess = this._openFile(undefined, password);
|
||||
let error = this._getError(); // 0 - ok, 4 - password, else: error
|
||||
this.type = this._getType();
|
||||
|
||||
@ -126,6 +126,11 @@ CFile.prototype["loadFromDataWithPassword"] = function(password)
|
||||
return error;
|
||||
};
|
||||
|
||||
CFile.prototype["getType"] = function()
|
||||
{
|
||||
return this.type;
|
||||
};
|
||||
|
||||
CFile.prototype["close"] = function()
|
||||
{
|
||||
this._closeFile();
|
||||
@ -236,14 +241,17 @@ CFile.prototype["getLinks"] = function(pageIndex)
|
||||
// TEXT
|
||||
CFile.prototype["getGlyphs"] = function(pageIndex)
|
||||
{
|
||||
let page = this.getOriginPage(pageIndex);
|
||||
let i = this.getOriginPage(pageIndex);
|
||||
if (i < 0)
|
||||
return null;
|
||||
let page = this.pages[i];
|
||||
if (!page || page.fonts.length > 0)
|
||||
{
|
||||
// waiting fonts
|
||||
return null;
|
||||
}
|
||||
|
||||
this.lockPageNumForFontsLoader(pageIndex, UpdateFontsSource.Page);
|
||||
this.lockPageNumForFontsLoader(i, UpdateFontsSource.Page);
|
||||
let res = this._getGlyphs(pageIndex);
|
||||
// there is no need to delete the result; this buffer is used as a text buffer
|
||||
// for text commands on other pages. After receiving ALL text pages,
|
||||
@ -488,7 +496,11 @@ function readAnnot(reader, rec)
|
||||
// Date of last change - M
|
||||
if (flags & (1 << 5))
|
||||
rec["LastModified"] = reader.readString();
|
||||
// AP
|
||||
rec["AP"]["have"] = (flags >> 6) & 1;
|
||||
// User ID
|
||||
if (flags & (1 << 7))
|
||||
rec["OUserID"] = reader.readString();
|
||||
}
|
||||
function readAnnotAP(reader, AP)
|
||||
{
|
||||
@ -841,6 +853,8 @@ CFile.prototype["getButtonIcons"] = function(pageIndex, width, height, backgroun
|
||||
let reader = ptr.getReader();
|
||||
|
||||
if (!reader) return {};
|
||||
|
||||
let res = {};
|
||||
|
||||
res["MK"] = [];
|
||||
res["View"] = [];
|
||||
@ -1368,14 +1382,17 @@ CFile.prototype["free"] = function(pointer)
|
||||
// PIXMAP
|
||||
CFile.prototype["getPagePixmap"] = function(pageIndex, width, height, backgroundColor)
|
||||
{
|
||||
let page = this.getOriginPage(pageIndex);
|
||||
let i = this.getOriginPage(pageIndex);
|
||||
if (i < 0)
|
||||
return null;
|
||||
let page = this.pages[i];
|
||||
if (!page || page.fonts.length > 0)
|
||||
{
|
||||
// waiting fonts
|
||||
return null;
|
||||
}
|
||||
|
||||
this.lockPageNumForFontsLoader(pageIndex, UpdateFontsSource.Page);
|
||||
this.lockPageNumForFontsLoader(i, UpdateFontsSource.Page);
|
||||
let ptr = this._getPixmap(pageIndex, width, height, backgroundColor);
|
||||
this.unlockPageNumForFontsLoader();
|
||||
|
||||
@ -1433,6 +1450,43 @@ function fontToMemory(file, isCheck)
|
||||
Module["_free"](idPointer);
|
||||
}
|
||||
|
||||
// FONTS
|
||||
CFile.prototype["addPage"] = function(pageIndex, pageObj)
|
||||
{
|
||||
this.pages.splice(pageIndex, 0, pageObj);
|
||||
if (this.fontStreams)
|
||||
{
|
||||
for (let i in this.fontStreams)
|
||||
{
|
||||
let pages = this.fontStreams[i].pages;
|
||||
for (let j = 0; j < pages.length; j++)
|
||||
{
|
||||
if (pages[j] >= pageIndex)
|
||||
pages[j] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
CFile.prototype["removePage"] = function(pageIndex)
|
||||
{
|
||||
let result = this.pages.splice(pageIndex, 1);
|
||||
if (this.fontStreams)
|
||||
{
|
||||
for (let i in this.fontStreams)
|
||||
{
|
||||
let pages = this.fontStreams[i].pages;
|
||||
for (let j = 0; j < pages.length; j++)
|
||||
{
|
||||
if (pages[j] > pageIndex)
|
||||
pages[j] -= 1;
|
||||
else if (pages[j] == pageIndex)
|
||||
pages.splice(j, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
// ONLY WEB
|
||||
self["AscViewer"]["Free"] = function(pointer)
|
||||
{
|
||||
|
||||
@ -107,7 +107,7 @@ CFile.prototype._setCMap = function(memoryBuffer)
|
||||
|
||||
CFile.prototype._getFontByID = function(ID)
|
||||
{
|
||||
return null;
|
||||
return g_native_drawing_file["GetFontBinary"](ID);
|
||||
};
|
||||
|
||||
CFile.prototype._getInteractiveFormsFonts = function(type)
|
||||
@ -144,7 +144,7 @@ CFile.prototype._getInteractiveFormsInfo = function()
|
||||
|
||||
CFile.prototype._getAnnotationsInfo = function(pageIndex)
|
||||
{
|
||||
g_module_pointer.ptr = g_native_drawing_file["GetAnnotationsInfo"](pageIndex);
|
||||
g_module_pointer.ptr = g_native_drawing_file["GetAnnotationsInfo"](pageIndex === undefined ? -1 : pageIndex);
|
||||
return g_module_pointer;
|
||||
};
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ CFile.prototype._getUint8ClampedArray = function(ptr, len)
|
||||
// FILE
|
||||
CFile.prototype._openFile = function(buffer, password)
|
||||
{
|
||||
if (this.stream && buffer)
|
||||
if (buffer)
|
||||
{
|
||||
let data = new Uint8Array(buffer);
|
||||
this.stream_size = data.length;
|
||||
@ -94,7 +94,7 @@ CFile.prototype._openFile = function(buffer, password)
|
||||
if (password)
|
||||
{
|
||||
let passwordBuf = password.toUtf8();
|
||||
let passwordPtr = Module["_malloc"](passwordBuf.length);
|
||||
passwordPtr = Module["_malloc"](passwordBuf.length);
|
||||
Module["HEAP8"].set(passwordBuf, passwordPtr);
|
||||
}
|
||||
|
||||
|
||||
@ -267,6 +267,13 @@ void ReadAnnot(BYTE* pWidgets, int& i)
|
||||
std::cout << "YES AP, ";
|
||||
else
|
||||
std::cout << "NO AP, ";
|
||||
if (nFlags & (1 << 7))
|
||||
{
|
||||
nPathLength = READ_INT(pWidgets + i);
|
||||
i += 4;
|
||||
std::cout << "User ID " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
|
||||
i += nPathLength;
|
||||
}
|
||||
}
|
||||
|
||||
void ReadInteractiveForms(BYTE* pWidgets, int& i)
|
||||
@ -821,7 +828,7 @@ void ReadFileAttachment(BYTE* pAnnots, int& i, int n)
|
||||
RELEASEARRAYOBJECTS(res);
|
||||
}
|
||||
|
||||
void ReadInteractiveFormsFonts(CGraphicsFileDrawing* pGrFile, int nType)
|
||||
void ReadInteractiveFormsFonts(CDrawingFile* pGrFile, int nType)
|
||||
{
|
||||
BYTE* pFonts = GetInteractiveFormsFonts(pGrFile, nType);
|
||||
int nLength = READ_INT(pFonts);
|
||||
@ -923,7 +930,7 @@ int main(int argc, char* argv[])
|
||||
if (!NSFile::CFileBinary::ReadAllBytes(sFilePath, &pFileData, nFileDataLen))
|
||||
return 1;
|
||||
|
||||
CGraphicsFileDrawing* pGrFile = Open(pFileData, (LONG)nFileDataLen, "");
|
||||
CDrawingFile* pGrFile = Open(pFileData, (LONG)nFileDataLen, "");
|
||||
int nError = GetErrorCode(pGrFile);
|
||||
|
||||
if (nError != 0)
|
||||
@ -1084,7 +1091,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// INTERACTIVE FORMS
|
||||
if (false)
|
||||
if (true)
|
||||
{
|
||||
ReadInteractiveFormsFonts(pGrFile, 1);
|
||||
ReadInteractiveFormsFonts(pGrFile, 2);
|
||||
@ -1199,7 +1206,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// ANNOTS
|
||||
if (false)
|
||||
if (true)
|
||||
{
|
||||
BYTE* pAnnots = GetAnnotationsInfo(pGrFile, -1);
|
||||
nLength = READ_INT(pAnnots);
|
||||
@ -1801,6 +1808,13 @@ int main(int argc, char* argv[])
|
||||
free(pAnnotAP);
|
||||
}
|
||||
|
||||
if (true)
|
||||
{
|
||||
BYTE* pScan = ScanPage(pGrFile, nTestPage, 1);
|
||||
if (pScan)
|
||||
free(pScan);
|
||||
}
|
||||
|
||||
Close(pGrFile);
|
||||
RELEASEARRAYOBJECTS(pFileData);
|
||||
RELEASEARRAYOBJECTS(pCMapData);
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
|
||||
#include "../agg-2.4/include/agg_color_rgba.h"
|
||||
#include "../graphics/aggplustypes.h"
|
||||
#include "../graphics/Matrix.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
@ -102,6 +103,23 @@ namespace NSStructures
|
||||
}
|
||||
}
|
||||
|
||||
void set_x_min(float x_min)
|
||||
{
|
||||
x_domain_min = x_min;
|
||||
}
|
||||
void set_x_max(float x_max)
|
||||
{
|
||||
x_domain_max = x_max;
|
||||
}
|
||||
void set_y_min(float y_min)
|
||||
{
|
||||
y_domain_min = y_min;
|
||||
}
|
||||
void set_y_max(float y_max)
|
||||
{
|
||||
y_domain_max = y_max;
|
||||
}
|
||||
|
||||
float get_x_min()
|
||||
{
|
||||
return x_domain_min;
|
||||
@ -386,6 +404,89 @@ namespace NSStructures
|
||||
{
|
||||
discrete_step = 1.0f / n;
|
||||
}
|
||||
void transform(const Aggplus::CMatrix& matrix)
|
||||
{
|
||||
// shading transform
|
||||
auto& point1 = shading.point1;
|
||||
auto& point2 = shading.point2;
|
||||
|
||||
double point1_x = static_cast<double>(point1.x);
|
||||
double point1_y = static_cast<double>(point1.y);
|
||||
double point2_x = static_cast<double>(point2.x);
|
||||
double point2_y = static_cast<double>(point2.y);
|
||||
|
||||
matrix.TransformPoint(point1_x, point1_y);
|
||||
matrix.TransformPoint(point2_x, point2_y);
|
||||
|
||||
point1.x = static_cast<float>(point1_x);
|
||||
point1.y = static_cast<float>(point1_y);
|
||||
point2.x = static_cast<float>(point2_x);
|
||||
point2.y = static_cast<float>(point2_y);
|
||||
|
||||
// triangle transform
|
||||
for (auto& p : shading.triangle)
|
||||
{
|
||||
double triangle_x = static_cast<double>(p.x);
|
||||
double triangle_y = static_cast<double>(p.y);
|
||||
|
||||
matrix.TransformPoint(triangle_x, triangle_y);
|
||||
|
||||
p.x = static_cast<float>(triangle_x);
|
||||
p.y = static_cast<float>(triangle_y);
|
||||
}
|
||||
|
||||
// domains transform
|
||||
double x_domain_min = static_cast<double>(shading.function.get_x_min());
|
||||
double y_domain_min = static_cast<double>(shading.function.get_y_min());
|
||||
double x_domain_max = static_cast<double>(shading.function.get_x_max());
|
||||
double y_domain_max = static_cast<double>(shading.function.get_y_max());
|
||||
|
||||
matrix.TransformPoint(x_domain_min, y_domain_min);
|
||||
matrix.TransformPoint(x_domain_max, y_domain_max);
|
||||
|
||||
shading.function.set_x_min(static_cast<float>(x_domain_min));
|
||||
shading.function.set_y_min(static_cast<float>(y_domain_min));
|
||||
shading.function.set_x_max(static_cast<float>(x_domain_max));
|
||||
shading.function.set_y_max(static_cast<float>(y_domain_max));
|
||||
|
||||
// center transform
|
||||
double center_x = static_cast<double>(centerX);
|
||||
double center_y = static_cast<double>(centerY);
|
||||
|
||||
matrix.TransformPoint(center_x, center_y);
|
||||
|
||||
double p0_x = static_cast<double>(p0.x);
|
||||
double p0_y = static_cast<double>(p0.y);
|
||||
double p1_x = static_cast<double>(p1.x);
|
||||
double p1_y = static_cast<double>(p1.y);
|
||||
|
||||
matrix.TransformPoint(p0_x, p0_y);
|
||||
matrix.TransformPoint(p1_x, p1_y);
|
||||
|
||||
p0.x = static_cast<float>(p0_x);
|
||||
p0.y = static_cast<float>(p0_y);
|
||||
p1.x = static_cast<float>(p1_x);
|
||||
p1.y = static_cast<float>(p1_y);
|
||||
|
||||
for (size_t i = 0; i < shading.patch.size(); ++i)
|
||||
{
|
||||
for (size_t j = 0; j < shading.patch[i].size(); ++j)
|
||||
{
|
||||
double patch_x = static_cast<double>(shading.patch[i][j].x);
|
||||
double patch_y = static_cast<double>(shading.patch[i][j].y);
|
||||
|
||||
matrix.TransformPoint(patch_x, patch_y);
|
||||
|
||||
shading.patch[i][j].x = static_cast<float>(patch_x);
|
||||
shading.patch[i][j].y = static_cast<float>(patch_y);
|
||||
}
|
||||
}
|
||||
|
||||
// sizes scale
|
||||
double sqrt_det = sqrt(fabs(matrix.Determinant()));
|
||||
r0 *= sqrt_det;
|
||||
r1 *= sqrt_det;
|
||||
}
|
||||
|
||||
Point p0, p1;
|
||||
float r0, r1;
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
include(../../../../Common/3dParty/googletest/googletest.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
CONFIG += console c++14
|
||||
CONFIG -= app_bundle
|
||||
CONFIG += thread
|
||||
CONFIG -= qt
|
||||
|
||||
SOURCES += \
|
||||
tst_booleanoperations.cpp
|
||||
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
CORE_ROOT_DIR = $$PWD/../../../../../core
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
ADD_DEPENDENCY(kernel, graphics, UnicodeConverter)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
@ -0,0 +1,17 @@
|
||||
isEmpty(GOOGLETEST_DIR):GOOGLETEST_DIR=$$(GOOGLETEST_DIR)
|
||||
|
||||
isEmpty(GOOGLETEST_DIR) {
|
||||
GOOGLETEST_DIR = ""
|
||||
!isEmpty(GOOGLETEST_DIR) {
|
||||
warning("Using googletest src dir specified at Qt Creator wizard")
|
||||
message("set GOOGLETEST_DIR as environment variable or qmake variable to get rid of this message")
|
||||
}
|
||||
}
|
||||
|
||||
!isEmpty(GOOGLETEST_DIR): {
|
||||
INCLUDEPATH *= "$$GOOGLETEST_DIR/include"
|
||||
|
||||
LIBS *= -L"$$GOOGLETEST_DIR/lib" -lgtest -lgmock
|
||||
} else {
|
||||
LIBS *= -lgtest -lgmock
|
||||
}
|
||||
@ -0,0 +1,459 @@
|
||||
|
||||
//#include <gmock/gmock-matchers.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include "../../GraphicsPath.h"
|
||||
|
||||
using namespace testing;
|
||||
|
||||
TEST(BooleanOperations, NoIntersOutside)
|
||||
{
|
||||
Aggplus::CGraphicsPath path1, path2, resultIntersect, resultUnite, resultSubtract;
|
||||
|
||||
path1.StartFigure();
|
||||
path1.MoveTo(100.0, 100.0);
|
||||
path1.LineTo(100.0, 200.0);
|
||||
path1.LineTo(200.0, 200.0);
|
||||
path1.LineTo(200.0, 100.0);
|
||||
path1.LineTo(100.0, 100.0);
|
||||
path1.CloseFigure();
|
||||
|
||||
path2.StartFigure();
|
||||
path2.MoveTo(300.0, 300.0);
|
||||
path2.LineTo(300.0, 400.0);
|
||||
path2.LineTo(400.0, 400.0);
|
||||
path2.LineTo(400.0, 300.0);
|
||||
path2.LineTo(300.0, 300.0);
|
||||
path2.CloseFigure();
|
||||
|
||||
resultIntersect.StartFigure();
|
||||
resultIntersect.CloseFigure();
|
||||
|
||||
resultUnite.StartFigure();
|
||||
resultUnite.MoveTo(100.0, 100.0);
|
||||
resultUnite.LineTo(100.0, 200.0);
|
||||
resultUnite.LineTo(200.0, 200.0);
|
||||
resultUnite.LineTo(200.0, 100.0);
|
||||
resultUnite.LineTo(100.0, 100.0);
|
||||
resultUnite.MoveTo(300.0, 300.0);
|
||||
resultUnite.LineTo(300.0, 400.0);
|
||||
resultUnite.LineTo(400.0, 400.0);
|
||||
resultUnite.LineTo(400.0, 300.0);
|
||||
resultUnite.LineTo(300.0, 300.0);
|
||||
resultUnite.CloseFigure();
|
||||
|
||||
resultSubtract.StartFigure();
|
||||
resultSubtract.MoveTo(100.0, 100.0);
|
||||
resultSubtract.LineTo(100.0, 200.0);
|
||||
resultSubtract.LineTo(200.0, 200.0);
|
||||
resultSubtract.LineTo(200.0, 100.0);
|
||||
resultSubtract.LineTo(100.0, 100.0);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, NoIntersInside)
|
||||
{
|
||||
Aggplus::CGraphicsPath path1, path2, resultIntersect, resultUnite, resultSubtract;
|
||||
|
||||
path1.StartFigure();
|
||||
path1.MoveTo(100.0, 100.0);
|
||||
path1.LineTo(100.0, 400.0);
|
||||
path1.LineTo(400.0, 400.0);
|
||||
path1.LineTo(400.0, 100.0);
|
||||
path1.LineTo(100.0, 100.0);
|
||||
path1.CloseFigure();
|
||||
|
||||
path2.StartFigure();
|
||||
path2.MoveTo(300.0, 300.0);
|
||||
path2.LineTo(300.0, 200.0);
|
||||
path2.LineTo(200.0, 200.0);
|
||||
path2.LineTo(200.0, 300.0);
|
||||
path2.LineTo(300.0, 300.0);
|
||||
path2.CloseFigure();
|
||||
|
||||
resultIntersect.StartFigure();
|
||||
resultIntersect.MoveTo(300.0, 300.0);
|
||||
resultIntersect.LineTo(300.0, 200.0);
|
||||
resultIntersect.LineTo(200.0, 200.0);
|
||||
resultIntersect.LineTo(200.0, 300.0);
|
||||
resultIntersect.LineTo(300.0, 300.0);
|
||||
resultIntersect.CloseFigure();
|
||||
|
||||
resultUnite.StartFigure();
|
||||
resultUnite.MoveTo(100.0, 100.0);
|
||||
resultUnite.LineTo(100.0, 400.0);
|
||||
resultUnite.LineTo(400.0, 400.0);
|
||||
resultUnite.LineTo(400.0, 100.0);
|
||||
resultUnite.LineTo(100.0, 100.0);
|
||||
resultUnite.CloseFigure();
|
||||
|
||||
resultSubtract.StartFigure();
|
||||
resultSubtract.MoveTo(100.0, 100.0);
|
||||
resultSubtract.LineTo(100.0, 400.0);
|
||||
resultSubtract.LineTo(400.0, 400.0);
|
||||
resultSubtract.LineTo(400.0, 100.0);
|
||||
resultSubtract.LineTo(100.0, 100.0);
|
||||
resultSubtract.MoveTo(300.0, 300.0);
|
||||
resultSubtract.LineTo(200.0, 300.0);
|
||||
resultSubtract.LineTo(200.0, 200.0);
|
||||
resultSubtract.LineTo(300.0, 200.0);
|
||||
resultSubtract.LineTo(300.0, 300.0);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, OneIntersOutside)
|
||||
{
|
||||
Aggplus::CGraphicsPath path1, path2, resultIntersect, resultUnite, resultSubtract;
|
||||
|
||||
path1.StartFigure();
|
||||
path1.MoveTo(100.0, 100.0);
|
||||
path1.LineTo(100.0, 200.0);
|
||||
path1.LineTo(200.0, 200.0);
|
||||
path1.LineTo(200.0, 100.0);
|
||||
path1.LineTo(100.0, 100.0);
|
||||
path1.CloseFigure();
|
||||
|
||||
path2.StartFigure();
|
||||
path2.MoveTo(200.0, 150.0);
|
||||
path2.LineTo(300.0, 150.0);
|
||||
path2.LineTo(250.0, 200.0);
|
||||
path2.LineTo(200.0, 150.0);
|
||||
path2.CloseFigure();
|
||||
|
||||
resultIntersect.StartFigure();
|
||||
resultIntersect.MoveTo(200.0, 150.0);
|
||||
resultIntersect.CloseFigure();
|
||||
|
||||
resultUnite.StartFigure();
|
||||
resultUnite.MoveTo(100.0, 100.0);
|
||||
resultUnite.LineTo(100.0, 200.0);
|
||||
resultUnite.LineTo(200.0, 200.0);
|
||||
resultUnite.LineTo(200.0, 150.0);
|
||||
resultUnite.LineTo(250.0, 200.0);
|
||||
resultUnite.LineTo(300.0, 150.0);
|
||||
resultUnite.LineTo(200.0, 150.0);
|
||||
resultUnite.LineTo(200.0, 100.0);
|
||||
resultUnite.LineTo(100.0, 100.0);
|
||||
resultUnite.CloseFigure();
|
||||
|
||||
resultSubtract.StartFigure();
|
||||
resultSubtract.MoveTo(100.0, 100.0);
|
||||
resultSubtract.LineTo(100.0, 200.0);
|
||||
resultSubtract.LineTo(200.0, 200.0);
|
||||
resultSubtract.LineTo(200.0, 100.0);
|
||||
resultSubtract.LineTo(100.0, 100.0);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, OneIntersInside)
|
||||
{
|
||||
Aggplus::CGraphicsPath path1, path2, resultIntersect, resultUnite, resultSubtract;
|
||||
|
||||
path1.StartFigure();
|
||||
path1.MoveTo(100.0, 100.0);
|
||||
path1.LineTo(100.0, 200.0);
|
||||
path1.LineTo(200.0, 200.0);
|
||||
path1.LineTo(200.0, 100.0);
|
||||
path1.LineTo(100.0, 100.0);
|
||||
path1.CloseFigure();
|
||||
|
||||
path2.StartFigure();
|
||||
path2.MoveTo(200.0, 150.0);
|
||||
path2.LineTo(150.0, 150.0);
|
||||
path2.LineTo(175.0, 175.0);
|
||||
path2.LineTo(200.0, 150.0);
|
||||
path2.CloseFigure();
|
||||
|
||||
resultIntersect.StartFigure();
|
||||
resultIntersect.MoveTo(200.0, 150.0);
|
||||
resultIntersect.LineTo(150.0, 150.0);
|
||||
resultIntersect.LineTo(175.0, 175.0);
|
||||
resultIntersect.LineTo(200.0, 150.0);
|
||||
resultIntersect.CloseFigure();
|
||||
|
||||
resultUnite.StartFigure();
|
||||
resultUnite.MoveTo(100.0, 100.0);
|
||||
resultUnite.LineTo(100.0, 200.0);
|
||||
resultUnite.LineTo(200.0, 200.0);
|
||||
resultUnite.LineTo(200.0, 100.0);
|
||||
resultUnite.LineTo(100.0, 100.0);
|
||||
resultUnite.CloseFigure();
|
||||
|
||||
resultSubtract.StartFigure();
|
||||
resultSubtract.MoveTo(100.0, 100.0);
|
||||
resultSubtract.LineTo(100.0, 200.0);
|
||||
resultSubtract.LineTo(200.0, 200.0);
|
||||
resultSubtract.LineTo(200.0, 150.0);
|
||||
resultSubtract.LineTo(175.0, 175.0);
|
||||
resultSubtract.LineTo(150.0, 150.0);
|
||||
resultSubtract.LineTo(200.0, 150.0);
|
||||
resultSubtract.LineTo(200.0, 100.0);
|
||||
resultSubtract.LineTo(100.0, 100.0);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, OverlapOutside)
|
||||
{
|
||||
Aggplus::CGraphicsPath path1, path2, resultIntersect, resultUnite, resultSubtract;
|
||||
|
||||
path1.StartFigure();
|
||||
path1.MoveTo(100.0, 100.0);
|
||||
path1.LineTo(100.0, 300.0);
|
||||
path1.LineTo(300.0, 300.0);
|
||||
path1.LineTo(300.0, 100.0);
|
||||
path1.LineTo(100.0, 100.0);
|
||||
path1.CloseFigure();
|
||||
|
||||
path2.StartFigure();
|
||||
path2.MoveTo(300.0, 200.0);
|
||||
path2.LineTo(300.0, 400.0);
|
||||
path2.LineTo(400.0, 400.0);
|
||||
path2.LineTo(400.0, 200.0);
|
||||
path2.LineTo(300.0, 200.0);
|
||||
path2.CloseFigure();
|
||||
|
||||
resultIntersect.StartFigure();
|
||||
resultIntersect.MoveTo(300.0, 300.0);
|
||||
resultIntersect.LineTo(300.0, 200.0);
|
||||
resultIntersect.LineTo(300.0, 300.0);
|
||||
resultIntersect.CloseFigure();
|
||||
|
||||
resultUnite.StartFigure();
|
||||
resultUnite.MoveTo(100.0, 100.0);
|
||||
resultUnite.LineTo(100.0, 300.0);
|
||||
resultUnite.LineTo(300.0, 300.0);
|
||||
resultUnite.LineTo(300.0, 400.0);
|
||||
resultUnite.LineTo(400.0, 400.0);
|
||||
resultUnite.LineTo(400.0, 200.0);
|
||||
resultUnite.LineTo(300.0, 200.0);
|
||||
resultUnite.LineTo(300.0, 100.0);
|
||||
resultUnite.LineTo(100.0, 100.0);
|
||||
resultUnite.CloseFigure();
|
||||
|
||||
resultSubtract.StartFigure();
|
||||
resultSubtract.MoveTo(100.0, 100.0);
|
||||
resultSubtract.LineTo(100.0, 300.0);
|
||||
resultSubtract.LineTo(300.0, 300.0);
|
||||
resultSubtract.LineTo(300.0, 100.0);
|
||||
resultSubtract.LineTo(100.0, 100.0);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, OverlapInside)
|
||||
{
|
||||
Aggplus::CGraphicsPath path1, path2, resultIntersect, resultUnite, resultSubtract;
|
||||
|
||||
path1.StartFigure();
|
||||
path1.MoveTo(100.0, 100.0);
|
||||
path1.LineTo(100.0, 400.0);
|
||||
path1.LineTo(400.0, 400.0);
|
||||
path1.LineTo(400.0, 100.0);
|
||||
path1.LineTo(100.0, 100.0);
|
||||
path1.CloseFigure();
|
||||
|
||||
path2.StartFigure();
|
||||
path2.MoveTo(200.0, 200.0);
|
||||
path2.LineTo(400.0, 200.0);
|
||||
path2.LineTo(400.0, 300.0);
|
||||
path2.LineTo(200.0, 300.0);
|
||||
path2.LineTo(200.0, 200.0);
|
||||
path2.CloseFigure();
|
||||
|
||||
resultIntersect.StartFigure();
|
||||
resultIntersect.MoveTo(400.0, 300.0);
|
||||
resultIntersect.LineTo(400.0, 200.0);
|
||||
resultIntersect.LineTo(200.0, 200.0);
|
||||
resultIntersect.LineTo(200.0, 300.0);
|
||||
resultIntersect.LineTo(400.0, 300.0);
|
||||
resultIntersect.CloseFigure();
|
||||
|
||||
resultUnite.StartFigure();
|
||||
resultUnite.MoveTo(100.0, 100.0);
|
||||
resultUnite.LineTo(100.0, 400.0);
|
||||
resultUnite.LineTo(400.0, 400.0);
|
||||
resultUnite.LineTo(400.0, 100.0);
|
||||
resultUnite.LineTo(100.0, 100.0);
|
||||
resultUnite.CloseFigure();
|
||||
|
||||
resultSubtract.StartFigure();
|
||||
resultSubtract.MoveTo(100.0, 100.0);
|
||||
resultSubtract.LineTo(100.0, 400.0);
|
||||
resultSubtract.LineTo(400.0, 400.0);
|
||||
resultSubtract.LineTo(400.0, 300.0);
|
||||
resultSubtract.LineTo(200.0, 300.0);
|
||||
resultSubtract.LineTo(200.0, 200.0);
|
||||
resultSubtract.LineTo(400.0, 200.0);
|
||||
resultSubtract.LineTo(400.0, 100.0);
|
||||
resultSubtract.LineTo(100.0, 100.0);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, LineIntersLine)
|
||||
{
|
||||
Aggplus::CGraphicsPath path1, path2, resultIntersect, resultUnite, resultSubtract;
|
||||
|
||||
path1.StartFigure();
|
||||
path1.MoveTo(100.0, 100.0);
|
||||
path1.LineTo(100.0, 300.0);
|
||||
path1.LineTo(300.0, 300.0);
|
||||
path1.LineTo(300.0, 100.0);
|
||||
path1.LineTo(100.0, 100.0);
|
||||
path1.CloseFigure();
|
||||
|
||||
path2.StartFigure();
|
||||
path2.MoveTo(200.0, 200.0);
|
||||
path2.LineTo(400.0, 200.0);
|
||||
path2.LineTo(400.0, 400.0);
|
||||
path2.LineTo(200.0, 400.0);
|
||||
path2.LineTo(200.0, 200.0);
|
||||
path2.CloseFigure();
|
||||
|
||||
resultIntersect.StartFigure();
|
||||
resultIntersect.MoveTo(200.0, 300.0);
|
||||
resultIntersect.LineTo(300.0, 300.0);
|
||||
resultIntersect.LineTo(300.0, 200.0);
|
||||
resultIntersect.LineTo(200.0, 200.0);
|
||||
resultIntersect.LineTo(200.0, 300.0);
|
||||
resultIntersect.CloseFigure();
|
||||
|
||||
resultUnite.StartFigure();
|
||||
resultUnite.MoveTo(100.0, 100.0);
|
||||
resultUnite.LineTo(100.0, 300.0);
|
||||
resultUnite.LineTo(200.0, 300.0);
|
||||
resultUnite.LineTo(200.0, 400.0);
|
||||
resultUnite.LineTo(400.0, 400.0);
|
||||
resultUnite.LineTo(400.0, 200.0);
|
||||
resultUnite.LineTo(300.0, 200.0);
|
||||
resultUnite.LineTo(300.0, 100.0);
|
||||
resultUnite.LineTo(100.0, 100.0);
|
||||
resultUnite.CloseFigure();
|
||||
|
||||
resultSubtract.StartFigure();
|
||||
resultSubtract.MoveTo(100.0, 100.0);
|
||||
resultSubtract.LineTo(100.0, 300.0);
|
||||
resultSubtract.LineTo(200.0, 300.0);
|
||||
resultSubtract.LineTo(200.0, 200.0);
|
||||
resultSubtract.LineTo(300.0, 200.0);
|
||||
resultSubtract.LineTo(300.0, 100.0);
|
||||
resultSubtract.LineTo(100.0, 100.0);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, CurveIntersLine)
|
||||
{
|
||||
Aggplus::CGraphicsPath path1, path2, resultIntersect, resultUnite, resultSubtract;
|
||||
|
||||
path1.AddEllipse(-300.0, -300.0, 200.0, 200.0);
|
||||
|
||||
path2.StartFigure();
|
||||
path2.MoveTo(-200.0, -200.0);
|
||||
path2.LineTo(0.0, -200.0);
|
||||
path2.LineTo(0.0, 0.0);
|
||||
path2.LineTo(-200.0, 0.0);
|
||||
path2.LineTo(-200.0, -200.0);
|
||||
path2.CloseFigure();
|
||||
|
||||
resultIntersect.StartFigure();
|
||||
resultIntersect.MoveTo(-100.0, -200.0);
|
||||
resultIntersect.CurveTo(-100.0, -144.772, -144.772, -100.0, -200.0, -100.0);
|
||||
resultIntersect.LineTo(-200.0, -200.0);
|
||||
resultIntersect.LineTo(-100.0, -200.0);
|
||||
resultIntersect.CloseFigure();
|
||||
|
||||
resultUnite.StartFigure();
|
||||
resultUnite.MoveTo(-100.0, -200.0);
|
||||
resultUnite.LineTo(0.0, -200.0);
|
||||
resultUnite.LineTo(0.0, 0.0);
|
||||
resultUnite.LineTo(-200.0, 0.0);
|
||||
resultUnite.LineTo(-200.0, -100.0);
|
||||
resultUnite.CurveTo(-255.228, -100.0, -300.0, -144.772, -300.0, -200.0);
|
||||
resultUnite.CurveTo(-300.0, -255.228, -255.228, -300.0, -200.0, -300.0);
|
||||
resultUnite.CurveTo(-144.772, -300.0, -100.0, -255.228, -100.0, -200.0);
|
||||
resultUnite.CloseFigure();
|
||||
|
||||
resultSubtract.StartFigure();
|
||||
resultSubtract.MoveTo(-100.0, -200.0);
|
||||
resultSubtract.LineTo(-200.0, -200.0);
|
||||
resultSubtract.LineTo(-200.0, -100.0);
|
||||
resultSubtract.CurveTo(-255.228, -100.0, -300.0, -144.772, -300.0, -200.0);
|
||||
resultSubtract.CurveTo(-300.0, -255.228, -255.228, -300.0, -200.0, -300.0);
|
||||
resultSubtract.CurveTo(-144.772, -300.0, -100.0, -255.228, -100.0, -200.0);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, CurveIntersCurve)
|
||||
{
|
||||
Aggplus::CGraphicsPath path1, path2, resultIntersect, resultUnite, resultSubtract;
|
||||
|
||||
path1.AddEllipse(-300.0, -300.0, 200.0, 200.0);
|
||||
|
||||
path2.AddEllipse(-200.0, -200.0, 200.0, 200.0);
|
||||
|
||||
resultIntersect.StartFigure();
|
||||
resultIntersect.MoveTo(-100.0, -200.0);
|
||||
resultIntersect.CurveTo(-100.0, -144.772, -144.772, -100.0, -200.0, -100.0);
|
||||
resultIntersect.CurveTo(-200.0, -155.228, -155.228, -200.0, -100.0, -200.0);
|
||||
resultIntersect.CloseFigure();
|
||||
|
||||
resultUnite.StartFigure();
|
||||
resultUnite.MoveTo(-100.0, -200.0);
|
||||
resultUnite.CurveTo(-44.772, -200.0, 0.0, -155.228, 0.0, -100.0);
|
||||
resultUnite.CurveTo(0.0, -44.772, -44.772, 0.0, -100.0, 0.0);
|
||||
resultUnite.CurveTo(-155.228, 0.0, -200.0, -44.772, -200.0, -100.0);
|
||||
resultUnite.CurveTo(-255.228, -100.0, -300.0, -144.772, -300.0, -200.0);
|
||||
resultUnite.CurveTo(-300.0, -255.228, -255.228, -300.0, -200.0, -300.0);
|
||||
resultUnite.CurveTo(-144.772, -300.0, -100.0, -255.228, -100.0, -200.0);
|
||||
resultUnite.CloseFigure();
|
||||
|
||||
resultSubtract.StartFigure();
|
||||
resultSubtract.MoveTo(-100.0, -200.0);
|
||||
resultSubtract.CurveTo(-155.228, -200.0, -200.0, -155.228, -200.0, -100.0);
|
||||
resultSubtract.CurveTo(-255.228, -100.0, -300.0, -144.772, -300.0, -200.0);
|
||||
resultSubtract.CurveTo(-300.0, -255.228, -255.228, -300.0, -200.0, -300.0);
|
||||
resultSubtract.CurveTo(-144.772, -300.0, -100.0, -255.228, -100.0, -200.0);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
11
DesktopEditor/graphics/tests/booleanPaths/main.cpp
Normal file
11
DesktopEditor/graphics/tests/booleanPaths/main.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
396
DesktopEditor/graphics/tests/booleanPaths/mainwindow.cpp
Normal file
396
DesktopEditor/graphics/tests/booleanPaths/mainwindow.cpp
Normal file
@ -0,0 +1,396 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include <vector>
|
||||
|
||||
CustomLabel::CustomLabel(QWidget *parent) : QLabel(parent)
|
||||
{
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
||||
QPointF CustomLabel::GetStartPoint() const noexcept
|
||||
{
|
||||
return StartP;
|
||||
}
|
||||
|
||||
double CustomLabel::GetDifferenceX() const noexcept
|
||||
{
|
||||
return CurrP.x() - StartP.x();
|
||||
}
|
||||
|
||||
double CustomLabel::GetDifferenceY() const noexcept
|
||||
{
|
||||
return CurrP.y() - StartP.y();
|
||||
}
|
||||
|
||||
bool CustomLabel::GetMovable() const noexcept
|
||||
{
|
||||
return Movable;
|
||||
}
|
||||
|
||||
void CustomLabel::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
StartP = event->pos();
|
||||
Movable = true;
|
||||
emit mousePress();
|
||||
}
|
||||
|
||||
void CustomLabel::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
CurrP = event->pos();
|
||||
Movable = false;
|
||||
emit mousePress();
|
||||
}
|
||||
|
||||
void CustomLabel::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
CurrP = event->pos();
|
||||
emit mouseMove();
|
||||
}
|
||||
|
||||
CustomButton::CustomButton(QWidget *parent) : QPushButton(parent)
|
||||
{
|
||||
}
|
||||
|
||||
BooleanButton::BooleanButton(QWidget *parent) : QPushButton(parent)
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<QObject*> GetChildsByClassName(QObject* parent, const QString& name)
|
||||
{
|
||||
std::vector<QObject*> res;
|
||||
foreach (QObject* child, parent->children())
|
||||
{
|
||||
if (QString(child->metaObject()->className()) == name)
|
||||
res.push_back(child);
|
||||
else
|
||||
{
|
||||
if (!child->children().empty())
|
||||
{
|
||||
std::vector<QObject*> resChilds = GetChildsByClassName(child, name);
|
||||
res.insert(res.end(), resChilds.begin(), resChilds.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
Figure1 = "";
|
||||
Figure2 = "";
|
||||
Op = Aggplus::Intersection;
|
||||
|
||||
std::vector<QObject*> arrPathButtons = GetChildsByClassName(this, "CustomButton");
|
||||
std::vector<QObject*> arrBooleanButtons = GetChildsByClassName(this, "BooleanButton");
|
||||
|
||||
for (std::vector<QObject*>::iterator i = arrPathButtons.begin(); i != arrPathButtons.end(); i++)
|
||||
connect((QPushButton*)(*i), &QPushButton::clicked, this, &MainWindow::SetFigure);
|
||||
|
||||
for (std::vector<QObject*>::iterator i = arrBooleanButtons.begin(); i != arrBooleanButtons.end(); i++)
|
||||
connect((QPushButton*)(*i), &QPushButton::clicked, this, &MainWindow::SetCommand);
|
||||
|
||||
Path1.StartFigure();
|
||||
Path1.MoveTo(100.0, 100.0);
|
||||
Path1.LineTo(150.0, 150.0);
|
||||
Path1.LineTo(200.0, 150.0);
|
||||
Path1.LineTo(100.0, 100.0);
|
||||
Path1.CloseFigure();
|
||||
Path1.MoveTo(300.0, 300.0);
|
||||
Path1.LineTo(400.0, 300.0);
|
||||
Path1.LineTo(400.0, 400.0);
|
||||
Path1.LineTo(300.0, 400.0);
|
||||
Path1.LineTo(300.0, 300.0);
|
||||
Path1.CloseFigure();
|
||||
|
||||
Path2.StartFigure();
|
||||
Path2.MoveTo(100.0, 125.0);
|
||||
Path2.LineTo(100.0, 350.0);
|
||||
Path2.LineTo(350.0, 350.0);
|
||||
Path2.LineTo(350.0, 125.0);
|
||||
Path2.LineTo(100.0, 125.0);
|
||||
Path2.CloseFigure();
|
||||
|
||||
Result = Aggplus::CalcBooleanOperation(Path1, Path2, Aggplus::Intersection);
|
||||
Draw(true);
|
||||
}
|
||||
|
||||
void MainWindow::SetFigure()
|
||||
{
|
||||
QPushButton* sender = (QPushButton*)this->sender();
|
||||
|
||||
if (((QGroupBox*)sender->parentWidget())->title() == "Path1")
|
||||
{
|
||||
Figure1 = sender->text();
|
||||
DrawPath1();
|
||||
}
|
||||
|
||||
if (((QGroupBox*)sender->parentWidget())->title() == "Path2")
|
||||
{
|
||||
Figure2 = sender->text();
|
||||
DrawPath2();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::SetCommand()
|
||||
{
|
||||
QString text = ((QPushButton*)sender())->text();
|
||||
if (text == "Unite")
|
||||
Op = Aggplus::Union;
|
||||
else if (text == "Intersect")
|
||||
Op = Aggplus::Intersection;
|
||||
else
|
||||
Op = Aggplus::Subtraction;
|
||||
|
||||
BooleanOp();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
Aggplus::CGraphicsPath MainWindow::SetPath(double scale, double offsetX, double offsetY, QString Figure)
|
||||
{
|
||||
Aggplus::CGraphicsPath path;
|
||||
|
||||
path.StartFigure();
|
||||
if (Figure == "Rectangle")
|
||||
{
|
||||
path.MoveTo(RECTANGLE[0] + offsetX,
|
||||
RECTANGLE[1] + offsetY);
|
||||
path.LineTo(RECTANGLE[0] + scale * RECTANGLE[2] + offsetX,
|
||||
RECTANGLE[1] + offsetY);
|
||||
path.LineTo(RECTANGLE[0] + scale * RECTANGLE[2] + offsetX,
|
||||
RECTANGLE[1] + scale * RECTANGLE[3] + offsetY);
|
||||
path.LineTo(RECTANGLE[0] + offsetX,
|
||||
RECTANGLE[1] + scale * RECTANGLE[3] + offsetY);
|
||||
path.LineTo(RECTANGLE[0] + offsetX,
|
||||
RECTANGLE[1] + offsetY);
|
||||
}
|
||||
else if (Figure == "Ellipse")
|
||||
{
|
||||
path.AddEllipse(RECTANGLE[0] + offsetX,
|
||||
RECTANGLE[1] + offsetY,
|
||||
scale * RECTANGLE[2],
|
||||
scale * RECTANGLE[3]);
|
||||
}
|
||||
else if (Figure == "Triangle")
|
||||
{
|
||||
path.MoveTo(TRIANGLE[0] + offsetX,
|
||||
TRIANGLE[1] + offsetY);
|
||||
for (size_t i = 2; i < std::size(TRIANGLE); i += 2)
|
||||
path.LineTo(TRIANGLE[0] + scale * TRIANGLE[i] + offsetX,
|
||||
TRIANGLE[1] + scale * TRIANGLE[i + 1] + offsetY);
|
||||
path.LineTo(TRIANGLE[0] + offsetX,
|
||||
TRIANGLE[1] + offsetY);
|
||||
}
|
||||
else if (Figure == "Cross")
|
||||
{
|
||||
path.MoveTo(CROSS[0] + offsetX,
|
||||
CROSS[1] + offsetY);
|
||||
for (size_t i = 2; i < std::size(CROSS); i += 2)
|
||||
path.LineTo(CROSS[0] + scale * CROSS[i] + offsetX,
|
||||
CROSS[1] + scale * CROSS[i + 1] + offsetY);
|
||||
path.LineTo(CROSS[0] + offsetX,
|
||||
CROSS[1] + offsetY);
|
||||
}
|
||||
path.CloseFigure();
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
void MainWindow::AddPath(NSGraphics::IGraphicsRenderer* pathRenderer, const Aggplus::CGraphicsPath& path, bool isResult)
|
||||
{
|
||||
if (path.GetPointCount() == 0)
|
||||
return;
|
||||
|
||||
pathRenderer->PathCommandStart();
|
||||
pathRenderer->BeginCommand(c_nPathType);
|
||||
|
||||
size_t length = path.GetPointCount(),
|
||||
compound = path.GetCloseCount();
|
||||
std::vector<Aggplus::PointD> points = path.GetPoints(0, length + compound);
|
||||
|
||||
for (size_t i = 0; i < length + compound; i++)
|
||||
{
|
||||
if (path.IsCurvePoint(i))
|
||||
{
|
||||
pathRenderer->PathCommandCurveTo(points[i].X + NEGATIVE_OFFSET, points[i].Y + NEGATIVE_OFFSET,
|
||||
points[i + 1].X + NEGATIVE_OFFSET, points[i + 1].Y + NEGATIVE_OFFSET,
|
||||
points[i + 2].X + NEGATIVE_OFFSET, points[i + 2].Y + NEGATIVE_OFFSET);
|
||||
i += 2;
|
||||
}
|
||||
else if (path.IsMovePoint(i))
|
||||
pathRenderer->PathCommandMoveTo(points[i].X + NEGATIVE_OFFSET, points[i].Y + NEGATIVE_OFFSET);
|
||||
else if (path.IsLinePoint(i))
|
||||
pathRenderer->PathCommandLineTo(points[i].X + NEGATIVE_OFFSET, points[i].Y + NEGATIVE_OFFSET);
|
||||
}
|
||||
|
||||
if (isResult)
|
||||
{
|
||||
pathRenderer->put_BrushColor1(0xFF0000);
|
||||
pathRenderer->Fill();
|
||||
}
|
||||
|
||||
pathRenderer->put_PenColor(!isResult ? 0x000000 : 0x0000FF);
|
||||
pathRenderer->DrawPath(c_nStroke);
|
||||
|
||||
pathRenderer->EndCommand(c_nPathType);
|
||||
pathRenderer->PathCommandEnd();
|
||||
}
|
||||
|
||||
void MainWindow::Draw(bool drawResult)
|
||||
{
|
||||
ui->label->clear();
|
||||
|
||||
NSGraphics::IGraphicsRenderer* pathRenderer = NSGraphics::Create();
|
||||
NSFonts::IFontManager* fmp = NSFonts::NSFontManager::Create();
|
||||
pathRenderer->SetFontManager(fmp);
|
||||
|
||||
int nW = ui->label->width();
|
||||
int nH = ui->label->height();
|
||||
|
||||
BYTE* pData = new BYTE[4 * nW * nH];
|
||||
|
||||
CBgraFrame oFrame;
|
||||
oFrame.put_Data(pData);
|
||||
oFrame.put_Width(nW);
|
||||
oFrame.put_Height(nH);
|
||||
oFrame.put_Stride(4 * nW);
|
||||
|
||||
pathRenderer->CreateFromBgraFrame(&oFrame);
|
||||
pathRenderer->SetSwapRGB(true);
|
||||
|
||||
pathRenderer->put_Width(nW);
|
||||
pathRenderer->put_Height(nH);
|
||||
|
||||
AddPath(pathRenderer, Path1);
|
||||
AddPath(pathRenderer, Path2);
|
||||
|
||||
if (drawResult)
|
||||
{
|
||||
AddPath(pathRenderer, Result, true);
|
||||
}
|
||||
|
||||
QImage img = QImage(pData, nW, nH, QImage::Format_RGBA8888, [](void *data){
|
||||
delete [] (BYTE*)data;
|
||||
});
|
||||
ui->label->setPixmap(QPixmap::fromImage(img));
|
||||
}
|
||||
|
||||
void MainWindow::SetCoords(QLabel *label, const Aggplus::CGraphicsPath& path)
|
||||
{
|
||||
size_t length = path.GetPointCount();
|
||||
std::vector<Aggplus::PointD> points = path.GetPoints(0, length);
|
||||
QString text = "";
|
||||
|
||||
for (size_t i = 0; i < length; i++)
|
||||
text += "(" + QString::number(points[i].X) +
|
||||
"; " + QString::number(points[i].Y) + "); ";
|
||||
|
||||
label->setText(text);
|
||||
}
|
||||
|
||||
void MainWindow::DrawPath1()
|
||||
{
|
||||
if (Path1.GetPointCount() > 0) Path1.Reset();
|
||||
Path1 = SetPath(Scale[0], Offsets[0], Offsets[1], Figure1);
|
||||
Draw();
|
||||
SetCoords(ui->label_4, Path1);
|
||||
}
|
||||
|
||||
void MainWindow::DrawPath2()
|
||||
{
|
||||
if (Path2.GetPointCount() > 0) Path2.Reset();
|
||||
Path2 = SetPath(Scale[1], Offsets[2], Offsets[3], Figure2);
|
||||
Draw();
|
||||
SetCoords(ui->label_5, Path2);
|
||||
}
|
||||
|
||||
void MainWindow::BooleanOp()
|
||||
{
|
||||
if (Path1.GetPointCount() == 0 || Path2.GetPointCount() == 0)
|
||||
return;
|
||||
|
||||
Result = Aggplus::CalcBooleanOperation(Path1, Path2, Op);
|
||||
Draw(true);
|
||||
SetCoords(ui->label_7, Result);
|
||||
}
|
||||
|
||||
void MainWindow::CheckMousePress()
|
||||
{
|
||||
if (!ui->label->GetMovable())
|
||||
{
|
||||
Move1 = false;
|
||||
Move2 = false;
|
||||
disconnect(ui->label, SIGNAL(mouseMove()), this, SLOT(Move()));
|
||||
return;
|
||||
}
|
||||
|
||||
QRectF rect1(RECTANGLE[0] + NEGATIVE_OFFSET + Offsets[0],
|
||||
RECTANGLE[1] + NEGATIVE_OFFSET + Offsets[1],
|
||||
Scale[0] * RECTANGLE[2],
|
||||
Scale[0] * RECTANGLE[3]),
|
||||
rect2(RECTANGLE[0] + NEGATIVE_OFFSET + Offsets[2],
|
||||
RECTANGLE[1] + NEGATIVE_OFFSET + Offsets[3],
|
||||
Scale[1] * RECTANGLE[2],
|
||||
Scale[1] * RECTANGLE[3]);
|
||||
|
||||
Move1 = rect1.contains(ui->label->GetStartPoint()) && Path1.GetPointCount() != 0;
|
||||
Move2 = rect2.contains(ui->label->GetStartPoint()) && Path2.GetPointCount() != 0;
|
||||
if (Move2)
|
||||
Move1 = false;
|
||||
if (Move1 || Move2)
|
||||
{
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
OldOffsets[i] = Offsets[i];
|
||||
connect(ui->label, SIGNAL(mouseMove()), this, SLOT(Move()));
|
||||
}
|
||||
}
|
||||
|
||||
inline double CheckOffset(double offset, double min, double max)
|
||||
{
|
||||
return std::max(min, std::min(max, offset));
|
||||
}
|
||||
|
||||
void MainWindow::Move()
|
||||
{
|
||||
if (Move1)
|
||||
{
|
||||
Offsets[0] = CheckOffset(OldOffsets[0] + ui->label->GetDifferenceX(),
|
||||
static_cast<double>(ui->label->x()),
|
||||
static_cast<double>(ui->label->width()));
|
||||
Offsets[1] = CheckOffset(OldOffsets[1] + ui->label->GetDifferenceY(),
|
||||
static_cast<double>(ui->label->y()),
|
||||
static_cast<double>(ui->label->height()));
|
||||
DrawPath1();
|
||||
}
|
||||
if (Move2)
|
||||
{
|
||||
Offsets[2] = CheckOffset(OldOffsets[2] + ui->label->GetDifferenceX(),
|
||||
static_cast<double>(ui->label->x()),
|
||||
static_cast<double>(ui->label->width()));
|
||||
Offsets[3] = CheckOffset(OldOffsets[3] + ui->label->GetDifferenceY(),
|
||||
static_cast<double>(ui->label->y()),
|
||||
static_cast<double>(ui->label->height()));
|
||||
DrawPath2();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_horizontalSlider_sliderMoved(int position)
|
||||
{
|
||||
Scale[0] = position / 100.0;
|
||||
DrawPath1();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_horizontalSlider_2_sliderMoved(int position)
|
||||
{
|
||||
Scale[1] = position / 100.0;
|
||||
DrawPath2();
|
||||
}
|
||||
|
||||
111
DesktopEditor/graphics/tests/booleanPaths/mainwindow.h
Normal file
111
DesktopEditor/graphics/tests/booleanPaths/mainwindow.h
Normal file
@ -0,0 +1,111 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QPoint>
|
||||
#include <QMouseEvent>
|
||||
#include "../../pro/Graphics.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
const double NEGATIVE_OFFSET= 400.0;
|
||||
const double RECTANGLE[4] = {-400.0, -400.0, 200.0, 200.0};
|
||||
const double TRIANGLE[6] = {-300.0, -400.0, 100.0, 200.0, -100.0, 100.0};
|
||||
const double CROSS[24] = {-375.0, -325.0, 50.0, 0.0, 50.0, -50.0,
|
||||
100.0, -50.0, 100.0, 0.0, 150.0, 0.0,
|
||||
150.0, 50.0, 100.0, 50.0, 100.0, 100.0,
|
||||
50.0, 100.0, 50.0, 50.0, 0.0, 50.0};
|
||||
|
||||
class CustomLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CustomLabel(QWidget *parent = nullptr);
|
||||
|
||||
QPointF GetStartPoint() const noexcept;
|
||||
double GetDifferenceX() const noexcept;
|
||||
double GetDifferenceY() const noexcept;
|
||||
bool GetMovable() const noexcept;
|
||||
|
||||
signals:
|
||||
void mousePress();
|
||||
void mouseMove();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
bool Movable = false;
|
||||
QPointF StartP = {0.0, 0.0};
|
||||
QPointF CurrP = {0.0, 0.0};
|
||||
};
|
||||
|
||||
class CustomButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CustomButton(QWidget *parent = nullptr);
|
||||
};
|
||||
|
||||
class BooleanButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BooleanButton(QWidget *parent = nullptr);
|
||||
};
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
Aggplus::CGraphicsPath SetPath(double scale, double offsetX, double offsetY, QString Figure);
|
||||
void AddPath(NSGraphics::IGraphicsRenderer* pathRenderer, const Aggplus::CGraphicsPath& path, bool isResult = false);
|
||||
void Draw(bool drawResult = false);
|
||||
void SetCoords(QLabel* label, const Aggplus::CGraphicsPath& path);
|
||||
|
||||
void DrawPath1();
|
||||
void DrawPath2();
|
||||
void BooleanOp();
|
||||
|
||||
private slots:
|
||||
void CheckMousePress();
|
||||
void Move();
|
||||
void SetCommand();
|
||||
void SetFigure();
|
||||
void on_horizontalSlider_sliderMoved(int position);
|
||||
void on_horizontalSlider_2_sliderMoved(int position);
|
||||
|
||||
public:
|
||||
QString Figure1;
|
||||
QString Figure2;
|
||||
Aggplus::BooleanOpType Op;
|
||||
|
||||
double Scale[2] = {1.0, 1.0};
|
||||
double Offsets[4] = {100.0, 100.0, 200.0, 200.0};
|
||||
double OldOffsets[4];
|
||||
|
||||
bool Move1 = false;
|
||||
bool Move2 = false;
|
||||
|
||||
Aggplus::CGraphicsPath Path1;
|
||||
Aggplus::CGraphicsPath Path2;
|
||||
Aggplus::CGraphicsPath Result;
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
437
DesktopEditor/graphics/tests/booleanPaths/mainwindow.ui
Normal file
437
DesktopEditor/graphics/tests/booleanPaths/mainwindow.ui
Normal file
@ -0,0 +1,437 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1441</width>
|
||||
<height>859</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="CustomLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>800</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>810</x>
|
||||
<y>0</y>
|
||||
<width>610</width>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>191</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Path1</string>
|
||||
</property>
|
||||
<widget class="CustomButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>83</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rectangle</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="CustomButton" name="pushButton_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>80</y>
|
||||
<width>83</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ellipse</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="CustomButton" name="pushButton_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>120</y>
|
||||
<width>83</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Triangle</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>250</y>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Coords:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>270</y>
|
||||
<width>170</width>
|
||||
<height>200</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSlider" name="horizontalSlider">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>230</y>
|
||||
<width>160</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>200</number>
|
||||
</property>
|
||||
<property name="sliderPosition">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>210</y>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Scale:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="CustomButton" name="pushButton_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>160</y>
|
||||
<width>83</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cross</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>10</y>
|
||||
<width>191</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Path2</string>
|
||||
</property>
|
||||
<widget class="CustomButton" name="pushButton_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>83</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rectangle</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="CustomButton" name="pushButton_10">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>80</y>
|
||||
<width>83</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ellipse</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="CustomButton" name="pushButton_12">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>120</y>
|
||||
<width>83</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Triangle</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>250</y>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Coords:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>270</y>
|
||||
<width>170</width>
|
||||
<height>200</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSlider" name="horizontalSlider_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>230</y>
|
||||
<width>160</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>200</number>
|
||||
</property>
|
||||
<property name="sliderPosition">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>210</y>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Scale:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="CustomButton" name="pushButton_9">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>160</y>
|
||||
<width>83</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cross</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>410</x>
|
||||
<y>10</y>
|
||||
<width>191</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Result</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>250</y>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Coords:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>270</y>
|
||||
<width>170</width>
|
||||
<height>200</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="BooleanButton" name="pushButton_15">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>120</y>
|
||||
<width>83</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Subtract</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="BooleanButton" name="pushButton_16">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>80</y>
|
||||
<width>83</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Intersect</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="BooleanButton" name="pushButton_17">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>83</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Unite</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1441</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CustomButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>mainwindow.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BooleanButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>mainwindow.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CustomLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>mainwindow.h</header>
|
||||
<slots>
|
||||
<signal>mousePress()</signal>
|
||||
</slots>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>label</sender>
|
||||
<signal>mousePress()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>CheckMousePress()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>249</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>561</x>
|
||||
<y>276</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>CheckMousePress()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
20
DesktopEditor/graphics/tests/booleanPaths/test.pro
Normal file
20
DesktopEditor/graphics/tests/booleanPaths/test.pro
Normal file
@ -0,0 +1,20 @@
|
||||
QT += core gui widgets
|
||||
|
||||
QMAKE_CXXFLAGS += /permissive-
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
CORE_ROOT_DIR = $$PWD/../../../../../core
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
ADD_DEPENDENCY(kernel, graphics, UnicodeConverter)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
@ -1028,6 +1028,8 @@ l_uint32 *line;
|
||||
pos = (qpos + i) % 8;
|
||||
npx = px + xpostab[pos];
|
||||
npy = py + ypostab[pos];
|
||||
if (npx < 0 || npx >= w || npy < 0 || npy >= h)
|
||||
continue;
|
||||
line = data + npy * wpl;
|
||||
val = GET_DATA_BIT(line, npx);
|
||||
if (val) {
|
||||
|
||||
@ -3228,7 +3228,7 @@ l_int32 i, j, w, h, wplc, wplm, wpld, ncolors, index;
|
||||
l_int32 rval, gval, bval, val, minval, maxval;
|
||||
l_int32 *lut;
|
||||
l_uint32 *datac, *datam, *datad, *linec, *linem, *lined;
|
||||
PIX *pixc, *pixm, *pixg, *pixd;
|
||||
PIX *pix1, *pixc, *pixm, *pixg, *pixd;
|
||||
PIXCMAP *cmap, *cmapd;
|
||||
|
||||
PROCNAME("pixFewColorsOctcubeQuantMixed");
|
||||
@ -3245,8 +3245,10 @@ PIXCMAP *cmap, *cmapd;
|
||||
if (maxspan <= 2) maxspan = 15;
|
||||
|
||||
/* Start with a simple fixed octcube quantizer. */
|
||||
if ((pixc = pixFewColorsOctcubeQuant1(pixs, level)) == NULL)
|
||||
if ((pix1 = pixFewColorsOctcubeQuant1(pixs, level)) == NULL)
|
||||
return (PIX *)ERROR_PTR("too many colors", procName, NULL);
|
||||
pixc = pixConvertTo8(pix1, 1); /* must be 8 bpp */
|
||||
pixDestroy(&pix1);
|
||||
|
||||
/* Identify and save color entries in the colormap. Set up a LUT
|
||||
* that returns -1 for any gray pixel. */
|
||||
|
||||
@ -45,7 +45,7 @@ namespace MetaFile
|
||||
{
|
||||
public:
|
||||
IMetaFileBase()
|
||||
: m_pOutput(NULL), m_pBufferData(NULL), m_bIsExternalBuffer(false), m_bError(false), m_pParent(NULL)
|
||||
: m_pOutput(NULL), m_pParent(NULL), m_pBufferData(NULL), m_bIsExternalBuffer(false), m_bError(false)
|
||||
{
|
||||
m_oStream.SetStream(NULL, 0);
|
||||
}
|
||||
|
||||
@ -1113,4 +1113,58 @@ namespace MetaFile
|
||||
|
||||
return wsValue;
|
||||
}
|
||||
|
||||
std::wstring ConvertToUnicode(const unsigned char* pText, unsigned long unLength, unsigned short uchCharSet)
|
||||
{
|
||||
NSStringExt::CConverter::ESingleByteEncoding eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_DEFAULT;;
|
||||
|
||||
// Соответствие Charset -> Codepage: http://support.microsoft.com/kb/165478
|
||||
// http://msdn.microsoft.com/en-us/library/cc194829.aspx
|
||||
// Charset Name Charset Value(hex) Codepage number
|
||||
// ------------------------------------------------------
|
||||
//
|
||||
// DEFAULT_CHARSET 1 (x01)
|
||||
// SYMBOL_CHARSET 2 (x02)
|
||||
// OEM_CHARSET 255 (xFF)
|
||||
// ANSI_CHARSET 0 (x00) 1252
|
||||
// RUSSIAN_CHARSET 204 (xCC) 1251
|
||||
// EASTEUROPE_CHARSET 238 (xEE) 1250
|
||||
// GREEK_CHARSET 161 (xA1) 1253
|
||||
// TURKISH_CHARSET 162 (xA2) 1254
|
||||
// BALTIC_CHARSET 186 (xBA) 1257
|
||||
// HEBREW_CHARSET 177 (xB1) 1255
|
||||
// ARABIC _CHARSET 178 (xB2) 1256
|
||||
// SHIFTJIS_CHARSET 128 (x80) 932
|
||||
// HANGEUL_CHARSET 129 (x81) 949
|
||||
// GB2313_CHARSET 134 (x86) 936
|
||||
// CHINESEBIG5_CHARSET 136 (x88) 950
|
||||
// THAI_CHARSET 222 (xDE) 874
|
||||
// JOHAB_CHARSET 130 (x82) 1361
|
||||
// VIETNAMESE_CHARSET 163 (xA3) 1258
|
||||
|
||||
switch (uchCharSet)
|
||||
{
|
||||
default:
|
||||
case DEFAULT_CHARSET: eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_DEFAULT; break;
|
||||
case SYMBOL_CHARSET: eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_DEFAULT; break;
|
||||
case ANSI_CHARSET: eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1252; break;
|
||||
case RUSSIAN_CHARSET: eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1251; break;
|
||||
case EASTEUROPE_CHARSET: eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1250; break;
|
||||
case GREEK_CHARSET: eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1253; break;
|
||||
case TURKISH_CHARSET: eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1254; break;
|
||||
case BALTIC_CHARSET: eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1257; break;
|
||||
case HEBREW_CHARSET: eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1255; break;
|
||||
case ARABIC_CHARSET: eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1256; break;
|
||||
case SHIFTJIS_CHARSET: eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP932; break;
|
||||
case HANGEUL_CHARSET: eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP949; break;
|
||||
case 134/*GB2313_CHARSET*/: eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP936; break;
|
||||
case CHINESEBIG5_CHARSET: eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP950; break;
|
||||
case THAI_CHARSET: eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP874; break;
|
||||
case JOHAB_CHARSET: eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1361; break;
|
||||
case VIETNAMESE_CHARSET: eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1258; break;
|
||||
}
|
||||
|
||||
return NSStringExt::CConverter::GetUnicodeFromSingleByteString(pText, unLength, eCharSet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
namespace MetaFile
|
||||
{
|
||||
bool Equals(double dFirst, double dSecond, double dEpsilon = DBL_EPSILON);
|
||||
std::wstring ConvertToUnicode(const unsigned char* pText, unsigned long unLength, unsigned short uchCharSet);
|
||||
|
||||
struct TRgbQuad
|
||||
{
|
||||
|
||||
@ -1167,23 +1167,29 @@ namespace MetaFile
|
||||
|
||||
arNodeAttributes.push_back({L"font-size", ConvertToWString(dFontHeight)});
|
||||
|
||||
std::wstring wsFontName = pFont->GetFaceName();
|
||||
NSStringUtils::CStringBuilder oFontName;
|
||||
oFontName.WriteEncodeXmlString(pFont->GetFaceName());
|
||||
|
||||
#ifndef BUILDING_WASM_MODULE
|
||||
if (!wsFontName.empty())
|
||||
if (0 != oFontName.GetSize())
|
||||
{
|
||||
#ifndef BUILDING_WASM_MODULE
|
||||
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 (NULL != pFontInfo && !StringEquals(*oFormat.wsName, pFontInfo->m_wsFontName))
|
||||
{
|
||||
oFontName.Clear();
|
||||
oFontName.WriteEncodeXmlString(L"\'");
|
||||
oFontName.WriteEncodeXmlString(*oFormat.wsName);
|
||||
oFontName.WriteEncodeXmlString(L"\',\'");
|
||||
oFontName.WriteEncodeXmlString(pFontInfo->m_wsFontName);
|
||||
oFontName.WriteEncodeXmlString(L"\'");
|
||||
}
|
||||
#endif
|
||||
arNodeAttributes.push_back({L"font-family", oFontName.GetData()});
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!wsFontName.empty())
|
||||
arNodeAttributes.push_back({L"font-family", wsFontName});
|
||||
|
||||
if (pFont->GetWeight() > 550)
|
||||
arNodeAttributes.push_back({L"font-weight", L"bold"});
|
||||
@ -1227,7 +1233,7 @@ namespace MetaFile
|
||||
{L"rx", ConvertToWString((oNewRect.Right - oNewRect.Left) / 2)},
|
||||
{L"ry", ConvertToWString((oNewRect.Bottom - oNewRect.Top) / 2)}};
|
||||
AddStroke(arAttributes);
|
||||
AddFill(arAttributes);
|
||||
AddNoneFill(arAttributes);
|
||||
AddTransform(arAttributes);
|
||||
AddClip();
|
||||
|
||||
|
||||
@ -177,7 +177,8 @@ namespace MetaFile
|
||||
|
||||
std::wstring CEmfLogFont::GetFaceName() const
|
||||
{
|
||||
return NSFile::CUtf8Converter::GetWStringFromUTF16(oLogFontEx.oLogFont.ushFaceName, 32);
|
||||
const std::wstring wsFaceName{NSFile::CUtf8Converter::GetWStringFromUTF16(oLogFontEx.oLogFont.ushFaceName, 32)};
|
||||
return wsFaceName.substr(0, wsFaceName.find(L'\0'));
|
||||
}
|
||||
|
||||
int CEmfLogFont::GetWeight() const
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user