mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-03-15 18:22:19 +08:00
Compare commits
112 Commits
v8.2.0.91
...
feature/do
| Author | SHA1 | Date | |
|---|---|---|---|
| 8550bdeed6 | |||
| 5aae57aad8 | |||
| 1d4f825ea6 | |||
| 0527472fef | |||
| c911733bd7 | |||
| 46f254c85d | |||
| a6a7d919e6 | |||
| 755d6cd970 | |||
| 604dc14d23 | |||
| 2263d7bf80 | |||
| ef415aad3f | |||
| 6744c172f4 | |||
| 6ea3a9551e | |||
| f48ab0351c | |||
| 632ddf9805 | |||
| 2c61e84e94 | |||
| 375b37e9aa | |||
| bb3e2e3bc2 | |||
| 1a5b8b4bbd | |||
| 901c44b486 | |||
| 88eadd9955 | |||
| b5f88cebaf | |||
| e0e7e31568 | |||
| 00344df9ad | |||
| cfb060e142 | |||
| 0565e6164b | |||
| 306cc3f985 | |||
| 2739dd3abd | |||
| 70e6df5aae | |||
| 96030aa322 | |||
| fee801eeeb | |||
| 750273b526 | |||
| cfdb541c28 | |||
| 11121961d9 | |||
| 45828709ee | |||
| 40916e5ccc | |||
| 319610c58d | |||
| 1837a2737e | |||
| 686fc60860 | |||
| 51216f27f4 | |||
| 2eb33ddd22 | |||
| 58c80b052b | |||
| 5eee408eeb | |||
| b6ae1f272c | |||
| 045f23d921 | |||
| d06b52988c | |||
| 4717b47388 | |||
| 31ce9f6a18 | |||
| e44c9fa4c9 | |||
| 3c59ba7a13 | |||
| 42e84249e8 | |||
| e2dbde8722 | |||
| 36c67d79d5 | |||
| cdc14d22f0 | |||
| baed05236b | |||
| c644f94c0b | |||
| 087e4433f2 | |||
| bc11a5cf5f | |||
| d86303e290 | |||
| 51f1faa51a | |||
| 6775dccc2c | |||
| ee3b4c612d | |||
| 1144bb166c | |||
| a9752208f6 | |||
| 84016cf8cf | |||
| cb7edc373c | |||
| d1e43d68dc | |||
| b5ab5f9b2b | |||
| 761c5bec53 | |||
| 8cc7034c22 | |||
| ee1c385b54 | |||
| ded640825b | |||
| 84301531c8 | |||
| 310cd6d8fd | |||
| 2d37cf634a | |||
| 04880b4e1d | |||
| 1000b5d5bd | |||
| c324b4a11c | |||
| a51fe4134c | |||
| 985d258bc1 | |||
| fee5c112b4 | |||
| 9b50f9fbc2 | |||
| 10f770fdbc | |||
| eb53c40135 | |||
| ded1655a04 | |||
| 20c11889aa | |||
| 910c2418d6 | |||
| e6ffdc0ae8 | |||
| 0335d330b8 | |||
| af2e86e777 | |||
| bcf7d08c51 | |||
| 11886dcdf7 | |||
| 615d0b682c | |||
| 535028fa0e | |||
| 5a6386e08b | |||
| 7ca8b22160 | |||
| ec16e247e9 | |||
| 9a76575082 | |||
| c1a586cb56 | |||
| 7707aeb914 | |||
| 50a8540f75 | |||
| cc2e755bca | |||
| 9c1efdeac2 | |||
| ea1538bc11 | |||
| c0d0fb6f5c | |||
| 5e5e07b406 | |||
| 9b5f762420 | |||
| 7020548f06 | |||
| 2d2e15671a | |||
| 00ad32d420 | |||
| ba2cf66c31 | |||
| 2e26a3697d |
@ -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,20 @@ 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" \
|
||||
cxxflags="" \
|
||||
--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" \
|
||||
cxxflags="" \
|
||||
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" \
|
||||
cxxflags="" \
|
||||
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"
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@ -648,7 +648,7 @@ namespace NSStringUtils
|
||||
}
|
||||
void CStringBuilder::AddInt(int val)
|
||||
{
|
||||
AddSize(10);
|
||||
AddSize(11);
|
||||
AddIntNoCheck(val);
|
||||
}
|
||||
void CStringBuilder::AddUInt(unsigned int val)
|
||||
@ -683,6 +683,9 @@ namespace NSStringUtils
|
||||
if (val < 0)
|
||||
{
|
||||
val = -val;
|
||||
if (val < 0)
|
||||
val = 2147483647;
|
||||
|
||||
*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);
|
||||
|
||||
@ -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();
|
||||
|
||||
9
DesktopEditor/doctrenderer/samples/.gitignore
vendored
Normal file
9
DesktopEditor/doctrenderer/samples/.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
!*.vcxproj.user
|
||||
!Makefile
|
||||
|
||||
out/
|
||||
|
||||
*.docx
|
||||
*.pptx
|
||||
*.xlsx
|
||||
*.class
|
||||
156
DesktopEditor/doctrenderer/samples/README.md
Normal file
156
DesktopEditor/doctrenderer/samples/README.md
Normal file
@ -0,0 +1,156 @@
|
||||
- [Document Builder samples](#document-builder-samples)
|
||||
- [About](#about)
|
||||
- [Project generator: configure.py](#project-generator-configurepy)
|
||||
- [Running C++ samples](#running-c-samples)
|
||||
- [Visual Studio](#visual-studio)
|
||||
- [Qt](#qt)
|
||||
- [Makefile](#makefile)
|
||||
- [Running C# samples](#running-c-samples-1)
|
||||
- [Visual Studio](#visual-studio-1)
|
||||
- [Running Python samples](#running-python-samples)
|
||||
- [Running Java samples](#running-java-samples)
|
||||
|
||||
# Document Builder samples
|
||||
## About
|
||||
Here you can find some code samples for Document Builder library in different programming languages:
|
||||
1. [C++](#running-c-samples)
|
||||
2. [C# (.NET)](#running-c-samples-1)
|
||||
3. [Python](#running-python-samples)
|
||||
4. [Java](#running-java-samples)
|
||||
|
||||
## Project generator: configure.py
|
||||
For running C++ and C# code samples use python script `configure/configure.py` which is able to generate:
|
||||
+ Visual Studio project files
|
||||
+ Qt project file
|
||||
+ Makefile
|
||||
|
||||
To use `configure.py` you need to specify following options:
|
||||
1. Which project files to generate: `--vs`, `--qt` or `--make`. Several options are available at the same time, but some of them are not supported on all platforms. In case you provide none of these options, all available projects will be generated.
|
||||
2. Test samples with `--test TEST`. Some available options:
|
||||
- `--test all` – generate projects for both C++ and C#.
|
||||
- `--test cpp` – generate projects only for C++ samples
|
||||
- `--test cs` – generate projects only for C# samples.
|
||||
- `--test cpp/creating_basic_form` – generate only project for the specified sample.
|
||||
|
||||
Several test options are available at the same time. To see all available `TEST` options call `configure.py -l`.
|
||||
3. Directory to the Document Builder with `--dir DIR`. If Document Builder is not installed in default path you have to provide path to it.
|
||||
|
||||
Generated files will be located in the `out` directory inside of the corresponding test folders.
|
||||
|
||||
## Running C++ samples
|
||||
|
||||
If Document Builder is not installed in `C:/Program Files/ONLYOFFICE/DocumentBuilder`, for every C++ sample you should change the `workDir` variable at the beginning of *main.cpp* to actual location of Document Builder directory.
|
||||
|
||||
### Visual Studio
|
||||
|
||||
> **NOTE:** Only available on Windows
|
||||
|
||||
1. Use `configure.py` to generate VS project files. For example:
|
||||
|
||||
```shell
|
||||
python configure.py --vs --test cpp/creating_basic_form --test cpp/creating_advanced_form
|
||||
```
|
||||
|
||||
2. Open `.sln` file in Visual Studio. It will prompt you to retarget Windows SDK and VS toolset to your installed version – click "OK".
|
||||
3. The solution is ready to be built and run. Documents will be created in the project files directory.
|
||||
|
||||
### Qt
|
||||
1. Use `configure.py` to generate Qt project files. For example:
|
||||
|
||||
```shell
|
||||
python configure.py --qt --test cpp
|
||||
```
|
||||
|
||||
2. Open `.pro` file in Qt Creator.
|
||||
3. The project is ready to be built and run. Documents will be created in the `build` directory.
|
||||
|
||||
### Makefile
|
||||
|
||||
> **NOTE:** Only available on Linux and Mac OS.
|
||||
|
||||
1. Use `configure.py` to generate Makefile. For example:
|
||||
|
||||
```shell
|
||||
python configure.py --make --test cpp/filling_spreadsheet
|
||||
```
|
||||
|
||||
2. Go to the directory with generated Makefile:
|
||||
|
||||
```shell
|
||||
cd ../out/cpp/filling_spreadsheet
|
||||
```
|
||||
|
||||
3. Call
|
||||
|
||||
```shell
|
||||
make
|
||||
```
|
||||
|
||||
`make` will build and run the executable. Documents will be created in the same directory as Makefile is.
|
||||
|
||||
## Running C# samples
|
||||
|
||||
> **NOTE:** Only available on Windows with Visual Studio and .NET SDK installed
|
||||
|
||||
If Document Builder is not installed in `C:/Program Files/ONLYOFFICE/DocumentBuilder`, for every C# sample you should change the `workDirectory` variable at the beginning of `Main` function to actual location of Document Builder directory.
|
||||
|
||||
### Visual Studio
|
||||
1. Use `configure.py` to generate VS project files. For example:
|
||||
|
||||
```shell
|
||||
python configure.py --vs --test cs
|
||||
```
|
||||
|
||||
2. Open `.sln` file in Visual Studio. Depending on your installed .NET SDK version you may need to set different target framework by setting it in Visual Studio project properties or editing it directly in the `.csproj` file.
|
||||
3. The solution is ready to be built and run. Documents will be created in the project files directory.
|
||||
|
||||
## Running Python samples
|
||||
|
||||
1. Go to test directory:
|
||||
|
||||
```shell
|
||||
cd python/creating_basic_form
|
||||
```
|
||||
|
||||
2. If it is needed, edit path to builder directory at the beginning of the python script:
|
||||
|
||||
```py
|
||||
sys.path.append('C:/Program Files/ONLYOFFICE/DocumentBuilder')
|
||||
```
|
||||
3. Run the script
|
||||
|
||||
```shell
|
||||
python main.py
|
||||
```
|
||||
|
||||
Documents will be created in the test directory.
|
||||
|
||||
## Running Java samples
|
||||
|
||||
> **NOTE:** JDK 8 or newer is required
|
||||
|
||||
1. Go to test directory:
|
||||
|
||||
```shell
|
||||
cd java/creating_presentation
|
||||
```
|
||||
|
||||
2. Compile the `Program.java` providing the path to ***docbuilder.jar***, located in the Document Builder directory:
|
||||
|
||||
```shell
|
||||
javac -cp "C:\Program Files\ONLYOFFICE\DocumentBuilder\docbuilder.jar" Program.java
|
||||
```
|
||||
|
||||
3. `.class` file should appear in the directory. Run the program:
|
||||
|
||||
```shell
|
||||
java -cp "C:\Program Files\ONLYOFFICE\DocumentBuilder\docbuilder.jar;." Program
|
||||
```
|
||||
|
||||
Note, that on UNIX systems the path separator is `:` instead of `;`. Thus, on Linux or Mac OS it should be:
|
||||
|
||||
```shell
|
||||
java -cp "/opt/onlyoffice/documentbuilder/docbuilder.jar:." Program
|
||||
```
|
||||
|
||||
3. Documents will be created in the test directory.
|
||||
293
DesktopEditor/doctrenderer/samples/configure/configure.py
Normal file
293
DesktopEditor/doctrenderer/samples/configure/configure.py
Normal file
@ -0,0 +1,293 @@
|
||||
import os
|
||||
import argparse
|
||||
import platform
|
||||
import uuid
|
||||
|
||||
langs = ['cpp', 'cs']
|
||||
os_name = platform.system().lower()
|
||||
|
||||
def mkdir(dir):
|
||||
if not os.path.exists(dir):
|
||||
os.mkdir(dir)
|
||||
|
||||
def log(level, message):
|
||||
print('configure.py: ' + level + ': ' + message)
|
||||
|
||||
def getDefaultBuilderDir():
|
||||
dir = ''
|
||||
if os_name == 'windows':
|
||||
dir = 'C:\\Program Files\\ONLYOFFICE\\DocumentBuilder'
|
||||
elif os_name == 'linux':
|
||||
dir = '/opt/onlyoffice/documentbuilder'
|
||||
return dir
|
||||
|
||||
def getAllTests():
|
||||
tests = {}
|
||||
for lang in langs:
|
||||
tests[lang] = []
|
||||
test_dirs = os.listdir(lang)
|
||||
for test_dir in test_dirs:
|
||||
if not os.path.isdir(lang + '/' + test_dir):
|
||||
continue
|
||||
tests[lang].append(lang + '/' + test_dir)
|
||||
return tests
|
||||
|
||||
def printAvailableTests():
|
||||
all_tests = getAllTests()
|
||||
print('all')
|
||||
for lang in langs:
|
||||
print('-----')
|
||||
print(lang)
|
||||
tests = all_tests[lang]
|
||||
for test in tests:
|
||||
print(test)
|
||||
|
||||
class PrintTestsList(argparse.Action):
|
||||
def __call__(self, parser, namespace, values, option_string=None):
|
||||
printAvailableTests()
|
||||
exit()
|
||||
|
||||
def getSelectedTests(tests):
|
||||
all_tests = getAllTests()
|
||||
# make set of all available tests
|
||||
tests_set = {'all'}
|
||||
for lang in langs:
|
||||
tests_set.add(lang)
|
||||
tests_set.update(all_tests[lang])
|
||||
# make dict with set of selected tests
|
||||
tests_selected = {lang: set() for lang in langs}
|
||||
# filter tests through only available ones
|
||||
for test in tests:
|
||||
if not test in tests_set:
|
||||
log('warning', 'wrong test "' + test + '". Call script with --list (or -l) to see all available tests')
|
||||
continue
|
||||
|
||||
if test == 'all':
|
||||
for lang in langs:
|
||||
tests_selected[lang].update(all_tests[lang])
|
||||
elif not '/' in test:
|
||||
lang = test
|
||||
tests_selected[lang].update(all_tests[lang])
|
||||
else:
|
||||
lang = test.split('/')[0]
|
||||
tests_selected[lang].add(test)
|
||||
# delete empty tests
|
||||
for lang in langs:
|
||||
if not tests_selected[lang]:
|
||||
del tests_selected[lang]
|
||||
|
||||
return tests_selected
|
||||
|
||||
def replacePlaceholders(template_file, output_file, replacements):
|
||||
content = ''
|
||||
# open and read template file
|
||||
with open(template_file, 'r') as file:
|
||||
content = file.read()
|
||||
# replace all placeholders with corresponding values
|
||||
for placeholder, replacement in replacements.items():
|
||||
content = content.replace(placeholder, replacement)
|
||||
# write result to output file
|
||||
with open(output_file, 'w') as file:
|
||||
file.write(content)
|
||||
|
||||
def genVSProjectsCPP(tests, builder_dir):
|
||||
for test in tests:
|
||||
test_dir = 'out/' + test
|
||||
mkdir(test_dir)
|
||||
test_name = test.split('/')[1]
|
||||
if os.path.exists(test_dir + '/' + test_name + '.vcxproj'):
|
||||
log('info', 'VS C++ project for sample "' + test + '" already exists. Skipping.')
|
||||
continue
|
||||
else:
|
||||
log('info', 'generating VS C++ project for sample "' + test + '"...')
|
||||
# .vcxproj
|
||||
project_guid = str(uuid.uuid4())
|
||||
replacements = {
|
||||
'[PROJECT_GUID]': project_guid,
|
||||
'[TEST_NAME]': test_name,
|
||||
'[BUILDER_DIR]': builder_dir,
|
||||
'[ROOT_DIR]': os.getcwd()
|
||||
}
|
||||
replacePlaceholders('configure/project_templates/cpp/template.vcxproj', test_dir + '/' + test_name + '.vcxproj', replacements)
|
||||
# .sln
|
||||
replacements = {
|
||||
'[SOLUTION_GUID]': str(uuid.uuid4()).upper(),
|
||||
'[TEST_NAME]': test_name,
|
||||
'[PROJECT_GUID]': project_guid.upper(),
|
||||
'[EXT_GLOBALS_GUID]': str(uuid.uuid4()).upper()
|
||||
}
|
||||
replacePlaceholders('configure/project_templates/cpp/template.sln', test_dir + '/' + test_name + '.sln', replacements)
|
||||
# .vcxproj.filters
|
||||
replacements = {
|
||||
'[GUID_SOURCE_FILES]': str(uuid.uuid4()).upper(),
|
||||
'[GUID_HEADER_FILES]': str(uuid.uuid4()).upper(),
|
||||
'[GUID_RESOURCE_FILES]': str(uuid.uuid4()).upper(),
|
||||
'[TEST_NAME]': test_name
|
||||
}
|
||||
replacePlaceholders('configure/project_templates/cpp/template.vcxproj.filters', test_dir + '/' + test_name + '.vcxproj.filters', replacements)
|
||||
# .vcxproj.user
|
||||
replacements = {
|
||||
'[BUILDER_DIR]': builder_dir
|
||||
}
|
||||
replacePlaceholders('configure/project_templates/cpp/template.vcxproj.user', test_dir + '/' + test_name + '.vcxproj.user', replacements)
|
||||
|
||||
def genVSProjectsCS(tests, builder_dir):
|
||||
for test in tests:
|
||||
test_dir = 'out/' + test
|
||||
mkdir(test_dir)
|
||||
test_name = test.split('/')[1]
|
||||
if os.path.exists(test_dir + '/' + test_name + '.csproj'):
|
||||
log('info', 'VS C# project for sample "' + test + '" already exists. Skipping.')
|
||||
continue
|
||||
else:
|
||||
log('info', 'generating VS C# project for sample "' + test + '"...')
|
||||
# .csproj
|
||||
project_guid = str(uuid.uuid4())
|
||||
replacements = {
|
||||
'[TEST_NAME]': test_name,
|
||||
'[BUILDER_DIR]': builder_dir,
|
||||
}
|
||||
replacePlaceholders('configure/project_templates/cs/template.csproj', test_dir + '/' + test_name + '.csproj', replacements)
|
||||
# .sln
|
||||
replacements = {
|
||||
'[SOLUTION_GUID]': str(uuid.uuid4()).upper(),
|
||||
'[TEST_NAME]': test_name,
|
||||
'[PROJECT_GUID]': project_guid.upper(),
|
||||
'[EXT_GLOBALS_GUID]': str(uuid.uuid4()).upper()
|
||||
}
|
||||
replacePlaceholders('configure/project_templates/cs/template.sln', test_dir + '/' + test_name + '.sln', replacements)
|
||||
|
||||
def genVSProjects(tests_selected, builder_dir):
|
||||
if os_name != 'windows':
|
||||
log('warning', 'generating Visual Studio projects is only available on Windows')
|
||||
return
|
||||
|
||||
builder_dir = builder_dir.replace('/', '\\')
|
||||
for lang, tests in tests_selected.items():
|
||||
mkdir('out/' + lang)
|
||||
if lang == 'cpp':
|
||||
genVSProjectsCPP(tests, builder_dir)
|
||||
elif lang == 'cs':
|
||||
genVSProjectsCS(tests, builder_dir)
|
||||
|
||||
def genQtProjects(tests_selected, builder_dir):
|
||||
# only for C++ projects
|
||||
if 'cpp' not in tests_selected:
|
||||
return
|
||||
|
||||
root_dir = os.getcwd()
|
||||
if os_name == 'windows':
|
||||
builder_dir = builder_dir.replace('\\', '/')
|
||||
root_dir = root_dir.replace('\\', '/')
|
||||
|
||||
tests = tests_selected['cpp']
|
||||
mkdir('out/cpp')
|
||||
for test in tests:
|
||||
test_dir = 'out/' + test
|
||||
mkdir(test_dir)
|
||||
test_name = test.split('/')[1]
|
||||
if os.path.exists(test_dir + '/' + test_name + '.pro'):
|
||||
log('info', 'Qt project for sample "' + test + '" already exists. Skipping.')
|
||||
continue
|
||||
else:
|
||||
log('info', 'generating Qt C++ project for sample "' + test + '"...')
|
||||
# .pro
|
||||
replacements = {
|
||||
'[TEST_NAME]': test_name,
|
||||
'[BUILDER_DIR]': builder_dir,
|
||||
'[ROOT_DIR]': root_dir
|
||||
}
|
||||
replacePlaceholders('configure/project_templates/cpp/template.pro', test_dir + '/' + test_name + '.pro', replacements)
|
||||
|
||||
def genMakefile(tests_selected, builder_dir):
|
||||
# only for C++ projects
|
||||
if 'cpp' not in tests_selected:
|
||||
return
|
||||
|
||||
if os_name == 'windows':
|
||||
log('warning', 'generating Makefile is not available on Windows')
|
||||
return
|
||||
|
||||
# initialize variables
|
||||
compiler = ''
|
||||
lflags = ''
|
||||
env_lib_path = ''
|
||||
if os_name == 'linux':
|
||||
compiler = 'g++'
|
||||
lflags = '-Wl,--unresolved-symbols=ignore-in-shared-libs'
|
||||
env_lib_path = 'LD_LIBRARY_PATH'
|
||||
elif os_name == 'darwin':
|
||||
compiler = 'clang++'
|
||||
env_lib_path = 'DYLD_LIBRARY_PATH'
|
||||
root_dir = os.getcwd()
|
||||
tests = tests_selected['cpp']
|
||||
mkdir('out/cpp')
|
||||
for test in tests:
|
||||
test_dir = 'out/' + test
|
||||
mkdir(test_dir)
|
||||
test_name = test.split('/')[1]
|
||||
if os.path.exists(test_dir + '/Makefile'):
|
||||
log('info', 'Makefile for sample "' + test + '" already exists. Skipping.')
|
||||
else:
|
||||
log('info', 'generating Makefile for C++ sample "' + test + '"...')
|
||||
continue
|
||||
# Makefile
|
||||
replacements = {
|
||||
'[TEST_NAME]': test_name,
|
||||
'[BUILDER_DIR]': builder_dir,
|
||||
'[ROOT_DIR]': root_dir,
|
||||
'[COMPILER]': compiler,
|
||||
'[LFLAGS]': lflags,
|
||||
'[ENV_LIB_PATH]': env_lib_path
|
||||
}
|
||||
replacePlaceholders('configure/project_templates/cpp/Makefile', test_dir + '/Makefile', replacements)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# go to root dir
|
||||
file_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
os.chdir(file_dir + '/..')
|
||||
# initialize argument parser
|
||||
parser = argparse.ArgumentParser(description='Generate project files for Document Builder samples')
|
||||
parser.add_argument('--vs', action='store_true', help='create Visual Studio (.vcxproj and .csproj) project files')
|
||||
parser.add_argument('--qt', action='store_true', help='create Qt (.pro) project files')
|
||||
parser.add_argument('--make', action='store_true', help='create Makefile')
|
||||
parser.add_argument('-t', '--test', dest='tests', action='append', help='specifies tests to generate project files', required=True)
|
||||
parser.add_argument('-l', '--list', action=PrintTestsList, nargs=0, help='show list of available tests and exit')
|
||||
|
||||
builder_dir = getDefaultBuilderDir()
|
||||
if builder_dir:
|
||||
parser.add_argument('--dir', action='store', help='specifies Document Builder directory (default: ' + builder_dir + ')', default=builder_dir)
|
||||
else:
|
||||
parser.add_argument('--dir', action='store', help='specifies Document Builder directory', required=True)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# validate arguments
|
||||
if not os.path.exists(args.dir):
|
||||
log('error', 'Document Builder directory doesn\'t exist: ' + args.dir)
|
||||
exit(1)
|
||||
|
||||
if not (args.vs or args.qt or args.make):
|
||||
if os_name == 'windows':
|
||||
args.vs = True
|
||||
args.qt = True
|
||||
if os_name != 'windows':
|
||||
args.make = True
|
||||
|
||||
# filter tests
|
||||
tests_selected = getSelectedTests(args.tests)
|
||||
|
||||
# generate projects
|
||||
mkdir('out')
|
||||
# VS
|
||||
if args.vs:
|
||||
genVSProjects(tests_selected, args.dir)
|
||||
elif 'cs' in tests_selected:
|
||||
log('warning', 'generating C# projects only available ' + ('on Windows ' if os_name != 'windows' else '') + 'with --vs')
|
||||
# Qt
|
||||
if args.qt:
|
||||
genQtProjects(tests_selected, args.dir)
|
||||
# Makefile
|
||||
if args.make:
|
||||
genMakefile(tests_selected, args.dir)
|
||||
@ -0,0 +1,29 @@
|
||||
CXX = [COMPILER]
|
||||
CXXFLAGS = -std=gnu++11 -Wall -W -fPIC
|
||||
INCPATH = -I[BUILDER_DIR]/include -I[ROOT_DIR]
|
||||
LINK = [COMPILER]
|
||||
LFLAGS = [LFLAGS]
|
||||
LIBS = -L[BUILDER_DIR] -ldoctrenderer
|
||||
|
||||
BUILD_DIR = build
|
||||
|
||||
SRC = ../../../cpp/[TEST_NAME]/main.cpp
|
||||
OBJ = $(BUILD_DIR)/main.o
|
||||
TARGET = $(BUILD_DIR)/[TEST_NAME]
|
||||
|
||||
.PHONY: all run clean
|
||||
|
||||
all: $(TARGET) run
|
||||
|
||||
$(TARGET): $(OBJ)
|
||||
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJ) $(LIBS)
|
||||
|
||||
$(OBJ): $(SRC)
|
||||
@test -d $(BUILD_DIR) || mkdir -p $(BUILD_DIR)
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $(OBJ) $(SRC)
|
||||
|
||||
run: $(TARGET)
|
||||
[ENV_LIB_PATH]="[BUILDER_DIR]" ./$(TARGET)
|
||||
|
||||
clean:
|
||||
@rm -rf $(BUILD_DIR)
|
||||
@ -0,0 +1,17 @@
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TARGET = [TEST_NAME]
|
||||
DESTDIR = $$PWD/build
|
||||
|
||||
BUILDER_DIR = "[BUILDER_DIR]"
|
||||
ROOT_DIR = "[ROOT_DIR]"
|
||||
INCLUDEPATH += $$BUILDER_DIR/include
|
||||
INCLUDEPATH += $$ROOT_DIR
|
||||
LIBS += -L$$BUILDER_DIR -ldoctrenderer
|
||||
|
||||
linux: QMAKE_LFLAGS += -Wl,--unresolved-symbols=ignore-in-shared-libs
|
||||
|
||||
SOURCES += ../../../cpp/[TEST_NAME]/main.cpp
|
||||
@ -0,0 +1,29 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{[SOLUTION_GUID]}") = "[TEST_NAME]", "[TEST_NAME].vcxproj", "{[PROJECT_GUID]}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{[PROJECT_GUID]}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{[PROJECT_GUID]}.Debug|x64.Build.0 = Debug|x64
|
||||
{[PROJECT_GUID]}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{[PROJECT_GUID]}.Debug|x86.Build.0 = Debug|Win32
|
||||
{[PROJECT_GUID]}.Release|x64.ActiveCfg = Release|x64
|
||||
{[PROJECT_GUID]}.Release|x64.Build.0 = Release|x64
|
||||
{[PROJECT_GUID]}.Release|x86.ActiveCfg = Release|Win32
|
||||
{[PROJECT_GUID]}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {[EXT_GLOBALS_GUID]}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@ -0,0 +1,147 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{[PROJECT_GUID]}</ProjectGuid>
|
||||
<RootNamespace>[TEST_NAME]</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>[BUILDER_DIR]\include;[ROOT_DIR];$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>[BUILDER_DIR]\include;[ROOT_DIR];$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>[BUILDER_DIR];%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>doctrenderer.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>[BUILDER_DIR];%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>doctrenderer.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\cpp\[TEST_NAME]\main.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{[GUID_SOURCE_FILES]}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{[GUID_HEADER_FILES]}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{[GUID_RESOURCE_FILES]}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\cpp\[TEST_NAME]\main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LocalDebuggerEnvironment>PATH=[BUILDER_DIR];%PATH%
|
||||
$(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LocalDebuggerEnvironment>PATH=[BUILDER_DIR];%PATH%
|
||||
$(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\..\cs\[TEST_NAME]\Program.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="[BUILDER_DIR]\docbuilder.net.dll" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,23 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{[SOLUTION_GUID]}") = "[TEST_NAME]", "[TEST_NAME].csproj", "{[PROJECT_GUID]}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{[PROJECT_GUID]}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{[PROJECT_GUID]}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{[PROJECT_GUID]}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{[PROJECT_GUID]}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {[EXT_GLOBALS_GUID]}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include "common.h"
|
||||
#include "docbuilder.h"
|
||||
|
||||
#include "resources/utils/utils.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
const wchar_t* workDir = L"C:\\Program Files\\ONLYOFFICE\\DocumentBuilder";
|
||||
const wchar_t* resultPath = L"result.xlsx";
|
||||
|
||||
// Helper functions
|
||||
void CheckCell(CValue oWorksheet, wstring cell, int row, int col)
|
||||
{
|
||||
if (cell.find('#') != std::wstring::npos)
|
||||
{
|
||||
wstring commentMsg = L"Error: " + cell;
|
||||
CValue errorCell = oWorksheet.Call("GetRangeByNumber", row, col);
|
||||
errorCell.Call("AddComment", commentMsg.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// Main function
|
||||
int main()
|
||||
{
|
||||
// Init DocBuilder
|
||||
CDocBuilder::Initialize(workDir);
|
||||
CDocBuilder oBuilder;
|
||||
oBuilder.SetProperty("--work-directory", workDir);
|
||||
|
||||
// Open file and get context
|
||||
wstring templatePath = NSUtils::GetResourcesDirectory() + L"/docs/spreadsheet_with_errors.xlsx";
|
||||
oBuilder.OpenFile(templatePath.c_str(), L"");
|
||||
CContext oContext = oBuilder.GetContext();
|
||||
CContextScope oScope = oContext.CreateScope();
|
||||
CValue oGlobal = oContext.GetGlobal();
|
||||
CValue oApi = oGlobal["Api"];
|
||||
|
||||
// Find and comment formula errors
|
||||
CValue oWorksheet = oApi.Call("GetActiveSheet");
|
||||
CValue oRange = oWorksheet.Call("GetUsedRange");
|
||||
CValue data = oRange.Call("GetValue");
|
||||
|
||||
for (int row = 0; row < (int)data.GetLength(); row++)
|
||||
{
|
||||
for (int col = 0; col < (int)data[0].GetLength(); col++)
|
||||
{
|
||||
CheckCell(oWorksheet, data[row][col].ToString().c_str(), row, col);
|
||||
}
|
||||
}
|
||||
|
||||
// Save and close
|
||||
oBuilder.SaveFile(OFFICESTUDIO_FILE_SPREADSHEET_XLSX, resultPath);
|
||||
oBuilder.CloseFile();
|
||||
CDocBuilder::Dispose();
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,206 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include "common.h"
|
||||
#include "docbuilder.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
const wchar_t* workDir = L"C:\\Program Files\\ONLYOFFICE\\DocumentBuilder";
|
||||
const wchar_t* resultPath = L"result.docx";
|
||||
|
||||
// Helper functions
|
||||
string cValueToString(CValue value)
|
||||
{
|
||||
wchar_t* txt = value.ToString().c_str();
|
||||
wstring ws(txt);
|
||||
string str(ws.begin(), ws.end());
|
||||
return str;
|
||||
}
|
||||
|
||||
void setTableBorders(CValue oTable, int borderColor)
|
||||
{
|
||||
oTable.Call("SetTableBorderTop", "single", 4, 0, borderColor, borderColor, borderColor);
|
||||
oTable.Call("SetTableBorderBottom", "single", 4, 0, borderColor, borderColor, borderColor);
|
||||
oTable.Call("SetTableBorderLeft", "single", 4, 0, borderColor, borderColor, borderColor);
|
||||
oTable.Call("SetTableBorderRight", "single", 4, 0, borderColor, borderColor, borderColor);
|
||||
oTable.Call("SetTableBorderInsideV", "single", 4, 0, borderColor, borderColor, borderColor);
|
||||
oTable.Call("SetTableBorderInsideH", "single", 4, 0, borderColor, borderColor, borderColor);
|
||||
}
|
||||
|
||||
CValue createFullWidthTable(CValue oApi, int rows, int cols, int borderColor)
|
||||
{
|
||||
CValue oTable = oApi.Call("CreateTable", cols, rows);
|
||||
oTable.Call("SetWidth", "percent", 100);
|
||||
setTableBorders(oTable, borderColor);
|
||||
return oTable;
|
||||
}
|
||||
|
||||
CValue getTableCellParagraph(CValue oTable, int row, int col)
|
||||
{
|
||||
return oTable.Call("GetCell", row, col).Call("GetContent").Call("GetElement", 0);
|
||||
}
|
||||
|
||||
void addTextToParagraph(CValue oParagraph, std::string text, int fontSize, bool isBold)
|
||||
{
|
||||
oParagraph.Call("AddText", text.c_str());
|
||||
oParagraph.Call("SetFontSize", fontSize);
|
||||
oParagraph.Call("SetBold", isBold);
|
||||
}
|
||||
|
||||
void setPictureFormProperties(CValue oPictureForm, std::string key, std::string tip, bool required, std::string placeholder, std::string scaleFlag, bool lockAspectRatio, bool respectBorders, int shiftX, int shiftY, std::string imageUrl)
|
||||
{
|
||||
oPictureForm.Call("SetFormKey", key.c_str());
|
||||
oPictureForm.Call("SetTipText", tip.c_str());
|
||||
oPictureForm.Call("SetRequired", required);
|
||||
oPictureForm.Call("SetPlaceholderText", placeholder.c_str());
|
||||
oPictureForm.Call("SetScaleFlag", scaleFlag.c_str());
|
||||
oPictureForm.Call("SetLockAspectRatio", lockAspectRatio);
|
||||
oPictureForm.Call("SetRespectBorders", respectBorders);
|
||||
oPictureForm.Call("SetPicturePosition", shiftX, shiftY);
|
||||
oPictureForm.Call("SetImage", imageUrl.c_str());
|
||||
}
|
||||
|
||||
void setTextFormProperties(CValue oTextForm, string key, string tip, bool required, string placeholder, bool comb, int maxCharacters, int cellWidth, bool multiLine, bool autoFit)
|
||||
{
|
||||
oTextForm.Call("SetFormKey", key.c_str());
|
||||
oTextForm.Call("SetTipText", tip.c_str());
|
||||
oTextForm.Call("SetRequired", required);
|
||||
oTextForm.Call("SetPlaceholderText", placeholder.c_str());
|
||||
oTextForm.Call("SetComb", comb);
|
||||
oTextForm.Call("SetCharactersLimit", maxCharacters);
|
||||
oTextForm.Call("SetCellWidth", cellWidth);
|
||||
oTextForm.Call("SetCellWidth", multiLine);
|
||||
oTextForm.Call("SetMultiline", autoFit);
|
||||
}
|
||||
|
||||
void addTextFormToParagraph(CValue oParagraph, CValue oTextForm, int fontSize, string jc, bool hasBorder, int borderColor)
|
||||
{
|
||||
if (hasBorder)
|
||||
{
|
||||
oTextForm.Call("SetBorderColor", borderColor, borderColor, borderColor);
|
||||
}
|
||||
oParagraph.Call("AddElement", oTextForm);
|
||||
oParagraph.Call("SetFontSize", fontSize);
|
||||
oParagraph.Call("SetJc", jc.c_str());
|
||||
}
|
||||
|
||||
// Main function
|
||||
int main()
|
||||
{
|
||||
// Init DocBuilder
|
||||
CDocBuilder::Initialize(workDir);
|
||||
CDocBuilder oBuilder;
|
||||
oBuilder.SetProperty("--work-directory", workDir);
|
||||
oBuilder.CreateFile(OFFICESTUDIO_FILE_DOCUMENT_DOCX);
|
||||
|
||||
CContext oContext = oBuilder.GetContext();
|
||||
CContextScope oScope = oContext.CreateScope();
|
||||
CValue oGlobal = oContext.GetGlobal();
|
||||
CValue oApi = oGlobal["Api"];
|
||||
|
||||
// Create advanced form
|
||||
CValue oDocument = oApi.Call("GetDocument");
|
||||
CValue oTable = createFullWidthTable(oApi, 1, 2, 255);
|
||||
CValue oParagraph = getTableCellParagraph(oTable, 0, 0);
|
||||
addTextToParagraph(oParagraph, "PURCHASE ORDER", 36, true);
|
||||
oParagraph = getTableCellParagraph(oTable, 0, 1);
|
||||
addTextToParagraph(oParagraph, "Serial # ", 25, true);
|
||||
|
||||
CValue oTextForm = oApi.Call("CreateTextForm");
|
||||
setTextFormProperties(oTextForm, "Serial", "Enter serial number", false, "Serial", true, 6, 1, false, false);
|
||||
addTextFormToParagraph(oParagraph, oTextForm, 25, "left", true, 255);
|
||||
oDocument.Call("Push", oTable);
|
||||
|
||||
CValue oPictureForm = oApi.Call("CreatePictureForm");
|
||||
setPictureFormProperties(oPictureForm, "Photo", "Upload company logo", false, "Photo", "tooBig", false, false, 0, 0, "https://api.onlyoffice.com/content/img/docbuilder/examples/user-profile.png");
|
||||
oParagraph = oApi.Call("CreateParagraph");
|
||||
oParagraph.Call("AddElement", oPictureForm);
|
||||
oDocument.Call("Push", oParagraph);
|
||||
|
||||
oTextForm = oApi.Call("CreateTextForm");
|
||||
setTextFormProperties(oTextForm, "Company Name", "Enter company name", false, "Company Name", true, 20, 1, false, false);
|
||||
oParagraph = oApi.Call("CreateParagraph");
|
||||
addTextFormToParagraph(oParagraph, oTextForm, 35, "left", false, 255);
|
||||
oDocument.Call("Push", oParagraph);
|
||||
|
||||
oParagraph = oApi.Call("CreateParagraph");
|
||||
addTextToParagraph(oParagraph, "Date: ", 25, true);
|
||||
oTextForm = oApi.Call("CreateTextForm");
|
||||
setTextFormProperties(oTextForm, "Date", "Date", false, "DD.MM.YYYY", true, 10, 1, false, false);
|
||||
addTextFormToParagraph(oParagraph, oTextForm, 25, "left", true, 255);
|
||||
oDocument.Call("Push", oParagraph);
|
||||
|
||||
oParagraph = oApi.Call("CreateParagraph");
|
||||
addTextToParagraph(oParagraph, "To:", 35, true);
|
||||
oDocument.Call("Push", oParagraph);
|
||||
|
||||
oTable = createFullWidthTable(oApi, 1, 1, 200);
|
||||
oParagraph = getTableCellParagraph(oTable, 0, 0);
|
||||
oTextForm = oApi.Call("CreateTextForm");
|
||||
setTextFormProperties(oTextForm, "Recipient", "Recipient", false, "Recipient", true, 25, 1, false, false);
|
||||
addTextFormToParagraph(oParagraph, oTextForm, 32, "left", false, 255);
|
||||
oDocument.Call("Push", oTable);
|
||||
|
||||
oTable = createFullWidthTable(oApi, 10, 2, 200);
|
||||
oTable.Call("GetRow", 0).Call("SetBackgroundColor", 245, 245, 245, false);
|
||||
CValue oCell = oTable.Call("GetCell", 0, 0);
|
||||
oCell.Call("SetWidth", "percent", 30);
|
||||
oParagraph = getTableCellParagraph(oTable, 0, 0);
|
||||
addTextToParagraph(oParagraph, "Qty.", 30, true);
|
||||
oParagraph = getTableCellParagraph(oTable, 0, 1);
|
||||
addTextToParagraph(oParagraph, "Description", 30, true);
|
||||
|
||||
for (int i = 1; i < 10; i++)
|
||||
{
|
||||
CValue oTempParagraph = getTableCellParagraph(oTable, i, 0);
|
||||
CValue oTempTextForm = oApi.Call("CreateTextForm");
|
||||
setTextFormProperties(oTempTextForm, "Qty" + std::to_string(i), "Qty" + std::to_string(i), false, " ", true, 9, 1, false, false);
|
||||
addTextFormToParagraph(oTempParagraph, oTempTextForm, 30, "left", false, 255);
|
||||
oTempParagraph = getTableCellParagraph(oTable, i, 1);
|
||||
oTempTextForm = oApi.Call("CreateTextForm");
|
||||
setTextFormProperties(oTempTextForm, "Description" + std::to_string(i), "Description" + std::to_string(i), false, " ", true, 22, 1, false, false);
|
||||
addTextFormToParagraph(oTempParagraph, oTempTextForm, 30, "left", false, 255);
|
||||
}
|
||||
|
||||
oDocument.Call("Push", oTable);
|
||||
oDocument.Call("RemoveElement", 0);
|
||||
oDocument.Call("RemoveElement", 1);
|
||||
|
||||
// Save and close
|
||||
oBuilder.SaveFile(OFFICESTUDIO_FILE_DOCUMENT_DOCX, resultPath);
|
||||
oBuilder.CloseFile();
|
||||
CDocBuilder::Dispose();
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include "common.h"
|
||||
#include "docbuilder.h"
|
||||
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
const wchar_t* workDir = L"C:\\Program Files\\ONLYOFFICE\\DocumentBuilder";
|
||||
const wchar_t* resultPath = L"result.docx";
|
||||
|
||||
// Helper functions
|
||||
void setPictureFormProperties(CValue oPictureForm, std::string key, std::string tip, bool required, std::string placeholder, std::string scaleFlag, bool lockAspectRatio, bool respectBorders, int shiftX, int shiftY, std::string imageUrl)
|
||||
{
|
||||
oPictureForm.Call("SetFormKey", key.c_str());
|
||||
oPictureForm.Call("SetTipText", tip.c_str());
|
||||
oPictureForm.Call("SetRequired", required);
|
||||
oPictureForm.Call("SetPlaceholderText", placeholder.c_str());
|
||||
oPictureForm.Call("SetScaleFlag", scaleFlag.c_str());
|
||||
oPictureForm.Call("SetLockAspectRatio", lockAspectRatio);
|
||||
oPictureForm.Call("SetRespectBorders", respectBorders);
|
||||
oPictureForm.Call("SetPicturePosition", shiftX, shiftY);
|
||||
oPictureForm.Call("SetImage", imageUrl.c_str());
|
||||
}
|
||||
void setTextFormProperties(CValue oTextForm, std::string key, std::string tip, bool required, std::string placeholder, bool comb, int maxCharacters, int cellWidth, bool multiLine, bool autoFit)
|
||||
{
|
||||
oTextForm.Call("SetFormKey", key.c_str());
|
||||
oTextForm.Call("SetTipText", tip.c_str());
|
||||
oTextForm.Call("SetRequired", required);
|
||||
oTextForm.Call("SetPlaceholderText", placeholder.c_str());
|
||||
oTextForm.Call("SetComb", comb);
|
||||
oTextForm.Call("SetCharactersLimit", maxCharacters);
|
||||
oTextForm.Call("SetCellWidth", cellWidth);
|
||||
oTextForm.Call("SetCellWidth", multiLine);
|
||||
oTextForm.Call("SetMultiline", autoFit);
|
||||
}
|
||||
|
||||
// Main function
|
||||
int main()
|
||||
{
|
||||
// Init DocBuilder
|
||||
CDocBuilder::Initialize(workDir);
|
||||
CDocBuilder oBuilder;
|
||||
oBuilder.SetProperty("--work-directory", workDir);
|
||||
oBuilder.CreateFile(OFFICESTUDIO_FILE_DOCUMENT_DOCX);
|
||||
|
||||
CContext oContext = oBuilder.GetContext();
|
||||
CContextScope oScope = oContext.CreateScope();
|
||||
CValue oGlobal = oContext.GetGlobal();
|
||||
CValue oApi = oGlobal["Api"];
|
||||
|
||||
// Create basic form
|
||||
CValue oDocument = oApi.Call("GetDocument");
|
||||
CValue oParagraph = oDocument.Call("GetElement", 0);
|
||||
CValue oHeadingStyle = oDocument.Call("GetStyle", "Heading 3");
|
||||
|
||||
oParagraph.Call("AddText", "Employee pass card");
|
||||
oParagraph.Call("SetStyle", oHeadingStyle);
|
||||
oDocument.Call("Push", oParagraph);
|
||||
|
||||
CValue oPictureForm = oApi.Call("CreatePictureForm");
|
||||
setPictureFormProperties(oPictureForm, "Photo", "Upload your photo", false, "Photo", "tooBig", true, false, 50, 50, "https://api.onlyoffice.com/content/img/docbuilder/examples/user-profile.png");
|
||||
oParagraph = oApi.Call("CreateParagraph");
|
||||
oParagraph.Call("AddElement", oPictureForm);
|
||||
oDocument.Call("Push", oParagraph);
|
||||
|
||||
CValue oTextForm = oApi.Call("CreateTextForm");
|
||||
setTextFormProperties(oTextForm, "First name", "Enter your first name", false, "First name", true, 13, 3, false, false);
|
||||
oParagraph = oApi.Call("CreateParagraph");
|
||||
oParagraph.Call("AddElement", oTextForm);
|
||||
oDocument.Call("Push", oParagraph);
|
||||
|
||||
// Save and close
|
||||
oBuilder.SaveFile(OFFICESTUDIO_FILE_DOCUMENT_DOCX, resultPath);
|
||||
oBuilder.CloseFile();
|
||||
CDocBuilder::Dispose();
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,156 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "common.h"
|
||||
#include "docbuilder.h"
|
||||
|
||||
#include "resources/utils/utils.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
const wchar_t* workDir = L"C:\\Program Files\\ONLYOFFICE\\DocumentBuilder";
|
||||
const wchar_t* resultPath = L"result.pptx";
|
||||
|
||||
void addText(CValue oApi, int fontSize, string text, CValue oSlide, CValue oShape, CValue oParagraph, CValue oFill, string jc)
|
||||
{
|
||||
CValue oRun = oApi.Call("CreateRun");
|
||||
CValue oTextPr = oRun.Call("GetTextPr");
|
||||
oTextPr.Call("SetFontSize", fontSize);
|
||||
oTextPr.Call("SetFill", oFill);
|
||||
oTextPr.Call("SetFontFamily", "Tahoma");
|
||||
oParagraph.Call("SetJc", jc.c_str());
|
||||
oRun.Call("AddText", text.c_str());
|
||||
oRun.Call("AddLineBreak");
|
||||
oParagraph.Call("AddElement", oRun);
|
||||
oSlide.Call("AddObject", oShape);
|
||||
}
|
||||
|
||||
// Main function
|
||||
int main()
|
||||
{
|
||||
// Init DocBuilder
|
||||
CDocBuilder::Initialize(workDir);
|
||||
CDocBuilder oBuilder;
|
||||
oBuilder.SetProperty("--work-directory", workDir);
|
||||
|
||||
// Read chart data from xlsx
|
||||
wstring templatePath = NSUtils::GetResourcesDirectory() + L"/docs/chart_data.xlsx";
|
||||
oBuilder.OpenFile(templatePath.c_str(), L"");
|
||||
CContext oContext = oBuilder.GetContext();
|
||||
CContextScope oScope = oContext.CreateScope();
|
||||
CValue oGlobal = oContext.GetGlobal();
|
||||
CValue oApi = oGlobal["Api"];
|
||||
CValue oWorksheet = oApi.Call("GetActiveSheet");
|
||||
CValue values = oWorksheet.Call("GetUsedRange").Call("GetValue");
|
||||
|
||||
int sizeX = values.GetLength();
|
||||
int sizeY = values[0].GetLength();
|
||||
vector<vector<wstring>> data(sizeX, vector<wstring>(sizeY));
|
||||
for (int i = 0; i < sizeX; i++)
|
||||
{
|
||||
for (int j = 0; j < sizeY; j++)
|
||||
{
|
||||
data[i][j] = values[i][j].ToString().c_str();
|
||||
}
|
||||
}
|
||||
oBuilder.CloseFile();
|
||||
|
||||
// Create chart presentation
|
||||
oBuilder.CreateFile(OFFICESTUDIO_FILE_PRESENTATION_PPTX);
|
||||
oContext = oBuilder.GetContext();
|
||||
oScope = oContext.CreateScope();
|
||||
oGlobal = oContext.GetGlobal();
|
||||
oApi = oGlobal["Api"];
|
||||
CValue oPresentation = oApi.Call("GetPresentation");
|
||||
CValue oSlide = oPresentation.Call("GetSlideByIndex", 0);
|
||||
oSlide.Call("RemoveAllObjects");
|
||||
|
||||
CValue oRGBColor = oApi.Call("CreateRGBColor", 255, 244, 240);
|
||||
CValue oFill = oApi.Call("CreateSolidFill", oRGBColor);
|
||||
oSlide.Call("SetBackground", oFill);
|
||||
|
||||
CValue oStroke = oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill"));
|
||||
CValue oShapeTitle = oApi.Call("CreateShape", "rect", 300 * 36000, 20 * 36000, oApi.Call("CreateNoFill"), oStroke);
|
||||
CValue oShapeText = oApi.Call("CreateShape", "rect", 120 * 36000, 80 * 36000, oApi.Call("CreateNoFill"), oStroke);
|
||||
oShapeTitle.Call("SetPosition", 20 * 36000, 20 * 36000);
|
||||
oShapeText.Call("SetPosition", 210 * 36000, 50 * 36000);
|
||||
CValue oParagraphTitle = oShapeTitle.Call("GetDocContent").Call("GetElement", 0);
|
||||
CValue oParagraphText = oShapeText.Call("GetDocContent").Call("GetElement", 0);
|
||||
oRGBColor = oApi.Call("CreateRGBColor", 115, 81, 68);
|
||||
oFill = oApi.Call("CreateSolidFill", oRGBColor);
|
||||
|
||||
string titleContent = "Price Type Report";
|
||||
string textContent = "This is an overview of price types. As we can see, May was the price peak, but even in June the price went down, the annual upward trend persists.";
|
||||
addText(oApi, 80, titleContent, oSlide, oShapeTitle, oParagraphTitle, oFill, "center");
|
||||
addText(oApi, 42, textContent, oSlide, oShapeText, oParagraphText, oFill, "left");
|
||||
|
||||
// Transform 2d array into cols names, rows names and data
|
||||
CValue cols = oContext.CreateArray(sizeY - 1);
|
||||
for (int col = 1; col < sizeY; col++)
|
||||
{
|
||||
cols[col - 1] = data[0][col].c_str();
|
||||
}
|
||||
|
||||
CValue rows = oContext.CreateArray(sizeX - 1);
|
||||
for (int row = 1; row < sizeX; row++)
|
||||
{
|
||||
rows[row - 1] = data[row][0].c_str();
|
||||
}
|
||||
|
||||
CValue vals = oContext.CreateArray(sizeY - 1);
|
||||
for (int row = 1; row < sizeY; row++)
|
||||
{
|
||||
CValue row_data = oContext.CreateArray(sizeX - 1);
|
||||
for (int col = 1; col < sizeX; col++)
|
||||
{
|
||||
row_data[col - 1] = data[col][row].c_str();
|
||||
}
|
||||
vals[row - 1] = row_data;
|
||||
}
|
||||
|
||||
// Pass CValue data to the CreateChart method
|
||||
CValue oChart = oApi.Call("CreateChart", "lineStacked", vals, cols, rows);
|
||||
oChart.Call("SetSize", 180 * 36000, 100 * 36000);
|
||||
oChart.Call("SetPosition", 20 * 36000, 50 * 36000);
|
||||
oChart.Call("ApplyChartStyle", 24);
|
||||
oChart.Call("SetLegendFontSize", 12);
|
||||
oChart.Call("SetLegendPos", "top");
|
||||
oSlide.Call("AddObject", oChart);
|
||||
|
||||
// Save and close
|
||||
oBuilder.SaveFile(OFFICESTUDIO_FILE_PRESENTATION_PPTX, resultPath);
|
||||
oBuilder.CloseFile();
|
||||
CDocBuilder::Dispose();
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,156 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "common.h"
|
||||
#include "docbuilder.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
const wchar_t* workDir = L"C:\\Program Files\\ONLYOFFICE\\DocumentBuilder";
|
||||
const wchar_t* resultPath = L"result.pptx";
|
||||
|
||||
// Helper functions
|
||||
CValue createImageSlide(CValue oApi, CValue oPresentation, string image_url)
|
||||
{
|
||||
CValue oSlide = oApi.Call("CreateSlide");
|
||||
oPresentation.Call("AddSlide", oSlide);
|
||||
CValue oFill = oApi.Call("CreateBlipFill", image_url.c_str(), "stretch");
|
||||
oSlide.Call("SetBackground", oFill);
|
||||
oSlide.Call("RemoveAllObjects");
|
||||
return oSlide;
|
||||
}
|
||||
|
||||
void addTextToSlideShape(CValue oApi, CValue oContent, string text, int fontSize, bool isBold, string js)
|
||||
{
|
||||
CValue oParagraph = oApi.Call("CreateParagraph");
|
||||
oParagraph.Call("SetSpacingBefore", 0);
|
||||
oParagraph.Call("SetSpacingAfter", 0);
|
||||
oContent.Call("Push", oParagraph);
|
||||
CValue oRun = oParagraph.Call("AddText", text.c_str());
|
||||
oRun.Call("SetFill", oApi.Call("CreateSolidFill", oApi.Call("CreateRGBColor", 0xff, 0xff, 0xff)));
|
||||
oRun.Call("SetFontSize", fontSize);
|
||||
oRun.Call("SetFontFamily", "Georgia");
|
||||
oRun.Call("SetBold", isBold);
|
||||
oParagraph.Call("SetJc", js.c_str());
|
||||
}
|
||||
|
||||
// Main function
|
||||
int main()
|
||||
{
|
||||
map<string, string>slideImages;
|
||||
slideImages["gun"] = "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_gun.png";
|
||||
slideImages["axe"] = "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_axe.png";
|
||||
slideImages["knight"] = "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_knight.png";
|
||||
slideImages["sky"] = "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_sky.png";
|
||||
|
||||
// Init DocBuilder
|
||||
CDocBuilder::Initialize(workDir);
|
||||
CDocBuilder oBuilder;
|
||||
oBuilder.SetProperty("--work-directory", workDir);
|
||||
oBuilder.CreateFile(OFFICESTUDIO_FILE_PRESENTATION_PPTX);
|
||||
|
||||
CContext oContext = oBuilder.GetContext();
|
||||
CContextScope oScope = oContext.CreateScope();
|
||||
CValue oGlobal = oContext.GetGlobal();
|
||||
CValue oApi = oGlobal["Api"];
|
||||
|
||||
// Create presentation
|
||||
CValue oPresentation = oApi.Call("GetPresentation");
|
||||
oPresentation.Call("SetSizes", 9144000, 6858000);
|
||||
|
||||
CValue oSlide = createImageSlide(oApi, oPresentation, slideImages["gun"]);
|
||||
oPresentation.Call("GetSlideByIndex", 0).Call("Delete");
|
||||
|
||||
CValue oShape = oApi.Call("CreateShape", "rect", 8056800, 3020400, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
|
||||
oShape.Call("SetPosition", 608400, 1267200);
|
||||
CValue oContent = oShape.Call("GetDocContent");
|
||||
oContent.Call("RemoveAllElements");
|
||||
addTextToSlideShape(oApi, oContent, "How They", 160, true, "left");
|
||||
addTextToSlideShape(oApi, oContent, "Throw Out", 132, false, "left");
|
||||
addTextToSlideShape(oApi, oContent, "a Challenge", 132, false, "left");
|
||||
oSlide.Call("AddObject", oShape);
|
||||
|
||||
oSlide = createImageSlide(oApi, oPresentation, slideImages["axe"]);
|
||||
|
||||
oShape = oApi.Call("CreateShape", "rect", 6904800, 1724400, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
|
||||
oShape.Call("SetPosition", 1764000, 1191600);
|
||||
oContent = oShape.Call("GetDocContent");
|
||||
oContent.Call("RemoveAllElements");
|
||||
addTextToSlideShape(oApi, oContent, "American Indians ", 110, true, "right");
|
||||
addTextToSlideShape(oApi, oContent, "(XVII century)", 94, false, "right");
|
||||
oSlide.Call("AddObject", oShape);
|
||||
|
||||
oShape = oApi.Call("CreateShape", "rect", 4986000, 2419200, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
|
||||
oShape.Call("SetPosition", 3834000, 3888000);
|
||||
oContent = oShape.Call("GetDocContent");
|
||||
oContent.Call("RemoveAllElements");
|
||||
addTextToSlideShape(oApi, oContent, "put a tomahawk on the ground in the ", 84, false, "right");
|
||||
addTextToSlideShape(oApi, oContent, "rival's camp", 84, false, "right");
|
||||
oSlide.Call("AddObject", oShape);
|
||||
|
||||
oSlide = createImageSlide(oApi, oPresentation, slideImages["knight"]);
|
||||
|
||||
oShape = oApi.Call("CreateShape", "rect", 6904800, 1724400, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
|
||||
oShape.Call("SetPosition", 1764000, 1191600);
|
||||
oContent = oShape.Call("GetDocContent");
|
||||
oContent.Call("RemoveAllElements");
|
||||
addTextToSlideShape(oApi, oContent, "European Knights", 110, true, "right");
|
||||
addTextToSlideShape(oApi, oContent, " (XII-XVI centuries)", 94, false, "right");
|
||||
oSlide.Call("AddObject", oShape);
|
||||
|
||||
oShape = oApi.Call("CreateShape", "rect", 4986000, 2419200, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
|
||||
oShape.Call("SetPosition", 3834000, 3888000);
|
||||
oContent = oShape.Call("GetDocContent");
|
||||
oContent.Call("RemoveAllElements");
|
||||
addTextToSlideShape(oApi, oContent, "threw a glove", 84, false, "right");
|
||||
addTextToSlideShape(oApi, oContent, "in the rival's face", 84, false, "right");
|
||||
oSlide.Call("AddObject", oShape);
|
||||
|
||||
oSlide = createImageSlide(oApi, oPresentation, slideImages["sky"]);
|
||||
|
||||
oShape = oApi.Call("CreateShape", "rect", 7887600, 3063600, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
|
||||
oShape.Call("SetPosition", 630000, 1357200);
|
||||
oContent = oShape.Call("GetDocContent");
|
||||
oContent.Call("RemoveAllElements");
|
||||
addTextToSlideShape(oApi, oContent, "OnlyOffice", 176, false, "center");
|
||||
addTextToSlideShape(oApi, oContent, "stands for Peace", 132, false, "center");
|
||||
oSlide.Call("AddObject", oShape);
|
||||
|
||||
// Save and close
|
||||
oBuilder.SaveFile(OFFICESTUDIO_FILE_PRESENTATION_PPTX, resultPath);
|
||||
oBuilder.CloseFile();
|
||||
CDocBuilder::Dispose();
|
||||
return 0;
|
||||
}
|
||||
94
DesktopEditor/doctrenderer/samples/cpp/filling_form/main.cpp
Normal file
94
DesktopEditor/doctrenderer/samples/cpp/filling_form/main.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "common.h"
|
||||
#include "docbuilder.h"
|
||||
|
||||
#include "resources/utils/utils.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
const wchar_t* workDir = L"C:\\Program Files\\ONLYOFFICE\\DocumentBuilder";
|
||||
const wchar_t* resultPath = L"result.docx";
|
||||
|
||||
// Main function
|
||||
int main()
|
||||
{
|
||||
std::map<wstring, wstring> formData;
|
||||
formData[L"Photo"] = L"https://api.onlyoffice.com/content/img/docbuilder/examples/blue_cloud.png";
|
||||
formData[L"Serial"] = L"A1345";
|
||||
formData[L"Company Name"] = L"Blue Cloud";
|
||||
formData[L"Date"] = L"25.12.2023";
|
||||
formData[L"Recipient"] = L"Space Corporation";
|
||||
formData[L"Qty1"] = L"25";
|
||||
formData[L"Description1"] = L"Frame";
|
||||
formData[L"Qty2"] = L"2";
|
||||
formData[L"Description2"] = L"Stack";
|
||||
formData[L"Qty3"] = L"34";
|
||||
formData[L"Description3"] = L"Shifter";
|
||||
|
||||
// Init DocBuilder
|
||||
CDocBuilder::Initialize(workDir);
|
||||
CDocBuilder oBuilder;
|
||||
oBuilder.SetProperty("--work-directory", workDir);
|
||||
wstring templatePath = NSUtils::GetResourcesDirectory() + L"/docs/form.docx";
|
||||
oBuilder.OpenFile(templatePath.c_str(), L"");
|
||||
|
||||
CContext oContext = oBuilder.GetContext();
|
||||
CContextScope oScope = oContext.CreateScope();
|
||||
CValue oGlobal = oContext.GetGlobal();
|
||||
CValue oApi = oGlobal["Api"];
|
||||
|
||||
// Fill form
|
||||
CValue oDocument = oApi.Call("GetDocument");
|
||||
CValue aForms = oDocument.Call("GetAllForms");
|
||||
|
||||
int formNum = 0;
|
||||
while (formNum < (int)aForms.GetLength())
|
||||
{
|
||||
CValue form = aForms[formNum];
|
||||
wstring type = aForms[formNum].Call("GetFormType").ToString().c_str();
|
||||
wstring value = formData[aForms[formNum].Call("GetFormKey").ToString().c_str()];
|
||||
if (type == L"textForm") form.Call("SetText", value.c_str());
|
||||
if (type == L"pictureForm") form.Call("SetImage", value.c_str());
|
||||
formNum++;
|
||||
}
|
||||
|
||||
// Save and close
|
||||
oBuilder.SaveFile(OFFICESTUDIO_FILE_DOCUMENT_DOCX, resultPath);
|
||||
oBuilder.CloseFile();
|
||||
CDocBuilder::Dispose();
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include "common.h"
|
||||
#include "docbuilder.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
const wchar_t* workDir = L"C:\\Program Files\\ONLYOFFICE\\DocumentBuilder";
|
||||
const wchar_t* resultPath = L"result.xlsx";
|
||||
|
||||
// Main function
|
||||
int main()
|
||||
{
|
||||
string data[9][4] = {
|
||||
{ "Id", "Product", "Price", "Available" },
|
||||
{ "1001", "Item A", "12.2", "true" },
|
||||
{ "1002", "Item B", "18.8", "true" },
|
||||
{ "1003", "Item C", "70.1", "false" },
|
||||
{ "1004", "Item D", "60.6", "true" },
|
||||
{ "1005", "Item E", "32.6", "true" },
|
||||
{ "1006", "Item F", "28.3", "false" },
|
||||
{ "1007", "Item G", "11.1", "false" },
|
||||
{ "1008", "Item H", "41.4", "true" }
|
||||
};
|
||||
|
||||
// Init DocBuilder
|
||||
CDocBuilder::Initialize(workDir);
|
||||
CDocBuilder oBuilder;
|
||||
oBuilder.SetProperty("--work-directory", workDir);
|
||||
oBuilder.CreateFile(OFFICESTUDIO_FILE_SPREADSHEET_XLSX);
|
||||
|
||||
CContext oContext = oBuilder.GetContext();
|
||||
CContextScope oScope = oContext.CreateScope();
|
||||
CValue oGlobal = oContext.GetGlobal();
|
||||
CValue oApi = oGlobal["Api"];
|
||||
|
||||
// Find and comment formula errors
|
||||
CValue oWorksheet = oApi.Call("GetActiveSheet");
|
||||
|
||||
// Create CValue array from data
|
||||
int rowsLen = sizeof data / sizeof data[0];
|
||||
int colsLen = sizeof data[0] / sizeof(string);
|
||||
CValue oArray = oContext.CreateArray(rowsLen);
|
||||
|
||||
for (int row = 0; row < rowsLen; row++)
|
||||
{
|
||||
CValue oArrayCol = oContext.CreateArray(colsLen);
|
||||
|
||||
for (int col = 0; col < colsLen; col++)
|
||||
{
|
||||
oArrayCol[col] = data[row][col].c_str();
|
||||
}
|
||||
oArray[row] = oArrayCol;
|
||||
}
|
||||
|
||||
// First cell in the range (A1) is equal to (0,0)
|
||||
CValue startCell = oWorksheet.Call("GetRangeByNumber", 0, 0);
|
||||
|
||||
// Last cell in the range is equal to array length -1
|
||||
CValue endCell = oWorksheet.Call("GetRangeByNumber", oArray.GetLength() - 1, oArray[0].GetLength() - 1);
|
||||
oWorksheet.Call("GetRange", startCell, endCell).Call("SetValue", oArray);
|
||||
|
||||
// Save and close
|
||||
oBuilder.SaveFile(OFFICESTUDIO_FILE_SPREADSHEET_XLSX, resultPath);
|
||||
oBuilder.CloseFile();
|
||||
CDocBuilder::Dispose();
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
using docbuilder_net;
|
||||
|
||||
using OfficeFileTypes = docbuilder_net.FileTypes;
|
||||
using CValue = docbuilder_net.CDocBuilderValue;
|
||||
using CContext = docbuilder_net.CDocBuilderContext;
|
||||
using CContextScope = docbuilder_net.CDocBuilderContextScope;
|
||||
|
||||
namespace Sample
|
||||
{
|
||||
public class CommentingErrors
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string workDirectory = "C:/Program Files/ONLYOFFICE/DocumentBuilder";
|
||||
string resultPath = "../../../result.xlsx";
|
||||
string filePath = "../../../../../../resources/docs/spreadsheet_with_errors.xlsx";
|
||||
// add Docbuilder dlls in path
|
||||
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + workDirectory);
|
||||
|
||||
CommentErrors(workDirectory, resultPath, filePath);
|
||||
}
|
||||
|
||||
public static void CommentErrors(string workDirectory, string resultPath, string filePath)
|
||||
{
|
||||
var doctype = (int)OfficeFileTypes.Spreadsheet.XLSX;
|
||||
|
||||
// Init DocBuilder
|
||||
CDocBuilder.Initialize(workDirectory);
|
||||
CDocBuilder oBuilder = new CDocBuilder();
|
||||
|
||||
oBuilder.OpenFile(filePath, "xlsx");
|
||||
CContext oContext = oBuilder.GetContext();
|
||||
CContextScope oScope = oContext.CreateScope();
|
||||
CValue oGlobal = oContext.GetGlobal();
|
||||
CValue oApi = oGlobal["Api"];
|
||||
|
||||
// Find and comment formula errors
|
||||
CValue oWorksheet = oApi.Call("GetActiveSheet");
|
||||
CValue oRange = oWorksheet.Call("GetUsedRange");
|
||||
var data = oRange.Call("GetValue");
|
||||
|
||||
for (int row = 0; row < data.GetLength(); row++)
|
||||
{
|
||||
for (int col = 0; col < data[0].GetLength(); col++)
|
||||
{
|
||||
CheckCell(oWorksheet, data[row][col].ToString(), row, col);
|
||||
}
|
||||
}
|
||||
|
||||
// Save file and close DocBuilder
|
||||
oBuilder.SaveFile(doctype, resultPath);
|
||||
oBuilder.CloseFile();
|
||||
CDocBuilder.Destroy();
|
||||
}
|
||||
|
||||
public static void CheckCell(CValue oWorksheet, string cell, int row, int col)
|
||||
{
|
||||
if (cell.Contains("#"))
|
||||
{
|
||||
string comment = "Error" + cell;
|
||||
CValue errorCell = oWorksheet.Call("GetRangeByNumber", row, col);
|
||||
errorCell.Call("AddComment", comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,212 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
using docbuilder_net;
|
||||
|
||||
using OfficeFileTypes = docbuilder_net.FileTypes;
|
||||
using CValue = docbuilder_net.CDocBuilderValue;
|
||||
using CContext = docbuilder_net.CDocBuilderContext;
|
||||
using CContextScope = docbuilder_net.CDocBuilderContextScope;
|
||||
|
||||
namespace Sample
|
||||
{
|
||||
public class CreatingAdvancedForm
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string workDirectory = "C:/Program Files/ONLYOFFICE/DocumentBuilder";
|
||||
string resultPath = "../../../result.docx";
|
||||
|
||||
// add Docbuilder dlls in path
|
||||
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + workDirectory);
|
||||
|
||||
CreateAdvancedForm(workDirectory, resultPath);
|
||||
}
|
||||
|
||||
public static void CreateAdvancedForm(string workDirectory, string resultPath)
|
||||
{
|
||||
var doctype = (int)OfficeFileTypes.Document.DOCX;
|
||||
|
||||
// Init DocBuilder
|
||||
CDocBuilder.Initialize(workDirectory);
|
||||
CDocBuilder oBuilder = new CDocBuilder();
|
||||
oBuilder.CreateFile(doctype);
|
||||
|
||||
CContext oContext = oBuilder.GetContext();
|
||||
CContextScope oScope = oContext.CreateScope();
|
||||
CValue oGlobal = oContext.GetGlobal();
|
||||
CValue oApi = oGlobal["Api"];
|
||||
|
||||
// Create advanced form
|
||||
CValue oDocument = oApi.Call("GetDocument");
|
||||
CValue oTable = createFullWidthTable(oApi, 1, 2, 255);
|
||||
CValue oParagraph = getTableCellParagraph(oTable, 0, 0);
|
||||
addTextToParagraph(oParagraph, "PURCHASE ORDER", 36, true);
|
||||
oParagraph = getTableCellParagraph(oTable, 0, 1);
|
||||
addTextToParagraph(oParagraph, "Serial # ", 25, true);
|
||||
|
||||
CValue oTextForm = oApi.Call("CreateTextForm");
|
||||
setTextFormProperties(oTextForm, "Serial", "Enter serial number", false, "Serial", true, 6, 1, false, false);
|
||||
addTextFormToParagraph(oParagraph, oTextForm, 25, "left", true, 255);
|
||||
oDocument.Call("Push", oTable);
|
||||
|
||||
CValue oPictureForm = oApi.Call("CreatePictureForm");
|
||||
setPictureFormProperties(oPictureForm, "Photo", "Upload company logo", false, "Photo", "tooBig", false, false, 0, 0, "https://api.onlyoffice.com/content/img/docbuilder/examples/user-profile.png");
|
||||
oParagraph = oApi.Call("CreateParagraph");
|
||||
oParagraph.Call("AddElement", oPictureForm);
|
||||
oDocument.Call("Push", oParagraph);
|
||||
|
||||
oTextForm = oApi.Call("CreateTextForm");
|
||||
setTextFormProperties(oTextForm, "Company Name", "Enter company name", false, "Company Name", true, 20, 1, false, false);
|
||||
oParagraph = oApi.Call("CreateParagraph");
|
||||
addTextFormToParagraph(oParagraph, oTextForm, 35, "left", false, 255);
|
||||
oDocument.Call("Push", oParagraph);
|
||||
|
||||
oParagraph = oApi.Call("CreateParagraph");
|
||||
addTextToParagraph(oParagraph, "Date: ", 25, true);
|
||||
oTextForm = oApi.Call("CreateTextForm");
|
||||
setTextFormProperties(oTextForm, "Date", "Date", false, "DD.MM.YYYY", true, 10, 1, false, false);
|
||||
addTextFormToParagraph(oParagraph, oTextForm, 25, "left", true, 255);
|
||||
oDocument.Call("Push", oParagraph);
|
||||
|
||||
oParagraph = oApi.Call("CreateParagraph");
|
||||
addTextToParagraph(oParagraph, "To:", 35, true);
|
||||
oDocument.Call("Push", oParagraph);
|
||||
|
||||
oTable = createFullWidthTable(oApi, 1, 1, 200);
|
||||
oParagraph = getTableCellParagraph(oTable, 0, 0);
|
||||
oTextForm = oApi.Call("CreateTextForm");
|
||||
setTextFormProperties(oTextForm, "Recipient", "Recipient", false, "Recipient", true, 25, 1, false, false);
|
||||
addTextFormToParagraph(oParagraph, oTextForm, 32, "left", false, 255);
|
||||
oDocument.Call("Push", oTable);
|
||||
|
||||
oTable = createFullWidthTable(oApi, 10, 2, 200);
|
||||
oTable.Call("GetRow", 0).Call("SetBackgroundColor", 245, 245, 245, false);
|
||||
CValue oCell = oTable.Call("GetCell", 0, 0);
|
||||
oCell.Call("SetWidth", "percent", 30);
|
||||
oParagraph = getTableCellParagraph(oTable, 0, 0);
|
||||
addTextToParagraph(oParagraph, "Qty.", 30, true);
|
||||
oParagraph = getTableCellParagraph(oTable, 0, 1);
|
||||
addTextToParagraph(oParagraph, "Description", 30, true);
|
||||
|
||||
for (var i = 1; i < 10; i++)
|
||||
{
|
||||
CValue oTempParagraph = getTableCellParagraph(oTable, i, 0);
|
||||
CValue oTempTextForm = oApi.Call("CreateTextForm");
|
||||
setTextFormProperties(oTempTextForm, "Qty" + i, "Qty" + i, false, " ", true, 9, 1, false, false);
|
||||
addTextFormToParagraph(oTempParagraph, oTempTextForm, 30, "left", false, 255);
|
||||
|
||||
oTempParagraph = getTableCellParagraph(oTable, i, 1);
|
||||
oTempTextForm = oApi.Call("CreateTextForm");
|
||||
setTextFormProperties(oTempTextForm, "Description" + i, "Description" + i, false, " ", true, 22, 1, false, false);
|
||||
addTextFormToParagraph(oTempParagraph, oTempTextForm, 30, "left", false, 255);
|
||||
}
|
||||
|
||||
oDocument.Call("Push", oTable);
|
||||
oDocument.Call("RemoveElement", 0);
|
||||
oDocument.Call("RemoveElement", 1);
|
||||
|
||||
// Save file and close DocBuilder
|
||||
oBuilder.SaveFile(doctype, resultPath);
|
||||
oBuilder.CloseFile();
|
||||
|
||||
CDocBuilder.Destroy();
|
||||
}
|
||||
|
||||
public static CValue createFullWidthTable(CValue oApi, int rows, int cols, int borderColor)
|
||||
{
|
||||
CValue oTable = oApi.Call("CreateTable", cols, rows);
|
||||
oTable.Call("SetWidth", "percent", 100);
|
||||
setTableBorders(oTable, borderColor);
|
||||
return oTable;
|
||||
}
|
||||
|
||||
public static void setTableBorders(CValue oTable, int borderColor)
|
||||
{
|
||||
oTable.Call("SetTableBorderTop", "single", 4, 0, borderColor, borderColor, borderColor);
|
||||
oTable.Call("SetTableBorderBottom", "single", 4, 0, borderColor, borderColor, borderColor);
|
||||
oTable.Call("SetTableBorderLeft", "single", 4, 0, borderColor, borderColor, borderColor);
|
||||
oTable.Call("SetTableBorderRight", "single", 4, 0, borderColor, borderColor, borderColor);
|
||||
oTable.Call("SetTableBorderInsideV", "single", 4, 0, borderColor, borderColor, borderColor);
|
||||
oTable.Call("SetTableBorderInsideH", "single", 4, 0, borderColor, borderColor, borderColor);
|
||||
}
|
||||
|
||||
public static CValue getTableCellParagraph(CValue oTable, int row, int col)
|
||||
{
|
||||
return oTable.Call("GetCell", row, col).Call("GetContent").Call("GetElement", 0);
|
||||
}
|
||||
|
||||
public static void addTextToParagraph(CValue oParagraph, string text, int fontSize, bool isBold)
|
||||
{
|
||||
oParagraph.Call("AddText", text);
|
||||
oParagraph.Call("SetFontSize", fontSize);
|
||||
oParagraph.Call("SetBold", isBold);
|
||||
}
|
||||
|
||||
public static void setPictureFormProperties(CValue oPictureForm, string key, string tip, bool required, string placeholder, string scaleFlag, bool lockAspectRatio, bool respectBorders, int shiftX, int shiftY, string imageUrl)
|
||||
{
|
||||
oPictureForm.Call("SetFormKey", key);
|
||||
oPictureForm.Call("SetTipText", tip);
|
||||
oPictureForm.Call("SetRequired", required);
|
||||
oPictureForm.Call("SetPlaceholderText", placeholder);
|
||||
oPictureForm.Call("SetScaleFlag", scaleFlag);
|
||||
oPictureForm.Call("SetLockAspectRatio", lockAspectRatio);
|
||||
oPictureForm.Call("SetRespectBorders", respectBorders);
|
||||
oPictureForm.Call("SetPicturePosition", shiftX, shiftY);
|
||||
oPictureForm.Call("SetImage", imageUrl);
|
||||
}
|
||||
|
||||
public static void setTextFormProperties(CValue oTextForm, string key, string tip, bool required, string placeholder, bool comb, int maxCharacters, int cellWidth, bool multiLine, bool autoFit)
|
||||
{
|
||||
oTextForm.Call("SetFormKey", key);
|
||||
oTextForm.Call("SetTipText", tip);
|
||||
oTextForm.Call("SetRequired", required);
|
||||
oTextForm.Call("SetPlaceholderText", placeholder);
|
||||
oTextForm.Call("SetComb", comb);
|
||||
oTextForm.Call("SetCharactersLimit", maxCharacters);
|
||||
oTextForm.Call("SetCellWidth", cellWidth);
|
||||
oTextForm.Call("SetCellWidth", multiLine);
|
||||
oTextForm.Call("SetMultiline", autoFit);
|
||||
}
|
||||
|
||||
public static void addTextFormToParagraph(CValue oParagraph, CValue oTextForm, int fontSize, string jc, bool hasBorder, int borderColor)
|
||||
{
|
||||
if (hasBorder)
|
||||
{
|
||||
oTextForm.Call("SetBorderColor", borderColor, borderColor, borderColor);
|
||||
}
|
||||
oParagraph.Call("AddElement", oTextForm);
|
||||
oParagraph.Call("SetFontSize", fontSize);
|
||||
oParagraph.Call("SetJc", jc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
using docbuilder_net;
|
||||
|
||||
using OfficeFileTypes = docbuilder_net.FileTypes;
|
||||
using CValue = docbuilder_net.CDocBuilderValue;
|
||||
using CContext = docbuilder_net.CDocBuilderContext;
|
||||
using CContextScope = docbuilder_net.CDocBuilderContextScope;
|
||||
|
||||
namespace Sample
|
||||
{
|
||||
public class CreatingBasicForm
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string workDirectory = "C:/Program Files/ONLYOFFICE/DocumentBuilder";
|
||||
string resultPath = "../../../result.docx";
|
||||
|
||||
// add Docbuilder dlls in path
|
||||
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + workDirectory);
|
||||
|
||||
CreateBasicForm(workDirectory, resultPath);
|
||||
}
|
||||
|
||||
public static void CreateBasicForm(string workDirectory, string resultPath)
|
||||
{
|
||||
var doctype = (int)OfficeFileTypes.Document.DOCX;
|
||||
|
||||
// Init DocBuilder
|
||||
CDocBuilder.Initialize(workDirectory);
|
||||
CDocBuilder oBuilder = new CDocBuilder();
|
||||
oBuilder.CreateFile(doctype);
|
||||
|
||||
CContext oContext = oBuilder.GetContext();
|
||||
CContextScope oScope = oContext.CreateScope();
|
||||
CValue oGlobal = oContext.GetGlobal();
|
||||
CValue oApi = oGlobal["Api"];
|
||||
|
||||
// Create basic form
|
||||
CValue oDocument = oApi.Call("GetDocument");
|
||||
CValue oParagraph = oDocument.Call("GetElement", 0);
|
||||
CValue oHeadingStyle = oDocument.Call("GetStyle", "Heading 3");
|
||||
|
||||
oParagraph.Call("AddText", "Employee pass card");
|
||||
oParagraph.Call("SetStyle", oHeadingStyle);
|
||||
oDocument.Call("Push", oParagraph);
|
||||
|
||||
CValue oPictureForm = oApi.Call("CreatePictureForm");
|
||||
setPictureFormProperties(oPictureForm, "Photo", "Upload your photo", false, "Photo", "tooBig", true, false, 50, 50, "https://api.onlyoffice.com/content/img/docbuilder/examples/user-profile.png");
|
||||
oParagraph = oApi.Call("CreateParagraph");
|
||||
oParagraph.Call("AddElement", oPictureForm);
|
||||
oDocument.Call("Push", oParagraph);
|
||||
|
||||
CValue oTextForm = oApi.Call("CreateTextForm");
|
||||
setTextFormProperties(oTextForm, "First name", "Enter your first name", false, "First name", true, 13, 3, false, false);
|
||||
oParagraph = oApi.Call("CreateParagraph");
|
||||
oParagraph.Call("AddElement", oTextForm);
|
||||
oDocument.Call("Push", oParagraph);
|
||||
|
||||
// Save file and close DocBuilder
|
||||
oBuilder.SaveFile(doctype, resultPath);
|
||||
oBuilder.CloseFile();
|
||||
|
||||
CDocBuilder.Destroy();
|
||||
}
|
||||
|
||||
public static void setPictureFormProperties(CValue oPictureForm, string key, string tip, bool required, string placeholder, string scaleFlag, bool lockAspectRatio, bool respectBorders, int shiftX, int shiftY, string imageUrl)
|
||||
{
|
||||
oPictureForm.Call("SetFormKey", key);
|
||||
oPictureForm.Call("SetTipText", tip);
|
||||
oPictureForm.Call("SetRequired", required);
|
||||
oPictureForm.Call("SetPlaceholderText", placeholder);
|
||||
oPictureForm.Call("SetScaleFlag", scaleFlag);
|
||||
oPictureForm.Call("SetLockAspectRatio", lockAspectRatio);
|
||||
oPictureForm.Call("SetRespectBorders", respectBorders);
|
||||
oPictureForm.Call("SetPicturePosition", shiftX, shiftY);
|
||||
oPictureForm.Call("SetImage", imageUrl);
|
||||
}
|
||||
|
||||
public static void setTextFormProperties(CValue oTextForm, string key, string tip, bool required, string placeholder, bool comb, int maxCharacters, int cellWidth, bool multiLine, bool autoFit)
|
||||
{
|
||||
oTextForm.Call("SetFormKey", key);
|
||||
oTextForm.Call("SetTipText", tip);
|
||||
oTextForm.Call("SetRequired", required);
|
||||
oTextForm.Call("SetPlaceholderText", placeholder);
|
||||
oTextForm.Call("SetComb", comb);
|
||||
oTextForm.Call("SetCharactersLimit", maxCharacters);
|
||||
oTextForm.Call("SetCellWidth", cellWidth);
|
||||
oTextForm.Call("SetCellWidth", multiLine);
|
||||
oTextForm.Call("SetMultiline", autoFit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,196 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
using docbuilder_net;
|
||||
|
||||
using OfficeFileTypes = docbuilder_net.FileTypes;
|
||||
using CValue = docbuilder_net.CDocBuilderValue;
|
||||
using CContext = docbuilder_net.CDocBuilderContext;
|
||||
using CContextScope = docbuilder_net.CDocBuilderContextScope;
|
||||
|
||||
namespace Sample
|
||||
{
|
||||
public class CreatingChartPresentation
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string workDirectory = "C:/Program Files/ONLYOFFICE/DocumentBuilder";
|
||||
string resultPath = "../../../result.pptx";
|
||||
string filePath = "../../../../../../resources/docs/chart_data.xlsx";
|
||||
|
||||
// add Docbuilder dlls in path
|
||||
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + workDirectory);
|
||||
|
||||
CreateChartPresentation(workDirectory, resultPath, filePath);
|
||||
}
|
||||
|
||||
public static void CreateChartPresentation(string workDirectory, string resultPath, string filePath)
|
||||
{
|
||||
var doctype = (int)OfficeFileTypes.Presentation.PPTX;
|
||||
|
||||
// Init DocBuilder
|
||||
CDocBuilder.Initialize(workDirectory);
|
||||
CDocBuilder oBuilder = new CDocBuilder();
|
||||
|
||||
// Read chart data from xlsx
|
||||
oBuilder.OpenFile(filePath, "xlsx");
|
||||
CContext oContext = oBuilder.GetContext();
|
||||
CContextScope oScope = oContext.CreateScope();
|
||||
CValue oGlobal = oContext.GetGlobal();
|
||||
CValue oApi = oGlobal["Api"];
|
||||
CValue oWorksheet = oApi.Call("GetActiveSheet");
|
||||
CValue oRange = oWorksheet.Call("GetUsedRange").Call("GetValue");
|
||||
object[,] array = oRangeTo2dArray(oRange, oContext);
|
||||
oBuilder.CloseFile();
|
||||
|
||||
// Create chart presentation
|
||||
oBuilder.CreateFile(doctype);
|
||||
oContext = oBuilder.GetContext();
|
||||
oScope = oContext.CreateScope();
|
||||
oGlobal = oContext.GetGlobal();
|
||||
oApi = oGlobal["Api"];
|
||||
CValue oPresentation = oApi.Call("GetPresentation");
|
||||
CValue oSlide = oPresentation.Call("GetSlideByIndex", 0);
|
||||
oSlide.Call("RemoveAllObjects");
|
||||
|
||||
CValue oRGBColor = oApi.Call("CreateRGBColor", 255, 244, 240);
|
||||
CValue oFill = oApi.Call("CreateSolidFill", oRGBColor);
|
||||
oSlide.Call("SetBackground", oFill);
|
||||
|
||||
CValue oStroke = oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill"));
|
||||
CValue oShapeTitle = oApi.Call("CreateShape", "rect", 300 * 36000, 20 * 36000, oApi.Call("CreateNoFill"), oStroke);
|
||||
CValue oShapeText = oApi.Call("CreateShape", "rect", 120 * 36000, 80 * 36000, oApi.Call("CreateNoFill"), oStroke);
|
||||
oShapeTitle.Call("SetPosition", 20 * 36000, 20 * 36000);
|
||||
oShapeText.Call("SetPosition", 210 * 36000, 50 * 36000);
|
||||
CValue oParagraphTitle = oShapeTitle.Call("GetDocContent").Call("GetElement", 0);
|
||||
CValue oParagraphText = oShapeText.Call("GetDocContent").Call("GetElement", 0);
|
||||
oRGBColor = oApi.Call("CreateRGBColor", 115, 81, 68);
|
||||
oFill = oApi.Call("CreateSolidFill", oRGBColor);
|
||||
|
||||
string titleContent = "Price Type Report";
|
||||
string textContent = "This is an overview of price types. As we can see, May was the price peak, but even in June the price went down, the annual upward trend persists.";
|
||||
addText(oApi, 80, titleContent, oSlide, oShapeTitle, oParagraphTitle, oFill, "center");
|
||||
addText(oApi, 42, textContent, oSlide, oShapeText, oParagraphText, oFill, "left");
|
||||
|
||||
// Transform 2d array into cols names, rows names and data
|
||||
CValue array_cols = colsFromArray(array, oContext);
|
||||
CValue array_rows = rowsFromArray(array, oContext);
|
||||
CValue array_data = dataFromArray(array, oContext);
|
||||
|
||||
// Pass CValue data to the CreateChart method
|
||||
CValue oChart = oApi.Call("CreateChart", "lineStacked", array_data, array_cols, array_rows);
|
||||
oChart.Call("SetSize", 180 * 36000, 100 * 36000);
|
||||
oChart.Call("SetPosition", 20 * 36000, 50 * 36000);
|
||||
oChart.Call("ApplyChartStyle", 24);
|
||||
oChart.Call("SetVertAxisLabelsFontSize", 16);
|
||||
oChart.Call("SetHorAxisLabelsFontSize", 16);
|
||||
oChart.Call("SetLegendFontSize", 16);
|
||||
oChart.Call("SetLegendPos", "top");
|
||||
oSlide.Call("AddObject", oChart);
|
||||
|
||||
// Save file and close DocBuilder
|
||||
oBuilder.SaveFile(doctype, resultPath);
|
||||
oBuilder.CloseFile();
|
||||
CDocBuilder.Destroy();
|
||||
}
|
||||
|
||||
public static object[,] oRangeTo2dArray(CValue oRange, CContext oContext)
|
||||
{
|
||||
int rowsLen = (int)oRange.GetLength();
|
||||
int colsLen = (int)oRange[0].GetLength();
|
||||
object[,] oArray = new object[rowsLen, colsLen];
|
||||
|
||||
for (int col = 0; col < colsLen; col++)
|
||||
{
|
||||
CValue oArrayRow = oContext.CreateArray(rowsLen);
|
||||
for (int row = 0; row < rowsLen; row++)
|
||||
{
|
||||
oArray[row, col] = oRange[row][col].ToString();
|
||||
}
|
||||
}
|
||||
return oArray;
|
||||
}
|
||||
|
||||
public static CValue colsFromArray(object[,] array, CContext oContext)
|
||||
{
|
||||
int colsLen = array.GetLength(1) - 1;
|
||||
CValue cols = oContext.CreateArray(colsLen);
|
||||
for (int col = 1; col <= colsLen; col++)
|
||||
{
|
||||
cols[col - 1] = array[0, col].ToString();
|
||||
}
|
||||
return cols;
|
||||
}
|
||||
|
||||
public static CValue rowsFromArray(object[,] array, CContext oContext)
|
||||
{
|
||||
int rowsLen = array.GetLength(0) - 1;
|
||||
CValue rows = oContext.CreateArray(rowsLen);
|
||||
for (int row = 1; row <= rowsLen; row++)
|
||||
{
|
||||
rows[row - 1] = array[row, 0].ToString();
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
public static CValue dataFromArray(object[,] array, CContext oContext)
|
||||
{
|
||||
int colsLen = array.GetLength(0) - 1;
|
||||
int rowsLen = array.GetLength(1) - 1;
|
||||
CValue data = oContext.CreateArray(rowsLen);
|
||||
for (int row = 1; row <= rowsLen; row++)
|
||||
{
|
||||
CValue row_data = oContext.CreateArray(colsLen);
|
||||
for (int col = 1; col <= colsLen; col++)
|
||||
{
|
||||
row_data[col - 1] = array[col, row].ToString();
|
||||
}
|
||||
data[row - 1] = row_data;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public static void addText(CValue oApi, int fontSize, string text, CValue oSlide, CValue oShape, CValue oParagraph, CValue oFill, string jc)
|
||||
{
|
||||
CValue oRun = oApi.Call("CreateRun");
|
||||
var oTextPr = oRun.Call("GetTextPr");
|
||||
oTextPr.Call("SetFontSize", fontSize);
|
||||
oTextPr.Call("SetFill", oFill);
|
||||
oTextPr.Call("SetFontFamily", "Tahoma");
|
||||
oParagraph.Call("SetJc", jc);
|
||||
oRun.Call("AddText", text);
|
||||
oRun.Call("AddLineBreak");
|
||||
oParagraph.Call("AddElement", oRun);
|
||||
oSlide.Call("AddObject", oShape);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
using docbuilder_net;
|
||||
|
||||
using OfficeFileTypes = docbuilder_net.FileTypes;
|
||||
using CValue = docbuilder_net.CDocBuilderValue;
|
||||
using CContext = docbuilder_net.CDocBuilderContext;
|
||||
using CContextScope = docbuilder_net.CDocBuilderContextScope;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Sample
|
||||
{
|
||||
public class CreatingPresentation
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string workDirectory = "C:/Program Files/ONLYOFFICE/DocumentBuilder";
|
||||
string resultPath = "../../../result.pptx";
|
||||
|
||||
IDictionary<string, string> slideImages = new Dictionary<string, string>() {
|
||||
{ "gun", "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_gun.png" },
|
||||
{ "axe","https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_axe.png" },
|
||||
{ "knight", "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_knight.png" },
|
||||
{ "sky","https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_sky.png" }
|
||||
};
|
||||
// add Docbuilder dlls in path
|
||||
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + workDirectory);
|
||||
|
||||
CreatePresentation(workDirectory, resultPath, slideImages);
|
||||
}
|
||||
|
||||
public static void CreatePresentation(string workDirectory, string resultPath, IDictionary<string, string> slideImages)
|
||||
{
|
||||
var doctype = (int)OfficeFileTypes.Presentation.PPTX;
|
||||
|
||||
// Init DocBuilder
|
||||
CDocBuilder.Initialize(workDirectory);
|
||||
CDocBuilder oBuilder = new CDocBuilder();
|
||||
|
||||
// Create presentation
|
||||
oBuilder.CreateFile(doctype);
|
||||
CContext oContext = oBuilder.GetContext();
|
||||
CContextScope oScope = oContext.CreateScope();
|
||||
CValue oGlobal = oContext.GetGlobal();
|
||||
CValue oApi = oGlobal["Api"];
|
||||
CValue oPresentation = oApi.Call("GetPresentation");
|
||||
oPresentation.Call("SetSizes", 9144000, 6858000);
|
||||
|
||||
CValue oSlide = createImageSlide(oApi, oPresentation, slideImages["gun"]);
|
||||
oPresentation.Call("GetSlideByIndex", 0).Call("Delete");
|
||||
|
||||
CValue oShape = oApi.Call("CreateShape", "rect", 8056800, 3020400, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
|
||||
oShape.Call("SetPosition", 608400, 1267200);
|
||||
CValue oContent = oShape.Call("GetDocContent");
|
||||
oContent.Call("RemoveAllElements");
|
||||
addTextToSlideShape(oApi, oContent, "How They", 160, true, "left");
|
||||
addTextToSlideShape(oApi, oContent, "Throw Out", 132, false, "left");
|
||||
addTextToSlideShape(oApi, oContent, "a Challenge", 132, false, "left");
|
||||
oSlide.Call("AddObject", oShape);
|
||||
|
||||
oSlide = createImageSlide(oApi, oPresentation, slideImages["axe"]);
|
||||
|
||||
oShape = oApi.Call("CreateShape", "rect", 6904800, 1724400, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
|
||||
oShape.Call("SetPosition", 1764000, 1191600);
|
||||
oContent = oShape.Call("GetDocContent");
|
||||
oContent.Call("RemoveAllElements");
|
||||
addTextToSlideShape(oApi, oContent, "American Indians ", 110, true, "right");
|
||||
addTextToSlideShape(oApi, oContent, "(XVII century)", 94, false, "right");
|
||||
oSlide.Call("AddObject", oShape);
|
||||
|
||||
oShape = oApi.Call("CreateShape", "rect", 4986000, 2419200, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
|
||||
oShape.Call("SetPosition", 3834000, 3888000);
|
||||
oContent = oShape.Call("GetDocContent");
|
||||
oContent.Call("RemoveAllElements");
|
||||
addTextToSlideShape(oApi, oContent, "put a tomahawk on the ground in the ", 84, false, "right");
|
||||
addTextToSlideShape(oApi, oContent, "rival's camp", 84, false, "right");
|
||||
oSlide.Call("AddObject", oShape);
|
||||
|
||||
oSlide = createImageSlide(oApi, oPresentation, slideImages["knight"]);
|
||||
|
||||
oShape = oApi.Call("CreateShape", "rect", 6904800, 1724400, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
|
||||
oShape.Call("SetPosition", 1764000, 1191600);
|
||||
oContent = oShape.Call("GetDocContent");
|
||||
oContent.Call("RemoveAllElements");
|
||||
addTextToSlideShape(oApi, oContent, "European Knights", 110, true, "right");
|
||||
addTextToSlideShape(oApi, oContent, " (XII-XVI centuries)", 94, false, "right");
|
||||
oSlide.Call("AddObject", oShape);
|
||||
|
||||
oShape = oApi.Call("CreateShape", "rect", 4986000, 2419200, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
|
||||
oShape.Call("SetPosition", 3834000, 3888000);
|
||||
oContent = oShape.Call("GetDocContent");
|
||||
oContent.Call("RemoveAllElements");
|
||||
addTextToSlideShape(oApi, oContent, "threw a glove", 84, false, "right");
|
||||
addTextToSlideShape(oApi, oContent, "in the rival's face", 84, false, "right");
|
||||
oSlide.Call("AddObject", oShape);
|
||||
|
||||
oSlide = createImageSlide(oApi, oPresentation, slideImages["sky"]);
|
||||
|
||||
oShape = oApi.Call("CreateShape", "rect", 7887600, 3063600, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
|
||||
oShape.Call("SetPosition", 630000, 1357200);
|
||||
oContent = oShape.Call("GetDocContent");
|
||||
oContent.Call("RemoveAllElements");
|
||||
addTextToSlideShape(oApi, oContent, "OnlyOffice", 176, false, "center");
|
||||
addTextToSlideShape(oApi, oContent, "stands for Peace", 132, false, "center");
|
||||
oSlide.Call("AddObject", oShape);
|
||||
|
||||
// Save file and close DocBuilder
|
||||
oBuilder.SaveFile(doctype, resultPath);
|
||||
oBuilder.CloseFile();
|
||||
CDocBuilder.Destroy();
|
||||
}
|
||||
|
||||
public static CValue createImageSlide(CValue oApi, CValue oPresentation, string image_url)
|
||||
{
|
||||
CValue oSlide = oApi.Call("CreateSlide");
|
||||
oPresentation.Call("AddSlide", oSlide);
|
||||
var oFill = oApi.Call("CreateBlipFill", image_url, "stretch");
|
||||
oSlide.Call("SetBackground", oFill);
|
||||
oSlide.Call("RemoveAllObjects");
|
||||
return oSlide;
|
||||
}
|
||||
|
||||
public static void addTextToSlideShape(CValue oApi, CValue oContent, string text, int fontSize, bool isBold, string js)
|
||||
{
|
||||
var oParagraph = oApi.Call("CreateParagraph");
|
||||
oParagraph.Call("SetSpacingBefore", 0);
|
||||
oParagraph.Call("SetSpacingAfter", 0);
|
||||
oContent.Call("Push", oParagraph);
|
||||
var oRun = oParagraph.Call("AddText", text);
|
||||
oRun.Call("SetFill", oApi.Call("CreateSolidFill", oApi.Call("CreateRGBColor", 0xff, 0xff, 0xff)));
|
||||
oRun.Call("SetFontSize", fontSize);
|
||||
oRun.Call("SetFontFamily", "Georgia");
|
||||
oRun.Call("SetBold", isBold);
|
||||
oParagraph.Call("SetJc", js);
|
||||
}
|
||||
}
|
||||
}
|
||||
115
DesktopEditor/doctrenderer/samples/cs/filling_form/Program.cs
Normal file
115
DesktopEditor/doctrenderer/samples/cs/filling_form/Program.cs
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
using docbuilder_net;
|
||||
|
||||
using OfficeFileTypes = docbuilder_net.FileTypes;
|
||||
using CValue = docbuilder_net.CDocBuilderValue;
|
||||
using CContext = docbuilder_net.CDocBuilderContext;
|
||||
using CContextScope = docbuilder_net.CDocBuilderContextScope;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Sample
|
||||
{
|
||||
public class FillingForm
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string workDirectory = "C:/Program Files/ONLYOFFICE/DocumentBuilder";
|
||||
string filePath = "../../../../../../resources/docs/form.docx";
|
||||
string resultPath = "../../../result.docx";
|
||||
|
||||
IDictionary<string, string> formData = new Dictionary<string, string>() {
|
||||
{ "Photo", "https://api.onlyoffice.com/content/img/docbuilder/examples/blue_cloud.png" },
|
||||
{ "Serial","A1345" },
|
||||
{ "Company Name", "Blue Cloud" },
|
||||
{ "Date", "25.12.2023" },
|
||||
{ "Recipient", "Space Corporation" },
|
||||
{ "Qty1", "25" },
|
||||
{ "Description1", "Frame" },
|
||||
{ "Qty2", "2" },
|
||||
{ "Description2", "Stack" },
|
||||
{ "Qty3", "34" },
|
||||
{ "Description3", "Shifter" }
|
||||
};
|
||||
// add Docbuilder dlls in path
|
||||
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + workDirectory);
|
||||
|
||||
FillForm(workDirectory, resultPath, filePath, formData);
|
||||
}
|
||||
|
||||
public static void FillForm(string workDirectory, string resultPath, string filePath, IDictionary<string, string> formData)
|
||||
{
|
||||
var doctype = (int)OfficeFileTypes.Document.DOCX;
|
||||
|
||||
// Init DocBuilder
|
||||
CDocBuilder.Initialize(workDirectory);
|
||||
CDocBuilder oBuilder = new CDocBuilder();
|
||||
oBuilder.OpenFile(filePath, "docxf");
|
||||
|
||||
CContext oContext = oBuilder.GetContext();
|
||||
CContextScope oScope = oContext.CreateScope();
|
||||
CValue oGlobal = oContext.GetGlobal();
|
||||
CValue oApi = oGlobal["Api"];
|
||||
|
||||
// Fill form
|
||||
CValue oDocument = oApi.Call("GetDocument");
|
||||
CValue aForms = oDocument.Call("GetAllForms");
|
||||
int formNum = 0;
|
||||
while (formNum < aForms.GetLength())
|
||||
{
|
||||
CValue form = aForms[formNum];
|
||||
string type = form.Call("GetFormType").ToString();
|
||||
string value;
|
||||
try
|
||||
{
|
||||
value = formData[form.Call("GetFormKey").ToString()];
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
if (type == "textForm") form.Call("SetText", value);
|
||||
if (type == "pictureForm") form.Call("SetImage", value);
|
||||
formNum++;
|
||||
}
|
||||
|
||||
// Save file and close DocBuilder
|
||||
oBuilder.SaveFile(doctype, resultPath);
|
||||
oBuilder.CloseFile();
|
||||
|
||||
CDocBuilder.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
using docbuilder_net;
|
||||
|
||||
using OfficeFileTypes = docbuilder_net.FileTypes;
|
||||
using CValue = docbuilder_net.CDocBuilderValue;
|
||||
using CContext = docbuilder_net.CDocBuilderContext;
|
||||
using CContextScope = docbuilder_net.CDocBuilderContextScope;
|
||||
|
||||
namespace Sample
|
||||
{
|
||||
public class FillingSpreadsheet
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string workDirectory = "C:/Program Files/ONLYOFFICE/DocumentBuilder";
|
||||
string resultPath = "../../../result.xlsx";
|
||||
object[,] data = {
|
||||
{ "Id", "Product", "Price", "Available"},
|
||||
{ 1001, "Item A", 12.2, true },
|
||||
{ 1002, "Item B", 18.8, true },
|
||||
{ 1003, "Item C", 70.1, false },
|
||||
{ 1004, "Item D", 60.6, true },
|
||||
{ 1005, "Item E", 32.6, true },
|
||||
{ 1006, "Item F", 28.3, false },
|
||||
{ 1007, "Item G", 11.1, false },
|
||||
{ 1008, "Item H", 41.4, true }
|
||||
};
|
||||
// add Docbuilder dlls in path
|
||||
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + workDirectory);
|
||||
|
||||
FillSpreadsheet(workDirectory, resultPath, data);
|
||||
}
|
||||
|
||||
public static void FillSpreadsheet(string workDirectory, string resultPath, object[,] data)
|
||||
{
|
||||
var doctype = (int)OfficeFileTypes.Spreadsheet.XLSX;
|
||||
|
||||
// Init DocBuilder
|
||||
CDocBuilder.Initialize(workDirectory);
|
||||
CDocBuilder oBuilder = new CDocBuilder();
|
||||
|
||||
oBuilder.CreateFile(doctype);
|
||||
CContext oContext = oBuilder.GetContext();
|
||||
CContextScope oScope = oContext.CreateScope();
|
||||
CValue oGlobal = oContext.GetGlobal();
|
||||
CValue oApi = oGlobal["Api"];
|
||||
CValue oWorksheet = oApi.Call("GetActiveSheet");
|
||||
|
||||
// pass data
|
||||
CValue oArray = TwoDimArrayToCValue(data, oContext);
|
||||
// First cell in the range (A1) is equal to (0,0)
|
||||
CValue startCell = oWorksheet.Call("GetRangeByNumber", 0, 0);
|
||||
// Last cell in the range is equal to array length -1
|
||||
CValue endCell = oWorksheet.Call("GetRangeByNumber", oArray.GetLength() - 1, oArray[0].GetLength() - 1);
|
||||
oWorksheet.Call("GetRange", startCell, endCell).Call("SetValue", oArray);
|
||||
|
||||
|
||||
// Save file and close DocBuilder
|
||||
oBuilder.SaveFile(doctype, resultPath);
|
||||
oBuilder.CloseFile();
|
||||
CDocBuilder.Destroy();
|
||||
}
|
||||
|
||||
public static CValue TwoDimArrayToCValue(object[,] data, CContext oContext)
|
||||
{
|
||||
int rowsLen = data.GetLength(0);
|
||||
int colsLen = data.GetLength(1);
|
||||
CValue oArray = oContext.CreateArray(rowsLen);
|
||||
|
||||
for (int row = 0; row < rowsLen; row++)
|
||||
{
|
||||
CValue oArrayCol = oContext.CreateArray(colsLen);
|
||||
|
||||
for (int col = 0; col < colsLen; col++)
|
||||
{
|
||||
oArrayCol[col] = data[row, col].ToString();
|
||||
}
|
||||
oArray[row] = oArrayCol;
|
||||
}
|
||||
return oArray;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
import docbuilder.*;
|
||||
|
||||
public class Program {
|
||||
public static void main(String[] args) {
|
||||
String resultPath = "result.docx";
|
||||
|
||||
createBasicForm(resultPath);
|
||||
|
||||
// Need to explicitly call System.gc() to free up resources
|
||||
System.gc();
|
||||
}
|
||||
|
||||
public static void createBasicForm(String resultPath) {
|
||||
int doctype = FileTypes.Document.DOCX;
|
||||
|
||||
// Initialize builder with docbuilder.jar directory by passing empty string
|
||||
CDocBuilder.initialize("");
|
||||
CDocBuilder builder = new CDocBuilder();
|
||||
builder.createFile(doctype);
|
||||
|
||||
CDocBuilderContext context = builder.getContext();
|
||||
CDocBuilderValue global = context.getGlobal();
|
||||
CDocBuilderValue api = global.get("Api");
|
||||
|
||||
// Create basic form
|
||||
CDocBuilderValue document = api.call("GetDocument");
|
||||
CDocBuilderValue paragraph = document.call("GetElement", 0);
|
||||
CDocBuilderValue headingStyle = document.call("GetStyle", "Heading 3");
|
||||
|
||||
paragraph.call("AddText", "Employee pass card");
|
||||
paragraph.call("SetStyle", headingStyle);
|
||||
document.call("Push", paragraph);
|
||||
|
||||
CDocBuilderValue pictureForm = api.call("CreatePictureForm");
|
||||
setPictureFormProperties(pictureForm, "Photo", "Upload your photo", false, "Photo", "tooBig", true, false, 50, 50, "https://api.onlyoffice.com/content/img/docbuilder/examples/user-profile.png");
|
||||
paragraph = api.call("CreateParagraph");
|
||||
paragraph.call("AddElement", pictureForm);
|
||||
document.call("Push", paragraph);
|
||||
|
||||
CDocBuilderValue textForm = api.call("CreateTextForm");
|
||||
setTextFormProperties(textForm, "First name", "Enter your first name", false, "First name", true, 13, 3, false, false);
|
||||
paragraph = api.call("CreateParagraph");
|
||||
paragraph.call("AddElement", textForm);
|
||||
document.call("Push", paragraph);
|
||||
|
||||
// Save file and close DocBuilder
|
||||
builder.saveFile(doctype, resultPath);
|
||||
builder.closeFile();
|
||||
|
||||
CDocBuilder.dispose();
|
||||
}
|
||||
|
||||
public static void setPictureFormProperties(CDocBuilderValue pictureForm, String key, String tip, boolean required, String placeholder, String scaleFlag, boolean lockAspectRatio, boolean respectBorders, int shiftX, int shiftY, String imageUrl) {
|
||||
pictureForm.call("SetFormKey", key);
|
||||
pictureForm.call("SetTipText", tip);
|
||||
pictureForm.call("SetRequired", required);
|
||||
pictureForm.call("SetPlaceholderText", placeholder);
|
||||
pictureForm.call("SetScaleFlag", scaleFlag);
|
||||
pictureForm.call("SetLockAspectRatio", lockAspectRatio);
|
||||
pictureForm.call("SetRespectBorders", respectBorders);
|
||||
pictureForm.call("SetPicturePosition", shiftX, shiftY);
|
||||
pictureForm.call("SetImage", imageUrl);
|
||||
}
|
||||
|
||||
public static void setTextFormProperties(CDocBuilderValue textForm, String key, String tip, boolean required, String placeholder, boolean comb, int maxCharacters, int cellWidth, boolean multiLine, boolean autoFit) {
|
||||
textForm.call("SetFormKey", key);
|
||||
textForm.call("SetTipText", tip);
|
||||
textForm.call("SetRequired", required);
|
||||
textForm.call("SetPlaceholderText", placeholder);
|
||||
textForm.call("SetComb", comb);
|
||||
textForm.call("SetCharactersLimit", maxCharacters);
|
||||
textForm.call("SetCellWidth", cellWidth);
|
||||
textForm.call("SetCellWidth", multiLine);
|
||||
textForm.call("SetMultiline", autoFit);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,123 @@
|
||||
import docbuilder.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Program {
|
||||
public static void main(String[] args) {
|
||||
String resultPath = "result.pptx";
|
||||
// Fill slide images
|
||||
HashMap<String, String> slideImages = new HashMap<String, String>();
|
||||
slideImages.put("gun", "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_gun.png");
|
||||
slideImages.put("axe", "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_axe.png");
|
||||
slideImages.put("knight", "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_knight.png");
|
||||
slideImages.put("sky", "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_sky.png");
|
||||
|
||||
createPresentation(resultPath, slideImages);
|
||||
|
||||
// Need to explicitly call System.gc() to free up resources
|
||||
System.gc();
|
||||
}
|
||||
|
||||
public static void createPresentation(String resultPath, HashMap<String, String> slideImages) {
|
||||
int doctype = FileTypes.Presentation.PPTX;
|
||||
|
||||
// Initialize builder with docbuilder.jar directory by passing empty String
|
||||
CDocBuilder.initialize("");
|
||||
CDocBuilder builder = new CDocBuilder();
|
||||
builder.createFile(doctype);
|
||||
|
||||
CDocBuilderContext context = builder.getContext();
|
||||
CDocBuilderValue global = context.getGlobal();
|
||||
CDocBuilderValue api = global.get("Api");
|
||||
|
||||
// Create presentation
|
||||
CDocBuilderValue presentation = api.call("GetPresentation");
|
||||
presentation.call("SetSizes", 9144000, 6858000);
|
||||
|
||||
CDocBuilderValue slide = createImageSlide(api, presentation, slideImages.get("gun"));
|
||||
presentation.call("GetSlideByIndex", 0).call("Delete");
|
||||
|
||||
CDocBuilderValue shape = api.call("CreateShape", "rect", 8056800, 3020400, api.call("CreateNoFill"), api.call("CreateStroke", 0, api.call("CreateNoFill")));
|
||||
shape.call("SetPosition", 608400, 1267200);
|
||||
CDocBuilderValue content = shape.call("GetDocContent");
|
||||
content.call("RemoveAllElements");
|
||||
addTextToSlideShape(api, content, "How They", 160, true, "left");
|
||||
addTextToSlideShape(api, content, "Throw Out", 132, false, "left");
|
||||
addTextToSlideShape(api, content, "a Challenge", 132, false, "left");
|
||||
slide.call("AddObject", shape);
|
||||
|
||||
slide = createImageSlide(api, presentation, slideImages.get("axe"));
|
||||
|
||||
shape = api.call("CreateShape", "rect", 6904800, 1724400, api.call("CreateNoFill"), api.call("CreateStroke", 0, api.call("CreateNoFill")));
|
||||
shape.call("SetPosition", 1764000, 1191600);
|
||||
content = shape.call("GetDocContent");
|
||||
content.call("RemoveAllElements");
|
||||
addTextToSlideShape(api, content, "American Indians ", 110, true, "right");
|
||||
addTextToSlideShape(api, content, "(XVII century)", 94, false, "right");
|
||||
slide.call("AddObject", shape);
|
||||
|
||||
shape = api.call("CreateShape", "rect", 4986000, 2419200, api.call("CreateNoFill"), api.call("CreateStroke", 0, api.call("CreateNoFill")));
|
||||
shape.call("SetPosition", 3834000, 3888000);
|
||||
content = shape.call("GetDocContent");
|
||||
content.call("RemoveAllElements");
|
||||
addTextToSlideShape(api, content, "put a tomahawk on the ground in the ", 84, false, "right");
|
||||
addTextToSlideShape(api, content, "rival's camp", 84, false, "right");
|
||||
slide.call("AddObject", shape);
|
||||
|
||||
slide = createImageSlide(api, presentation, slideImages.get("knight"));
|
||||
|
||||
shape = api.call("CreateShape", "rect", 6904800, 1724400, api.call("CreateNoFill"), api.call("CreateStroke", 0, api.call("CreateNoFill")));
|
||||
shape.call("SetPosition", 1764000, 1191600);
|
||||
content = shape.call("GetDocContent");
|
||||
content.call("RemoveAllElements");
|
||||
addTextToSlideShape(api, content, "European Knights", 110, true, "right");
|
||||
addTextToSlideShape(api, content, " (XII-XVI centuries)", 94, false, "right");
|
||||
slide.call("AddObject", shape);
|
||||
|
||||
shape = api.call("CreateShape", "rect", 4986000, 2419200, api.call("CreateNoFill"), api.call("CreateStroke", 0, api.call("CreateNoFill")));
|
||||
shape.call("SetPosition", 3834000, 3888000);
|
||||
content = shape.call("GetDocContent");
|
||||
content.call("RemoveAllElements");
|
||||
addTextToSlideShape(api, content, "threw a glove", 84, false, "right");
|
||||
addTextToSlideShape(api, content, "in the rival's face", 84, false, "right");
|
||||
slide.call("AddObject", shape);
|
||||
|
||||
slide = createImageSlide(api, presentation, slideImages.get("sky"));
|
||||
|
||||
shape = api.call("CreateShape", "rect", 7887600, 3063600, api.call("CreateNoFill"), api.call("CreateStroke", 0, api.call("CreateNoFill")));
|
||||
shape.call("SetPosition", 630000, 1357200);
|
||||
content = shape.call("GetDocContent");
|
||||
content.call("RemoveAllElements");
|
||||
addTextToSlideShape(api, content, "OnlyOffice", 176, false, "center");
|
||||
addTextToSlideShape(api, content, "stands for Peace", 132, false, "center");
|
||||
slide.call("AddObject", shape);
|
||||
|
||||
// Save file and close DocBuilder
|
||||
builder.saveFile(doctype, resultPath);
|
||||
builder.closeFile();
|
||||
|
||||
CDocBuilder.dispose();
|
||||
}
|
||||
|
||||
public static CDocBuilderValue createImageSlide(CDocBuilderValue api, CDocBuilderValue presentation, String imageUrl) {
|
||||
CDocBuilderValue slide = api.call("CreateSlide");
|
||||
presentation.call("AddSlide", slide);
|
||||
CDocBuilderValue fill = api.call("CreateBlipFill", imageUrl, "stretch");
|
||||
slide.call("SetBackground", fill);
|
||||
slide.call("RemoveAllObjects");
|
||||
return slide;
|
||||
}
|
||||
|
||||
public static void addTextToSlideShape(CDocBuilderValue api, CDocBuilderValue content, String text, int fontSize, boolean isBold, String js) {
|
||||
CDocBuilderValue paragraph = api.call("CreateParagraph");
|
||||
paragraph.call("SetSpacingBefore", 0);
|
||||
paragraph.call("SetSpacingAfter", 0);
|
||||
content.call("Push", paragraph);
|
||||
CDocBuilderValue run = paragraph.call("AddText", text);
|
||||
run.call("SetFill", api.call("CreateSolidFill", api.call("CreateRGBColor", 0xff, 0xff, 0xff)));
|
||||
run.call("SetFontSize", fontSize);
|
||||
run.call("SetFontFamily", "Georgia");
|
||||
run.call("SetBold", isBold);
|
||||
paragraph.call("SetJc", js);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
import docbuilder.*;
|
||||
|
||||
public class Program {
|
||||
public static void main(String[] args) {
|
||||
String resultPath = "result.xlsx";
|
||||
// Fill table data
|
||||
Object[][] data = {
|
||||
{ "Id", "Product", "Price", "Available" },
|
||||
{ 1001, "Item A", 12.2, true },
|
||||
{ 1002, "Item B", 18.8, true },
|
||||
{ 1003, "Item C", 70.1, false },
|
||||
{ 1004, "Item D", 60.6, true },
|
||||
{ 1005, "Item E", 32.6, true },
|
||||
{ 1006, "Item F", 28.3, false },
|
||||
{ 1007, "Item G", 11.1, false },
|
||||
{ 1008, "Item H", 41.4, true }
|
||||
};
|
||||
|
||||
fillSpreadsheet(resultPath, data);
|
||||
|
||||
// Need to explicitly call System.gc() to free up resources
|
||||
System.gc();
|
||||
}
|
||||
|
||||
public static void fillSpreadsheet(String resultPath, Object[][] data) {
|
||||
int doctype = FileTypes.Spreadsheet.XLSX;
|
||||
|
||||
// Initialize builder with docbuilder.jar directory by passing empty String
|
||||
CDocBuilder.initialize("");
|
||||
CDocBuilder builder = new CDocBuilder();
|
||||
builder.createFile(doctype);
|
||||
|
||||
CDocBuilderContext context = builder.getContext();
|
||||
CDocBuilderValue global = context.getGlobal();
|
||||
CDocBuilderValue api = global.get("Api");
|
||||
|
||||
// Create spreadsheet
|
||||
CDocBuilderValue worksheet = api.call("GetActiveSheet");
|
||||
|
||||
// Convert data to array value type
|
||||
CDocBuilderValue array = new CDocBuilderValue(data);
|
||||
// First cell in the range (A1) is equal to (0,0)
|
||||
CDocBuilderValue startCell = worksheet.call("GetRangeByNumber", 0, 0);
|
||||
// Last cell in the range is equal to array length -1
|
||||
CDocBuilderValue endCell = worksheet.call("GetRangeByNumber", array.getLength() - 1, array.get(0).getLength() - 1);
|
||||
worksheet.call("GetRange", startCell, endCell).call("SetValue", array);
|
||||
|
||||
// Save file and close DocBuilder
|
||||
builder.saveFile(doctype, resultPath);
|
||||
builder.closeFile();
|
||||
|
||||
CDocBuilder.dispose();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
import os
|
||||
import sys
|
||||
sys.path.append('C:/Program Files/ONLYOFFICE/DocumentBuilder')
|
||||
import docbuilder
|
||||
|
||||
# Helper functions
|
||||
def setPictureFormProperties(pictureForm, key, tip, required, placeholder, scaleFlag, lockAspectRatio, respectBorders, shiftX, shiftY, imageUrl):
|
||||
pictureForm.Call('SetFormKey', key)
|
||||
pictureForm.Call('SetTipText', tip)
|
||||
pictureForm.Call('SetRequired', required)
|
||||
pictureForm.Call('SetPlaceholderText', placeholder)
|
||||
pictureForm.Call('SetScaleFlag', scaleFlag)
|
||||
pictureForm.Call('SetLockAspectRatio', lockAspectRatio)
|
||||
pictureForm.Call('SetRespectBorders', respectBorders)
|
||||
pictureForm.Call('SetPicturePosition', shiftX, shiftY)
|
||||
pictureForm.Call('SetImage', imageUrl)
|
||||
|
||||
def setTextFormProperties(textForm, key, tip, required, placeholder, comb, maxCharacters, cellWidth, multiLine, autoFit):
|
||||
textForm.Call('SetFormKey', key)
|
||||
textForm.Call('SetTipText', tip)
|
||||
textForm.Call('SetRequired', required)
|
||||
textForm.Call('SetPlaceholderText', placeholder)
|
||||
textForm.Call('SetComb', comb)
|
||||
textForm.Call('SetCharactersLimit', maxCharacters)
|
||||
textForm.Call('SetCellWidth', cellWidth)
|
||||
textForm.Call('SetCellWidth', multiLine)
|
||||
textForm.Call('SetMultiline', autoFit)
|
||||
|
||||
if __name__ == '__main__':
|
||||
builder = docbuilder.CDocBuilder()
|
||||
builder.CreateFile(docbuilder.FileTypes.Document.DOCX)
|
||||
|
||||
context = builder.GetContext()
|
||||
globalObj = context.GetGlobal()
|
||||
api = globalObj['Api']
|
||||
|
||||
document = api.Call('GetDocument')
|
||||
paragraph = document.Call('GetElement', 0)
|
||||
headingStyle = document.Call('GetStyle', 'Heading 3')
|
||||
|
||||
paragraph.Call('AddText', 'Employee pass card')
|
||||
paragraph.Call('SetStyle', headingStyle)
|
||||
document.Call('Push', paragraph)
|
||||
|
||||
pictureForm = api.Call('CreatePictureForm')
|
||||
setPictureFormProperties(pictureForm, 'Photo', 'Upload your photo', False, 'Photo', 'tooBig', True, False, 50, 50, 'https://api.onlyoffice.com/content/img/docbuilder/examples/user-profile.png')
|
||||
paragraph = api.Call('CreateParagraph')
|
||||
paragraph.Call('AddElement', pictureForm)
|
||||
document.Call('Push', paragraph)
|
||||
|
||||
textForm = api.Call('CreateTextForm')
|
||||
setTextFormProperties(textForm, 'First name', 'Enter your first name', False, 'First name', True, 13, 3, False, False)
|
||||
paragraph = api.Call('CreateParagraph')
|
||||
paragraph.Call('AddElement', textForm)
|
||||
document.Call('Push', paragraph)
|
||||
|
||||
# Save and close
|
||||
resultPath = os.getcwd() + '/result.docx'
|
||||
builder.SaveFile(docbuilder.FileTypes.Document.DOCX, resultPath)
|
||||
builder.CloseFile()
|
||||
@ -0,0 +1,105 @@
|
||||
import os
|
||||
import sys
|
||||
sys.path.append('C:/Program Files/ONLYOFFICE/DocumentBuilder')
|
||||
import docbuilder
|
||||
|
||||
def createImageSlide(api, presentation, image_url):
|
||||
slide = api.Call('CreateSlide')
|
||||
presentation.Call('AddSlide', slide)
|
||||
fill = api.Call('CreateBlipFill', image_url, 'stretch')
|
||||
slide.Call('SetBackground', fill)
|
||||
slide.Call('RemoveAllObjects')
|
||||
return slide
|
||||
|
||||
def addTextToSlideShape(api, content, text, fontSize, isBold, js):
|
||||
paragraph = api.Call('CreateParagraph')
|
||||
paragraph.Call('SetSpacingBefore', 0)
|
||||
paragraph.Call('SetSpacingAfter', 0)
|
||||
content.Call('Push', paragraph)
|
||||
run = paragraph.Call('AddText', text)
|
||||
run.Call('SetFill', api.Call('CreateSolidFill', api.Call('CreateRGBColor', 0xff, 0xff, 0xff)))
|
||||
run.Call('SetFontSize', fontSize)
|
||||
run.Call('SetFontFamily', 'Georgia')
|
||||
run.Call('SetBold', isBold)
|
||||
paragraph.Call('SetJc', js)
|
||||
|
||||
if __name__ == '__main__':
|
||||
slideImages = {}
|
||||
slideImages['gun'] = 'https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_gun.png'
|
||||
slideImages['axe'] = 'https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_axe.png'
|
||||
slideImages['knight'] = 'https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_knight.png'
|
||||
slideImages['sky'] = 'https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_sky.png'
|
||||
|
||||
builder = docbuilder.CDocBuilder()
|
||||
builder.CreateFile(docbuilder.FileTypes.Presentation.PPTX)
|
||||
|
||||
context = builder.GetContext()
|
||||
globalObj = context.GetGlobal()
|
||||
api = globalObj['Api']
|
||||
|
||||
# Create presentation
|
||||
presentation = api.Call('GetPresentation')
|
||||
presentation.Call('SetSizes', 9144000, 6858000)
|
||||
|
||||
slide = createImageSlide(api, presentation, slideImages['gun'])
|
||||
presentation.Call('GetSlideByIndex', 0).Call('Delete')
|
||||
|
||||
shape = api.Call('CreateShape', 'rect', 8056800, 3020400, api.Call('CreateNoFill'), api.Call('CreateStroke', 0, api.Call('CreateNoFill')))
|
||||
shape.Call('SetPosition', 608400, 1267200)
|
||||
content = shape.Call('GetDocContent')
|
||||
content.Call('RemoveAllElements')
|
||||
addTextToSlideShape(api, content, 'How They', 160, True, 'left')
|
||||
addTextToSlideShape(api, content, 'Throw Out', 132, False, 'left')
|
||||
addTextToSlideShape(api, content, 'a Challenge', 132, False, 'left')
|
||||
slide.Call('AddObject', shape)
|
||||
|
||||
slide = createImageSlide(api, presentation, slideImages['axe'])
|
||||
|
||||
shape = api.Call('CreateShape', 'rect', 6904800, 1724400, api.Call('CreateNoFill'), api.Call('CreateStroke', 0, api.Call('CreateNoFill')))
|
||||
shape.Call('SetPosition', 1764000, 1191600)
|
||||
content = shape.Call('GetDocContent')
|
||||
content.Call('RemoveAllElements')
|
||||
addTextToSlideShape(api, content, 'American Indians ', 110, True, 'right')
|
||||
addTextToSlideShape(api, content, '(XVII century)', 94, False, 'right')
|
||||
slide.Call('AddObject', shape)
|
||||
|
||||
shape = api.Call('CreateShape', 'rect', 4986000, 2419200, api.Call('CreateNoFill'), api.Call('CreateStroke', 0, api.Call('CreateNoFill')))
|
||||
shape.Call('SetPosition', 3834000, 3888000)
|
||||
content = shape.Call('GetDocContent')
|
||||
content.Call('RemoveAllElements')
|
||||
addTextToSlideShape(api, content, 'put a tomahawk on the ground in the ', 84, False, 'right')
|
||||
addTextToSlideShape(api, content, 'rival\'s camp', 84, False, 'right')
|
||||
slide.Call('AddObject', shape)
|
||||
|
||||
slide = createImageSlide(api, presentation, slideImages['knight'])
|
||||
|
||||
shape = api.Call('CreateShape', 'rect', 6904800, 1724400, api.Call('CreateNoFill'), api.Call('CreateStroke', 0, api.Call('CreateNoFill')))
|
||||
shape.Call('SetPosition', 1764000, 1191600)
|
||||
content = shape.Call('GetDocContent')
|
||||
content.Call('RemoveAllElements')
|
||||
addTextToSlideShape(api, content, 'European Knights', 110, True, 'right')
|
||||
addTextToSlideShape(api, content, ' (XII-XVI centuries)', 94, False, 'right')
|
||||
slide.Call('AddObject', shape)
|
||||
|
||||
shape = api.Call('CreateShape', 'rect', 4986000, 2419200, api.Call('CreateNoFill'), api.Call('CreateStroke', 0, api.Call('CreateNoFill')))
|
||||
shape.Call('SetPosition', 3834000, 3888000)
|
||||
content = shape.Call('GetDocContent')
|
||||
content.Call('RemoveAllElements')
|
||||
addTextToSlideShape(api, content, 'threw a glove', 84, False, 'right')
|
||||
addTextToSlideShape(api, content, 'in the rival\'s face', 84, False, 'right')
|
||||
slide.Call('AddObject', shape)
|
||||
|
||||
slide = createImageSlide(api, presentation, slideImages['sky'])
|
||||
|
||||
shape = api.Call('CreateShape', 'rect', 7887600, 3063600, api.Call('CreateNoFill'), api.Call('CreateStroke', 0, api.Call('CreateNoFill')))
|
||||
shape.Call('SetPosition', 630000, 1357200)
|
||||
content = shape.Call('GetDocContent')
|
||||
content.Call('RemoveAllElements')
|
||||
addTextToSlideShape(api, content, 'OnlyOffice', 176, False, 'center')
|
||||
addTextToSlideShape(api, content, 'stands for Peace', 132, False, 'center')
|
||||
slide.Call('AddObject', shape)
|
||||
|
||||
# Save and close
|
||||
resultPath = os.getcwd() + '/result.pptx'
|
||||
builder.SaveFile(docbuilder.FileTypes.Presentation.PPTX, resultPath)
|
||||
builder.CloseFile()
|
||||
@ -0,0 +1,42 @@
|
||||
import os
|
||||
import sys
|
||||
sys.path.append('C:/Program Files/ONLYOFFICE/DocumentBuilder')
|
||||
import docbuilder
|
||||
|
||||
if __name__ == '__main__':
|
||||
data = [
|
||||
[ 'Id', 'Product', 'Price', 'Available' ],
|
||||
[ '1001', 'Item A', "12.2", 'true' ],
|
||||
[ '1002', 'Item B', "18.8", 'true' ],
|
||||
[ '1003', 'Item C', "70.1", 'false' ],
|
||||
[ '1004', 'Item D', "60.6", 'true' ],
|
||||
[ '1005', 'Item E', "32.6", 'true' ],
|
||||
[ '1006', 'Item F', "28.3", 'false' ],
|
||||
[ '1007', 'Item G', "11.1", 'false' ],
|
||||
[ '1008', 'Item H', "41.4", 'true' ]
|
||||
]
|
||||
|
||||
builder = docbuilder.CDocBuilder()
|
||||
builder.CreateFile(docbuilder.FileTypes.Spreadsheet.XLSX)
|
||||
|
||||
context = builder.GetContext()
|
||||
globalObj = context.GetGlobal()
|
||||
api = globalObj['Api']
|
||||
|
||||
# Find and comment formula errors
|
||||
worksheet = api.Call('GetActiveSheet')
|
||||
|
||||
# Create array from data
|
||||
array = docbuilder.CDocBuilderValue(data)
|
||||
|
||||
# First cell in the range (A1) is equal to (0,0)
|
||||
startCell = worksheet.Call('GetRangeByNumber', 0, 0)
|
||||
|
||||
# Last cell in the range is equal to array length -1
|
||||
endCell = worksheet.Call('GetRangeByNumber', len(data) - 1, len(data[0]) - 1)
|
||||
worksheet.Call('GetRange', startCell, endCell).Call('SetValue', array)
|
||||
|
||||
# Save and close
|
||||
resultPath = os.getcwd() + '/result.xlsx'
|
||||
builder.SaveFile(docbuilder.FileTypes.Spreadsheet.XLSX, resultPath)
|
||||
builder.CloseFile()
|
||||
Binary file not shown.
BIN
DesktopEditor/doctrenderer/samples/resources/docs/form.docx
Normal file
BIN
DesktopEditor/doctrenderer/samples/resources/docs/form.docx
Normal file
Binary file not shown.
Binary file not shown.
258
DesktopEditor/doctrenderer/samples/resources/utils/utils.h
Normal file
258
DesktopEditor/doctrenderer/samples/resources/utils/utils.h
Normal file
@ -0,0 +1,258 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
// convenient macro definitions
|
||||
#if defined(__linux__) || defined(__linux)
|
||||
#define _LINUX
|
||||
#elif defined(__APPLE__) || defined(__MACH__)
|
||||
#define _MAC
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <wchar.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(_LINUX) || defined(_MAC)
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#ifdef _MAC
|
||||
#include <mach-o/dyld.h>
|
||||
#endif
|
||||
|
||||
#ifdef CreateFile
|
||||
#undef CreateFile
|
||||
#endif
|
||||
|
||||
namespace NSUtils
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#define PATH_SEPARATOR '\\'
|
||||
#define WriteCodepoint(code) \
|
||||
if (code < 0x10000) \
|
||||
*unicodes_cur++ = code; \
|
||||
else \
|
||||
{ \
|
||||
code -= 0x10000; \
|
||||
*unicodes_cur++ = 0xD800 | ((code >> 10) & 0x03FF); \
|
||||
*unicodes_cur++ = 0xDC00 | (code & 0x03FF); \
|
||||
}
|
||||
#else
|
||||
#define PATH_SEPARATOR '/'
|
||||
#define WriteCodepoint(code) *unicodes_cur++ = (wchar_t)code;
|
||||
#endif
|
||||
|
||||
std::wstring GetStringFromUtf8(const unsigned char* utf8, size_t length)
|
||||
{
|
||||
wchar_t* unicodes = new wchar_t[length + 1];
|
||||
wchar_t* unicodes_cur = unicodes;
|
||||
size_t index = 0;
|
||||
|
||||
while (index < length)
|
||||
{
|
||||
unsigned char byteMain = utf8[index];
|
||||
if (0x00 == (byteMain & 0x80))
|
||||
{
|
||||
// 1 byte
|
||||
WriteCodepoint(byteMain)
|
||||
++index;
|
||||
}
|
||||
else if (0x00 == (byteMain & 0x20))
|
||||
{
|
||||
// 2 byte
|
||||
int val = 0;
|
||||
if ((index + 1) < length)
|
||||
{
|
||||
val = (int)(((byteMain & 0x1F) << 6) |
|
||||
(utf8[index + 1] & 0x3F));
|
||||
}
|
||||
|
||||
WriteCodepoint(val)
|
||||
index += 2;
|
||||
}
|
||||
else if (0x00 == (byteMain & 0x10))
|
||||
{
|
||||
// 3 byte
|
||||
int val = 0;
|
||||
if ((index + 2) < length)
|
||||
{
|
||||
val = (int)(((byteMain & 0x0F) << 12) |
|
||||
((utf8[index + 1] & 0x3F) << 6) |
|
||||
(utf8[index + 2] & 0x3F));
|
||||
}
|
||||
|
||||
WriteCodepoint(val)
|
||||
index += 3;
|
||||
}
|
||||
else if (0x00 == (byteMain & 0x0F))
|
||||
{
|
||||
// 4 byte
|
||||
int val = 0;
|
||||
if ((index + 3) < length)
|
||||
{
|
||||
val = (int)(((byteMain & 0x07) << 18) |
|
||||
((utf8[index + 1] & 0x3F) << 12) |
|
||||
((utf8[index + 2] & 0x3F) << 6) |
|
||||
(utf8[index + 3] & 0x3F));
|
||||
}
|
||||
|
||||
WriteCodepoint(val)
|
||||
index += 4;
|
||||
}
|
||||
else if (0x00 == (byteMain & 0x08))
|
||||
{
|
||||
// 4 byte
|
||||
int val = 0;
|
||||
if ((index + 3) < length)
|
||||
{
|
||||
val = (int)(((byteMain & 0x07) << 18) |
|
||||
((utf8[index + 1] & 0x3F) << 12) |
|
||||
((utf8[index + 2] & 0x3F) << 6) |
|
||||
(utf8[index + 3] & 0x3F));
|
||||
}
|
||||
|
||||
WriteCodepoint(val)
|
||||
index += 4;
|
||||
}
|
||||
else if (0x00 == (byteMain & 0x04))
|
||||
{
|
||||
// 5 byte
|
||||
int val = 0;
|
||||
if ((index + 4) < length)
|
||||
{
|
||||
val = (int)(((byteMain & 0x03) << 24) |
|
||||
((utf8[index + 1] & 0x3F) << 18) |
|
||||
((utf8[index + 2] & 0x3F) << 12) |
|
||||
((utf8[index + 3] & 0x3F) << 6) |
|
||||
(utf8[index + 4] & 0x3F));
|
||||
}
|
||||
|
||||
WriteCodepoint(val)
|
||||
index += 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 6 byte
|
||||
int val = 0;
|
||||
if ((index + 5) < length)
|
||||
{
|
||||
val = (int)(((byteMain & 0x01) << 30) |
|
||||
((utf8[index + 1] & 0x3F) << 24) |
|
||||
((utf8[index + 2] & 0x3F) << 18) |
|
||||
((utf8[index + 3] & 0x3F) << 12) |
|
||||
((utf8[index + 4] & 0x3F) << 6) |
|
||||
(utf8[index + 5] & 0x3F));
|
||||
}
|
||||
|
||||
WriteCodepoint(val)
|
||||
index += 5;
|
||||
}
|
||||
}
|
||||
|
||||
*unicodes_cur++ = 0;
|
||||
|
||||
std::wstring sOutput(unicodes);
|
||||
|
||||
delete[] unicodes;
|
||||
|
||||
return sOutput;
|
||||
}
|
||||
}
|
||||
|
||||
namespace NSUtils
|
||||
{
|
||||
#define NS_FILE_MAX_PATH 32768
|
||||
std::wstring GetProcessPath()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
wchar_t buf [NS_FILE_MAX_PATH];
|
||||
GetModuleFileNameW(GetModuleHandle(NULL), buf, NS_FILE_MAX_PATH);
|
||||
return std::wstring(buf);
|
||||
#endif
|
||||
|
||||
#if defined(_LINUX) || defined(_MAC)
|
||||
char buf[NS_FILE_MAX_PATH];
|
||||
memset(buf, 0, NS_FILE_MAX_PATH);
|
||||
if (readlink ("/proc/self/exe", buf, NS_FILE_MAX_PATH) <= 0)
|
||||
{
|
||||
#ifdef _MAC
|
||||
uint32_t _size = NS_FILE_MAX_PATH;
|
||||
_NSGetExecutablePath(buf, &_size);
|
||||
#endif
|
||||
}
|
||||
return GetStringFromUtf8((unsigned char*)buf, strlen(buf));
|
||||
#endif
|
||||
}
|
||||
|
||||
std::wstring GetProcessDirectory()
|
||||
{
|
||||
std::wstring path = GetProcessPath();
|
||||
size_t pos = path.find_last_of(PATH_SEPARATOR);
|
||||
if (pos != std::wstring::npos)
|
||||
path = path.substr(0, pos);
|
||||
return path;
|
||||
}
|
||||
|
||||
std::wstring GetResourcesDirectory()
|
||||
{
|
||||
std::wstring path = GetProcessDirectory();
|
||||
while (!path.empty())
|
||||
{
|
||||
size_t pos = path.find_last_of(PATH_SEPARATOR);
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
std::wstring currDir = path.substr(pos + 1);
|
||||
if (currDir == L"samples")
|
||||
{
|
||||
path += PATH_SEPARATOR;
|
||||
path += L"resources";
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
path = path.substr(0, pos);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
path = L"";
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
@ -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,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;
|
||||
@ -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;
|
||||
@ -741,9 +742,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++)
|
||||
@ -754,6 +753,7 @@ void CBooleanOperations::TraceBoolean()
|
||||
{
|
||||
Locations.erase(Locations.begin() + i);
|
||||
length--;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
@ -770,31 +770,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();
|
||||
}
|
||||
|
||||
@ -946,26 +924,8 @@ void CBooleanOperations::TraceAllOverlap()
|
||||
|
||||
if (Op == Intersection)
|
||||
{
|
||||
if (count1 % 2 == 0 && count2 % 2 == 0)
|
||||
{
|
||||
Result.StartFigure();
|
||||
bool start = true;
|
||||
for (size_t i = 0; i < Locations.size() / 2; i += 2)
|
||||
{
|
||||
if (start && !(Locations[i]->C.Segment1.Id == Locations[i + 1]->C.Segment1.Id &&
|
||||
abs(Locations[i]->C.Segment1.Index - Locations[i + 1]->C.Segment1.Index) == 1))
|
||||
Result.MoveTo(Locations[i]->S.P.X, Locations[i]->S.P.Y);
|
||||
else
|
||||
Result.LineTo(Locations[i]->S.P.X, Locations[i]->S.P.Y);
|
||||
|
||||
Result.LineTo(Locations[i + 1]->S.P.X, Locations[i + 1]->S.P.Y);
|
||||
}
|
||||
Result.CloseFigure();
|
||||
}
|
||||
else if (count1 % 2 == 0)
|
||||
Result = std::move(Path2);
|
||||
else
|
||||
Result = std::move(Path1);
|
||||
SetWinding();
|
||||
TracePaths();
|
||||
}
|
||||
else if (Op == Union)
|
||||
{
|
||||
@ -1133,7 +1093,7 @@ void CBooleanOperations::PreparePath(const CGraphicsPath& path, int id,
|
||||
curves.push_back(Curve(segments[i], 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)
|
||||
{
|
||||
@ -1141,6 +1101,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;
|
||||
}
|
||||
@ -1164,6 +1125,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;
|
||||
}
|
||||
@ -1278,7 +1240,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());
|
||||
@ -1691,31 +1654,59 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CBooleanOperations::DivideLocations()
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -31,13 +31,14 @@
|
||||
*/
|
||||
#include "GraphicsPath_private.h"
|
||||
#include "agg_bounding_rect.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
// GraphicsPath
|
||||
CGraphicsPath::CGraphicsPath() : ISimpleGraphicsPath()
|
||||
{
|
||||
m_internal = new CGraphicsPath_private();
|
||||
m_internal = new CGraphicsPath_private();
|
||||
}
|
||||
|
||||
CGraphicsPath::CGraphicsPath(const CGraphicsPath& other) noexcept
|
||||
@ -75,58 +76,58 @@ namespace Aggplus
|
||||
j += 2;
|
||||
}
|
||||
}
|
||||
CloseFigure();
|
||||
if (p.Is_poly_closed()) CloseFigure();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CGraphicsPath::~CGraphicsPath()
|
||||
{
|
||||
RELEASEOBJECT(m_internal);
|
||||
RELEASEOBJECT(m_internal);
|
||||
}
|
||||
|
||||
CGraphicsPath* CGraphicsPath::Clone()
|
||||
{
|
||||
CGraphicsPath* pNew = new CGraphicsPath();
|
||||
pNew->m_internal->m_agg_ps = m_internal->m_agg_ps;
|
||||
pNew->m_internal->m_bEvenOdd = m_internal->m_bEvenOdd;
|
||||
pNew->m_internal->m_bIsMoveTo = m_internal->m_bIsMoveTo;
|
||||
pNew->m_internal->m_agg_ps = m_internal->m_agg_ps;
|
||||
pNew->m_internal->m_bEvenOdd = m_internal->m_bEvenOdd;
|
||||
pNew->m_internal->m_bIsMoveTo = m_internal->m_bIsMoveTo;
|
||||
return pNew;
|
||||
}
|
||||
|
||||
Status CGraphicsPath::Reset()
|
||||
{
|
||||
m_internal->m_agg_ps.remove_all();
|
||||
m_internal->m_bIsMoveTo = false;
|
||||
m_internal->m_agg_ps.remove_all();
|
||||
m_internal->m_bIsMoveTo = false;
|
||||
return Ok;
|
||||
}
|
||||
|
||||
void CGraphicsPath::SetRuler(bool bEvenOdd)
|
||||
{
|
||||
m_internal->m_bEvenOdd = bEvenOdd;
|
||||
m_internal->m_bEvenOdd = bEvenOdd;
|
||||
}
|
||||
|
||||
Status CGraphicsPath::StartFigure()
|
||||
{
|
||||
m_internal->m_agg_ps.start_new_path();
|
||||
return Ok;
|
||||
Status CGraphicsPath::StartFigure()
|
||||
{
|
||||
m_internal->m_agg_ps.start_new_path();
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CGraphicsPath::CloseFigure()
|
||||
{
|
||||
m_internal->m_agg_ps.close_polygon();
|
||||
return Ok;
|
||||
Status CGraphicsPath::CloseFigure()
|
||||
{
|
||||
m_internal->m_agg_ps.close_polygon();
|
||||
return Ok;
|
||||
}
|
||||
|
||||
bool CGraphicsPath::Is_poly_closed() const
|
||||
{
|
||||
if (!m_internal->m_agg_ps.total_vertices())
|
||||
if (!m_internal->m_agg_ps.total_vertices())
|
||||
return true;
|
||||
|
||||
double x, y;
|
||||
unsigned int nTip = m_internal->m_agg_ps.last_vertex(&x, &y);
|
||||
|
||||
if (nTip & agg::path_flags_close)
|
||||
unsigned int nTip = m_internal->m_agg_ps.last_vertex(&x, &y);
|
||||
|
||||
if (nTip & agg::path_flags_close)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@ -134,33 +135,33 @@ namespace Aggplus
|
||||
|
||||
Status CGraphicsPath::MoveTo(double x, double y)
|
||||
{
|
||||
m_internal->m_bIsMoveTo = true;
|
||||
m_internal->m_agg_ps.move_to(x, y);
|
||||
m_internal->m_bIsMoveTo = true;
|
||||
m_internal->m_agg_ps.move_to(x, y);
|
||||
return Ok;
|
||||
}
|
||||
Status CGraphicsPath::LineTo(double x, double y)
|
||||
{
|
||||
m_internal->m_agg_ps.line_to(x, y);
|
||||
m_internal->m_agg_ps.line_to(x, y);
|
||||
return Ok;
|
||||
}
|
||||
Status CGraphicsPath::CurveTo(double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
{
|
||||
m_internal->m_agg_ps.curve4(x1, y1, x2, y2, x3, y3);
|
||||
m_internal->m_agg_ps.curve4(x1, y1, x2, y2, x3, y3);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CGraphicsPath::AddLine(double x1, double y1, double x2, double y2)
|
||||
{
|
||||
if (Is_poly_closed())
|
||||
if (Is_poly_closed())
|
||||
{
|
||||
m_internal->m_agg_ps.move_to(x1, y1);
|
||||
m_internal->m_agg_ps.move_to(x1, y1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_ps.line_to(x1, y1);
|
||||
m_internal->m_agg_ps.line_to(x1, y1);
|
||||
}
|
||||
|
||||
m_internal->m_agg_ps.line_to(x2, y2);
|
||||
m_internal->m_agg_ps.line_to(x2, y2);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
@ -172,7 +173,7 @@ namespace Aggplus
|
||||
}
|
||||
int nRet = 0;
|
||||
|
||||
if (!m_internal->m_bIsMoveTo)
|
||||
if (!m_internal->m_bIsMoveTo)
|
||||
{
|
||||
MoveTo(pPoints[0], pPoints[1]);
|
||||
}
|
||||
@ -191,19 +192,19 @@ namespace Aggplus
|
||||
for (int i = 1; i <= n; ++i)
|
||||
{
|
||||
const double* points = &pPoints[i * 2];
|
||||
m_internal->m_agg_ps.line_to(points[0], points[1]);
|
||||
m_internal->m_agg_ps.line_to(points[0], points[1]);
|
||||
}
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CGraphicsPath::AddBezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
|
||||
{
|
||||
if (Is_poly_closed())
|
||||
m_internal->m_agg_ps.move_to(x1, y1);
|
||||
else
|
||||
m_internal->m_agg_ps.line_to(x1, y1);
|
||||
if (Is_poly_closed())
|
||||
m_internal->m_agg_ps.move_to(x1, y1);
|
||||
else
|
||||
m_internal->m_agg_ps.line_to(x1, y1);
|
||||
|
||||
m_internal->m_agg_ps.curve4(x2, y2, x3, y3, x4, y4);
|
||||
m_internal->m_agg_ps.curve4(x2, y2, x3, y3, x4, y4);
|
||||
return Ok;
|
||||
}
|
||||
Status CGraphicsPath::AddBeziers(double* pPoints, int nCount)
|
||||
@ -211,7 +212,7 @@ namespace Aggplus
|
||||
if (8 > nCount)
|
||||
return InvalidParameter;
|
||||
|
||||
if (!m_internal->m_bIsMoveTo)
|
||||
if (!m_internal->m_bIsMoveTo)
|
||||
{
|
||||
MoveTo(pPoints[0], pPoints[1]);
|
||||
}
|
||||
@ -223,13 +224,13 @@ namespace Aggplus
|
||||
curve.approximation_scale(25.0);
|
||||
curve.init(points[0], points[1], points[2], points[3], points[4], points[5], points[6], points[7]);
|
||||
|
||||
if (Is_poly_closed())
|
||||
if (Is_poly_closed())
|
||||
{
|
||||
m_internal->m_agg_ps.concat_path(curve, 0);
|
||||
m_internal->m_agg_ps.concat_path(curve, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_ps.join_path(curve, 0);
|
||||
m_internal->m_agg_ps.join_path(curve, 0);
|
||||
}
|
||||
|
||||
int nCountTo = (nCount - 8) / 6;
|
||||
@ -252,16 +253,16 @@ namespace Aggplus
|
||||
{
|
||||
agg::bezier_arc arc(x+width/2.0, y+height/2.0, width/2.0, height/2.0, 0.0, agg::pi2);
|
||||
//2.3 m_agg_ps.add_path(arc, 0, true);
|
||||
m_internal->m_agg_ps.join_path(arc, 0);
|
||||
m_internal->m_agg_ps.join_path(arc, 0);
|
||||
return Ok;
|
||||
}
|
||||
Status CGraphicsPath::AddRectangle(double x, double y, double width, double height)
|
||||
{
|
||||
m_internal->m_agg_ps.move_to(x, y);
|
||||
m_internal->m_agg_ps.line_to(x + width, y);
|
||||
m_internal->m_agg_ps.line_to(x + width, y + height);
|
||||
m_internal->m_agg_ps.line_to(x, y + height);
|
||||
m_internal->m_agg_ps.close_polygon();
|
||||
m_internal->m_agg_ps.move_to(x, y);
|
||||
m_internal->m_agg_ps.line_to(x + width, y);
|
||||
m_internal->m_agg_ps.line_to(x + width, y + height);
|
||||
m_internal->m_agg_ps.line_to(x, y + height);
|
||||
m_internal->m_agg_ps.close_polygon();
|
||||
return Ok;
|
||||
}
|
||||
Status CGraphicsPath::AddPolygon(double* pPoints, int nCount)
|
||||
@ -272,13 +273,13 @@ namespace Aggplus
|
||||
}
|
||||
int nRet = 0;
|
||||
|
||||
if (Is_poly_closed())
|
||||
if (Is_poly_closed())
|
||||
{
|
||||
m_internal->m_agg_ps.move_to(pPoints[0], pPoints[1]);
|
||||
m_internal->m_agg_ps.move_to(pPoints[0], pPoints[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_ps.line_to(pPoints[0], pPoints[1]);
|
||||
m_internal->m_agg_ps.line_to(pPoints[0], pPoints[1]);
|
||||
}
|
||||
|
||||
int n = (nCount / 2) - 1;
|
||||
@ -286,20 +287,20 @@ namespace Aggplus
|
||||
for (int i = 1; i < n; ++i)
|
||||
{
|
||||
double* points = &pPoints[i * 2];
|
||||
m_internal->m_agg_ps.line_to(points[0], points[1]);
|
||||
m_internal->m_agg_ps.line_to(points[0], points[1]);
|
||||
}
|
||||
|
||||
m_internal->m_agg_ps.close_polygon();
|
||||
m_internal->m_agg_ps.close_polygon();
|
||||
return Ok;
|
||||
}
|
||||
Status CGraphicsPath::AddPath(const CGraphicsPath& oPath)
|
||||
{
|
||||
typedef agg::conv_curve<agg::path_storage> conv_crv_type;
|
||||
|
||||
agg::path_storage p_copy(oPath.m_internal->m_agg_ps);
|
||||
agg::path_storage p_copy(oPath.m_internal->m_agg_ps);
|
||||
conv_crv_type p3(p_copy);
|
||||
|
||||
m_internal->m_agg_ps.join_path(p3, 0);
|
||||
m_internal->m_agg_ps.join_path(p3, 0);
|
||||
return Ok;
|
||||
}
|
||||
Status CGraphicsPath::AddArc(double x, double y, double width, double height, double startAngle, double sweepAngle)
|
||||
@ -315,11 +316,11 @@ namespace Aggplus
|
||||
|
||||
if (Is_poly_closed())
|
||||
{
|
||||
m_internal->m_agg_ps.concat_path(arc, 0);
|
||||
m_internal->m_agg_ps.concat_path(arc, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_ps.join_path(arc, 0);
|
||||
m_internal->m_agg_ps.join_path(arc, 0);
|
||||
}
|
||||
|
||||
return Ok;
|
||||
@ -328,13 +329,13 @@ namespace Aggplus
|
||||
ULONG CGraphicsPath::GetPointCount() const
|
||||
{
|
||||
ULONG nPointCount=0;
|
||||
ULONG nTotal = m_internal->m_agg_ps.total_vertices();
|
||||
ULONG nTotal = m_internal->m_agg_ps.total_vertices();
|
||||
|
||||
double x, y;
|
||||
|
||||
for(ULONG i = 0; i < nTotal; ++i)
|
||||
{
|
||||
ULONG nTip = m_internal->m_agg_ps.vertex(i, &x, &y);
|
||||
ULONG nTip = m_internal->m_agg_ps.vertex(i, &x, &y);
|
||||
if(nTip)
|
||||
{
|
||||
if (!(nTip & agg::path_flags_close))
|
||||
@ -348,13 +349,13 @@ namespace Aggplus
|
||||
|
||||
Status CGraphicsPath::GetPathPoints(PointF* points, int count) const
|
||||
{
|
||||
int nTotal = m_internal->m_agg_ps.total_vertices();
|
||||
int nTotal = m_internal->m_agg_ps.total_vertices();
|
||||
double x, y;
|
||||
int i = 0, k = 0;
|
||||
|
||||
while (k < count && i < nTotal)
|
||||
{
|
||||
unsigned int nTip = m_internal->m_agg_ps.vertex(i, &x, &y);
|
||||
unsigned int nTip = m_internal->m_agg_ps.vertex(i, &x, &y);
|
||||
if (nTip)
|
||||
{
|
||||
if(!(nTip & agg::path_flags_close))
|
||||
@ -372,19 +373,19 @@ namespace Aggplus
|
||||
|
||||
Status CGraphicsPath::GetLastPoint(double& x, double& y)
|
||||
{
|
||||
m_internal->m_agg_ps.last_vertex(&x, &y);
|
||||
m_internal->m_agg_ps.last_vertex(&x, &y);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CGraphicsPath::GetPathPoints(double* points, int count) const
|
||||
{
|
||||
int nTotal = m_internal->m_agg_ps.total_vertices();
|
||||
int nTotal = m_internal->m_agg_ps.total_vertices();
|
||||
double x, y;
|
||||
int i = 0, k = 0;
|
||||
|
||||
while (k < count && i < nTotal)
|
||||
{
|
||||
unsigned int nTip = m_internal->m_agg_ps.vertex(i, &x, &y);
|
||||
unsigned int nTip = m_internal->m_agg_ps.vertex(i, &x, &y);
|
||||
if (nTip)
|
||||
{
|
||||
if(!(nTip & agg::path_flags_close))
|
||||
@ -402,14 +403,14 @@ namespace Aggplus
|
||||
|
||||
void CGraphicsPath::GetBounds(double& left, double& top, double& width, double& height) const
|
||||
{
|
||||
unsigned int nTotal = m_internal->m_agg_ps.total_vertices();
|
||||
unsigned int nTotal = m_internal->m_agg_ps.total_vertices();
|
||||
if (nTotal)
|
||||
{
|
||||
agg::rect_d bounds(1e100, 1e100, -1e100, -1e100);
|
||||
double x, y;
|
||||
for(unsigned int i = 0; i < nTotal; i++)
|
||||
{
|
||||
unsigned int nTip = m_internal->m_agg_ps.vertex(i, &x, &y);
|
||||
unsigned int nTip = m_internal->m_agg_ps.vertex(i, &x, &y);
|
||||
if(agg::is_vertex(nTip))
|
||||
{
|
||||
if(x < bounds.x1) bounds.x1 = x;
|
||||
@ -452,38 +453,38 @@ namespace Aggplus
|
||||
{
|
||||
if (NULL != matrix)
|
||||
{
|
||||
agg::path_storage p2(m_internal->m_agg_ps);
|
||||
agg::conv_transform<agg::path_storage> trans(p2, matrix->m_internal->m_agg_mtx);
|
||||
m_internal->m_agg_ps.remove_all();
|
||||
agg::path_storage p2(m_internal->m_agg_ps);
|
||||
agg::conv_transform<agg::path_storage> trans(p2, matrix->m_internal->m_agg_mtx);
|
||||
m_internal->m_agg_ps.remove_all();
|
||||
//2.3 m_agg_ps.add_path(trans, 0, false);
|
||||
m_internal->m_agg_ps.concat_path(trans, 0);
|
||||
m_internal->m_agg_ps.concat_path(trans, 0);
|
||||
}
|
||||
return Ok;
|
||||
}
|
||||
|
||||
bool CGraphicsPath::_MoveTo(double x, double y)
|
||||
{
|
||||
if (NULL != m_internal->m_pTransform)
|
||||
if (NULL != m_internal->m_pTransform)
|
||||
{
|
||||
m_internal->m_pTransform->TransformPoint(x, y);
|
||||
m_internal->m_pTransform->TransformPoint(x, y);
|
||||
}
|
||||
return (Ok == MoveTo(x, y));
|
||||
}
|
||||
bool CGraphicsPath::_LineTo(double x, double y)
|
||||
{
|
||||
if (NULL != m_internal->m_pTransform)
|
||||
if (NULL != m_internal->m_pTransform)
|
||||
{
|
||||
m_internal->m_pTransform->TransformPoint(x, y);
|
||||
m_internal->m_pTransform->TransformPoint(x, y);
|
||||
}
|
||||
return (Ok == LineTo(x, y));
|
||||
}
|
||||
bool CGraphicsPath::_CurveTo(double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
{
|
||||
if (NULL != m_internal->m_pTransform)
|
||||
if (NULL != m_internal->m_pTransform)
|
||||
{
|
||||
m_internal->m_pTransform->TransformPoint(x1, y1);
|
||||
m_internal->m_pTransform->TransformPoint(x2, y2);
|
||||
m_internal->m_pTransform->TransformPoint(x3, y3);
|
||||
m_internal->m_pTransform->TransformPoint(x1, y1);
|
||||
m_internal->m_pTransform->TransformPoint(x2, y2);
|
||||
m_internal->m_pTransform->TransformPoint(x3, y3);
|
||||
}
|
||||
return (Ok == CurveTo(x1, y1, x2, y2, x3, y3));
|
||||
}
|
||||
@ -492,26 +493,26 @@ namespace Aggplus
|
||||
return (Ok == CloseFigure());
|
||||
}
|
||||
|
||||
Status CGraphicsPath::AddString(const std::wstring& strText, NSFonts::IFontManager* pFont, double x, double y)
|
||||
Status CGraphicsPath::AddString(const std::wstring& strText, NSFonts::IFontManager* pFont, double x, double y)
|
||||
{
|
||||
if (NULL == pFont)
|
||||
return InvalidParameter;
|
||||
|
||||
|
||||
pFont->SetTextMatrix(1, 0, 0, 1, 0, 0);
|
||||
pFont->LoadString1(strText, (float)x, (float)y);
|
||||
return (TRUE == pFont->GetStringPath(this)) ? Ok : InvalidParameter;
|
||||
}
|
||||
Status CGraphicsPath::AddString(const unsigned int* pGids, const unsigned int nGidsCount, NSFonts::IFontManager* pFont, double x, double y)
|
||||
{
|
||||
if (NULL == pFont)
|
||||
return InvalidParameter;
|
||||
Status CGraphicsPath::AddString(const unsigned int* pGids, const unsigned int nGidsCount, NSFonts::IFontManager* pFont, double x, double y)
|
||||
{
|
||||
if (NULL == pFont)
|
||||
return InvalidParameter;
|
||||
|
||||
pFont->SetTextMatrix(1, 0, 0, 1, 0, 0);
|
||||
pFont->LoadString1(pGids, nGidsCount, (float)x, (float)y);
|
||||
return (TRUE == pFont->GetStringPath(this)) ? Ok : InvalidParameter;
|
||||
}
|
||||
pFont->LoadString1(pGids, nGidsCount, (float)x, (float)y);
|
||||
return (TRUE == pFont->GetStringPath(this)) ? Ok : InvalidParameter;
|
||||
}
|
||||
|
||||
Status CGraphicsPath::AddStringC(const LONG& lText, NSFonts::IFontManager* pFont, double x, double y)
|
||||
Status CGraphicsPath::AddStringC(const LONG& lText, NSFonts::IFontManager* pFont, double x, double y)
|
||||
{
|
||||
if (NULL == pFont)
|
||||
return InvalidParameter;
|
||||
@ -522,45 +523,45 @@ namespace Aggplus
|
||||
return (TRUE == pFont->GetStringPath(this)) ? Ok : InvalidParameter;
|
||||
}
|
||||
|
||||
void CGraphicsPath::z_Stroke(const double& size)
|
||||
void CGraphicsPath::z_Stroke(const double& size)
|
||||
{
|
||||
typedef agg::conv_stroke<agg::path_storage> Path_Conv_Stroke;
|
||||
Path_Conv_Stroke pg(m_internal->m_agg_ps);
|
||||
Path_Conv_Stroke pg(m_internal->m_agg_ps);
|
||||
pg.line_join(agg::round_join);
|
||||
pg.line_cap(agg::round_cap);
|
||||
pg.approximation_scale(25.00);
|
||||
//pg.miter_limit(0.50);
|
||||
|
||||
pg.width(size);
|
||||
pg.width(size);
|
||||
//pg.auto_detect_orientation(true);
|
||||
|
||||
agg::path_storage psNew;
|
||||
//2.3 psNew.add_path(pg, 0, false);
|
||||
psNew.concat_path(pg, 0);
|
||||
|
||||
m_internal->m_agg_ps = psNew;
|
||||
m_internal->m_agg_ps = psNew;
|
||||
}
|
||||
|
||||
void CGraphicsPath::Widen(const double& size, const Aggplus::LineJoin& join, const CMatrix* matrix, float flatness)
|
||||
void CGraphicsPath::Widen(const double& size, const Aggplus::LineJoin& join, const CMatrix* matrix, float flatness)
|
||||
{
|
||||
if (NULL == matrix || 0.0f == flatness)
|
||||
if (NULL == matrix || 0.0f == flatness)
|
||||
return;
|
||||
|
||||
typedef agg::conv_curve<agg::path_storage> conv_crv_type;
|
||||
|
||||
typedef agg::conv_contour<conv_crv_type> Path_Conv_Contour;
|
||||
|
||||
conv_crv_type crv(m_internal->m_agg_ps);
|
||||
conv_crv_type crv(m_internal->m_agg_ps);
|
||||
Path_Conv_Contour pg(crv);
|
||||
|
||||
pg.miter_limit(0.50);
|
||||
//pg.miter_limit_theta(0.05);
|
||||
//pg.approximation_scale(2.00);
|
||||
|
||||
pg.width(size);
|
||||
pg.width(size);
|
||||
|
||||
agg::line_join_e LineJoin;
|
||||
switch (join)
|
||||
switch (join)
|
||||
{
|
||||
case LineJoinMiter : LineJoin=agg::miter_join; break;
|
||||
case LineJoinBevel : LineJoin=agg::bevel_join; break;
|
||||
@ -575,8 +576,8 @@ namespace Aggplus
|
||||
agg::path_storage psNew;
|
||||
//2.3 psNew.add_path(pg, 0, false);
|
||||
//m_agg_ps.concat_path(pg, 0);
|
||||
m_internal->m_agg_ps.concat_path(pg, 0);
|
||||
m_internal->m_agg_ps = psNew;
|
||||
m_internal->m_agg_ps.concat_path(pg, 0);
|
||||
m_internal->m_agg_ps = psNew;
|
||||
}
|
||||
|
||||
int CGraphicsPath::EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection)
|
||||
@ -637,8 +638,8 @@ namespace Aggplus
|
||||
// Выясним в каких четвертях находятся начальная и конечная точки
|
||||
unsigned int nFirstPointQuard = int(fAngle1) / 90 + 1;
|
||||
unsigned int nSecondPointQuard = int(fAngle2) / 90 + 1;
|
||||
nSecondPointQuard = std::min( 4, std::max( 1, (int)nSecondPointQuard ) );
|
||||
nFirstPointQuard = std::min( 4, std::max( 1, (int)nFirstPointQuard ) );
|
||||
nSecondPointQuard = std::min( 4, std::max( 1, (int)nSecondPointQuard ) );
|
||||
nFirstPointQuard = std::min( 4, std::max( 1, (int)nFirstPointQuard ) );
|
||||
// Проведем линию в начальную точку дуги
|
||||
double fStartX = 0.0, fStartY = 0.0, fEndX = 0.0, fEndY = 0.0;
|
||||
|
||||
@ -774,14 +775,14 @@ namespace Aggplus
|
||||
return Ok;
|
||||
}
|
||||
|
||||
bool CGraphicsPath::IsPointInPath(const double& x, const double& y)
|
||||
{
|
||||
agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip_dbl> rasterizer;
|
||||
agg::conv_curve<agg::path_storage> c_c_path(m_internal->m_agg_ps);
|
||||
rasterizer.add_path(c_c_path);
|
||||
bool CGraphicsPath::IsPointInPath(const double& x, const double& y)
|
||||
{
|
||||
agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip_dbl> rasterizer;
|
||||
agg::conv_curve<agg::path_storage> c_c_path(m_internal->m_agg_ps);
|
||||
rasterizer.add_path(c_c_path);
|
||||
|
||||
return rasterizer.hit_test((int)x, (int)y);
|
||||
}
|
||||
return rasterizer.hit_test((int)x, (int)y);
|
||||
}
|
||||
|
||||
unsigned CGraphicsPath::GetCloseCount() const noexcept
|
||||
{
|
||||
@ -850,7 +851,8 @@ namespace Aggplus
|
||||
double CGraphicsPath::GetArea() const noexcept
|
||||
{
|
||||
double area = 0.0;
|
||||
for (unsigned i = 0; i < GetPointCount() - 1; i++)
|
||||
unsigned length = GetPointCount() - 1;
|
||||
for (unsigned i = 0; i < length; i++)
|
||||
{
|
||||
area += GetArea(i, IsCurvePoint(i + 1));
|
||||
if (IsCurvePoint(i + 1)) i += 2;
|
||||
@ -991,13 +993,13 @@ namespace Aggplus
|
||||
CGraphicsPathSimpleConverter::CGraphicsPathSimpleConverter()
|
||||
{
|
||||
m_pRenderer = NULL;
|
||||
m_internal = new CGraphicsPathSimpleConverter_private();
|
||||
m_internal = new CGraphicsPathSimpleConverter_private();
|
||||
}
|
||||
|
||||
CGraphicsPathSimpleConverter::~CGraphicsPathSimpleConverter()
|
||||
{
|
||||
RELEASEINTERFACE(m_pRenderer);
|
||||
RELEASEOBJECT(m_internal);
|
||||
RELEASEOBJECT(m_internal);
|
||||
}
|
||||
|
||||
void CGraphicsPathSimpleConverter::SetRenderer(IRenderer* pRenderer)
|
||||
@ -1043,7 +1045,7 @@ namespace Aggplus
|
||||
|
||||
int nRet = 0;
|
||||
|
||||
if (!m_internal->m_bIsMoveTo)
|
||||
if (!m_internal->m_bIsMoveTo)
|
||||
{
|
||||
_MoveTo(pData[0], pData[1]);
|
||||
}
|
||||
@ -1071,7 +1073,7 @@ namespace Aggplus
|
||||
if (8 > lCount)
|
||||
return false;
|
||||
|
||||
if (!m_internal->m_bIsMoveTo)
|
||||
if (!m_internal->m_bIsMoveTo)
|
||||
{
|
||||
_MoveTo(pData[0], pData[1]);
|
||||
|
||||
@ -1116,14 +1118,14 @@ namespace Aggplus
|
||||
}
|
||||
bool CGraphicsPathSimpleConverter::PathCommandGetCurrentPoint(double* fX, double* fY)
|
||||
{
|
||||
m_internal->m_agg_ps.last_vertex(fX, fY);
|
||||
m_internal->m_agg_ps.last_vertex(fX, fY);
|
||||
return true;
|
||||
}
|
||||
bool CGraphicsPathSimpleConverter::PathCommandText(const std::wstring& bsText, NSFonts::IFontManager* pManager, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset)
|
||||
bool CGraphicsPathSimpleConverter::PathCommandText(const std::wstring& bsText, NSFonts::IFontManager* pManager, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset)
|
||||
{
|
||||
return AddString(bsText, pManager, fX, fY + fBaseLineOffset);
|
||||
}
|
||||
bool CGraphicsPathSimpleConverter::PathCommandTextEx(std::wstring& bsText, std::wstring& bsGidText, NSFonts::IFontManager* pManager, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset, DWORD lFlags)
|
||||
bool CGraphicsPathSimpleConverter::PathCommandTextEx(std::wstring& bsText, std::wstring& bsGidText, NSFonts::IFontManager* pManager, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset, DWORD lFlags)
|
||||
{
|
||||
if (!bsGidText.empty())
|
||||
{
|
||||
@ -1133,49 +1135,49 @@ namespace Aggplus
|
||||
return PathCommandText(bsText, pManager, fX, fY, fWidth, fHeight, fBaseLineOffset);
|
||||
}
|
||||
|
||||
bool CGraphicsPathSimpleConverter::PathCommandText2(const int* pUnicodes, const int* pGids, const int& nCount, NSFonts::IFontManager* pManager,
|
||||
const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
if (NULL == pGids)
|
||||
{
|
||||
pManager->SetStringGID(FALSE);
|
||||
pManager->LoadString1((const unsigned int*)pUnicodes, (unsigned int)nCount, (float)x, (float)y);
|
||||
return (TRUE == pManager->GetStringPath(this)) ? true : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
pManager->SetStringGID(TRUE);
|
||||
pManager->LoadString1((const unsigned int*)pGids, (unsigned int)nCount, (float)x, (float)y);
|
||||
return (TRUE == pManager->GetStringPath(this)) ? true : false;
|
||||
}
|
||||
}
|
||||
bool CGraphicsPathSimpleConverter::PathCommandText2(const std::wstring& sUnicodes, const int* pGids, const int& nCount, NSFonts::IFontManager* pManager,
|
||||
const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
if (NULL == pGids)
|
||||
{
|
||||
pManager->SetStringGID(FALSE);
|
||||
pManager->LoadString1(sUnicodes, (float)x, (float)y);
|
||||
return (TRUE == pManager->GetStringPath(this)) ? true : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
pManager->SetStringGID(TRUE);
|
||||
pManager->LoadString1((const unsigned int*)pGids, (unsigned int)nCount, (float)x, (float)y);
|
||||
return (TRUE == pManager->GetStringPath(this)) ? true : false;
|
||||
}
|
||||
}
|
||||
bool CGraphicsPathSimpleConverter::PathCommandText2(const int* pUnicodes, const int* pGids, const int& nCount, NSFonts::IFontManager* pManager,
|
||||
const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
if (NULL == pGids)
|
||||
{
|
||||
pManager->SetStringGID(FALSE);
|
||||
pManager->LoadString1((const unsigned int*)pUnicodes, (unsigned int)nCount, (float)x, (float)y);
|
||||
return (TRUE == pManager->GetStringPath(this)) ? true : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
pManager->SetStringGID(TRUE);
|
||||
pManager->LoadString1((const unsigned int*)pGids, (unsigned int)nCount, (float)x, (float)y);
|
||||
return (TRUE == pManager->GetStringPath(this)) ? true : false;
|
||||
}
|
||||
}
|
||||
bool CGraphicsPathSimpleConverter::PathCommandText2(const std::wstring& sUnicodes, const int* pGids, const int& nCount, NSFonts::IFontManager* pManager,
|
||||
const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
if (NULL == pGids)
|
||||
{
|
||||
pManager->SetStringGID(FALSE);
|
||||
pManager->LoadString1(sUnicodes, (float)x, (float)y);
|
||||
return (TRUE == pManager->GetStringPath(this)) ? true : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
pManager->SetStringGID(TRUE);
|
||||
pManager->LoadString1((const unsigned int*)pGids, (unsigned int)nCount, (float)x, (float)y);
|
||||
return (TRUE == pManager->GetStringPath(this)) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CGraphicsPathSimpleConverter::PathCommandGetBounds(double& left, double& top, double& width, double &height)
|
||||
{
|
||||
unsigned int nTotal = m_internal->m_agg_ps.total_vertices();
|
||||
unsigned int nTotal = m_internal->m_agg_ps.total_vertices();
|
||||
if (nTotal)
|
||||
{
|
||||
agg::rect_d bounds(1e100, 1e100, -1e100, -1e100);
|
||||
double x, y;
|
||||
for(unsigned int i = 0; i < nTotal; i++)
|
||||
{
|
||||
unsigned int nTip = m_internal->m_agg_ps.vertex(i, &x, &y);
|
||||
unsigned int nTip = m_internal->m_agg_ps.vertex(i, &x, &y);
|
||||
if(agg::is_vertex(nTip))
|
||||
{
|
||||
if(x < bounds.x1) bounds.x1 = x;
|
||||
@ -1202,8 +1204,8 @@ namespace Aggplus
|
||||
|
||||
bool CGraphicsPathSimpleConverter::_MoveTo(double x, double y)
|
||||
{
|
||||
m_internal->m_bIsMoveTo = true;
|
||||
m_internal->m_agg_ps.move_to(x, y);
|
||||
m_internal->m_bIsMoveTo = true;
|
||||
m_internal->m_agg_ps.move_to(x, y);
|
||||
|
||||
if (NULL != m_pRenderer)
|
||||
{
|
||||
@ -1215,12 +1217,12 @@ namespace Aggplus
|
||||
}
|
||||
bool CGraphicsPathSimpleConverter::_LineTo(double x, double y)
|
||||
{
|
||||
if (!m_internal->m_bIsMoveTo)
|
||||
if (!m_internal->m_bIsMoveTo)
|
||||
{
|
||||
_MoveTo(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
m_internal->m_agg_ps.line_to(x, y);
|
||||
m_internal->m_agg_ps.line_to(x, y);
|
||||
|
||||
if (NULL != m_pRenderer)
|
||||
{
|
||||
@ -1233,12 +1235,12 @@ namespace Aggplus
|
||||
}
|
||||
bool CGraphicsPathSimpleConverter::_CurveTo(double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
{
|
||||
if (!m_internal->m_bIsMoveTo)
|
||||
if (!m_internal->m_bIsMoveTo)
|
||||
{
|
||||
_MoveTo(x1, y1);
|
||||
}
|
||||
|
||||
m_internal->m_agg_ps.curve4(x1, y1, x2, y2, x3, y3);
|
||||
m_internal->m_agg_ps.curve4(x1, y1, x2, y2, x3, y3);
|
||||
|
||||
if (NULL != m_pRenderer)
|
||||
{
|
||||
@ -1251,8 +1253,8 @@ namespace Aggplus
|
||||
}
|
||||
bool CGraphicsPathSimpleConverter::_Close()
|
||||
{
|
||||
m_internal->m_bIsClosed = true;
|
||||
m_internal->m_agg_ps.close_polygon();
|
||||
m_internal->m_bIsClosed = true;
|
||||
m_internal->m_agg_ps.close_polygon();
|
||||
|
||||
if (NULL != m_pRenderer)
|
||||
{
|
||||
@ -1264,11 +1266,11 @@ namespace Aggplus
|
||||
}
|
||||
bool CGraphicsPathSimpleConverter::_Reset()
|
||||
{
|
||||
m_internal->m_bEvenOdd = false;
|
||||
m_internal->m_bIsMoveTo = false;
|
||||
m_internal->m_bIsClosed = false;
|
||||
m_internal->m_bEvenOdd = false;
|
||||
m_internal->m_bIsMoveTo = false;
|
||||
m_internal->m_bIsClosed = false;
|
||||
|
||||
m_internal->m_agg_ps.remove_all();
|
||||
m_internal->m_agg_ps.remove_all();
|
||||
|
||||
if (NULL != m_pRenderer)
|
||||
{
|
||||
@ -1281,7 +1283,7 @@ namespace Aggplus
|
||||
}
|
||||
bool CGraphicsPathSimpleConverter::_Start()
|
||||
{
|
||||
m_internal->m_agg_ps.start_new_path();
|
||||
m_internal->m_agg_ps.start_new_path();
|
||||
|
||||
if (NULL != m_pRenderer)
|
||||
{
|
||||
@ -1293,7 +1295,7 @@ namespace Aggplus
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGraphicsPathSimpleConverter::AddString(const std::wstring& bstrText, NSFonts::IFontManager* pFont, double x, double y)
|
||||
bool CGraphicsPathSimpleConverter::AddString(const std::wstring& bstrText, NSFonts::IFontManager* pFont, double x, double y)
|
||||
{
|
||||
if (NULL == pFont)
|
||||
return false;
|
||||
@ -1360,8 +1362,8 @@ namespace Aggplus
|
||||
// Выясним в каких четвертях находятся начальная и конечная точки
|
||||
unsigned int nFirstPointQuard = int(fAngle1) / 90 + 1;
|
||||
unsigned int nSecondPointQuard = int(fAngle2) / 90 + 1;
|
||||
nSecondPointQuard = std::min( 4, std::max( 1, (int)nSecondPointQuard ) );
|
||||
nFirstPointQuard = std::min( 4, std::max( 1, (int)nFirstPointQuard ) );
|
||||
nSecondPointQuard = std::min( 4, std::max( 1, (int)nSecondPointQuard ) );
|
||||
nFirstPointQuard = std::min( 4, std::max( 1, (int)nFirstPointQuard ) );
|
||||
// Проведем линию в начальную точку дуги
|
||||
double fStartX = 0.0, fStartY = 0.0, fEndX = 0.0, fEndY = 0.0;
|
||||
|
||||
@ -1499,15 +1501,15 @@ namespace Aggplus
|
||||
|
||||
bool CGraphicsPathSimpleConverter::Is_poly_closed()
|
||||
{
|
||||
if (!m_internal->m_agg_ps.total_vertices())
|
||||
if (!m_internal->m_agg_ps.total_vertices())
|
||||
return true;
|
||||
|
||||
double x, y;
|
||||
unsigned int nTip = m_internal->m_agg_ps.last_vertex(&x, &y);
|
||||
unsigned int nTip = m_internal->m_agg_ps.last_vertex(&x, &y);
|
||||
|
||||
if (nTip & agg::path_flags_close)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
constexpr double EPSILON = 1e-12;
|
||||
constexpr double POINT_EPSILON = 1e-2;
|
||||
constexpr double GEOMETRIC_EPSILON = 1e-7;
|
||||
constexpr double LOCATION_EPSILON = 1e-4;
|
||||
constexpr double LOCATION_EPSILON = 1e-7;
|
||||
constexpr double TIME_EPSILON = 1e-8;
|
||||
constexpr double MACHINE_EPSILON = 1.12e-16;
|
||||
constexpr double TRIGANOMETRIC_EPSILON = 1e-8;
|
||||
@ -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;
|
||||
@ -340,7 +340,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 +394,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 +420,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 +431,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())
|
||||
{
|
||||
|
||||
@ -414,6 +414,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 +467,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;
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -234,6 +234,7 @@ TEST(BooleanOperations, OverlapOutside)
|
||||
resultIntersect.StartFigure();
|
||||
resultIntersect.MoveTo(300.0, 300.0);
|
||||
resultIntersect.LineTo(300.0, 200.0);
|
||||
resultIntersect.LineTo(300.0, 300.0);
|
||||
resultIntersect.CloseFigure();
|
||||
|
||||
resultUnite.StartFigure();
|
||||
@ -283,11 +284,11 @@ TEST(BooleanOperations, OverlapInside)
|
||||
path2.CloseFigure();
|
||||
|
||||
resultIntersect.StartFigure();
|
||||
resultIntersect.MoveTo(200.0, 200.0);
|
||||
resultIntersect.MoveTo(400.0, 300.0);
|
||||
resultIntersect.LineTo(400.0, 200.0);
|
||||
resultIntersect.LineTo(400.0, 300.0);
|
||||
resultIntersect.LineTo(200.0, 300.0);
|
||||
resultIntersect.LineTo(200.0, 200.0);
|
||||
resultIntersect.LineTo(200.0, 300.0);
|
||||
resultIntersect.LineTo(400.0, 300.0);
|
||||
resultIntersect.CloseFigure();
|
||||
|
||||
resultUnite.StartFigure();
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1640,8 +1640,8 @@ namespace MetaFile
|
||||
|
||||
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));
|
||||
const unsigned int unWidth = std::min(((unsigned int)abs(oClipRect.Right - oClipRect.Left)), ((unsigned int)nWidth ));
|
||||
const unsigned int unHeight = std::min(((unsigned int)abs(oClipRect.Bottom - oClipRect.Top)), ((unsigned int)nHeight));
|
||||
|
||||
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);
|
||||
@ -1655,8 +1655,6 @@ namespace MetaFile
|
||||
|
||||
oParser.PlayFile();
|
||||
|
||||
const TXForm& oXForm{m_pDC->GetTransform()};
|
||||
|
||||
TRectD oRect;
|
||||
|
||||
oRect.Left = arPoints[0].X;
|
||||
@ -1671,9 +1669,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;
|
||||
@ -3210,8 +3206,6 @@ namespace MetaFile
|
||||
|
||||
m_oStream >> oMatrix;
|
||||
|
||||
UpdateMatrix(oMatrix);
|
||||
|
||||
m_pDC->MultiplyTransform(oMatrix, MWT_SET);
|
||||
UpdateOutputDC();
|
||||
}
|
||||
|
||||
@ -721,14 +721,14 @@ namespace MetaFile
|
||||
TEmfXForm oViewportXForm(GetPixelWidth() * dM11, 0, 0, GetPixelHeight() * dM22, oViewPort.lX, oViewPort.lY);
|
||||
|
||||
m_oFinalTransform.Init();
|
||||
m_oFinalTransform.Multiply(oViewportXForm, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform.Multiply(m_oTransform, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform.Multiply(oWindowXForm, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform.Multiply(m_oTransform, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform.Multiply(oViewportXForm, MWT_RIGHTMULTIPLY);
|
||||
|
||||
m_oFinalTransform2.Init();
|
||||
m_oFinalTransform2.Multiply(oViewportXForm, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform2.Multiply(m_oTransform, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform2.Multiply(oWindowXForm, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform2.Multiply(m_oTransform, MWT_RIGHTMULTIPLY);
|
||||
m_oFinalTransform2.Multiply(oViewportXForm, MWT_RIGHTMULTIPLY);
|
||||
}
|
||||
|
||||
void CEmfDC::FixIsotropic()
|
||||
|
||||
@ -734,6 +734,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)
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -45,6 +45,8 @@ namespace SVG
|
||||
if (NULL == pTSpan)
|
||||
return;
|
||||
|
||||
m_oStyles = pTSpan->m_oStyles;
|
||||
|
||||
if (m_oX.Empty())
|
||||
{
|
||||
if (!pTSpan->m_arObjects.empty())
|
||||
@ -157,18 +159,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;
|
||||
@ -318,7 +320,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;
|
||||
}
|
||||
|
||||
@ -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,9 +154,13 @@ 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);
|
||||
|
||||
// for drawingml is no tag behind-doc - so we need to reorder shapes
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.ReorderShapesForPptx();
|
||||
|
||||
std::vector<std::wstring> xml_shapes;
|
||||
for (const auto& shape : m_pInternal->m_oDocument.m_oCurrentPage.m_arShapes)
|
||||
{
|
||||
@ -213,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);
|
||||
|
||||
@ -969,8 +969,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;
|
||||
|
||||
@ -55,9 +55,7 @@ namespace NSDocxRenderer
|
||||
{
|
||||
m_lCurrentCommand = -1;
|
||||
|
||||
if (lType == c_nPathType)
|
||||
PathEnd();
|
||||
else if (lType == c_nResetClipType)
|
||||
if (lType == c_nResetClipType)
|
||||
{
|
||||
m_oCurrVectorGraphics.Clear();
|
||||
m_oClipVectorGraphics.Clear();
|
||||
@ -65,7 +63,7 @@ namespace NSDocxRenderer
|
||||
else if (lType == c_nClipType)
|
||||
{
|
||||
// closing clip path if non-closed
|
||||
if (m_oCurrVectorGraphics.GetData().back().type != CVectorGraphics::ePathCommandType::pctClose)
|
||||
if (!m_oCurrVectorGraphics.IsEmpty() && m_oCurrVectorGraphics.GetData().back().type != CVectorGraphics::ePathCommandType::pctClose)
|
||||
m_oCurrVectorGraphics.Add({CVectorGraphics::ePathCommandType::pctClose, {}});
|
||||
|
||||
if (!m_oClipVectorGraphics.IsEmpty())
|
||||
@ -182,6 +180,13 @@ namespace NSDocxRenderer
|
||||
// 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())
|
||||
{
|
||||
m_oClipVectorGraphics.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
double rotation = m_pTransform->z_Rotation();
|
||||
double left = m_oCurrVectorGraphics.GetLeft();
|
||||
double right = m_oCurrVectorGraphics.GetRight();
|
||||
@ -189,6 +194,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)
|
||||
{
|
||||
@ -232,6 +240,13 @@ namespace NSDocxRenderer
|
||||
m_oCurrVectorGraphics,
|
||||
m_oClipVectorGraphics,
|
||||
m_lClipMode);
|
||||
|
||||
if (new_vector_graphics.IsEmpty())
|
||||
{
|
||||
m_oCurrVectorGraphics.Clear();
|
||||
m_oClipVectorGraphics.Clear();
|
||||
return;
|
||||
}
|
||||
m_oCurrVectorGraphics = std::move(new_vector_graphics);
|
||||
}
|
||||
shape->SetVector(std::move(m_oCurrVectorGraphics));
|
||||
@ -239,8 +254,12 @@ 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;
|
||||
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;
|
||||
|
||||
@ -283,25 +302,24 @@ 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;
|
||||
@ -313,9 +331,7 @@ namespace NSDocxRenderer
|
||||
return;
|
||||
|
||||
shape->m_nOrder = ++m_nShapeOrder;
|
||||
shape->m_dRotation = rotation;
|
||||
m_arShapes.push_back(shape);
|
||||
|
||||
m_oClipVectorGraphics.Clear();
|
||||
}
|
||||
|
||||
@ -541,6 +557,20 @@ namespace NSDocxRenderer
|
||||
ToXml(oWriter);
|
||||
WriteSectionToFile(bIsLastPage, oWriter);
|
||||
}
|
||||
void CPage::ReorderShapesForPptx()
|
||||
{
|
||||
using shape_ptr_t = std::shared_ptr<CShape>;
|
||||
|
||||
// переместим nullptr в конец и удалим
|
||||
auto right = MoveNullptr(m_arShapes.begin(), m_arShapes.end());
|
||||
m_arShapes.erase(right, m_arShapes.end());
|
||||
|
||||
std::sort(m_arShapes.begin(), m_arShapes.end(), [] (const shape_ptr_t& s1, const shape_ptr_t& s2) {
|
||||
if (s1->m_bIsBehindDoc && !s2->m_bIsBehindDoc) return true;
|
||||
if (!s1->m_bIsBehindDoc && s2->m_bIsBehindDoc) return false;
|
||||
return s1->m_nOrder < s2->m_nOrder;
|
||||
});
|
||||
}
|
||||
|
||||
void CPage::BuildDiacriticalSymbols()
|
||||
{
|
||||
@ -899,10 +929,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())
|
||||
@ -1024,12 +1060,13 @@ namespace NSDocxRenderer
|
||||
{
|
||||
auto h_type = pCont->CBaseItem::GetHorizontalCrossingType(pShape.get());
|
||||
double dTopBorder = pCont->m_dTop + pCont->m_dHeight / 3;
|
||||
double dBotBorder = pCont->m_dBaselinePos - pCont->m_dHeight / 6;
|
||||
|
||||
bool bIf1 = pShape->m_eGraphicsType == eGraphicsType::gtRectangle &&
|
||||
pShape->m_eLineType != eLineType::ltUnknown;
|
||||
|
||||
// Условие пересечения по вертикали
|
||||
bool bIf2 = pShape->m_dTop > dTopBorder && pShape->m_dBaselinePos < pCont->m_dBaselinePos;
|
||||
bool bIf2 = pShape->m_dTop > dTopBorder && pShape->m_dBaselinePos < dBotBorder;
|
||||
|
||||
// Условие пересечения по горизонтали
|
||||
bool bIf3 = h_type != eHorizontalCrossingType::hctUnknown &&
|
||||
@ -1239,20 +1276,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();
|
||||
}
|
||||
@ -1528,19 +1554,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])
|
||||
{
|
||||
@ -1554,6 +1567,9 @@ namespace NSDocxRenderer
|
||||
|
||||
if (!no_crossing(h_type, v_type))
|
||||
{
|
||||
prev_line->CalcFirstWordWidth();
|
||||
curr_line->CalcFirstWordWidth();
|
||||
|
||||
for (auto& cont : prev_line->m_arConts)
|
||||
cont->CalcSelected();
|
||||
|
||||
@ -1968,6 +1984,7 @@ namespace NSDocxRenderer
|
||||
pParagraph->m_dWidth = pLine->m_dWidth + c_dERROR_OF_PARAGRAPH_BORDERS_MM;
|
||||
pParagraph->m_dHeight = pLine->m_dHeight;
|
||||
pParagraph->m_dRight = pLine->m_dRight;
|
||||
pParagraph->m_dLineHeight = pParagraph->m_dHeight;
|
||||
|
||||
if (pLine->m_pDominantShape)
|
||||
{
|
||||
|
||||
@ -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
|
||||
{
|
||||
@ -103,6 +103,7 @@ namespace NSDocxRenderer
|
||||
|
||||
void Analyze();
|
||||
void Record(NSStringUtils::CStringBuilder& oWriter, bool bIsLastPage);
|
||||
void ReorderShapesForPptx();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -83,6 +83,7 @@ namespace NSDocxRenderer
|
||||
|
||||
m_oSelectedFont = rCont.m_oSelectedFont;
|
||||
m_bPossibleSplit = rCont.m_bPossibleSplit;
|
||||
m_bWriteStyleRaw = rCont.m_bWriteStyleRaw;
|
||||
|
||||
m_arSymWidths.clear();
|
||||
m_arSymWidths.resize(rCont.m_arSymWidths.size());
|
||||
@ -194,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 &&
|
||||
@ -528,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
|
||||
@ -622,6 +628,10 @@ namespace NSDocxRenderer
|
||||
m_dRight = m_dLeft + m_dWidth;
|
||||
m_arSymWidths.resize(m_arSymWidths.size() - 1);
|
||||
}
|
||||
uint32_t CContText::GetLastSym() const
|
||||
{
|
||||
return m_oText.at(m_oText.length() - 1);
|
||||
}
|
||||
|
||||
const NSStringUtils::CStringUTF32& CContText::GetText() const noexcept
|
||||
{
|
||||
|
||||
@ -97,6 +97,8 @@ namespace NSDocxRenderer
|
||||
void SetSym(uint32_t cSym, double dWidth);
|
||||
void RemoveLastSym();
|
||||
|
||||
uint32_t GetLastSym() const;
|
||||
|
||||
const NSStringUtils::CStringUTF32& GetText() const noexcept;
|
||||
const std::vector<double>& GetSymWidths() const noexcept;
|
||||
const std::vector<double> GetSymLefts() const noexcept;
|
||||
@ -108,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;
|
||||
|
||||
@ -25,7 +25,9 @@ namespace NSDocxRenderer
|
||||
oWriter.AddInt(nFontSize);
|
||||
oWriter.WriteString(L"\" />");
|
||||
oWriter.WriteString(L"</" + wsTag + L":rPr>");
|
||||
oWriter.WriteString(L"<" + wsTag + L":t xml:space=\"preserve\">" + wsText + L"</" + wsTag + L":t>");
|
||||
oWriter.WriteString(L"<" + wsTag + L":t xml:space=\"preserve\">");
|
||||
oWriter.WriteEncodeXmlString(wsText);
|
||||
oWriter.WriteString(L"</" + wsTag + L":t>");
|
||||
oWriter.WriteString(L"</" + wsTag + L":r>");
|
||||
oWriter.WriteString(L"</" + wsTag + L":p>");
|
||||
}
|
||||
|
||||
@ -591,11 +591,8 @@ namespace NSDocxRenderer
|
||||
|
||||
void CShape::ToXml(NSStringUtils::CStringBuilder &oWriter) const
|
||||
{
|
||||
//todo для уменьшения размера каждого шейпа ипользовавать только то, что необходимо - для графики, текста, графика+текст
|
||||
//todo добавить все возможные параметры/атрибуты
|
||||
|
||||
oWriter.WriteString(L"<w:r>");
|
||||
oWriter.WriteString(L"<w:rPr><w:noProof/></w:rPr>"); //отключение проверки орфографии
|
||||
oWriter.WriteString(L"<w:rPr><w:noProof/></w:rPr>");
|
||||
oWriter.WriteString(L"<w:drawing>");
|
||||
BuildGeneralProperties(oWriter);
|
||||
oWriter.WriteString(L"</w:drawing>");
|
||||
@ -679,13 +676,9 @@ namespace NSDocxRenderer
|
||||
break;
|
||||
}
|
||||
oWriter.AddUInt(m_nShapeId);
|
||||
//oWriter.WriteString(L" descr=\"Alt Text!\""); //Коммент к картинке
|
||||
oWriter.WriteString(L"\"/>");
|
||||
|
||||
oWriter.WriteString(L"<wp:cNvGraphicFramePr/>");
|
||||
|
||||
BuildSpecificProperties(oWriter);
|
||||
|
||||
oWriter.WriteString(L"</wp:anchor>");
|
||||
}
|
||||
|
||||
@ -750,11 +743,19 @@ namespace NSDocxRenderer
|
||||
}
|
||||
else
|
||||
{
|
||||
double left = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetLeft() : m_dLeft;
|
||||
double right = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetRight() : m_dRight;
|
||||
double top = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetTop() : m_dTop;
|
||||
double bot = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetBottom() : m_dBaselinePos;
|
||||
|
||||
double height = bot - top;
|
||||
double width = right - left;
|
||||
|
||||
// coeff
|
||||
double offset_left = (m_dRight - m_dImageLeft) / m_dWidth - 1;
|
||||
double offset_right = (m_dImageRight - m_dLeft) / m_dWidth - 1;
|
||||
double offset_top = (m_dBaselinePos - m_dImageTop) / m_dHeight - 1;
|
||||
double offset_bot = (m_dImageBot - m_dTop) / m_dHeight - 1;
|
||||
double offset_left = (right - m_dImageLeft) / width - 1;
|
||||
double offset_right = (m_dImageRight - left) / width - 1;
|
||||
double offset_top = (bot - m_dImageTop) / height - 1;
|
||||
double offset_bot = (m_dImageBot - top) / height - 1;
|
||||
|
||||
// percentage
|
||||
offset_left *= 100;
|
||||
@ -794,7 +795,6 @@ namespace NSDocxRenderer
|
||||
oWriter.WriteString(L"\" name=\"Picture ");
|
||||
oWriter.AddUInt(m_pImageInfo->m_nId);
|
||||
oWriter.WriteString(L"\"");
|
||||
//oWriter.WriteString(L" descr=\"Alt Text!\""); //Коммент к картинке
|
||||
oWriter.WriteString(L"/>");
|
||||
oWriter.WriteString(L"<pic:cNvPicPr preferRelativeResize=\"0\">");
|
||||
oWriter.WriteString(L"<a:picLocks noChangeArrowheads=\"1\"/>");
|
||||
@ -875,10 +875,10 @@ namespace NSDocxRenderer
|
||||
oWriter.WriteString(L"<a:solidFill>");
|
||||
oWriter.WriteString(L"<a:srgbClr val=\"");
|
||||
oWriter.WriteHexInt3(static_cast<int>(ConvertColorBGRToRGB(m_oBrush.Color1)));
|
||||
if (0xFF != m_oBrush.TextureAlpha)
|
||||
if (0xFF != m_oBrush.Alpha1)
|
||||
{
|
||||
oWriter.WriteString(L"\"><a:alpha val=\"");
|
||||
oWriter.AddInt(static_cast<int>(m_oBrush.TextureAlpha / 255.0 * 100.0));
|
||||
oWriter.AddInt(static_cast<int>(m_oBrush.Alpha1 / 255.0 * 100.0));
|
||||
oWriter.WriteString(L"%\"/></a:srgbClr>");
|
||||
}
|
||||
else
|
||||
|
||||
@ -37,6 +37,9 @@ namespace NSDocxRenderer
|
||||
NSStructures::CPen m_oPen {};
|
||||
|
||||
CVectorGraphics m_oVector {};
|
||||
|
||||
// vector with rotation 0 (to write ooxml if m_dRotation is > c_dMinRotation)
|
||||
CVectorGraphics m_oNoRotVector{};
|
||||
std::wstring m_strDstMedia {};
|
||||
|
||||
double m_dRotation {0.0};
|
||||
@ -105,7 +108,6 @@ namespace NSDocxRenderer
|
||||
static void CheckLineType(std::shared_ptr<CShape>& pFirstShape, std::shared_ptr<CShape>& pSecondShape, bool bIsLast = false);
|
||||
|
||||
private:
|
||||
CVectorGraphics m_oNoRotVector{};
|
||||
|
||||
UINT m_nShapeId{0};
|
||||
UINT m_nRelativeHeight{0};
|
||||
|
||||
@ -74,6 +74,9 @@ namespace NSDocxRenderer
|
||||
|
||||
if (bIsWideSpaceDelta || (pCurrent->m_bPossibleSplit && bIsSpaceDelta))
|
||||
{
|
||||
if (CContText::IsUnicodeSpace(pFirst->GetLastSym()))
|
||||
pFirst->RemoveLastSym();
|
||||
|
||||
auto wide_space = std::make_shared<CContText>(pFirst->m_pManager);
|
||||
|
||||
// sets all members for wide_space except highlight things
|
||||
@ -110,9 +113,15 @@ namespace NSDocxRenderer
|
||||
else
|
||||
set_base();
|
||||
|
||||
m_arConts.insert(m_arConts.begin() + i, wide_space);
|
||||
// pFrist cont contains only 1 space
|
||||
if (pFirst->GetLength() == 0)
|
||||
*pFirst = *wide_space;
|
||||
else
|
||||
{
|
||||
m_arConts.insert(m_arConts.begin() + i, wide_space);
|
||||
i++;
|
||||
}
|
||||
|
||||
i++;
|
||||
while (!m_arConts[i] && i < m_arConts.size()) i++;
|
||||
if (i == m_arConts.size()) break;
|
||||
pFirst = m_arConts[i];
|
||||
|
||||
@ -469,7 +469,7 @@ namespace NSDocxRenderer
|
||||
//CheckFontNameStyle(wsName, L"light");
|
||||
|
||||
CheckFontNameStyle(wsName, L"condensedbold");
|
||||
CheckFontNameStyle(wsName, L"semibold");
|
||||
if (CheckFontNameStyle(wsName, L"semibold")) bBold = true;
|
||||
if (CheckFontNameStyle(wsName, L"boldmt")) bBold = true;
|
||||
if (CheckFontNameStyle(wsName, L"bold")) bBold = true;
|
||||
|
||||
|
||||
@ -12,10 +12,6 @@
|
||||
namespace NSDocxRenderer
|
||||
{
|
||||
CVectorGraphics::CVectorGraphics() noexcept
|
||||
: m_dLeftDefault(std::numeric_limits<double>().max()),
|
||||
m_dRightDefault(std::numeric_limits<double>().min()),
|
||||
m_dTopDefault(std::numeric_limits<double>().max()),
|
||||
m_dBottomDefault(std::numeric_limits<double>().min())
|
||||
{
|
||||
ResetBorders();
|
||||
}
|
||||
@ -131,10 +127,10 @@ namespace NSDocxRenderer
|
||||
|
||||
void CVectorGraphics::ResetBorders() noexcept
|
||||
{
|
||||
m_dLeft = m_dLeftDefault;
|
||||
m_dTop = m_dTopDefault;
|
||||
m_dRight = m_dRightDefault;
|
||||
m_dBottom = m_dBottomDefault;
|
||||
m_dLeft = std::numeric_limits<double>().max();
|
||||
m_dTop = std::numeric_limits<double>().max();
|
||||
m_dRight = std::numeric_limits<double>().min();
|
||||
m_dBottom = std::numeric_limits<double>().min();
|
||||
}
|
||||
|
||||
double CVectorGraphics::GetLeft() const noexcept
|
||||
@ -259,6 +255,12 @@ namespace NSDocxRenderer
|
||||
rotate_matrix.RotateAt(rotation, center.x, center.y, Aggplus::MatrixOrderAppend);
|
||||
Transform(rotate_matrix);
|
||||
}
|
||||
void CVectorGraphics::RotateAt(const double& rotation, const Point& point)
|
||||
{
|
||||
Aggplus::CMatrix rotate_matrix;
|
||||
rotate_matrix.RotateAt(rotation, point.x, point.y, Aggplus::MatrixOrderAppend);
|
||||
Transform(rotate_matrix);
|
||||
}
|
||||
void CVectorGraphics::Transform(const Aggplus::CMatrix& matrix)
|
||||
{
|
||||
auto data = std::move(m_arData);
|
||||
|
||||
@ -76,6 +76,7 @@ namespace NSDocxRenderer
|
||||
void Clear();
|
||||
void CheckPoint(const Point& point) noexcept;
|
||||
void CheckPoint(const double& x, const double& y) noexcept;
|
||||
void RotateAt(const double& rotation, const Point& point);
|
||||
void Rotate(const double& rotation);
|
||||
void Transform(const Aggplus::CMatrix& matrix);
|
||||
void DrawOnRenderer(IRenderer* renderer) const noexcept;
|
||||
@ -90,11 +91,6 @@ namespace NSDocxRenderer
|
||||
double m_dRight;
|
||||
double m_dBottom;
|
||||
|
||||
const double m_dLeftDefault;
|
||||
const double m_dTopDefault;
|
||||
const double m_dRightDefault;
|
||||
const double m_dBottomDefault;
|
||||
|
||||
void ResetBorders() noexcept;
|
||||
|
||||
Aggplus::CGraphicsPath GetGraphicsPath() const noexcept;
|
||||
|
||||
@ -13,6 +13,7 @@ inline LONG ConvertColorBGRToRGB(LONG lBGR)
|
||||
template<typename It>
|
||||
It MoveNullptr(It start, It end)
|
||||
{
|
||||
if (end <= start) return start;
|
||||
It left = start, right = end - 1;
|
||||
for (;;)
|
||||
{
|
||||
|
||||
@ -61,7 +61,7 @@ _UINT64 MemoryStream::ReadUInt64()
|
||||
{
|
||||
_UINT64 rdU64 = 0;
|
||||
|
||||
if (m_Data)
|
||||
if (m_Data && (m_Position + 8 <= m_Size))
|
||||
{
|
||||
rdU64 = DocFileFormat::FormatUtils::BytesToUInt64(m_Data, m_Position, m_Size);
|
||||
m_Position += 8;
|
||||
@ -73,7 +73,7 @@ unsigned short MemoryStream::ReadUInt16()
|
||||
{
|
||||
unsigned short rdUShort = 0;
|
||||
|
||||
if (m_Data)
|
||||
if (m_Data && (m_Position + sizeof(unsigned short) <= m_Size))
|
||||
{
|
||||
rdUShort = DocFileFormat::FormatUtils::BytesToUInt16 (m_Data, m_Position, m_Size);
|
||||
m_Position += 2;
|
||||
@ -93,7 +93,7 @@ short MemoryStream::ReadInt16()
|
||||
{
|
||||
short rdShort = 0;
|
||||
|
||||
if (m_Data)
|
||||
if (m_Data && (m_Position + sizeof(short) <= m_Size))
|
||||
{
|
||||
rdShort = DocFileFormat::FormatUtils::BytesToInt16 (m_Data, m_Position, m_Size);
|
||||
m_Position += 2;
|
||||
@ -106,7 +106,7 @@ int MemoryStream::ReadInt32()
|
||||
{
|
||||
int rdInt = 0;
|
||||
|
||||
if (m_Data)
|
||||
if (m_Data && (m_Position + sizeof(_INT32) <= m_Size))
|
||||
{
|
||||
rdInt = DocFileFormat::FormatUtils::BytesToInt32 (m_Data, m_Position, m_Size);
|
||||
m_Position += 4;
|
||||
|
||||
@ -60,11 +60,13 @@ namespace XLSB
|
||||
{
|
||||
record >> crfx;
|
||||
UncheckedRfX rfx;
|
||||
bool isXlsb = (record.getGlobalWorkbookInfo()->Version) >= 0x0800;
|
||||
for(size_t i = 0; i < crfx; i++)
|
||||
{
|
||||
record >> rfx;
|
||||
rgrfx.push_back(rfx);
|
||||
strValue += std::wstring (rfx.toString(false).c_str()) + ((i == crfx - 1) ? L"" : L" ");
|
||||
strValue += std::wstring (rfx.toString(false, isXlsb).c_str()) + ((i == crfx - 1) ? L"" : L" ");
|
||||
rfx.to_string_cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -732,11 +732,7 @@ void CSVWriter::Impl::WriteCell(OOX::Spreadsheet::CCell *pCell)
|
||||
//else
|
||||
bool bString = false;
|
||||
|
||||
if (pCell->m_oFormula.IsInit())
|
||||
{
|
||||
sCellValue = pCell->m_oFormula->m_sText;
|
||||
}
|
||||
else if (pCell->m_oValue.IsInit())
|
||||
if (pCell->m_oValue.IsInit())
|
||||
{
|
||||
sCellValue = pCell->m_oValue->ToString();
|
||||
|
||||
@ -798,10 +794,12 @@ void CSVWriter::Impl::WriteCell(OOX::Spreadsheet::CCell *pCell)
|
||||
}
|
||||
}
|
||||
sCellValue = ConvertValueCellToString(sCellValue, format_type, format_code);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (pCell->m_oFormula.IsInit() && sCellValue.empty())
|
||||
{
|
||||
sCellValue = pCell->m_oFormula->m_sText;
|
||||
}
|
||||
|
||||
// Escape cell value
|
||||
if (m_bJSON)
|
||||
|
||||
@ -181,7 +181,7 @@ namespace OOX
|
||||
|
||||
void Diagram::CAnimLvl::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
WriteByteToPPTY(m_oVal.IsInit() ? (BYTE)m_oVal->GetValue() : 0, pWriter);
|
||||
WriteByteToPPTY(m_oVal.IsInit() ? (BYTE)m_oVal->GetValue() : SimpleTypes::EAnimLvlStr::animLvlStr_none, pWriter);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------
|
||||
@ -211,7 +211,7 @@ namespace OOX
|
||||
|
||||
void Diagram::CAnimOne::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
WriteByteToPPTY(m_oVal.IsInit() ? (BYTE)m_oVal->GetValue() : 0, pWriter);
|
||||
WriteByteToPPTY(m_oVal.IsInit() ? (BYTE)m_oVal->GetValue() : SimpleTypes::EAnimOneStr::animOneStr_none, pWriter);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------
|
||||
@ -241,7 +241,7 @@ namespace OOX
|
||||
|
||||
void Diagram::CBulletEnabled::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
WriteByteToPPTY(m_oVal.IsInit() ? (BYTE)m_oVal->GetValue() : 0, pWriter);
|
||||
WriteByteToPPTY(m_oVal.IsInit() ? (BYTE)m_oVal->GetValue() : SimpleTypes::onoffFalse, pWriter);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------
|
||||
@ -331,7 +331,7 @@ namespace OOX
|
||||
|
||||
void Diagram::CDirection::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
WriteByteToPPTY(m_oVal.IsInit() ? (BYTE)m_oVal->GetValue() : 0, pWriter);
|
||||
WriteByteToPPTY(m_oVal.IsInit() ? (BYTE)m_oVal->GetValue() : SimpleTypes::EDirectionDraw::direction_norm, pWriter);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------
|
||||
@ -360,7 +360,7 @@ namespace OOX
|
||||
|
||||
void Diagram::CHierBranch::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
WriteByteToPPTY(m_oVal.IsInit() ? (BYTE)m_oVal->GetValue() : 0, pWriter);
|
||||
WriteByteToPPTY(m_oVal.IsInit() ? (BYTE)m_oVal->GetValue() : SimpleTypes::EHierBranch::hierBranch_std, pWriter);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------
|
||||
@ -390,7 +390,7 @@ namespace OOX
|
||||
|
||||
void Diagram::COrgChart::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
WriteByteToPPTY(m_oVal.IsInit() ? (BYTE)m_oVal->GetValue() : 0, pWriter);
|
||||
WriteByteToPPTY(m_oVal.IsInit() ? (BYTE)m_oVal->GetValue() : SimpleTypes::EOnOff::onoffFalse, pWriter);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------
|
||||
@ -420,7 +420,7 @@ namespace OOX
|
||||
|
||||
void Diagram::CResizeHandles::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
WriteByteToPPTY(m_oVal.IsInit() ? (BYTE)m_oVal->GetValue() : 0, pWriter);
|
||||
WriteByteToPPTY(m_oVal.IsInit() ? (BYTE)m_oVal->GetValue() : SimpleTypes::EResizeHandles::resizeHandles_exact, pWriter);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -2675,7 +2675,12 @@ void CDrawingConverter::ConvertShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::CX
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pPPTShape->m_eType == PPTShapes::sptCTextBox)
|
||||
if (pPPTShape->m_eType == PPTShapes::sptCTextBox ||
|
||||
pPPTShape->m_eType == PPTShapes::sptCRect ||
|
||||
pPPTShape->m_eType == PPTShapes::sptCRoundRect ||
|
||||
pPPTShape->m_eType == PPTShapes::sptCWedgeRectCallout ||
|
||||
pPPTShape->m_eType == PPTShapes::sptCWedgeRoundRectCallout)
|
||||
// sptCRound1Rect ?
|
||||
{
|
||||
pShape->oTextBoxBodyPr->lIns = 91440;
|
||||
pShape->oTextBoxBodyPr->tIns = 45720;
|
||||
|
||||
@ -294,12 +294,12 @@ namespace PPTX
|
||||
if (chExtX.IsInit() && extX.IsInit())
|
||||
pWriter->m_dCxCurShape = pWriter->m_dCyCurShape * (double)*extX / (double)*chExtX;
|
||||
else if (extX.IsInit())
|
||||
pWriter->m_dCxCurShape = (pWriter->m_bInGroup ? pWriter->m_dCxCurShape : 1) * *extX;
|
||||
pWriter->m_dCxCurShape = ((pWriter->m_bInGroup && pWriter->m_dCxCurShape > 0) ? pWriter->m_dCxCurShape : 1) * *extX;
|
||||
|
||||
if (chExtY.IsInit() && extY.IsInit())
|
||||
pWriter->m_dCyCurShape = pWriter->m_dCyCurShape * (double)*extY / (double)*chExtY;
|
||||
else if (extY.IsInit())
|
||||
pWriter->m_dCyCurShape = (pWriter->m_bInGroup ? pWriter->m_dCyCurShape : 1) * *extY;
|
||||
pWriter->m_dCyCurShape = ((pWriter->m_bInGroup && pWriter->m_dCyCurShape > 0) ? pWriter->m_dCyCurShape : 1) * *extY;
|
||||
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
|
||||
pWriter->WriteInt2(0, offX);
|
||||
|
||||
@ -2040,10 +2040,9 @@ namespace OOX
|
||||
{
|
||||
public:
|
||||
nullable_string m_name;
|
||||
nullableUintVal m_fmtId;
|
||||
nullableIntVal m_fmtId;
|
||||
nullable<OOX::Drawing::COfficeArtExtensionList> m_extLst;
|
||||
|
||||
|
||||
CT_PivotSource();
|
||||
~CT_PivotSource();
|
||||
|
||||
|
||||
@ -876,8 +876,8 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
|
||||
writer.WriteString(L"<cx:valScaling");
|
||||
WritingStringNullableAttrString(L"min", m_min, m_min->ToString())
|
||||
WritingStringNullableAttrString(L"max", m_max, m_max->ToString())
|
||||
WritingStringNullableAttrString(L"majorUnit", m_max, m_majorUnit->ToString())
|
||||
WritingStringNullableAttrString(L"minorUnit", m_max, m_minorUnit->ToString())
|
||||
WritingStringNullableAttrString(L"majorUnit", m_majorUnit, m_majorUnit->ToString())
|
||||
WritingStringNullableAttrString(L"minorUnit", m_minorUnit, m_minorUnit->ToString())
|
||||
writer.WriteString(L"/>");
|
||||
|
||||
}
|
||||
@ -962,8 +962,11 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
|
||||
}
|
||||
else if( L"axisId" == sName)
|
||||
{
|
||||
std::wstring s = oReader.GetText3();
|
||||
m_arAxisId.push_back(XmlUtils::GetInteger(s));
|
||||
nullableUintVal val = oReader;
|
||||
if (val.IsInit())
|
||||
{
|
||||
m_arAxisId.push_back(*val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1000,11 +1003,8 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
|
||||
}
|
||||
for (size_t i = 0; i < m_arAxisId.size(); i++)
|
||||
{
|
||||
writer.WriteString(L"<cx:axisId>");
|
||||
writer.WriteString(std::to_wstring(m_arAxisId[i]));
|
||||
writer.WriteString(L"</cx:axisId>");
|
||||
writer.WriteString(L"<cx:axisId val=\"" + std::to_wstring(m_arAxisId[i]) + L"\"/>");
|
||||
}
|
||||
|
||||
if (m_spPr.IsInit())
|
||||
{
|
||||
m_spPr->m_namespace = L"cx";
|
||||
@ -1476,8 +1476,11 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
|
||||
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
|
||||
if( L"idx" == sName)
|
||||
{
|
||||
std::wstring s = oReader.GetText3();
|
||||
m_arIdx.push_back(XmlUtils::GetInteger(s));
|
||||
nullableUintVal val = oReader;
|
||||
if (val.IsInit())
|
||||
{
|
||||
m_arIdx.push_back(*val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1487,9 +1490,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
|
||||
|
||||
for (size_t i= 0; i < m_arIdx.size(); i++)
|
||||
{
|
||||
writer.WriteString(L"<cx:idx>");
|
||||
writer.WriteString(std::to_wstring(m_arIdx[i]));
|
||||
writer.WriteString(L"</cx:idx>");
|
||||
writer.WriteString(L"<cx:idx val=\"" + std::to_wstring(m_arIdx[i]) + L"\"/>");
|
||||
}
|
||||
writer.WriteString(L"</cx:subtotals>");
|
||||
}
|
||||
|
||||
@ -334,7 +334,7 @@ namespace ChartEx
|
||||
virtual std::wstring toXML() const { return L""; }
|
||||
virtual EElementType getType () const;
|
||||
|
||||
std::vector<unsigned int> m_arIdx;
|
||||
std::vector<unsigned int> m_arIdx;
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
class CSeriesLayoutProperties : public WritingElement
|
||||
|
||||
@ -55,7 +55,7 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
|
||||
{L"star4" ,L"star4" ,1 ,0 ,50000 },
|
||||
{L"star5" ,L"star5" ,0 ,0 ,50000 },//??? 19098 неверно
|
||||
{L"star8" ,L"star8" ,0 ,0 ,50000 },
|
||||
{L"star24" ,L"star24" ,1 ,0 ,50000 },
|
||||
{L"star24" ,L"star24" ,0 ,0 ,50000 },
|
||||
{L"star6" ,L"star6" ,0 ,0 ,50000 },
|
||||
{L"star12" ,L"star12" ,1 ,0 ,50000 },
|
||||
{L"round-rectangle" ,L"roundRect" ,0 ,0 ,0 },
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user