mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-08 20:05:51 +08:00
Compare commits
294 Commits
v9.0.4.22
...
feature/x2
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c17190c0c | |||
| 40809ea3c2 | |||
| 13158b2956 | |||
| 9e8beb5651 | |||
| 711e80e62c | |||
| 3404aab782 | |||
| 9c3ba26fab | |||
| 02f4c10cd6 | |||
| 0d912533bf | |||
| 066793921b | |||
| 9b2b7263c2 | |||
| 31c28903d6 | |||
| 518a38e178 | |||
| 631c2d4490 | |||
| 0d0003ad5a | |||
| eb3bedd840 | |||
| 0e9db67173 | |||
| 1a65242d46 | |||
| 30da4b631f | |||
| a988e6741c | |||
| 29c2239df2 | |||
| 0d7ddfb580 | |||
| 8bbb21263d | |||
| a652bd6591 | |||
| 78532c27cf | |||
| 63d3999072 | |||
| d055522aa0 | |||
| c5e63a8d26 | |||
| e56da8e641 | |||
| ba63cfc622 | |||
| 7486182be7 | |||
| 6f171bd5d7 | |||
| dad2fdd3e0 | |||
| 48bc54311c | |||
| a71b7ec6e7 | |||
| 292e6b0431 | |||
| 5649de0877 | |||
| 7aa2056785 | |||
| b1c8969ede | |||
| d3805e81d7 | |||
| 8171939be6 | |||
| 5178de4254 | |||
| b534907bc9 | |||
| b957d3aeea | |||
| 520c345f00 | |||
| 08ce05e5d3 | |||
| a8125114de | |||
| 13a4986eb7 | |||
| 62003d97bb | |||
| 3e0a88a487 | |||
| 1969229659 | |||
| 98af93c631 | |||
| a4ebe56f28 | |||
| 247b90ce1a | |||
| aef05de075 | |||
| 5b12d7fff3 | |||
| 4223f9c265 | |||
| 9e60a7e3ab | |||
| 5de9bd7e67 | |||
| dacde4c593 | |||
| 97385c3f37 | |||
| edd17cd7c3 | |||
| e373adf717 | |||
| 2ad1771333 | |||
| 73f40edc7e | |||
| 182a3cea90 | |||
| 72f0b0403e | |||
| 3d5d871911 | |||
| 1fbffa673c | |||
| 06c47b07ec | |||
| e2bcf62cc4 | |||
| f5a91c33b5 | |||
| 79ab0bc04b | |||
| 242aa2c9d6 | |||
| e01517714c | |||
| 3f7edeec4f | |||
| 9cef29c201 | |||
| 688632c373 | |||
| c86387c015 | |||
| e8f7720387 | |||
| c3dd5c8fc9 | |||
| 6e1357f276 | |||
| fee71647a9 | |||
| 6c516b7ce2 | |||
| 53d5f4517b | |||
| 03e21d19f1 | |||
| cd05b830b1 | |||
| bf05a63db0 | |||
| bc96c82ff9 | |||
| 4187522006 | |||
| 81f057ba78 | |||
| fcd7818675 | |||
| baf8321c61 | |||
| 826bd168ad | |||
| b1dff84b1b | |||
| c65460e49b | |||
| f5fa14a230 | |||
| db744e6fdc | |||
| a15156fcb3 | |||
| dbc54e5879 | |||
| 2a09e2ef67 | |||
| 17534abdda | |||
| 0eadce28da | |||
| 29c53f751b | |||
| 6500e65edc | |||
| e8ecb2cdfb | |||
| 3046b1557f | |||
| fbf4ef22d8 | |||
| 628908e96c | |||
| 78df0b3780 | |||
| d8c0e9b68d | |||
| df8f8636b6 | |||
| 5722599351 | |||
| f4489a3926 | |||
| 91f27bf771 | |||
| eb3daff8d6 | |||
| 6d707ebae2 | |||
| bab8da0475 | |||
| a865901405 | |||
| c1987b196e | |||
| 8899966508 | |||
| 41dc23ce53 | |||
| 3a555aa223 | |||
| 2168216009 | |||
| 13b42d71e2 | |||
| 58cd88a93f | |||
| 4dc1d88bc9 | |||
| ef2d554265 | |||
| 2d08404f72 | |||
| cd6c4c56c3 | |||
| b655a4e109 | |||
| 7ce6602951 | |||
| f45b3ba0da | |||
| 5ec24525b8 | |||
| 0c601c1c82 | |||
| c7d3e5df14 | |||
| 2351b1f052 | |||
| b93ea3bb41 | |||
| 697f604fc4 | |||
| a817cd54d5 | |||
| e1b3474a06 | |||
| c7a209048f | |||
| a359060684 | |||
| 08fafaa655 | |||
| 2462074f63 | |||
| 114f9a0da3 | |||
| 7c4b85600d | |||
| 07bd804009 | |||
| e74a96884c | |||
| c67d87b1f0 | |||
| 1e73aed4a5 | |||
| 63da89d846 | |||
| 9f223deee7 | |||
| d49789ea19 | |||
| 738583d0d4 | |||
| 47a1e26ff5 | |||
| ecca7a5cdd | |||
| f5ddf8c6ce | |||
| 337847f606 | |||
| e6e93549c9 | |||
| 00e5c8bd2e | |||
| 01d6a7d090 | |||
| 98c998b3ee | |||
| 880951a611 | |||
| 2895f829e3 | |||
| 671b88d8bc | |||
| c0ba4267d2 | |||
| 29355d337b | |||
| 6f7a414888 | |||
| a040e89ae5 | |||
| e025ae2779 | |||
| e17b99554d | |||
| 09ac9f8609 | |||
| 156578ca82 | |||
| 2ec63f2cb7 | |||
| 62d2deaefb | |||
| fbed837a47 | |||
| 0715c0c5a5 | |||
| 453e17ac0e | |||
| d3430ace10 | |||
| 8c6a26895b | |||
| 5142536e17 | |||
| ae2918ec71 | |||
| 1495581b00 | |||
| 6c2fce16a8 | |||
| 6c2a8205ec | |||
| 29cee43448 | |||
| 0154543b01 | |||
| 3e2dee5719 | |||
| c25f8cc204 | |||
| 010d1ce4c9 | |||
| d3aae6dfcb | |||
| fb07c0c468 | |||
| 327d00bacf | |||
| fe0d95009c | |||
| 9200c29d42 | |||
| c13027c9d1 | |||
| 6acb9855a1 | |||
| 2b1e5faef9 | |||
| ea214f942f | |||
| ccbff8d8da | |||
| 1cd72ab988 | |||
| 63937e706e | |||
| 537304ad24 | |||
| d362999e2a | |||
| 1f4a420d35 | |||
| d11e0492f2 | |||
| 4b3c4242f6 | |||
| 48ec45c1dd | |||
| 91badde27d | |||
| 618b1a9ca8 | |||
| 85e8d253a9 | |||
| 827dc4c1b9 | |||
| 18e22f0f05 | |||
| b8053ae388 | |||
| c56cfaf71f | |||
| e5fcbcf5f3 | |||
| 8a9277d1d8 | |||
| f3d3755a31 | |||
| ffab501ce9 | |||
| db9fd85f22 | |||
| 9a74609366 | |||
| aaf744353f | |||
| 67a5b7f087 | |||
| 750b28d866 | |||
| db7ebc5765 | |||
| 8ac1c4d158 | |||
| 18f92b56ba | |||
| 03463ee0e4 | |||
| d50ee7467e | |||
| d15ac8b84f | |||
| 00176a0425 | |||
| 14f0a757ac | |||
| 9b24261b2b | |||
| 211f151346 | |||
| 6c8cbec6ba | |||
| 755a357e3d | |||
| 2a7256eb48 | |||
| 0e8c37c293 | |||
| bf00185275 | |||
| 6ed57dae6c | |||
| eb472e27b4 | |||
| 51aed7ae53 | |||
| ecf59a75a7 | |||
| 9039ff53db | |||
| b53b2859de | |||
| fe1372882e | |||
| 34e0b7e69a | |||
| 856ae09f69 | |||
| 28f2e14bce | |||
| b8d9ba3b1d | |||
| 5fe6dd8730 | |||
| ab573cf9ba | |||
| 92902724a0 | |||
| 7e116dbd41 | |||
| c964ed7d58 | |||
| b456a094ee | |||
| a19dc86ea9 | |||
| 62ba3fa029 | |||
| 58c2fa783e | |||
| 678101f7e4 | |||
| 17fb69ee8a | |||
| 0833c97c99 | |||
| 5d64c7c6e7 | |||
| 0f3ef78362 | |||
| 1a54c8f8b9 | |||
| 6d6f87cae6 | |||
| 3d9a783d46 | |||
| 21028c2ca5 | |||
| 8c16766e9f | |||
| c8ca725523 | |||
| 3c2fd33c7a | |||
| f9062d7d38 | |||
| 25fa05b701 | |||
| 6f66b0c533 | |||
| bf89efd471 | |||
| 8f14a0f30b | |||
| 494b7b52cb | |||
| e5d6f5df47 | |||
| 6f1ffaad40 | |||
| e76398db01 | |||
| cafdb1d2a5 | |||
| 421f5bb0f2 | |||
| 61640a9a06 | |||
| 87f0835010 | |||
| eb71d95944 | |||
| 1d27cc61f4 | |||
| f535cef848 | |||
| 7ad49a5650 | |||
| 3ad2fff67b | |||
| 66b56360da | |||
| e8f88ab20d | |||
| 7857106d76 | |||
| 64c74192c7 |
1
Common/.gitignore
vendored
Normal file
1
Common/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
**/module.version
|
||||
@ -26,14 +26,21 @@ bundle_xcframeworks {
|
||||
}
|
||||
}
|
||||
|
||||
core_win_arm64 {
|
||||
DEFINES += MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS=0
|
||||
}
|
||||
|
||||
core_windows {
|
||||
VS_VERSION=140
|
||||
VS_DEBUG=
|
||||
VS_ARCH=x64
|
||||
core_debug:VS_DEBUG=gd-
|
||||
core_win_32:VS_ARCH=x32
|
||||
core_win_arm64:VS_ARCH=a64
|
||||
vs2019:VS_VERSION=142
|
||||
|
||||
DEFINES += BOOST_USE_WINDOWS_H BOOST_WINAPI_NO_REDECLARATIONS
|
||||
|
||||
BOOST_POSTFIX = -vc$${VS_VERSION}-mt-$${VS_DEBUG}$${VS_ARCH}-1_72
|
||||
|
||||
core_boost_libs:LIBS += -L$$CORE_BOOST_LIBS -llibboost_system$$BOOST_POSTFIX -llibboost_filesystem$$BOOST_POSTFIX
|
||||
|
||||
4
Common/3dParty/heif/.gitignore
vendored
Normal file
4
Common/3dParty/heif/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
x265_git
|
||||
libde265
|
||||
libheif
|
||||
ios-cmake
|
||||
42
Common/3dParty/heif/heif.pri
Normal file
42
Common/3dParty/heif/heif.pri
Normal file
@ -0,0 +1,42 @@
|
||||
DEFINES += LIBHEIF_STATIC_BUILD
|
||||
|
||||
HEIF_BUILDS_PLATFORM_PREFIX = $$CORE_BUILDS_PLATFORM_PREFIX
|
||||
core_ios : xcframework_platform_ios_simulator {
|
||||
HEIF_BUILDS_PLATFORM_PREFIX = ios_simulator
|
||||
}
|
||||
|
||||
HEIF_BUILD_PATH = $$PWD/libheif/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$PWD/libheif/libheif/api \
|
||||
$$HEIF_BUILD_PATH # for heif_version.h
|
||||
|
||||
core_windows {
|
||||
core_debug {
|
||||
BUILD_TYPE = Debug
|
||||
} else {
|
||||
BUILD_TYPE = Release
|
||||
}
|
||||
|
||||
LIBS += \
|
||||
-L$$PWD/x265_git/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX/$$BUILD_TYPE -lx265-static \
|
||||
-L$$PWD/libde265/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX/libde265/$$BUILD_TYPE -llibde265 \
|
||||
-L$$HEIF_BUILD_PATH/libheif/$$BUILD_TYPE -lheif
|
||||
}
|
||||
|
||||
core_linux | core_android {
|
||||
# we need to wrap x265 and de265 libraries in `whole-archive` flags to avoid "undefined symbol" errors when later linking with graphics.so
|
||||
LIBS += \
|
||||
-Wl,--whole-archive \
|
||||
-L$$PWD/x265_git/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX -lx265 \
|
||||
-L$$PWD/libde265/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX/libde265 -lde265 \
|
||||
-Wl,--no-whole-archive \
|
||||
-L$$HEIF_BUILD_PATH/libheif -lheif
|
||||
}
|
||||
|
||||
core_mac | core_ios {
|
||||
LIBS += \
|
||||
-L$$PWD/x265_git/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX -lx265 \
|
||||
-L$$PWD/libde265/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX/libde265 -lde265 \
|
||||
-L$$HEIF_BUILD_PATH/libheif -lheif
|
||||
}
|
||||
@ -15,6 +15,10 @@
|
||||
#include "../../../UnicodeConverter/UnicodeConverter.h"
|
||||
#include "../../../HtmlFile2/src/StringFinder.h"
|
||||
|
||||
#if defined(CreateDirectory)
|
||||
#undef CreateDirectory
|
||||
#endif
|
||||
|
||||
static std::string nonbreaking_inline = "|a|abbr|acronym|b|bdo|big|cite|code|dfn|em|font|i|img|kbd|nobr|s|small|span|strike|strong|sub|sup|tt|";
|
||||
static std::string empty_tags = "|area|base|basefont|bgsound|br|command|col|embed|event-source|frame|hr|image|img|input|keygen|link|menuitem|meta|param|source|spacer|track|wbr|";
|
||||
static std::string preserve_whitespace = "|pre|textarea|script|style|";
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
ICU_MAJOR_VER = 58
|
||||
ICU_MAJOR_VER = 74
|
||||
|
||||
core_windows {
|
||||
exists($$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/icu) {
|
||||
@ -20,8 +20,15 @@ core_linux {
|
||||
core_mac {
|
||||
INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/include
|
||||
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.$${ICU_MAJOR_VER}.dylib
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.$${ICU_MAJOR_VER}.dylib
|
||||
ICU_LIBS_PATH_MAC = $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build
|
||||
bundle_dylibs {
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicudata.a
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicui18n.a
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicuuc.a
|
||||
} else {
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicuuc.$${ICU_MAJOR_VER}.dylib
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicudata.$${ICU_MAJOR_VER}.dylib
|
||||
}
|
||||
}
|
||||
|
||||
core_ios {
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
ICU_VERSION="58"
|
||||
|
||||
ICU_DIR="$PWD/icu"
|
||||
|
||||
ICU_SOURCE="${ICU_DIR}/source"
|
||||
@ -47,8 +45,6 @@ defines_utypes=(
|
||||
|
||||
function prebuild() {
|
||||
|
||||
svn export http://source.icu-project.org/repos/icu/tags/release-${ICU_VERSION}/icu4c/ ${ICU_DIR} --native-eol LF
|
||||
|
||||
echo "===== REMOVING data from bundle ====="
|
||||
|
||||
#Data bundle reduction
|
||||
|
||||
@ -34,6 +34,8 @@
|
||||
#include "../../../../DesktopEditor/common/StringExt.h"
|
||||
|
||||
#include <wininet.h>
|
||||
#include <objbase.h>
|
||||
#include <urlmon.h>
|
||||
#pragma comment(lib, "Wininet")
|
||||
#pragma comment(lib, "Ole32.lib")
|
||||
|
||||
|
||||
103
Common/base.pri
103
Common/base.pri
@ -91,6 +91,10 @@ isEqual(QT_MAJOR_VERSION, 5) {
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5) {
|
||||
DEFINES += QT_VERSION_6
|
||||
|
||||
core_windows {
|
||||
QMAKE_CXXFLAGS += /permissive-
|
||||
}
|
||||
}
|
||||
|
||||
ios {
|
||||
@ -108,6 +112,10 @@ win32:contains(QMAKE_TARGET.arch, x86_64): {
|
||||
win32:!contains(QMAKE_TARGET.arch, x86_64): {
|
||||
CONFIG += core_win_32
|
||||
}
|
||||
win32:contains(QMAKE_TARGET.arch, arm64): {
|
||||
CONFIG -= core_win_32
|
||||
CONFIG += core_win_arm64
|
||||
}
|
||||
|
||||
linux-clang-libc++ {
|
||||
CONFIG += core_linux
|
||||
@ -190,6 +198,8 @@ core_windows {
|
||||
DEFINES += WIN32 _WIN32
|
||||
DEFINES += NOMINMAX
|
||||
|
||||
#DEFINES += WIN32_LEAN_AND_MEAN
|
||||
|
||||
# use default _ITERATOR_DEBUG_LEVEL value
|
||||
#core_debug:DEFINES += "_ITERATOR_DEBUG_LEVEL=0"
|
||||
}
|
||||
@ -199,6 +209,25 @@ core_win_64 {
|
||||
|
||||
core_linux {
|
||||
DEFINES += LINUX _LINUX
|
||||
|
||||
QMAKE_CUSTOM_SYSROOT = $$(QMAKE_CUSTOM_SYSROOT)
|
||||
QMAKE_CUSTOM_SYSROOT_BIN = $$(QMAKE_CUSTOM_SYSROOT)/usr/bin/
|
||||
|
||||
core_linux_64 {
|
||||
!linux_arm64 { # x86_64
|
||||
QMAKE_CUSTOM_SYSROOT_LIB = $$(QMAKE_CUSTOM_SYSROOT)/usr/lib/x86_64-linux-gnu
|
||||
!isEmpty(QMAKE_CUSTOM_SYSROOT) {
|
||||
message("using custom sysroot $$QMAKE_CUSTOM_SYSROOT")
|
||||
QMAKE_CC = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "gcc")
|
||||
QMAKE_CXX = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
|
||||
QMAKE_LINK = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
|
||||
QMAKE_LINK_SHLIB = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
|
||||
|
||||
QMAKE_CXXFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
QMAKE_LFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
core_linux_host_arm64 {
|
||||
message("build on arm64")
|
||||
@ -211,7 +240,11 @@ core_mac {
|
||||
QMAKE_LFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH
|
||||
|
||||
# xcode15 add new linker
|
||||
QMAKE_LFLAGS += -Wl,-ld_classic
|
||||
greaterThan(QMAKE_XCODE_VERSION, 1499) {
|
||||
QMAKE_LFLAGS += -Wl,-ld_classic
|
||||
} else {
|
||||
CONFIG += c++14
|
||||
}
|
||||
|
||||
QMAKE_CFLAGS += "-Wno-implicit-function-declaration"
|
||||
|
||||
@ -228,8 +261,8 @@ core_linux_clang {
|
||||
# PREFIXES
|
||||
core_windows {
|
||||
CONFIG -= debug_and_release debug_and_release_target
|
||||
QMAKE_CXXFLAGS_RELEASE -= -Zc:strictStrings
|
||||
QMAKE_CXXFLAGS -= -Zc:strictStrings
|
||||
QMAKE_CXXFLAGS_RELEASE += /Zc:strictStrings-
|
||||
QMAKE_CXXFLAGS += /Zc:strictStrings-
|
||||
QMAKE_CXXFLAGS += /MP
|
||||
|
||||
MSVC_VERSION_DETECT = $$(VisualStudioVersion)
|
||||
@ -285,6 +318,9 @@ core_win_32 {
|
||||
core_win_64 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = win_64
|
||||
}
|
||||
core_win_arm64 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = win_arm64
|
||||
}
|
||||
core_linux_32 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = linux_32
|
||||
}
|
||||
@ -311,8 +347,8 @@ linux_arm64 {
|
||||
|
||||
!isEmpty(ARM64_TOOLCHAIN_BIN){
|
||||
!isEmpty(ARM64_TOOLCHAIN_BIN_PREFIX){
|
||||
|
||||
ARM64_TOOLCHAIN_BIN_FULL = $$ARM64_TOOLCHAIN_BIN/$$ARM64_TOOLCHAIN_BIN_PREFIX
|
||||
message("using arm64 toolchain $$ARM64_TOOLCHAIN_BIN")
|
||||
|
||||
QMAKE_CC = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "gcc")
|
||||
QMAKE_CXX = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "g++")
|
||||
@ -572,42 +608,45 @@ core_windows {
|
||||
DEFINES += CRYPTOPP_DISABLE_ASM
|
||||
}
|
||||
|
||||
core_ios:CONFIG+=support_bundle_dylibs
|
||||
core_ios|core_mac {
|
||||
CONFIG += support_bundle_dylibs
|
||||
}
|
||||
|
||||
!support_bundle_dylibs:CONFIG-=bundle_dylibs
|
||||
|
||||
core_ios {
|
||||
bundle_dylibs {
|
||||
plugin {
|
||||
CONFIG -= plugin
|
||||
CONFIG += lib_bundle
|
||||
bundle_dylibs {
|
||||
plugin {
|
||||
CONFIG -= plugin
|
||||
CONFIG += lib_bundle
|
||||
|
||||
QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
|
||||
#QMAKE_LFLAGS += -Xlinker -rpath -Xlinker @executable_path/Frameworks
|
||||
#QMAKE_LFLAGS += -Xlinker -rpath -Xlinker @loader_path/Frameworks
|
||||
QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
|
||||
#QMAKE_LFLAGS += -Xlinker -rpath -Xlinker @executable_path/Frameworks
|
||||
#QMAKE_LFLAGS += -Xlinker -rpath -Xlinker @loader_path/Frameworks
|
||||
|
||||
# correct version to < 256
|
||||
VERSIONS = $$split(VERSION, ".")
|
||||
VERSION_1 = $$member(VERSIONS, 0)
|
||||
VERSION_2 = $$member(VERSIONS, 1)
|
||||
VERSION_3 = $$member(VERSIONS, 2)
|
||||
VERSION_4 = $$member(VERSIONS, 3)
|
||||
# correct version to < 256
|
||||
VERSIONS = $$split(VERSION, ".")
|
||||
VERSION_1 = $$member(VERSIONS, 0)
|
||||
VERSION_2 = $$member(VERSIONS, 1)
|
||||
VERSION_3 = $$member(VERSIONS, 2)
|
||||
VERSION_4 = $$member(VERSIONS, 3)
|
||||
|
||||
greaterThan(VERSION_1, 255): VERSION_1 = 255
|
||||
greaterThan(VERSION_2, 255): VERSION_2 = 255
|
||||
greaterThan(VERSION_3, 255): VERSION_3 = 255
|
||||
greaterThan(VERSION_4, 255): VERSION_4 = 255
|
||||
greaterThan(VERSION_1, 255): VERSION_1 = 255
|
||||
greaterThan(VERSION_2, 255): VERSION_2 = 255
|
||||
greaterThan(VERSION_3, 255): VERSION_3 = 255
|
||||
greaterThan(VERSION_4, 255): VERSION_4 = 255
|
||||
|
||||
VERSION_CORRECT = $$VERSION_1
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_2)
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_3)
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_4)
|
||||
VERSION_CORRECT = $$VERSION_1
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_2)
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_3)
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_4)
|
||||
|
||||
VERSION = $$VERSION_CORRECT
|
||||
}
|
||||
VERSION = $$VERSION_CORRECT
|
||||
MAJOR_VERSION = $$VERSION_1
|
||||
# set framework version as A
|
||||
QMAKE_FRAMEWORK_VERSION = A
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1
Common/js/.gitignore
vendored
1
Common/js/.gitignore
vendored
@ -1 +1,2 @@
|
||||
emsdk
|
||||
__pycache__
|
||||
|
||||
@ -506,7 +506,7 @@ namespace NSDirectory
|
||||
rmdir((char*)pUtf8);
|
||||
delete [] pUtf8;
|
||||
|
||||
if (deleteRoot = false)CreateDirectory(strDirectory);
|
||||
if (deleteRoot == false)CreateDirectory(strDirectory);
|
||||
#elif MAC
|
||||
BYTE* pUtf8 = NULL;
|
||||
LONG lLen = 0;
|
||||
@ -514,7 +514,7 @@ namespace NSDirectory
|
||||
rmdir((char*)pUtf8);
|
||||
delete [] pUtf8;
|
||||
|
||||
if (deleteRoot = false)CreateDirectory(strDirectory);
|
||||
if (deleteRoot == false)CreateDirectory(strDirectory);
|
||||
#endif
|
||||
}
|
||||
std::wstring GetFolderPath(const std::wstring& wsFolderPath)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
@ -59,7 +59,7 @@ namespace NSSystemUtils
|
||||
static const wchar_t* gc_EnvLastModifiedBy = L"LAST_MODIFIED_BY";
|
||||
static const wchar_t* gc_EnvModified = L"MODIFIED";
|
||||
static const wchar_t* gc_EnvMemoryLimit = L"X2T_MEMORY_LIMIT";
|
||||
static const wchar_t* gc_EnvMemoryLimitDefault = L"4GiB";
|
||||
static const wchar_t* gc_EnvMemoryLimitDefault = L"3GiB";
|
||||
|
||||
KERNEL_DECL std::string GetEnvVariableA(const std::wstring& strName);
|
||||
KERNEL_DECL std::wstring GetEnvVariable(const std::wstring& strName);
|
||||
|
||||
@ -46,8 +46,10 @@
|
||||
#define CXIMAGE_SUPPORT_PSD 1
|
||||
|
||||
#ifndef BUILDING_WASM_MODULE
|
||||
#define CXIMAGE_SUPPORT_HEIF 1
|
||||
#define CXIMAGE_SUPPORT_RAW 1
|
||||
#else
|
||||
#define CXIMAGE_SUPPORT_HEIF 0
|
||||
#define CXIMAGE_SUPPORT_RAW 0
|
||||
#endif
|
||||
|
||||
|
||||
@ -133,13 +133,17 @@ CXIMAGE_FORMAT_PSD = 20,
|
||||
#if CXIMAGE_SUPPORT_PIC
|
||||
CXIMAGE_FORMAR_PIC = 25,
|
||||
#endif
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
CXIMAGE_FORMAT_HEIF = 26,
|
||||
#endif
|
||||
CMAX_IMAGE_FORMATS = CXIMAGE_SUPPORT_BMP + CXIMAGE_SUPPORT_GIF + CXIMAGE_SUPPORT_JPG +
|
||||
CXIMAGE_SUPPORT_PNG + CXIMAGE_SUPPORT_MNG + CXIMAGE_SUPPORT_ICO +
|
||||
CXIMAGE_SUPPORT_TIF + CXIMAGE_SUPPORT_TGA + CXIMAGE_SUPPORT_PCX +
|
||||
CXIMAGE_SUPPORT_WBMP+ CXIMAGE_SUPPORT_WMF + CXIMAGE_SUPPORT_PIC +
|
||||
CXIMAGE_SUPPORT_JBG + CXIMAGE_SUPPORT_JP2 + CXIMAGE_SUPPORT_JPC +
|
||||
CXIMAGE_SUPPORT_PGX + CXIMAGE_SUPPORT_PNM + CXIMAGE_SUPPORT_RAS +
|
||||
CXIMAGE_SUPPORT_SKA + CXIMAGE_SUPPORT_RAW + CXIMAGE_SUPPORT_PSD + 1
|
||||
CXIMAGE_SUPPORT_SKA + CXIMAGE_SUPPORT_RAW + CXIMAGE_SUPPORT_PSD +
|
||||
CXIMAGE_SUPPORT_HEIF + 1
|
||||
};
|
||||
|
||||
#if CXIMAGE_SUPPORT_EXIF
|
||||
|
||||
@ -23,14 +23,14 @@
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma warning (disable : 4550)
|
||||
|
||||
#pragma warning (disable : 4550)
|
||||
|
||||
/*
|
||||
* TIFF Library
|
||||
*
|
||||
* Read and return a packed RGBA image.
|
||||
*/
|
||||
*/
|
||||
#include "tiffiop.h"
|
||||
#include <stdio.h>
|
||||
|
||||
@ -828,11 +828,12 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
nrowsub = nrow;
|
||||
if ((nrowsub%subsamplingver)!=0)
|
||||
nrowsub+=subsamplingver-nrowsub%subsamplingver;
|
||||
|
||||
if (TIFFReadEncodedStrip(tif,
|
||||
TIFFComputeStrip(tif,row+img->row_offset, 0),
|
||||
buf,
|
||||
((row + img->row_offset)%rowsperstrip + nrowsub) * scanline) < 0
|
||||
&& img->stoponerr)
|
||||
((row + img->row_offset)%rowsperstrip + nrowsub) * scanline) < 0
|
||||
&& img->stoponerr)
|
||||
{
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
@ -23,6 +23,30 @@ public class NativeLibraryLoader {
|
||||
}
|
||||
}
|
||||
|
||||
private static String libPrefix;
|
||||
private static String libExtension;
|
||||
|
||||
private static boolean loadIfExist(String libPath) {
|
||||
File libFile = new File(libPath);
|
||||
if (libFile.exists()) {
|
||||
System.load(libPath);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void load(Path libDirPath, String libName) {
|
||||
String libPath = libDirPath.resolve(libPrefix + libName + libExtension).toString();
|
||||
if (OSChecker.isMac()) {
|
||||
if (!loadIfExist(libPath)) {
|
||||
// if dylib does not exist, load framework library
|
||||
System.load(libDirPath.resolve(libName + ".framework/" + libName).toString());
|
||||
}
|
||||
} else {
|
||||
System.load(libPath);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
Path libDirPath = getLibPath();
|
||||
@ -31,8 +55,8 @@ public class NativeLibraryLoader {
|
||||
System.load(libDirPath.resolve("icudt58.dll").toString());
|
||||
System.load(libDirPath.resolve("icuuc58.dll").toString());
|
||||
} else if (OSChecker.isMac()) {
|
||||
System.load(libDirPath.resolve("libicudata.58.dylib").toString());
|
||||
System.load(libDirPath.resolve("libicuuc.58.dylib").toString());
|
||||
loadIfExist(libDirPath.resolve("libicudata.58.dylib").toString());
|
||||
loadIfExist(libDirPath.resolve("libicuuc.58.dylib").toString());
|
||||
} else if (OSChecker.isLinux()) {
|
||||
System.load(libDirPath.resolve("libicudata.so.58").toString());
|
||||
System.load(libDirPath.resolve("libicuuc.so.58").toString());
|
||||
@ -42,24 +66,25 @@ public class NativeLibraryLoader {
|
||||
|
||||
String[] libs = {"UnicodeConverter", "kernel", "kernel_network", "graphics", "PdfFile", "XpsFile", "DjVuFile", "DocxRenderer", "doctrenderer", "docbuilder.jni"};
|
||||
|
||||
String prefix = "";
|
||||
libPrefix = "";
|
||||
if (OSChecker.isMac() || OSChecker.isLinux()) {
|
||||
prefix = "lib";
|
||||
libPrefix = "lib";
|
||||
}
|
||||
|
||||
String extension = "";
|
||||
libExtension = "";
|
||||
if (OSChecker.isWindows()) {
|
||||
extension = ".dll";
|
||||
libExtension = ".dll";
|
||||
} else if (OSChecker.isMac()) {
|
||||
extension = ".dylib";
|
||||
libExtension = ".dylib";
|
||||
} else {
|
||||
extension = ".so";
|
||||
libExtension = ".so";
|
||||
}
|
||||
|
||||
for (String lib : libs) {
|
||||
System.load(libDirPath.resolve(prefix + lib + extension).toString());
|
||||
load(libDirPath, lib);
|
||||
}
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
throw new RuntimeException("Cannot load dynamic libraries. Check if JAR file is in the same directory as all docbuilder libraries.");
|
||||
}
|
||||
}
|
||||
|
||||
1
DesktopEditor/doctrenderer/docbuilder.net/.gitignore
vendored
Normal file
1
DesktopEditor/doctrenderer/docbuilder.net/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
deploy/
|
||||
@ -24,6 +24,10 @@ def _loadLibrary(path):
|
||||
library_name = 'libdocbuilder.c.so'
|
||||
elif 'darwin' == os_name:
|
||||
library_name = 'libdocbuilder.c.dylib'
|
||||
# if there is no dylib file, get library from framework
|
||||
if not os.path.exists(path + '/' + library_name):
|
||||
path = path + '/docbuilder.c.framework'
|
||||
library_name = 'docbuilder.c'
|
||||
|
||||
_lib = ctypes.CDLL(path + '/' + library_name)
|
||||
|
||||
@ -437,7 +441,7 @@ class CDocBuilderValue:
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_Call6(self._internal, ctypes.c_wchar_p(name), values[0]._internal, values[1]._internal, values[2]._internal, values[3]._internal, values[4]._internal, values[5]._internal)))
|
||||
else:
|
||||
raise TypeError("Call() expects at most 6 arguments")
|
||||
|
||||
|
||||
def append(self, value):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not an array")
|
||||
|
||||
@ -547,6 +547,7 @@ namespace NSDoctRenderer
|
||||
CApplicationFontsWorker oWorker;
|
||||
oWorker.m_bIsUseSystemFonts = m_oParams.m_bIsSystemFonts;
|
||||
oWorker.m_arAdditionalFolders = m_oParams.m_arFontDirs;
|
||||
oWorker.m_arAdditionalFolders.push_back(NSFile::GetProcessDirectory() + L"/fonts");
|
||||
oWorker.m_bIsNeedThumbnails = false;
|
||||
oWorker.m_sDirectory = sDirectory;
|
||||
// это не рабочая папка, где только шрифты
|
||||
|
||||
@ -1853,6 +1853,16 @@ std::vector<std::wstring> CApplicationFonts::GetSetupFontFiles(const bool& bIsUs
|
||||
#if defined(_MAC) && !defined(_IOS)
|
||||
std::vector<std::wstring> _array = NSDirectory::GetFiles(L"/Library/Fonts", true);
|
||||
NSDirectory::GetFiles2(L"/System/Library/Fonts", _array, true);
|
||||
|
||||
std::set<std::wstring> installedList = GetInstalledFontsMac();
|
||||
for (const auto& sysPath : installedList) {
|
||||
if (0 == sysPath.find(L"/System/Library/Fonts/"))
|
||||
continue;
|
||||
if (0 == sysPath.find(L"/Library/Fonts/"))
|
||||
continue;
|
||||
_array.push_back(sysPath);
|
||||
}
|
||||
|
||||
return _array;
|
||||
#endif
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include "FontManager.h"
|
||||
#include <set>
|
||||
|
||||
namespace NSFonts
|
||||
{
|
||||
@ -354,6 +355,10 @@ public:
|
||||
void InitFromReg();
|
||||
#endif
|
||||
|
||||
#if defined(_MAC) && !defined(_IOS)
|
||||
std::set<std::wstring> GetInstalledFontsMac();
|
||||
#endif
|
||||
|
||||
NSFonts::IFontManager* GenerateFontManager();
|
||||
|
||||
std::wstring GetFontBySymbol(int symbol);
|
||||
|
||||
@ -877,6 +877,11 @@ public:
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"PingFang SC", 36));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"PingFang TC", 37));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"PingFang HK", 38));
|
||||
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Heiti SC", 39));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Heiti TC", 40));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Songti SC", 41));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Songti TC", 42));
|
||||
#endif
|
||||
|
||||
NSFonts::CApplicationFontsSymbols oApplicationChecker;
|
||||
@ -1604,6 +1609,14 @@ NSFonts::IApplicationFonts* CApplicationFontsWorker::Check()
|
||||
if (m_sDirectory.empty())
|
||||
return NULL;
|
||||
|
||||
for (std::vector<std::wstring>::iterator i = m_arAdditionalFolders.begin(); i != m_arAdditionalFolders.end(); i++)
|
||||
{
|
||||
if (0 == i->find(L"./"))
|
||||
*i = NSFile::GetProcessDirectory() + L"/" + i->substr(2);
|
||||
else if (0 == i->find(L"../"))
|
||||
*i = NSFile::GetProcessDirectory() + L"/" + *i;
|
||||
}
|
||||
|
||||
std::wstring strAllFontsJSPath = m_sDirectory + L"/AllFonts.js";
|
||||
std::wstring strFontsSelectionBin = m_sDirectory + L"/font_selection.bin";
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
#include <vector>
|
||||
#include "../graphics/pro/Fonts.h"
|
||||
|
||||
#define ONLYOFFICE_FONTS_VERSION 13
|
||||
#define ONLYOFFICE_FONTS_VERSION 14
|
||||
#define ONLYOFFICE_ALL_FONTS_VERSION 2
|
||||
|
||||
class CApplicationFontsWorkerBreaker
|
||||
|
||||
@ -29,37 +29,36 @@
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#include "ApplicationFonts.h"
|
||||
#include "../common/File.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreText/CoreText.h>
|
||||
|
||||
#include "./../WrapperWritingElement.h"
|
||||
#include "./../Limit/FrameShape.h"
|
||||
#include "./../Limit/AlbumLayout.h"
|
||||
|
||||
namespace PPTX
|
||||
std::set<std::wstring> CApplicationFonts::GetInstalledFontsMac()
|
||||
{
|
||||
namespace nsPresentation
|
||||
std::set<std::wstring> paths;
|
||||
|
||||
CFArrayRef fontURLs = CTFontManagerCopyAvailableFontURLs();
|
||||
if (!fontURLs)
|
||||
return paths;
|
||||
|
||||
NSStringEncoding encode = CFStringConvertEncodingToNSStringEncoding (kCFStringEncodingUTF32LE);
|
||||
|
||||
CFIndex count = CFArrayGetCount(fontURLs);
|
||||
for (CFIndex i = 0; i < count; ++i)
|
||||
{
|
||||
class PhotoAlbum : public WrapperWritingElement
|
||||
{
|
||||
public:
|
||||
PPTX_LOGIC_BASE(PhotoAlbum)
|
||||
CFURLRef url = (CFURLRef)CFArrayGetValueAtIndex(fontURLs, i);
|
||||
if (!url)
|
||||
continue;
|
||||
|
||||
public:
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node);
|
||||
virtual std::wstring toXML() const;
|
||||
NSString* nsPath = [(__bridge NSURL *)url path];
|
||||
if (!nsPath)
|
||||
continue;
|
||||
|
||||
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const;
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
|
||||
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
|
||||
|
||||
nullable_bool bw;
|
||||
nullable_limit<Limit::FrameShape> frame;
|
||||
nullable_limit<Limit::AlbumLayout> layout;
|
||||
nullable_bool showCaptions;
|
||||
|
||||
protected:
|
||||
virtual void FillParentPointersForChilds();
|
||||
};
|
||||
} // namespace nsPresentation
|
||||
} // namespace PPTX
|
||||
NSData* pSData = [nsPath dataUsingEncoding: encode];
|
||||
paths.emplace(std::wstring((wchar_t*)[pSData bytes], [pSData length] / sizeof (wchar_t)));
|
||||
}
|
||||
|
||||
CFRelease(fontURLs);
|
||||
return paths;
|
||||
}
|
||||
@ -214,7 +214,7 @@ int CAnnotFieldInfo::GetFlag() const { return m_nFlag; }
|
||||
int CAnnotFieldInfo::GetID() const { return m_nID; }
|
||||
int CAnnotFieldInfo::GetAnnotFlag() const { return m_nAnnotFlag; }
|
||||
int CAnnotFieldInfo::GetPage() const { return m_nPage; }
|
||||
int CAnnotFieldInfo::GetCopyAP() const { return m_nCopyAP; }
|
||||
int CAnnotFieldInfo::GetCopyAP() const { return m_nCopyAP; }
|
||||
void CAnnotFieldInfo::GetBE(BYTE& nS, double& dI) { nS = m_pBE.first; dI = m_pBE.second; }
|
||||
BYTE* CAnnotFieldInfo::GetRender(LONG& nLen)
|
||||
{
|
||||
@ -224,6 +224,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::GetOMetadata() { return m_wsOMetadata; }
|
||||
const std::wstring& CAnnotFieldInfo::GetContents() { return m_wsContents; }
|
||||
const std::vector<double>& CAnnotFieldInfo::GetC() { return m_arrC; }
|
||||
|
||||
@ -362,6 +363,8 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
m_wsOUserID = pReader->ReadString();
|
||||
if (nFlags & (1 << 8))
|
||||
m_nCopyAP = pReader->ReadInt();
|
||||
if (nFlags & (1 << 9))
|
||||
m_wsOMetadata = pReader->ReadString();
|
||||
|
||||
if (IsMarkup())
|
||||
{
|
||||
@ -680,6 +683,7 @@ int CAnnotFieldInfo::CWidgetAnnotPr::GetR() const { return m_nR; }
|
||||
int CAnnotFieldInfo::CWidgetAnnotPr::GetFlag() const { return m_nFlag; }
|
||||
int CAnnotFieldInfo::CWidgetAnnotPr::GetFlags() const { return m_nFlags; }
|
||||
int CAnnotFieldInfo::CWidgetAnnotPr::GetParentID() const { return m_nParentID; }
|
||||
int CAnnotFieldInfo::CWidgetAnnotPr::GetMEOptions() const { return m_nMEOptions; }
|
||||
int CAnnotFieldInfo::CWidgetAnnotPr::GetFontStyle() const { return m_nFontStyle; }
|
||||
double CAnnotFieldInfo::CWidgetAnnotPr::GetFontSize() const { return m_dFS; }
|
||||
double CAnnotFieldInfo::CWidgetAnnotPr::GetFontSizeAP() const { return m_dFSAP; }
|
||||
@ -689,7 +693,6 @@ const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetDV() { return m_wsDV; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetT() { return m_wsT; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetFontName() { return m_wsFN; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetFontKey() { return m_wsFK; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetOMetadata() { return m_wsOMetadata; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CWidgetAnnotPr::GetTC() { return m_arrTC; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CWidgetAnnotPr::GetBC() { return m_arrBC; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CWidgetAnnotPr::GetBG() { return m_arrBG; }
|
||||
@ -890,8 +893,8 @@ void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
|
||||
m_nParentID = pReader->ReadInt();
|
||||
if (nFlags & (1 << 18))
|
||||
m_wsT = pReader->ReadString();
|
||||
if (nFlags & (1 << 20))
|
||||
m_wsOMetadata = pReader->ReadString();
|
||||
if (nFlags & (1 << 21))
|
||||
m_nMEOptions = pReader->ReadInt();
|
||||
|
||||
// Action
|
||||
int nAction = pReader->ReadInt();
|
||||
@ -1143,6 +1146,10 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
|
||||
}
|
||||
if (nFlags & (1 << 9))
|
||||
pParent->nMaxLen = pReader->ReadInt();
|
||||
if (nFlags & (1 << 10))
|
||||
pParent->sTU = pReader->ReadString();
|
||||
if (nFlags & (1 << 11))
|
||||
pParent->nMEOptions = pReader->ReadInt();
|
||||
m_arrParents.push_back(pParent);
|
||||
}
|
||||
|
||||
@ -1151,7 +1158,10 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
std::string sImagePath = pReader->ReadStringA();
|
||||
m_arrButtonImg.push_back(pCorrector->GetImagePath(UTF8_TO_U(sImagePath)));
|
||||
std::wstring sImage = UTF8_TO_U(sImagePath);
|
||||
if (sImagePath.find("data:") != 0 && !sImagePath.empty())
|
||||
sImage = pCorrector->GetImagePath(sImage);
|
||||
m_arrButtonImg.push_back(sImage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -185,6 +185,7 @@ public:
|
||||
int GetFlag() const;
|
||||
int GetFlags() const;
|
||||
int GetParentID() const;
|
||||
int GetMEOptions() const;
|
||||
int GetFontStyle() const;
|
||||
double GetFontSize() const;
|
||||
double GetFontSizeAP() const;
|
||||
@ -194,7 +195,6 @@ public:
|
||||
const std::wstring& GetT();
|
||||
const std::wstring& GetFontName();
|
||||
const std::wstring& GetFontKey();
|
||||
const std::wstring& GetOMetadata();
|
||||
const std::vector<double>& GetTC();
|
||||
const std::vector<double>& GetBC();
|
||||
const std::vector<double>& GetBG();
|
||||
@ -215,6 +215,7 @@ public:
|
||||
int m_nFlag;
|
||||
int m_nFlags;
|
||||
int m_nParentID;
|
||||
int m_nMEOptions;
|
||||
int m_nFontStyle;
|
||||
double m_dFS;
|
||||
double m_dFSAP;
|
||||
@ -224,7 +225,6 @@ public:
|
||||
std::wstring m_wsT;
|
||||
std::wstring m_wsFN;
|
||||
std::wstring m_wsFK;
|
||||
std::wstring m_wsOMetadata;
|
||||
std::vector<double> m_arrTC;
|
||||
std::vector<double> m_arrBC;
|
||||
std::vector<double> m_arrBG;
|
||||
@ -471,6 +471,7 @@ public:
|
||||
const std::wstring& GetNM();
|
||||
const std::wstring& GetLM();
|
||||
const std::wstring& GetOUserID();
|
||||
const std::wstring& GetOMetadata();
|
||||
const std::wstring& GetContents();
|
||||
const std::vector<double>& GetC();
|
||||
|
||||
@ -527,6 +528,7 @@ private:
|
||||
std::wstring m_wsNM;
|
||||
std::wstring m_wsLM;
|
||||
std::wstring m_wsOUserID;
|
||||
std::wstring m_wsOMetadata;
|
||||
std::wstring m_wsContents;
|
||||
std::pair<BYTE, double> m_pBE;
|
||||
std::vector<double> m_arrC;
|
||||
@ -571,10 +573,12 @@ public:
|
||||
int nFlags;
|
||||
int nMaxLen;
|
||||
int nParentID;
|
||||
int nMEOptions;
|
||||
int nFieldFlag;
|
||||
std::wstring sName;
|
||||
std::wstring sV;
|
||||
std::wstring sDV;
|
||||
std::wstring sTU;
|
||||
std::vector<int> arrI;
|
||||
std::vector<std::wstring> arrV;
|
||||
std::vector<CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget*> arrAction;
|
||||
|
||||
@ -18,6 +18,12 @@ SOURCES += \
|
||||
$$FONT_ENGINE_PATH/FontPath.cpp \
|
||||
$$FONT_ENGINE_PATH/GlyphString.cpp
|
||||
|
||||
core_mac {
|
||||
OBJECTIVE_SOURCES += $$FONT_ENGINE_PATH/ApplicationFonts_mac.mm
|
||||
LIBS += -framework Foundation
|
||||
LIBS += -framework CoreText
|
||||
}
|
||||
|
||||
# Application fonts worker
|
||||
HEADERS += $$FONT_ENGINE_PATH/ApplicationFontsWorker.h
|
||||
SOURCES += $$FONT_ENGINE_PATH/ApplicationFontsWorker.cpp
|
||||
|
||||
@ -163,7 +163,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../../Common/3dParty/icu/icu/source/common/",
|
||||
"files": ["ucnv.c", "ustr_wcs.cpp", "ucnv_err.c", "ucnv_bld.cpp", "ustrtrns.cpp", "ucnv_cb.c", "udata.cpp", "ucnv_io.cpp", "uhash.c", "udatamem.c", "cmemory.c", "ustring.cpp", "umutex.cpp", "putil.cpp", "ustr_cnv.cpp", "ucnvmbcs.cpp", "ucnvlat1.c", "ucnv_u16.c", "ucnv_u8.c", "ucnv_u32.c", "ucnv_u7.c", "ucln_cmn.cpp", "ucnv2022.cpp", "ucnv_lmb.c", "ucnvhz.c", "ucnvscsu.c", "ucnvisci.c", "ucnvbocu.cpp", "ucnv_ct.c", "ucnv_cnv.c", "stringpiece.cpp", "charstr.cpp", "umapfile.c", "ucmndata.c", "ucnv_ext.cpp", "uobject.cpp", "umath.c", "ubidi_props.c", "uchar.c", "uinvchar.c", "usprep.cpp", "unistr.cpp", "uniset_props.cpp", "loadednormalizer2impl.cpp", "filterednormalizer2.cpp", "utrie2.cpp", "normalizer2.cpp", "normalizer2impl.cpp", "utrie.cpp", "ucase.cpp", "uniset.cpp", "ruleiter.cpp", "parsepos.cpp", "util.cpp", "uprops.cpp", "uvector.cpp", "unames.cpp", "propname.cpp", "utrie2_builder.cpp", "unifunct.cpp", "bmpset.cpp", "unisetspan.cpp", "unifilt.cpp", "patternprops.cpp", "utf_impl.c", "ustrcase.cpp", "cstring.c", "bytestrie.cpp"]
|
||||
"files": ["ustr_wcs.cpp", "ustrtrns.cpp", "udata.cpp", "ucnv_io.cpp", "ustring.cpp", "umutex.cpp", "putil.cpp", "ustr_cnv.cpp", "ucnvmbcs.cpp", "ucln_cmn.cpp", "ucnv2022.cpp", "ucnvbocu.cpp", "stringpiece.cpp", "charstr.cpp", "ucnv_ext.cpp", "uobject.cpp", "usprep.cpp", "unistr.cpp", "uniset_props.cpp", "loadednormalizer2impl.cpp", "filterednormalizer2.cpp", "utrie2.cpp", "normalizer2.cpp", "normalizer2impl.cpp", "utrie.cpp", "ucase.cpp", "uniset.cpp", "ruleiter.cpp", "parsepos.cpp", "util.cpp", "uprops.cpp", "uvector.cpp", "unames.cpp", "propname.cpp", "utrie2_builder.cpp", "unifunct.cpp", "bmpset.cpp", "unisetspan.cpp", "unifilt.cpp", "patternprops.cpp", "ustrcase.cpp", "bytestrie.cpp", "utf_impl.cpp", "cmemory.cpp", "uhash.cpp", "udatamem.cpp", "umapfile.cpp", "uinvchar.cpp", "uchar.cpp", "ubidi_props.cpp", "characterproperties.cpp", "ucptrie.cpp", "edits.cpp", "umutablecptrie.cpp", "bytesinkutil.cpp", "emojiprops.cpp", "cstring.cpp", "ucmndata.cpp", "ucnv.cpp", "ucnv_u7.cpp", "ucnv_u8.cpp", "ucnv_u16.cpp", "ucnv_u32.cpp", "ucnv_err.cpp", "ucnv_cnv.cpp", "ucnv_lmb.cpp", "ucnv_cb.cpp", "ucnv_ct.cpp", "ucharstrieiterator.cpp", "ucnvlat1.cpp", "uvectr32.cpp", "ucnvhz.cpp", "ucnvscsu.cpp", "ucnv_bld.cpp", "ucnvisci.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../Common/3dParty/cryptopp/",
|
||||
|
||||
@ -543,9 +543,10 @@ function readAnnot(reader, rec, readDoubleFunc, readDouble2Func, readStringFunc,
|
||||
// User ID
|
||||
if (flags & (1 << 7))
|
||||
rec["OUserID"] = readStringFunc.call(reader);
|
||||
// User ID
|
||||
if (flags & (1 << 8))
|
||||
rec["AP"]["Copy"] = reader.readInt();
|
||||
// if (flags & (1 << 8))
|
||||
// reader.readInt();
|
||||
if (flags & (1 << 9))
|
||||
rec["meta"] = readStringFunc.call(reader);
|
||||
}
|
||||
function readAnnotAP(reader, AP)
|
||||
{
|
||||
@ -581,7 +582,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
{
|
||||
// Markup
|
||||
let flags = 0;
|
||||
if ((rec["Type"] < 18 && rec["Type"] != 1 && rec["Type"] != 15) || rec["Type"] == 25)
|
||||
if ((rec["type"] < 18 && rec["type"] != 1 && rec["type"] != 15) || rec["type"] == 25)
|
||||
{
|
||||
flags = reader.readInt();
|
||||
if (flags & (1 << 0))
|
||||
@ -636,7 +637,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
rec["Subj"] = readStringFunc.call(reader);
|
||||
}
|
||||
// Text
|
||||
if (rec["Type"] == 0)
|
||||
if (rec["type"] == 0)
|
||||
{
|
||||
// Background color - C->IC
|
||||
if (rec["C"])
|
||||
@ -660,7 +661,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
|
||||
}
|
||||
// Line
|
||||
else if (rec["Type"] == 3)
|
||||
else if (rec["type"] == 3)
|
||||
{
|
||||
// L
|
||||
rec["L"] = [];
|
||||
@ -710,7 +711,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
}
|
||||
}
|
||||
// Ink
|
||||
else if (rec["Type"] == 14)
|
||||
else if (rec["type"] == 14)
|
||||
{
|
||||
// offsets like getStructure and viewer.navigate
|
||||
let n = reader.readInt();
|
||||
@ -724,7 +725,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
}
|
||||
}
|
||||
// Highlight, Underline, Squiggly, Strikeout
|
||||
else if (rec["Type"] > 7 && rec["Type"] < 12)
|
||||
else if (rec["type"] > 7 && rec["type"] < 12)
|
||||
{
|
||||
// QuadPoints
|
||||
let n = reader.readInt();
|
||||
@ -733,7 +734,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
rec["QuadPoints"].push(readDoubleFunc.call(reader));
|
||||
}
|
||||
// Square, Circle
|
||||
else if (rec["Type"] == 4 || rec["Type"] == 5)
|
||||
else if (rec["type"] == 4 || rec["type"] == 5)
|
||||
{
|
||||
// Rect and RD differences
|
||||
if (flags & (1 << 15))
|
||||
@ -752,7 +753,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
}
|
||||
}
|
||||
// Polygon, PolyLine
|
||||
else if (rec["Type"] == 6 || rec["Type"] == 7)
|
||||
else if (rec["type"] == 6 || rec["type"] == 7)
|
||||
{
|
||||
let nVertices = reader.readInt();
|
||||
rec["Vertices"] = [];
|
||||
@ -780,8 +781,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
rec["IT"] = reader.readByte();
|
||||
}
|
||||
// Popup
|
||||
/*
|
||||
else if (rec["Type"] == 15)
|
||||
else if (rec["type"] == 15)
|
||||
{
|
||||
flags = reader.readInt();
|
||||
rec["Open"] = (flags >> 0) & 1;
|
||||
@ -789,9 +789,8 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
if (flags & (1 << 1))
|
||||
rec["PopupParent"] = reader.readInt();
|
||||
}
|
||||
*/
|
||||
// FreeText
|
||||
else if (rec["Type"] == 2)
|
||||
else if (rec["type"] == 2)
|
||||
{
|
||||
// Background color - C->IC
|
||||
if (!isRead && rec["C"])
|
||||
@ -847,7 +846,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
}
|
||||
}
|
||||
// Caret
|
||||
else if (rec["Type"] == 13)
|
||||
else if (rec["type"] == 13)
|
||||
{
|
||||
// Rect and RD differenses
|
||||
if (flags & (1 << 15))
|
||||
@ -862,7 +861,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
rec["Sy"] = reader.readByte();
|
||||
}
|
||||
// FileAttachment
|
||||
else if (rec["Type"] == 16)
|
||||
else if (rec["type"] == 16)
|
||||
{
|
||||
if (flags & (1 << 15))
|
||||
rec["Icon"] = readStringFunc.call(reader);
|
||||
@ -961,7 +960,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
rec["Desc"] = readStringFunc.call(reader);
|
||||
}
|
||||
// Stamp
|
||||
else if (rec["Type"] == 12)
|
||||
else if (rec["type"] == 12)
|
||||
{
|
||||
rec["Icon"] = readStringFunc.call(reader);
|
||||
rec["Rotate"] = readDouble2Func.call(reader);
|
||||
@ -969,6 +968,55 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
for (let i = 0; i < 8; ++i)
|
||||
rec["InRect"].push(readDouble2Func.call(reader));
|
||||
}
|
||||
// Redact
|
||||
else if (rec["type"] == 25)
|
||||
{
|
||||
// QuadPoints
|
||||
if (flags & (1 << 15))
|
||||
{
|
||||
let n = reader.readInt();
|
||||
rec["QuadPoints"] = [];
|
||||
for (let i = 0; i < n; ++i)
|
||||
rec["QuadPoints"].push(readDoubleFunc.call(reader));
|
||||
}
|
||||
// IC
|
||||
if (flags & (1 << 16))
|
||||
{
|
||||
let n = reader.readInt();
|
||||
rec["IC"] = [];
|
||||
for (let i = 0; i < n; ++i)
|
||||
rec["IC"].push(readDouble2Func.call(reader));
|
||||
}
|
||||
// OverlayText
|
||||
if (flags & (1 << 17))
|
||||
rec["OverlayText"] = readStringFunc.call(reader);
|
||||
// Repeat
|
||||
rec["Repeat"] = (flags >> 18) & 1;
|
||||
// Q - alignment
|
||||
if (flags & (1 << 19))
|
||||
{
|
||||
// 0 - left-justified, 1 - centered, 2 - right-justified
|
||||
rec["alignment"] = reader.readByte();
|
||||
}
|
||||
// Font from DA
|
||||
if (flags & (1 << 20))
|
||||
{
|
||||
rec["font"] = {};
|
||||
let n = reader.readInt();
|
||||
rec["font"]["color"] = [];
|
||||
for (let i = 0; i < n; ++i)
|
||||
rec["font"]["color"].push(readDouble2Func.call(reader));
|
||||
rec["font"]["size"] = readDoubleFunc.call(reader);
|
||||
rec["font"]["name"] = readStringFunc.call(reader);
|
||||
if (!isRead)
|
||||
{
|
||||
let fontActual = readStringFunc.call(reader);
|
||||
if (fontActual != "")
|
||||
rec["font"]["actual"] = fontActual;
|
||||
}
|
||||
rec["font"]["style"] = reader.readInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
function readWidgetType(reader, rec, readDoubleFunc, readDouble2Func, readStringFunc, isRead = false)
|
||||
{
|
||||
@ -987,7 +1035,7 @@ function readWidgetType(reader, rec, readDoubleFunc, readDouble2Func, readString
|
||||
rec["font"]["color"].push(readDouble2Func.call(reader));
|
||||
}
|
||||
// 0 - left-justified, 1 - centered, 2 - right-justified
|
||||
if (!isRead || (rec["Type"] != 29 && rec["Type"] != 28 && rec["Type"] != 27))
|
||||
if (!isRead || (rec["type"] != 29 && rec["type"] != 28 && rec["type"] != 27))
|
||||
rec["alignment"] = reader.readByte();
|
||||
rec["flag"] = reader.readInt();
|
||||
// 12.7.3.1
|
||||
@ -1000,7 +1048,7 @@ function readWidgetType(reader, rec, readDoubleFunc, readDouble2Func, readString
|
||||
let flags = reader.readInt();
|
||||
// Alternative field name, used in tooltip and error messages - TU
|
||||
if (flags & (1 << 0))
|
||||
rec["userName"] = readStringFunc.call(reader);
|
||||
rec["tooltip"] = readStringFunc.call(reader);
|
||||
// Default style string (CSS2 format) - DS
|
||||
if (flags & (1 << 1))
|
||||
rec["defaultStyle"] = readStringFunc.call(reader);
|
||||
@ -1044,8 +1092,10 @@ function readWidgetType(reader, rec, readDoubleFunc, readDouble2Func, readString
|
||||
rec["name"] = readStringFunc.call(reader);
|
||||
if (flags & (1 << 19))
|
||||
rec["font"]["AP"] = readStringFunc.call(reader);
|
||||
if (flags & (1 << 20))
|
||||
rec["meta"] = readStringFunc.call(reader);
|
||||
// if (flags & (1 << 20))
|
||||
// readStringFunc.call(reader);
|
||||
if (flags & (1 << 21))
|
||||
rec["MEOptions"] = reader.readInt();
|
||||
// Action
|
||||
let nAction = reader.readInt();
|
||||
if (nAction > 0)
|
||||
@ -1317,6 +1367,10 @@ CFile.prototype["getInteractiveFormsInfo"] = function()
|
||||
}
|
||||
if (flags & (1 << 9))
|
||||
rec["maxLen"] = reader.readInt();
|
||||
if (flags & (1 << 10))
|
||||
rec["tooltip"] = reader.readString();
|
||||
if (flags & (1 << 11))
|
||||
rec["MEOptions"] = reader.readInt();
|
||||
res["Parents"].push(rec);
|
||||
}
|
||||
|
||||
@ -1471,7 +1525,7 @@ CFile.prototype["getAnnotationsInfo"] = function(pageIndex)
|
||||
// 11 - Strikeout, 12 - Stamp, 13 - Caret, 14 - Ink, 15 - Popup, 16 - FileAttachment,
|
||||
// 17 - Sound, 18 - Movie, 19 - Widget, 20 - Screen, 21 - PrinterMark,
|
||||
// 22 - TrapNet, 23 - Watermark, 24 - 3D, 25 - Redact
|
||||
rec["Type"] = reader.readByte();
|
||||
rec["type"] = reader.readByte();
|
||||
// Annot
|
||||
readAnnot(reader, rec, reader.readDouble, reader.readDouble2, reader.readString);
|
||||
// Annot type
|
||||
@ -1528,35 +1582,50 @@ CFile.prototype["readAnnotationsInfoFromBinary"] = function(AnnotInfo)
|
||||
let reader = new CBinaryReader(AnnotInfo, 0, AnnotInfo.length);
|
||||
if (!reader) return [];
|
||||
|
||||
let res = [];
|
||||
let res = { annots:[], imgs:[] };
|
||||
while (reader.isValid())
|
||||
{
|
||||
let nCommand = reader.readByte();
|
||||
let nPos = reader.pos;
|
||||
let nSize = reader.readInt();
|
||||
if (nCommand != 164) // ctAnnotField
|
||||
if (nCommand == 164) // ctAnnotField
|
||||
{
|
||||
let rec = {};
|
||||
// Annotation type
|
||||
// 0 - Text, 1 - Link, 2 - FreeText, 3 - Line, 4 - Square, 5 - Circle,
|
||||
// 6 - Polygon, 7 - PolyLine, 8 - Highlight, 9 - Underline, 10 - Squiggly,
|
||||
// 11 - Strikeout, 12 - Stamp, 13 - Caret, 14 - Ink, 15 - Popup, 16 - FileAttachment,
|
||||
// 17 - Sound, 18 - Movie, 19 - Widget, 20 - Screen, 21 - PrinterMark,
|
||||
// 22 - TrapNet, 23 - Watermark, 24 - 3D, 25 - Redact
|
||||
rec["type"] = reader.readByte();
|
||||
// Annot
|
||||
readAnnot(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true);
|
||||
// Annot type
|
||||
readAnnotType(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true);
|
||||
if (rec["type"] >= 26 && rec["type"] <= 33)
|
||||
{
|
||||
// Widget type
|
||||
readWidgetType(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true);
|
||||
}
|
||||
res.annots.push(rec);
|
||||
}
|
||||
else if (nCommand == 166) // ctWidgetsInfo
|
||||
{
|
||||
reader.readInt(); // CO must be 0
|
||||
reader.readInt(); // Parents must be 0
|
||||
// ButtonImg
|
||||
let n = reader.readInt();
|
||||
for (let i = 0; i < n; ++i)
|
||||
{
|
||||
let data = reader.readString();
|
||||
res.imgs.push(data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.pos = nPos + nSize;
|
||||
continue;
|
||||
}
|
||||
let rec = {};
|
||||
// Annotation type
|
||||
// 0 - Text, 1 - Link, 2 - FreeText, 3 - Line, 4 - Square, 5 - Circle,
|
||||
// 6 - Polygon, 7 - PolyLine, 8 - Highlight, 9 - Underline, 10 - Squiggly,
|
||||
// 11 - Strikeout, 12 - Stamp, 13 - Caret, 14 - Ink, 15 - Popup, 16 - FileAttachment,
|
||||
// 17 - Sound, 18 - Movie, 19 - Widget, 20 - Screen, 21 - PrinterMark,
|
||||
// 22 - TrapNet, 23 - Watermark, 24 - 3D, 25 - Redact
|
||||
rec["Type"] = reader.readByte();
|
||||
// Annot
|
||||
readAnnot(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true);
|
||||
// Annot type
|
||||
readAnnotType(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true);
|
||||
if (rec["Type"] >= 26 && rec["Type"] <= 33)
|
||||
{
|
||||
// Widget type
|
||||
readWidgetType(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true);
|
||||
}
|
||||
res.push(rec);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
@ -278,6 +278,13 @@ void ReadAnnot(BYTE* pWidgets, int& i)
|
||||
std::cout << "User ID " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
|
||||
i += nPathLength;
|
||||
}
|
||||
if (nFlags & (1 << 9))
|
||||
{
|
||||
nPathLength = READ_INT(pWidgets + i);
|
||||
i += 4;
|
||||
std::cout << "OMetadata " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
|
||||
i += nPathLength;
|
||||
}
|
||||
}
|
||||
|
||||
void ReadInteractiveForms(BYTE* pWidgets, int& i)
|
||||
@ -415,6 +422,19 @@ void ReadInteractiveForms(BYTE* pWidgets, int& i)
|
||||
i += 4;
|
||||
std::cout << "MaxLen " << nPathLength << ", ";
|
||||
}
|
||||
if (nFlags & (1 << 10))
|
||||
{
|
||||
nPathLength = READ_INT(pWidgets + i);
|
||||
i += 4;
|
||||
std::cout << "TU " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
|
||||
i += nPathLength;
|
||||
}
|
||||
if (nFlags & (1 << 11))
|
||||
{
|
||||
nPathLength = READ_INT(pWidgets + i);
|
||||
i += 4;
|
||||
std::cout << "MEOptions " << nPathLength << ", ";
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
}
|
||||
@ -574,12 +594,11 @@ void ReadInteractiveForms(BYTE* pWidgets, int& i)
|
||||
std::cout << "Font button " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
|
||||
i += nPathLength;
|
||||
}
|
||||
if (nFlags & (1 << 20))
|
||||
if (nFlags & (1 << 21))
|
||||
{
|
||||
nPathLength = READ_INT(pWidgets + i);
|
||||
i += 4;
|
||||
std::cout << "OMetadata " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
|
||||
i += nPathLength;
|
||||
std::cout << "MEOptions " << nPathLength << ", ";
|
||||
}
|
||||
|
||||
//Action
|
||||
@ -2036,6 +2055,83 @@ int main(int argc, char* argv[])
|
||||
i += 4;
|
||||
std::cout << "Y4 " << (double)nPathLength / 10000.0 << ", ";
|
||||
}
|
||||
else if (sType == "Redact")
|
||||
{
|
||||
if (nFlags & (1 << 15))
|
||||
{
|
||||
std::cout << "QuadPoints";
|
||||
int nQuadPointsLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
|
||||
for (int j = 0; j < nQuadPointsLength; ++j)
|
||||
{
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << " " << (double)nPathLength / 100.0;
|
||||
}
|
||||
std::cout << ", ";
|
||||
}
|
||||
if (nFlags & (1 << 16))
|
||||
{
|
||||
int nICLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << "IC ";
|
||||
|
||||
for (int j = 0; j < nICLength; ++j)
|
||||
{
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << (double)nPathLength / 10000.0 << " ";
|
||||
}
|
||||
std::cout << ", ";
|
||||
}
|
||||
if (nFlags & (1 << 17))
|
||||
{
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << "OverlayText " << std::string((char*)(pAnnots + i), nPathLength) << ", ";
|
||||
i += nPathLength;
|
||||
}
|
||||
if (nFlags & (1 << 18))
|
||||
std::cout << "Repeat true, ";
|
||||
else
|
||||
std::cout << "Repeat false, ";
|
||||
if (nFlags & (1 << 19))
|
||||
{
|
||||
std::string arrQ[] = {"left-justified", "centered", "right-justified"};
|
||||
nPathLength = READ_BYTE(pAnnots + i);
|
||||
i += 1;
|
||||
std::cout << "Q " << arrQ[nPathLength] << ", ";
|
||||
}
|
||||
if (nFlags & (1 << 20))
|
||||
{
|
||||
int nICLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << "DA color ";
|
||||
|
||||
for (int j = 0; j < nICLength; ++j)
|
||||
{
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << (double)nPathLength / 10000.0 << " ";
|
||||
}
|
||||
std::cout << ", size ";
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << (double)nPathLength / 100.0 << ", font ";
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << std::string((char*)(pAnnots + i), nPathLength) << " actual ";
|
||||
i += nPathLength;
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << std::string((char*)(pAnnots + i), nPathLength) << ", style ";
|
||||
i += nPathLength;
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << nPathLength << ", ";
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << std::endl << "]" << std::endl;
|
||||
}
|
||||
|
||||
@ -14,13 +14,15 @@ DEFINES += \
|
||||
MNG_STORE_CHUNKS\
|
||||
MNG_ERROR_TELLTALE
|
||||
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/heif/heif.pri)
|
||||
|
||||
core_linux {
|
||||
DEFINES += HAVE_UNISTD_H HAVE_FCNTL_H
|
||||
QMAKE_CXXFLAGS += -Wno-narrowing
|
||||
}
|
||||
|
||||
core_linux_clang {
|
||||
QMAKE_CFLAGS += -Wno-incompatible-function-pointer-types
|
||||
QMAKE_CFLAGS += -Wno-incompatible-function-pointer-types
|
||||
}
|
||||
|
||||
core_mac {
|
||||
@ -285,6 +287,9 @@ SOURCES += \
|
||||
$$LIB_GRAPHICS_PRI_PATH/raster/PICT/PICFile.cpp \
|
||||
$$LIB_GRAPHICS_PRI_PATH/raster/PICT/pic.cpp
|
||||
|
||||
SOURCES += \
|
||||
$$LIB_GRAPHICS_PRI_PATH/raster/heif/heif.cpp
|
||||
|
||||
SOURCES += \
|
||||
$$LIB_GRAPHICS_PRI_PATH/cximage/jasper/base/jas_cm.c \
|
||||
$$LIB_GRAPHICS_PRI_PATH/cximage/jasper/base/jas_debug.c \
|
||||
|
||||
9
DesktopEditor/graphics/tests/testHeic/main.cpp
Normal file
9
DesktopEditor/graphics/tests/testHeic/main.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include "../../pro/Graphics.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Aggplus::CImage img(L"C:\\Users\\KProkhorov\\Work\\core\\DesktopEditor\\graphics\\tests\\testHeic\\image1.heic");
|
||||
img.SaveFile(L"C:\\Users\\KProkhorov\\Work\\core\\DesktopEditor\\graphics\\tests\\testHeic\\image1.bmp", 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
24
DesktopEditor/graphics/tests/testHeic/testHeic.pro
Normal file
24
DesktopEditor/graphics/tests/testHeic/testHeic.pro
Normal file
@ -0,0 +1,24 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
TARGET = test
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
|
||||
ADD_DEPENDENCY(kernel, graphics, UnicodeConverter)
|
||||
|
||||
GRAPHICS_AGG_PATH = $$PWD/../../../agg-2.4
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$GRAPHICS_AGG_PATH/include
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
DESTDIR = $$PWD_ROOT_DIR/build/$$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX
|
||||
@ -44,6 +44,10 @@
|
||||
#include "PICT/PICFile.h"
|
||||
#endif
|
||||
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
#include "heif/heif.h"
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#define BGRA_FRAME_CXIMAGE_MAX_MEMORY 67108864 // 256Mb (*4 channel)
|
||||
|
||||
@ -444,11 +448,18 @@ bool CBgraFrame::OpenFile(const std::wstring& strFileName, unsigned int nFileTyp
|
||||
#endif
|
||||
|
||||
#if CXIMAGE_SUPPORT_PIC
|
||||
if (CXIMAGE_FORMAR_PIC == m_nFileType)
|
||||
{
|
||||
PICT::CPictFile PIC;
|
||||
return PIC.Open(this, strFileName, !m_bIsRGBA);
|
||||
}
|
||||
if (CXIMAGE_FORMAR_PIC == m_nFileType)
|
||||
{
|
||||
PICT::CPictFile PIC;
|
||||
return PIC.Open(this, strFileName, !m_bIsRGBA);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
if (CXIMAGE_FORMAT_HEIF == m_nFileType)
|
||||
{
|
||||
return NSHeif::CHeifFile::Open(this, strFileName);
|
||||
}
|
||||
#endif
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
@ -534,6 +545,13 @@ bool CBgraFrame::Decode(BYTE* pBuffer, int nSize, unsigned int nFileType)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
if (CXIMAGE_FORMAT_HEIF == m_nFileType)
|
||||
{
|
||||
return NSHeif::CHeifFile::Open(this, pBuffer, nSize);
|
||||
}
|
||||
#endif
|
||||
|
||||
CxImage img;
|
||||
|
||||
if (!img.Decode(pBuffer, nSize, m_nFileType))
|
||||
@ -562,28 +580,32 @@ bool CBgraFrame::SaveFile(const std::wstring& strFileName, unsigned int nFileTyp
|
||||
|
||||
return res;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
if (CXIMAGE_FORMAT_HEIF == nFileType)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (!oFile.CreateFileW(strFileName))
|
||||
return false;
|
||||
|
||||
CxImage img;
|
||||
|
||||
if (!img.CreateFromArray(m_pData, m_lWidth, m_lHeight, lBitsPerPixel * 8, lStride, (m_lStride >= 0) ? true : false, !m_bIsRGBA))
|
||||
return false;
|
||||
|
||||
if (m_pPalette)
|
||||
{
|
||||
img.SetPalette((RGBQUAD*)m_pPalette, m_lPaletteColors);
|
||||
}
|
||||
|
||||
if (!img.Encode(oFile.GetFileNative(), nFileType))
|
||||
return false;
|
||||
|
||||
oFile.CloseFile();
|
||||
return NSHeif::CHeifFile::Save(m_pData, m_lWidth, m_lHeight, m_lStride, strFileName);
|
||||
}
|
||||
#endif
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
if (!oFile.CreateFileW(strFileName))
|
||||
return false;
|
||||
|
||||
CxImage img;
|
||||
|
||||
if (!img.CreateFromArray(m_pData, m_lWidth, m_lHeight, lBitsPerPixel * 8, lStride, (m_lStride >= 0) ? true : false, !m_bIsRGBA))
|
||||
return false;
|
||||
|
||||
if (m_pPalette)
|
||||
{
|
||||
img.SetPalette((RGBQUAD*)m_pPalette, m_lPaletteColors);
|
||||
}
|
||||
|
||||
if (!img.Encode(oFile.GetFileNative(), nFileType))
|
||||
return false;
|
||||
|
||||
oFile.CloseFile();
|
||||
return true;
|
||||
}
|
||||
bool CBgraFrame::Encode(BYTE*& pBuffer, int& nSize, unsigned int nFileType)
|
||||
|
||||
@ -32,6 +32,9 @@
|
||||
#include "ImageFileFormatChecker.h"
|
||||
#include "../common/File.h"
|
||||
#include "../cximage/CxImage/ximacfg.h"
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
#include "heif/heif.h"
|
||||
#endif
|
||||
|
||||
#ifndef IMAGE_CHECKER_DISABLE_XML
|
||||
#include "../xml/include/xmlutils.h"
|
||||
@ -432,6 +435,15 @@ bool CImageFileFormatChecker::isPicFile(BYTE *pBuffer, DWORD dwBytes)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CImageFileFormatChecker::isHeifFile(BYTE* pBuffer, DWORD dwBytes)
|
||||
{
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
return NSHeif::CHeifFile::isHeif(pBuffer, dwBytes);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool CImageFileFormatChecker::isImageFile(const std::wstring& fileName)
|
||||
{
|
||||
@ -554,6 +566,10 @@ bool CImageFileFormatChecker::isImageFile(const std::wstring& fileName)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_PIC;
|
||||
}
|
||||
else if (isHeifFile(fileName))
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_HEIF;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
delete [] buffer;
|
||||
|
||||
@ -669,6 +685,10 @@ bool CImageFileFormatChecker::isImageFile(BYTE* buffer, DWORD sizeRead)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_PIC;
|
||||
}
|
||||
if (isHeifFile(buffer, sizeRead))
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_HEIF;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
if (eFileType) return true;
|
||||
return false;
|
||||
@ -786,6 +806,14 @@ bool CImageFileFormatChecker::isSvgFile(const std::wstring& fileName)
|
||||
return bFind;
|
||||
#endif
|
||||
}
|
||||
bool CImageFileFormatChecker::isHeifFile(const std::wstring& fileName)
|
||||
{
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
return NSHeif::CHeifFile::isHeif(fileName);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::wstring CImageFileFormatChecker::DetectFormatByData(BYTE *Data, int DataSize)
|
||||
{
|
||||
|
||||
@ -63,6 +63,7 @@ enum __ENUM_CXIMAGE_FORMATS
|
||||
_CXIMAGE_FORMAT_SVM = 23,
|
||||
_CXIMAGE_FORMAT_SVG = 24,
|
||||
_CXIMAGE_FORMAT_PIC = 25,
|
||||
_CXIMAGE_FORMAT_HEIF = 26,
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CImageFileFormatChecker
|
||||
@ -82,6 +83,7 @@ public:
|
||||
|
||||
bool isRawFile(const std::wstring& fileName);
|
||||
bool isSvgFile(const std::wstring& fileName);
|
||||
bool isHeifFile(const std::wstring& fileName);
|
||||
|
||||
bool isImageFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
bool isBmpFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
@ -111,6 +113,7 @@ public:
|
||||
bool isSvgFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
bool isRawFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
bool isPicFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
bool isHeifFile(BYTE* pBuffer, DWORD dwBytes);
|
||||
|
||||
std::wstring DetectFormatByData(BYTE *Data, int DataSize);
|
||||
|
||||
|
||||
@ -260,6 +260,8 @@ namespace SVG
|
||||
{
|
||||
oSecondPoint = Point{arValues[arValues.size() - 2], arValues[arValues.size() - 1]};
|
||||
|
||||
arValues.erase(arValues.end() - 2, arValues.end());
|
||||
|
||||
return new CLineElement(oSecondPoint + oTranslatePoint);
|
||||
}
|
||||
|
||||
|
||||
154
DesktopEditor/raster/heif/heif.cpp
Normal file
154
DesktopEditor/raster/heif/heif.cpp
Normal file
@ -0,0 +1,154 @@
|
||||
#include "heif.h"
|
||||
#include "../../common/File.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
#define CONCAT_IMPL(x, y) x##y
|
||||
#define CONCAT(x, y) CONCAT_IMPL(x, y)
|
||||
#define defer(code) Defer CONCAT(_defer_, __COUNTER__)([&](){code;})
|
||||
|
||||
class Defer {
|
||||
std::function<void()> func;
|
||||
public:
|
||||
explicit Defer(std::function<void()> func) : func(func) {}
|
||||
~Defer() { func(); }
|
||||
};
|
||||
|
||||
namespace NSHeif {
|
||||
NSUnicodeConverter::CUnicodeConverter CHeifFile::m_oConverter{};
|
||||
|
||||
bool CHeifFile::isHeif(const std::wstring& fileName)
|
||||
{
|
||||
heif_context* ctx = heif_context_alloc();
|
||||
defer(heif_context_free(ctx););
|
||||
return !IsError(heif_context_read_from_file(ctx, m_oConverter.fromUnicode(fileName, "UTF-8").c_str(), nullptr));
|
||||
}
|
||||
|
||||
bool CHeifFile::isHeif(BYTE* buffer, DWORD size)
|
||||
{
|
||||
heif_context* ctx = heif_context_alloc();
|
||||
defer(heif_context_free(ctx););
|
||||
return !IsError(heif_context_read_from_memory_without_copy(ctx, buffer, size, nullptr));
|
||||
}
|
||||
|
||||
bool CHeifFile::Open(CBgraFrame *frame, const std::wstring& fileName)
|
||||
{
|
||||
heif_context* ctx = heif_context_alloc();
|
||||
defer(heif_context_free(ctx););
|
||||
if (IsError(heif_context_read_from_file(ctx, m_oConverter.fromUnicode(fileName, "UTF-8").c_str(), nullptr)))
|
||||
return false;
|
||||
return Decode(ctx, frame);
|
||||
}
|
||||
|
||||
bool CHeifFile::Open(CBgraFrame *frame, BYTE* buffer, DWORD size)
|
||||
{
|
||||
heif_context* ctx = heif_context_alloc();
|
||||
defer(heif_context_free(ctx););
|
||||
if (IsError(heif_context_read_from_memory_without_copy(ctx, buffer, size, nullptr)))
|
||||
return false;
|
||||
return Decode(ctx, frame);
|
||||
}
|
||||
|
||||
bool CHeifFile::Save(const BYTE* source, int width, int height, int sourceStride, const std::wstring& dstPath)
|
||||
{
|
||||
if (!source)
|
||||
return false;
|
||||
|
||||
heif_image* img;
|
||||
defer(heif_image_release(img););
|
||||
|
||||
if (IsError(heif_image_create(width, height, heif_colorspace_RGB, heif_chroma_interleaved_RGB, &img)))
|
||||
return false;
|
||||
|
||||
if (IsError(heif_image_add_plane(img, heif_channel_interleaved, width, height, 24)))
|
||||
return false;
|
||||
|
||||
int stride;
|
||||
BYTE* data = heif_image_get_plane(img, heif_channel_interleaved, &stride);
|
||||
|
||||
if (!data || stride == 0)
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < height; ++i)
|
||||
{
|
||||
const BYTE* row = source + (height - i - 1) * (sourceStride < 0 ? -sourceStride : sourceStride);
|
||||
for (size_t j = 0; j < width; ++j)
|
||||
{
|
||||
data[(i * width + j) * 3 + 0] = row[(width - j - 1) * 4 + 2];
|
||||
data[(i * width + j) * 3 + 1] = row[(width - j - 1) * 4 + 1];
|
||||
data[(i * width + j) * 3 + 2] = row[(width - j - 1) * 4 + 0];
|
||||
}
|
||||
}
|
||||
|
||||
heif_context* ctx = heif_context_alloc();
|
||||
defer(heif_context_free(ctx););
|
||||
|
||||
heif_encoder* encoder;
|
||||
defer(heif_encoder_release(encoder););
|
||||
|
||||
if (IsError(heif_context_get_encoder_for_format(ctx, heif_compression_HEVC, &encoder)))
|
||||
return false;
|
||||
|
||||
if (IsError(heif_context_encode_image(ctx, img, encoder, nullptr, nullptr)))
|
||||
return false;
|
||||
|
||||
if (IsError(heif_context_write_to_file(ctx, m_oConverter.fromUnicode(dstPath, "UTF-8").c_str())))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool CHeifFile::IsError(heif_error err)
|
||||
{
|
||||
return err.code != heif_error_Ok;
|
||||
}
|
||||
|
||||
inline bool CHeifFile::Decode(heif_context* ctx, CBgraFrame* frame)
|
||||
{
|
||||
heif_image_handle* handle;
|
||||
defer(heif_image_handle_release(handle););
|
||||
|
||||
if (IsError(heif_context_get_primary_image_handle(ctx, &handle)))
|
||||
return false;
|
||||
|
||||
heif_image* img;
|
||||
defer(heif_image_release(img););
|
||||
|
||||
if (IsError(heif_decode_image(handle, &img, heif_colorspace_RGB, heif_chroma_444, nullptr)))
|
||||
return false;
|
||||
|
||||
int width = heif_image_get_primary_width(img);
|
||||
int height = heif_image_get_primary_height(img);
|
||||
|
||||
int stride_R, stride_G, stride_B;
|
||||
const BYTE* source_R = heif_image_get_plane_readonly(img, heif_channel_R, &stride_R);
|
||||
const BYTE* source_G = heif_image_get_plane_readonly(img, heif_channel_G, &stride_G);
|
||||
const BYTE* source_B = heif_image_get_plane_readonly(img, heif_channel_B, &stride_B);
|
||||
|
||||
if (stride_R == 0 || !source_R)
|
||||
return false;
|
||||
|
||||
BYTE* data = new BYTE[4 * width * height];
|
||||
|
||||
frame->put_Width(width);
|
||||
frame->put_Height(height);
|
||||
frame->put_Stride(4 * width);
|
||||
frame->put_Data(data);
|
||||
|
||||
for (size_t i = 0; i < height; ++i)
|
||||
{
|
||||
const BYTE* row_R = source_R + i * stride_R;
|
||||
const BYTE* row_G = source_G + i * stride_G;
|
||||
const BYTE* row_B = source_B + i * stride_B;
|
||||
for (size_t j = 0; j < width; ++j)
|
||||
{
|
||||
data[(i * width + j) * 4 + 0] = row_B[j];
|
||||
data[(i * width + j) * 4 + 1] = row_G[j];
|
||||
data[(i * width + j) * 4 + 2] = row_R[j];
|
||||
data[(i * width + j) * 4 + 3] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
22
DesktopEditor/raster/heif/heif.h
Normal file
22
DesktopEditor/raster/heif/heif.h
Normal file
@ -0,0 +1,22 @@
|
||||
#include "../BgraFrame.h"
|
||||
#include "../../Common/3dParty/heif/libheif/libheif/api/libheif/heif.h"
|
||||
#include "../../UnicodeConverter/UnicodeConverter.h"
|
||||
|
||||
namespace NSHeif {
|
||||
class GRAPHICS_DECL CHeifFile {
|
||||
private:
|
||||
CHeifFile() = delete;
|
||||
public:
|
||||
static bool isHeif(const std::wstring& fileName);
|
||||
static bool isHeif(BYTE* buffer, DWORD size);
|
||||
|
||||
static bool Open(CBgraFrame* frame, const std::wstring& fileName);
|
||||
static bool Open(CBgraFrame* frame, BYTE* buffer, DWORD size);
|
||||
static bool Save(const BYTE* source, int width, int height, int sourceStride, const std::wstring& dstPath);
|
||||
|
||||
private:
|
||||
static bool IsError(heif_error err);
|
||||
static bool Decode(heif_context* ctx, CBgraFrame* frame);
|
||||
static NSUnicodeConverter::CUnicodeConverter m_oConverter;
|
||||
};
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
@ -33,13 +33,17 @@
|
||||
|
||||
namespace NSDocxRenderer
|
||||
{
|
||||
/**
|
||||
* @enum TextAssociationType
|
||||
* @brief Specifies how extracted text is associated with layout elements.
|
||||
*/
|
||||
enum class TextAssociationType
|
||||
{
|
||||
tatBlockChar = 0, // Каждый символ во фрейме
|
||||
tatBlockLine = 1, // Каждая линия - параграф во фрейме. Линии могут объединяться в рамках одного блока.
|
||||
tatPlainLine = 2, // Каждая линия - параграф обычный
|
||||
tatShapeLine = 3, // Каждая линия - параграф в шейпе. Линии могут объединяться в рамках одного блока.
|
||||
tatPlainParagraph = 4, // Все линии объединяются в параграфы
|
||||
tatParagraphToShape = 5 // Параграфы записываем в шейпы
|
||||
tatBlockChar = 0, ///< Each character is placed in a frame.
|
||||
tatBlockLine = 1, ///< Each line becomes a paragraph in a frame; lines may merge within one block.
|
||||
tatPlainLine = 2, ///< Each line becomes a regular paragraph.
|
||||
tatShapeLine = 3, ///< Each line becomes a paragraph in a shape; lines may merge within one block.
|
||||
tatPlainParagraph = 4, ///< All lines are grouped into paragraphs.
|
||||
tatParagraphToShape = 5 ///< Paragraphs are written into shapes.
|
||||
};
|
||||
}
|
||||
|
||||
@ -99,8 +99,8 @@ SOURCES += \
|
||||
HEADERS += \
|
||||
HWPFile.h \
|
||||
HwpDoc/Common/Common.h \
|
||||
HwpDoc/Common/XMLNode.h \
|
||||
HwpDoc/Common/WriterContext.h \
|
||||
HwpDoc/Common/XMLReader.h \
|
||||
HwpDoc/Conversion/ConversionState.h \
|
||||
HwpDoc/Conversion/Converter2OOXML.h \
|
||||
HwpDoc/Conversion/FootnoteConverter.h \
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
#ifndef XMLNODEH_H
|
||||
#define XMLNODEH_H
|
||||
|
||||
#include "../../../DesktopEditor/xml/include/xmlutils.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
class CXMLNode : public XmlUtils::CXmlNode
|
||||
{
|
||||
public:
|
||||
CXMLNode();
|
||||
CXMLNode(const XmlUtils::CXmlNode& oNode);
|
||||
|
||||
bool GetAttributeBool(const std::wstring& wsName);
|
||||
int GetAttributeColor(const std::wstring& wsName, const int& _default = 0x00000000);
|
||||
CXMLNode GetChild(const std::wstring& wsName);
|
||||
std::vector<CXMLNode> GetChilds();
|
||||
std::vector<CXMLNode> GetChilds(const std::wstring& wsName);
|
||||
};
|
||||
|
||||
int ConvertWidthToHWP(const std::wstring& wsValue);
|
||||
int ConvertHexToInt(const std::string& wsValue, const int& _default = 0x00000000);
|
||||
}
|
||||
|
||||
#endif // XMLNODEH_H
|
||||
@ -1,86 +1,300 @@
|
||||
#include "XMLNode.h"
|
||||
#include "XMLReader.h"
|
||||
#include <cmath>
|
||||
#include <cctype>
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
CXMLNode::CXMLNode()
|
||||
: XmlUtils::CXmlNode()
|
||||
CXMLReader::CXMLReader()
|
||||
: m_pReader(new XmlUtils::CXmlLiteReader), m_bParseAttribute(false)
|
||||
{}
|
||||
|
||||
CXMLNode::CXMLNode(const CXmlNode& oNode)
|
||||
: XmlUtils::CXmlNode(oNode)
|
||||
{}
|
||||
|
||||
bool CXMLNode::GetAttributeBool(const std::wstring& wsName)
|
||||
CXMLReader::~CXMLReader()
|
||||
{
|
||||
return L"1" == XmlUtils::CXmlNode::GetAttribute(wsName, L"0");
|
||||
if (nullptr != m_pReader)
|
||||
delete m_pReader;
|
||||
}
|
||||
|
||||
int CXMLNode::GetAttributeColor(const std::wstring& wsName, const int& _default)
|
||||
XmlUtils::CXmlLiteReader* CXMLReader::GetReader()
|
||||
{
|
||||
return ConvertHexToInt(XmlUtils::CXmlNode::GetAttributeA(wsName), _default);
|
||||
return m_pReader;
|
||||
}
|
||||
|
||||
CXMLNode CXMLNode::GetChild(const std::wstring& wsName)
|
||||
unsigned int CXMLReader::GetDepth()
|
||||
{
|
||||
return CXMLNode(XmlUtils::CXmlNode::GetNode(wsName));
|
||||
return (nullptr != m_pReader) ? m_pReader->GetDepth() : 0;
|
||||
}
|
||||
|
||||
std::vector<CXMLNode> CXMLNode::GetChilds()
|
||||
bool CXMLReader::IsEmptyNode()
|
||||
{
|
||||
std::vector<XmlUtils::CXmlNode> arChilds;
|
||||
XmlUtils::CXmlNode::GetChilds(arChilds);
|
||||
|
||||
std::vector<CXMLNode> arNewChilds(arChilds.size());
|
||||
for (unsigned int unIndex = 0; unIndex < arChilds.size(); ++unIndex)
|
||||
arNewChilds[unIndex] = CXMLNode(arChilds[unIndex]);
|
||||
|
||||
return arNewChilds;
|
||||
return (nullptr != m_pReader) ? m_pReader->IsEmptyNode() : true;
|
||||
}
|
||||
|
||||
std::vector<CXMLNode> CXMLNode::GetChilds(const std::wstring& wsName)
|
||||
bool CXMLReader::GetBool()
|
||||
{
|
||||
std::vector<XmlUtils::CXmlNode> arChilds{XmlUtils::CXmlNode::GetNodes(wsName)};
|
||||
|
||||
std::vector<CXMLNode> arNewChilds(arChilds.size());
|
||||
for (unsigned int unIndex = 0; unIndex < arChilds.size(); ++unIndex)
|
||||
arNewChilds[unIndex] = CXMLNode(arChilds[unIndex]);
|
||||
|
||||
return arNewChilds;
|
||||
return "1" == GetTextAValue(*this);
|
||||
}
|
||||
|
||||
int ConvertWidthToHWP(const std::wstring& wsValue)
|
||||
int CXMLReader::GetColor(const int& nDefault)
|
||||
{
|
||||
if (wsValue.empty() || L"0.1" == wsValue || L"0.1 mm" == wsValue)
|
||||
return ConvertHexToInt(GetTextAValue(*this), nDefault);
|
||||
}
|
||||
|
||||
int CXMLReader::GetInt()
|
||||
{
|
||||
return GetIntValue(*this);
|
||||
}
|
||||
|
||||
double CXMLReader::GetDouble()
|
||||
{
|
||||
return GetDoubleValue(*this);
|
||||
}
|
||||
|
||||
std::string CXMLReader::GetTextA()
|
||||
{
|
||||
if (nullptr == m_pReader)
|
||||
return std::string();
|
||||
|
||||
return (m_bParseAttribute) ? m_pReader->GetTextA() : m_pReader->GetText2A();
|
||||
}
|
||||
|
||||
std::wstring CXMLReader::GetText()
|
||||
{
|
||||
if (nullptr == m_pReader)
|
||||
return std::wstring();
|
||||
|
||||
return (m_bParseAttribute) ? m_pReader->GetText() : m_pReader->GetText2();
|
||||
}
|
||||
|
||||
const char* CXMLReader::GetTextChar()
|
||||
{
|
||||
if (nullptr == m_pReader)
|
||||
return "";
|
||||
|
||||
return m_pReader->GetTextChar();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T CXMLReader::GetAttribute(const std::string& sName, T _default, T (*GetValue)(CXMLReader&))
|
||||
{
|
||||
if (!MoveToFirstAttribute())
|
||||
return _default;
|
||||
|
||||
T oValue = _default;
|
||||
|
||||
do
|
||||
{
|
||||
if (sName == m_pReader->GetNameA())
|
||||
{
|
||||
oValue = GetValue(*this);
|
||||
break;
|
||||
}
|
||||
}while(m_pReader->MoveToNextAttribute());
|
||||
|
||||
MoveToElement();
|
||||
|
||||
return oValue;
|
||||
}
|
||||
|
||||
int CXMLReader::GetAttributeInt(const std::string& sName, int nDefault)
|
||||
{
|
||||
return GetAttribute<int>(sName, nDefault, &GetIntValue);
|
||||
}
|
||||
|
||||
bool CXMLReader::GetAttributeBool(const std::string& sName)
|
||||
{
|
||||
return GetAttribute<bool>(sName, false, &GetBoolValue);
|
||||
}
|
||||
|
||||
double CXMLReader::GetAttributeDouble(const std::string& sName)
|
||||
{
|
||||
return GetAttribute<double>(sName, 0., &GetDoubleValue);
|
||||
}
|
||||
|
||||
std::string CXMLReader::GetAttributeA(const std::string& sName)
|
||||
{
|
||||
return GetAttribute<std::string>(sName, "", &GetTextAValue);
|
||||
}
|
||||
|
||||
std::wstring CXMLReader::GetAttribute(const std::string& sName)
|
||||
{
|
||||
return GetAttribute<std::wstring>(sName, L"", &GetTextValue);
|
||||
}
|
||||
|
||||
bool CXMLReader::MoveToFirstAttribute()
|
||||
{
|
||||
if (nullptr == m_pReader || !m_pReader->MoveToFirstAttribute())
|
||||
return false;
|
||||
|
||||
m_bParseAttribute = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CXMLReader::MoveToNextAttribute()
|
||||
{
|
||||
return (nullptr != m_pReader) ? m_pReader->MoveToNextAttribute() : false;
|
||||
}
|
||||
|
||||
bool CXMLReader::MoveToElement()
|
||||
{
|
||||
if (nullptr == m_pReader || !m_pReader->MoveToElement())
|
||||
return false;
|
||||
|
||||
m_bParseAttribute = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::wstring CXMLReader::GetInnerXml()
|
||||
{
|
||||
return m_pReader->GetInnerXml();
|
||||
}
|
||||
|
||||
std::string CXMLReader::GetName()
|
||||
{
|
||||
return (nullptr != m_pReader) ? m_pReader->GetNameA() : std::string();
|
||||
}
|
||||
|
||||
bool CXMLReader::ReadNextSiblingNode(unsigned int unDepth)
|
||||
{
|
||||
return (nullptr != m_pReader) ? m_pReader->ReadNextSiblingNode(unDepth) : false;
|
||||
}
|
||||
|
||||
bool CXMLReader::ReadNextNode()
|
||||
{
|
||||
return (nullptr != m_pReader) ? m_pReader->ReadNextNode() : false;
|
||||
}
|
||||
|
||||
bool CXMLReader::Read(XmlUtils::XmlNodeType& eNodeType)
|
||||
{
|
||||
return (nullptr != m_pReader) ? m_pReader->Read(eNodeType) : false;
|
||||
}
|
||||
|
||||
int CXMLReader::GetIntValue(CXMLReader& oXmlReader)
|
||||
{
|
||||
return std::atoi(oXmlReader.GetTextA().c_str());
|
||||
}
|
||||
|
||||
bool CXMLReader::GetBoolValue(CXMLReader& oXmlReader)
|
||||
{
|
||||
return "1" == oXmlReader.GetTextA();
|
||||
}
|
||||
|
||||
double CXMLReader::GetDoubleValue(CXMLReader& oXmlReader)
|
||||
{
|
||||
const std::string sValue{oXmlReader.GetTextA()};
|
||||
const char* pCur = sValue.c_str();
|
||||
|
||||
while (std::isspace(*pCur))
|
||||
++pCur;
|
||||
|
||||
if (!pCur)
|
||||
return 0.;
|
||||
|
||||
bool bNegative = false;
|
||||
|
||||
while ('-' == *pCur || '+' == *pCur)
|
||||
{
|
||||
if ('-' == *pCur)
|
||||
bNegative = !bNegative;
|
||||
|
||||
++pCur;
|
||||
}
|
||||
|
||||
if (!pCur)
|
||||
return 0.;
|
||||
|
||||
double dResult = 0.;
|
||||
|
||||
while (std::isdigit(*pCur))
|
||||
dResult = dResult * 10. + (*pCur++ - '0');
|
||||
|
||||
if (',' == *pCur || '.' == *pCur)
|
||||
{
|
||||
++pCur;
|
||||
|
||||
double dFraction = 0.0;
|
||||
double dDivisor = 1.0;
|
||||
|
||||
while (std::isdigit(*pCur))
|
||||
{
|
||||
dFraction = dFraction * 10. + (*pCur++ - '0');
|
||||
dDivisor *= 10;
|
||||
}
|
||||
|
||||
dResult += dFraction / dDivisor;
|
||||
}
|
||||
|
||||
if ('e' == *pCur || 'E' == *pCur)
|
||||
{
|
||||
++pCur;
|
||||
|
||||
bool bExpNegative = false;
|
||||
while ('-' == *pCur || '+' == *pCur)
|
||||
{
|
||||
if ('-' == *pCur)
|
||||
bExpNegative = !bExpNegative;
|
||||
|
||||
++pCur;
|
||||
}
|
||||
|
||||
int nExponent = 0;
|
||||
|
||||
while (std::isdigit(*pCur))
|
||||
nExponent = nExponent * 10 + (*pCur++ - '0');
|
||||
|
||||
if (bExpNegative)
|
||||
nExponent = -nExponent;
|
||||
|
||||
dResult *= std::pow(10., nExponent);
|
||||
}
|
||||
|
||||
return bNegative ? -dResult : dResult;
|
||||
}
|
||||
|
||||
std::string CXMLReader::GetTextAValue(CXMLReader& oXmlReader)
|
||||
{
|
||||
return oXmlReader.GetTextA();
|
||||
}
|
||||
|
||||
std::wstring CXMLReader::GetTextValue(CXMLReader& oXmlReader)
|
||||
{
|
||||
return oXmlReader.GetText();
|
||||
}
|
||||
|
||||
int ConvertWidthToHWP(const std::string& sValue)
|
||||
{
|
||||
if (sValue.empty() || "0.1" == sValue || "0.1 mm" == sValue)
|
||||
return 0;
|
||||
else if (L"0.12" == wsValue || L"0.12 mm" == wsValue)
|
||||
else if ("0.12" == sValue || "0.12 mm" == sValue)
|
||||
return 1;
|
||||
else if (L"0.15" == wsValue || L"0.15 mm" == wsValue)
|
||||
else if ("0.15" == sValue || "0.15 mm" == sValue)
|
||||
return 2;
|
||||
else if (L"0.2" == wsValue || L"0.2 mm" == wsValue)
|
||||
else if ("0.2" == sValue || "0.2 mm" == sValue)
|
||||
return 3;
|
||||
else if (L"0.25" == wsValue || L"0.25 mm" == wsValue)
|
||||
else if ("0.25" == sValue || "0.25 mm" == sValue)
|
||||
return 4;
|
||||
else if (L"0.3" == wsValue || L"0.3 mm" == wsValue)
|
||||
else if ("0.3" == sValue || "0.3 mm" == sValue)
|
||||
return 5;
|
||||
else if (L"0.4" == wsValue || L"0.4 mm" == wsValue)
|
||||
else if ("0.4" == sValue || "0.4 mm" == sValue)
|
||||
return 6;
|
||||
else if (L"0.5" == wsValue || L"0.5 mm" == wsValue)
|
||||
else if ("0.5" == sValue || "0.5 mm" == sValue)
|
||||
return 7;
|
||||
else if (L"0.6" == wsValue || L"0.6 mm" == wsValue)
|
||||
else if ("0.6" == sValue || "0.6 mm" == sValue)
|
||||
return 8;
|
||||
else if (L"0.7" == wsValue || L"0.7 mm" == wsValue)
|
||||
else if ("0.7" == sValue || "0.7 mm" == sValue)
|
||||
return 9;
|
||||
else if (L"1.0" == wsValue || L"1.0 mm" == wsValue)
|
||||
else if ("1.0" == sValue || "1.0 mm" == sValue)
|
||||
return 10;
|
||||
else if (L"1.5" == wsValue || L"1.5 mm" == wsValue)
|
||||
else if ("1.5" == sValue || "1.5 mm" == sValue)
|
||||
return 11;
|
||||
else if (L"2.0" == wsValue || L"2.0 mm" == wsValue)
|
||||
else if ("2.0" == sValue || "2.0 mm" == sValue)
|
||||
return 12;
|
||||
else if (L"3.0" == wsValue || L"3.0 mm" == wsValue)
|
||||
else if ("3.0" == sValue || "3.0 mm" == sValue)
|
||||
return 13;
|
||||
else if (L"4.0" == wsValue || L"4.0 mm" == wsValue)
|
||||
else if ("4.0" == sValue || "4.0 mm" == sValue)
|
||||
return 14;
|
||||
else if (L"5.0" == wsValue || L"5.0 mm" == wsValue)
|
||||
else if ("5.0" == sValue || "5.0 mm" == sValue)
|
||||
return 15;
|
||||
|
||||
return 0;
|
||||
|
||||
110
HwpFile/HwpDoc/Common/XMLReader.h
Normal file
110
HwpFile/HwpDoc/Common/XMLReader.h
Normal file
@ -0,0 +1,110 @@
|
||||
#ifndef XMLNODEH_H
|
||||
#define XMLNODEH_H
|
||||
|
||||
#include "../../../DesktopEditor/xml/include/xmlutils.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
class CXMLReader
|
||||
{
|
||||
XmlUtils::CXmlLiteReader *m_pReader;
|
||||
|
||||
bool m_bParseAttribute;
|
||||
public:
|
||||
CXMLReader();
|
||||
~CXMLReader();
|
||||
|
||||
XmlUtils::CXmlLiteReader* GetReader();
|
||||
unsigned int GetDepth();
|
||||
bool IsEmptyNode();
|
||||
|
||||
bool GetBool();
|
||||
int GetColor(const int& nDefault = 0x000000);
|
||||
int GetInt();
|
||||
double GetDouble();
|
||||
std::string GetTextA();
|
||||
std::wstring GetText();
|
||||
const char* GetTextChar();
|
||||
|
||||
int GetAttributeInt(const std::string& sName, int nDefault = 0);
|
||||
bool GetAttributeBool(const std::string& sName);
|
||||
double GetAttributeDouble(const std::string& sName);
|
||||
std::string GetAttributeA(const std::string& sName);
|
||||
std::wstring GetAttribute(const std::string& sName);
|
||||
|
||||
bool MoveToFirstAttribute();
|
||||
bool MoveToNextAttribute();
|
||||
bool MoveToElement();
|
||||
|
||||
std::wstring GetInnerXml();
|
||||
|
||||
std::string GetName();
|
||||
bool ReadNextSiblingNode(unsigned int unDepth);
|
||||
bool ReadNextNode();
|
||||
bool Read(XmlUtils::XmlNodeType& eNodeType);
|
||||
private:
|
||||
static int GetIntValue(CXMLReader& oXmlReader);
|
||||
static bool GetBoolValue(CXMLReader& oXmlReader);
|
||||
static double GetDoubleValue(CXMLReader& oXmlReader);
|
||||
static std::string GetTextAValue(CXMLReader& oXmlReader);
|
||||
static std::wstring GetTextValue(CXMLReader& oXmlReader);
|
||||
|
||||
template<typename T>
|
||||
T GetAttribute(const std::string& sName, T _default, T (*GetValue)(CXMLReader& oXmlReader));
|
||||
};
|
||||
|
||||
#define WHILE_READ_NEXT_NODE_WITH_DEPTH(xml_reader, name_depth)\
|
||||
if (!xml_reader.IsEmptyNode())\
|
||||
{\
|
||||
const int n##name_depth = xml_reader.GetDepth();\
|
||||
while (xml_reader.ReadNextSiblingNode(n##name_depth))\
|
||||
{
|
||||
|
||||
#define WHILE_READ_NEXT_NODE_WITH_DEPTH_AND_NAME(xml_reader, name_depth)\
|
||||
if (!xml_reader.IsEmptyNode())\
|
||||
{\
|
||||
const int n##name_depth##Depth = xml_reader.GetDepth();\
|
||||
std::string sNode##name_depth##Name;\
|
||||
while (xml_reader.ReadNextSiblingNode(n##name_depth##Depth))\
|
||||
{\
|
||||
sNode##name_depth##Name = xml_reader.GetName();
|
||||
|
||||
#define WHILE_READ_NEXT_NODE(xml_reader) WHILE_READ_NEXT_NODE_WITH_DEPTH(xml_reader, Depth)
|
||||
|
||||
#define WHILE_READ_NEXT_NODE_WITH_NAME(xml_reader)\
|
||||
if (!xml_reader.IsEmptyNode())\
|
||||
{\
|
||||
const int nDepth = xml_reader.GetDepth();\
|
||||
std::string sNodeName;\
|
||||
while (xml_reader.ReadNextSiblingNode(nDepth))\
|
||||
{\
|
||||
sNodeName = xml_reader.GetName();
|
||||
|
||||
#define WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(xml_reader, name_depth, node_name)\
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH(xml_reader, name_depth)\
|
||||
if (node_name != xml_reader.GetName())\
|
||||
continue;
|
||||
|
||||
#define WHILE_READ_NEXT_NODE_WITH_ONE_NAME(xml_reader, node_name) WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(xml_reader, Depth, node_name)
|
||||
|
||||
#define END_WHILE } }
|
||||
|
||||
#define START_READ_ATTRIBUTES(xml_reader)\
|
||||
if (xml_reader.MoveToFirstAttribute())\
|
||||
{\
|
||||
std::string sAttributeName;\
|
||||
do\
|
||||
{\
|
||||
sAttributeName = xml_reader.GetName();
|
||||
|
||||
#define END_READ_ATTRIBUTES(xml_reader)\
|
||||
}\
|
||||
while(xml_reader.MoveToNextAttribute());\
|
||||
xml_reader.MoveToElement();\
|
||||
}
|
||||
|
||||
int ConvertWidthToHWP(const std::string& sValue);
|
||||
int ConvertHexToInt(const std::string& sValue, const int& _default = 0x00000000);
|
||||
}
|
||||
|
||||
#endif // XMLNODEH_H
|
||||
@ -321,6 +321,12 @@ void CConverter2OOXML::WriteCharacter(const CCtrlCharacter* pCharacter, short sh
|
||||
oState.m_eBreakType = TConversionState::EBreakType::TextWrapping;
|
||||
break;
|
||||
}
|
||||
case ECtrlCharType::TABULATION:
|
||||
{
|
||||
OpenParagraph(shParaShapeID, shParaStyleID, oBuilder, oState);
|
||||
oBuilder.WriteString(L"<w:r><w:tab/></w:r>");
|
||||
break;
|
||||
}
|
||||
case ECtrlCharType::HARD_HYPHEN:
|
||||
case ECtrlCharType::HARD_SPACE:
|
||||
break;
|
||||
@ -670,6 +676,60 @@ void CConverter2OOXML::WriteParaShapeProperties(short shParaShapeID, short shPar
|
||||
case EHeadingType::NONE:
|
||||
break;
|
||||
}
|
||||
|
||||
if (oState.m_bInTable)
|
||||
return;
|
||||
|
||||
const CHwpRecordTabDef* pTabDef = m_pContext->GetTabDef(pParaShape->GetTabDef());
|
||||
|
||||
if (nullptr != pTabDef && 0 != pTabDef->GetCount())
|
||||
{
|
||||
oBuilder.WriteString(L"<w:tabs>");
|
||||
|
||||
const TTab *pTab = nullptr;
|
||||
for (unsigned int unIndex = 0; unIndex < pTabDef->GetCount(); ++unIndex)
|
||||
{
|
||||
pTab = pTabDef->GetTab(unIndex);
|
||||
|
||||
if (nullptr == pTab)
|
||||
continue;
|
||||
|
||||
oBuilder.WriteString(L"<w:tab w:val=\"");
|
||||
|
||||
switch (pTab->m_eType)
|
||||
{
|
||||
case TTab::EType::LEFT: oBuilder.WriteString(L"start"); break;
|
||||
case TTab::EType::RIGHT: oBuilder.WriteString(L"end"); break;
|
||||
case TTab::EType::CENTER: oBuilder.WriteString(L"center"); break;
|
||||
case TTab::EType::DECIMAL: oBuilder.WriteString(L"decimal"); break;
|
||||
}
|
||||
|
||||
oBuilder.WriteString(L"\" w:leader=\"");
|
||||
|
||||
switch (pTab->m_eLeader)
|
||||
{
|
||||
case ELineStyle2::NONE: oBuilder.WriteString(L"none"); break;
|
||||
case ELineStyle2::SOLID:
|
||||
case ELineStyle2::DOUBLE_SLIM:
|
||||
case ELineStyle2::SLIM_THICK:
|
||||
case ELineStyle2::THICK_SLIM:
|
||||
case ELineStyle2::SLIM_THICK_SLIM:
|
||||
oBuilder.WriteString(L"heavy"); break;
|
||||
case ELineStyle2::DASH:
|
||||
case ELineStyle2::LONG_DASH:
|
||||
case ELineStyle2::DASH_DOT:
|
||||
case ELineStyle2::DASH_DOT_DOT:
|
||||
oBuilder.WriteString(L"hyphen"); break;
|
||||
case ELineStyle2::DOT:
|
||||
case ELineStyle2::CIRCLE:
|
||||
oBuilder.WriteString(L"dot"); break;
|
||||
}
|
||||
|
||||
oBuilder.WriteString(L"\" w:pos=\"" + std::to_wstring(pTab->m_nPos / 10) + L"\"/>");
|
||||
}
|
||||
|
||||
oBuilder.WriteString(L"</w:tabs>");
|
||||
}
|
||||
}
|
||||
|
||||
void CConverter2OOXML::WriteTable(const CCtrlTable* pTable, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
@ -1362,83 +1422,18 @@ bool CConverter2OOXML::SaveSVGFile(const HWP_STRING& sSVG, HWP_STRING& sFileName
|
||||
return false;
|
||||
}
|
||||
|
||||
NSGraphics::IGraphicsRenderer* pGrRenderer = NSGraphics::Create();
|
||||
pGrRenderer->SetFontManager(pSvgReader->get_FontManager());
|
||||
|
||||
double dX, dY, dW, dH;
|
||||
pSvgReader->GetBounds(&dX, &dY, &dW, &dH);
|
||||
|
||||
if (dW < 0) dW = -dW;
|
||||
if (dH < 0) dH = -dH;
|
||||
|
||||
double dOneMaxSize = (double)1000.;
|
||||
|
||||
if (dW > dH && dW > dOneMaxSize)
|
||||
{
|
||||
dH *= (dOneMaxSize / dW);
|
||||
dW = dOneMaxSize;
|
||||
}
|
||||
else if (dH > dW && dH > dOneMaxSize)
|
||||
{
|
||||
dW *= (dOneMaxSize / dH);
|
||||
dH = dOneMaxSize;
|
||||
}
|
||||
|
||||
int nWidth = static_cast<int>(dW + 0.5);
|
||||
int nHeight = static_cast<int>(dH + 0.5);
|
||||
|
||||
double dWidth = 25.4 * nWidth / 96;
|
||||
double dHeight = 25.4 * nHeight / 96;
|
||||
|
||||
unsigned char* pBgraData = (unsigned char*)malloc(nWidth * nHeight * 4);
|
||||
if (!pBgraData)
|
||||
{
|
||||
double dKoef = 2000.0 / (nWidth > nHeight ? nWidth : nHeight);
|
||||
|
||||
nWidth = (int)(dKoef * nWidth);
|
||||
nHeight = (int)(dKoef * nHeight);
|
||||
|
||||
dWidth = 25.4 * nWidth / 96;
|
||||
dHeight = 25.4 * nHeight / 96;
|
||||
|
||||
pBgraData = (unsigned char*)malloc(nWidth * nHeight * 4);
|
||||
}
|
||||
|
||||
if (!pBgraData)
|
||||
return false;
|
||||
|
||||
unsigned int alfa = 0xffffff;
|
||||
//дефолтный тон должен быть прозрачным, а не белым
|
||||
//memset(pBgraData, 0xff, nWidth * nHeight * 4);
|
||||
for (int i = 0; i < nWidth * nHeight; i++)
|
||||
{
|
||||
((unsigned int*)pBgraData)[i] = alfa;
|
||||
}
|
||||
|
||||
CBgraFrame oFrame;
|
||||
oFrame.put_Data(pBgraData);
|
||||
oFrame.put_Width(nWidth);
|
||||
oFrame.put_Height(nHeight);
|
||||
oFrame.put_Stride(-4 * nWidth);
|
||||
|
||||
pGrRenderer->CreateFromBgraFrame(&oFrame);
|
||||
pGrRenderer->SetSwapRGB(false);
|
||||
pGrRenderer->put_Width(dWidth);
|
||||
pGrRenderer->put_Height(dHeight);
|
||||
|
||||
pSvgReader->SetTempDirectory(m_sTempDirectory);
|
||||
pSvgReader->DrawOnRenderer(pGrRenderer, 0, 0, dWidth, dHeight);
|
||||
|
||||
sFileName = sFileName.substr(0, sFileName.find(L'.'));
|
||||
sFileName += L".png";
|
||||
|
||||
oFrame.SaveFile(m_sTempDirectory + L"/word/media/" + sFileName, 4);
|
||||
oFrame.put_Data(NULL);
|
||||
const std::wstring wsImagePath{m_sTempDirectory + L"/word/media/" + sFileName};
|
||||
|
||||
RELEASEINTERFACE(pGrRenderer);
|
||||
|
||||
if (pBgraData)
|
||||
free(pBgraData);
|
||||
pSvgReader->ConvertToRaster(wsImagePath.c_str(), 4, dW, dH);
|
||||
|
||||
RELEASEINTERFACE(pSvgReader);
|
||||
RELEASEINTERFACE(pFonts);
|
||||
|
||||
@ -24,8 +24,6 @@
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
|
||||
|
||||
struct TContentType
|
||||
{
|
||||
HWP_STRING m_wsName;
|
||||
|
||||
@ -182,81 +182,94 @@ bool CHWPDocInfo::Parse(CHWPStream& oBuffer, int nVersion)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CHWPDocInfo::Parse(CXMLNode& oNode, int nVersion)
|
||||
bool CHWPDocInfo::Parse(CXMLReader& oReader, int nVersion)
|
||||
{
|
||||
for (CXMLNode& oChild : oNode.GetChilds())
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if (L"hh:beginNum" == oChild.GetName())
|
||||
m_arRecords.push_back(new CHWPRecordDocumentProperties(*this, oChild, nVersion));
|
||||
else if (L"hh:refList" == oChild.GetName())
|
||||
ReadRefList(oChild, nVersion);
|
||||
if ("hh:beginNum" == sNodeName)
|
||||
m_arRecords.push_back(new CHWPRecordDocumentProperties(*this, oReader, nVersion));
|
||||
else if ("hh:refList" == sNodeName)
|
||||
ReadRefList(oReader, nVersion);
|
||||
}
|
||||
END_WHILE
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CHWPDocInfo::ReadRefList(CXMLNode& oNode, int nVersion)
|
||||
bool CHWPDocInfo::ReadRefList(CXMLReader& oReader, int nVersion)
|
||||
{
|
||||
for (CXMLNode& oChild : oNode.GetChilds())
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if (L"hh:fontfaces" == oChild.GetName())
|
||||
if ("hh:fontfaces" == sNodeName)
|
||||
{
|
||||
for (CXMLNode& oFontFaceNode : oChild.GetChilds(L"hh:fontface"))
|
||||
for (CXMLNode& oFontNode : oFontFaceNode.GetChilds(L"hh:font"))
|
||||
m_arFaseNames.push_back(new CHWPRecordFaceName(*this, oFontNode, nVersion));
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, FontFace, "hh:fontface")
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Font, "hh:font")
|
||||
m_arFaseNames.push_back(new CHWPRecordFaceName(*this, oReader, nVersion));
|
||||
END_WHILE
|
||||
END_WHILE
|
||||
}
|
||||
else if (L"hh:borderFills" == oChild.GetName())
|
||||
else if ("hh:borderFills" == sNodeName)
|
||||
{
|
||||
for (CXMLNode& oBorderFillNode : oChild.GetChilds(L"hh:borderFill"))
|
||||
m_arBorderFills.push_back(new CHWPRecordBorderFill(*this, oBorderFillNode, nVersion));
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, BorderFill, "hh:borderFill")
|
||||
m_arBorderFills.push_back(new CHWPRecordBorderFill(*this, oReader, nVersion));
|
||||
END_WHILE
|
||||
}
|
||||
else if (L"hh:charProperties" == oChild.GetName())
|
||||
else if ("hh:charProperties" == sNodeName)
|
||||
{
|
||||
for (CXMLNode& oCharPrNode : oChild.GetChilds(L"hh:charPr"))
|
||||
m_arCharShapes.push_back(new CHWPRecordCharShape(*this, oCharPrNode, nVersion));
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, CharPr, "hh:charPr")
|
||||
m_arCharShapes.push_back(new CHWPRecordCharShape(*this, oReader, nVersion));
|
||||
END_WHILE
|
||||
}
|
||||
else if (L"hh:tabProperties" == oChild.GetName())
|
||||
else if ("hh:tabProperties" == sNodeName)
|
||||
{
|
||||
for (CXMLNode& oTabPrNode : oChild.GetChilds(L"hh:tabPr"))
|
||||
m_arTabDefs.push_back(new CHwpRecordTabDef(*this, oTabPrNode, nVersion));
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, TabPr, "hh:tabPr")
|
||||
m_arTabDefs.push_back(new CHwpRecordTabDef(*this, oReader, nVersion));
|
||||
END_WHILE
|
||||
}
|
||||
else if (L"hh:numberings" == oChild.GetName())
|
||||
else if ("hh:numberings" == sNodeName)
|
||||
{
|
||||
for (CXMLNode& oNumberingNode : oChild.GetChilds(L"hh:numbering"))
|
||||
m_arNumberings.push_back(new CHWPRecordNumbering(*this, oNumberingNode, nVersion));
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Numbering, "hh:numbering")
|
||||
m_arNumberings.push_back(new CHWPRecordNumbering(*this, oReader, nVersion));
|
||||
END_WHILE
|
||||
}
|
||||
else if (L"hh:bullets" == oChild.GetName())
|
||||
else if ("hh:bullets" == sNodeName)
|
||||
{
|
||||
for (CXMLNode& oBulletNode : oChild.GetChilds())
|
||||
m_arBullets.push_back(new CHWPRecordBullet(*this, oBulletNode, nVersion));
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH(oReader, Bullet)
|
||||
m_arBullets.push_back(new CHWPRecordBullet(*this, oReader, nVersion));
|
||||
END_WHILE
|
||||
}
|
||||
else if (L"hh:paraProperties" == oChild.GetName())
|
||||
else if ("hh:paraProperties" == sNodeName)
|
||||
{
|
||||
for (CXMLNode& oParaPrNode : oChild.GetChilds(L"hh:paraPr"))
|
||||
m_arParaShapes.push_back(new CHWPRecordParaShape(*this, oParaPrNode, nVersion));
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, ParaPr, "hh:paraPr")
|
||||
m_arParaShapes.push_back(new CHWPRecordParaShape(*this, oReader, nVersion));
|
||||
END_WHILE
|
||||
}
|
||||
else if (L"hh:styles" == oChild.GetName())
|
||||
else if ("hh:styles" == sNodeName)
|
||||
{
|
||||
for (CXMLNode& oStyleNode : oChild.GetChilds(L"hh:style"))
|
||||
m_arStyles.push_back(new CHWPRecordStyle(*this, oStyleNode, nVersion));
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Style, "hh:style")
|
||||
m_arStyles.push_back(new CHWPRecordStyle(*this, oReader, nVersion));
|
||||
END_WHILE
|
||||
}
|
||||
}
|
||||
END_WHILE
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CHWPDocInfo::ReadContentHpf(CXMLNode& oNode, int nVersion)
|
||||
bool CHWPDocInfo::ReadContentHpf(CXMLReader& oReader, int nVersion)
|
||||
{
|
||||
CHWPRecordBinData *pRecordBinData = nullptr;
|
||||
|
||||
for (CXMLNode& oChild : oNode.GetChilds(L"opf:manifest"))
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "opf:manifest")
|
||||
{
|
||||
for (CXMLNode& oGrandChild : oChild.GetChilds(L"opf:item"))
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Item, "opf:item")
|
||||
{
|
||||
pRecordBinData = new CHWPRecordBinData(oGrandChild, nVersion);
|
||||
pRecordBinData = new CHWPRecordBinData(oReader, nVersion);
|
||||
m_mBinDatas.insert(std::make_pair<HWP_STRING, CHWPRecord*>(pRecordBinData->GetItemID(), (HWP::CHWPRecord*)pRecordBinData));
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
END_WHILE
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include "HanType.h"
|
||||
#include "HWPStream.h"
|
||||
#include "HWPElements/HWPRecord.h"
|
||||
#include "Common/XMLNode.h"
|
||||
#include "Common/XMLReader.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
@ -46,8 +46,8 @@ public:
|
||||
~CHWPDocInfo();
|
||||
|
||||
bool Parse(CHWPStream& oBuffer, int nVersion);
|
||||
bool Parse(CXMLNode& oNode, int nVersion);
|
||||
bool ReadContentHpf(CXMLNode& oNode, int nVersion);
|
||||
bool Parse(CXMLReader& oReader, int nVersion);
|
||||
bool ReadContentHpf(CXMLReader& oReader, int nVersion);
|
||||
|
||||
const CHWPRecord* GetRecord(int nIndex) const;
|
||||
const CHWPRecord* GetFaceName(int nIndex) const;
|
||||
@ -65,7 +65,7 @@ public:
|
||||
EHanType GetHanType() const;
|
||||
ECompatDoc GetCompatibleDoc() const;
|
||||
private:
|
||||
bool ReadRefList(CXMLNode& oNode, int nVersion);
|
||||
bool ReadRefList(CXMLReader& oReader, int nVersion);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -74,35 +74,41 @@ CHWPRecordBinData::CHWPRecordBinData(CHWPDocInfo& oDocInfo, int nTagNum, int nLe
|
||||
oBuffer.Skip(nSize - oBuffer.GetDistanceToLastPos(true));
|
||||
}
|
||||
|
||||
CHWPRecordBinData::CHWPRecordBinData(CXMLNode& oNode, int nVersion)
|
||||
CHWPRecordBinData::CHWPRecordBinData(CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_BIN_DATA, 0, 0)
|
||||
{
|
||||
m_sItemID = oNode.GetAttribute(L"id");
|
||||
std::string sType;
|
||||
HWP_STRING sSubPath;
|
||||
|
||||
HWP_STRING sType = oNode.GetAttribute(L"isEmbeded");
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("id" == sAttributeName)
|
||||
m_sItemID = oReader.GetText();
|
||||
else if ("isEmbeded" == sAttributeName)
|
||||
sType = oReader.GetTextA();
|
||||
else if ("href" == sAttributeName)
|
||||
m_sAPath = oReader.GetText();
|
||||
else if ("sub-path" == sAttributeName)
|
||||
sSubPath = oReader.GetText();
|
||||
else if ("media-type" == sAttributeName)
|
||||
{
|
||||
m_sFormat = oReader.GetText();
|
||||
|
||||
if (L"0" == sType)
|
||||
std::wregex oRegex(L"image/(.*)");
|
||||
m_sFormat = std::regex_replace(m_sFormat, oRegex, L"$1");
|
||||
}
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
if ("0" == sType)
|
||||
{
|
||||
m_eType = EType::LINK;
|
||||
|
||||
m_sAPath = oNode.GetAttribute(L"sub-path");
|
||||
|
||||
if (m_sAPath.empty())
|
||||
m_sAPath = oNode.GetAttribute(L"href");
|
||||
if (!sSubPath.empty())
|
||||
m_sAPath = sSubPath;
|
||||
}
|
||||
else if (L"1" == sType)
|
||||
{
|
||||
else if ("1" == sType)
|
||||
m_eType = EType::EMBEDDING;
|
||||
m_sAPath = oNode.GetAttribute(L"href");
|
||||
}
|
||||
else
|
||||
m_sAPath = oNode.GetAttribute(L"href");
|
||||
|
||||
m_sFormat = oNode.GetAttribute(L"media-type");
|
||||
|
||||
std::wregex oRegex(L"image/(.*)");
|
||||
|
||||
m_sFormat = std::regex_replace(m_sFormat, oRegex, L"$1");
|
||||
}
|
||||
|
||||
HWP_STRING CHWPRecordBinData::GetPath() const
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include "HWPRecord.h"
|
||||
#include "../HWPStream.h"
|
||||
#include "../HWPDocInfo.h"
|
||||
#include "../Common/XMLNode.h"
|
||||
#include "../Common/XMLReader.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
@ -44,7 +44,7 @@ class CHWPRecordBinData : public CHWPRecord
|
||||
HWP_STRING m_sItemID;
|
||||
public:
|
||||
CHWPRecordBinData(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordBinData(CXMLNode& oNode, int nVersion);
|
||||
CHWPRecordBinData(CXMLReader& oReader, int nVersion);
|
||||
|
||||
HWP_STRING GetPath() const;
|
||||
HWP_STRING GetItemID() const;
|
||||
|
||||
@ -58,19 +58,26 @@ EColorFillPattern GetColorFillPattern(int nPattern)
|
||||
}
|
||||
}
|
||||
|
||||
void TBorder::ReadFromNode(CXMLNode& oNode)
|
||||
void TBorder::Read(CXMLReader& oReader)
|
||||
{
|
||||
m_eStyle = GetLineStyle2(oNode.GetAttribute(L"type"));
|
||||
m_nColor = oNode.GetAttributeColor(L"color");
|
||||
m_chWidth = (HWP_BYTE)ConvertWidthToHWP(oNode.GetAttribute(L"width"));
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("type" == sAttributeName)
|
||||
m_eStyle = GetLineStyle2(oReader.GetText());
|
||||
else if ("color" == sAttributeName)
|
||||
m_nColor = oReader.GetInt();
|
||||
else if ("width" == sAttributeName)
|
||||
m_chWidth = (HWP_BYTE)ConvertWidthToHWP(oReader.GetTextA());
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
|
||||
CFill::CFill()
|
||||
: m_nFillType(0)
|
||||
: m_nFillType(0), m_eHatchStyle(EColorFillPattern::NONE), m_eMode(EImageFillType::NONE), m_chAlpha(0xff)
|
||||
{}
|
||||
|
||||
CFill::CFill(CHWPStream& oBuffer, int nOff, int nSize)
|
||||
: m_nFillType(0)
|
||||
: m_nFillType(0), m_eHatchStyle(EColorFillPattern::NONE), m_eMode(EImageFillType::NONE), m_chAlpha(0xff)
|
||||
{
|
||||
oBuffer.SavePosition();
|
||||
|
||||
@ -147,82 +154,117 @@ CFill::CFill(CHWPStream& oBuffer, int nOff, int nSize)
|
||||
m_nSize = oBuffer.GetDistanceToLastPos(true);
|
||||
}
|
||||
|
||||
CFill::CFill(CXMLNode& oNode)
|
||||
: m_nFillType(0)
|
||||
CFill::CFill(CXMLReader& oReader)
|
||||
: m_nFillType(0), m_eHatchStyle(EColorFillPattern::NONE), m_eMode(EImageFillType::NONE), m_chAlpha(0xff)
|
||||
{
|
||||
for (CXMLNode& oChild : oNode.GetChilds())
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if (L"hc:winBrush" == oChild.GetName())
|
||||
if ("hc:winBrush" == sNodeName)
|
||||
{
|
||||
ReadWinBrush(oChild);
|
||||
ReadWinBrush(oReader);
|
||||
m_nFillType |= 0x01;
|
||||
}
|
||||
else if (L"hc:gradation" == oChild.GetName())
|
||||
else if ("hc:gradation" == sNodeName)
|
||||
{
|
||||
ReadGradation(oChild);
|
||||
ReadGradation(oReader);
|
||||
m_nFillType |= 0x04;
|
||||
}
|
||||
else if (L"hc:imgBrush" == oChild.GetName())
|
||||
else if ("hc:imgBrush" == sNodeName)
|
||||
{
|
||||
ReadImgBrush(oChild);
|
||||
ReadImgBrush(oReader);
|
||||
m_nFillType |= 0x02;
|
||||
}
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
void CFill::ReadWinBrush(CXMLNode& oNode)
|
||||
void CFill::ReadWinBrush(CXMLReader& oReader)
|
||||
{
|
||||
m_nFaceColor = oNode.GetAttributeColor(L"faceColor", 0xFFFFFFFF);
|
||||
m_nHatchColor = oNode.GetAttributeColor(L"hatchColor", 0x000000);
|
||||
m_eHatchStyle = GetColorFillPattern(oNode.GetAttributeInt(L"hatchStyle", -1));
|
||||
m_chAlpha = (HWP_BYTE)oNode.GetAttributeInt(L"alpha", 255);
|
||||
}
|
||||
m_eHatchStyle = EColorFillPattern::NONE;
|
||||
m_chAlpha = 0xff;
|
||||
|
||||
void CFill::ReadGradation(CXMLNode& oNode)
|
||||
{
|
||||
m_eGradType = ::HWP::GetGradFillType(oNode.GetAttributeInt(L"type"));
|
||||
m_nAngle = oNode.GetAttributeInt(L"angle");
|
||||
m_nCenterX = oNode.GetAttributeInt(L"centerX");
|
||||
m_nCenterY = oNode.GetAttributeInt(L"centerY");
|
||||
m_nStep = oNode.GetAttributeInt(L"step");
|
||||
m_nColorNum = oNode.GetAttributeInt(L"colorNum");
|
||||
m_chStepCenter = (HWP_BYTE)oNode.GetAttributeInt(L"stepCenter");
|
||||
m_chAlpha = (HWP_BYTE)oNode.GetAttributeInt(L"alpha", 255);
|
||||
|
||||
std::vector<XmlUtils::CXmlNode> arChilds;
|
||||
|
||||
oNode.GetNodes(L"hc:color", arChilds);
|
||||
|
||||
m_arColors.resize(arChilds.size());
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < arChilds.size(); ++unIndex)
|
||||
m_arColors[unIndex] = CXMLNode(arChilds[unIndex]).GetAttributeColor(L"value");
|
||||
}
|
||||
|
||||
void CFill::ReadImgBrush(CXMLNode& oNode)
|
||||
{
|
||||
m_eMode = GetImageFillType(oNode.GetAttributeInt(L"mode", (int)EImageFillType::NONE));
|
||||
|
||||
for (CXMLNode& oChild : oNode.GetChilds())
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (L"hc:img" == oChild.GetName())
|
||||
{
|
||||
m_chBright = (HWP_BYTE)oChild.GetAttributeInt(L"bright");
|
||||
m_chContrast = (HWP_BYTE)oChild.GetAttributeInt(L"contrast");
|
||||
|
||||
HWP_STRING sEffect = oChild.GetAttribute(L"effect");
|
||||
|
||||
if (L"REAL_PIC" == sEffect)
|
||||
m_chEffect = 0;
|
||||
else if (L"GRAY_SCALE" == sEffect)
|
||||
m_chEffect = 1;
|
||||
else if (L"BLACK_WHITE" == sEffect)
|
||||
m_chEffect = 2;
|
||||
|
||||
m_sBinItemID = oChild.GetAttribute(L"binaryItemIDRef");
|
||||
m_chAlpha = (HWP_BYTE)oChild.GetAttributeInt(L"alpha", 255);
|
||||
}
|
||||
if ("faceColor" == sAttributeName)
|
||||
m_nFaceColor = oReader.GetColor(0xFFFFFFFF);
|
||||
else if ("hatchColor" == sAttributeName)
|
||||
m_nHatchColor = oReader.GetColor();
|
||||
else if ("hatchStyle" == sAttributeName)
|
||||
m_eHatchStyle = GetColorFillPattern(oReader.GetInt());
|
||||
else if ("alpha" == sAttributeName)
|
||||
m_chAlpha = (HWP_BYTE)oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
|
||||
void CFill::ReadGradation(CXMLReader& oReader)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("type" == sAttributeName)
|
||||
m_eGradType = ::HWP::GetGradFillType(oReader.GetInt());
|
||||
else if ("angle" == sAttributeName)
|
||||
m_nAngle = oReader.GetInt();
|
||||
else if ("centerX" == sAttributeName)
|
||||
m_nCenterX = oReader.GetInt();
|
||||
else if ("centerY" == sAttributeName)
|
||||
m_nCenterY = oReader.GetInt();
|
||||
else if ("step" == sAttributeName)
|
||||
m_nStep = oReader.GetInt();
|
||||
else if ("colorNum" == sAttributeName)
|
||||
m_nColorNum = oReader.GetInt();
|
||||
else if ("stepCenter" == sAttributeName)
|
||||
m_chStepCenter = (HWP_BYTE)oReader.GetInt();
|
||||
else if ("alpha" == sAttributeName)
|
||||
m_chAlpha = (HWP_BYTE)oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hc:color")
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("value" != oReader.GetName())
|
||||
continue;
|
||||
|
||||
m_arColors.push_back(oReader.GetColor(true));
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
void CFill::ReadImgBrush(CXMLReader& oReader)
|
||||
{
|
||||
m_eMode = GetImageFillType(oReader.GetAttributeInt("mode"));
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hc:img")
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("bright" == sAttributeName)
|
||||
m_chBright = (HWP_BYTE)oReader.GetInt();
|
||||
else if ("contrast" == sAttributeName)
|
||||
m_chContrast = (HWP_BYTE)oReader.GetInt();
|
||||
else if ("effect" == sAttributeName)
|
||||
{
|
||||
const std::string sEffect{oReader.GetTextA()};
|
||||
|
||||
if ("REAL_PIC" == sEffect)
|
||||
m_chEffect = 0;
|
||||
else if ("GRAY_SCALE" == sEffect)
|
||||
m_chEffect = 1;
|
||||
else if ("BLACK_WHITE" == sEffect)
|
||||
m_chEffect = 2;
|
||||
}
|
||||
else if ("binaryItemIDRef" == sAttributeName)
|
||||
m_sBinItemID = oReader.GetText();
|
||||
else if ("alpha" == sAttributeName)
|
||||
m_chAlpha = (HWP_BYTE)oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
int CFill::GetSize() const
|
||||
@ -333,66 +375,88 @@ CHWPRecordBorderFill::CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, int nTagNum, i
|
||||
m_pFill = new CFill(oBuffer, 0, 0); // TODO:: перейти от использования off и size
|
||||
}
|
||||
|
||||
CHWPRecordBorderFill::CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion)
|
||||
CHWPRecordBorderFill::CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_BORDER_FILL, 0, 0), m_pFill(nullptr)
|
||||
{
|
||||
m_bThreeD = oNode.GetAttributeBool(L"threeD");
|
||||
m_bShadow = oNode.GetAttributeBool(L"shadow");
|
||||
m_bBreakCellSeparateLine = oNode.GetAttributeBool(L"breakCellSeparateLine");
|
||||
|
||||
HWP_STRING sChildName;
|
||||
|
||||
for (CXMLNode& oChild : oNode.GetChilds())
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (L"hh:slash" == oChild.GetName())
|
||||
{
|
||||
HWP_STRING sType = oChild.GetAttribute(L"type");
|
||||
|
||||
if (L"NONE" == sType)
|
||||
m_chSlash = 0x0;
|
||||
else if (L"CENTER" == sType)
|
||||
m_chSlash = 0b010;
|
||||
else if (L"CENTER_BELOW" == sType)
|
||||
m_chSlash = 0b011;
|
||||
else if (L"CENTER_ABOVE" == sType)
|
||||
m_chSlash = 0b110;
|
||||
else if (L"ALL" == sType)
|
||||
m_chSlash = 0b111;
|
||||
|
||||
m_chCrookedSlash = oChild.GetAttributeBool(L"Crooked");
|
||||
m_bCounterSlash = oChild.GetAttributeBool(L"isCounter");
|
||||
}
|
||||
else if (L"hh:backSlash" == oChild.GetName())
|
||||
{
|
||||
HWP_STRING sType = oChild.GetAttribute(L"type");
|
||||
|
||||
if (L"NONE" == sType)
|
||||
m_chBackSlash = 0x0;
|
||||
else if (L"CENTER" == sType)
|
||||
m_chBackSlash = 0b010;
|
||||
else if (L"CENTER_BELOW" == sType)
|
||||
m_chBackSlash = 0b011;
|
||||
else if (L"CENTER_ABOVE" == sType)
|
||||
m_chBackSlash = 0b110;
|
||||
else if (L"ALL" == sType)
|
||||
m_chBackSlash = 0b111;
|
||||
|
||||
m_chCrookedBackSlash = oChild.GetAttributeBool(L"Crooked");
|
||||
m_bCounterBackSlash = oChild.GetAttributeBool(L"isCounter");
|
||||
}
|
||||
else if (L"hh:leftBorder" == oChild.GetName())
|
||||
m_oLeft.ReadFromNode(oChild);
|
||||
else if (L"hh:rightBorder" == oChild.GetName())
|
||||
m_oRight.ReadFromNode(oChild);
|
||||
else if (L"hh:topBorder" == oChild.GetName())
|
||||
m_oTop.ReadFromNode(oChild);
|
||||
else if (L"hh:bottomBorder" == oChild.GetName())
|
||||
m_oBottom.ReadFromNode(oChild);
|
||||
else if (L"hh:diagonal" == oChild.GetName())
|
||||
m_oDiagonal.ReadFromNode(oChild);
|
||||
else if (L"hc:fillBrush" == oChild.GetName())
|
||||
m_pFill = new CFill(oChild);
|
||||
if ("threeD" == sAttributeName)
|
||||
m_bThreeD = oReader.GetBool();
|
||||
else if ("shadow" == sAttributeName)
|
||||
m_bShadow = oReader.GetBool();
|
||||
else if ("breakCellSeparateLine" == sAttributeName)
|
||||
m_bBreakCellSeparateLine = oReader.GetBool();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if ("hh:slash" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("type" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if ("NONE" == sType)
|
||||
m_chSlash = 0x0;
|
||||
else if ("CENTER" == sType)
|
||||
m_chSlash = 0b010;
|
||||
else if ("CENTER_BELOW" == sType)
|
||||
m_chSlash = 0b011;
|
||||
else if ("CENTER_ABOVE" == sType)
|
||||
m_chSlash = 0b110;
|
||||
else if ("ALL" == sType)
|
||||
m_chSlash = 0b111;
|
||||
}
|
||||
else if ("Crooked" == sAttributeName)
|
||||
m_chCrookedSlash = oReader.GetBool();
|
||||
else if ("isCounter" == sAttributeName)
|
||||
m_bCounterSlash = oReader.GetBool();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("hh:backSlash" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("type" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if ("NONE" == sType)
|
||||
m_chBackSlash = 0x0;
|
||||
else if ("CENTER" == sType)
|
||||
m_chBackSlash = 0b010;
|
||||
else if ("CENTER_BELOW" == sType)
|
||||
m_chBackSlash = 0b011;
|
||||
else if ("CENTER_ABOVE" == sType)
|
||||
m_chBackSlash = 0b110;
|
||||
else if ("ALL" == sType)
|
||||
m_chBackSlash = 0b111;
|
||||
}
|
||||
else if ("Crooked" == sAttributeName)
|
||||
m_chCrookedBackSlash = oReader.GetBool();
|
||||
else if ("isCounter" == sAttributeName)
|
||||
m_bCounterBackSlash = oReader.GetBool();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("hh:leftBorder" == sNodeName)
|
||||
m_oLeft.Read(oReader);
|
||||
else if ("hh:rightBorder" == sNodeName)
|
||||
m_oRight.Read(oReader);
|
||||
else if ("hh:topBorder" == sNodeName)
|
||||
m_oTop.Read(oReader);
|
||||
else if ("hh:bottomBorder" == sNodeName)
|
||||
m_oBottom.Read(oReader);
|
||||
else if ("hh:diagonal" == sNodeName)
|
||||
m_oDiagonal.Read(oReader);
|
||||
else if ("hc:fillBrush" == sNodeName)
|
||||
m_pFill = new CFill(oReader);
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
CHWPRecordBorderFill::~CHWPRecordBorderFill()
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include "../HWPDocInfo.h"
|
||||
#include "HwpRecordTypes.h"
|
||||
#include "../HWPStream.h"
|
||||
#include "../Common/XMLNode.h"
|
||||
#include "../Common/XMLReader.h"
|
||||
#include <vector>
|
||||
|
||||
namespace HWP
|
||||
@ -15,7 +15,7 @@ struct TBorder
|
||||
HWP_BYTE m_chWidth;
|
||||
int m_nColor;
|
||||
|
||||
void ReadFromNode(CXMLNode& oNode);
|
||||
void Read(CXMLReader& oReader);
|
||||
};
|
||||
|
||||
enum class EImageFillType
|
||||
@ -86,13 +86,13 @@ class CFill : public IRef
|
||||
|
||||
HWP_BYTE m_chAlpha;
|
||||
|
||||
void ReadWinBrush(CXMLNode& oNode);
|
||||
void ReadGradation(CXMLNode& oNode);
|
||||
void ReadImgBrush(CXMLNode& oNode);
|
||||
void ReadWinBrush(CXMLReader& oReader);
|
||||
void ReadGradation(CXMLReader& oReader);
|
||||
void ReadImgBrush(CXMLReader& oReader);
|
||||
public:
|
||||
CFill();
|
||||
CFill(CHWPStream& oBuffer, int nOff, int nSize);
|
||||
CFill(CXMLNode& oNode);
|
||||
CFill(CXMLReader& oReader);
|
||||
|
||||
int GetSize() const;
|
||||
bool NoneFill() const;
|
||||
@ -136,7 +136,7 @@ class CHWPRecordBorderFill : public CHWPRecord
|
||||
public:
|
||||
CHWPRecordBorderFill(int nTagNum, int nLevel, int nSize);
|
||||
CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion);
|
||||
CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
~CHWPRecordBorderFill();
|
||||
|
||||
TBorder GetLeftBorder() const;
|
||||
|
||||
@ -45,25 +45,32 @@ CHWPRecordBullet::CHWPRecordBullet(CHWPDocInfo& oDocInfo, int nTagNum, int nLeve
|
||||
oBuffer.ReadChar(m_chCheckBulletChar);
|
||||
}
|
||||
|
||||
CHWPRecordBullet::CHWPRecordBullet(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion)
|
||||
CHWPRecordBullet::CHWPRecordBullet(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_BULLET, 0, 0), m_pParent(&oDocInfo)
|
||||
{
|
||||
std::wstring wsAttributeValue = oNode.GetAttribute(L"char");
|
||||
|
||||
if (!wsAttributeValue.empty())
|
||||
m_chBulletChar = wsAttributeValue.at(0);
|
||||
|
||||
wsAttributeValue = oNode.GetAttribute(L"checkedChar");
|
||||
|
||||
if (!wsAttributeValue.empty())
|
||||
m_chCheckBulletChar = wsAttributeValue.at(0);
|
||||
|
||||
m_nBulletImage = oNode.GetAttributeInt(L"useImage");
|
||||
|
||||
for (CXMLNode& oChild : oNode.GetChilds())
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (L"hc:img" == oChild.GetName())
|
||||
m_sBinItemRefID = oChild.GetAttribute(L"binaryItemIDRef");
|
||||
if ("char" == sAttributeName)
|
||||
{
|
||||
const HWP_STRING wsValue{oReader.GetText()};
|
||||
|
||||
if (!wsValue.empty())
|
||||
m_chBulletChar = wsValue.at(0);
|
||||
}
|
||||
else if ("checkedChar" == sAttributeName)
|
||||
{
|
||||
const HWP_STRING wsValue{oReader.GetText()};
|
||||
|
||||
if (!wsValue.empty())
|
||||
m_chCheckBulletChar = wsValue.at(0);
|
||||
}
|
||||
else if ("useImage" == sAttributeName)
|
||||
m_nBulletImage = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hc:img")
|
||||
m_sBinItemRefID = oReader.GetAttribute("binaryItemIDRef");
|
||||
END_WHILE
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
#include "../HWPStream.h"
|
||||
#include "../HWPDocInfo.h"
|
||||
#include "HWPRecordNumbering.h"
|
||||
#include "../Common/XMLNode.h"
|
||||
#include "../Common/XMLReader.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
@ -24,7 +24,7 @@ class CHWPRecordBullet : public CHWPRecord
|
||||
HWP_CHAR m_chCheckBulletChar;
|
||||
public:
|
||||
CHWPRecordBullet(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordBullet(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion);
|
||||
CHWPRecordBullet(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -107,15 +107,29 @@ EShadow GetShadow(const HWP_STRING& sValue)
|
||||
ELSE_STRING_IN_ENUM(NONE, EShadow);
|
||||
}
|
||||
|
||||
void CHWPRecordCharShape::ReadContainerData(CXMLNode& oNode, short arValues[], int nDefaultValue)
|
||||
void CHWPRecordCharShape::ReadContainerData(CXMLReader& oReader, short arValues[], int nDefaultValue)
|
||||
{
|
||||
arValues[(int)ELang::HANGUL] = oNode.GetAttributeInt(L"hangul", nDefaultValue);
|
||||
arValues[(int)ELang::LATIN] = oNode.GetAttributeInt(L"latin", nDefaultValue);
|
||||
arValues[(int)ELang::HANJA] = oNode.GetAttributeInt(L"hanja", nDefaultValue);
|
||||
arValues[(int)ELang::JAPANESE] = oNode.GetAttributeInt(L"japanese", nDefaultValue);
|
||||
arValues[(int)ELang::OTHER] = oNode.GetAttributeInt(L"other", nDefaultValue);
|
||||
arValues[(int)ELang::SYMBOL] = oNode.GetAttributeInt(L"symbol", nDefaultValue);
|
||||
arValues[(int)ELang::USER] = oNode.GetAttributeInt(L"user", nDefaultValue);
|
||||
for (unsigned int unIndex = 0; unIndex < (int)ELang::MAX; ++unIndex)
|
||||
arValues[unIndex] = nDefaultValue;
|
||||
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("hangul" == sAttributeName)
|
||||
arValues[(int)ELang::HANGUL] = oReader.GetInt();
|
||||
else if ("latin" == sAttributeName)
|
||||
arValues[(int)ELang::LATIN] = oReader.GetInt();
|
||||
else if ("hanja" == sAttributeName)
|
||||
arValues[(int)ELang::HANJA] = oReader.GetInt();
|
||||
else if ("japanese" == sAttributeName)
|
||||
arValues[(int)ELang::JAPANESE] = oReader.GetInt();
|
||||
else if ("other" == sAttributeName)
|
||||
arValues[(int)ELang::OTHER] = oReader.GetInt();
|
||||
else if ("symbol" == sAttributeName)
|
||||
arValues[(int)ELang::SYMBOL] = oReader.GetInt();
|
||||
else if ("user" == sAttributeName)
|
||||
arValues[(int)ELang::USER] = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
|
||||
CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
|
||||
@ -194,103 +208,138 @@ CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, int nTagNum, int
|
||||
oBuffer.RemoveLastSavedPos();
|
||||
}
|
||||
|
||||
CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion)
|
||||
CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_HWP_CHAR_SHAPE, 0, 0), m_pParent(&oDocInfo),
|
||||
m_bItalic(false), m_bBold(false), m_bEmboss(false), m_bEngrave(false),
|
||||
m_bSuperScript(false), m_bSubScript(false)
|
||||
m_nHeight(1000), m_bItalic(false), m_bBold(false), m_eUnderline(EUnderline::NONE),
|
||||
m_eUnderLineShape(ELineStyle1::SOLID), m_eOutline(EOutline::NONE), m_eShadow(EShadow::NONE), m_bEmboss(false), m_bEngrave(false),
|
||||
m_bSuperScript(false), m_bSubScript(false), m_eStrikeOutShape(ELineStyle2::NONE), m_nShadeColor(0xFFFFFFFF)
|
||||
{
|
||||
m_eUnderline = EUnderline::NONE;
|
||||
m_eUnderLineShape = ELineStyle1::SOLID;
|
||||
m_eOutline = EOutline::NONE;
|
||||
m_eShadow = EShadow::NONE;
|
||||
m_eStrikeOutShape = ELineStyle2::NONE;
|
||||
|
||||
m_nHeight = oNode.GetAttributeInt(L"height", 1000);
|
||||
m_nTextColor = oNode.GetAttributeColor(L"textColor", 0x000000);
|
||||
m_nShadeColor = oNode.GetAttributeColor(L"shadeColor", 0xFFFFFFFF);
|
||||
m_bUseFontSpace = oNode.GetAttributeBool(L"useFontSpace");
|
||||
m_bUseKerning = oNode.GetAttributeBool(L"useKerning");
|
||||
|
||||
m_eSymMark = GetAccent(oNode.GetAttribute(L"symMark"));
|
||||
|
||||
m_shBorderFillIDRef = oNode.GetAttributeInt(L"borderFillIDRef");
|
||||
|
||||
for (CXMLNode& oChild : oNode.GetChilds())
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (L"hh:fontRef" == oChild.GetName())
|
||||
if ("height" == sAttributeName)
|
||||
m_nHeight = oReader.GetInt();
|
||||
else if ("textColor" == sAttributeName)
|
||||
m_nTextColor = oReader.GetColor();
|
||||
else if ("shadeColor" == sAttributeName)
|
||||
m_nShadeColor = oReader.GetColor(0xFFFFFFFF);
|
||||
else if ("useFontSpace" == sAttributeName)
|
||||
m_bUseFontSpace = oReader.GetBool();
|
||||
else if ("useKerning" == sAttributeName)
|
||||
m_bUseKerning = oReader.GetBool();
|
||||
else if ("symMark" == sAttributeName)
|
||||
m_eSymMark = GetAccent(oReader.GetText());
|
||||
else if ("borderFillIDRef" == sAttributeName)
|
||||
m_shBorderFillIDRef = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if ("hh:fontRef" == sNodeName)
|
||||
{
|
||||
if (nullptr == m_pParent)
|
||||
continue;
|
||||
|
||||
const CHWPRecordFaceName* pFaceName = nullptr;
|
||||
|
||||
#define UPDATE_FACENAME(node_name, elang_type) \
|
||||
pFaceName = dynamic_cast<const CHWPRecordFaceName*>(m_pParent->GetFaceName(oChild.GetAttributeInt(node_name))); \
|
||||
if (nullptr != pFaceName) \
|
||||
m_arFontNames[(int)elang_type] = pFaceName->GetFaceName()
|
||||
#define UPDATE_FACENAME(elang_type)\
|
||||
{\
|
||||
pFaceName = dynamic_cast<const CHWPRecordFaceName*>(m_pParent->GetFaceName(oReader.GetInt()));\
|
||||
if (nullptr != pFaceName)\
|
||||
m_arFontNames[(int)elang_type] = pFaceName->GetFaceName();\
|
||||
}
|
||||
|
||||
UPDATE_FACENAME(L"hangul", ELang::HANGUL);
|
||||
UPDATE_FACENAME(L"latin", ELang::LATIN);
|
||||
UPDATE_FACENAME(L"hanja", ELang::HANJA);
|
||||
UPDATE_FACENAME(L"japanese", ELang::JAPANESE);
|
||||
UPDATE_FACENAME(L"other", ELang::OTHER);
|
||||
UPDATE_FACENAME(L"symbol", ELang::SYMBOL);
|
||||
UPDATE_FACENAME(L"user", ELang::USER);
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("hangul" == sAttributeName)
|
||||
UPDATE_FACENAME(ELang::HANGUL)
|
||||
else if ("latin" == sAttributeName)
|
||||
UPDATE_FACENAME(ELang::LATIN)
|
||||
else if ("hanja" == sAttributeName)
|
||||
UPDATE_FACENAME(ELang::HANJA)
|
||||
else if ("japanese" == sAttributeName)
|
||||
UPDATE_FACENAME(ELang::JAPANESE)
|
||||
else if ("other" == sAttributeName)
|
||||
UPDATE_FACENAME(ELang::OTHER)
|
||||
else if ("symbol" == sAttributeName)
|
||||
UPDATE_FACENAME(ELang::SYMBOL)
|
||||
else if ("user" == sAttributeName)
|
||||
UPDATE_FACENAME(ELang::USER)
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if (L"hh:ratio" == oChild.GetName())
|
||||
ReadContainerData(oChild, m_arRatios, 100);
|
||||
else if (L"hh:spacing" == oChild.GetName())
|
||||
ReadContainerData(oChild, m_arSpacings);
|
||||
else if (L"hh:relSz" == oChild.GetName())
|
||||
ReadContainerData(oChild, m_arRelSizes, 100);
|
||||
else if (L"hh:offset" == oChild.GetName())
|
||||
ReadContainerData(oChild, m_arCharOffset);
|
||||
else if (L"hh:underline" == oChild.GetName())
|
||||
else if ("hh:ratio" == sNodeName)
|
||||
ReadContainerData(oReader, m_arRatios, 100);
|
||||
else if ("hh:spacing" == sNodeName)
|
||||
ReadContainerData(oReader, m_arSpacings);
|
||||
else if ("hh:relSz" == sNodeName)
|
||||
ReadContainerData(oReader, m_arRelSizes, 100);
|
||||
else if ("hh:offset" == sNodeName)
|
||||
ReadContainerData(oReader, m_arCharOffset);
|
||||
else if ("hh:underline" == sNodeName)
|
||||
{
|
||||
m_eUnderline = GetUnderline(oChild.GetAttribute(L"type"));
|
||||
m_eUnderLineShape = GetLineStyle1(oChild.GetAttribute(L"shape"));
|
||||
m_nUnderlineColor = oChild.GetAttributeColor(L"color");
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("type" == sAttributeName)
|
||||
m_eUnderline = GetUnderline(oReader.GetText());
|
||||
else if ("shape" == sAttributeName)
|
||||
m_eUnderLineShape = GetLineStyle1(oReader.GetText());
|
||||
else if ("color" == sAttributeName)
|
||||
m_nUnderlineColor = oReader.GetColor();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if (L"hh:strikeout" == oChild.GetName())
|
||||
else if ("hh:strikeout" == sNodeName)
|
||||
{
|
||||
m_eStrikeOutShape = GetLineStyle2(oChild.GetAttribute(L"shape"));
|
||||
m_nStrikeOutColor = oChild.GetAttributeColor(L"color");
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("shape" == sAttributeName)
|
||||
m_eStrikeOutShape = GetLineStyle2(oReader.GetText());
|
||||
else if ("color" == sAttributeName)
|
||||
m_nStrikeOutColor = oReader.GetColor();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("hh:outline" == sNodeName)
|
||||
m_eOutline = GetOutline(oReader.GetAttribute("type"));
|
||||
else if ("hh:shadow" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("type" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if (L"3D" == oChild.GetAttribute(L"shape"))
|
||||
m_eStrikeOutShape = ELineStyle2::NONE;
|
||||
if ("DROP" == sType)
|
||||
m_eShadow = EShadow::DISCRETE;
|
||||
else if ("CONTINUOUS" == sType)
|
||||
m_eShadow = EShadow::CONTINUOUS;
|
||||
else
|
||||
m_eShadow = EShadow::NONE;
|
||||
}
|
||||
else if ("color" == sAttributeName)
|
||||
m_nShadowColor = oReader.GetColor();
|
||||
else if ("offsetX" == sAttributeName)
|
||||
m_chShadowOffsetX = (HWP_BYTE)oReader.GetInt();
|
||||
else if ("offsetY" == sAttributeName)
|
||||
m_chShadowOffsetY = (HWP_BYTE)oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if (L"hh:outline" == oChild.GetName())
|
||||
{
|
||||
m_eOutline = GetOutline(oChild.GetAttribute(L"type"));
|
||||
}
|
||||
else if (L"hh:shadow" == oChild.GetName())
|
||||
{
|
||||
HWP_STRING sType = oChild.GetAttribute(L"type");
|
||||
|
||||
if (L"DROP" == sType)
|
||||
m_eShadow = EShadow::DISCRETE;
|
||||
else if (L"CONTINUOUS" == sType)
|
||||
m_eShadow = EShadow::CONTINUOUS;
|
||||
else
|
||||
m_eShadow = EShadow::NONE;
|
||||
|
||||
m_nShadowColor = oChild.GetAttributeColor(L"color");
|
||||
m_chShadowOffsetX = (HWP_BYTE)oChild.GetAttributeInt(L"offsetX");
|
||||
m_chShadowOffsetY = (HWP_BYTE)oChild.GetAttributeInt(L"offsetY");
|
||||
}
|
||||
else if (L"hh:italic" == oChild.GetName())
|
||||
else if ("hh:italic" == sNodeName)
|
||||
m_bItalic = true;
|
||||
else if (L"hh:bold" == oChild.GetName())
|
||||
else if ("hh:bold" == sNodeName)
|
||||
m_bBold = true;
|
||||
else if (L"hh:emboss" == oChild.GetName())
|
||||
else if ("hh:emboss" == sNodeName)
|
||||
m_bEmboss = true;
|
||||
else if (L"hh:engrave" == oChild.GetName())
|
||||
m_bEmboss = true;
|
||||
else if (L"hh:supscript" == oChild.GetName())
|
||||
else if ("hh:engrave" == sNodeName)
|
||||
m_bEngrave = true;
|
||||
else if ("hh:supscript" == sNodeName)
|
||||
m_bSuperScript = true;
|
||||
else if (L"hh:subscript" == oChild.GetName())
|
||||
else if ("hh:subscript" == sNodeName)
|
||||
m_bSubScript = true;
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
bool CHWPRecordCharShape::Bold() const
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
#include "../HWPStream.h"
|
||||
#include "HWPRecord.h"
|
||||
#include "HwpRecordTypes.h"
|
||||
#include "../Common/XMLNode.h"
|
||||
#include "../Common/XMLReader.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
@ -100,10 +100,10 @@ class CHWPRecordCharShape : public CHWPRecord
|
||||
short m_shBorderFillIDRef;
|
||||
int m_nStrikeOutColor;
|
||||
|
||||
void ReadContainerData(CXMLNode& oNode, short arValues[], int nDefaultValue = 0);
|
||||
void ReadContainerData(CXMLReader& oReader, short arValues[], int nDefaultValue = 0);
|
||||
public:
|
||||
CHWPRecordCharShape(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion);
|
||||
CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
|
||||
bool Bold() const;
|
||||
bool Italic() const;
|
||||
|
||||
@ -16,14 +16,24 @@ CHWPRecordDocumentProperties::CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo
|
||||
oBuffer.ReadInt(m_nCharUnitLocInPara);
|
||||
}
|
||||
|
||||
CHWPRecordDocumentProperties::CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion)
|
||||
CHWPRecordDocumentProperties::CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_DOCUMENT_PROPERTIES, 0, 0), m_pParent(&oDocInfo)
|
||||
{
|
||||
m_shFigureStartNo = oNode.GetAttributeInt(L"page");
|
||||
m_shFootNoteStartNo = oNode.GetAttributeInt(L"footnote");
|
||||
m_shEndNoteStartNo = oNode.GetAttributeInt(L"endnote");
|
||||
m_shFigureStartNo = oNode.GetAttributeInt(L"pic");
|
||||
m_shTableStartNo = oNode.GetAttributeInt(L"tbl");
|
||||
m_shEqStartNo = oNode.GetAttributeInt(L"equation");
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("page" == sAttributeName)
|
||||
m_shPageStartNo = oReader.GetInt();
|
||||
else if ("footnote" == sAttributeName)
|
||||
m_shFootNoteStartNo = oReader.GetInt();
|
||||
else if ("endnote" == sAttributeName)
|
||||
m_shEndNoteStartNo = oReader.GetInt();
|
||||
else if ("pic" == sAttributeName)
|
||||
m_shFigureStartNo = oReader.GetInt();
|
||||
else if ("tbl" == sAttributeName)
|
||||
m_shTableStartNo = oReader.GetInt();
|
||||
else if ("equation" == sAttributeName)
|
||||
m_shEqStartNo = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include "../HWPDocInfo.h"
|
||||
#include "../HWPStream.h"
|
||||
#include "HWPRecord.h"
|
||||
#include "../Common/XMLNode.h"
|
||||
#include "../Common/XMLReader.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
@ -24,7 +24,7 @@ class CHWPRecordDocumentProperties : public CHWPRecord
|
||||
int m_nCharUnitLocInPara;
|
||||
public:
|
||||
CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion);
|
||||
CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -53,47 +53,71 @@ CHWPRecordFaceName::CHWPRecordFaceName(CHWPDocInfo& oDocInfo, int nTagNum, int n
|
||||
oBuffer.ReadString(m_sBasicFaceName, EStringCharacter::UTF16);
|
||||
}
|
||||
|
||||
CHWPRecordFaceName::CHWPRecordFaceName(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion)
|
||||
CHWPRecordFaceName::CHWPRecordFaceName(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_FACE_NAME, 0, 0), m_pParent(&oDocInfo)
|
||||
{
|
||||
m_sFaceName = oNode.GetAttribute(L"face");
|
||||
m_sFaceName = oReader.GetAttribute("face");
|
||||
|
||||
for (CXMLNode& oChild: oNode.GetChilds())
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if (L"hh:substFont" == oChild.GetName())
|
||||
if ("hh:substFont" == sNodeName)
|
||||
{
|
||||
m_bSubstExists = true;
|
||||
m_sSubstFace = oChild.GetAttribute(L"face");
|
||||
|
||||
HWP_STRING sType = oChild.GetAttribute(L"type");
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("face" == sAttributeName)
|
||||
m_sSubstFace = oReader.GetText();
|
||||
else if ("type" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if (L"TTF" == sType)
|
||||
m_eSubstType = EAltType::FFT;
|
||||
else if (L"HFT" == sType)
|
||||
m_eSubstType = EAltType::HFT;
|
||||
else
|
||||
m_eSubstType = EAltType::UNKNOWN;
|
||||
if ("TTF" == sType)
|
||||
m_eSubstType = EAltType::FFT;
|
||||
else if ("HFT" == sType)
|
||||
m_eSubstType = EAltType::HFT;
|
||||
else
|
||||
m_eSubstType = EAltType::UNKNOWN;
|
||||
}
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if (L"hh:typeInfo" == oChild.GetName())
|
||||
else if ("hh:typeInfo" == sNodeName)
|
||||
{
|
||||
m_bAttrExists = true;
|
||||
|
||||
m_sBasicFaceName = oChild.GetAttribute(L"familyType");
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("familyType" == sAttributeName)
|
||||
{
|
||||
m_sBasicFaceName = oReader.GetText();
|
||||
|
||||
if (!m_sBasicFaceName.empty())
|
||||
m_bBasicFaceExists = true;
|
||||
|
||||
m_chSerifStyle = (HWP_BYTE)oChild.GetAttributeInt(L"serifStyle");
|
||||
m_shWeight = oChild.GetAttributeInt(L"weight");
|
||||
m_shPropotion = oChild.GetAttributeInt(L"proportion");
|
||||
m_shContrast = oChild.GetAttributeInt(L"contrast");
|
||||
m_shStrokeVariation = oChild.GetAttributeInt(L"strokeVariation");
|
||||
m_shArmStyle = oChild.GetAttributeInt(L"armStyle");
|
||||
m_shLetterform = oChild.GetAttributeInt(L"letterform");
|
||||
m_shMidLine = oChild.GetAttributeInt(L"midline");
|
||||
m_shXHeight = oChild.GetAttributeInt(L"xHeight");
|
||||
if (!m_sBasicFaceName.empty())
|
||||
m_bBasicFaceExists = true;
|
||||
}
|
||||
else if ("serifStyle" == sAttributeName)
|
||||
m_chSerifStyle = (HWP_BYTE)oReader.GetInt();
|
||||
else if ("weight" == sAttributeName)
|
||||
m_shWeight = oReader.GetInt();
|
||||
else if ("proportion" == sAttributeName)
|
||||
m_shPropotion = oReader.GetInt();
|
||||
else if ("contrast" == sAttributeName)
|
||||
m_shContrast = oReader.GetInt();
|
||||
else if ("strokeVariation" == sAttributeName)
|
||||
m_shStrokeVariation = oReader.GetInt();
|
||||
else if ("armStyle" == sAttributeName)
|
||||
m_shArmStyle = oReader.GetInt();
|
||||
else if ("letterform" == sAttributeName)
|
||||
m_shLetterform = oReader.GetInt();
|
||||
else if ("midline" == sAttributeName)
|
||||
m_shMidLine = oReader.GetInt();
|
||||
else if ("xHeight" == sAttributeName)
|
||||
m_shXHeight = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
HWP_STRING CHWPRecordFaceName::GetFaceName() const
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#ifndef HWPRECORDFACENAME_H
|
||||
#define HWPRECORDFACENAME_H
|
||||
|
||||
#include "../Common/XMLNode.h"
|
||||
#include "../Common/XMLReader.h"
|
||||
#include "../HWPDocInfo.h"
|
||||
#include "../HWPStream.h"
|
||||
#include "HWPRecord.h"
|
||||
@ -41,7 +41,7 @@ class CHWPRecordFaceName : public CHWPRecord
|
||||
short m_shXHeight;
|
||||
public:
|
||||
CHWPRecordFaceName(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordFaceName(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion);
|
||||
CHWPRecordFaceName(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
|
||||
HWP_STRING GetFaceName() const;
|
||||
};
|
||||
|
||||
@ -54,52 +54,68 @@ CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, int nTagNum, int
|
||||
oBuffer.RemoveLastSavedPos();
|
||||
}
|
||||
|
||||
CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion)
|
||||
CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_NUMBERING, 0, 0), m_pParent(&oDocInfo)
|
||||
{
|
||||
m_shStart = oNode.GetAttributeInt(L"start", 1);
|
||||
m_shStart = oReader.GetAttributeInt("start", 1);
|
||||
|
||||
unsigned int unIndex = 0;
|
||||
HWP_STRING sType;
|
||||
short shLevel = 0;
|
||||
std::string sNumFormat;
|
||||
|
||||
for (CXMLNode& oChild : oNode.GetChilds())
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if (L"hh:paraHead" == oChild.GetName() ||
|
||||
L"paraHead" == oChild.GetName())
|
||||
if ("hh:paraHead" == sNodeName ||
|
||||
"paraHead" == sNodeName)
|
||||
{
|
||||
sType = oChild.GetAttribute(L"align");
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("align" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if (L"LEFT" == sType)
|
||||
m_arNumbering[unIndex].m_chAlign = 0;
|
||||
else if (L"CENTER" == sType)
|
||||
m_arNumbering[unIndex].m_chAlign = 1;
|
||||
else if (L"RIGHT" == sType)
|
||||
m_arNumbering[unIndex].m_chAlign = 2;
|
||||
if ("LEFT" == sType)
|
||||
m_arNumbering[unIndex].m_chAlign = 0;
|
||||
else if ("CENTER" == sType)
|
||||
m_arNumbering[unIndex].m_chAlign = 1;
|
||||
else if ("RIGHT" == sType)
|
||||
m_arNumbering[unIndex].m_chAlign = 2;
|
||||
}
|
||||
else if ("useInstWidth" == sAttributeName)
|
||||
m_arNumbering[unIndex].m_bUseInstWidth = oReader.GetBool();
|
||||
else if ("autoIndent" == sAttributeName)
|
||||
m_arNumbering[unIndex].m_bAutoIndent = oReader.GetBool();
|
||||
else if ("widthAdjust" == sAttributeName)
|
||||
m_arNumbering[unIndex].m_shWidthAdjust = oReader.GetInt();
|
||||
else if ("textOffsetType" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
m_arNumbering[unIndex].m_bUseInstWidth = oChild.GetAttributeBool(L"useInstWidth");
|
||||
m_arNumbering[unIndex].m_bAutoIndent = oChild.GetAttributeBool(L"autoIndent");
|
||||
m_arNumbering[unIndex].m_shWidthAdjust = oChild.GetAttributeInt(L"widthAdjust");
|
||||
if ("PERCENT" == sType)
|
||||
m_arNumbering[unIndex].m_chTextOffsetType = 0;
|
||||
else if ("HWPUNIT" == sType)
|
||||
m_arNumbering[unIndex].m_chTextOffsetType = 1;
|
||||
}
|
||||
else if ("textOffset" == sAttributeName)
|
||||
m_arNumbering[unIndex].m_shTextOffset = oReader.GetInt();
|
||||
else if ("charPrIDRef" == sAttributeName)
|
||||
m_arNumbering[unIndex].m_nCharShape = std::abs(oReader.GetInt());
|
||||
else if ("start" == sAttributeName)
|
||||
m_arNumbering[unIndex].m_nStartNumber = oReader.GetInt();
|
||||
else if ("numFormat" == sAttributeName)
|
||||
sNumFormat = oReader.GetTextA();
|
||||
else if ("level" == sAttributeName)
|
||||
shLevel = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
sType = oChild.GetAttribute(L"textOffsetType");
|
||||
|
||||
if (L"PERCENT" == sType)
|
||||
m_arNumbering[unIndex].m_chTextOffsetType = 0;
|
||||
else if (L"HWPUNIT" == sType)
|
||||
m_arNumbering[unIndex].m_chTextOffsetType = 1;
|
||||
|
||||
m_arNumbering[unIndex].m_shTextOffset = oChild.GetAttributeInt(L"textOffset");
|
||||
|
||||
short shLevel = oChild.GetAttributeInt(L"level");
|
||||
|
||||
sType = oChild.GetAttribute(L"numFormat");
|
||||
|
||||
if (L"DIGIT" == sType)
|
||||
if ("DIGIT" == sNumFormat)
|
||||
{
|
||||
if (shLevel > 0 && shLevel < 11)
|
||||
m_arNumbering[unIndex].m_sNumFormat = L'^' + std::to_wstring(shLevel) + L'.';
|
||||
}
|
||||
else if (L"HANGUL_SYLLABLE" == sType ||
|
||||
L"HANGUL_JAMO" == sType)
|
||||
else if ("HANGUL_SYLLABLE" == sNumFormat ||
|
||||
"HANGUL_JAMO" == sNumFormat)
|
||||
{
|
||||
switch (shLevel)
|
||||
{
|
||||
@ -115,7 +131,7 @@ CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLNode& oNode,
|
||||
case 10: m_arNumbering[unIndex].m_sNumFormat = L"^차."; break;
|
||||
}
|
||||
}
|
||||
else if (L"CIRCLED_DIGIT" == sType)
|
||||
else if ("CIRCLED_DIGIT" == sNumFormat)
|
||||
{
|
||||
switch (shLevel)
|
||||
{
|
||||
@ -131,7 +147,7 @@ CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLNode& oNode,
|
||||
case 10: m_arNumbering[unIndex].m_sNumFormat = L"^\u2469."; break;
|
||||
}
|
||||
}
|
||||
else if (L"LATIN_SMALL" == sType)
|
||||
else if ("LATIN_SMALL" == sNumFormat)
|
||||
{
|
||||
switch (shLevel)
|
||||
{
|
||||
@ -147,7 +163,7 @@ CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLNode& oNode,
|
||||
case 10: m_arNumbering[unIndex].m_sNumFormat = L"^j."; break;
|
||||
}
|
||||
}
|
||||
else if (L"CIRCLED_HANGUL_SYLLABLE" == sType)
|
||||
else if ("CIRCLED_HANGUL_SYLLABLE" == sNumFormat)
|
||||
{
|
||||
switch (shLevel)
|
||||
{
|
||||
@ -163,7 +179,7 @@ CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLNode& oNode,
|
||||
case 10: m_arNumbering[unIndex].m_sNumFormat = L"^\u3277."; break;
|
||||
}
|
||||
}
|
||||
else if (L"ROMAN_SMALL" == sType)
|
||||
else if ("ROMAN_SMALL" == sNumFormat)
|
||||
{
|
||||
switch (shLevel)
|
||||
{
|
||||
@ -180,14 +196,13 @@ CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLNode& oNode,
|
||||
}
|
||||
}
|
||||
|
||||
m_arNumbering[unIndex].m_nCharShape = std::abs(oChild.GetAttributeInt(L"charPrIDRef"));
|
||||
m_arNumbering[unIndex].m_nStartNumber = oChild.GetAttributeInt(L"start");
|
||||
++unIndex;
|
||||
}
|
||||
|
||||
if (7 == unIndex)
|
||||
return;
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
short CHWPRecordNumbering::GetStart() const
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include "../HWPDocInfo.h"
|
||||
#include "../HWPStream.h"
|
||||
#include "HWPRecord.h"
|
||||
#include "../Common/XMLNode.h"
|
||||
#include "../Common/XMLReader.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
@ -36,7 +36,7 @@ class CHWPRecordNumbering : public CHWPRecord
|
||||
int m_arExtLevelStart[3];
|
||||
public:
|
||||
CHWPRecordNumbering(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion);
|
||||
CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
|
||||
short GetStart() const;
|
||||
HWP_STRING GetNumFormat(unsigned short ushIndex) const;
|
||||
|
||||
@ -131,116 +131,166 @@ CHWPRecordParaShape::CHWPRecordParaShape(CHWPDocInfo& oDocInfo, int nTagNum, int
|
||||
oBuffer.Skip(8);
|
||||
}
|
||||
|
||||
CHWPRecordParaShape::CHWPRecordParaShape(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion)
|
||||
CHWPRecordParaShape::CHWPRecordParaShape(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_PARA_SHAPE, 0, 0), m_pParent(&oDocInfo),
|
||||
m_eAlign(EHorizontalAlign::JUSTIFY), m_bWidowOrphan(false), m_bKeepWithNext(false),
|
||||
m_bPageBreakBefore(false), m_eVertAlign(EVerticalAlign::BASELINE), m_eHeadingType(EHeadingType::NONE),
|
||||
m_bConnect(false), m_bIgnoreMargin(false), m_bParaTailShape(false)
|
||||
{
|
||||
m_shTabDef = oNode.GetAttributeInt(L"tabPrIDRef");
|
||||
m_chCondense = (HWP_BYTE)oNode.GetAttributeInt(L"condense");
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("tabPrIDRef" == sAttributeName)
|
||||
m_shTabDef = oReader.GetInt();
|
||||
else if ("condense" == sAttributeName)
|
||||
m_chCondense = (HWP_BYTE)oReader.GetInt();
|
||||
else if ("fontLineHeight" == sAttributeName)
|
||||
m_bFontLineHeight = oReader.GetBool();
|
||||
else if ("snapToGrid" == sAttributeName)
|
||||
m_bSnapToGrid = oReader.GetBool();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
m_bFontLineHeight = oNode.GetAttributeBool(L"fontLineHeight");
|
||||
m_bSnapToGrid = oNode.GetAttributeBool(L"snapToGrid");
|
||||
|
||||
for (CXMLNode& oChild : oNode.GetChilds())
|
||||
RecursiveParaShape(oChild);
|
||||
RecursiveParaShape(oReader);
|
||||
}
|
||||
|
||||
void CHWPRecordParaShape::RecursiveParaShape(CXMLNode& oNode)
|
||||
void CHWPRecordParaShape::RecursiveParaShape(CXMLReader& oReader)
|
||||
{
|
||||
if (L"hh:align" == oNode.GetName())
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
m_eAlign = ::HWP::GetHorizontalAlign(oNode.GetAttribute(L"horizontal"));
|
||||
m_eVertAlign = ::HWP::GetVerticalAlign(oNode.GetAttribute(L"vertical"));
|
||||
}
|
||||
else if (L"hh:heading" == oNode.GetName())
|
||||
{
|
||||
m_eHeadingType = ::HWP::GetHeadingType(oNode.GetAttribute(L"type"));
|
||||
m_shHeadingIdRef = oNode.GetAttributeInt(L"idRef");
|
||||
m_chHeadingLevel = (HWP_BYTE)oNode.GetAttributeInt(L"level");
|
||||
}
|
||||
else if (L"hh:breakSetting" == oNode.GetName())
|
||||
{
|
||||
HWP_STRING sType = oNode.GetAttribute(L"breakLatinWord");
|
||||
|
||||
if (L"KEEP_WORD" == sType)
|
||||
m_chBreakLatinWord = 0;
|
||||
else if (L"BREAK_WORD" == sType)
|
||||
m_chBreakLatinWord = 1;
|
||||
|
||||
sType = oNode.GetAttribute(L"breakNonLatinWord");
|
||||
|
||||
if (L"KEEP_WORD" == sType)
|
||||
m_chBreakNonLatinWord = 0;
|
||||
else if (L"BREAK_WORD" == sType)
|
||||
m_chBreakNonLatinWord = 1;
|
||||
|
||||
m_bWidowOrphan = oNode.GetAttributeBool(L"widowOrphan");
|
||||
m_bKeepWithNext = oNode.GetAttributeBool(L"keepWithNext");
|
||||
m_bPageBreakBefore = oNode.GetAttributeBool(L"pageBreakBefore");
|
||||
|
||||
sType = oNode.GetAttribute(L"lineWrap");
|
||||
|
||||
if (L"BREAK" == sType)
|
||||
m_chLineWrap = 0;
|
||||
else if (L"SQUEEZE" == sType)
|
||||
m_chLineWrap = 1;
|
||||
}
|
||||
else if (L"hh:lineSpacing" == oNode.GetName())
|
||||
{
|
||||
HWP_STRING sType = oNode.GetAttribute(L"type");
|
||||
|
||||
if (L"PERCENT" == sType)
|
||||
m_nLineSpacingType = 0;
|
||||
else if (L"FIXED" == sType)
|
||||
m_nLineSpacingType = 1;
|
||||
else if (L"BETWEENLINES" == sType)
|
||||
m_nLineSpacingType = 2;
|
||||
else if (L"AT_LEAST" == sType)
|
||||
m_nLineSpacingType = 4;
|
||||
|
||||
m_nLineSpacing = oNode.GetAttributeInt(L"value");
|
||||
}
|
||||
else if (L"hh:border" == oNode.GetName())
|
||||
{
|
||||
m_shBorderFill = oNode.GetAttributeInt(L"borderFillIDRef");
|
||||
m_shOffsetLeft = oNode.GetAttributeInt(L"offsetLeft");
|
||||
m_shOffsetRight = oNode.GetAttributeInt(L"offsetRight");
|
||||
m_shOffsetTop = oNode.GetAttributeInt(L"offsetTop");
|
||||
m_shOffsetBottom = oNode.GetAttributeInt(L"offsetBottom");
|
||||
|
||||
m_bConnect = oNode.GetAttributeBool(L"connect");
|
||||
m_bIgnoreMargin = oNode.GetAttributeBool(L"ignoreMargin");
|
||||
}
|
||||
else if (L"hh:autoSpacing" == oNode.GetName())
|
||||
{
|
||||
m_bAutoSpaceEAsianEng = oNode.GetAttributeBool(L"eAsianEng");
|
||||
m_bAutoSpaceEAsianNum = oNode.GetAttributeBool(L"eAsianNum");
|
||||
}
|
||||
else if (L"hc:intent" == oNode.GetName())
|
||||
m_nIndent = oNode.GetAttributeInt(L"value");
|
||||
else if (L"hc:left" == oNode.GetName())
|
||||
m_nMarginLeft = oNode.GetAttributeInt(L"value");
|
||||
else if (L"hc:right" == oNode.GetName())
|
||||
m_nMarginRight = oNode.GetAttributeInt(L"value");
|
||||
else if (L"hc:prev" == oNode.GetName())
|
||||
m_nMarginPrev = oNode.GetAttributeInt(L"value");
|
||||
else if (L"hc:next" == oNode.GetName())
|
||||
m_nMarginNext = oNode.GetAttributeInt(L"value");
|
||||
else if (/*L"hp:switch" == oNode.GetName() ||
|
||||
L"hp:case" == oNode.GetName() ||
|
||||
L"hp:default" == oNode.GetName() ||*/
|
||||
L"hh:margin" == oNode.GetName())
|
||||
{
|
||||
for (CXMLNode& oChild : oNode.GetChilds())
|
||||
RecursiveParaShape(oChild);
|
||||
}
|
||||
else if (L"hp:switch" == oNode.GetName())
|
||||
{
|
||||
for (CXMLNode& oChild : oNode.GetChild(L"hp:default").GetChilds())
|
||||
RecursiveParaShape(oChild);
|
||||
if ("hh:align" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("horizontal" == sAttributeName)
|
||||
m_eAlign = ::HWP::GetHorizontalAlign(oReader.GetText());
|
||||
else if ("vertical" == sAttributeName)
|
||||
m_eVertAlign = ::HWP::GetVerticalAlign(oReader.GetText());
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("hh:heading" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("type" == sAttributeName)
|
||||
m_eHeadingType = ::HWP::GetHeadingType(oReader.GetText());
|
||||
else if ("idRef" == sAttributeName)
|
||||
m_shHeadingIdRef = oReader.GetInt();
|
||||
else if ("level" == sAttributeName)
|
||||
m_chHeadingLevel = (HWP_BYTE)oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("hh:breakSetting" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("breakLatinWord" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if ("KEEP_WORD" == sType)
|
||||
m_chBreakLatinWord = 0;
|
||||
else if ("BREAK_WORD" == sType)
|
||||
m_chBreakLatinWord = 1;
|
||||
}
|
||||
else if ("breakNonLatinWord" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if ("KEEP_WORD" == sType)
|
||||
m_chBreakNonLatinWord = 0;
|
||||
else if ("BREAK_WORD" == sType)
|
||||
m_chBreakNonLatinWord = 1;
|
||||
}
|
||||
else if ("widowOrphan" == sAttributeName)
|
||||
m_bWidowOrphan = oReader.GetBool();
|
||||
else if ("keepWithNext" == sAttributeName)
|
||||
m_bKeepWithNext = oReader.GetBool();
|
||||
else if ("pageBreakBefore" == sAttributeName)
|
||||
m_bPageBreakBefore = oReader.GetBool();
|
||||
else if ("lineWrap" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if ("BREAK" == sType)
|
||||
m_chLineWrap = 0;
|
||||
else if ("SQUEEZE" == sType)
|
||||
m_chLineWrap = 1;
|
||||
}
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("hh:lineSpacing" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("type" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if ("PERCENT" == sType)
|
||||
m_nLineSpacingType = 0;
|
||||
else if ("FIXED" == sType)
|
||||
m_nLineSpacingType = 1;
|
||||
else if ("BETWEENLINES" == sType)
|
||||
m_nLineSpacingType = 2;
|
||||
else if ("AT_LEAST" == sType)
|
||||
m_nLineSpacingType = 4;
|
||||
}
|
||||
else if ("value" == sAttributeName)
|
||||
m_nLineSpacing = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("hh:border" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("borderFillIDRef" == sAttributeName)
|
||||
m_shBorderFill = oReader.GetInt();
|
||||
else if ("offsetLeft" == sAttributeName)
|
||||
m_shOffsetLeft = oReader.GetInt();
|
||||
else if ("offsetRight" == sAttributeName)
|
||||
m_shOffsetRight = oReader.GetInt();
|
||||
else if ("offsetTop" == sAttributeName)
|
||||
m_shOffsetTop = oReader.GetInt();
|
||||
else if ("offsetBottom" == sAttributeName)
|
||||
m_shOffsetBottom = oReader.GetInt();
|
||||
else if ("connect" == sAttributeName)
|
||||
m_bConnect = oReader.GetBool();
|
||||
else if ("ignoreMargin" == sAttributeName)
|
||||
m_bIgnoreMargin = oReader.GetBool();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("hh:autoSpacing" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("eAsianEng" == sAttributeName)
|
||||
m_bAutoSpaceEAsianEng = oReader.GetBool();
|
||||
else if ("eAsianNum" == sAttributeName)
|
||||
m_bAutoSpaceEAsianNum = oReader.GetBool();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("hc:intent" == sNodeName)
|
||||
m_nIndent = oReader.GetAttributeInt("value");
|
||||
else if ("hc:left" == sNodeName)
|
||||
m_nMarginLeft = oReader.GetAttributeInt("value");
|
||||
else if ("hc:right" == sNodeName)
|
||||
m_nMarginRight = oReader.GetAttributeInt("value");
|
||||
else if ("hc:prev" == sNodeName)
|
||||
m_nMarginPrev = oReader.GetAttributeInt("value");
|
||||
else if ("hc:next" == sNodeName)
|
||||
m_nMarginNext = oReader.GetAttributeInt("value");
|
||||
else if ("hh:margin" == sNodeName ||
|
||||
"hp:switch" == sNodeName ||
|
||||
"hp:default" == sNodeName)
|
||||
RecursiveParaShape(oReader);
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
EHorizontalAlign CHWPRecordParaShape::GetHorizantalAlign() const
|
||||
@ -308,6 +358,11 @@ int CHWPRecordParaShape::GetRightIndent() const
|
||||
return m_nMarginRight;
|
||||
}
|
||||
|
||||
short CHWPRecordParaShape::GetTabDef() const
|
||||
{
|
||||
return m_shTabDef;
|
||||
}
|
||||
|
||||
bool CHWPRecordParaShape::KeepWithNext() const
|
||||
{
|
||||
return m_bKeepWithNext;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
#include "HWPRecord.h"
|
||||
#include "../HWPDocInfo.h"
|
||||
#include "../Common/XMLNode.h"
|
||||
#include "../Common/XMLReader.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
@ -74,10 +74,10 @@ class CHWPRecordParaShape : public CHWPRecord
|
||||
bool m_bAutoSpaceEAsianNum;
|
||||
|
||||
int m_nLineSpacingType;
|
||||
void RecursiveParaShape(CXMLNode& oNode);
|
||||
void RecursiveParaShape(CXMLReader& oReader);
|
||||
public:
|
||||
CHWPRecordParaShape(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordParaShape(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion);
|
||||
CHWPRecordParaShape(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
|
||||
EHorizontalAlign GetHorizantalAlign() const;
|
||||
EVerticalAlign GetVerticalAlign() const;
|
||||
@ -94,6 +94,8 @@ public:
|
||||
int GetLeftIndent() const;
|
||||
int GetRightIndent() const;
|
||||
|
||||
short GetTabDef() const;
|
||||
|
||||
bool KeepWithNext() const;
|
||||
};
|
||||
}
|
||||
|
||||
@ -148,11 +148,21 @@ LIST<CCtrl*> CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS
|
||||
unIndex += unInfoLength + 2;
|
||||
break;
|
||||
}
|
||||
case 0x09: // Tabs
|
||||
{
|
||||
UPDATE_CURRENT_TEXT();
|
||||
|
||||
if (sText.length() < unIndex + 6 || (sText[unIndex] != sText[unIndex + 6] && sText[unIndex] != sText[unIndex + 7]))
|
||||
continue;
|
||||
|
||||
arParas.push_back(new CCtrlCharacter(L" _", ECtrlCharType::TABULATION));
|
||||
unIndex += 6;
|
||||
break;
|
||||
}
|
||||
case 0x05: // Scheduling
|
||||
case 0x06: // Scheduling
|
||||
case 0x07: // Scheduling
|
||||
case 0x08: // Title mark
|
||||
case 0x09: // Tabs
|
||||
case 0x13: // Scheduling
|
||||
case 0x14: // Scheduling
|
||||
{
|
||||
|
||||
@ -20,23 +20,36 @@ CHWPRecordStyle::CHWPRecordStyle(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel,
|
||||
m_nCharShape = oBuffer.ReadShort();
|
||||
}
|
||||
|
||||
CHWPRecordStyle::CHWPRecordStyle(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion)
|
||||
CHWPRecordStyle::CHWPRecordStyle(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_STYLE, 0, 0), m_pParent(&oDocInfo)
|
||||
{
|
||||
HWP_STRING sType = oNode.GetAttribute(L"type");
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("type" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if (L"PARA" == sType)
|
||||
m_chType = 0;
|
||||
else if (L"CHAR" == sType)
|
||||
m_chType = 1;
|
||||
|
||||
m_sName = oNode.GetAttribute(L"name");
|
||||
m_sEngName = oNode.GetAttribute(L"engName");
|
||||
m_nParaShape = oNode.GetAttributeInt(L"paraPrIDRef");
|
||||
m_nCharShape = oNode.GetAttributeInt(L"charPrIDRef");
|
||||
m_chNextStyle = oNode.GetAttributeInt(L"nextStyleIDRef");
|
||||
m_shLangID = oNode.GetAttributeInt(L"langID");
|
||||
m_bLockForm = oNode.GetAttributeBool(L"lockForm");
|
||||
if ("PARA" == sType)
|
||||
m_chType = 0;
|
||||
else if ("CHAR" == sType)
|
||||
m_chType = 1;
|
||||
}
|
||||
else if ("name" == sAttributeName)
|
||||
m_sName = oReader.GetText();
|
||||
else if ("engName" == sAttributeName)
|
||||
m_sEngName = oReader.GetText();
|
||||
else if ("paraPrIDRef" == sAttributeName)
|
||||
m_nParaShape = oReader.GetInt();
|
||||
else if ("charPrIDRef" == sAttributeName)
|
||||
m_nCharShape = oReader.GetInt();
|
||||
else if ("nextStyleIDRef" == sAttributeName)
|
||||
m_chNextStyle = oReader.GetInt();
|
||||
else if ("langID" == sAttributeName)
|
||||
m_shLangID = oReader.GetInt();
|
||||
else if ("lockForm" == sAttributeName)
|
||||
m_bLockForm = oReader.GetBool();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
|
||||
HWP_STRING CHWPRecordStyle::GetName() const
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
#include "HWPRecord.h"
|
||||
#include "../HWPDocInfo.h"
|
||||
#include "../Common/XMLNode.h"
|
||||
#include "../Common/XMLReader.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
@ -22,7 +22,7 @@ class CHWPRecordStyle : public CHWPRecord
|
||||
public:
|
||||
CHWPRecordStyle(int nTagNum, int nLevel, int nSize);
|
||||
CHWPRecordStyle(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordStyle(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion);
|
||||
CHWPRecordStyle(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
|
||||
HWP_STRING GetName() const;
|
||||
HWP_STRING GetEngName() const;
|
||||
|
||||
@ -5,11 +5,18 @@ namespace HWP
|
||||
TTab::TTab()
|
||||
{}
|
||||
|
||||
TTab::TTab(CXMLNode& oNode)
|
||||
TTab::TTab(CXMLReader& oReader)
|
||||
{
|
||||
m_nPos = oNode.GetAttributeInt(L"pos");
|
||||
SetType(oNode.GetAttributeInt(L"type"));
|
||||
m_eLeader = GetLineStyle2(oNode.GetAttribute(L"leader"));
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("pos" == sAttributeName)
|
||||
m_nPos = oReader.GetInt();
|
||||
else if ("type" == sAttributeName)
|
||||
SetType(oReader.GetInt());
|
||||
else if ("leader" == sAttributeName)
|
||||
m_eLeader = GetLineStyle2(oReader.GetText());
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
|
||||
void TTab::SetType(int nValue)
|
||||
@ -24,7 +31,7 @@ void TTab::SetType(int nValue)
|
||||
}
|
||||
|
||||
CHwpRecordTabDef::CHwpRecordTabDef(int nTagNum, int nLevel, int nSize)
|
||||
: CHWPRecord(nTagNum, nLevel, nSize), m_pParent(nullptr)
|
||||
: CHWPRecord(nTagNum, nLevel, nSize), m_pParent(nullptr), m_nAttr(0)
|
||||
{}
|
||||
|
||||
CHwpRecordTabDef::CHwpRecordTabDef(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
|
||||
@ -33,13 +40,15 @@ CHwpRecordTabDef::CHwpRecordTabDef(CHWPDocInfo& oDocInfo, int nTagNum, int nLeve
|
||||
oBuffer.SavePosition();
|
||||
|
||||
oBuffer.ReadInt(m_nAttr);
|
||||
oBuffer.ReadInt(m_nCount);
|
||||
|
||||
if (nSize - oBuffer.GetDistanceToLastPos() != m_nCount * 8)
|
||||
int nCount = 0;
|
||||
oBuffer.ReadInt(nCount);
|
||||
|
||||
if (nSize - oBuffer.GetDistanceToLastPos() != nCount * 8)
|
||||
return; // TODO:: ошибка
|
||||
|
||||
TTab *pTab = nullptr;
|
||||
for (unsigned int unIndex = 0; unIndex < m_nCount; ++unIndex)
|
||||
for (unsigned int unIndex = 0; unIndex < nCount; ++unIndex)
|
||||
{
|
||||
pTab = new TTab();
|
||||
|
||||
@ -60,24 +69,48 @@ CHwpRecordTabDef::CHwpRecordTabDef(CHWPDocInfo& oDocInfo, int nTagNum, int nLeve
|
||||
oBuffer.RemoveLastSavedPos();
|
||||
}
|
||||
|
||||
CHwpRecordTabDef::CHwpRecordTabDef(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_TAB_DEF, 0, 0), m_pParent(&oDocInfo)
|
||||
CHwpRecordTabDef::CHwpRecordTabDef(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_TAB_DEF, 0, 0), m_pParent(&oDocInfo), m_nAttr(0)
|
||||
{
|
||||
if (oNode.GetAttributeBool(L"autoTabLeft"))
|
||||
m_nAttr |= 0x00000001;
|
||||
else
|
||||
m_nAttr &= 0xFFFFFFFE;
|
||||
|
||||
if (oNode.GetAttributeBool(L"autoTabRight"))
|
||||
m_nAttr |= 0x00000002;
|
||||
else
|
||||
m_nAttr &= 0xFFFFFFFD;
|
||||
|
||||
for (CXMLNode& oChild : oNode.GetChilds(L"hp:switch"))
|
||||
for (CXMLNode& oGrandChild : oChild.GetChilds(L"hp:default"))
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("autoTabLeft" == sAttributeName)
|
||||
{
|
||||
CXMLNode oTabItem{oGrandChild.GetChild(L"hh:tabItem")};
|
||||
m_arTabs.push_back(new TTab(oTabItem));
|
||||
if (oReader.GetBool())
|
||||
m_nAttr |= 0x00000001;
|
||||
else
|
||||
m_nAttr &= 0xFFFFFFFE;
|
||||
}
|
||||
else if ("autoTabRight" == sAttributeName)
|
||||
{
|
||||
if (oReader.GetBool())
|
||||
m_nAttr |= 0x00000002;
|
||||
else
|
||||
m_nAttr &= 0xFFFFFFFD;
|
||||
}
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hp:switch")
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Child, "hp:default")
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, TabChild, "hh:tabItem")
|
||||
m_arTabs.push_back(new TTab(oReader));
|
||||
END_WHILE
|
||||
END_WHILE
|
||||
END_WHILE
|
||||
|
||||
}
|
||||
|
||||
int CHwpRecordTabDef::GetCount() const
|
||||
{
|
||||
return m_arTabs.size();
|
||||
}
|
||||
|
||||
const TTab* CHwpRecordTabDef::GetTab(unsigned int unIndex) const
|
||||
{
|
||||
if (unIndex >= m_arTabs.size())
|
||||
return nullptr;
|
||||
|
||||
return dynamic_cast<const TTab*>(m_arTabs.at(unIndex));
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include "HWPRecord.h"
|
||||
#include "../HWPDocInfo.h"
|
||||
#include "HwpRecordTypes.h"
|
||||
#include "../Common/XMLNode.h"
|
||||
#include "../Common/XMLReader.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
@ -22,7 +22,7 @@ struct TTab
|
||||
|
||||
|
||||
TTab();
|
||||
TTab(CXMLNode& oNode);
|
||||
TTab(CXMLReader& oReader);
|
||||
|
||||
void SetType(int nValue);
|
||||
};
|
||||
@ -32,12 +32,14 @@ class CHwpRecordTabDef : public CHWPRecord
|
||||
CHWPDocInfo *m_pParent;
|
||||
|
||||
int m_nAttr;
|
||||
int m_nCount;
|
||||
LIST<TTab*> m_arTabs;
|
||||
VECTOR<TTab*> m_arTabs;
|
||||
public:
|
||||
CHwpRecordTabDef(int nTagNum, int nLevel, int nSize);
|
||||
CHwpRecordTabDef(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHwpRecordTabDef(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion);
|
||||
CHwpRecordTabDef(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
|
||||
int GetCount() const;
|
||||
const TTab* GetTab(unsigned int unIndex) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -111,14 +111,11 @@ CHWPSection::~CHWPSection()
|
||||
CLEAR_ARRAY(CHWPPargraph, m_arParas);
|
||||
}
|
||||
|
||||
bool CHWPSection::Parse(CXMLNode& oNode, int nVersion)
|
||||
bool CHWPSection::Parse(CXMLReader& oReader, int nVersion)
|
||||
{
|
||||
std::vector<CXMLNode> arParagraphNodes{oNode.GetChilds(L"hp:p")};
|
||||
|
||||
m_arParas.resize(arParagraphNodes.size());
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < arParagraphNodes.size(); ++unIndex)
|
||||
m_arParas[unIndex] = new CHWPPargraph(arParagraphNodes[unIndex], nVersion);
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hp:p")
|
||||
m_arParas.push_back(new CHWPPargraph(oReader, nVersion));
|
||||
END_WHILE
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ public:
|
||||
CHWPSection();
|
||||
~CHWPSection();
|
||||
|
||||
bool Parse(CXMLNode& oNode, int nVersion);
|
||||
bool Parse(CXMLReader& oReader, int nVersion);
|
||||
bool Parse(CHWPStream& oBuffer, int nVersion);
|
||||
int ParseRecurse(CHWPPargraph* oCurrPara, int nRunLevel, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
int ParseCtrlRecurse(CCtrl* oCurrCtrl, int nRunLevel, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
|
||||
@ -115,8 +115,12 @@ VECTOR<HWP_STRING> CHWPXFile::GetPathsToSections() const
|
||||
|
||||
bool CHWPXFile::GetFileHeader()
|
||||
{
|
||||
CXMLNode oVersionXml{GetDocument(L"version.xml")};
|
||||
return m_oFileHeader.Parse(oVersionXml);
|
||||
CXMLReader oReader;
|
||||
|
||||
if (!GetDocument(L"version.xml", oReader))
|
||||
return false;
|
||||
|
||||
return m_oFileHeader.Parse(oReader);
|
||||
}
|
||||
|
||||
const CHWPDocInfo* CHWPXFile::GetDocInfo() const
|
||||
@ -146,11 +150,19 @@ bool CHWPXFile::GetChildStream(const HWP_STRING& sFileName, CHWPStream& oBuffer)
|
||||
|
||||
bool CHWPXFile::GetDocInfo(int nVersion)
|
||||
{
|
||||
CXMLNode oContent{GetDocument(L"Contents/content.hpf")};
|
||||
if (m_oDocInfo.ReadContentHpf(oContent, nVersion))
|
||||
CXMLReader oContentReader;
|
||||
|
||||
if (!GetDocument(L"Contents/content.hpf", oContentReader))
|
||||
return false;
|
||||
|
||||
if (m_oDocInfo.ReadContentHpf(oContentReader, nVersion))
|
||||
{
|
||||
CXMLNode oHeader{GetDocument(L"Contents/header.xml")};
|
||||
return m_oDocInfo.Parse(oHeader, nVersion);
|
||||
CXMLReader oHeaderReader;
|
||||
|
||||
if (!GetDocument(L"Contents/header.xml", oHeaderReader))
|
||||
return false;
|
||||
|
||||
return m_oDocInfo.Parse(oHeaderReader, nVersion);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -158,10 +170,13 @@ bool CHWPXFile::GetDocInfo(int nVersion)
|
||||
|
||||
bool CHWPXFile::ReadSection(const HWP_STRING& sName, int nVersion)
|
||||
{
|
||||
CXMLNode oRootNode{GetDocument(sName)};
|
||||
CXMLReader oReader;
|
||||
|
||||
if (!GetDocument(sName, oReader))
|
||||
return false;
|
||||
|
||||
CHWPSection* pSection = new CHWPSection();
|
||||
const bool bResult = pSection->Parse(oRootNode, nVersion);
|
||||
const bool bResult = pSection->Parse(oReader, nVersion);
|
||||
|
||||
if (bResult)
|
||||
m_arSections.push_back(pSection);
|
||||
@ -171,11 +186,14 @@ bool CHWPXFile::ReadSection(const HWP_STRING& sName, int nVersion)
|
||||
return bResult;
|
||||
}
|
||||
|
||||
CXMLNode CHWPXFile::GetDocument(const HWP_STRING& sEntryName)
|
||||
bool CHWPXFile::GetDocument(const HWP_STRING& sEntryName, CXMLReader& oReader)
|
||||
{
|
||||
if (nullptr == m_pZipFolder)
|
||||
return CXMLNode();
|
||||
if (nullptr == m_pZipFolder || nullptr == oReader.GetReader())
|
||||
return false;
|
||||
|
||||
return CXMLNode(m_pZipFolder->getNodeFromFile(sEntryName));
|
||||
if (m_pZipFolder->getReaderFromFile(sEntryName, *oReader.GetReader()))
|
||||
return oReader.ReadNextNode();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ private:
|
||||
bool GetFileHeader();
|
||||
bool GetDocInfo(int nVersion);
|
||||
bool ReadSection(const HWP_STRING& sName, int nVersion);
|
||||
CXMLNode GetDocument(const HWP_STRING& sEntryName);
|
||||
bool GetDocument(const HWP_STRING& sEntryName, CXMLReader& oReader);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -60,15 +60,27 @@ bool CHwpFileHeader::Parse(CHWPStream& oBuffer)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CHwpFileHeader::Parse(CXMLNode& oNode)
|
||||
bool CHwpFileHeader::Parse(CXMLReader& oReader)
|
||||
{
|
||||
if (!oNode.IsValid())
|
||||
return false;
|
||||
HWP_STRING wsMajor, wsMinor, wsMicro, wsBuildNumber;
|
||||
|
||||
m_sVersion += oNode.GetAttribute(L"major");
|
||||
m_sVersion += oNode.GetAttribute(L"minor");
|
||||
m_sVersion += oNode.GetAttribute(L"micro");
|
||||
m_sVersion += oNode.GetAttribute(L"buildNumber");
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("major" == sAttributeName)
|
||||
wsMajor = oReader.GetText();
|
||||
else if ("minor" == sAttributeName)
|
||||
wsMinor = oReader.GetText();
|
||||
else if ("micro" == sAttributeName)
|
||||
wsMicro = oReader.GetText();
|
||||
else if ("buildNumber" == sAttributeName)
|
||||
wsBuildNumber = oReader.GetText();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
m_sVersion = ((!wsMajor.empty()) ? wsMajor : L"0") +
|
||||
((!wsMinor.empty()) ? wsMinor : L"0") +
|
||||
((!wsMicro.empty()) ? wsMicro : L"0") +
|
||||
((!wsBuildNumber.empty()) ? wsBuildNumber : L"0");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#define HWPFILEHEADER_H
|
||||
|
||||
#include "HWPStream.h"
|
||||
#include "Common/XMLNode.h"
|
||||
#include "Common/XMLReader.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
@ -47,7 +47,7 @@ public:
|
||||
HWP_STRING GetVersion() const;
|
||||
|
||||
bool Parse(CHWPStream& oBuffer);
|
||||
bool Parse(CXMLNode& oNode);
|
||||
bool Parse(CXMLReader& oReader);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -6,8 +6,8 @@ CCapParagraph::CCapParagraph()
|
||||
: CHWPPargraph()
|
||||
{}
|
||||
|
||||
CCapParagraph::CCapParagraph(CXMLNode& oNode, int nVersion)
|
||||
: CHWPPargraph(oNode, nVersion)
|
||||
CCapParagraph::CCapParagraph(CXMLReader& oReader, int nVersion)
|
||||
: CHWPPargraph(oReader, nVersion)
|
||||
{}
|
||||
|
||||
EParagraphType CCapParagraph::GetType() const
|
||||
|
||||
@ -9,7 +9,7 @@ class CCapParagraph : public CHWPPargraph
|
||||
{
|
||||
public:
|
||||
CCapParagraph();
|
||||
CCapParagraph(CXMLNode& oNode, int nVersion);
|
||||
CCapParagraph(CXMLReader& oReader, int nVersion);
|
||||
|
||||
EParagraphType GetType() const override;
|
||||
};
|
||||
|
||||
@ -7,8 +7,8 @@ CCellParagraph::CCellParagraph()
|
||||
{
|
||||
}
|
||||
|
||||
CCellParagraph::CCellParagraph(CXMLNode& oNode, int nVersion)
|
||||
: CHWPPargraph(oNode, nVersion)
|
||||
CCellParagraph::CCellParagraph(CXMLReader& oReader, int nVersion)
|
||||
: CHWPPargraph(oReader, nVersion)
|
||||
{}
|
||||
|
||||
EParagraphType CCellParagraph::GetType() const
|
||||
|
||||
@ -9,7 +9,7 @@ class CCellParagraph : public CHWPPargraph
|
||||
{
|
||||
public:
|
||||
CCellParagraph();
|
||||
CCellParagraph(CXMLNode& oNode, int nVersion);
|
||||
CCellParagraph(CXMLReader& oReader, int nVersion);
|
||||
|
||||
EParagraphType GetType() const override;
|
||||
};
|
||||
|
||||
@ -2,9 +2,6 @@
|
||||
#define COMMONOBJ_H
|
||||
|
||||
#include "HWPPargraph.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
|
||||
@ -50,27 +50,29 @@ bool CCtrl::Equals(CCtrl* pFirstCtrl, CCtrl* pSecondCtrl)
|
||||
pFirstCtrl->m_bFullFilled == pSecondCtrl->m_bFullFilled;
|
||||
}
|
||||
|
||||
CCtrl* CCtrl::GetCtrl(CXMLNode& oNode, int nVersion)
|
||||
CCtrl* CCtrl::GetCtrl(CXMLReader& oReader, int nVersion)
|
||||
{
|
||||
if (L"hp:colPr" == oNode.GetName())
|
||||
return new CCtrlColumnDef(L"dloc", oNode, nVersion);
|
||||
else if (L"hp:header" == oNode.GetName())
|
||||
return new CCtrlHeadFoot(L"daeh", oNode, nVersion);
|
||||
else if (L"hp:footer" == oNode.GetName())
|
||||
return new CCtrlHeadFoot(L"toof", oNode, nVersion);
|
||||
else if (L"hp:footNote" == oNode.GetName())
|
||||
return new CCtrlNote(L" nf", oNode, nVersion);
|
||||
else if (L"hp:endNote" == oNode.GetName())
|
||||
return new CCtrlNote(L" ne", oNode, nVersion);
|
||||
else if (L"hp:autoNum" == oNode.GetName())
|
||||
return new CCtrlAutoNumber(L"onta", oNode, nVersion);
|
||||
else if (L"hp:newNum" == oNode.GetName())
|
||||
return new CCtrlNewNumber(L"onwn", oNode, nVersion);
|
||||
else if (L"hp:pageNum" == oNode.GetName())
|
||||
return new CCtrlPageNumPos(L"pngp", oNode, nVersion);
|
||||
else if (L"hp:fieldBegin" == oNode.GetName() ||
|
||||
L"hp:fieldEnd" == oNode.GetName())
|
||||
return new CCtrlField(L"", oNode, nVersion);
|
||||
const std::string sNodeName{oReader.GetName()};
|
||||
|
||||
if ("hp:colPr" == sNodeName)
|
||||
return new CCtrlColumnDef(L"dloc", oReader, nVersion);
|
||||
else if ("hp:header" == sNodeName)
|
||||
return new CCtrlHeadFoot(L"daeh", oReader, nVersion);
|
||||
else if ("hp:footer" == sNodeName)
|
||||
return new CCtrlHeadFoot(L"toof", oReader, nVersion);
|
||||
else if ("hp:footNote" == sNodeName)
|
||||
return new CCtrlNote(L" nf", oReader, nVersion);
|
||||
else if ("hp:endNote" == sNodeName)
|
||||
return new CCtrlNote(L" ne", oReader, nVersion);
|
||||
else if ("hp:autoNum" == sNodeName)
|
||||
return new CCtrlAutoNumber(L"onta", oReader, nVersion);
|
||||
else if ("hp:newNum" == sNodeName)
|
||||
return new CCtrlNewNumber(L"onwn", oReader, nVersion);
|
||||
else if ("hp:pageNum" == sNodeName)
|
||||
return new CCtrlPageNumPos(L"pngp", oReader, nVersion);
|
||||
else if ("hp:fieldBegin" == sNodeName ||
|
||||
"hp:fieldEnd" == sNodeName)
|
||||
return new CCtrlField(L"", oReader, nVersion);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#define CTRL_H
|
||||
|
||||
#include "../Common/Common.h"
|
||||
#include "../Common/XMLNode.h"
|
||||
#include "../Common/XMLReader.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
@ -46,7 +46,7 @@ public:
|
||||
void SetFullFilled();
|
||||
|
||||
static bool Equals(CCtrl* pFirstCtrl, CCtrl* pSecondCtrl);
|
||||
static CCtrl* GetCtrl(CXMLNode& oNode, int nVersion);
|
||||
static CCtrl* GetCtrl(CXMLReader& oReader, int nVersion);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -44,58 +44,65 @@ CCtrlAutoNumber::CCtrlAutoNumber(const HWP_STRING& sCtrlID, int nSize, CHWPStrea
|
||||
m_bFullFilled = true;
|
||||
}
|
||||
|
||||
CCtrlAutoNumber::CCtrlAutoNumber(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion)
|
||||
CCtrlAutoNumber::CCtrlAutoNumber(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion)
|
||||
: CCtrl(sCtrlID)
|
||||
{
|
||||
m_eNumType = ::HWP::GetNumType(oNode.GetAttribute(L"numType"));
|
||||
m_eNumType = ::HWP::GetNumType(oReader.GetAttribute("numType"));
|
||||
|
||||
HWP_STRING sType;
|
||||
|
||||
for (CXMLNode& oChild : oNode.GetChilds())
|
||||
WHILE_READ_NEXT_NODE(oReader)
|
||||
{
|
||||
m_bSuperscript = oChild.GetAttributeBool(L"supscript");
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("supscript" == sAttributeName)
|
||||
m_bSuperscript = oReader.GetBool();
|
||||
else if ("type" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
sType = oChild.GetAttribute(L"type");
|
||||
|
||||
if (L"DIGIT" == sType)
|
||||
m_eNumShape = ENumberShape2::DIGIT;
|
||||
else if (L"CIRCLE_DIGIT" == sType)
|
||||
m_eNumShape = ENumberShape2::CIRCLE_DIGIT;
|
||||
else if (L"ROMAN_CAPITAL" == sType)
|
||||
m_eNumShape = ENumberShape2::ROMAN_CAPITAL;
|
||||
else if (L"ROMAN_SMALL" == sType)
|
||||
m_eNumShape = ENumberShape2::ROMAN_SMALL;
|
||||
else if (L"LATIN_CAPITAL" == sType)
|
||||
m_eNumShape = ENumberShape2::LATIN_CAPITAL;
|
||||
else if (L"LATIN_SMALL" == sType)
|
||||
m_eNumShape = ENumberShape2::LATIN_SMALL;
|
||||
else if (L"CIRCLED_LATIN_CAPITAL" == sType)
|
||||
m_eNumShape = ENumberShape2::CIRCLED_LATIN_CAPITAL;
|
||||
else if (L"CIRCLED_LATIN_SMALL" == sType)
|
||||
m_eNumShape = ENumberShape2::CIRCLED_LATIN_SMALL;
|
||||
else if (L"CIRCLED_HANGUL_SYLLABLE" == sType)
|
||||
m_eNumShape = ENumberShape2::CIRCLED_HANGUL_SYLLABLE;
|
||||
else if (L"HANGUL_JAMO" == sType)
|
||||
m_eNumShape = ENumberShape2::HANGUL_JAMO;
|
||||
else if (L"CIRCLED_HANGUL_JAMO" == sType)
|
||||
m_eNumShape = ENumberShape2::CIRCLED_HANGUL_JAMO;
|
||||
else if (L"HANGUL_PHONETIC" == sType)
|
||||
m_eNumShape = ENumberShape2::HANGUL_PHONETIC;
|
||||
else if (L"IDEOGRAPH" == sType)
|
||||
m_eNumShape = ENumberShape2::IDEOGRAPH;
|
||||
else if (L"CIRCLED_IDEOGRAPH" == sType)
|
||||
m_eNumShape = ENumberShape2::CIRCLED_IDEOGRAPH;
|
||||
else if (L"DECAGON_CIRCLE" == sType)
|
||||
m_eNumShape = ENumberShape2::DECAGON_CIRCLE;
|
||||
else if (L"DECAGON_CRICLE_HANGJA" == sType)
|
||||
m_eNumShape = ENumberShape2::DECAGON_CRICLE_HANGJA;
|
||||
else if (L"SYMBOL" == sType)
|
||||
m_eNumShape = ENumberShape2::SYMBOL;
|
||||
else if (L"USER_CHAR" == sType)
|
||||
m_eNumShape = ENumberShape2::USER_HWP_CHAR;
|
||||
|
||||
m_eNumShape = GetNumberShape2(oChild.GetAttributeInt(L"hp:autoNumFormat", oChild.GetAttributeInt(L"autoNumFormat")));
|
||||
if ("DIGIT" == sType)
|
||||
m_eNumShape = ENumberShape2::DIGIT;
|
||||
else if ("CIRCLE_DIGIT" == sType)
|
||||
m_eNumShape = ENumberShape2::CIRCLE_DIGIT;
|
||||
else if ("ROMAN_CAPITAL" == sType)
|
||||
m_eNumShape = ENumberShape2::ROMAN_CAPITAL;
|
||||
else if ("ROMAN_SMALL" == sType)
|
||||
m_eNumShape = ENumberShape2::ROMAN_SMALL;
|
||||
else if ("LATIN_CAPITAL" == sType)
|
||||
m_eNumShape = ENumberShape2::LATIN_CAPITAL;
|
||||
else if ("LATIN_SMALL" == sType)
|
||||
m_eNumShape = ENumberShape2::LATIN_SMALL;
|
||||
else if ("CIRCLED_LATIN_CAPITAL" == sType)
|
||||
m_eNumShape = ENumberShape2::CIRCLED_LATIN_CAPITAL;
|
||||
else if ("CIRCLED_LATIN_SMALL" == sType)
|
||||
m_eNumShape = ENumberShape2::CIRCLED_LATIN_SMALL;
|
||||
else if ("CIRCLED_HANGUL_SYLLABLE" == sType)
|
||||
m_eNumShape = ENumberShape2::CIRCLED_HANGUL_SYLLABLE;
|
||||
else if ("HANGUL_JAMO" == sType)
|
||||
m_eNumShape = ENumberShape2::HANGUL_JAMO;
|
||||
else if ("CIRCLED_HANGUL_JAMO" == sType)
|
||||
m_eNumShape = ENumberShape2::CIRCLED_HANGUL_JAMO;
|
||||
else if ("HANGUL_PHONETIC" == sType)
|
||||
m_eNumShape = ENumberShape2::HANGUL_PHONETIC;
|
||||
else if ("IDEOGRAPH" == sType)
|
||||
m_eNumShape = ENumberShape2::IDEOGRAPH;
|
||||
else if ("CIRCLED_IDEOGRAPH" == sType)
|
||||
m_eNumShape = ENumberShape2::CIRCLED_IDEOGRAPH;
|
||||
else if ("DECAGON_CIRCLE" == sType)
|
||||
m_eNumShape = ENumberShape2::DECAGON_CIRCLE;
|
||||
else if ("DECAGON_CRICLE_HANGJA" == sType)
|
||||
m_eNumShape = ENumberShape2::DECAGON_CRICLE_HANGJA;
|
||||
else if ("SYMBOL" == sType)
|
||||
m_eNumShape = ENumberShape2::SYMBOL;
|
||||
else if ("USER_CHAR" == sType)
|
||||
m_eNumShape = ENumberShape2::USER_HWP_CHAR;
|
||||
}
|
||||
else if ("hp:autoNumFormat" == sAttributeName ||
|
||||
"autoNumFormat" == sAttributeName)
|
||||
m_eNumShape = GetNumberShape2(oReader.GetInt());
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
END_WHILE
|
||||
|
||||
m_bFullFilled = true;
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
#include "../HWPStream.h"
|
||||
#include "../HWPElements/HwpRecordTypes.h"
|
||||
#include "../Common/Common.h"
|
||||
#include "../Common/XMLNode.h"
|
||||
#include "../Common/XMLReader.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
@ -31,7 +31,7 @@ class CCtrlAutoNumber : public CCtrl
|
||||
public:
|
||||
CCtrlAutoNumber(const HWP_STRING& sCtrlID);
|
||||
CCtrlAutoNumber(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CCtrlAutoNumber(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion);
|
||||
CCtrlAutoNumber(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion);
|
||||
|
||||
ECtrlObjectType GetCtrlType() const override;
|
||||
|
||||
|
||||
@ -10,7 +10,8 @@ enum class ECtrlCharType
|
||||
LINE_BREAK = 0x1,
|
||||
PARAGRAPH_BREAK = 0x2,
|
||||
HARD_HYPHEN = 0x3,
|
||||
HARD_SPACE = 0x04
|
||||
HARD_SPACE = 0x04,
|
||||
TABULATION = 0x05
|
||||
};
|
||||
|
||||
class CCtrlCharacter : public CCtrl
|
||||
|
||||
@ -40,12 +40,17 @@ CCtrlColumnDef::CCtrlColumnDef(const HWP_STRING& sCtrlID, int nSize, CHWPStream&
|
||||
m_bFullFilled = true;
|
||||
}
|
||||
|
||||
CCtrlColumnDef::CCtrlColumnDef(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion)
|
||||
: CCtrl(sCtrlID)
|
||||
CCtrlColumnDef::CCtrlColumnDef(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion)
|
||||
: CCtrl(sCtrlID), m_eColLineStyle(ELineStyle2::SOLID)
|
||||
{
|
||||
m_eColLineStyle = ELineStyle2::SOLID;
|
||||
m_shColCount = oNode.GetAttributeInt(L"colCount");
|
||||
m_bSameSz = oNode.GetAttributeBool(L"sameSz");
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("colCount" == sAttributeName)
|
||||
m_shColCount = oReader.GetInt();
|
||||
else if ("sameSz" == sAttributeName)
|
||||
m_bSameSz = oReader.GetBool();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
if (!m_bSameSz)
|
||||
{
|
||||
@ -55,20 +60,34 @@ CCtrlColumnDef::CCtrlColumnDef(const HWP_STRING& sCtrlID, CXMLNode& oNode, int n
|
||||
|
||||
unsigned int unColSzIndex = 0;
|
||||
|
||||
for (CXMLNode& oChild : oNode.GetChilds())
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if (L"hp:colLine" == oChild.GetName())
|
||||
if ("hp:colLine" == sNodeName)
|
||||
{
|
||||
m_eColLineStyle = GetLineStyle2(oChild.GetAttribute(L"type"));
|
||||
m_chColLineWidth = (HWP_BYTE)ConvertWidthToHWP(oChild.GetAttribute(L"width"));
|
||||
m_nColLineColor = oChild.GetAttributeColor(L"color");
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("type" == sAttributeName)
|
||||
m_eColLineStyle = GetLineStyle2(oReader.GetText());
|
||||
else if ("width" == sAttributeName)
|
||||
m_chColLineWidth = (HWP_BYTE)ConvertWidthToHWP(oReader.GetTextA());
|
||||
else if ("color" == sAttributeName)
|
||||
m_nColLineColor = oReader.GetColor();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if (L"hp:colSz" == oChild.GetName())
|
||||
else if ("hp:colSz" == sNodeName)
|
||||
{
|
||||
m_arColSzWidths[unColSzIndex] = oChild.GetAttributeInt(L"width");
|
||||
m_arColSzGaps[unColSzIndex++] = oChild.GetAttributeInt(L"gap");
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("width" == sAttributeName)
|
||||
m_arColSzWidths[unColSzIndex] = oReader.GetInt();
|
||||
else if ("gap" == sAttributeName)
|
||||
m_arColSzGaps[unColSzIndex++] = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
}
|
||||
END_WHILE
|
||||
|
||||
m_bFullFilled = true;
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include "../HWPElements/HwpRecordTypes.h"
|
||||
#include "../HWPStream.h"
|
||||
#include "Ctrl.h"
|
||||
#include "../Common/XMLNode.h"
|
||||
#include "../Common/XMLReader.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
@ -22,7 +22,7 @@ class CCtrlColumnDef : public CCtrl
|
||||
public:
|
||||
CCtrlColumnDef(const HWP_STRING& sCtrlID);
|
||||
CCtrlColumnDef(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CCtrlColumnDef(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion);
|
||||
CCtrlColumnDef(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion);
|
||||
|
||||
ECtrlObjectType GetCtrlType() const override;
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#include "CtrlCommon.h"
|
||||
#include "../Common/Common.h"
|
||||
#include <climits>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
|
||||
#include "CapParagraph.h"
|
||||
|
||||
@ -250,116 +252,58 @@ namespace HWP
|
||||
oBuffer.Skip(nSize - oBuffer.GetDistanceToLastPos(true));
|
||||
}
|
||||
|
||||
CCtrlCommon::CCtrlCommon(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion)
|
||||
CCtrlCommon::CCtrlCommon(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion)
|
||||
: CCtrl(sCtrlID), m_bTreatAsChar(false), m_eVertRelTo(EVRelTo::PARA), m_eHorzRelTo(EHRelTo::PARA), m_nVertOffset(0), m_nHorzOffset(0), m_nWidth(0), m_nHeight(0), m_arOutMargin{0, 0, 0, 0}, m_arInMargin{0, 0, 0, 0}, m_eTextVerAlign(EVertAlign::TOP)
|
||||
{
|
||||
m_nObjInstanceID = std::abs(oNode.GetAttributeInt(L"id"));
|
||||
std::string sType;
|
||||
|
||||
HWP_STRING sType = oNode.GetAttribute(L"textFlow");
|
||||
|
||||
if (L"BOTH_SIDES" == sType)
|
||||
m_chTextFlow = 0;
|
||||
else if (L"LEFT_ONLY" == sType)
|
||||
m_chTextFlow = 1;
|
||||
else if (L"RIGHT_ONLY" == sType)
|
||||
m_chTextFlow = 2;
|
||||
else if (L"LARGEST_ONLY" == sType)
|
||||
m_chTextFlow = 3;
|
||||
|
||||
sType = oNode.GetAttribute(L"textWrap");
|
||||
|
||||
if (L"SQUARE" == sType)
|
||||
m_eTextWrap = ETextWrap::SQUARE;
|
||||
else if (L"TOP_AND_BOTTOM" == sType)
|
||||
m_eTextWrap = ETextWrap::TOP_AND_BOTTOM;
|
||||
else if (L"BEHIND_TEXT" == sType)
|
||||
m_eTextWrap = ETextWrap::BEHIND_TEXT;
|
||||
else if (L"IN_FRONT_OF_TEXT" == sType)
|
||||
m_eTextWrap = ETextWrap::IN_FRONT_OF_TEXT;
|
||||
|
||||
m_nZOrder = oNode.GetAttributeInt(L"zOrder");
|
||||
|
||||
sType = oNode.GetAttribute(L"numberingType");
|
||||
|
||||
if (L"NONE" == sType)
|
||||
m_chNumeringType = 0;
|
||||
else if (L"PICTURE" == sType)
|
||||
m_chNumeringType = 1;
|
||||
else if (L"TABLE" == sType)
|
||||
m_chNumeringType = 2;
|
||||
else if (L"EQUATION" == sType)
|
||||
m_chNumeringType = 3;
|
||||
|
||||
for (CXMLNode& oChild : oNode.GetChilds())
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (L"hp:sz" == oChild.GetName())
|
||||
if ("id" == sAttributeName)
|
||||
m_nObjInstanceID = std::abs(oReader.GetInt());
|
||||
else if ("textFlow" == sAttributeName)
|
||||
{
|
||||
m_nWidth = oChild.GetAttributeInt(L"width");
|
||||
m_eWidthRelTo = ::HWP::GetWidthRelTo(oChild.GetAttribute(L"widthRelTo"));
|
||||
m_nHeight = oChild.GetAttributeInt(L"height");
|
||||
m_eHeightRelTo = ::HWP::GetHeightRelTo(oChild.GetAttribute(L"heightRelTo"));
|
||||
sType = oReader.GetTextA();
|
||||
|
||||
if ("BOTH_SIDES" == sType)
|
||||
m_chTextFlow = 0;
|
||||
else if ("LEFT_ONLY" == sType)
|
||||
m_chTextFlow = 1;
|
||||
else if ("RIGHT_ONLY" == sType)
|
||||
m_chTextFlow = 2;
|
||||
else if ("LARGEST_ONLY" == sType)
|
||||
m_chTextFlow = 3;
|
||||
}
|
||||
else if (L"hp:pos" == oChild.GetName())
|
||||
else if ("textWrap" == sAttributeName)
|
||||
{
|
||||
m_bTreatAsChar = oChild.GetAttributeBool(L"treatAsChar");
|
||||
sType = oReader.GetTextA();
|
||||
|
||||
if (m_bTreatAsChar)
|
||||
m_bAffectLSpacing = oChild.GetAttributeBool(L"affectLSpacing");
|
||||
else
|
||||
m_bAllowOverlap = oChild.GetAttributeBool(L"allowOverlap");
|
||||
|
||||
m_eVertRelTo = GetVRelTo(oChild.GetAttribute(L"vertRelTo"));
|
||||
m_eHorzRelTo = GetHRelTo(oChild.GetAttribute(L"horzRelTo"));
|
||||
|
||||
if (EVRelTo::PARA == m_eVertRelTo)
|
||||
m_bFlowWithText = oChild.GetAttributeBool(L"flowWithText");
|
||||
|
||||
m_eVertAlign = GetVertAlign(oChild.GetAttribute(L"vertAlign"));
|
||||
m_eHorzAlign = GetHorzAlign(oChild.GetAttribute(L"horzAlign"));
|
||||
m_nVertOffset = oChild.GetAttributeInt(L"vertOffset");
|
||||
m_nHorzOffset = oChild.GetAttributeInt(L"horzOffset");
|
||||
if ("SQUARE" == sType)
|
||||
m_eTextWrap = ETextWrap::SQUARE;
|
||||
else if ("TOP_AND_BOTTOM" == sType)
|
||||
m_eTextWrap = ETextWrap::TOP_AND_BOTTOM;
|
||||
else if ("BEHIND_TEXT" == sType)
|
||||
m_eTextWrap = ETextWrap::BEHIND_TEXT;
|
||||
else if ("IN_FRONT_OF_TEXT" == sType)
|
||||
m_eTextWrap = ETextWrap::IN_FRONT_OF_TEXT;
|
||||
}
|
||||
else if (L"hp:outMargin" == oChild.GetName())
|
||||
else if ("zOrder" == sAttributeName)
|
||||
m_nZOrder = oReader.GetInt();
|
||||
else if ("numberingType" == sAttributeName)
|
||||
{
|
||||
m_arOutMargin[0] = oChild.GetAttributeInt(L"left");
|
||||
m_arOutMargin[1] = oChild.GetAttributeInt(L"right");
|
||||
m_arOutMargin[2] = oChild.GetAttributeInt(L"top");
|
||||
m_arOutMargin[3] = oChild.GetAttributeInt(L"bottom");
|
||||
}
|
||||
else if (L"hp:inMargin" == oChild.GetName())
|
||||
{
|
||||
m_arInMargin[0] = oChild.GetAttributeInt(L"left");
|
||||
m_arInMargin[1] = oChild.GetAttributeInt(L"right");
|
||||
m_arInMargin[2] = oChild.GetAttributeInt(L"top");
|
||||
m_arInMargin[3] = oChild.GetAttributeInt(L"bottom");
|
||||
}
|
||||
else if (L"hp:caption" == oChild.GetName())
|
||||
{
|
||||
HWP_STRING sType = oChild.GetAttribute(L"side");
|
||||
sType = oReader.GetTextA();
|
||||
|
||||
if (L"LEFT" == sType)
|
||||
m_nCaptionAttr = 0b00;
|
||||
else if (L"RIGHT" == sType)
|
||||
m_nCaptionAttr = 0b01;
|
||||
else if (L"TOP" == sType)
|
||||
m_nCaptionAttr = 0b10;
|
||||
else if (L"BOTTOM" == sType)
|
||||
m_nCaptionAttr = 0b11;
|
||||
|
||||
if (oChild.GetAttributeBool(L"fullSz"))
|
||||
m_nCaptionAttr |= 0b100;
|
||||
|
||||
m_nCaptionWidth = oChild.GetAttributeInt(L"width");
|
||||
m_nCaptionSpacing = oChild.GetAttributeInt(L"gap");
|
||||
m_nCaptionMaxW = oChild.GetAttributeInt(L"lastWidth");
|
||||
|
||||
for (CXMLNode& oSubList : oChild.GetChilds(L"hp:subList"))
|
||||
{
|
||||
for (CXMLNode& oParagraph : oSubList.GetChilds(L"hp:p"))
|
||||
m_arCaption.push_back(new CCapParagraph(oParagraph, nVersion));
|
||||
}
|
||||
if ("NONE" == sType)
|
||||
m_chNumeringType = 0;
|
||||
else if ("PICTURE" == sType)
|
||||
m_chNumeringType = 1;
|
||||
else if ("TABLE" == sType)
|
||||
m_chNumeringType = 2;
|
||||
else if ("EQUATION" == sType)
|
||||
m_chNumeringType = 3;
|
||||
}
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
|
||||
CCtrlCommon::~CCtrlCommon()
|
||||
@ -387,6 +331,121 @@ namespace HWP
|
||||
m_eTextVerAlign = eVertAlign;
|
||||
}
|
||||
|
||||
void CCtrlCommon::ParseChildren(CXMLReader& oReader, int nVersion)
|
||||
{
|
||||
const std::string sNodeName{oReader.GetName()};
|
||||
|
||||
if ("hp:sz" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("width" == sAttributeName)
|
||||
m_nWidth = oReader.GetInt();
|
||||
else if ("widthRelTo" == sAttributeName)
|
||||
m_eWidthRelTo = ::HWP::GetWidthRelTo(oReader.GetText());
|
||||
else if ("height" == sAttributeName)
|
||||
m_nHeight = oReader.GetInt();
|
||||
else if ("heightRelTo" == sAttributeName)
|
||||
m_eHeightRelTo = ::HWP::GetHeightRelTo(oReader.GetText());
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("hp:pos" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("treatAsChar" == sAttributeName)
|
||||
m_bTreatAsChar = oReader.GetBool();
|
||||
else if ("affectLSpacing" == sAttributeName)
|
||||
m_bAffectLSpacing = oReader.GetBool();
|
||||
else if ("allowOverlap" == sAttributeName)
|
||||
m_bAllowOverlap = oReader.GetBool();
|
||||
else if ("vertRelTo" == sAttributeName)
|
||||
m_eVertRelTo = GetVRelTo(oReader.GetText());
|
||||
else if ("horzRelTo" == sAttributeName)
|
||||
m_eHorzRelTo = GetHRelTo(oReader.GetText());
|
||||
else if ("flowWithText" == sAttributeName)
|
||||
m_bFlowWithText = oReader.GetBool();
|
||||
else if ("vertAlign" == sAttributeName)
|
||||
m_eVertAlign = GetVertAlign(oReader.GetText());
|
||||
else if ("horzAlign" == sAttributeName)
|
||||
m_eHorzAlign = GetHorzAlign(oReader.GetText());
|
||||
else if ("vertOffset" == sAttributeName)
|
||||
m_nVertOffset = oReader.GetInt();
|
||||
else if ("horzOffset" == sAttributeName)
|
||||
m_nHorzOffset = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("hp:outMargin" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("left" == sAttributeName)
|
||||
m_arOutMargin[0] = oReader.GetInt();
|
||||
else if ("right" == sAttributeName)
|
||||
m_arOutMargin[1] = oReader.GetInt();
|
||||
else if ("top" == sAttributeName)
|
||||
m_arOutMargin[2] = oReader.GetInt();
|
||||
else if ("bottom" == sAttributeName)
|
||||
m_arOutMargin[3] = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("hp:inMargin" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("left" == sAttributeName)
|
||||
m_arInMargin[0] = oReader.GetInt();
|
||||
else if ("right" == sAttributeName)
|
||||
m_arInMargin[1] = oReader.GetInt();
|
||||
else if ("top" == sAttributeName)
|
||||
m_arInMargin[2] = oReader.GetInt();
|
||||
else if ("bottom" == sAttributeName)
|
||||
m_arInMargin[3] = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("hp:caption" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("side" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if ("LEFT" == sType)
|
||||
m_nCaptionAttr = 0b00;
|
||||
else if ("RIGHT" == sType)
|
||||
m_nCaptionAttr = 0b01;
|
||||
else if ("TOP" == sType)
|
||||
m_nCaptionAttr = 0b10;
|
||||
else if ("BOTTOM" == sType)
|
||||
m_nCaptionAttr = 0b11;
|
||||
}
|
||||
else if ("fullSz" == sAttributeName)
|
||||
{
|
||||
if (oReader.GetBool())
|
||||
m_nCaptionAttr |= 0b100;
|
||||
}
|
||||
else if ("width" == sAttributeName)
|
||||
m_nCaptionWidth = oReader.GetInt();
|
||||
else if ("gap" == sAttributeName)
|
||||
m_nCaptionSpacing = oReader.GetInt();
|
||||
else if ("lastWidth" == sAttributeName)
|
||||
m_nCaptionMaxW = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, SubList, "hp:subList")
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Paragraph, "hp:p")
|
||||
m_arCaption.push_back(new CCapParagraph(oReader, nVersion));
|
||||
END_WHILE
|
||||
END_WHILE
|
||||
}
|
||||
}
|
||||
|
||||
void CCtrlCommon::AddParagraph(CHWPPargraph* pParagraph)
|
||||
{
|
||||
m_arParas.push_back(pParagraph);
|
||||
|
||||
@ -114,13 +114,15 @@ public:
|
||||
CCtrlCommon(const HWP_STRING& sCtrlID);
|
||||
CCtrlCommon(const CCtrlCommon& oCtrlCommon);
|
||||
CCtrlCommon(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CCtrlCommon(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion);
|
||||
CCtrlCommon(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion);
|
||||
virtual ~CCtrlCommon();
|
||||
|
||||
ECtrlObjectType GetCtrlType() const override;
|
||||
|
||||
void SetTextVerAlign(EVertAlign eVertAlign);
|
||||
|
||||
void ParseChildren(CXMLReader& oReader, int nVersion);
|
||||
|
||||
void AddParagraph(CHWPPargraph* pParagraph);
|
||||
void AddCaption(CCapParagraph* pCapPara);
|
||||
|
||||
|
||||
@ -25,32 +25,33 @@ CCtrlContainer::CCtrlContainer(const HWP_STRING& sCtrlID, int nSize, CHWPStream&
|
||||
: CCtrlGeneralShape(sCtrlID, nSize, oBuffer, nOff, nVersion)
|
||||
{}
|
||||
|
||||
CCtrlContainer::CCtrlContainer(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion)
|
||||
: CCtrlGeneralShape(sCtrlID, oNode, nVersion)
|
||||
CCtrlContainer::CCtrlContainer(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion)
|
||||
: CCtrlGeneralShape(sCtrlID, oReader, nVersion)
|
||||
{
|
||||
for (CXMLNode& oChild : oNode.GetChilds())
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if (L"hp:container" == oChild.GetName())
|
||||
m_arShapes.push_back(new CCtrlContainer(L"noc$", oChild, nVersion));
|
||||
else if (L"hp:line" == oChild.GetName())
|
||||
m_arShapes.push_back(new CCtrlShapeLine(L"nil$", oChild, nVersion));
|
||||
else if (L"hp:rect" == oChild.GetName())
|
||||
m_arShapes.push_back(new CCtrlShapeRect(L"cer$", oChild, nVersion));
|
||||
else if (L"hp:ellipse" == oChild.GetName())
|
||||
m_arShapes.push_back(new CCtrlShapeEllipse(L"lle$", oChild, nVersion));
|
||||
else if (L"hp:arc" == oChild.GetName())
|
||||
m_arShapes.push_back(new CCtrlShapeArc(L"cra$", oChild, nVersion));
|
||||
else if (L"hp:polygon" == oChild.GetName())
|
||||
m_arShapes.push_back(new CCtrlShapePolygon(L"lop$", oChild, nVersion));
|
||||
else if (L"hp:curve" == oChild.GetName())
|
||||
m_arShapes.push_back(new CCtrlShapeCurve(L"ruc$", oChild, nVersion));
|
||||
else if (L"hp:connectLine" == oChild.GetName())
|
||||
m_arShapes.push_back(new CCtrlShapeConnectLine(L"loc$", oChild, nVersion));
|
||||
else if (L"hp:pic" == oChild.GetName())
|
||||
m_arShapes.push_back(new CCtrlShapePic(L"cip$", oChild, nVersion));
|
||||
else if (L"hp:ole" == oChild.GetName())
|
||||
m_arShapes.push_back(new CCtrlShapeOle(L"elo$", oChild, nVersion));
|
||||
if ("hp:container" == sNodeName)
|
||||
m_arShapes.push_back(new CCtrlContainer(L"noc$", oReader, nVersion));
|
||||
else if ("hp:line" == sNodeName)
|
||||
m_arShapes.push_back(new CCtrlShapeLine(L"nil$", oReader, nVersion));
|
||||
else if ("hp:rect" == sNodeName)
|
||||
m_arShapes.push_back(new CCtrlShapeRect(L"cer$", oReader, nVersion));
|
||||
else if ("hp:ellipse" == sNodeName)
|
||||
m_arShapes.push_back(new CCtrlShapeEllipse(L"lle$", oReader, nVersion));
|
||||
else if ("hp:arc" == sNodeName)
|
||||
m_arShapes.push_back(new CCtrlShapeArc(L"cra$", oReader, nVersion));
|
||||
else if ("hp:polygon" == sNodeName)
|
||||
m_arShapes.push_back(new CCtrlShapePolygon(L"lop$", oReader, nVersion));
|
||||
else if ("hp:curve" == sNodeName)
|
||||
m_arShapes.push_back(new CCtrlShapeCurve(L"ruc$", oReader, nVersion));
|
||||
else if ("hp:connectLine" == sNodeName)
|
||||
m_arShapes.push_back(new CCtrlShapeConnectLine(L"loc$", oReader, nVersion));
|
||||
else if ("hp:pic" == sNodeName)
|
||||
m_arShapes.push_back(new CCtrlShapePic(L"cip$", oReader, nVersion));
|
||||
else if ("hp:ole" == sNodeName)
|
||||
m_arShapes.push_back(new CCtrlShapeOle(L"elo$", oReader, nVersion));
|
||||
}
|
||||
END_WHILE
|
||||
|
||||
m_shNElement = m_arShapes.size();
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ public:
|
||||
CCtrlContainer(const HWP_STRING& sCtrlID);
|
||||
CCtrlContainer(const CCtrlGeneralShape& oShape);
|
||||
CCtrlContainer(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CCtrlContainer(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion);
|
||||
CCtrlContainer(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion);
|
||||
|
||||
~CCtrlContainer();
|
||||
|
||||
|
||||
@ -17,23 +17,41 @@ CCtrlEqEdit::CCtrlEqEdit(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuff
|
||||
: CCtrlGeneralShape(sCtrlID, nSize, oBuffer, nOff, nVersion)
|
||||
{}
|
||||
|
||||
CCtrlEqEdit::CCtrlEqEdit(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion)
|
||||
: CCtrlGeneralShape(sCtrlID)
|
||||
CCtrlEqEdit::CCtrlEqEdit(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion)
|
||||
: CCtrlGeneralShape(sCtrlID, oReader, nVersion)
|
||||
{
|
||||
m_sVersion = oNode.GetAttribute(L"version");
|
||||
m_nBaseline = oNode.GetAttributeInt(L"baseLine");
|
||||
m_nColor = oNode.GetAttributeColor(L"textColor");
|
||||
m_nCharSize = oNode.GetAttributeInt(L"baseUnit");
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("version" == sAttributeName)
|
||||
m_sVersion = oReader.GetText();
|
||||
else if ("baseLine" == sAttributeName)
|
||||
m_nBaseline = oReader.GetInt();
|
||||
else if ("textColor" == sAttributeName)
|
||||
m_nColor = oReader.GetColor();
|
||||
else if ("baseUnit" == sAttributeName)
|
||||
m_nCharSize = oReader.GetInt();
|
||||
else if ("lineMode" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
HWP_STRING sType = oNode.GetAttribute(L"lineMode");
|
||||
if ("LINE" == sType)
|
||||
m_nAttr = 1;
|
||||
else if ("CHAR" == sType)
|
||||
m_nAttr = 0;
|
||||
}
|
||||
else if ("font" == sAttributeName)
|
||||
m_sFont = oReader.GetText();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
if (L"LINE" == sType)
|
||||
m_nAttr = 1;
|
||||
else if (L"CHAR" == sType)
|
||||
m_nAttr = 0;
|
||||
|
||||
m_sFont = oNode.GetAttribute(L"font");
|
||||
m_sEqn = oNode.GetChild(L"hp:script").GetText();
|
||||
WHILE_READ_NEXT_NODE(oReader)
|
||||
{
|
||||
if ("hp:script" == oReader.GetName())
|
||||
m_sEqn = oReader.GetText();
|
||||
else
|
||||
CCtrlGeneralShape::ParseChildren(oReader, nVersion);
|
||||
}
|
||||
END_WHILE
|
||||
|
||||
m_bFullFilled = true;
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ public:
|
||||
CCtrlEqEdit(const HWP_STRING& sCtrlID);
|
||||
CCtrlEqEdit(const CCtrlGeneralShape& oShape);
|
||||
CCtrlEqEdit(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CCtrlEqEdit(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion);
|
||||
CCtrlEqEdit(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion);
|
||||
|
||||
EShapeType GetShapeType() const override;
|
||||
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
#include "CtrlField.h"
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
@ -33,37 +31,50 @@ void CCtrlField::UpdateType(const HWP_STRING& sCtrlID)
|
||||
m_eType = EFieldType::BookmarkClosing;
|
||||
}
|
||||
|
||||
CCtrlField::CCtrlField(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion)
|
||||
CCtrlField::CCtrlField(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion)
|
||||
: CCtrl(sCtrlID), m_eType(EFieldType::Unknown)
|
||||
{
|
||||
if (L"hp:fieldBegin" == oNode.GetName())
|
||||
const std::string sNodeName{oReader.GetName()};
|
||||
HWP_STRING wsName;
|
||||
|
||||
if ("hp:fieldBegin" == sNodeName)
|
||||
{
|
||||
HWP_STRING sType = oNode.GetAttribute(L"type");
|
||||
|
||||
if (L"HYPERLINK" == sType)
|
||||
m_eType = EFieldType::Hyperlink;
|
||||
else if (L"BOOKMARK" == sType)
|
||||
m_eType = EFieldType::Bookmark;
|
||||
|
||||
m_nInstanceID = oNode.GetAttributeInt(L"fieldid");
|
||||
|
||||
HWP_STRING sName = oNode.GetAttribute(L"name");
|
||||
|
||||
if (!sName.empty() && EFieldType::Bookmark == m_eType)
|
||||
AddStringParam(L"bookmarkname", sName);
|
||||
|
||||
for (CXMLNode& oChild : oNode.GetChild(L"hp:parameters").GetChilds())
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (L"hp:stringParam" == oChild.GetName())
|
||||
AddStringParam(oChild.GetAttribute(L"name"), oChild.GetText());
|
||||
else if (L"hp:integerParam" == oChild.GetName())
|
||||
AddIntegerParam(oChild.GetAttribute(L"name"), std::stoi(oChild.GetText()));
|
||||
if ("type" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if ("HYPERLINK" == sType)
|
||||
m_eType = EFieldType::Hyperlink;
|
||||
else if ("BOOKMARK" == sType)
|
||||
m_eType = EFieldType::Bookmark;
|
||||
}
|
||||
else if ("fieldid" == sAttributeName)
|
||||
m_nInstanceID = oReader.GetInt();
|
||||
else if ("name" == sAttributeName)
|
||||
wsName = oReader.GetText();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
if (!wsName.empty() && EFieldType::Bookmark == m_eType)
|
||||
AddStringParam(L"bookmarkname", wsName);
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hp:parameters")
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_AND_NAME(oReader, Child)
|
||||
{
|
||||
if ("hp:stringParam" == sNodeChildName)
|
||||
AddStringParam(oReader.GetAttribute("name"), oReader.GetText());
|
||||
else if ("hp:integerParam" == sNodeChildName)
|
||||
AddIntegerParam(oReader.GetAttribute("name"), oReader.GetInt());
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
else if (L"hp:fieldEnd" == oNode.GetName())
|
||||
{
|
||||
m_nInstanceID = oNode.GetAttributeInt(L"fieldid");
|
||||
}
|
||||
else if ("hp:fieldEnd" == sNodeName)
|
||||
m_nInstanceID = oReader.GetAttributeInt("fieldid");
|
||||
}
|
||||
|
||||
ECtrlObjectType CCtrlField::GetCtrlType() const
|
||||
|
||||
@ -32,7 +32,7 @@ class CCtrlField : public CCtrl
|
||||
public:
|
||||
CCtrlField(const HWP_STRING& sCtrlID);
|
||||
CCtrlField(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CCtrlField(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion);
|
||||
CCtrlField(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion);
|
||||
|
||||
ECtrlObjectType GetCtrlType() const override;
|
||||
|
||||
|
||||
@ -62,121 +62,10 @@ CCtrlGeneralShape::CCtrlGeneralShape(const HWP_STRING& sCtrlID, int nSize, CHWPS
|
||||
InitData();
|
||||
}
|
||||
|
||||
CCtrlGeneralShape::CCtrlGeneralShape(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion)
|
||||
: CCtrlObjElement(sCtrlID, oNode, nVersion)
|
||||
CCtrlGeneralShape::CCtrlGeneralShape(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion)
|
||||
: CCtrlObjElement(sCtrlID, oReader, nVersion)
|
||||
{
|
||||
InitData();
|
||||
|
||||
for (CXMLNode& oChild : oNode.GetChilds())
|
||||
{
|
||||
if (L"hp:lineShape" == oChild.GetName())
|
||||
{
|
||||
m_nLineColor = oChild.GetAttributeColor(L"color");
|
||||
m_nLineThick = std::abs(oChild.GetAttributeInt(L"width"));
|
||||
m_eLineStyle = GetLineStyle2(oChild.GetAttribute(L"style"));
|
||||
|
||||
HWP_STRING sType = oChild.GetAttribute(L"headStyle");
|
||||
|
||||
if (L"ARROW" == sType)
|
||||
m_eLineHead = ELineArrowStyle::ARROW;
|
||||
else if (L"SPEAR" == sType)
|
||||
m_eLineHead = ELineArrowStyle::SPEAR;
|
||||
else if (L"CONCAVE_ARROW" == sType)
|
||||
m_eLineHead = ELineArrowStyle::CONCAVE_ARROW;
|
||||
else if (L"EMPTY_DIAMOND" == sType)
|
||||
m_eLineHead = (oChild.GetAttributeBool(L"headfill")) ? ELineArrowStyle::DIAMOND : ELineArrowStyle::EMPTY_DIAMOND;
|
||||
else if (L"EMPTY_CIRCLE" == sType)
|
||||
m_eLineHead = (oChild.GetAttributeBool(L"headfill")) ? ELineArrowStyle::CIRCLE : ELineArrowStyle::EMPTY_CIRCLE;
|
||||
else if (L"EMPTY_BOX" == sType)
|
||||
m_eLineHead = (oChild.GetAttributeBool(L"headfill")) ? ELineArrowStyle::BOX : ELineArrowStyle::EMPTY_BOX;
|
||||
else
|
||||
m_eLineHead = ELineArrowStyle::NORMAL;
|
||||
|
||||
sType = oChild.GetAttribute(L"headSz");
|
||||
|
||||
if (L"SMALL_SMALL" == sType)
|
||||
m_eLineHeadSz = ELineArrowSize::SMALL_SMALL;
|
||||
else if (L"SMALL_MEDIUM" == sType)
|
||||
m_eLineHeadSz = ELineArrowSize::SMALL_MEDIUM;
|
||||
else if (L"SMALL_LARGE" == sType)
|
||||
m_eLineHeadSz = ELineArrowSize::SMALL_LARGE;
|
||||
else if (L"MEDIUM_SMALL" == sType)
|
||||
m_eLineHeadSz = ELineArrowSize::MEDIUM_SMALL;
|
||||
else if (L"MEDIUM_MEDIUM" == sType)
|
||||
m_eLineHeadSz = ELineArrowSize::MEDIUM_MEDIUM;
|
||||
else if (L"MEDIUM_LARGE" == sType)
|
||||
m_eLineHeadSz = ELineArrowSize::MEDIUM_LARGE;
|
||||
else if (L"LARGE_SMALL" == sType)
|
||||
m_eLineHeadSz = ELineArrowSize::LARGE_SMALL;
|
||||
else if (L"LARGE_MEDIUM" == sType)
|
||||
m_eLineHeadSz = ELineArrowSize::LARGE_MEDIUM;
|
||||
else if (L"LARGE_LARGE" == sType)
|
||||
m_eLineHeadSz = ELineArrowSize::LARGE_LARGE;
|
||||
else
|
||||
m_eLineHeadSz = ELineArrowSize::MEDIUM_MEDIUM;
|
||||
|
||||
sType = oChild.GetAttribute(L"tailStyle");
|
||||
|
||||
if (L"ARROW" == sType)
|
||||
m_eLineTail = ELineArrowStyle::ARROW;
|
||||
else if (L"SPEAR" == sType)
|
||||
m_eLineTail = ELineArrowStyle::SPEAR;
|
||||
else if (L"CONCAVE_ARROW" == sType)
|
||||
m_eLineTail = ELineArrowStyle::CONCAVE_ARROW;
|
||||
else if (L"EMPTY_DIAMOND" == sType)
|
||||
m_eLineTail = (oChild.GetAttributeBool(L"tailfill")) ? ELineArrowStyle::DIAMOND : ELineArrowStyle::EMPTY_DIAMOND;
|
||||
else if (L"EMPTY_CIRCLE" == sType)
|
||||
m_eLineTail = (oChild.GetAttributeBool(L"tailfill")) ? ELineArrowStyle::CIRCLE : ELineArrowStyle::EMPTY_CIRCLE;
|
||||
else if (L"EMPTY_BOX" == sType)
|
||||
m_eLineTail = (oChild.GetAttributeBool(L"tailfill")) ? ELineArrowStyle::BOX : ELineArrowStyle::EMPTY_BOX;
|
||||
else
|
||||
m_eLineTail = ELineArrowStyle::NORMAL;
|
||||
|
||||
sType = oChild.GetAttribute(L"tailSz");
|
||||
|
||||
if (L"SMALL_SMALL" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::SMALL_SMALL;
|
||||
else if (L"SMALL_MEDIUM" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::SMALL_MEDIUM;
|
||||
else if (L"SMALL_LARGE" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::SMALL_LARGE;
|
||||
else if (L"MEDIUM_SMALL" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::MEDIUM_SMALL;
|
||||
else if (L"MEDIUM_MEDIUM" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::MEDIUM_MEDIUM;
|
||||
else if (L"MEDIUM_LARGE" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::MEDIUM_LARGE;
|
||||
else if (L"LARGE_SMALL" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::LARGE_SMALL;
|
||||
else if (L"LARGE_MEDIUM" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::LARGE_MEDIUM;
|
||||
else if (L"LARGE_LARGE" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::LARGE_LARGE;
|
||||
else
|
||||
m_eLineTailSz = ELineArrowSize::MEDIUM_MEDIUM;
|
||||
}
|
||||
else if (L"hc:fillBrush" == oChild.GetName())
|
||||
m_pFill = new CFill(oChild);
|
||||
else if (L"hp:drawText" == oChild.GetName())
|
||||
{
|
||||
m_nMaxTxtWidth = oChild.GetAttributeInt(L"lastWidth");
|
||||
|
||||
for (CXMLNode& oGrandChild : oChild.GetChilds())
|
||||
{
|
||||
if (L"hp:textMargin" == oGrandChild.GetName())
|
||||
{
|
||||
m_shLeftSpace = oGrandChild.GetAttributeInt(L"left");
|
||||
m_shRightSpace = oGrandChild.GetAttributeInt(L"right");
|
||||
m_shTopSpace = oGrandChild.GetAttributeInt(L"top");
|
||||
m_shBottomSpace = oGrandChild.GetAttributeInt(L"bottom");
|
||||
}
|
||||
else if (L"hp:subList" == oGrandChild.GetName())
|
||||
{
|
||||
ReadSubList(oGrandChild, nVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CCtrlGeneralShape::~CCtrlGeneralShape()
|
||||
@ -195,36 +84,177 @@ EShapeType CCtrlGeneralShape::GetShapeType() const
|
||||
return EShapeType::GeneralShape;
|
||||
}
|
||||
|
||||
void CCtrlGeneralShape::ParseChildren(CXMLReader& oReader, int nVersion)
|
||||
{
|
||||
bool bHeadFill = false, bTailFill = false;
|
||||
|
||||
const std::string sNodeName{oReader.GetName()};
|
||||
|
||||
if ("hp:lineShape" == sNodeName)
|
||||
{
|
||||
std::string sHeadStyle, sTailStyle;
|
||||
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("color" == sAttributeName)
|
||||
m_nLineColor = oReader.GetInt();
|
||||
else if ("width" == sAttributeName)
|
||||
m_nLineThick = oReader.GetInt();
|
||||
else if ("style" == sAttributeName)
|
||||
m_eLineStyle = GetLineStyle2(oReader.GetText());
|
||||
else if ("headStyle" == sAttributeName)
|
||||
sHeadStyle = oReader.GetTextA();
|
||||
else if ("headfill" == sAttributeName)
|
||||
bHeadFill = oReader.GetBool();
|
||||
else if ("headSz" == sAttributeName)
|
||||
{
|
||||
const std::string sHeadSz{oReader.GetTextA()};
|
||||
|
||||
if ("SMALL_SMALL" == sHeadSz)
|
||||
m_eLineHeadSz = ELineArrowSize::SMALL_SMALL;
|
||||
else if ("SMALL_MEDIUM" == sHeadSz)
|
||||
m_eLineHeadSz = ELineArrowSize::SMALL_MEDIUM;
|
||||
else if ("SMALL_LARGE" == sHeadSz)
|
||||
m_eLineHeadSz = ELineArrowSize::SMALL_LARGE;
|
||||
else if ("MEDIUM_SMALL" == sHeadSz)
|
||||
m_eLineHeadSz = ELineArrowSize::MEDIUM_SMALL;
|
||||
else if ("MEDIUM_MEDIUM" == sHeadSz)
|
||||
m_eLineHeadSz = ELineArrowSize::MEDIUM_MEDIUM;
|
||||
else if ("MEDIUM_LARGE" == sHeadSz)
|
||||
m_eLineHeadSz = ELineArrowSize::MEDIUM_LARGE;
|
||||
else if ("LARGE_SMALL" == sHeadSz)
|
||||
m_eLineHeadSz = ELineArrowSize::LARGE_SMALL;
|
||||
else if ("LARGE_MEDIUM" == sHeadSz)
|
||||
m_eLineHeadSz = ELineArrowSize::LARGE_MEDIUM;
|
||||
else if ("LARGE_LARGE" == sHeadSz)
|
||||
m_eLineHeadSz = ELineArrowSize::LARGE_LARGE;
|
||||
else
|
||||
m_eLineHeadSz = ELineArrowSize::MEDIUM_MEDIUM;
|
||||
}
|
||||
else if ("tailStyle" == sAttributeName)
|
||||
sTailStyle = oReader.GetTextA();
|
||||
else if ("tailfill" == sAttributeName)
|
||||
bTailFill = oReader.GetBool();
|
||||
else if ("tailSz" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if ("SMALL_SMALL" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::SMALL_SMALL;
|
||||
else if ("SMALL_MEDIUM" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::SMALL_MEDIUM;
|
||||
else if ("SMALL_LARGE" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::SMALL_LARGE;
|
||||
else if ("MEDIUM_SMALL" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::MEDIUM_SMALL;
|
||||
else if ("MEDIUM_MEDIUM" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::MEDIUM_MEDIUM;
|
||||
else if ("MEDIUM_LARGE" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::MEDIUM_LARGE;
|
||||
else if ("LARGE_SMALL" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::LARGE_SMALL;
|
||||
else if ("LARGE_MEDIUM" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::LARGE_MEDIUM;
|
||||
else if ("LARGE_LARGE" == sType)
|
||||
m_eLineTailSz = ELineArrowSize::LARGE_LARGE;
|
||||
else
|
||||
m_eLineTailSz = ELineArrowSize::MEDIUM_MEDIUM;
|
||||
}
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
if (sHeadStyle.empty())
|
||||
m_eLineHead = ELineArrowStyle::NORMAL;
|
||||
else if ("ARROW" == sHeadStyle)
|
||||
m_eLineHead = ELineArrowStyle::ARROW;
|
||||
else if ("SPEAR" == sHeadStyle)
|
||||
m_eLineHead = ELineArrowStyle::SPEAR;
|
||||
else if ("CONCAVE_ARROW" == sHeadStyle)
|
||||
m_eLineHead = ELineArrowStyle::CONCAVE_ARROW;
|
||||
else if ("EMPTY_DIAMOND" == sHeadStyle)
|
||||
m_eLineHead = bHeadFill ? ELineArrowStyle::DIAMOND : ELineArrowStyle::EMPTY_DIAMOND;
|
||||
else if ("EMPTY_CIRCLE" == sHeadStyle)
|
||||
m_eLineHead = bHeadFill ? ELineArrowStyle::CIRCLE : ELineArrowStyle::EMPTY_CIRCLE;
|
||||
else if ("EMPTY_BOX" == sHeadStyle)
|
||||
m_eLineHead = bHeadFill ? ELineArrowStyle::BOX : ELineArrowStyle::EMPTY_BOX;
|
||||
else
|
||||
m_eLineHead = ELineArrowStyle::NORMAL;
|
||||
|
||||
if (sTailStyle.empty())
|
||||
m_eLineTail = ELineArrowStyle::NORMAL;
|
||||
else if ("ARROW" == sTailStyle)
|
||||
m_eLineTail = ELineArrowStyle::ARROW;
|
||||
else if ("SPEAR" == sTailStyle)
|
||||
m_eLineTail = ELineArrowStyle::SPEAR;
|
||||
else if ("CONCAVE_ARROW" == sTailStyle)
|
||||
m_eLineTail = ELineArrowStyle::CONCAVE_ARROW;
|
||||
else if ("EMPTY_DIAMOND" == sTailStyle)
|
||||
m_eLineTail = bTailFill ? ELineArrowStyle::DIAMOND : ELineArrowStyle::EMPTY_DIAMOND;
|
||||
else if ("EMPTY_CIRCLE" == sTailStyle)
|
||||
m_eLineTail = bTailFill ? ELineArrowStyle::CIRCLE : ELineArrowStyle::EMPTY_CIRCLE;
|
||||
else if ("EMPTY_BOX" == sTailStyle)
|
||||
m_eLineTail = bTailFill ? ELineArrowStyle::BOX : ELineArrowStyle::EMPTY_BOX;
|
||||
else
|
||||
m_eLineTail = ELineArrowStyle::NORMAL;
|
||||
}
|
||||
else if ("hc:fillBrush" == sNodeName)
|
||||
m_pFill = new CFill(oReader);
|
||||
else if ("hp:drawText" == sNodeName)
|
||||
{
|
||||
m_nMaxTxtWidth = oReader.GetAttributeInt("lastWidth");
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_AND_NAME(oReader, Child)
|
||||
{
|
||||
if ("hp:textMargin" == sNodeChildName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("left" == sAttributeName)
|
||||
m_shLeftSpace = oReader.GetInt();
|
||||
else if ("right" == sAttributeName)
|
||||
m_shRightSpace = oReader.GetInt();
|
||||
else if ("top" == sAttributeName)
|
||||
m_shTopSpace = oReader.GetInt();
|
||||
else if ("bottom" == sAttributeName)
|
||||
m_shBottomSpace = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("hp:subList" == sNodeChildName)
|
||||
ReadSubList(oReader, nVersion);
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
else
|
||||
CCtrlObjElement::ParseChildren(oReader, nVersion);
|
||||
}
|
||||
|
||||
void CCtrlGeneralShape::InitData()
|
||||
{
|
||||
m_eLineStyle = ELineStyle2::NONE;
|
||||
m_pFill = nullptr;
|
||||
}
|
||||
|
||||
void CCtrlGeneralShape::ReadSubList(CXMLNode& oNode, int nVersion)
|
||||
void CCtrlGeneralShape::ReadSubList(CXMLReader& oReader, int nVersion)
|
||||
{
|
||||
m_eTextVerAlign = GetVertAlign(oNode.ReadAttributeInt(L"vertAlign"));
|
||||
m_eTextVerAlign = GetVertAlign(oReader.GetAttributeInt("vertAlign"));
|
||||
|
||||
std::vector<CXMLNode> arChilds{oNode.GetChilds()};
|
||||
// CHWPPargraph* pLatestParagraph = nullptr;
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < arChilds.size(); ++unIndex)
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hp:p")
|
||||
{
|
||||
CHWPPargraph* pLatestParagraph = nullptr;
|
||||
CHWPPargraph* pParagraph = new CHWPPargraph(oReader, nVersion);
|
||||
|
||||
if (L"hp:p" == arChilds[unIndex].GetName())
|
||||
{
|
||||
CHWPPargraph* pParagraph = new CHWPPargraph(arChilds[unIndex], nVersion);
|
||||
if (nullptr == pParagraph)
|
||||
continue;
|
||||
|
||||
if (nullptr == pParagraph)
|
||||
continue;
|
||||
m_arParas.push_back(pParagraph);
|
||||
// pLatestParagraph = pParagraph;
|
||||
|
||||
m_arParas.push_back(pParagraph);
|
||||
pLatestParagraph = pParagraph;
|
||||
}
|
||||
|
||||
if (nullptr != pLatestParagraph && 0 != pLatestParagraph->GetCountCtrls() && ECtrlObjectType::ParaText == pLatestParagraph->GetCtrls().back()->GetCtrlType() && unIndex < arChilds.size() - 1)
|
||||
pLatestParagraph->AddCtrl(new CCtrlCharacter(L" _", ECtrlCharType::PARAGRAPH_BREAK));
|
||||
// if (nullptr != pLatestParagraph && 0 != pLatestParagraph->GetCountCtrls() && ECtrlObjectType::ParaText == pLatestParagraph->GetCtrls().back()->GetCtrlType())
|
||||
// pLatestParagraph->AddCtrl(new CCtrlCharacter(L" _", ECtrlCharType::PARAGRAPH_BREAK));
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
void CCtrlGeneralShape::SetParent(CHWPPargraph* pParent)
|
||||
|
||||
@ -53,18 +53,20 @@ class CCtrlGeneralShape : public CCtrlObjElement
|
||||
friend class CCtrlShapePolygon;
|
||||
friend class CCtrlShapeRect;
|
||||
|
||||
void ReadSubList(CXMLNode& oNode, int nVersion);
|
||||
void ReadSubList(CXMLReader& oReader, int nVersion);
|
||||
public:
|
||||
CCtrlGeneralShape();
|
||||
CCtrlGeneralShape(const HWP_STRING& sCtrlID);
|
||||
CCtrlGeneralShape(const CCtrlGeneralShape& oGeneralShape);
|
||||
CCtrlGeneralShape(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CCtrlGeneralShape(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion);
|
||||
CCtrlGeneralShape(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion);
|
||||
virtual ~CCtrlGeneralShape();
|
||||
|
||||
ECtrlObjectType GetCtrlType() const override;
|
||||
virtual EShapeType GetShapeType() const;
|
||||
|
||||
void ParseChildren(CXMLReader& oReader, int nVersion);
|
||||
|
||||
void SetParent(CHWPPargraph* pParent);
|
||||
CHWPPargraph* GetParent();
|
||||
|
||||
|
||||
@ -24,23 +24,33 @@ CCtrlHeadFoot::CCtrlHeadFoot(const HWP_STRING& sCtrlID, int nSize, CHWPStream& o
|
||||
oBuffer.ReadInt(m_nSerialInSec);
|
||||
}
|
||||
|
||||
CCtrlHeadFoot::CCtrlHeadFoot(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion)
|
||||
CCtrlHeadFoot::CCtrlHeadFoot(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion)
|
||||
: CCtrl(sCtrlID)
|
||||
{
|
||||
m_bIsHeader = L"daeh" == sCtrlID;
|
||||
|
||||
m_eWhichPage = GetPageRange(oNode.GetAttributeInt(L"applyPageType"));
|
||||
m_eWhichPage = GetPageRange(oReader.GetAttributeInt("applyPageType"));
|
||||
|
||||
for (CXMLNode& oChild : oNode.GetChilds(L"hp:subList"))
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hp:subList")
|
||||
{
|
||||
m_chRefLevelNum = (HWP_BYTE)oChild.GetAttributeInt(L"hasNumRef");
|
||||
m_chRefLevelText = (HWP_BYTE)oChild.GetAttributeInt(L"hasTextRef");
|
||||
m_nTextHeight = oChild.GetAttributeInt(L"textHeight");
|
||||
m_nTextWidth = oChild.GetAttributeInt(L"textWidth");
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("hasNumRef" == sAttributeName)
|
||||
m_chRefLevelNum = (HWP_BYTE)oReader.GetInt();
|
||||
else if ("hasTextRef" == sAttributeName)
|
||||
m_chRefLevelText = (HWP_BYTE)oReader.GetInt();
|
||||
else if ("textHeight" == sAttributeName)
|
||||
m_nTextHeight = oReader.GetInt();
|
||||
else if ("textWidth" == sAttributeName)
|
||||
m_nTextWidth = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
for (CXMLNode& oGrandChild : oChild.GetChilds(L"hp:p"))
|
||||
m_arParas.push_back(new CHWPPargraph(oGrandChild, nVersion));
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Child, "hp:p")
|
||||
m_arParas.push_back(new CHWPPargraph(oReader, nVersion));
|
||||
END_WHILE
|
||||
}
|
||||
END_WHILE
|
||||
|
||||
m_bFullFilled = true;
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ class CCtrlHeadFoot : public CCtrl
|
||||
public:
|
||||
CCtrlHeadFoot(const HWP_STRING& sCtrlID);
|
||||
CCtrlHeadFoot(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion, bool bIsHeader);
|
||||
CCtrlHeadFoot(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion);
|
||||
CCtrlHeadFoot(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion);
|
||||
|
||||
ECtrlObjectType GetCtrlType() const override;
|
||||
|
||||
|
||||
@ -20,13 +20,20 @@ CCtrlNewNumber::CCtrlNewNumber(const HWP_STRING& sCtrlID, int nSize, CHWPStream&
|
||||
m_bFullFilled = true;
|
||||
}
|
||||
|
||||
CCtrlNewNumber::CCtrlNewNumber(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion)
|
||||
CCtrlNewNumber::CCtrlNewNumber(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion)
|
||||
: CCtrl(sCtrlID)
|
||||
{
|
||||
m_shNum = oNode.GetAttributeInt(L"num");
|
||||
m_eNumType = ::HWP::GetNumType(oNode.GetAttribute(L"numType"));
|
||||
//TODO:: проверить данный момент
|
||||
m_eNumShape = GetNumberShape2(oNode.GetAttributeInt(L"autoNumFormat"));
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("num" == sAttributeName)
|
||||
m_shNum = oReader.GetInt();
|
||||
else if ("numType" == sAttributeName)
|
||||
m_eNumType = ::HWP::GetNumType(oReader.GetText());
|
||||
//TODO:: проверить данный момент
|
||||
else if ("autoNumFormat" == sAttributeName)
|
||||
m_eNumShape = GetNumberShape2(oReader.GetInt());
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
m_bFullFilled = true;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user