mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
198 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 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 | |||
| 9b5f762420 |
@ -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;
|
||||
|
||||
@ -2301,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
|
||||
@ -2395,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
|
||||
@ -2644,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
|
||||
|
||||
@ -656,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;
|
||||
@ -675,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;
|
||||
@ -702,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
|
||||
|
||||
@ -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,8 +173,6 @@ namespace NSDoctRenderer
|
||||
if (NSDirectory::CreateDirectory(sAppDir + L"/docbuilder"))
|
||||
{
|
||||
m_strAllFonts = sAppDir + L"/docbuilder/AllFonts.js";
|
||||
// файл может не существовать пока - и тогда private_GetFile не учтет его
|
||||
bIsAbsoluteFontsPath = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -175,9 +183,6 @@ namespace NSDoctRenderer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bIsAbsoluteFontsPath)
|
||||
m_strAllFonts = private_GetFile(sConfigDir, m_strAllFonts);
|
||||
}
|
||||
|
||||
m_strSdkPath = oNode.ReadNodeText(L"sdkjs");
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -203,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 = []
|
||||
@ -492,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):
|
||||
|
||||
@ -301,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()
|
||||
|
||||
@ -97,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();
|
||||
|
||||
@ -728,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>");
|
||||
@ -1054,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())
|
||||
{
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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>();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,128 @@
|
||||
#include "GraphicsEmbed.h"
|
||||
#include "../graphics.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;
|
||||
|
||||
CGraphicsAppImage_private()
|
||||
{
|
||||
m_pFonts = NULL;
|
||||
m_sFontsDirectory = L"";
|
||||
m_sImagesDirectory = L"";
|
||||
m_sThemesDirectory = L"";
|
||||
m_bIsRgba = false;
|
||||
}
|
||||
~CGraphicsAppImage_private()
|
||||
{
|
||||
RELEASEINTERFACE(m_pFonts);
|
||||
}
|
||||
};
|
||||
|
||||
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()
|
||||
|
||||
@ -1,21 +1,55 @@
|
||||
#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;
|
||||
};
|
||||
|
||||
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"";
|
||||
}
|
||||
|
||||
@ -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,43 @@ 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 = (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 +343,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 +366,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 +402,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 +445,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 +488,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 +560,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 +586,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 +671,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 +1017,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::SaveGrState()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "SaveGrState " << std::endl;
|
||||
#endif
|
||||
CGrStateState* pState = new CGrStateState();
|
||||
@ -1004,7 +1033,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 +1097,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 +1162,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 +1207,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 +1250,7 @@ namespace NSGraphics
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring strImage = (0 == src.find(L"theme") ? m_sApplicationThemesDirectory : m_sApplicationImagesDirectory) + L'/' + src;
|
||||
std::wstring 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 +1260,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 +1273,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 +1283,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 +1322,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 +1330,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 +1338,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 +1354,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 +1370,7 @@ namespace NSGraphics
|
||||
}
|
||||
double CGraphics::GetlineWidth()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "GetlineWidth " << std::endl;
|
||||
#endif
|
||||
double nRes;
|
||||
@ -1350,7 +1379,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 +1392,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);
|
||||
|
||||
@ -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++;
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "BooleanOperations.h"
|
||||
#include "boolean_operations_math.h"
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
namespace Aggplus {
|
||||
Segment::Segment() noexcept
|
||||
@ -248,9 +249,9 @@ double Curve::GetTimeAt(const double& offset) const noexcept
|
||||
double a = forward ? start : 0,
|
||||
b = forward ? 1 : start,
|
||||
rangeLength = GetLength(a, b),
|
||||
diff = abs(offset) - rangeLength;
|
||||
diff = fabs(offset) - rangeLength;
|
||||
|
||||
if (abs(diff) < EPSILON)
|
||||
if (fabs(diff) < EPSILON)
|
||||
return forward ? b : a;
|
||||
else if (diff > EPSILON)
|
||||
return MIN;
|
||||
@ -311,8 +312,8 @@ PointD Curve::Get(const double& t, const int& type) const noexcept
|
||||
}
|
||||
else if (t > tMax)
|
||||
{
|
||||
x0 = 3 * (x[3] - y[2]);
|
||||
y0 = 3 * (y[3] - x[2]);
|
||||
x0 = 3 * (x[3] - x[2]);
|
||||
y0 = 3 * (y[3] - y[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -368,7 +369,7 @@ Curve Curve::GetPart(double from, double to) const noexcept
|
||||
result.Segment2.HO.X -= result.Segment2.P.X;
|
||||
result.Segment2.HO.Y -= result.Segment2.P.Y;
|
||||
}
|
||||
else if (to < 1)
|
||||
if (to < 1)
|
||||
{
|
||||
result = result.Subdivide((to - from) / (1 - from))[0];
|
||||
result.Segment2.HI.X -= result.Segment2.P.X;
|
||||
@ -447,8 +448,8 @@ std::vector<std::pair<double, double>> Curve::GetOverlaps(const Curve& curve) co
|
||||
: std::pair<double, double>(t2, t1);
|
||||
if (pairs.empty())
|
||||
pairs.push_back(pair);
|
||||
else if (abs(pair.first - pairs[0].first) > TIME_EPSILON &&
|
||||
abs(pair.second - pairs[0].second) > TIME_EPSILON)
|
||||
else if (fabs(pair.first - pairs[0].first) > TIME_EPSILON &&
|
||||
fabs(pair.second - pairs[0].second) > TIME_EPSILON)
|
||||
pairs.push_back(pair);
|
||||
}
|
||||
|
||||
@ -463,10 +464,10 @@ std::vector<std::pair<double, double>> Curve::GetOverlaps(const Curve& curve) co
|
||||
Curve o1 = GetPart(pairs[0].first, pairs[1].first),
|
||||
o2 = curve.GetPart(pairs[0].second, pairs[1].second);
|
||||
|
||||
double dox = abs(o2.Segment2.HO.X - o1.Segment2.HO.X),
|
||||
doy = abs(o2.Segment2.HO.Y - o1.Segment2.HO.Y),
|
||||
dix = abs(o2.Segment2.HI.X - o1.Segment2.HI.X),
|
||||
diy = abs(o2.Segment2.HI.Y - o1.Segment2.HI.Y);
|
||||
double dox = fabs(o2.Segment2.HO.X - o1.Segment2.HO.X),
|
||||
doy = fabs(o2.Segment2.HO.Y - o1.Segment2.HO.Y),
|
||||
dix = fabs(o2.Segment2.HI.X - o1.Segment2.HI.X),
|
||||
diy = fabs(o2.Segment2.HI.Y - o1.Segment2.HI.Y);
|
||||
|
||||
if (dox > GEOMETRIC_EPSILON ||
|
||||
doy > GEOMETRIC_EPSILON ||
|
||||
@ -577,9 +578,9 @@ int Curve::SolveCubic(double a, double b, double c, double d,
|
||||
std::vector<double>& roots, const double& mn, const double& mx) const noexcept
|
||||
{
|
||||
int count = 0;
|
||||
double f = max(abs(a), abs(b), abs(c), abs(d));
|
||||
double f = max(fabs(a), fabs(b), fabs(c), fabs(d));
|
||||
double x, b1, c2, qd, q;
|
||||
if (f < 1e-8 || f > 1e8)
|
||||
if (f != 0 && (f < 1e-8 || f > 1e8))
|
||||
{
|
||||
f = pow(2, -round(log2(f)));
|
||||
a *= f;
|
||||
@ -588,14 +589,14 @@ int Curve::SolveCubic(double a, double b, double c, double d,
|
||||
d *= f;
|
||||
}
|
||||
|
||||
if (abs(a) < EPSILON)
|
||||
if (fabs(a) < EPSILON)
|
||||
{
|
||||
a = b;
|
||||
b1 = c;
|
||||
c2 = d;
|
||||
x = MAX;
|
||||
}
|
||||
else if (abs(d) <EPSILON)
|
||||
else if (fabs(d) <EPSILON)
|
||||
{
|
||||
b1 = b;
|
||||
c2 = c;
|
||||
@ -610,7 +611,7 @@ int Curve::SolveCubic(double a, double b, double c, double d,
|
||||
q = c2 * x + d;
|
||||
|
||||
double t = q / a,
|
||||
r = pow(abs(t), 1 / 3),
|
||||
r = pow(fabs(t), 1 / 3),
|
||||
s = t < 0 ? -1 : 1,
|
||||
td = -qd / a,
|
||||
rd = td > 0 ? 1.324717957244746 * std::max(r, sqrt(td)) : r,
|
||||
@ -628,7 +629,7 @@ int Curve::SolveCubic(double a, double b, double c, double d,
|
||||
x0 = qd == 0 ? x : x - q / qd / (1 + MACHINE_EPSILON);
|
||||
} while (s * x0 > s * x);
|
||||
|
||||
if (abs(a) * x * x > abs(d / x))
|
||||
if (fabs(a) * x * x > fabs(d / x))
|
||||
{
|
||||
c2 = -d / x;
|
||||
b1 = (c2 - c) / x;
|
||||
@ -652,8 +653,11 @@ int Curve::SolveCubic(double a, double b, double c, double d,
|
||||
|
||||
void Curve::Flip() noexcept
|
||||
{
|
||||
PointD tmpHI = Segment2.P + Segment2.HI;
|
||||
PointD tmpHO = Segment2.P + Segment2.HO;
|
||||
std::swap(Segment1.P, Segment2.P);
|
||||
std::swap(Segment1.HI, Segment1.HO);
|
||||
Segment2.HI = tmpHI - Segment2.P;
|
||||
Segment2.HO = tmpHO - Segment2.P;
|
||||
}
|
||||
|
||||
bool Curve::IsStraight() const noexcept
|
||||
@ -706,12 +710,14 @@ bool Location::IsTouching() noexcept
|
||||
|
||||
CBooleanOperations::CBooleanOperations(const CGraphicsPath& path1,
|
||||
const CGraphicsPath& path2,
|
||||
BooleanOpType op) :
|
||||
BooleanOpType op,
|
||||
long fillType) :
|
||||
Op(op),
|
||||
Close1(path1.Is_poly_closed()),
|
||||
Close2(path2.Is_poly_closed()),
|
||||
Path1(path1),
|
||||
Path2(path2)
|
||||
Path2(path2),
|
||||
FillType(fillType)
|
||||
{
|
||||
TraceBoolean();
|
||||
}
|
||||
@ -741,9 +747,7 @@ void CBooleanOperations::TraceBoolean()
|
||||
|
||||
GetIntersection();
|
||||
|
||||
if (Locations.empty())
|
||||
SetWinding();
|
||||
else
|
||||
if (!Locations.empty())
|
||||
{
|
||||
int length = static_cast<int>(Locations.size());
|
||||
for (int i = 0; i < length; i++)
|
||||
@ -771,31 +775,9 @@ void CBooleanOperations::TraceBoolean()
|
||||
TraceAllOverlap();
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& l : Locations)
|
||||
{
|
||||
Segment start = l->S,
|
||||
s = GetNextSegment(l->S);
|
||||
|
||||
if (s.IsEmpty() || s.Inters || s == start)
|
||||
continue;
|
||||
|
||||
int count = 0,
|
||||
touchCount = 0;
|
||||
for (const auto& c : (s.Id == 1 ? OriginCurves2 : OriginCurves1))
|
||||
count += CheckInters(MIN_POINT, s, c, touchCount);
|
||||
|
||||
do
|
||||
{
|
||||
if (s.Id == 1 )
|
||||
Segments1[s.Index].Winding = count % 2;
|
||||
else
|
||||
Segments2[s.Index].Winding = count % 2;
|
||||
s = GetNextSegment(s);
|
||||
} while (!s.IsEmpty() && !s.Inters && s != start);
|
||||
}
|
||||
}
|
||||
|
||||
SetWinding();
|
||||
TracePaths();
|
||||
}
|
||||
|
||||
@ -1065,12 +1047,12 @@ void CBooleanOperations::PreparePath(const CGraphicsPath& path, int id,
|
||||
bool reverse)
|
||||
{
|
||||
bool isPolyClosed = path.Is_poly_closed();
|
||||
int length = isPolyClosed ? (path.GetPointCount() - 1) : path.GetPointCount();
|
||||
int length = path.GetPointCount();
|
||||
int idx = 0;
|
||||
if (reverse)
|
||||
{
|
||||
bool isCurve = false;
|
||||
for (int i = length; i > 0; i--)
|
||||
for (int i = length - 1; i >= 0; i--)
|
||||
{
|
||||
std::vector<PointD> points = path.GetPoints(isCurve ? i - 2 : i, isCurve ? 3 : 1);
|
||||
if (isCurve) std::reverse(points.begin(), points.end());
|
||||
@ -1110,13 +1092,13 @@ void CBooleanOperations::PreparePath(const CGraphicsPath& path, int id,
|
||||
}
|
||||
}
|
||||
|
||||
length = segments.size();
|
||||
length = isPolyClosed ? static_cast<int>(segments.size()) : static_cast<int>(segments.size()) - 1;
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
curves.push_back(Curve(segments[i], i == (length - 1) ? segments[0] : segments[i + 1]));
|
||||
curves.push_back(Curve(segments[i], isPolyClosed && (i == (length - 1)) ? segments[0] : segments[i + 1]));
|
||||
}
|
||||
|
||||
void CBooleanOperations::InsertSegment(const Segment& segment, const Segment& handles, bool updateHandles)
|
||||
void CBooleanOperations::InsertSegment(Segment& segment, const Segment& handles, bool updateHandles)
|
||||
{
|
||||
if (segment.Id == 1)
|
||||
{
|
||||
@ -1124,6 +1106,7 @@ void CBooleanOperations::InsertSegment(const Segment& segment, const Segment& ha
|
||||
index = segment.Index == length ? 0 : segment.Index;
|
||||
if (getDistance(segment.P, Segments1[index].P) <= GEOMETRIC_EPSILON)
|
||||
{
|
||||
segment.Index = index;
|
||||
Segments1[index] = segment;
|
||||
return;
|
||||
}
|
||||
@ -1147,6 +1130,7 @@ void CBooleanOperations::InsertSegment(const Segment& segment, const Segment& ha
|
||||
index = segment.Index == length ? 0 : segment.Index;
|
||||
if (getDistance(segment.P, Segments2[index].P) <= GEOMETRIC_EPSILON)
|
||||
{
|
||||
segment.Index = index;
|
||||
Segments2[index] = segment;
|
||||
return;
|
||||
}
|
||||
@ -1261,7 +1245,8 @@ std::vector<std::vector<int>> CBooleanOperations::FindBoundsCollisions()
|
||||
|
||||
std::vector<std::vector<double>> allBounds(bounds1);
|
||||
if (!self)
|
||||
std::copy(bounds2.begin(), bounds2.end(), std::back_inserter(allBounds));
|
||||
for (auto it = bounds2.begin(); it != bounds2.end(); ++it) // std::copy(bounds2.begin(), bounds2.end(), std::back_inserter(allBounds));
|
||||
allBounds.push_back(*it);
|
||||
|
||||
int allLength = static_cast<int>(allBounds.size()),
|
||||
length1 = static_cast<int>(bounds1.size());
|
||||
@ -1539,7 +1524,7 @@ void CBooleanOperations::AddCurveLineIntersection(const Curve& curve1, const Cur
|
||||
}
|
||||
}
|
||||
|
||||
int CBooleanOperations::AddCurveIntersection(Curve curve1, Curve curve2, const Curve& startCurve1,
|
||||
int CBooleanOperations::AddCurveIntersection(const Curve& curve1, const Curve& curve2, const Curve& startCurve1,
|
||||
const Curve& startCurve2, bool flip,
|
||||
int recursion, int calls, double tMin,
|
||||
double tMax, double uMin, double uMax)
|
||||
@ -1562,9 +1547,9 @@ int CBooleanOperations::AddCurveIntersection(Curve curve1, Curve curve2, const C
|
||||
dp2 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[2], y1[2]),
|
||||
dp3 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[3], y1[3]);
|
||||
|
||||
std::vector<std::vector<PointD>> hull = getConvexHull(dp0, dp1, dp2, dp3);
|
||||
std::vector<PointD> top = hull[0],
|
||||
bottom = hull[1];
|
||||
std::vector<PointD> top;
|
||||
std::vector<PointD> bottom;
|
||||
getConvexHull(dp0, dp1, dp2, dp3, top, bottom);
|
||||
|
||||
double tMinClip = clipConvexHull(top, bottom, dMin, dMax);
|
||||
|
||||
@ -1595,14 +1580,14 @@ int CBooleanOperations::AddCurveIntersection(Curve curve1, Curve curve2, const C
|
||||
}
|
||||
else
|
||||
{
|
||||
curve1 = curve1.GetPart(tMinClip, tMaxClip);
|
||||
Curve newCurve1 = curve1.GetPart(tMinClip, tMaxClip);
|
||||
double uDiff = uMax - uMin;
|
||||
|
||||
if (tMaxClip - tMinClip > 0.8)
|
||||
{
|
||||
if (tMaxNew - tMinNew > uDiff)
|
||||
{
|
||||
std::vector<Curve> parts = curve1.Subdivide(0.5);
|
||||
std::vector<Curve> parts = newCurve1.Subdivide(0.5);
|
||||
double t = (tMinNew + tMaxNew) / 2;
|
||||
|
||||
parts[0].Segment2.SetHandles(parts[0].Segment2.HI, parts[0].Segment2.HO);
|
||||
@ -1621,19 +1606,19 @@ int CBooleanOperations::AddCurveIntersection(Curve curve1, Curve curve2, const C
|
||||
parts[0].Segment2.SetHandles(parts[0].Segment2.HI, parts[0].Segment2.HO);
|
||||
parts[1].Segment2.SetHandles(parts[1].Segment2.HI, parts[1].Segment2.HO);
|
||||
|
||||
calls = AddCurveIntersection(parts[0], curve1, startCurve2, startCurve1,
|
||||
calls = AddCurveIntersection(parts[0], newCurve1, startCurve2, startCurve1,
|
||||
!flip, recursion, calls, uMin, u, tMinNew, tMaxNew);
|
||||
calls = AddCurveIntersection(parts[1], curve1, startCurve2, startCurve1,
|
||||
calls = AddCurveIntersection(parts[1], newCurve1, startCurve2, startCurve1,
|
||||
!flip, recursion, calls, u, uMax, tMinNew, tMaxNew);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (uDiff == 0 || uDiff >= LINE_EPSILON)
|
||||
calls = AddCurveIntersection(curve2, curve1, startCurve2, startCurve1,
|
||||
calls = AddCurveIntersection(curve2, newCurve1, startCurve2, startCurve1,
|
||||
!flip, recursion, calls, uMin, uMax, tMinNew, tMaxNew);
|
||||
else
|
||||
calls = AddCurveIntersection(curve1, curve2, startCurve1, startCurve2,
|
||||
calls = AddCurveIntersection(newCurve1, curve2, startCurve1, startCurve2,
|
||||
flip, recursion, calls, tMinNew, tMaxNew, uMin, uMax);
|
||||
}
|
||||
}
|
||||
@ -1646,14 +1631,12 @@ int CBooleanOperations::CheckInters(const PointD& point, const Segment& segment,
|
||||
PointD pt{};
|
||||
if (intersect({point.X, point.Y, segment.P.X, segment.P.Y, curve.Segment1.P.X, curve.Segment1.P.Y, curve.Segment2.P.X, curve.Segment2.P.Y}, pt))
|
||||
{
|
||||
if (getDistance(segment.P, pt) <= GEOMETRIC_EPSILON) return (touchCount + 1) % 2;
|
||||
if (getDistance(curve.Segment1.P, pt) <= GEOMETRIC_EPSILON || getDistance(curve.Segment2.P, pt) <= GEOMETRIC_EPSILON)
|
||||
{
|
||||
int tmp = touchCount % 2;
|
||||
touchCount++;
|
||||
return tmp;
|
||||
}
|
||||
return ++touchCount % 2;
|
||||
else if (curve.IsStraight())
|
||||
{
|
||||
touchCount++;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -1674,31 +1657,63 @@ int CBooleanOperations::CheckInters(const PointD& point, const Segment& segment,
|
||||
|
||||
void CBooleanOperations::SetWinding()
|
||||
{
|
||||
Segment s1, s2;
|
||||
if (Locations.empty() || (Locations.size() == 2 && Locations[0]->Ends))
|
||||
{
|
||||
Segment s1, s2;
|
||||
|
||||
for (const auto& s : Segments1)
|
||||
if (!s.Inters)
|
||||
s1 = s;
|
||||
for (const auto& s : Segments1)
|
||||
if (!s.Inters)
|
||||
s1 = s;
|
||||
|
||||
for (const auto& s : Segments2)
|
||||
if (!s.Inters)
|
||||
s2 = s;
|
||||
for (const auto& s : Segments2)
|
||||
if (!s.Inters)
|
||||
s2 = s;
|
||||
|
||||
int count = 0,
|
||||
int count = 0,
|
||||
touchCount = 0;
|
||||
for (const auto& c : OriginCurves2)
|
||||
count += CheckInters(MIN_POINT, s1, c, touchCount);
|
||||
|
||||
for (auto& s : Segments1)
|
||||
s.Winding = count % 2;
|
||||
|
||||
count = 0;
|
||||
touchCount = 0;
|
||||
for (const auto& c : OriginCurves2)
|
||||
count += CheckInters(MIN_POINT, s1, c, touchCount);
|
||||
for (const auto& c : OriginCurves1)
|
||||
count += CheckInters(MIN_POINT, s2, c, touchCount);
|
||||
|
||||
for (auto& s : Segments1)
|
||||
s.Winding = count % 2;
|
||||
for (auto& s : Segments2)
|
||||
s.Winding = count % 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const auto& l : Locations)
|
||||
{
|
||||
Segment start = l->S,
|
||||
s = GetNextSegment(l->S);
|
||||
|
||||
count = 0;
|
||||
touchCount = 0;
|
||||
for (const auto& c : OriginCurves1)
|
||||
count += CheckInters(MIN_POINT, s2, c, touchCount);
|
||||
if (s.IsEmpty() || s.Inters || s == start)
|
||||
continue;
|
||||
|
||||
for (auto& s : Segments2)
|
||||
s.Winding = count % 2;
|
||||
int count = 0,
|
||||
touchCount = 0;
|
||||
for (const auto& c : (s.Id == 1 ? OriginCurves2 : OriginCurves1))
|
||||
count += CheckInters(MIN_POINT, s, c, touchCount);
|
||||
|
||||
do
|
||||
{
|
||||
if (s.Id == 1 )
|
||||
Segments1[s.Index].Winding = count % 2;
|
||||
else
|
||||
Segments2[s.Index].Winding = count % 2;
|
||||
s = GetNextSegment(s);
|
||||
} while (!s.IsEmpty() && !s.Inters && s != start);
|
||||
}
|
||||
}
|
||||
|
||||
if (FillType & c_nStroke)
|
||||
for (auto& s : Segments2)
|
||||
s.Winding = 0;
|
||||
}
|
||||
|
||||
void CBooleanOperations::DivideLocations()
|
||||
@ -1890,7 +1905,8 @@ void CBooleanOperations::AddOffsets(std::vector<double>& offsets,
|
||||
|
||||
CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
|
||||
const CGraphicsPath& path2,
|
||||
BooleanOpType op)
|
||||
BooleanOpType op,
|
||||
long fillType)
|
||||
{
|
||||
std::vector<CGraphicsPath> paths1 = path1.GetSubPaths(),
|
||||
paths2 = path2.GetSubPaths(),
|
||||
@ -1900,7 +1916,7 @@ CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
|
||||
{
|
||||
for (const auto& p2 : paths2)
|
||||
{
|
||||
CBooleanOperations operation(p1, p2, op);
|
||||
CBooleanOperations operation(p1, p2, op, fillType);
|
||||
paths.push_back(operation.GetResult());
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ namespace Aggplus
|
||||
class CBooleanOperations
|
||||
{
|
||||
public:
|
||||
CBooleanOperations(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op);
|
||||
CBooleanOperations(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op, long fillType = c_nWindingFillMode);
|
||||
~CBooleanOperations();
|
||||
CGraphicsPath&& GetResult();
|
||||
|
||||
@ -120,7 +120,7 @@ namespace Aggplus
|
||||
// Path
|
||||
void PreparePath(const CGraphicsPath& path, int id, std::vector<Segment>& segments,
|
||||
std::vector<Curve>& curves, bool reverse = false);
|
||||
void InsertSegment(const Segment& segment, const Segment& handles, bool updateHandles);
|
||||
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;
|
||||
@ -140,7 +140,7 @@ namespace Aggplus
|
||||
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(Curve curve1, Curve curve2, const Curve& startCurve1, const Curve& startCurve2, 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();
|
||||
@ -159,6 +159,9 @@ namespace Aggplus
|
||||
bool Close1 = true;
|
||||
bool Close2 = true;
|
||||
|
||||
// c_nStroke, c_nWindingFillMode, c_nEvenOddFillMode
|
||||
long FillType = c_nWindingFillMode;
|
||||
|
||||
CGraphicsPath Path1;
|
||||
CGraphicsPath Path2;
|
||||
CGraphicsPath Result;
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -76,7 +76,7 @@ namespace Aggplus
|
||||
j += 2;
|
||||
}
|
||||
}
|
||||
CloseFigure();
|
||||
if (p.Is_poly_closed()) CloseFigure();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,7 +189,7 @@ namespace Aggplus
|
||||
Exclusion = 3
|
||||
};
|
||||
|
||||
GRAPHICS_DECL CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op);
|
||||
GRAPHICS_DECL CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op, long fillType = c_nWindingFillMode);
|
||||
|
||||
} // namespace Aggplus
|
||||
|
||||
|
||||
@ -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 )
|
||||
|
||||
@ -18,7 +18,7 @@ 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(-500.0, -500.0);
|
||||
const Aggplus::PointD MIN_POINT = Aggplus::PointD(-100000.0, -100000.0);
|
||||
|
||||
const std::vector<double> ABSCISSAS[16] = {
|
||||
{0.5773502691896257645091488},
|
||||
@ -124,14 +124,14 @@ inline double clamp(const double& value, const double& mn, const double& mx)
|
||||
|
||||
inline bool isCollinear(const Aggplus::PointD& p1, const Aggplus::PointD& p2)
|
||||
{
|
||||
return abs(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;
|
||||
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(abs(b - a) * 32)));
|
||||
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,
|
||||
@ -180,7 +180,7 @@ double findRoot(double& length, double& start, const double& offset, const doubl
|
||||
dx = fx / CurveLength(x, ax, bx, cx, ay, by, cy),
|
||||
nx = x - dx;
|
||||
|
||||
if (abs(dx) < EPSILON)
|
||||
if (fabs(dx) < EPSILON)
|
||||
{
|
||||
x = nx;
|
||||
break;
|
||||
@ -229,8 +229,10 @@ bool intersect(std::vector<double> v, Aggplus::PointD& res)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::vector<Aggplus::PointD>> getConvexHull(const double& dq0, const double& dq1,
|
||||
const double& dq2, const double& dq3)
|
||||
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),
|
||||
@ -240,27 +242,59 @@ std::vector<std::vector<Aggplus::PointD>> getConvexHull(const double& dq0, const
|
||||
double dist1 = dq1 - (2.0 * dq0 + dq3) / 3.0,
|
||||
dist2 = dq2 - (dq0 + 2.0 * dq3) / 3.0;
|
||||
|
||||
std::vector<std::vector<Aggplus::PointD>> hull;
|
||||
|
||||
if (dist1 * dist2 < 0.0)
|
||||
{
|
||||
hull = {{p0, p1, p3}, {p0, p2, p3}};
|
||||
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)
|
||||
hull = {{p0, p1, p3}, {p0, p3}};
|
||||
{
|
||||
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)
|
||||
hull = {{p0, p2, p3}, {p0, p3}};
|
||||
{
|
||||
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
|
||||
hull = {{p0, p1, p2, p3}, {p0, p3}};
|
||||
{
|
||||
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::reverse(hull.begin(), hull.end());
|
||||
|
||||
return hull;
|
||||
std::swap(top, bottom);
|
||||
}
|
||||
|
||||
double clipConvexHullPart(const std::vector<Aggplus::PointD>& part, const bool& top,
|
||||
@ -340,7 +374,7 @@ inline double getSignedDistance(const double& px, const double& py, double vx, d
|
||||
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 abs(getSignedDistance(px, py, vx, vy, x, y, 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,
|
||||
@ -394,7 +428,7 @@ inline double getDiscriminant(const double& a, const double& b, const double& c)
|
||||
double D = b * b - a * c,
|
||||
E = b * b + a * c;
|
||||
|
||||
if (abs(D) * 3 < E)
|
||||
if (fabs(D) * 3 < E)
|
||||
{
|
||||
std::pair<double, double> ad = split(a),
|
||||
bd = split(b),
|
||||
@ -420,10 +454,10 @@ int solveQuadratic(double a, double b, double c, std::vector<double>& roots,
|
||||
const double& mn, const double& mx)
|
||||
{
|
||||
double x1 = MAX, x2 = MAX;
|
||||
if (abs(a) < EPSILON)
|
||||
if (fabs(a) < EPSILON)
|
||||
{
|
||||
if (abs(b) < EPSILON)
|
||||
return abs(c) < EPSILON ? -1 : 0;
|
||||
if (fabs(b) < EPSILON)
|
||||
return fabs(c) < EPSILON ? -1 : 0;
|
||||
x1 = -c / b;
|
||||
}
|
||||
else
|
||||
@ -431,10 +465,10 @@ int solveQuadratic(double a, double b, double c, std::vector<double>& roots,
|
||||
b *= -0.5;
|
||||
|
||||
double D = getDiscriminant(a, b, c);
|
||||
if (D != 0 && abs(D) < MACHINE_EPSILON)
|
||||
if (D != 0 && fabs(D) < MACHINE_EPSILON)
|
||||
{
|
||||
double f = max(abs(a), abs(b), abs(c));
|
||||
if (f < 1e-8 || f < 1e8)
|
||||
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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -59,7 +59,8 @@ SOURCES += \
|
||||
|
||||
# alpha mask
|
||||
HEADERS += \
|
||||
./../AlphaMask.h
|
||||
./../AlphaMask.h \
|
||||
./../AlphaMask_p.h
|
||||
|
||||
SOURCES += \
|
||||
./../AlphaMask.cpp
|
||||
|
||||
@ -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()
|
||||
@ -236,14 +236,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 +491,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)
|
||||
{
|
||||
@ -1370,14 +1377,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();
|
||||
|
||||
@ -1435,6 +1445,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)
|
||||
{
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
|
||||
@ -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)
|
||||
@ -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);
|
||||
|
||||
@ -468,6 +468,20 @@ namespace NSStructures
|
||||
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;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -454,60 +454,10 @@ namespace MetaFile
|
||||
return SetError();
|
||||
|
||||
const IFont* pFont = GetFont();
|
||||
NSStringExt::CConverter::ESingleByteEncoding eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_DEFAULT;
|
||||
if (pFont)
|
||||
{
|
||||
// Соответствие 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 (pFont->GetCharSet())
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring wsText = NSStringExt::CConverter::GetUnicodeFromSingleByteString((unsigned char*)oText.pOutputString, oText.unChars, eCharSet);
|
||||
std::wstring wsText = ConvertToUnicode(oText.pOutputString, oText.unChars, (NULL != pFont) ? pFont->GetCharSet() : DEFAULT_CHARSET);
|
||||
|
||||
int* pDx = NULL;
|
||||
if (oText.pOutputDx)
|
||||
if (oText.pOutputDx && oText.unChars == wsText.length())
|
||||
{
|
||||
pDx = new int[oText.unChars];
|
||||
if (pDx)
|
||||
@ -538,7 +488,7 @@ namespace MetaFile
|
||||
|
||||
unsigned int unLen = 0;
|
||||
int* pDx = NULL;
|
||||
if (oText.pOutputDx && oText.unChars)
|
||||
if (oText.pOutputDx && oText.unChars && oText.unChars == wsText.length())
|
||||
{
|
||||
// Здесь мы эмулируем конвертацию Utf16 в Utf32, чтобы правильно получить массив pDx
|
||||
pDx = new int[oText.unChars];
|
||||
|
||||
@ -177,7 +177,8 @@ namespace MetaFile
|
||||
: m_bBanEmfProcessing(true),
|
||||
m_unLogicalDpiX(96),
|
||||
m_unLogicalDpiY(96),
|
||||
m_dUnitKoef(1)
|
||||
m_dPageTransformX(1.),
|
||||
m_dPageTransformY(1.)
|
||||
{
|
||||
m_oHeader = oHeader;
|
||||
|
||||
@ -1370,16 +1371,19 @@ namespace MetaFile
|
||||
UpdateOutputDC();
|
||||
}
|
||||
|
||||
void CEmfPlusParser::UpdateMatrix(TEmfPlusXForm &oMatrix)
|
||||
double CEmfPlusParser::GetUnitToPixel(const double& dDpi, EEmfPlusUnitType eUnitType) const
|
||||
{
|
||||
const double dKoef{m_dUnitKoef * (m_unLogicalDpiX / 96)};
|
||||
|
||||
oMatrix.M11 *= dKoef;
|
||||
oMatrix.M12 *= dKoef;
|
||||
oMatrix.M21 *= dKoef;
|
||||
oMatrix.M22 *= dKoef;
|
||||
oMatrix.Dx *= dKoef;
|
||||
oMatrix.Dy *= dKoef;
|
||||
switch (eUnitType)
|
||||
{
|
||||
case UnitTypePixel:
|
||||
case UnitTypeWorld:
|
||||
case UnitTypeDisplay:
|
||||
default: return 1.;
|
||||
case UnitTypePoint: return dDpi / 72.;
|
||||
case UnitTypeInch: return dDpi;
|
||||
case UnitTypeDocument: return dDpi / 300.;
|
||||
case UnitTypeMillimeter: return dDpi / 25.4;
|
||||
}
|
||||
}
|
||||
|
||||
bool CEmfPlusParser::SaveImage(const CEmfPlusImage &oEmfPlusImage, std::wstring &wsPathToImage)
|
||||
@ -1412,47 +1416,50 @@ namespace MetaFile
|
||||
return true;
|
||||
}
|
||||
|
||||
BYTE* GetClipedImage(const BYTE* pBuffer, LONG lWidth, LONG lHeight, TRectL& oNewRect)
|
||||
BYTE* GetClipedImage(const BYTE* pBuffer, LONG lWidth, LONG lHeight, const TRectL& oNewRect, unsigned int& nWidth, unsigned int& nHeight)
|
||||
{
|
||||
if (NULL == pBuffer ||
|
||||
oNewRect.Left < 0 || oNewRect.Right < 0 ||
|
||||
oNewRect.Top < 0 || oNewRect.Bottom < 0)
|
||||
if (NULL == pBuffer)
|
||||
return NULL;
|
||||
|
||||
if (lHeight < (oNewRect.Bottom - oNewRect.Top))
|
||||
oNewRect.Bottom = oNewRect.Top + lHeight;
|
||||
int nBeginX = (std::min)(oNewRect.Left, oNewRect.Right);
|
||||
int nBeginY = (std::min)(oNewRect.Top, oNewRect.Bottom);
|
||||
|
||||
if (lWidth < (oNewRect.Right - oNewRect.Left))
|
||||
oNewRect.Right = oNewRect.Left + lWidth;
|
||||
int nEndX = (std::max)(oNewRect.Left, oNewRect.Right);
|
||||
int nEndY = (std::max)(oNewRect.Top, oNewRect.Bottom);
|
||||
|
||||
if (lHeight == (oNewRect.Bottom - oNewRect.Top) &&
|
||||
lWidth == (oNewRect.Right - oNewRect.Left))
|
||||
if (nBeginX >= lWidth || nEndX <= 0)
|
||||
return NULL;
|
||||
if (nBeginY >= lHeight || nEndY <= 0)
|
||||
return NULL;
|
||||
|
||||
int nBeginX, nBeginY, nEndX, nEndY;
|
||||
if (nBeginX <= 0 && nEndX >= lWidth &&
|
||||
nBeginY <= 0 && nEndY >= lHeight)
|
||||
return NULL;
|
||||
|
||||
nBeginX = (std::min)(oNewRect.Left, oNewRect.Right);
|
||||
nBeginY = (std::min)(oNewRect.Top, oNewRect.Bottom);
|
||||
if (nBeginX < 0)
|
||||
nBeginX = 0;
|
||||
if (nBeginY < 0)
|
||||
nBeginY = 0;
|
||||
|
||||
nEndX = (std::max)(oNewRect.Left, oNewRect.Right);
|
||||
nEndY = (std::max)(oNewRect.Top, oNewRect.Bottom);
|
||||
if (nEndX > lWidth)
|
||||
nEndX = lWidth;
|
||||
if (nEndY > lHeight)
|
||||
nEndY = lHeight;
|
||||
|
||||
int nWidth = nEndX - nBeginX;
|
||||
int nHeight = nEndY - nBeginY;
|
||||
if (nEndX <= nBeginX || nEndY <= nBeginY)
|
||||
return NULL;
|
||||
|
||||
nWidth = nEndX - nBeginX;
|
||||
nHeight = nEndY - nBeginY;
|
||||
|
||||
BYTE* pNewBuffer = new BYTE[nWidth * nHeight * 4];
|
||||
BYTE* pCurrentLine = pNewBuffer;
|
||||
|
||||
ULONG ulPos = 0;
|
||||
|
||||
for (ULONG ulPosY = nBeginY * 4; ulPosY < nEndY * 4; ulPosY += 4)
|
||||
int ulStride = 4 * nWidth;
|
||||
for (int nPosY = nBeginY; nPosY < nEndY; ++nPosY)
|
||||
{
|
||||
for (ULONG ulPosX = nBeginX * 4; ulPosX < nEndX * 4; ulPosX += 4)
|
||||
{
|
||||
pNewBuffer[ulPos++] = (BYTE)pBuffer[ulPosY * lWidth + ulPosX + 0];
|
||||
pNewBuffer[ulPos++] = (BYTE)pBuffer[ulPosY * lWidth + ulPosX + 1];
|
||||
pNewBuffer[ulPos++] = (BYTE)pBuffer[ulPosY * lWidth + ulPosX + 2];
|
||||
pNewBuffer[ulPos++] = (BYTE)pBuffer[ulPosY * lWidth + ulPosX + 3];
|
||||
}
|
||||
memcpy(pCurrentLine, pBuffer + lWidth * 4 * nPosY + 4 * nBeginX, ulStride);
|
||||
pCurrentLine += ulStride;
|
||||
}
|
||||
|
||||
return pNewBuffer;
|
||||
@ -1463,29 +1470,18 @@ namespace MetaFile
|
||||
if (NULL == pImageBuffer || lWidth == 0 || lHeight == 0)
|
||||
return S_FALSE;
|
||||
|
||||
BYTE oBuffer[4] = {0, 0, 0, 0};
|
||||
BYTE* pTempLine = (BYTE*)malloc(lWidth * 4);
|
||||
const ULONG ulStride = 4 * lWidth;
|
||||
|
||||
for (ULONG ulPosY = 0; ulPosY < lHeight / 2 * 4; ulPosY += 4)
|
||||
for (UINT nPosY = 0; nPosY < lHeight / 2; ++nPosY)
|
||||
{
|
||||
for (ULONG ulPosX = 0; ulPosX < lWidth * 4; ulPosX += 4)
|
||||
{
|
||||
oBuffer[0] = pImageBuffer[ulPosY * lWidth + ulPosX + 0];
|
||||
oBuffer[1] = pImageBuffer[ulPosY * lWidth + ulPosX + 1];
|
||||
oBuffer[2] = pImageBuffer[ulPosY * lWidth + ulPosX + 2];
|
||||
oBuffer[3] = pImageBuffer[ulPosY * lWidth + ulPosX + 3];
|
||||
|
||||
pImageBuffer[ulPosY * lWidth + ulPosX + 0] = pImageBuffer[((lHeight - 1) * 4 - ulPosY) * lWidth + ulPosX + 0];
|
||||
pImageBuffer[ulPosY * lWidth + ulPosX + 1] = pImageBuffer[((lHeight - 1) * 4 - ulPosY) * lWidth + ulPosX + 1];
|
||||
pImageBuffer[ulPosY * lWidth + ulPosX + 2] = pImageBuffer[((lHeight - 1) * 4 - ulPosY) * lWidth + ulPosX + 2];
|
||||
pImageBuffer[ulPosY * lWidth + ulPosX + 3] = pImageBuffer[((lHeight - 1) * 4 - ulPosY) * lWidth + ulPosX + 3];
|
||||
|
||||
pImageBuffer[((lHeight - 1) * 4 - ulPosY) * lWidth + ulPosX + 0] = oBuffer[0];
|
||||
pImageBuffer[((lHeight - 1) * 4 - ulPosY) * lWidth + ulPosX + 1] = oBuffer[1];
|
||||
pImageBuffer[((lHeight - 1) * 4 - ulPosY) * lWidth + ulPosX + 2] = oBuffer[2];
|
||||
pImageBuffer[((lHeight - 1) * 4 - ulPosY) * lWidth + ulPosX + 3] = oBuffer[3];
|
||||
}
|
||||
memcpy(pTempLine, pImageBuffer + nPosY * ulStride, ulStride);
|
||||
memcpy(pImageBuffer + nPosY * ulStride, pImageBuffer + (lHeight - nPosY - 1) * ulStride, ulStride);
|
||||
memcpy(pImageBuffer + (lHeight - nPosY - 1) * ulStride, pTempLine, ulStride);
|
||||
}
|
||||
|
||||
free(pTempLine);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -1633,18 +1629,17 @@ namespace MetaFile
|
||||
|
||||
TRectL oClipRect;
|
||||
|
||||
oClipRect.Left = oSrcRect.dX * dScale;
|
||||
oClipRect.Top = oSrcRect.dY * dScale;
|
||||
oClipRect.Right = (oSrcRect.dX + oSrcRect.dWidth) * dScale;
|
||||
oClipRect.Bottom = (oSrcRect.dY + oSrcRect.dHeight) * dScale;
|
||||
oClipRect.Left = std::floor((oSrcRect.dX - oFileBounds.Left) * dScale);
|
||||
oClipRect.Top = std::floor((oSrcRect.dY - oFileBounds.Top) * dScale);
|
||||
oClipRect.Right = std::floor((oSrcRect.dX + oSrcRect.dWidth - oFileBounds.Left) * dScale);
|
||||
oClipRect.Bottom = std::floor((oSrcRect.dY + oSrcRect.dHeight - oFileBounds.Top) * dScale);
|
||||
|
||||
BYTE* pNewBuffer = GetClipedImage(pPixels, nWidth, nHeight, oClipRect);
|
||||
|
||||
const unsigned int unWidth = std::min(((unsigned int)fabs(oClipRect.Right - oClipRect.Left)), ((unsigned int)nWidth ));
|
||||
const unsigned int unHeight = std::min(((unsigned int)fabs(oClipRect.Bottom - oClipRect.Top)), ((unsigned int)nHeight));
|
||||
unsigned int nW = (unsigned int)nWidth;
|
||||
unsigned int nH = (unsigned int)nHeight;
|
||||
BYTE* pNewBuffer = GetClipedImage(pPixels, nWidth, nHeight, oClipRect, nW, nH);
|
||||
|
||||
m_pInterpretator->DrawBitmap(arPoints[0].X, arPoints[0].Y, arPoints[1].X - arPoints[0].X - m_pDC->GetPixelWidth(), arPoints[2].Y - arPoints[0].Y - m_pDC->GetPixelHeight(),
|
||||
(NULL != pNewBuffer) ? pNewBuffer : pPixels, unWidth, unHeight);
|
||||
(NULL != pNewBuffer) ? pNewBuffer : pPixels, nW, nH);
|
||||
|
||||
RELEASEINTERFACE(pGrRenderer);
|
||||
RELEASEARRAYOBJECTS(pNewBuffer);
|
||||
@ -1655,8 +1650,6 @@ namespace MetaFile
|
||||
|
||||
oParser.PlayFile();
|
||||
|
||||
const TXForm& oXForm{m_pDC->GetTransform()};
|
||||
|
||||
TRectD oRect;
|
||||
|
||||
oRect.Left = arPoints[0].X;
|
||||
@ -1671,9 +1664,7 @@ namespace MetaFile
|
||||
oTempSrcRect.Right = oTempSrcRect.Left + ((dFileWidth > oSrcRect.dWidth) ? oSrcRect.dWidth - GetPixelWidth() : dFileWidth);
|
||||
oTempSrcRect.Bottom = oTempSrcRect.Top + ((dFileHeight > oSrcRect.dHeight) ? oSrcRect.dHeight - GetPixelHeight() : dFileHeight);
|
||||
|
||||
TXForm oTransform;
|
||||
|
||||
oTransform.Copy(oXForm);
|
||||
TXForm oTransform(m_pDC->GetTransform());
|
||||
|
||||
oTransform.Dx -= m_oHeader.oFramePx.Left;
|
||||
oTransform.Dy -= m_oHeader.oFramePx.Top;
|
||||
@ -1717,15 +1708,17 @@ namespace MetaFile
|
||||
|
||||
TRectL oClipRect;
|
||||
|
||||
oClipRect.Left = oSrcRect.dX;
|
||||
oClipRect.Top = oSrcRect.dY;
|
||||
oClipRect.Right = (oSrcRect.dX + oSrcRect.dWidth);
|
||||
oClipRect.Bottom = (oSrcRect.dY + oSrcRect.dHeight);
|
||||
oClipRect.Left = std::floor(oSrcRect.dX);
|
||||
oClipRect.Top = std::floor(oSrcRect.dY);
|
||||
oClipRect.Right = std::floor((oSrcRect.dX + oSrcRect.dWidth));
|
||||
oClipRect.Bottom = std::floor((oSrcRect.dY + oSrcRect.dHeight));
|
||||
|
||||
BYTE* pNewBuffer = GetClipedImage(pBytes, unWidth, unHeight, oClipRect);
|
||||
unsigned int nW = (unsigned int)unWidth;
|
||||
unsigned int nH = (unsigned int)unHeight;
|
||||
BYTE* pNewBuffer = GetClipedImage(pBytes, unWidth, unHeight, oClipRect, nW, nH);
|
||||
|
||||
m_pInterpretator->DrawBitmap(arPoints[0].X, arPoints[0].Y, arPoints[1].X - arPoints[0].X, arPoints[2].Y - arPoints[0].Y,
|
||||
(NULL != pNewBuffer) ? pNewBuffer : pBytes, fabs(oClipRect.Right - oClipRect.Left), fabs(oClipRect.Bottom - oClipRect.Top));
|
||||
(NULL != pNewBuffer) ? pNewBuffer : pBytes, nW, nH);
|
||||
|
||||
if (!bExternalBuffer)
|
||||
RELEASEARRAYOBJECTS(pBytes);
|
||||
@ -3183,24 +3176,16 @@ namespace MetaFile
|
||||
m_bBanEmfProcessing = true;
|
||||
|
||||
short shPageUnit = ExpressValue(unShFlags, 0, 7);
|
||||
double dUnitKoef;
|
||||
|
||||
m_oStream >> m_dUnitKoef;
|
||||
m_oStream >> dUnitKoef;
|
||||
|
||||
switch (shPageUnit)
|
||||
{
|
||||
case UnitTypePixel:
|
||||
case UnitTypeWorld:
|
||||
case UnitTypeDisplay:
|
||||
default: break;
|
||||
case UnitTypePoint: m_dUnitKoef *= m_unLogicalDpiX * 72.f; break;
|
||||
case UnitTypeInch: m_dUnitKoef *= m_unLogicalDpiX; break;
|
||||
case UnitTypeDocument: m_dUnitKoef *= m_unLogicalDpiX / 300.f; break;
|
||||
case UnitTypeMillimeter: m_dUnitKoef *= m_unLogicalDpiX / 25.4f; break;
|
||||
}
|
||||
m_dPageTransformX = dUnitKoef * GetUnitToPixel(m_unLogicalDpiX, static_cast<EEmfPlusUnitType>(shPageUnit));
|
||||
m_dPageTransformY = dUnitKoef * GetUnitToPixel(m_unLogicalDpiY, static_cast<EEmfPlusUnitType>(shPageUnit));
|
||||
|
||||
TXForm oMatrix(m_dUnitKoef, 0, 0, m_dUnitKoef, 0, 0);
|
||||
TEmfPlusXForm oUnitKoefMatrix(m_dPageTransformX, 0, 0, m_dPageTransformY, 0, 0);
|
||||
m_pDC->MultiplyTransform(oUnitKoefMatrix, MWT_LEFTMULTIPLY);
|
||||
|
||||
m_pDC->MultiplyTransform(oMatrix, MWT_LEFTMULTIPLY);
|
||||
UpdateOutputDC();
|
||||
}
|
||||
|
||||
@ -3210,9 +3195,11 @@ namespace MetaFile
|
||||
|
||||
m_oStream >> oMatrix;
|
||||
|
||||
UpdateMatrix(oMatrix);
|
||||
|
||||
m_pDC->MultiplyTransform(oMatrix, MWT_SET);
|
||||
|
||||
TEmfPlusXForm oUnitKoefMatrix(m_dPageTransformX, 0, 0, m_dPageTransformY, 0, 0);
|
||||
m_pDC->MultiplyTransform(oUnitKoefMatrix, MWT_LEFTMULTIPLY);
|
||||
|
||||
UpdateOutputDC();
|
||||
}
|
||||
|
||||
|
||||
@ -87,7 +87,7 @@ namespace MetaFile
|
||||
template<typename T> std::vector<TEmfPlusPointF> GetConvertedPoints(std::vector<T>arPoints);
|
||||
template<typename T> TEmfPlusRectF GetConvertedRectangle(T oRectangle);
|
||||
|
||||
void UpdateMatrix(TEmfPlusXForm& oMatrix);
|
||||
double GetUnitToPixel(const double& dDpi, EEmfPlusUnitType eUnitType) const;
|
||||
|
||||
bool SaveImage(const CEmfPlusImage& oImage, std::wstring& wsPathToImage);
|
||||
|
||||
@ -176,7 +176,8 @@ namespace MetaFile
|
||||
unsigned int m_unLogicalDpiX;
|
||||
unsigned int m_unLogicalDpiY;
|
||||
|
||||
double m_dUnitKoef;
|
||||
double m_dPageTransformX;
|
||||
double m_dPageTransformY;
|
||||
|
||||
typedef std::map<unsigned int, CEmfPlusObject*> EmfPlusObjects;
|
||||
|
||||
|
||||
@ -469,8 +469,8 @@ namespace MetaFile
|
||||
|
||||
// Обновляем обратную матрицу
|
||||
TEmfXForm* pT = &m_oTransform;
|
||||
double dDet = pT->M11 * pT->M22 - pT->M12 * pT->M21;
|
||||
if (dDet < 0.0001 && dDet > 0.0001)
|
||||
const double dDet = pT->M11 * pT->M22 - pT->M12 * pT->M21;
|
||||
if (Equals(0., dDet, 0.0001))
|
||||
{
|
||||
m_oInverseTransform.M11 = 1;
|
||||
m_oInverseTransform.M12 = 0;
|
||||
@ -479,13 +479,15 @@ namespace MetaFile
|
||||
m_oInverseTransform.Dx = 0;
|
||||
m_oInverseTransform.Dy = 0;
|
||||
}
|
||||
|
||||
m_oInverseTransform.M11 = pT->M22 / dDet;
|
||||
m_oInverseTransform.M12 = -pT->M12 / dDet;
|
||||
m_oInverseTransform.M21 = -pT->M21 / dDet;
|
||||
m_oInverseTransform.M22 = pT->M22 / dDet;
|
||||
m_oInverseTransform.Dx = pT->Dy * pT->M21 / dDet - pT->Dx * pT->M22 / dDet;
|
||||
m_oInverseTransform.Dy = pT->Dx * pT->M12 / dDet - pT->Dy * pT->M11 / dDet;
|
||||
else
|
||||
{
|
||||
m_oInverseTransform.M11 = pT->M22 / dDet;
|
||||
m_oInverseTransform.M12 = -pT->M12 / dDet;
|
||||
m_oInverseTransform.M21 = -pT->M21 / dDet;
|
||||
m_oInverseTransform.M22 = pT->M22 / dDet;
|
||||
m_oInverseTransform.Dx = pT->Dy * pT->M21 / dDet - pT->Dx * pT->M22 / dDet;
|
||||
m_oInverseTransform.Dy = pT->Dx * pT->M12 / dDet - pT->Dy * pT->M11 / dDet;
|
||||
}
|
||||
|
||||
UpdateFinalTransform();
|
||||
}
|
||||
@ -714,20 +716,20 @@ namespace MetaFile
|
||||
const TEmfWindow& oWindow{GetWindow()};
|
||||
const TEmfWindow& oViewPort{GetViewport()};
|
||||
|
||||
double dM11 = (oViewPort.ulW >= 0) ? 1 : -1;
|
||||
double dM22 = (oViewPort.ulH >= 0) ? 1 : -1;
|
||||
double dM11 = ((oViewPort.ulW >= 0) ? 1. : -1.) * GetPixelWidth();
|
||||
double dM22 = ((oViewPort.ulH >= 0) ? 1. : -1.) * GetPixelHeight();
|
||||
|
||||
TEmfXForm oWindowXForm(1, 0, 0, 1, -(oWindow.lX * GetPixelWidth() * dM11), -(oWindow.lY * GetPixelHeight() * dM22));
|
||||
TEmfXForm oViewportXForm(GetPixelWidth() * dM11, 0, 0, GetPixelHeight() * dM22, oViewPort.lX, oViewPort.lY);
|
||||
TEmfXForm oWindowXForm(1, 0, 0, 1, -(oWindow.lX * dM11), -(oWindow.lY * dM22));
|
||||
TEmfXForm oViewportXForm(dM11, 0, 0, dM22, oViewPort.lX, oViewPort.lY);
|
||||
|
||||
m_oFinalTransform.Init();
|
||||
m_oFinalTransform.Multiply(oViewportXForm, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform.Multiply(m_oTransform, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform.Multiply(oViewportXForm, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform.Multiply(oWindowXForm, MWT_RIGHTMULTIPLY);
|
||||
|
||||
m_oFinalTransform2.Init();
|
||||
m_oFinalTransform2.Multiply(oViewportXForm, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform2.Multiply(m_oTransform, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform2.Multiply(oViewportXForm, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform2.Multiply(oWindowXForm, MWT_RIGHTMULTIPLY);
|
||||
}
|
||||
|
||||
|
||||
@ -149,63 +149,13 @@ namespace MetaFile
|
||||
if (NULL != m_pParser)
|
||||
pFont = m_pParser->GetFont();
|
||||
|
||||
NSStringExt::CConverter::ESingleByteEncoding eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_DEFAULT;;
|
||||
if (pFont)
|
||||
{
|
||||
// Соответствие 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 (pFont->GetCharSet())
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring wsText = NSStringExt::CConverter::GetUnicodeFromSingleByteString((const unsigned char*)pString, (long)shStringLength, eCharSet);
|
||||
const std::wstring wsText{ConvertToUnicode(pString, (long)shStringLength, (NULL != pFont) ? pFont->GetCharSet() : DEFAULT_CHARSET)};
|
||||
|
||||
TPointD oScale((m_pParser->IsWindowFlippedX()) ? -1 : 1, (m_pParser->IsWindowFlippedY()) ? -1 : 1);
|
||||
|
||||
std::vector<double> arDx(0);
|
||||
|
||||
if (NULL != pDx)
|
||||
if (NULL != pDx && shStringLength == wsText.length())
|
||||
arDx = std::vector<double>(pDx, pDx + wsText.length());
|
||||
|
||||
WriteText(wsText, TPointD(shX, shY), oRectangle, oScale, arDx);
|
||||
|
||||
@ -182,7 +182,8 @@ namespace MetaFile
|
||||
|
||||
std::wstring CWmfFont::GetFaceName() const
|
||||
{
|
||||
return std::wstring(NSStringExt::CConverter::GetUnicodeFromSingleByteString((const unsigned char*)uchFacename, 32).c_str());
|
||||
const std::wstring wsFontName(ConvertToUnicode((const unsigned char*)uchFacename, 32, uchCharSet));
|
||||
return wsFontName.substr(0, wsFontName.find(L'\0'));
|
||||
}
|
||||
|
||||
int CWmfFont::GetWeight() const
|
||||
|
||||
@ -52,7 +52,7 @@ namespace MetaFile
|
||||
m_oStream.SetCurrentBlockSize(m_unRecordSize);
|
||||
|
||||
if (NULL != m_pInterpretator)
|
||||
PRINT_WMF_RECORD(ushType)
|
||||
PRINT_WMF_RECORD(ushType);
|
||||
|
||||
switch (ushType)
|
||||
{
|
||||
|
||||
@ -353,57 +353,7 @@ namespace MetaFile
|
||||
}
|
||||
|
||||
const IFont* pFont = GetFont();
|
||||
NSStringExt::CConverter::ESingleByteEncoding eCharSet = NSStringExt::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_DEFAULT;;
|
||||
if (pFont)
|
||||
{
|
||||
// Соответствие 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 (pFont->GetCharSet())
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring wsText = NSStringExt::CConverter::GetUnicodeFromSingleByteString((const unsigned char*)pString, (long)unCharsCount, eCharSet);
|
||||
std::wstring wsText = ConvertToUnicode(pString, (long)unCharsCount, (NULL != pFont) ? pFont->GetCharSet() : DEFAULT_CHARSET);
|
||||
|
||||
if (NULL != m_pInterpretator)
|
||||
{
|
||||
@ -411,7 +361,7 @@ namespace MetaFile
|
||||
TranslatePoint(nX, nY, dX, dY);
|
||||
|
||||
double* pdDx = NULL;
|
||||
if (NULL != pDx)
|
||||
if (NULL != pDx && unCharsCount == wsText.length())
|
||||
{
|
||||
pdDx = new double[unCharsCount];
|
||||
if (pdDx)
|
||||
@ -734,6 +684,10 @@ namespace MetaFile
|
||||
if (oDestRect != oSrcRect)
|
||||
{
|
||||
TRectL oClip = oSrcRect;
|
||||
|
||||
oClip.Right = oClip.Left + (std::min)(oClip.Right - oClip.Left, (int)unWidth ) - 1;
|
||||
oClip.Bottom = oClip.Top + (std::min)(oClip.Bottom - oClip.Top, (int)unHeight) - 1;
|
||||
|
||||
BYTE* pNewBuffer = ClipBuffer(pBgra, unWidth, unHeight, oClip);
|
||||
|
||||
if (NULL != pNewBuffer)
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
#undef DrawText
|
||||
#endif
|
||||
|
||||
#define PRINT_WMF_RECORD(type) do {} while(false);
|
||||
#define PRINT_WMF_LOG(text) do {} while(false);
|
||||
#define PRINT_WMF_RECORD(type) do {} while(false)
|
||||
#define PRINT_WMF_LOG(text) do {} while(false)
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define LOG_WMF_RECORDS 1
|
||||
@ -105,13 +105,13 @@
|
||||
};
|
||||
|
||||
#define PRINT_WMF_RECORD(type) \
|
||||
{\
|
||||
do {\
|
||||
std::map<UINT, std::string>::const_iterator itFound = mWmfRecords.find(type); \
|
||||
if (mWmfRecords.cend() != itFound) \
|
||||
std::cout << itFound->second << std::endl; \
|
||||
else \
|
||||
std::cout << "Unknown record: " << type << std::endl; \
|
||||
}
|
||||
} while(false)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -571,20 +571,20 @@ namespace MetaFile
|
||||
const TWmfWindow& oWindow{GetWindow()};
|
||||
const TWmfWindow& oViewPort{GetViewport()};
|
||||
|
||||
double dM11 = (oViewPort.w >= 0) ? 1 : -1;
|
||||
double dM22 = (oViewPort.h >= 0) ? 1 : -1;
|
||||
double dM11 = ((oViewPort.w >= 0) ? 1. : -1.) * GetPixelWidth();
|
||||
double dM22 = ((oViewPort.h >= 0) ? 1. : -1.) * GetPixelHeight();
|
||||
|
||||
TEmfXForm oWindowXForm(1, 0, 0, 1, -(oWindow.x * GetPixelWidth() * dM11), -(oWindow.y * GetPixelHeight() * dM22));
|
||||
TEmfXForm oViewportXForm(GetPixelWidth() * dM11, 0, 0, GetPixelHeight() * dM22, oViewPort.x, oViewPort.y);
|
||||
TEmfXForm oWindowXForm(1, 0, 0, 1, -(oWindow.x * dM11), -(oWindow.y * dM22));
|
||||
TEmfXForm oViewportXForm(dM11, 0, 0, dM22, oViewPort.x, oViewPort.y);
|
||||
|
||||
m_oFinalTransform.Init();
|
||||
m_oFinalTransform.Multiply(oViewportXForm, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform.Multiply(m_oTransform, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform.Multiply(oViewportXForm, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform.Multiply(oWindowXForm, MWT_RIGHTMULTIPLY);
|
||||
|
||||
m_oFinalTransform2.Init();
|
||||
m_oFinalTransform2.Multiply(m_oTransform, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform2.Multiply(oViewportXForm, MWT_RIGHTMULTIPLY);
|
||||
// m_oFinalTransform2.Multiply(m_oTransform, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform2.Multiply(oWindowXForm, MWT_RIGHTMULTIPLY);
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
#include "CSvgParser.h"
|
||||
|
||||
#include "SvgUtils.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
||||
#include "CSvgFile.h"
|
||||
|
||||
@ -41,17 +40,70 @@ namespace SVG
|
||||
m_pFontManager = pFontManager;
|
||||
}
|
||||
|
||||
std::string FindEncoding(const std::string& wsContent)
|
||||
{
|
||||
size_t unEncodingBegin = wsContent.find("encoding");
|
||||
|
||||
if (std::string::npos == unEncodingBegin)
|
||||
return std::string();
|
||||
|
||||
unEncodingBegin += 8;
|
||||
|
||||
while (unEncodingBegin < wsContent.length() && std::isspace(wsContent[unEncodingBegin]))
|
||||
++unEncodingBegin;
|
||||
|
||||
if (unEncodingBegin >= wsContent.length() || '=' != wsContent[unEncodingBegin++])
|
||||
return std::string();
|
||||
|
||||
while (unEncodingBegin < wsContent.length() && std::isspace(wsContent[unEncodingBegin]))
|
||||
++unEncodingBegin;
|
||||
|
||||
if (unEncodingBegin >= wsContent.length() || ('\'' != wsContent[unEncodingBegin] && '"' != wsContent[unEncodingBegin]))
|
||||
return std::string();
|
||||
|
||||
std::string::const_iterator itEncodingValueBegin = std::find_if(wsContent.cbegin() + unEncodingBegin + 1, wsContent.cend(), [](char chElement){ return !isspace(chElement);});
|
||||
|
||||
if (wsContent.cend() == itEncodingValueBegin)
|
||||
return std::string();
|
||||
|
||||
std::string::const_iterator itEncodingValueEnd = std::find_if(itEncodingValueBegin, wsContent.cend(), [](char chElement){ return isspace(chElement) || '\'' == chElement || '\"' == chElement;});
|
||||
|
||||
if (wsContent.cend() == itEncodingValueEnd)
|
||||
return std::string();
|
||||
|
||||
return std::string(itEncodingValueBegin, itEncodingValueEnd);
|
||||
}
|
||||
|
||||
bool CSvgParser::LoadFromFile(const std::wstring &wsFile, CGraphicsContainer* pContainer, CSvgFile* pFile) const
|
||||
{
|
||||
if (wsFile.empty() || NULL == pFile)
|
||||
return false;
|
||||
|
||||
std::wstring wsXml;
|
||||
if (!NSFile::CFileBinary::ReadAllTextUtf8(wsFile, wsXml))
|
||||
std::string sXml;
|
||||
if (!NSFile::CFileBinary::ReadAllTextUtf8A(wsFile, sXml))
|
||||
return false;
|
||||
|
||||
size_t unFoundBegin = sXml.find("<svg");
|
||||
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
std::wstring wsContent;
|
||||
|
||||
if (std::string::npos != unFoundBegin)
|
||||
{
|
||||
std::string sEncoding = FindEncoding(sXml.substr(0, unFoundBegin));
|
||||
std::transform(sEncoding.begin(), sEncoding.end(), sEncoding.begin(), tolower);
|
||||
sXml.erase(0, unFoundBegin);
|
||||
|
||||
if (!sEncoding.empty() && "utf-8" != sEncoding)
|
||||
wsContent = oConverter.toUnicode(sXml, sEncoding.c_str());
|
||||
else
|
||||
wsContent = UTF8_TO_U(sXml);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
XmlUtils::IXmlDOMDocument::DisableOutput();
|
||||
bool bResult = LoadFromString(wsXml, pContainer, pFile);
|
||||
bool bResult = LoadFromString(wsContent, pContainer, pFile);
|
||||
XmlUtils::IXmlDOMDocument::EnableOutput();
|
||||
|
||||
return bResult;
|
||||
|
||||
@ -52,9 +52,9 @@ namespace SVG
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CFont::Draw(const std::wstring &wsText, double dX, double dY, IRenderer *pRenderer, const CSvgFile *pFile, CommandeMode oMode, const TSvgStyles *pStyles, const CRenderedObject* pContexObject) const
|
||||
bool CFont::Draw(const std::wstring &wsText, const double& dX, const double& dY, const double& dFontHeight, IRenderer *pRenderer, const CSvgFile *pFile, CommandeMode oMode, const TSvgStyles *pStyles, const CRenderedObject* pContexObject) const
|
||||
{
|
||||
if (NULL == pRenderer)
|
||||
if (NULL == pRenderer || wsText.empty())
|
||||
return false;
|
||||
|
||||
double dM11, dM12, dM21, dM22, dRx, dRy;
|
||||
@ -64,10 +64,25 @@ namespace SVG
|
||||
Aggplus::CMatrix oMatrix(dM11, dM12, dM21, dM22, dRx, dRy);
|
||||
oMatrix.Translate(dX, dY);
|
||||
|
||||
pRenderer->SetTransform(dM11, dM12, dM21, -dM22, oMatrix.tx(), oMatrix.ty());
|
||||
|
||||
MGlyphsMap::const_iterator itFound;
|
||||
TBounds oGlyphBounds;
|
||||
double dGlyphScale = 1.;
|
||||
|
||||
#define DrawGlyph(glyphPtr, function) \
|
||||
const TBounds oGlyphBound{glyphPtr->GetBounds()};\
|
||||
if (Equals(0., dFontHeight) || Equals(oGlyphBound.m_dBottom, oGlyphBound.m_dTop) || Equals(oGlyphBound.m_dRight, oGlyphBound.m_dLeft)) \
|
||||
continue; \
|
||||
dGlyphScale = dFontHeight / 1000.; \
|
||||
if (!Equals(1., dGlyphScale)) \
|
||||
{ \
|
||||
oMatrix.Scale(dGlyphScale, -dGlyphScale); \
|
||||
pRenderer->SetTransform(oMatrix.sx(), oMatrix.shy(), oMatrix.shx(), oMatrix.sy(), oMatrix.tx(), oMatrix.ty()); \
|
||||
} \
|
||||
function; \
|
||||
if (!Equals(1., dGlyphScale)) \
|
||||
{ \
|
||||
oMatrix.Scale(1. / dGlyphScale, -1. / dGlyphScale); \
|
||||
pRenderer->SetTransform(oMatrix.sx(), oMatrix.shy(), oMatrix.shx(), oMatrix.sy(), oMatrix.tx(), oMatrix.ty()); \
|
||||
} \
|
||||
|
||||
for (wchar_t wchGlyph : wsText)
|
||||
{
|
||||
@ -78,12 +93,13 @@ namespace SVG
|
||||
if (NULL == m_pMissingGlyph)
|
||||
continue;
|
||||
|
||||
m_pMissingGlyph->Draw(pRenderer, pFile, oMode, pStyles, pContexObject);
|
||||
DrawGlyph(m_pMissingGlyph, m_pMissingGlyph->Draw(pRenderer, pFile, oMode, pStyles, pContexObject))
|
||||
|
||||
oMatrix.Translate(m_oHorizAdvX.ToDouble(NSCSS::Pixel), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
itFound->second->Draw(pRenderer, pFile, oMode, pStyles, pContexObject);
|
||||
DrawGlyph(itFound->second, itFound->second->Draw(pRenderer, pFile, oMode, pStyles, pContexObject))
|
||||
|
||||
if (!itFound->second->m_oHorizAdvX.Empty())
|
||||
oMatrix.Translate(itFound->second->m_oHorizAdvX.ToDouble(NSCSS::Pixel), 0);
|
||||
@ -91,9 +107,7 @@ namespace SVG
|
||||
oMatrix.Translate(m_oHorizAdvX.ToDouble(NSCSS::Pixel), 0);
|
||||
}
|
||||
|
||||
oMatrix.Translate(std::abs(oGlyphBounds.m_dRight - oGlyphBounds.m_dLeft), 0);
|
||||
|
||||
pRenderer->SetTransform(dM11, dM12, dM21, -dM22, oMatrix.tx(), oMatrix.ty());
|
||||
pRenderer->SetTransform(oMatrix.sx(), oMatrix.shy(), oMatrix.shx(), -oMatrix.sy(), oMatrix.tx(), oMatrix.ty());
|
||||
}
|
||||
|
||||
pRenderer->SetTransform(dM11, dM12, dM21, dM22, dRx, dRy);
|
||||
|
||||
@ -43,7 +43,7 @@ namespace SVG
|
||||
void SetData(const std::map<std::wstring, std::wstring> &mAttributes, unsigned short ushLevel, bool bHardMode) override;
|
||||
|
||||
bool Apply(IRenderer* pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds) override;
|
||||
bool Draw(const std::wstring& wsText, double dX, double dY, IRenderer* pRenderer, const CSvgFile *pFile, CommandeMode oMode = CommandeModeDraw, const TSvgStyles* pStyles = NULL, const CRenderedObject* pContexObject = NULL) const;
|
||||
bool Draw(const std::wstring& wsText, const double& dX, const double& dY, const double& dFontHeight, IRenderer* pRenderer, const CSvgFile *pFile, CommandeMode oMode = CommandeModeDraw, const TSvgStyles* pStyles = NULL, const CRenderedObject* pContexObject = NULL) const;
|
||||
private:
|
||||
void ParseGlyphs(XmlUtils::CXmlNode& oNode);
|
||||
|
||||
|
||||
@ -128,6 +128,7 @@ namespace SVG
|
||||
bool AddElement(IPathElement* pElement);
|
||||
|
||||
friend class CLine;
|
||||
friend class CFont;
|
||||
friend class CPolygon;
|
||||
friend class CPolyline;
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
#define DEFAULT_TSPAN_FONT_SIZE 16
|
||||
#define DefaultFontFamily L"Times New Roman"
|
||||
#define MIN_FONT_SIZE 5
|
||||
#define MAX_FONT_SIZE 100
|
||||
@ -26,7 +27,7 @@ namespace SVG
|
||||
CTSpan::CTSpan(XmlUtils::CXmlNode& oNode, CRenderedObject* pParent, NSFonts::IFontManager* pFontManager, bool bCheckText)
|
||||
: CRenderedObject(oNode, pParent), m_pFontManager(pFontManager)
|
||||
{
|
||||
m_oFont.UpdateSize(16);
|
||||
m_oFont.UpdateSize(DEFAULT_TSPAN_FONT_SIZE,DEFAULT_TSPAN_FONT_SIZE);
|
||||
|
||||
if (bCheckText)
|
||||
m_wsText = StrUtils::TrimExtraEnding(oNode.GetText());
|
||||
@ -45,6 +46,8 @@ namespace SVG
|
||||
if (NULL == pTSpan)
|
||||
return;
|
||||
|
||||
m_oStyles = pTSpan->m_oStyles;
|
||||
|
||||
if (m_oX.Empty())
|
||||
{
|
||||
if (!pTSpan->m_arObjects.empty())
|
||||
@ -61,7 +64,7 @@ namespace SVG
|
||||
CTSpan::CTSpan(const std::wstring &wsText, const Point &oPosition, CRenderedObject *pParent, NSFonts::IFontManager *pFontManager, bool bCheckText)
|
||||
: CRenderedObject(NSCSS::CNode(L"tspan", L"", L""), pParent), m_pFontManager(pFontManager), m_wsText(wsText)
|
||||
{
|
||||
m_oFont.UpdateSize(16);
|
||||
m_oFont.UpdateSize(DEFAULT_TSPAN_FONT_SIZE, DEFAULT_TSPAN_FONT_SIZE);
|
||||
|
||||
if (bCheckText)
|
||||
m_wsText = StrUtils::TrimExtraEnding(m_wsText);
|
||||
@ -157,18 +160,18 @@ namespace SVG
|
||||
double dX, dY;
|
||||
CalculatePosition(dX, dY);
|
||||
|
||||
if (!UseExternalFont(pFile, dX, dY, pRenderer, oMode, pOtherStyles))
|
||||
if (!UseExternalFont(pFile, dX, dY, pRenderer, oMode, pOtherStyles, pContexObject))
|
||||
{
|
||||
if (!m_wsText.empty())
|
||||
{
|
||||
ApplyFont(pRenderer, dX, dY);
|
||||
pRenderer->CommandDrawText(m_wsText, dX, dY, 0, 0);
|
||||
}
|
||||
|
||||
for (const CTSpan* pTSpan : m_arObjects)
|
||||
pTSpan->Draw(pRenderer, pFile, oMode, pOtherStyles, pContexObject);
|
||||
}
|
||||
|
||||
for (const CTSpan* pTSpan : m_arObjects)
|
||||
pTSpan->Draw(pRenderer, pFile, oMode, pOtherStyles, pContexObject);
|
||||
|
||||
EndPath(pRenderer, pFile, oOldMatrix, oMode, pOtherStyles, pContexObject);
|
||||
|
||||
return true;
|
||||
@ -302,7 +305,7 @@ namespace SVG
|
||||
pRenderer->put_BrushColor1(m_oStyles.m_oFill.ToInt());
|
||||
pRenderer->put_BrushAlpha1(255);
|
||||
}
|
||||
|
||||
|
||||
bool CTSpan::UseExternalFont(const CSvgFile *pFile, double dX, double dY, IRenderer *pRenderer, CommandeMode oMode, const TSvgStyles *pOtherStyles, const CRenderedObject* pContexObject) const
|
||||
{
|
||||
std::wstring wsFontFamily = DefaultFontFamily;
|
||||
@ -318,7 +321,14 @@ namespace SVG
|
||||
if (NULL == pFont)
|
||||
return false;
|
||||
|
||||
pFont->Draw(m_wsText, dX, dY, pRenderer, pFile, oMode, pOtherStyles, pContexObject);
|
||||
TSvgStyles oStyle;
|
||||
|
||||
if (NULL != pOtherStyles)
|
||||
oStyle = *pOtherStyles;
|
||||
|
||||
oStyle += m_oStyles;
|
||||
|
||||
pFont->Draw(m_wsText, dX, dY, m_oFont.GetSize().ToDouble(NSCSS::Pixel), pRenderer, pFile, oMode, &oStyle, pContexObject);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -74,6 +74,8 @@ SOURCES += \
|
||||
$$PWD/../../libxml2/valid.c \
|
||||
$$PWD/../../libxml2/parser.c
|
||||
}
|
||||
|
||||
!core_only_libxml {
|
||||
SOURCES += \
|
||||
$$PWD/../../src/xmlwriter.cpp \
|
||||
$$PWD/../../src/xmllight.cpp \
|
||||
@ -85,3 +87,4 @@ HEADERS += \
|
||||
HEADERS += \
|
||||
$$PWD/../../include/xmlutils.h \
|
||||
$$PWD/../../include/xmlwriter.h
|
||||
}
|
||||
|
||||
@ -42,6 +42,7 @@ class CDocxRenderer_Private
|
||||
public:
|
||||
NSDocxRenderer::CDocument m_oDocument;
|
||||
std::wstring m_sTempDirectory;
|
||||
bool m_bIsSupportShapeCommands = false;
|
||||
|
||||
public:
|
||||
CDocxRenderer_Private(NSFonts::IApplicationFonts* pFonts, IRenderer* pRenderer) : m_oDocument(pRenderer, pFonts)
|
||||
@ -85,6 +86,7 @@ int CDocxRenderer::Convert(IOfficeDrawingFile* pFile, const std::wstring& sDst,
|
||||
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_bUseDefaultFont = false;
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_bWriteStyleRaw = false;
|
||||
m_pInternal->m_bIsSupportShapeCommands = false;
|
||||
|
||||
if (bIsOutCompress)
|
||||
m_pInternal->m_oDocument.m_strTempDirectory = NSDirectory::CreateDirectoryWithUniqueName(m_pInternal->m_sTempDirectory);
|
||||
@ -123,6 +125,7 @@ std::vector<std::wstring> CDocxRenderer::ScanPage(IOfficeDrawingFile* pFile, siz
|
||||
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_bUseDefaultFont = true;
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_bWriteStyleRaw = true;
|
||||
m_pInternal->m_bIsSupportShapeCommands = false;
|
||||
|
||||
DrawPage(pFile, nPage);
|
||||
|
||||
@ -151,6 +154,7 @@ std::vector<std::wstring> CDocxRenderer::ScanPagePptx(IOfficeDrawingFile* pFile,
|
||||
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_bUseDefaultFont = true;
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_bWriteStyleRaw = true;
|
||||
m_pInternal->m_bIsSupportShapeCommands = true;
|
||||
|
||||
DrawPage(pFile, nPage);
|
||||
|
||||
@ -216,7 +220,7 @@ HRESULT CDocxRenderer::IsSupportAdvancedCommand(const IAdvancedCommand::Advanced
|
||||
{
|
||||
case IAdvancedCommand::AdvancedCommandType::ShapeStart:
|
||||
case IAdvancedCommand::AdvancedCommandType::ShapeEnd:
|
||||
return S_OK;
|
||||
return m_pInternal->m_bIsSupportShapeCommands ? S_OK: S_FALSE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@ -192,6 +192,9 @@ public:
|
||||
virtual HRESULT CommandDouble(const LONG& lType, const double& dCommand);
|
||||
virtual HRESULT CommandString(const LONG& lType, const std::wstring& sCommand);
|
||||
|
||||
virtual HRESULT IsSupportAdvancedCommand(const IAdvancedCommand::AdvancedCommandType& type);
|
||||
virtual HRESULT AdvancedCommand(IAdvancedCommand* command);
|
||||
|
||||
// методы, которыми будет пользоваться конвертер
|
||||
HRESULT SetTextAssociationType(const NSDocxRenderer::TextAssociationType& eType);
|
||||
int Convert(IOfficeDrawingFile* pFile, const std::wstring& sDstFile, bool bIsOutCompress = true);
|
||||
@ -199,10 +202,6 @@ public:
|
||||
std::vector<std::wstring> ScanPagePptx(IOfficeDrawingFile* pFile, size_t nPage);
|
||||
|
||||
void SetExternalImageStorage(NSDocxRenderer::IImageStorage* pStorage);
|
||||
|
||||
virtual HRESULT IsSupportAdvancedCommand(const IAdvancedCommand::AdvancedCommandType& type);
|
||||
virtual HRESULT AdvancedCommand(IAdvancedCommand* command);
|
||||
|
||||
private:
|
||||
CDocxRenderer_Private* m_pInternal;
|
||||
void DrawPage(IOfficeDrawingFile* pFile, size_t nPage);
|
||||
|
||||
@ -6,6 +6,9 @@
|
||||
#include "./../resources/resources.h"
|
||||
#endif
|
||||
|
||||
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
|
||||
#define CLAMP_ALPHA(x) CLAMP(x, 0, 255)
|
||||
|
||||
namespace NSDocxRenderer
|
||||
{
|
||||
CDocument::CDocument(IRenderer* pRenderer, NSFonts::IApplicationFonts* pFonts) :
|
||||
@ -92,7 +95,7 @@ namespace NSDocxRenderer
|
||||
}
|
||||
HRESULT CDocument::put_PenAlpha(LONG lAlpha)
|
||||
{
|
||||
m_oPen.Alpha = lAlpha;
|
||||
m_oPen.Alpha = CLAMP_ALPHA(lAlpha);
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_PenSize(double* dSize)
|
||||
@ -212,7 +215,7 @@ namespace NSDocxRenderer
|
||||
}
|
||||
HRESULT CDocument::put_BrushAlpha1(LONG lAlpha)
|
||||
{
|
||||
m_oBrush.Alpha1 = lAlpha;
|
||||
m_oBrush.Alpha1 = CLAMP_ALPHA(lAlpha);;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_BrushColor2(LONG* lColor)
|
||||
@ -232,7 +235,7 @@ namespace NSDocxRenderer
|
||||
}
|
||||
HRESULT CDocument::put_BrushAlpha2(LONG lAlpha)
|
||||
{
|
||||
m_oBrush.Alpha2 = lAlpha;
|
||||
m_oBrush.Alpha2 = CLAMP_ALPHA(lAlpha);;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_BrushTexturePath(std::wstring* sPath)
|
||||
@ -262,7 +265,7 @@ namespace NSDocxRenderer
|
||||
}
|
||||
HRESULT CDocument::put_BrushTextureAlpha(LONG lTxAlpha)
|
||||
{
|
||||
m_oBrush.TextureAlpha = lTxAlpha;
|
||||
m_oBrush.TextureAlpha = CLAMP_ALPHA(lTxAlpha);
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_BrushLinearAngle(double* dAngle)
|
||||
@ -303,6 +306,7 @@ namespace NSDocxRenderer
|
||||
color.position = (long)(pPositions[i] * 65536);
|
||||
m_oBrush.m_arrSubColors.push_back(color);
|
||||
}
|
||||
m_oCurrentPage.m_bIsGradient = true;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_BrushGradInfo(void* pGradInfo)
|
||||
@ -969,8 +973,19 @@ namespace NSDocxRenderer
|
||||
xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" \
|
||||
mc:Ignorable=\"w14 w15 w16se w16cid w16 w16cex w16sdtdh\">");
|
||||
|
||||
auto oFonts = m_oFontSelector.GetCache();
|
||||
for (auto& val : oFonts)
|
||||
const auto& cache = m_oFontSelector.GetCache();
|
||||
std::list<CFontSelector::CFontSelectInfo> font_table;
|
||||
std::map<std::wstring, bool> ar_is_written;
|
||||
for (const auto& info : cache)
|
||||
{
|
||||
if (!ar_is_written[info.wsSelectedName])
|
||||
{
|
||||
font_table.push_back(info);
|
||||
ar_is_written[info.wsSelectedName] = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& val : font_table)
|
||||
{
|
||||
if (val.wsSelectedName.empty())
|
||||
continue;
|
||||
|
||||
@ -57,7 +57,6 @@ namespace NSDocxRenderer
|
||||
|
||||
if (lType == c_nResetClipType)
|
||||
{
|
||||
m_oCurrVectorGraphics.Clear();
|
||||
m_oClipVectorGraphics.Clear();
|
||||
}
|
||||
else if (lType == c_nClipType)
|
||||
@ -162,11 +161,12 @@ namespace NSDocxRenderer
|
||||
|
||||
void CPage::PathStart()
|
||||
{
|
||||
m_oCurrVectorGraphics.Clear();
|
||||
}
|
||||
|
||||
void CPage::PathEnd()
|
||||
{
|
||||
m_oCurrVectorGraphics.End();
|
||||
m_oCurrVectorGraphics.Clear();
|
||||
}
|
||||
|
||||
void CPage::PathClose()
|
||||
@ -174,12 +174,15 @@ namespace NSDocxRenderer
|
||||
m_oCurrVectorGraphics.Close();
|
||||
}
|
||||
|
||||
|
||||
// c_nStroke = 0x0001;
|
||||
// c_nWindingFillMode = 0x0100;
|
||||
// c_nEvenOddFillMode = 0x0200;
|
||||
void CPage::DrawPath(LONG lType, const std::shared_ptr<CImageInfo> pInfo)
|
||||
{
|
||||
// in case if text comes as a path with unicode 32 (space)
|
||||
if (m_oCurrVectorGraphics.IsEmpty())
|
||||
return;
|
||||
|
||||
double rotation = m_pTransform->z_Rotation();
|
||||
double left = m_oCurrVectorGraphics.GetLeft();
|
||||
double right = m_oCurrVectorGraphics.GetRight();
|
||||
@ -187,6 +190,9 @@ namespace NSDocxRenderer
|
||||
double bot = m_oCurrVectorGraphics.GetBottom();
|
||||
double transform_det = sqrt(fabs(m_pTransform->Determinant()));
|
||||
|
||||
// save default image vector before clip to calc blipFill
|
||||
auto image_vector = m_oCurrVectorGraphics;
|
||||
|
||||
auto set_fill_mode = [this, lType, &transform_det] (std::shared_ptr<CShape> s) {
|
||||
if (lType & c_nStroke)
|
||||
{
|
||||
@ -229,7 +235,14 @@ namespace NSDocxRenderer
|
||||
CVectorGraphics new_vector_graphics = CVectorGraphics::CalcBoolean(
|
||||
m_oCurrVectorGraphics,
|
||||
m_oClipVectorGraphics,
|
||||
m_lClipMode);
|
||||
m_lClipMode,
|
||||
lType);
|
||||
|
||||
if (new_vector_graphics.IsEmpty())
|
||||
{
|
||||
m_oCurrVectorGraphics.Clear();
|
||||
return;
|
||||
}
|
||||
m_oCurrVectorGraphics = std::move(new_vector_graphics);
|
||||
}
|
||||
shape->SetVector(std::move(m_oCurrVectorGraphics));
|
||||
@ -237,8 +250,16 @@ namespace NSDocxRenderer
|
||||
auto info = pInfo;
|
||||
if (!info && m_bIsGradient)
|
||||
{
|
||||
const long width_pix = shape->m_dWidth * c_dMMToPix;
|
||||
const long height_pix = shape->m_dHeight * c_dMMToPix;
|
||||
// image with gradient must be closed
|
||||
if (!shape->m_oVector.IsEmpty() && shape->m_oVector.GetData().back().type != CVectorGraphics::ePathCommandType::pctClose)
|
||||
shape->m_oVector.Add({CVectorGraphics::ePathCommandType::pctClose, {}});
|
||||
|
||||
long width_pix = static_cast<long>(shape->m_dWidth * c_dMMToPix);
|
||||
long height_pix = static_cast<long>(shape->m_dHeight * c_dMMToPix);
|
||||
|
||||
if (width_pix == 0) width_pix = 1;
|
||||
if (height_pix == 0) height_pix = 1;
|
||||
|
||||
const long step = 4;
|
||||
const long stride = -step * width_pix;
|
||||
|
||||
@ -273,6 +294,7 @@ namespace NSDocxRenderer
|
||||
g_renderer->put_Width(shape->m_dWidth);
|
||||
g_renderer->put_Height(shape->m_dHeight);
|
||||
g_renderer->RestoreBrush(shifted_brush);
|
||||
g_renderer->RestorePen(*m_pPen);
|
||||
g_renderer->BeginCommand(c_nPathType);
|
||||
shifted_vector.DrawOnRenderer(g_renderer);
|
||||
g_renderer->DrawPath(c_nWindingFillMode);
|
||||
@ -281,29 +303,31 @@ namespace NSDocxRenderer
|
||||
Aggplus::CImage img;
|
||||
img.Create(data, width_pix, height_pix, stride, true);
|
||||
info = m_pImageManager->WriteImage(&img, shape->m_dTop, shape->m_dBaselinePos, shape->m_dWidth, shape->m_dHeight);
|
||||
left = shape->m_dLeft;
|
||||
right = shape->m_dRight;
|
||||
top = shape->m_dTop;
|
||||
bot = shape->m_dBaselinePos;
|
||||
rotation = 0;
|
||||
image_vector = shape->m_oVector;
|
||||
|
||||
m_bIsGradient = false;
|
||||
RELEASEINTERFACE(g_renderer)
|
||||
}
|
||||
shape->m_dRotation = rotation;
|
||||
|
||||
if (info)
|
||||
{
|
||||
shape->m_pImageInfo = info;
|
||||
shape->m_eType = CShape::eShapeType::stVectorTexture;
|
||||
image_vector.RotateAt(-shape->m_dRotation, shape->m_oVector.GetCenter());
|
||||
|
||||
shape->m_dImageBot = bot;
|
||||
shape->m_dImageTop = top;
|
||||
shape->m_dImageLeft = left;
|
||||
shape->m_dImageRight = right;
|
||||
shape->m_dImageBot = image_vector.GetBottom();
|
||||
shape->m_dImageTop = image_vector.GetTop();
|
||||
shape->m_dImageLeft = image_vector.GetLeft();
|
||||
shape->m_dImageRight = image_vector.GetRight();
|
||||
}
|
||||
else
|
||||
shape->m_eType = CShape::eShapeType::stVectorGraphics;
|
||||
|
||||
if (!shape->IsOoxmlValid())
|
||||
return;
|
||||
|
||||
// big white shape with page width & height skip
|
||||
if (fabs(shape->m_dHeight - m_dHeight) <= c_dSHAPE_X_OFFSET * 2 &&
|
||||
fabs(shape->m_dWidth - m_dWidth) <= c_dSHAPE_X_OFFSET * 2 &&
|
||||
@ -311,10 +335,7 @@ namespace NSDocxRenderer
|
||||
return;
|
||||
|
||||
shape->m_nOrder = ++m_nShapeOrder;
|
||||
shape->m_dRotation = rotation;
|
||||
m_arShapes.push_back(shape);
|
||||
|
||||
m_oClipVectorGraphics.Clear();
|
||||
}
|
||||
|
||||
void CPage::CollectTextData(
|
||||
@ -797,18 +818,18 @@ namespace NSDocxRenderer
|
||||
continue;
|
||||
|
||||
// если совпадает строка по высоте - берем ее и выходим
|
||||
if (fabs(line->m_dBaselinePos - drop_cap_cont->m_dBaselinePos) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
if (fabs(line->m_dBotWithMaxDescent - drop_cap_cont->m_dBotWithDescent) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
{
|
||||
num_of_lines++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (line->m_dBaselinePos > drop_cap_cont->m_dBaselinePos)
|
||||
break;
|
||||
|
||||
if (fabs(line->m_dTop - drop_cap_cont->m_dTop) > c_dTHE_SAME_STRING_Y_PRECISION_MM && line->m_dTop < drop_cap_cont->m_dTop)
|
||||
if (line->m_dBotWithMaxDescent < drop_cap_cont->m_dTopWithAscent)
|
||||
continue;
|
||||
|
||||
if (line->m_dTopWithMaxAscent > drop_cap_cont->m_dBotWithDescent)
|
||||
break;
|
||||
|
||||
num_of_lines++;
|
||||
}
|
||||
if (num_of_lines > 1)
|
||||
@ -911,10 +932,16 @@ namespace NSDocxRenderer
|
||||
pNextLine->m_pLine = pCurrLine;
|
||||
}
|
||||
}
|
||||
else if (!is_font_effect && pCurrCont->IsDuplicate(pNextCont.get(), eVType))
|
||||
else if (!is_font_effect && pCurrCont->IsDuplicate(pNextCont.get(), eVType, eHType))
|
||||
{
|
||||
pNextCont = nullptr;
|
||||
pCurrCont->m_iNumDuplicates++;
|
||||
// if (!pCurrCont->m_pFontStyle.get()->bBold)
|
||||
// {
|
||||
// CFontStyle font_style = *pCurrCont->m_pFontStyle;
|
||||
// font_style.bBold = true;
|
||||
// pCurrCont->m_pFontStyle = m_pFontStyleManager->GetOrAddFontStyle(font_style);
|
||||
// }
|
||||
}
|
||||
}
|
||||
if (pNextLine && pNextLine->IsCanBeDeleted())
|
||||
@ -1252,20 +1279,9 @@ namespace NSDocxRenderer
|
||||
{
|
||||
for (size_t i = 0; i < m_arTextLines.size(); ++i)
|
||||
{
|
||||
auto& pCurrLine = m_arTextLines[i];
|
||||
if (!pCurrLine)
|
||||
continue;
|
||||
|
||||
for (size_t j = 0; j < pCurrLine->m_arConts.size(); ++j)
|
||||
{
|
||||
auto& pCurrCont = pCurrLine->m_arConts[j];
|
||||
if (!pCurrCont)
|
||||
continue;
|
||||
|
||||
if (pCurrCont->m_iNumDuplicates > 0)
|
||||
pCurrLine->m_iNumDuplicates = std::max(pCurrLine->m_iNumDuplicates, pCurrCont->m_iNumDuplicates);
|
||||
}
|
||||
pCurrLine->MergeConts();
|
||||
auto& curr_line = m_arTextLines[i];
|
||||
if (!curr_line) continue;
|
||||
curr_line->MergeConts();
|
||||
}
|
||||
DetermineDominantGraphics();
|
||||
}
|
||||
@ -1541,19 +1557,6 @@ namespace NSDocxRenderer
|
||||
if (!curr_line)
|
||||
continue;
|
||||
|
||||
// если у текущей линии есть дубликаты, то создаем из них шейпы
|
||||
if (curr_line->m_iNumDuplicates > 0)
|
||||
{
|
||||
size_t duplicates = curr_line->m_iNumDuplicates;
|
||||
m_arShapes.push_back(CreateSingleLineShape(curr_line));
|
||||
while (duplicates > 0)
|
||||
{
|
||||
m_arShapes.push_back(CreateSingleLineShape(curr_line));
|
||||
duplicates--;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// если линия пересекается с предыдущей линией
|
||||
if (index && m_arTextLines[index - 1])
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
#include "managers/ImageManager.h"
|
||||
#include "managers/FontStyleManager.h"
|
||||
#include "managers/ParagraphStyleManager.h"
|
||||
#include "convert_params.h"
|
||||
#include "../../convert_params.h"
|
||||
|
||||
namespace NSDocxRenderer
|
||||
{
|
||||
|
||||
@ -95,12 +95,12 @@ namespace NSDocxRenderer
|
||||
return eHorizontalCrossingType::hctCurrentOutsideNext;
|
||||
}
|
||||
else if (m_dLeft < oSrc->m_dLeft && m_dRight < oSrc->m_dRight &&
|
||||
(m_dRight >= oSrc->m_dLeft || fabs(m_dRight - oSrc->m_dLeft) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
|
||||
(m_dRight >= oSrc->m_dLeft || fabs(m_dRight - oSrc->m_dLeft) < c_dTHE_SAME_STRING_X_PRECISION_MM))
|
||||
{
|
||||
return eHorizontalCrossingType::hctCurrentLeftOfNext;
|
||||
}
|
||||
else if (m_dLeft > oSrc->m_dLeft && m_dRight > oSrc->m_dRight &&
|
||||
(m_dLeft <= oSrc->m_dRight || fabs(m_dLeft - oSrc->m_dRight) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
|
||||
(m_dLeft <= oSrc->m_dRight || fabs(m_dLeft - oSrc->m_dRight) < c_dTHE_SAME_STRING_X_PRECISION_MM))
|
||||
{
|
||||
return eHorizontalCrossingType::hctCurrentRightOfNext;
|
||||
}
|
||||
@ -109,8 +109,8 @@ namespace NSDocxRenderer
|
||||
{
|
||||
return eHorizontalCrossingType::hctDublicate;
|
||||
}
|
||||
else if (fabs(m_dLeft - oSrc->m_dLeft) < c_dTHE_SAME_STRING_Y_PRECISION_MM &&
|
||||
fabs(m_dRight - oSrc->m_dRight) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
else if (fabs(m_dLeft - oSrc->m_dLeft) < c_dTHE_SAME_STRING_X_PRECISION_MM &&
|
||||
fabs(m_dRight - oSrc->m_dRight) < c_dTHE_SAME_STRING_X_PRECISION_MM)
|
||||
{
|
||||
return eHorizontalCrossingType::hctLeftAndRightBordersMatch;
|
||||
}
|
||||
|
||||
@ -195,8 +195,7 @@ namespace NSDocxRenderer
|
||||
(this_top <= other_bot || fabs(this_top - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
|
||||
return eVerticalCrossingType::vctCurrentBelowNext;
|
||||
|
||||
else if (this_top == other_top && this_bot == other_bot &&
|
||||
m_dLeft == pCont->m_dLeft && m_dRight == pCont->m_dRight)
|
||||
else if (this_top == other_top && this_bot == other_bot)
|
||||
return eVerticalCrossingType::vctDublicate;
|
||||
|
||||
else if (fabs(this_top - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM &&
|
||||
@ -529,11 +528,17 @@ namespace NSDocxRenderer
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CContText::IsDuplicate(CContText* pCont, eVerticalCrossingType eVType) const noexcept
|
||||
bool CContText::IsDuplicate(CContText* pCont, eVerticalCrossingType eVType, eHorizontalCrossingType eHType) const noexcept
|
||||
{
|
||||
if (eVType == eVerticalCrossingType::vctDublicate && m_oText == pCont->m_oText)
|
||||
return true;
|
||||
return false;
|
||||
return m_oText == pCont->m_oText &&
|
||||
eVType == eVerticalCrossingType::vctDublicate &&
|
||||
eHType == eHorizontalCrossingType::hctDublicate;
|
||||
|
||||
// return m_oText == pCont->m_oText &&
|
||||
// eVType == eVerticalCrossingType::vctDublicate &&
|
||||
// (eHType == eHorizontalCrossingType::hctDublicate ||
|
||||
// eHType == eHorizontalCrossingType::hctCurrentLeftOfNext ||
|
||||
// eHType == eHorizontalCrossingType::hctCurrentRightOfNext);
|
||||
}
|
||||
|
||||
bool CContText::IsOnlySpaces() const
|
||||
|
||||
@ -110,7 +110,7 @@ namespace NSDocxRenderer
|
||||
bool IsEqual(const CContText* pCont) const noexcept;
|
||||
|
||||
UINT GetNumberOfFeatures() const noexcept;
|
||||
bool IsDuplicate(CContText *pCont, eVerticalCrossingType eVType) const noexcept;
|
||||
bool IsDuplicate(CContText* pCont, eVerticalCrossingType eVType, eHorizontalCrossingType eHType) const noexcept;
|
||||
|
||||
bool IsOnlySpaces() const;
|
||||
double CalculateSpace() const noexcept;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user