mirror of
https://github.com/ONLYOFFICE/core.git
synced 2025-04-18 14:04:06 +03:00
Remove HtmlRenderer library
This commit is contained in:
parent
185b3d54eb
commit
2f45a87669
@ -121,7 +121,7 @@ drawingfile_support {
|
||||
embed/DrawingFileEmbed.h
|
||||
|
||||
SOURCES += \
|
||||
../../HtmlRenderer/src/HTMLRendererText.cpp \
|
||||
../graphics/pro/js/wasm/src/HTMLRendererText.cpp \
|
||||
embed/DrawingFileEmbed.cpp
|
||||
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/DrawingFileEmbed.h)
|
||||
|
@ -19,7 +19,7 @@ include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
include(../../freetype.pri)
|
||||
|
||||
ADD_DEPENDENCY(UnicodeConverter, kernel, HtmlRenderer)
|
||||
ADD_DEPENDENCY(UnicodeConverter, kernel)
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$CORE_ROOT_DIR/DesktopEditor/agg-2.4/include \
|
||||
@ -704,7 +704,6 @@ HEADERS += \
|
||||
SOURCES += \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/BaseItem.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/ContText.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/DropCap.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Paragraph.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Shape.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/TextLine.cpp \
|
||||
|
@ -36,7 +36,6 @@
|
||||
|
||||
#include "../../common/Directory.h"
|
||||
#include "../../fontengine/ApplicationFonts.h"
|
||||
#include "../../../HtmlRenderer/include/ASCSVGWriter.h"
|
||||
#include "MetaFile.h"
|
||||
|
||||
#if defined(_WIN64)
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include <fstream>
|
||||
|
||||
#ifdef TEST_FOR_HTML_RENDERER_TEXT
|
||||
#include "../../HtmlRenderer/include/HTMLRendererText.h"
|
||||
#include "../../DesktopEditor/graphics/pro/js/wasm/src/HTMLRendererText.h"
|
||||
#endif
|
||||
|
||||
//#define LOAD_FILE_AS_BINARY
|
||||
|
@ -30,6 +30,6 @@ DESTDIR = $$PWD_ROOT_DIR/build
|
||||
use_test_html_renderer {
|
||||
DEFINES += TEST_FOR_HTML_RENDERER_TEXT
|
||||
|
||||
HEADERS += $$CORE_ROOT_DIR/HtmlRenderer/include/HTMLRendererText.h
|
||||
SOURCES += $$CORE_ROOT_DIR/HtmlRenderer/src/HTMLRendererText.cpp
|
||||
HEADERS += $$CORE_ROOT_DIR/DesktopEditor/graphics/pro/js/wasm/src/HTMLRendererText.h
|
||||
SOURCES += $$CORE_ROOT_DIR/DesktopEditor/graphics/pro/js/wasm/src/HTMLRendererText.cpp
|
||||
}
|
||||
|
@ -1,326 +0,0 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
6967BEDE1E28BC7300A129E2 /* HTMLRenderer3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6967BED51E28BC7300A129E2 /* HTMLRenderer3.cpp */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
6967BEBF1E28BC1700A129E2 /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "include/$(PRODUCT_NAME)";
|
||||
dstSubfolderSpec = 16;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
6967BEC11E28BC1700A129E2 /* libHtmlRenderer.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libHtmlRenderer.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
6967BECF1E28BC7300A129E2 /* CanvasWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CanvasWriter.h; sourceTree = "<group>"; };
|
||||
6967BED01E28BC7300A129E2 /* Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Common.h; sourceTree = "<group>"; };
|
||||
6967BED11E28BC7300A129E2 /* Common2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Common2.h; sourceTree = "<group>"; };
|
||||
6967BED21E28BC7300A129E2 /* Document.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Document.h; sourceTree = "<group>"; };
|
||||
6967BED31E28BC7300A129E2 /* FontManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontManager.h; sourceTree = "<group>"; };
|
||||
6967BED41E28BC7300A129E2 /* FontManagerBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontManagerBase.h; sourceTree = "<group>"; };
|
||||
6967BED51E28BC7300A129E2 /* HTMLRenderer3.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLRenderer3.cpp; sourceTree = "<group>"; };
|
||||
6967BED61E28BC7300A129E2 /* SVGWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGWriter.h; sourceTree = "<group>"; };
|
||||
6967BED71E28BC7300A129E2 /* SVGWriter2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGWriter2.h; sourceTree = "<group>"; };
|
||||
6967BED81E28BC7300A129E2 /* Text.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Text.h; sourceTree = "<group>"; };
|
||||
6967BED91E28BC7300A129E2 /* VectorGraphicsWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VectorGraphicsWriter.h; sourceTree = "<group>"; };
|
||||
6967BEDA1E28BC7300A129E2 /* VectorGraphicsWriter2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VectorGraphicsWriter2.h; sourceTree = "<group>"; };
|
||||
6967BEDB1E28BC7300A129E2 /* VMLWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMLWriter.h; sourceTree = "<group>"; };
|
||||
6967BEDC1E28BC7300A129E2 /* Writer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Writer.h; sourceTree = "<group>"; };
|
||||
6967BEE11E28BC7900A129E2 /* HTMLRenderer3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLRenderer3.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
6967BEBE1E28BC1700A129E2 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
6967BEB81E28BC1700A129E2 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
6967BEC31E28BC1700A129E2 /* HtmlRenderer */,
|
||||
6967BEC21E28BC1700A129E2 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
6967BEC21E28BC1700A129E2 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
6967BEC11E28BC1700A129E2 /* libHtmlRenderer.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
6967BEC31E28BC1700A129E2 /* HtmlRenderer */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
6967BEDF1E28BC7900A129E2 /* include */,
|
||||
6967BECD1E28BC7300A129E2 /* src */,
|
||||
);
|
||||
path = HtmlRenderer;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
6967BECD1E28BC7300A129E2 /* src */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
6967BECF1E28BC7300A129E2 /* CanvasWriter.h */,
|
||||
6967BED01E28BC7300A129E2 /* Common.h */,
|
||||
6967BED11E28BC7300A129E2 /* Common2.h */,
|
||||
6967BED21E28BC7300A129E2 /* Document.h */,
|
||||
6967BED31E28BC7300A129E2 /* FontManager.h */,
|
||||
6967BED41E28BC7300A129E2 /* FontManagerBase.h */,
|
||||
6967BED51E28BC7300A129E2 /* HTMLRenderer3.cpp */,
|
||||
6967BED61E28BC7300A129E2 /* SVGWriter.h */,
|
||||
6967BED71E28BC7300A129E2 /* SVGWriter2.h */,
|
||||
6967BED81E28BC7300A129E2 /* Text.h */,
|
||||
6967BED91E28BC7300A129E2 /* VectorGraphicsWriter.h */,
|
||||
6967BEDA1E28BC7300A129E2 /* VectorGraphicsWriter2.h */,
|
||||
6967BEDB1E28BC7300A129E2 /* VMLWriter.h */,
|
||||
6967BEDC1E28BC7300A129E2 /* Writer.h */,
|
||||
);
|
||||
name = src;
|
||||
path = ../../src;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
6967BEDF1E28BC7900A129E2 /* include */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
6967BEE11E28BC7900A129E2 /* HTMLRenderer3.h */,
|
||||
);
|
||||
name = include;
|
||||
path = ../../include;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
6967BEC01E28BC1700A129E2 /* HtmlRenderer */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 6967BECA1E28BC1700A129E2 /* Build configuration list for PBXNativeTarget "HtmlRenderer" */;
|
||||
buildPhases = (
|
||||
6967BEBD1E28BC1700A129E2 /* Sources */,
|
||||
6967BEBE1E28BC1700A129E2 /* Frameworks */,
|
||||
6967BEBF1E28BC1700A129E2 /* CopyFiles */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = HtmlRenderer;
|
||||
productName = HtmlRenderer;
|
||||
productReference = 6967BEC11E28BC1700A129E2 /* libHtmlRenderer.a */;
|
||||
productType = "com.apple.product-type.library.static";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
6967BEB91E28BC1700A129E2 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0820;
|
||||
ORGANIZATIONNAME = OnlyOffce;
|
||||
TargetAttributes = {
|
||||
6967BEC01E28BC1700A129E2 = {
|
||||
CreatedOnToolsVersion = 8.2;
|
||||
DevelopmentTeam = 2WH24U26GJ;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 6967BEBC1E28BC1700A129E2 /* Build configuration list for PBXProject "HtmlRenderer" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = 6967BEB81E28BC1700A129E2;
|
||||
productRefGroup = 6967BEC21E28BC1700A129E2 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
6967BEC01E28BC1700A129E2 /* HtmlRenderer */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
6967BEBD1E28BC1700A129E2 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
6967BEDE1E28BC7300A129E2 /* HTMLRenderer3.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
6967BEC81E28BC1700A129E2 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
6967BEC91E28BC1700A129E2 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
6967BECB1E28BC1700A129E2 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
DEVELOPMENT_TEAM = 2WH24U26GJ;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||
/usr/include/,
|
||||
/usr/include/libxml2/,
|
||||
"$(PROJECT_DIR)/../../DesktopEditor/freetype-2.5.2/include",
|
||||
"$(PROJECT_DIR)/../../DesktopEditor/freetype-2.5.2/devel",
|
||||
"$(PROJECT_DIR)/../../DesktopEditor/agg-2.4/include",
|
||||
);
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
6967BECC1E28BC1700A129E2 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
DEVELOPMENT_TEAM = 2WH24U26GJ;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||
/usr/include/,
|
||||
/usr/include/libxml2/,
|
||||
"$(PROJECT_DIR)/../../DesktopEditor/freetype-2.5.2/include",
|
||||
"$(PROJECT_DIR)/../../DesktopEditor/freetype-2.5.2/devel",
|
||||
"$(PROJECT_DIR)/../../DesktopEditor/agg-2.4/include",
|
||||
);
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
6967BEBC1E28BC1700A129E2 /* Build configuration list for PBXProject "HtmlRenderer" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
6967BEC81E28BC1700A129E2 /* Debug */,
|
||||
6967BEC91E28BC1700A129E2 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
6967BECA1E28BC1700A129E2 /* Build configuration list for PBXNativeTarget "HtmlRenderer" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
6967BECB1E28BC1700A129E2 /* Debug */,
|
||||
6967BECC1E28BC1700A129E2 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 6967BEB91E28BC1700A129E2 /* Project object */;
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:HtmlRenderer.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
@ -1 +0,0 @@
|
||||
DO NOT REMOVE FOLDER FOR XCODE
|
@ -1,47 +0,0 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
VERSION = 1.0.0.3
|
||||
TARGET = HtmlRenderer
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += shared
|
||||
CONFIG += plugin
|
||||
|
||||
DEFINES += HTMLRENDERER_USE_DYNAMIC_LIBRARY
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include(../Common/base.pri)
|
||||
|
||||
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter)
|
||||
|
||||
core_windows {
|
||||
LIBS += -lgdi32 \
|
||||
-ladvapi32 \
|
||||
-luser32 \
|
||||
-lshell32
|
||||
}
|
||||
|
||||
SOURCES += \
|
||||
src/HTMLRenderer3.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/CanvasWriter.h \
|
||||
src/Common.h \
|
||||
src/Document.h \
|
||||
src/FontManager.h \
|
||||
src/FontManagerBase.h \
|
||||
src/SVGWriter.h \
|
||||
src/SVGWriter2.h \
|
||||
src/Text.h \
|
||||
src/VectorGraphicsWriter.h \
|
||||
src/VectorGraphicsWriter2.h \
|
||||
src/VMLWriter.h \
|
||||
src/Writer.h \
|
||||
include/HTMLRenderer3.h \
|
||||
src/Common2.h \
|
||||
src/Meta.h
|
||||
|
||||
#HEADERS += $$PWD/include/HTMLRendererText.h
|
||||
#SOURCES += $$PWD/src/HTMLRendererText.cpp
|
@ -1,240 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef _ASC_HTMLRENDERER_SVG_WRITER_H_
|
||||
#define _ASC_HTMLRENDERER_SVG_WRITER_H_
|
||||
|
||||
#include "../../DesktopEditor/graphics/IRenderer.h"
|
||||
#include "../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
#include "../../DesktopEditor/graphics/GraphicsPath.h"
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
class CSVGGraphicsWriter;
|
||||
}
|
||||
namespace NSStructures
|
||||
{
|
||||
class CPen;
|
||||
class CBrush;
|
||||
class CFont;
|
||||
}
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
class CASCSVGWriter : public IRenderer
|
||||
{
|
||||
public:
|
||||
CASCSVGWriter(bool bIsInitializeFonts = true);
|
||||
~CASCSVGWriter();
|
||||
|
||||
void Reset();
|
||||
|
||||
// тип рендерера-----------------------------------------------------------------------------
|
||||
HRESULT get_Type(LONG* lType);
|
||||
//-------- Функции для работы со страницей --------------------------------------------------
|
||||
HRESULT NewPage();
|
||||
HRESULT get_Height(double* dHeight);
|
||||
HRESULT put_Height(const double& dHeight);
|
||||
HRESULT get_Width(double* dWidth);
|
||||
HRESULT put_Width(const double& dWidth);
|
||||
HRESULT get_DpiX(double* dDpiX);
|
||||
HRESULT get_DpiY(double* dDpiY);
|
||||
|
||||
// pen --------------------------------------------------------------------------------------
|
||||
HRESULT get_PenColor(LONG* lColor);
|
||||
HRESULT put_PenColor(const LONG& lColor);
|
||||
HRESULT get_PenAlpha(LONG* lAlpha);
|
||||
HRESULT put_PenAlpha(const LONG& lAlpha);
|
||||
HRESULT get_PenSize(double* dSize);
|
||||
HRESULT put_PenSize(const double& dSize);
|
||||
HRESULT get_PenDashStyle(BYTE* val);
|
||||
HRESULT put_PenDashStyle(const BYTE& val);
|
||||
HRESULT get_PenLineStartCap(BYTE* val);
|
||||
HRESULT put_PenLineStartCap(const BYTE& val);
|
||||
HRESULT get_PenLineEndCap(BYTE* val);
|
||||
HRESULT put_PenLineEndCap(const BYTE& val);
|
||||
HRESULT get_PenLineJoin(BYTE* val);
|
||||
HRESULT put_PenLineJoin(const BYTE& val);
|
||||
HRESULT get_PenDashOffset(double* dOffset);
|
||||
HRESULT put_PenDashOffset(const double& dOffset);
|
||||
HRESULT get_PenAlign(LONG* lAlign);
|
||||
HRESULT put_PenAlign(const LONG& lAlign);
|
||||
HRESULT get_PenMiterLimit(double* dOffset);
|
||||
HRESULT put_PenMiterLimit(const double& dOffset);
|
||||
HRESULT PenDashPattern(double* pPattern, LONG lCount);
|
||||
|
||||
// brush ------------------------------------------------------------------------------------
|
||||
HRESULT get_BrushType(LONG* lType);
|
||||
HRESULT put_BrushType(const LONG& lType);
|
||||
HRESULT get_BrushColor1(LONG* lColor);
|
||||
HRESULT put_BrushColor1(const LONG& lColor);
|
||||
HRESULT get_BrushAlpha1(LONG* lAlpha);
|
||||
HRESULT put_BrushAlpha1(const LONG& lAlpha);
|
||||
HRESULT get_BrushColor2(LONG* lColor);
|
||||
HRESULT put_BrushColor2(const LONG& lColor);
|
||||
HRESULT get_BrushAlpha2(LONG* lAlpha);
|
||||
HRESULT put_BrushAlpha2(const LONG& lAlpha);
|
||||
HRESULT get_BrushTexturePath(std::wstring* bsPath);
|
||||
HRESULT put_BrushTexturePath(const std::wstring& bsPath);
|
||||
HRESULT get_BrushTextureMode(LONG* lMode);
|
||||
HRESULT put_BrushTextureMode(const LONG& lMode);
|
||||
HRESULT get_BrushTextureAlpha(LONG* lTxAlpha);
|
||||
HRESULT put_BrushTextureAlpha(const LONG& lTxAlpha);
|
||||
HRESULT get_BrushLinearAngle(double* dAngle);
|
||||
HRESULT put_BrushLinearAngle(const double& dAngle);
|
||||
HRESULT BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height);
|
||||
HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height);
|
||||
|
||||
HRESULT put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount);
|
||||
|
||||
HRESULT get_BrushTextureImage(Aggplus::CImage** pImage) { return S_OK; }
|
||||
HRESULT put_BrushTextureImage(Aggplus::CImage* pImage) { return S_OK; }
|
||||
HRESULT get_BrushTransform(Aggplus::CMatrix& oMatrix) { return S_OK; }
|
||||
HRESULT put_BrushTransform(const Aggplus::CMatrix& oMatrix) { return S_OK; }
|
||||
// font -------------------------------------------------------------------------------------
|
||||
HRESULT get_FontName(std::wstring* bsName);
|
||||
HRESULT put_FontName(const std::wstring& bsName);
|
||||
HRESULT get_FontPath(std::wstring* bsName);
|
||||
HRESULT put_FontPath(const std::wstring& bsName);
|
||||
HRESULT get_FontSize(double* dSize);
|
||||
HRESULT put_FontSize(const double& dSize);
|
||||
HRESULT get_FontStyle(LONG* lStyle) ;
|
||||
HRESULT put_FontStyle(const LONG& lStyle);
|
||||
HRESULT get_FontStringGID(INT* bGID);
|
||||
HRESULT put_FontStringGID(const INT& bGID);
|
||||
HRESULT get_FontCharSpace(double* dSpace);
|
||||
HRESULT put_FontCharSpace(const double& dSpace);
|
||||
HRESULT get_FontFaceIndex(int* lFaceIndex);
|
||||
HRESULT put_FontFaceIndex(const int& lFaceIndex);
|
||||
|
||||
//-------- Функции для вывода текста --------------------------------------------------------
|
||||
HRESULT CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h);
|
||||
HRESULT CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h);
|
||||
|
||||
HRESULT CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h);
|
||||
HRESULT CommandDrawTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h);
|
||||
|
||||
//-------- Маркеры для команд ---------------------------------------------------------------
|
||||
HRESULT BeginCommand(const DWORD& lType);
|
||||
HRESULT EndCommand(const DWORD& lType);
|
||||
|
||||
//-------- Функции для работы с Graphics Path -----------------------------------------------
|
||||
HRESULT PathCommandMoveTo(const double& x, const double& y);
|
||||
HRESULT PathCommandLineTo(const double& x, const double& y);
|
||||
HRESULT PathCommandLinesTo(double* points, const int& count);
|
||||
HRESULT PathCommandCurveTo(const double& x1, const double& y1, const double& x2, const double& y2, const double& x3, const double& y3);
|
||||
HRESULT PathCommandCurvesTo(double* points, const int& count);
|
||||
HRESULT PathCommandArcTo(const double& x, const double& y, const double& w, const double& h, const double& startAngle, const double& sweepAngle);
|
||||
HRESULT PathCommandClose();
|
||||
HRESULT PathCommandEnd();
|
||||
HRESULT DrawPath(const LONG& nType);
|
||||
HRESULT PathCommandStart();
|
||||
HRESULT PathCommandGetCurrentPoint(double* x, double* y);
|
||||
|
||||
HRESULT PathCommandTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h);
|
||||
HRESULT PathCommandText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h);
|
||||
|
||||
HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h);
|
||||
HRESULT PathCommandTextEx(const std::wstring& sText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h);
|
||||
|
||||
//-------- Функции для вывода изображений ---------------------------------------------------
|
||||
HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h);
|
||||
HRESULT DrawImageFromFile(const std::wstring&, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha);
|
||||
|
||||
// transform --------------------------------------------------------------------------------
|
||||
HRESULT SetTransform(const double& m1, const double& m2, const double& m3, const double& m4, const double& m5, const double& m6);
|
||||
HRESULT GetTransform(double *pdA, double *pdB, double *pdC, double *pdD, double *pdE, double *pdF);
|
||||
HRESULT ResetTransform();
|
||||
|
||||
// -----------------------------------------------------------------------------------------
|
||||
HRESULT get_ClipMode(LONG* plMode);
|
||||
HRESULT put_ClipMode(const LONG& lMode);
|
||||
// additiaonal params ----------------------------------------------------------------------
|
||||
HRESULT SaveFile(const std::wstring& strFileSave);
|
||||
HRESULT ReInit();
|
||||
HRESULT IsRaster(bool* bVal);
|
||||
HRESULT GetSVGDataSize(LONG* lVal);
|
||||
// additiaonal params ----------------------------------------------------------------------
|
||||
HRESULT CommandLong(const LONG& lType, const LONG& lCommand);
|
||||
HRESULT CommandDouble(const LONG& lType, const double& dCommand);
|
||||
HRESULT CommandString(const LONG& lType, const std::wstring& sCommand);
|
||||
public:
|
||||
|
||||
void SetFontManager(NSFonts::IFontManager* pFontManager);
|
||||
|
||||
private:
|
||||
|
||||
NSHtmlRenderer::CSVGGraphicsWriter* m_pVectorWriter;
|
||||
|
||||
Aggplus::CGraphicsPathSimpleConverter* m_pSimpleGraphicsConverter; // конвертер сложных гафических путей в простые
|
||||
NSFonts::IFontManager* m_pFontManager; // менеджер шрифтов
|
||||
|
||||
Aggplus::CMatrix* m_pBaseTransform; // матрица перерасчета координатных осей (здесь: миллиметры -> пикселы)
|
||||
Aggplus::CMatrix* m_pTransform; // текущая матрица преобразований рендерера
|
||||
Aggplus::CMatrix* m_pFullTransform; // полная матрица преобразований (m_oBaseTransform * m_oTransform)
|
||||
|
||||
double m_dTransformAngle;
|
||||
|
||||
LONG m_lCurrentCommandType; // текущая команда
|
||||
|
||||
double m_dDpiX;
|
||||
double m_dDpiY;
|
||||
|
||||
double m_dWidth;
|
||||
double m_dHeight;
|
||||
|
||||
LONG m_lClipMode;
|
||||
|
||||
NSStructures::CPen* m_pPen; // настройки всей графики (скопирован ашник из AVSGraphics)
|
||||
NSStructures::CBrush* m_pBrush;
|
||||
NSStructures::CFont* m_pFont;
|
||||
|
||||
NSStructures::CFont* m_pInstalledFont;
|
||||
|
||||
bool m_bIsRaster;
|
||||
|
||||
double m_dTextScale;
|
||||
bool m_bIsTextPath;
|
||||
//todo
|
||||
//IASCWinFonts* m_pFonts;
|
||||
|
||||
protected:
|
||||
void CalculateFullTransform();
|
||||
inline void MoveTo(const double& dX, const double& dY);
|
||||
inline void LineTo(const double& dX, const double& dY);
|
||||
inline void CurveTo(const double& x1, const double& y1, const double& x2, const double& y2, const double& x3, const double& y3);
|
||||
void Start();
|
||||
void End();
|
||||
void Close();
|
||||
void _SetFont();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _ASC_HTMLRENDERER_SVG_WRITER_H_
|
@ -1,204 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef _ASC_HTMLRENDERER3_H_
|
||||
#define _ASC_HTMLRENDERER3_H_
|
||||
|
||||
#include "../../DesktopEditor/graphics/IRenderer.h"
|
||||
#include "../../DesktopEditor/graphics/pro/officedrawingfile.h"
|
||||
|
||||
#ifndef HTMLRENDERER_USE_DYNAMIC_LIBRARY
|
||||
#define HTMLRENDERER_DECL_EXPORT
|
||||
#else
|
||||
#include "../../DesktopEditor/common/base_export.h"
|
||||
#define HTMLRENDERER_DECL_EXPORT Q_DECL_EXPORT
|
||||
#endif
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
class CASCHTMLRenderer3_Private;
|
||||
class HTMLRENDERER_DECL_EXPORT CASCHTMLRenderer3 : public IRenderer
|
||||
{
|
||||
public:
|
||||
CASCHTMLRenderer3();
|
||||
virtual ~CASCHTMLRenderer3();
|
||||
public:
|
||||
// тип рендерера-----------------------------------------------------------------------------
|
||||
virtual HRESULT get_Type(LONG* lType);
|
||||
//-------- Функции для работы со страницей --------------------------------------------------
|
||||
virtual HRESULT NewPage();
|
||||
virtual HRESULT get_Height(double* dHeight);
|
||||
virtual HRESULT put_Height(const double& dHeight);
|
||||
virtual HRESULT get_Width(double* dWidth);
|
||||
virtual HRESULT put_Width(const double& dWidth);
|
||||
virtual HRESULT get_DpiX(double* dDpiX);
|
||||
virtual HRESULT get_DpiY(double* dDpiY);
|
||||
|
||||
// pen --------------------------------------------------------------------------------------
|
||||
virtual HRESULT get_PenColor(LONG* lColor);
|
||||
virtual HRESULT put_PenColor(const LONG& lColor);
|
||||
virtual HRESULT get_PenAlpha(LONG* lAlpha);
|
||||
virtual HRESULT put_PenAlpha(const LONG& lAlpha);
|
||||
virtual HRESULT get_PenSize(double* dSize);
|
||||
virtual HRESULT put_PenSize(const double& dSize);
|
||||
virtual HRESULT get_PenDashStyle(BYTE* val);
|
||||
virtual HRESULT put_PenDashStyle(const BYTE& val);
|
||||
virtual HRESULT get_PenLineStartCap(BYTE* val);
|
||||
virtual HRESULT put_PenLineStartCap(const BYTE& val);
|
||||
virtual HRESULT get_PenLineEndCap(BYTE* val);
|
||||
virtual HRESULT put_PenLineEndCap(const BYTE& val);
|
||||
virtual HRESULT get_PenLineJoin(BYTE* val);
|
||||
virtual HRESULT put_PenLineJoin(const BYTE& val);
|
||||
virtual HRESULT get_PenDashOffset(double* dOffset);
|
||||
virtual HRESULT put_PenDashOffset(const double& dOffset);
|
||||
virtual HRESULT get_PenAlign(LONG* lAlign);
|
||||
virtual HRESULT put_PenAlign(const LONG& lAlign);
|
||||
virtual HRESULT get_PenMiterLimit(double* dOffset);
|
||||
virtual HRESULT put_PenMiterLimit(const double& dOffset);
|
||||
virtual HRESULT PenDashPattern(double* pPattern, LONG lCount);
|
||||
|
||||
// brush ------------------------------------------------------------------------------------
|
||||
virtual HRESULT get_BrushType(LONG* lType);
|
||||
virtual HRESULT put_BrushType(const LONG& lType);
|
||||
virtual HRESULT get_BrushColor1(LONG* lColor);
|
||||
virtual HRESULT put_BrushColor1(const LONG& lColor);
|
||||
virtual HRESULT get_BrushAlpha1(LONG* lAlpha);
|
||||
virtual HRESULT put_BrushAlpha1(const LONG& lAlpha);
|
||||
virtual HRESULT get_BrushColor2(LONG* lColor);
|
||||
virtual HRESULT put_BrushColor2(const LONG& lColor);
|
||||
virtual HRESULT get_BrushAlpha2(LONG* lAlpha);
|
||||
virtual HRESULT put_BrushAlpha2(const LONG& lAlpha);
|
||||
virtual HRESULT get_BrushTexturePath(std::wstring* bsPath);
|
||||
virtual HRESULT put_BrushTexturePath(const std::wstring& bsPath);
|
||||
virtual HRESULT get_BrushTextureMode(LONG* lMode);
|
||||
virtual HRESULT put_BrushTextureMode(const LONG& lMode);
|
||||
virtual HRESULT get_BrushTextureAlpha(LONG* lTxAlpha);
|
||||
virtual HRESULT put_BrushTextureAlpha(const LONG& lTxAlpha);
|
||||
virtual HRESULT get_BrushLinearAngle(double* dAngle);
|
||||
virtual HRESULT put_BrushLinearAngle(const double& dAngle);
|
||||
virtual HRESULT BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height);
|
||||
virtual HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height);
|
||||
|
||||
virtual HRESULT put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount);
|
||||
|
||||
virtual HRESULT get_BrushTextureImage(Aggplus::CImage** pImage);
|
||||
virtual HRESULT put_BrushTextureImage(Aggplus::CImage* pImage);
|
||||
virtual HRESULT get_BrushTransform(Aggplus::CMatrix& oMatrix);
|
||||
virtual HRESULT put_BrushTransform(const Aggplus::CMatrix& oMatrix);
|
||||
|
||||
// font -------------------------------------------------------------------------------------
|
||||
virtual HRESULT get_FontName(std::wstring* bsName);
|
||||
virtual HRESULT put_FontName(const std::wstring& bsName);
|
||||
virtual HRESULT get_FontPath(std::wstring* bsName);
|
||||
virtual HRESULT put_FontPath(const std::wstring& bsName);
|
||||
virtual HRESULT get_FontSize(double* dSize);
|
||||
virtual HRESULT put_FontSize(const double& dSize);
|
||||
virtual HRESULT get_FontStyle(LONG* lStyle);
|
||||
virtual HRESULT put_FontStyle(const LONG& lStyle);
|
||||
virtual HRESULT get_FontStringGID(INT* bGID);
|
||||
virtual HRESULT put_FontStringGID(const INT& bGID);
|
||||
virtual HRESULT get_FontCharSpace(double* dSpace);
|
||||
virtual HRESULT put_FontCharSpace(const double& dSpace);
|
||||
virtual HRESULT get_FontFaceIndex(int* lFaceIndex);
|
||||
virtual HRESULT put_FontFaceIndex(const int& lFaceIndex);
|
||||
|
||||
//-------- Функции для вывода текста --------------------------------------------------------
|
||||
virtual HRESULT CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h);
|
||||
virtual HRESULT CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h);
|
||||
|
||||
virtual HRESULT CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h);
|
||||
virtual HRESULT CommandDrawTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h);
|
||||
|
||||
//-------- Маркеры для команд ---------------------------------------------------------------
|
||||
virtual HRESULT BeginCommand(const DWORD& lType);
|
||||
virtual HRESULT EndCommand(const DWORD& lType);
|
||||
|
||||
//-------- Функции для работы с Graphics Path -----------------------------------------------
|
||||
virtual HRESULT PathCommandMoveTo(const double& x, const double& y);
|
||||
virtual HRESULT PathCommandLineTo(const double& x, const double& y);
|
||||
virtual HRESULT PathCommandLinesTo(double* points, const int& count);
|
||||
virtual HRESULT PathCommandCurveTo(const double& x1, const double& y1, const double& x2, const double& y2, const double& x3, const double& y3);
|
||||
virtual HRESULT PathCommandCurvesTo(double* points, const int& count);
|
||||
virtual HRESULT PathCommandArcTo(const double& x, const double& y, const double& w, const double& h, const double& startAngle, const double& sweepAngle);
|
||||
virtual HRESULT PathCommandClose();
|
||||
virtual HRESULT PathCommandEnd();
|
||||
virtual HRESULT DrawPath(const LONG& nType);
|
||||
virtual HRESULT PathCommandStart();
|
||||
virtual HRESULT PathCommandGetCurrentPoint(double* x, double* y);
|
||||
|
||||
virtual HRESULT PathCommandTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h);
|
||||
virtual HRESULT PathCommandText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h);
|
||||
|
||||
virtual HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h);
|
||||
virtual HRESULT PathCommandTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h);
|
||||
|
||||
//-------- Функции для вывода изображений ---------------------------------------------------
|
||||
virtual HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h);
|
||||
virtual HRESULT DrawImageFromFile(const std::wstring&, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha = 255);
|
||||
|
||||
// transform --------------------------------------------------------------------------------
|
||||
virtual HRESULT SetTransform(const double& m1, const double& m2, const double& m3, const double& m4, const double& m5, const double& m6);
|
||||
virtual HRESULT GetTransform(double *pdA, double *pdB, double *pdC, double *pdD, double *pdE, double *pdF);
|
||||
virtual HRESULT ResetTransform();
|
||||
|
||||
// -----------------------------------------------------------------------------------------
|
||||
virtual HRESULT get_ClipMode(LONG* plMode);
|
||||
virtual HRESULT put_ClipMode(const LONG& lMode);
|
||||
|
||||
// additiaonal params ----------------------------------------------------------------------
|
||||
virtual HRESULT CommandLong(const LONG& lType, const LONG& lCommand);
|
||||
virtual HRESULT CommandDouble(const LONG& lType, const double& dCommand);
|
||||
virtual HRESULT CommandString(const LONG& lType, const std::wstring& sCommand);
|
||||
|
||||
virtual HRESULT StartConvertCoordsToIdentity();
|
||||
virtual HRESULT EndConvertCoordsToIdentity();
|
||||
|
||||
// owner params ----------------------------------------------------------------------
|
||||
virtual HRESULT get_Mode(LONG *plMode);
|
||||
virtual HRESULT put_Mode(LONG lMode);
|
||||
|
||||
virtual HRESULT CreateOfficeFile(std::wstring bsFileName, const std::wstring& fontsDir = L"");
|
||||
virtual HRESULT CloseFile(bool bIsNoBase64 = false);
|
||||
|
||||
virtual HRESULT SetAdditionalParam(std::string sParamName, int nValue);
|
||||
virtual HRESULT SetAdditionalParam(std::string sParamName, const std::wstring& sParam);
|
||||
|
||||
bool GetOnlyTextMode();
|
||||
void SetOnlyTextMode(const bool& enabled);
|
||||
|
||||
void GetLastPageInfo(int& paragraphs, int& words, int& symbols, int& spaces, std::string& sBase64Data);
|
||||
|
||||
protected:
|
||||
CASCHTMLRenderer3_Private* m_pInternal;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _ASC_HTMLRENDERER3_H_
|
@ -1,190 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef _ASC_HTMLRENDERER3_TEXT_H_
|
||||
#define _ASC_HTMLRENDERER3_TEXT_H_
|
||||
|
||||
#include "../../DesktopEditor/graphics/IRenderer.h"
|
||||
#include "../../DesktopEditor/graphics/pro/officedrawingfile.h"
|
||||
|
||||
#ifndef HTMLRENDERER_USE_DYNAMIC_LIBRARY
|
||||
#define HTMLRENDERER_DECL_EXPORT
|
||||
#else
|
||||
#include "../../DesktopEditor/common/base_export.h"
|
||||
#define HTMLRENDERER_DECL_EXPORT Q_DECL_EXPORT
|
||||
#endif
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
class CHTMLRendererText_Private;
|
||||
class HTMLRENDERER_DECL_EXPORT CHTMLRendererText : public IRenderer
|
||||
{
|
||||
public:
|
||||
CHTMLRendererText();
|
||||
virtual ~CHTMLRendererText();
|
||||
|
||||
public:
|
||||
void Init(IOfficeDrawingFile* pFile, int nCacheSize = 0);
|
||||
BYTE* GetBuffer();
|
||||
|
||||
public:
|
||||
// тип рендерера-----------------------------------------------------------------------------
|
||||
virtual HRESULT get_Type(LONG* lType);
|
||||
//-------- Функции для работы со страницей --------------------------------------------------
|
||||
virtual HRESULT NewPage();
|
||||
virtual HRESULT get_Height(double* dHeight);
|
||||
virtual HRESULT put_Height(const double& dHeight);
|
||||
virtual HRESULT get_Width(double* dWidth);
|
||||
virtual HRESULT put_Width(const double& dWidth);
|
||||
virtual HRESULT get_DpiX(double* dDpiX);
|
||||
virtual HRESULT get_DpiY(double* dDpiY);
|
||||
|
||||
// pen --------------------------------------------------------------------------------------
|
||||
virtual HRESULT get_PenColor(LONG* lColor);
|
||||
virtual HRESULT put_PenColor(const LONG& lColor);
|
||||
virtual HRESULT get_PenAlpha(LONG* lAlpha);
|
||||
virtual HRESULT put_PenAlpha(const LONG& lAlpha);
|
||||
virtual HRESULT get_PenSize(double* dSize);
|
||||
virtual HRESULT put_PenSize(const double& dSize);
|
||||
virtual HRESULT get_PenDashStyle(BYTE* val);
|
||||
virtual HRESULT put_PenDashStyle(const BYTE& val);
|
||||
virtual HRESULT get_PenLineStartCap(BYTE* val);
|
||||
virtual HRESULT put_PenLineStartCap(const BYTE& val);
|
||||
virtual HRESULT get_PenLineEndCap(BYTE* val);
|
||||
virtual HRESULT put_PenLineEndCap(const BYTE& val);
|
||||
virtual HRESULT get_PenLineJoin(BYTE* val);
|
||||
virtual HRESULT put_PenLineJoin(const BYTE& val);
|
||||
virtual HRESULT get_PenDashOffset(double* dOffset);
|
||||
virtual HRESULT put_PenDashOffset(const double& dOffset);
|
||||
virtual HRESULT get_PenAlign(LONG* lAlign);
|
||||
virtual HRESULT put_PenAlign(const LONG& lAlign);
|
||||
virtual HRESULT get_PenMiterLimit(double* dOffset);
|
||||
virtual HRESULT put_PenMiterLimit(const double& dOffset);
|
||||
virtual HRESULT PenDashPattern(double* pPattern, LONG lCount);
|
||||
virtual HRESULT get_BrushTextureImage(Aggplus::CImage** pImage);
|
||||
virtual HRESULT put_BrushTextureImage(Aggplus::CImage* pImage);
|
||||
virtual HRESULT get_BrushTransform(Aggplus::CMatrix& oMatrix);
|
||||
virtual HRESULT put_BrushTransform(const Aggplus::CMatrix& oMatrix);
|
||||
|
||||
// brush ------------------------------------------------------------------------------------
|
||||
virtual HRESULT get_BrushType(LONG* lType);
|
||||
virtual HRESULT put_BrushType(const LONG& lType);
|
||||
virtual HRESULT get_BrushColor1(LONG* lColor);
|
||||
virtual HRESULT put_BrushColor1(const LONG& lColor);
|
||||
virtual HRESULT get_BrushAlpha1(LONG* lAlpha);
|
||||
virtual HRESULT put_BrushAlpha1(const LONG& lAlpha);
|
||||
virtual HRESULT get_BrushColor2(LONG* lColor);
|
||||
virtual HRESULT put_BrushColor2(const LONG& lColor);
|
||||
virtual HRESULT get_BrushAlpha2(LONG* lAlpha);
|
||||
virtual HRESULT put_BrushAlpha2(const LONG& lAlpha);
|
||||
virtual HRESULT get_BrushTexturePath(std::wstring* bsPath);
|
||||
virtual HRESULT put_BrushTexturePath(const std::wstring& bsPath);
|
||||
virtual HRESULT get_BrushTextureMode(LONG* lMode);
|
||||
virtual HRESULT put_BrushTextureMode(const LONG& lMode);
|
||||
virtual HRESULT get_BrushTextureAlpha(LONG* lTxAlpha);
|
||||
virtual HRESULT put_BrushTextureAlpha(const LONG& lTxAlpha);
|
||||
virtual HRESULT get_BrushLinearAngle(double* dAngle);
|
||||
virtual HRESULT put_BrushLinearAngle(const double& dAngle);
|
||||
virtual HRESULT BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height);
|
||||
virtual HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height);
|
||||
|
||||
virtual HRESULT put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount);
|
||||
|
||||
// font -------------------------------------------------------------------------------------
|
||||
virtual HRESULT get_FontName(std::wstring* bsName);
|
||||
virtual HRESULT put_FontName(const std::wstring& bsName);
|
||||
virtual HRESULT get_FontPath(std::wstring* bsName);
|
||||
virtual HRESULT put_FontPath(const std::wstring& bsName);
|
||||
virtual HRESULT get_FontSize(double* dSize);
|
||||
virtual HRESULT put_FontSize(const double& dSize);
|
||||
virtual HRESULT get_FontStyle(LONG* lStyle);
|
||||
virtual HRESULT put_FontStyle(const LONG& lStyle);
|
||||
virtual HRESULT get_FontStringGID(INT* bGID);
|
||||
virtual HRESULT put_FontStringGID(const INT& bGID);
|
||||
virtual HRESULT get_FontCharSpace(double* dSpace);
|
||||
virtual HRESULT put_FontCharSpace(const double& dSpace);
|
||||
virtual HRESULT get_FontFaceIndex(int* lFaceIndex);
|
||||
virtual HRESULT put_FontFaceIndex(const int& lFaceIndex);
|
||||
|
||||
//-------- Функции для вывода текста --------------------------------------------------------
|
||||
virtual HRESULT CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h);
|
||||
virtual HRESULT CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h);
|
||||
|
||||
virtual HRESULT CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h);
|
||||
virtual HRESULT CommandDrawTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h);
|
||||
|
||||
//-------- Маркеры для команд ---------------------------------------------------------------
|
||||
virtual HRESULT BeginCommand(const DWORD& lType);
|
||||
virtual HRESULT EndCommand(const DWORD& lType);
|
||||
|
||||
//-------- Функции для работы с Graphics Path -----------------------------------------------
|
||||
virtual HRESULT PathCommandMoveTo(const double& x, const double& y);
|
||||
virtual HRESULT PathCommandLineTo(const double& x, const double& y);
|
||||
virtual HRESULT PathCommandLinesTo(double* points, const int& count);
|
||||
virtual HRESULT PathCommandCurveTo(const double& x1, const double& y1, const double& x2, const double& y2, const double& x3, const double& y3);
|
||||
virtual HRESULT PathCommandCurvesTo(double* points, const int& count);
|
||||
virtual HRESULT PathCommandArcTo(const double& x, const double& y, const double& w, const double& h, const double& startAngle, const double& sweepAngle);
|
||||
virtual HRESULT PathCommandClose();
|
||||
virtual HRESULT PathCommandEnd();
|
||||
virtual HRESULT DrawPath(const LONG& nType);
|
||||
virtual HRESULT PathCommandStart();
|
||||
virtual HRESULT PathCommandGetCurrentPoint(double* x, double* y);
|
||||
|
||||
virtual HRESULT PathCommandTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h);
|
||||
virtual HRESULT PathCommandText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h);
|
||||
|
||||
virtual HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h);
|
||||
virtual HRESULT PathCommandTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h);
|
||||
|
||||
//-------- Функции для вывода изображений ---------------------------------------------------
|
||||
virtual HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h);
|
||||
virtual HRESULT DrawImageFromFile(const std::wstring&, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha = 255);
|
||||
|
||||
// transform --------------------------------------------------------------------------------
|
||||
virtual HRESULT SetTransform(const double& m1, const double& m2, const double& m3, const double& m4, const double& m5, const double& m6);
|
||||
virtual HRESULT GetTransform(double *pdA, double *pdB, double *pdC, double *pdD, double *pdE, double *pdF);
|
||||
virtual HRESULT ResetTransform();
|
||||
|
||||
// -----------------------------------------------------------------------------------------
|
||||
virtual HRESULT get_ClipMode(LONG* plMode);
|
||||
virtual HRESULT put_ClipMode(const LONG& lMode);
|
||||
|
||||
// additiaonal params ----------------------------------------------------------------------
|
||||
virtual HRESULT CommandLong(const LONG& lType, const LONG& lCommand);
|
||||
virtual HRESULT CommandDouble(const LONG& lType, const double& dCommand);
|
||||
virtual HRESULT CommandString(const LONG& lType, const std::wstring& sCommand);
|
||||
|
||||
protected:
|
||||
CHTMLRendererText_Private* m_pInternal;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _ASC_HTMLRENDERER3_TEXT_H_
|
File diff suppressed because it is too large
Load Diff
@ -1,243 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef _ASC_HTMLRENDERER_CANVASWRITER_H_
|
||||
#define _ASC_HTMLRENDERER_CANVASWRITER_H_
|
||||
|
||||
#include "Common.h"
|
||||
#include "../../DesktopEditor/graphics/GraphicsPath.h"
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
class CCanvasWriter
|
||||
{
|
||||
public:
|
||||
NSStringUtils::CStringBuilder m_oPath;
|
||||
NSStringUtils::CStringBuilder m_oDocument;
|
||||
|
||||
LONG m_lCurDocumentID;
|
||||
LONG m_lClippingPath;
|
||||
|
||||
bool m_bIsClipping;
|
||||
LONG m_lClipMode;
|
||||
bool m_bIsMoveTo;
|
||||
|
||||
NSStructures::CPen* m_pPen;
|
||||
NSStructures::CBrush* m_pBrush;
|
||||
|
||||
double m_lWidth;
|
||||
double m_lHeight;
|
||||
|
||||
double m_dDpiX;
|
||||
double m_dDpiY;
|
||||
|
||||
public:
|
||||
CCanvasWriter() : m_oPath(), m_oDocument()
|
||||
{
|
||||
m_lCurDocumentID = 0;
|
||||
m_lClippingPath = 0;
|
||||
|
||||
m_pPen = NULL;
|
||||
m_pBrush = NULL;
|
||||
|
||||
m_dDpiX = 96;
|
||||
m_dDpiY = 96;
|
||||
|
||||
m_lClipMode = c_nWindingFillMode;
|
||||
|
||||
m_bIsClipping = false;
|
||||
m_bIsMoveTo = false;
|
||||
}
|
||||
|
||||
void SetSettings(NSStructures::CPen* pPen, NSStructures::CBrush* pBrush)
|
||||
{
|
||||
m_pPen = pPen;
|
||||
m_pBrush = pBrush;
|
||||
}
|
||||
|
||||
void CloseFile(std::wstring strFile = L"")
|
||||
{
|
||||
if (!strFile.empty())
|
||||
{
|
||||
NSFile::CFileBinary::SaveToFile(strFile, m_oDocument.GetData());
|
||||
}
|
||||
|
||||
m_oDocument.ClearNoAttack();
|
||||
m_oPath.ClearNoAttack();
|
||||
}
|
||||
void NewDocument(double& dWidth, double& dHeigth)
|
||||
{
|
||||
CloseFile(L"");
|
||||
|
||||
m_lWidth = (int)dWidth;
|
||||
m_lHeight = (int)dHeigth;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
inline void WritePathEnd()
|
||||
{
|
||||
}
|
||||
inline void WritePathStart()
|
||||
{
|
||||
m_bIsMoveTo = false;
|
||||
m_oDocument.WriteString(L"b(c);\n", 6);
|
||||
}
|
||||
void WritePathClose()
|
||||
{
|
||||
m_oDocument.WriteString(L"x(c);\n", 6);
|
||||
}
|
||||
|
||||
void WritePathMoveTo(double& x, double& y)
|
||||
{
|
||||
m_oDocument.WriteString(L"m(c,", 4);
|
||||
WriteIntsToStringBuilder(round(x), round(y), &m_oDocument);
|
||||
m_oDocument.WriteString(L");\n", 3);
|
||||
|
||||
m_bIsMoveTo = true;
|
||||
}
|
||||
void WritePathLineTo(double& x, double& y)
|
||||
{
|
||||
if (false == m_bIsMoveTo)
|
||||
WritePathMoveTo(x, y);
|
||||
|
||||
m_oDocument.WriteString(L"l(c,", 4);
|
||||
WriteIntsToStringBuilder(round(x), round(y), &m_oDocument);
|
||||
m_oDocument.WriteString(L");\n", 3);
|
||||
}
|
||||
void WritePathCurveTo(double& x1, double& y1, double& x2, double& y2, double& x3, double& y3)
|
||||
{
|
||||
if (false == m_bIsMoveTo)
|
||||
WritePathMoveTo(x1, y1);
|
||||
|
||||
m_oDocument.WriteString(L"cu(c,", 5);
|
||||
WriteIntsToStringBuilder(round(x1), round(y1), round(x2), round(y2), round(x3), round(y3), &m_oDocument);
|
||||
m_oDocument.WriteString(L");\n", 3);
|
||||
}
|
||||
void WriteDrawPath(LONG lType, Aggplus::CMatrix* pTransform, Aggplus::CGraphicsPathSimpleConverter* pConverter, LONG lTxId)
|
||||
{
|
||||
bool bStroke = false;
|
||||
|
||||
if (m_pPen->Alpha == 0)
|
||||
lType &= 0xFF00;
|
||||
|
||||
if ((-1 == lTxId) && (0 == m_pBrush->Alpha1))
|
||||
lType &= 0xFF;
|
||||
|
||||
if ((lType & 0x01) == 0x01)
|
||||
{
|
||||
SetStrokeColor(m_pPen->Color, m_pPen->Alpha, &m_oDocument);
|
||||
|
||||
bStroke = true;
|
||||
}
|
||||
if (lType > 0x01)
|
||||
{
|
||||
if (-1 != lTxId)
|
||||
{
|
||||
// текстура!
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
double w = 0;
|
||||
double h = 0;
|
||||
|
||||
pConverter->PathCommandGetBounds(x, y, w, h);
|
||||
|
||||
double r = x + w;
|
||||
double b = y + h;
|
||||
|
||||
pTransform->TransformPoint(x, y);
|
||||
pTransform->TransformPoint(r, b);
|
||||
|
||||
w = r - x;
|
||||
h = b - y;
|
||||
|
||||
m_oDocument.WriteString(L"img", 3);
|
||||
m_oDocument.AddInt(lTxId);
|
||||
m_oDocument.WriteString(L".src = \"media\\\\image", 20);
|
||||
m_oDocument.AddInt(lTxId);
|
||||
m_oDocument.WriteString(L".jpg\";img", 9);
|
||||
m_oDocument.AddInt(lTxId);
|
||||
m_oDocument.WriteString(L".onload = function(){c.drawImage(img", 36);
|
||||
WriteIntsToStringBuilder(lTxId, round(x), round(y), round(w), round(h), &m_oDocument);
|
||||
m_oDocument.WriteString(L");drawpage", 10);
|
||||
m_oDocument.AddInt(m_lCurDocumentID);
|
||||
m_oDocument.AddCharSafe('_');
|
||||
m_oDocument.AddInt(lTxId);
|
||||
m_oDocument.WriteString(L"(c);};\n}\nfunction drawpage", 26);
|
||||
m_oDocument.AddInt(m_lCurDocumentID);
|
||||
m_oDocument.AddCharSafe('_');
|
||||
m_oDocument.AddInt(lTxId);
|
||||
m_oDocument.WriteString(L"(c)\n{\n", 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFillColor(m_pBrush->Color1, m_pBrush->Alpha1, &m_oDocument);
|
||||
m_oDocument.WriteString(L"f(c);\n", 6);
|
||||
}
|
||||
}
|
||||
|
||||
if (bStroke)
|
||||
{
|
||||
m_oDocument.WriteString(L"s(c);\n", 6);
|
||||
}
|
||||
}
|
||||
|
||||
void WritePathClip()
|
||||
{
|
||||
m_bIsClipping = true;
|
||||
++m_lClippingPath;
|
||||
}
|
||||
void WritePathClipEnd()
|
||||
{
|
||||
if (!m_bIsClipping)
|
||||
{
|
||||
m_oDocument.WriteString(L"c.save();\n", 10);
|
||||
}
|
||||
m_bIsClipping = true;
|
||||
m_oDocument.WriteString(L"c.clip();\n", 10);
|
||||
}
|
||||
void WritePathResetClip()
|
||||
{
|
||||
if (m_bIsClipping)
|
||||
{
|
||||
m_oDocument.WriteString(L"c.restore();\n", 13);
|
||||
}
|
||||
|
||||
m_bIsClipping = false;
|
||||
}
|
||||
|
||||
inline void WriteStyleClip()
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _ASC_HTMLRENDERER_CANVASWRITER_H_
|
@ -1,304 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef _ASC_HTMLRENDERER_COMMON_H_
|
||||
#define _ASC_HTMLRENDERER_COMMON_H_
|
||||
|
||||
#include "../../DesktopEditor/common/Types.h"
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
#include "../../DesktopEditor/common/Directory.h"
|
||||
#include "../../DesktopEditor/graphics/Matrix.h"
|
||||
#include "../../DesktopEditor/graphics/structures.h"
|
||||
#include "../../DesktopEditor/common/StringBuilder.h"
|
||||
#include "../../DesktopEditor/graphics/IRenderer.h"
|
||||
#include "../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
|
||||
#define SVG_WRITER_SCALE 100
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
class IBaseMatrixUpdater
|
||||
{
|
||||
public:
|
||||
virtual void OnBaseMatrixUpdate(const double& dWidth, const double& dHeight) = 0;
|
||||
};
|
||||
|
||||
class CDstInfo
|
||||
{
|
||||
public:
|
||||
std::wstring m_strDstFilePath;
|
||||
std::wstring m_strAdditionalPath;
|
||||
std::wstring m_strDstMedia;
|
||||
bool m_bIsWeb;
|
||||
|
||||
public:
|
||||
CDstInfo()
|
||||
{
|
||||
m_strDstFilePath = L"";
|
||||
m_strAdditionalPath = L"";
|
||||
m_strDstMedia = L"";
|
||||
m_bIsWeb = false;
|
||||
}
|
||||
CDstInfo(const CDstInfo& oInfo)
|
||||
{
|
||||
*this = oInfo;
|
||||
}
|
||||
CDstInfo& operator=(const CDstInfo& oSrc)
|
||||
{
|
||||
m_strDstFilePath = oSrc.m_strDstFilePath;
|
||||
m_strAdditionalPath = oSrc.m_strAdditionalPath;
|
||||
m_strDstMedia = oSrc.m_strDstMedia;
|
||||
m_bIsWeb = oSrc.m_bIsWeb;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
inline LONG ConvertColor(const LONG& lBGR)
|
||||
{
|
||||
return (0x00FFFFFF & (((lBGR & 0xFF) << 16) | (lBGR & 0x0000FF00) | ((lBGR >> 16) & 0xFF)));
|
||||
}
|
||||
|
||||
inline void WriteIntsToStringBuilder(const int& n1, const int& n2, NSStringUtils::CStringBuilder* pBuilder)
|
||||
{
|
||||
pBuilder->AddSize(21);
|
||||
pBuilder->AddIntNoCheck(n1);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(n2);
|
||||
}
|
||||
inline void WriteIntsToStringBuilder(const int& n1, const int& n2,
|
||||
const int& n3, const int& n4,
|
||||
NSStringUtils::CStringBuilder* pBuilder)
|
||||
{
|
||||
pBuilder->AddSize(65);
|
||||
pBuilder->AddIntNoCheck(n1);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(n2);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(n3);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(n4);
|
||||
}
|
||||
inline void WriteIntsToStringBuilder(const int& n1, const int& n2,
|
||||
const int& n3, const int& n4,
|
||||
const int& n5,
|
||||
NSStringUtils::CStringBuilder* pBuilder)
|
||||
{
|
||||
pBuilder->AddSize(65);
|
||||
pBuilder->AddIntNoCheck(n1);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(n2);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(n3);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(n4);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(n5);
|
||||
}
|
||||
inline void WriteIntsToStringBuilder(const int& n1, const int& n2,
|
||||
const int& n3, const int& n4,
|
||||
const int& n5, const int& n6,
|
||||
NSStringUtils::CStringBuilder* pBuilder)
|
||||
{
|
||||
pBuilder->AddSize(65);
|
||||
pBuilder->AddIntNoCheck(n1);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(n2);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(n3);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(n4);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(n5);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(n6);
|
||||
}
|
||||
|
||||
inline void WriteFormatted(const wchar_t* s1, const int& n1,
|
||||
const wchar_t* s2,
|
||||
NSStringUtils::CStringBuilder* pBuilder)
|
||||
{
|
||||
pBuilder->WriteString(s1, wcslen(s1));
|
||||
pBuilder->AddInt(n1);
|
||||
pBuilder->WriteString(s2, wcslen(s2));
|
||||
}
|
||||
inline void WriteFormatted(const wchar_t* s1, const int& n1,
|
||||
const wchar_t* s2, const int& n2,
|
||||
const wchar_t* s3,
|
||||
NSStringUtils::CStringBuilder* pBuilder)
|
||||
{
|
||||
pBuilder->WriteString(s1, wcslen(s1));
|
||||
pBuilder->AddInt(n1);
|
||||
pBuilder->WriteString(s2, wcslen(s2));
|
||||
pBuilder->AddInt(n2);
|
||||
pBuilder->WriteString(s3, wcslen(s3));
|
||||
}
|
||||
inline void WriteFormatted(const wchar_t* s1, const int& n1,
|
||||
const wchar_t* s2, const int& n2,
|
||||
const wchar_t* s3, const int& n3,
|
||||
const wchar_t* s4,
|
||||
NSStringUtils::CStringBuilder* pBuilder)
|
||||
{
|
||||
pBuilder->WriteString(s1, wcslen(s1));
|
||||
pBuilder->AddInt(n1);
|
||||
pBuilder->WriteString(s2, wcslen(s2));
|
||||
pBuilder->AddInt(n2);
|
||||
pBuilder->WriteString(s3, wcslen(s3));
|
||||
pBuilder->AddInt(n3);
|
||||
pBuilder->WriteString(s4, wcslen(s4));
|
||||
}
|
||||
inline void WriteFormatted(const wchar_t* s1, const int& n1,
|
||||
const wchar_t* s2, const int& n2,
|
||||
const wchar_t* s3, const int& n3,
|
||||
const wchar_t* s4, const int& n4,
|
||||
const wchar_t* s5,
|
||||
NSStringUtils::CStringBuilder* pBuilder)
|
||||
{
|
||||
pBuilder->WriteString(s1, wcslen(s1));
|
||||
pBuilder->AddInt(n1);
|
||||
pBuilder->WriteString(s2, wcslen(s2));
|
||||
pBuilder->AddInt(n2);
|
||||
pBuilder->WriteString(s3, wcslen(s3));
|
||||
pBuilder->AddInt(n3);
|
||||
pBuilder->WriteString(s4, wcslen(s4));
|
||||
pBuilder->AddInt(n4);
|
||||
pBuilder->WriteString(s5, wcslen(s5));
|
||||
}
|
||||
|
||||
inline void SetStringColor(LONG lBGR, NSStringUtils::CStringBuilder* pBuilder)
|
||||
{
|
||||
BYTE R = (BYTE)(lBGR & 0xFF);
|
||||
BYTE G = (BYTE)((lBGR >> 8) & 0xFF);
|
||||
BYTE B = (BYTE)((lBGR >> 16) & 0xFF);
|
||||
|
||||
pBuilder->AddSize(50);
|
||||
pBuilder->WriteString(L"rgb(", 4);
|
||||
pBuilder->AddIntNoCheck(R);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(G);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(B);
|
||||
pBuilder->AddCharSafe(')');
|
||||
}
|
||||
inline void SetStrokeColor(LONG lBGR, LONG lA, NSStringUtils::CStringBuilder* pBuilder)
|
||||
{
|
||||
BYTE R = (BYTE)(lBGR & 0xFF);
|
||||
BYTE G = (BYTE)((lBGR >> 8) & 0xFF);
|
||||
BYTE B = (BYTE)((lBGR >> 16) & 0xFF);
|
||||
|
||||
pBuilder->WriteString(L"c.strokeStyle = \"rgba(", 22);
|
||||
pBuilder->AddSize(70);
|
||||
pBuilder->AddIntNoCheck(R);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(G);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(B);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheckDel100(100 * lA / 255);
|
||||
pBuilder->WriteString(L")\";\n", 4);
|
||||
}
|
||||
inline void SetFillColor(LONG lBGR, LONG lA, NSStringUtils::CStringBuilder* pBuilder)
|
||||
{
|
||||
BYTE R = (BYTE)(lBGR & 0xFF);
|
||||
BYTE G = (BYTE)((lBGR >> 8) & 0xFF);
|
||||
BYTE B = (BYTE)((lBGR >> 16) & 0xFF);
|
||||
|
||||
pBuilder->WriteString(L"c.fillStyle = \"rgba(", 20);
|
||||
pBuilder->AddSize(70);
|
||||
pBuilder->AddIntNoCheck(R);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(G);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheck(B);
|
||||
pBuilder->AddCharNoSafe(',');
|
||||
pBuilder->AddIntNoCheckDel100(100 * lA / 255);
|
||||
pBuilder->WriteString(L")\";\n", 4);
|
||||
}
|
||||
|
||||
struct RECT
|
||||
{
|
||||
LONG left;
|
||||
LONG top;
|
||||
LONG right;
|
||||
LONG bottom;
|
||||
};
|
||||
|
||||
const double c_ag_Inch_to_MM = 25.4;
|
||||
const double c_ag_1pxWidth = 25.4 / 96;
|
||||
|
||||
enum ImageType
|
||||
{
|
||||
itJPG = 0,
|
||||
itPNG = 1
|
||||
};
|
||||
|
||||
class CImageInfo
|
||||
{
|
||||
public:
|
||||
ImageType m_eType;
|
||||
LONG m_lID;
|
||||
|
||||
CImageInfo()
|
||||
{
|
||||
m_eType = itJPG;
|
||||
m_lID = -1;
|
||||
}
|
||||
CImageInfo(const CImageInfo& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
CImageInfo& operator=(const CImageInfo& oSrc)
|
||||
{
|
||||
m_eType = oSrc.m_eType;
|
||||
m_lID = oSrc.m_lID;
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
inline double FABS(double dVal)
|
||||
{
|
||||
return (dVal >= 0) ? dVal : -dVal;
|
||||
}
|
||||
inline int round(double dVal)
|
||||
{
|
||||
return (int)(dVal + 0.5);
|
||||
}
|
||||
inline int round2(double dVal)
|
||||
{
|
||||
// повышаем точность
|
||||
return (int)(SVG_WRITER_SCALE * dVal + 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _ASC_HTMLRENDERER_COMMON_H_
|
@ -1,234 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef _ASC_HTMLRENDERER_COMMON2_H_
|
||||
#define _ASC_HTMLRENDERER_COMMON2_H_
|
||||
|
||||
#include "Common.h"
|
||||
#include "Meta.h"
|
||||
#include "../../DesktopEditor/raster/BgraFrame.h"
|
||||
#include "../../DesktopEditor/xml/include/xmlutils.h"
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
static RECT GetImageBounds(CBgraFrame* pFrame)
|
||||
{
|
||||
BYTE* pBuffer = pFrame->get_Data();
|
||||
LONG lWidth = (LONG)pFrame->get_Width();
|
||||
LONG lHeight = (LONG)pFrame->get_Height();
|
||||
|
||||
RECT rect;
|
||||
rect.left = 0;
|
||||
rect.top = 0;
|
||||
rect.right = lWidth - 1;
|
||||
rect.bottom = lHeight - 1;
|
||||
|
||||
// top
|
||||
unsigned int* pData = (unsigned int*)pBuffer;
|
||||
for (; rect.top < lHeight; rect.top++)
|
||||
{
|
||||
bool bIsBreak = false;
|
||||
for (LONG i = 0; i < lWidth; ++i, ++pData)
|
||||
{
|
||||
if (*pData != 0x00)
|
||||
{
|
||||
bIsBreak = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bIsBreak)
|
||||
break;
|
||||
}
|
||||
if (rect.top >= lHeight)
|
||||
rect.top = (lHeight - 1);
|
||||
|
||||
// bottom
|
||||
for (; rect.bottom >= rect.top; rect.bottom--)
|
||||
{
|
||||
pData = (unsigned int*)pBuffer;
|
||||
pData += (lWidth * rect.bottom);
|
||||
|
||||
bool bIsBreak = false;
|
||||
for (LONG i = 0; i < lWidth; ++i, ++pData)
|
||||
{
|
||||
if (*pData != 0x00)
|
||||
{
|
||||
bIsBreak = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bIsBreak)
|
||||
break;
|
||||
}
|
||||
if (rect.bottom < rect.top)
|
||||
rect.bottom = rect.top;
|
||||
|
||||
LONG lDelta = rect.bottom - rect.top + 1;
|
||||
|
||||
// left
|
||||
for (; rect.left < lWidth; rect.left++)
|
||||
{
|
||||
pData = (unsigned int*)(pBuffer + 4 * lWidth * rect.top);
|
||||
pData += rect.left;
|
||||
|
||||
bool bIsBreak = false;
|
||||
for (LONG i = 0; i < lDelta; ++i, pData += lWidth)
|
||||
{
|
||||
if (*pData != 0x00)
|
||||
{
|
||||
bIsBreak = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bIsBreak)
|
||||
break;
|
||||
}
|
||||
if (rect.left >= lWidth)
|
||||
rect.left = lWidth - 1;
|
||||
|
||||
// right
|
||||
for (; rect.right >= rect.left; rect.right--)
|
||||
{
|
||||
pData = (unsigned int*)(pBuffer + 4 * lWidth * rect.top);
|
||||
pData += rect.right;
|
||||
|
||||
bool bIsBreak = false;
|
||||
for (LONG i = 0; i < lDelta; ++i, pData += lWidth)
|
||||
{
|
||||
if (*pData != 0x00)
|
||||
{
|
||||
bIsBreak = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bIsBreak)
|
||||
break;
|
||||
}
|
||||
if (rect.right < rect.left)
|
||||
rect.right = rect.left;
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
static RECT GetImageBounds2(CBgraFrame* pFrame, BYTE* pCache)
|
||||
{
|
||||
BYTE* pBuffer = pFrame->get_Data();
|
||||
LONG lWidth = (LONG)pFrame->get_Width();
|
||||
LONG lHeight = (LONG)pFrame->get_Height();
|
||||
|
||||
RECT rect;
|
||||
rect.left = 0;
|
||||
rect.top = 0;
|
||||
rect.right = lWidth - 1;
|
||||
rect.bottom = lHeight - 1;
|
||||
|
||||
// top
|
||||
unsigned int** pData = (unsigned int**)pBuffer;
|
||||
unsigned int** pDataSrc = (unsigned int**)pCache;
|
||||
for (; rect.top < lHeight; rect.top++)
|
||||
{
|
||||
if (0 != memcmp((void*)pData, (void*)pDataSrc, 4 * lWidth))
|
||||
break;
|
||||
|
||||
pData += lWidth;
|
||||
pDataSrc += lWidth;
|
||||
}
|
||||
if (rect.top >= lHeight)
|
||||
rect.top = (lHeight - 1);
|
||||
|
||||
// bottom
|
||||
for (; rect.bottom >= rect.top; rect.bottom--)
|
||||
{
|
||||
pData = (unsigned int**)pBuffer;
|
||||
pData += (lWidth * rect.bottom);
|
||||
pDataSrc = (unsigned int**)pCache;
|
||||
pDataSrc += (lWidth * rect.bottom);
|
||||
|
||||
if (0 != memcmp((void*)pData, (void*)pDataSrc, 4 * lWidth))
|
||||
break;
|
||||
}
|
||||
if (rect.bottom < rect.top)
|
||||
rect.bottom = rect.top;
|
||||
|
||||
LONG lDelta = rect.bottom - rect.top + 1;
|
||||
|
||||
// left
|
||||
for (; rect.left < lWidth; rect.left++)
|
||||
{
|
||||
pData = (unsigned int**)(pBuffer + 4 * lWidth * rect.top);
|
||||
pData += rect.left;
|
||||
pDataSrc = (unsigned int**)(pCache + 4 * lWidth * rect.top);
|
||||
pDataSrc += rect.left;
|
||||
|
||||
bool bIsBreak = false;
|
||||
for (LONG i = 0; i < lDelta; ++i, pData += lWidth, pDataSrc += lWidth)
|
||||
{
|
||||
if (*pData != *pDataSrc)
|
||||
{
|
||||
bIsBreak = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bIsBreak)
|
||||
break;
|
||||
}
|
||||
if (rect.left >= lWidth)
|
||||
rect.left = lWidth - 1;
|
||||
|
||||
// right
|
||||
for (; rect.right >= rect.left; rect.right--)
|
||||
{
|
||||
pData = (unsigned int**)(pBuffer + 4 * lWidth * rect.top);
|
||||
pData += rect.right;
|
||||
|
||||
pDataSrc = (unsigned int**)(pCache + 4 * lWidth * rect.top);
|
||||
pDataSrc += rect.right;
|
||||
|
||||
bool bIsBreak = false;
|
||||
for (LONG i = 0; i < lDelta; ++i, pData += lWidth)
|
||||
{
|
||||
if (*pData != *pDataSrc)
|
||||
{
|
||||
bIsBreak = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bIsBreak)
|
||||
break;
|
||||
}
|
||||
if (rect.right < rect.left)
|
||||
rect.right = rect.left;
|
||||
|
||||
return rect;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _ASC_HTMLRENDERER_COMMON2_H_
|
@ -1,859 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef _ASC_HTMLRENDERER_DOCUMENT_H_
|
||||
#define _ASC_HTMLRENDERER_DOCUMENT_H_
|
||||
|
||||
#include "Common.h"
|
||||
#include <vector>
|
||||
#include "../../DesktopEditor/graphics/pro/Graphics.h"
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
class CPageInfo
|
||||
{
|
||||
private:
|
||||
double m_dWidthMM;
|
||||
double m_dHeightMM;
|
||||
|
||||
bool m_bInitW;
|
||||
bool m_bInitH;
|
||||
|
||||
IBaseMatrixUpdater* m_pUpdater;
|
||||
|
||||
public:
|
||||
CPageInfo()
|
||||
{
|
||||
m_dWidthMM = 190;
|
||||
m_dHeightMM = 270;
|
||||
|
||||
m_bInitW = false;
|
||||
m_bInitH = false;
|
||||
|
||||
m_pUpdater = NULL;
|
||||
}
|
||||
CPageInfo(const CPageInfo& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
CPageInfo& operator=(const CPageInfo& oSrc)
|
||||
{
|
||||
m_dWidthMM = oSrc.m_dWidthMM;
|
||||
m_dHeightMM = oSrc.m_dHeightMM;
|
||||
|
||||
m_bInitW = oSrc.m_bInitW;
|
||||
m_bInitH = oSrc.m_bInitH;
|
||||
|
||||
m_pUpdater = oSrc.m_pUpdater;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline double GetWidth()
|
||||
{
|
||||
return m_dWidthMM;
|
||||
}
|
||||
inline double GetHeight()
|
||||
{
|
||||
return m_dHeightMM;
|
||||
}
|
||||
inline void SetWidth(const double& width)
|
||||
{
|
||||
m_dWidthMM = width;
|
||||
m_bInitW = true;
|
||||
|
||||
if (m_bInitH && (NULL != m_pUpdater))
|
||||
{
|
||||
m_pUpdater->OnBaseMatrixUpdate(m_dWidthMM, m_dHeightMM);
|
||||
}
|
||||
}
|
||||
inline void SetHeight(const double& height)
|
||||
{
|
||||
m_dHeightMM = height;
|
||||
m_bInitH = true;
|
||||
|
||||
if (m_bInitW && (NULL != m_pUpdater))
|
||||
{
|
||||
m_pUpdater->OnBaseMatrixUpdate(m_dWidthMM, m_dHeightMM);
|
||||
}
|
||||
}
|
||||
inline void SetUpdater(IBaseMatrixUpdater* pUpdater)
|
||||
{
|
||||
m_pUpdater = pUpdater;
|
||||
}
|
||||
};
|
||||
|
||||
class CDocument
|
||||
{
|
||||
private:
|
||||
|
||||
public:
|
||||
std::vector<CPageInfo> m_arrPages;
|
||||
IBaseMatrixUpdater* m_pUpdater;
|
||||
|
||||
public:
|
||||
CDocument() : m_arrPages()
|
||||
{
|
||||
m_pUpdater = NULL;
|
||||
}
|
||||
inline void SetUpdater(IBaseMatrixUpdater* pUpdater)
|
||||
{
|
||||
m_pUpdater = pUpdater;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
inline void NewPage()
|
||||
{
|
||||
CPageInfo oInfo;
|
||||
oInfo.SetUpdater(m_pUpdater);
|
||||
m_arrPages.push_back(oInfo);
|
||||
}
|
||||
inline void SetWidth(const double& dValue)
|
||||
{
|
||||
size_t nCount = m_arrPages.size();
|
||||
if (nCount > 0)
|
||||
{
|
||||
m_arrPages[nCount - 1].SetWidth(dValue);
|
||||
}
|
||||
}
|
||||
inline void SetHeight(const double& dValue)
|
||||
{
|
||||
size_t nCount = m_arrPages.size();
|
||||
if (nCount > 0)
|
||||
{
|
||||
m_arrPages[nCount - 1].SetHeight(dValue);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
std::wstring GetThumbnailsHTML()
|
||||
{
|
||||
std::wstring strHTML = L"<html>";
|
||||
|
||||
strHTML += GetThumbnailsHeader();
|
||||
strHTML += GetThumbnailsBody();
|
||||
|
||||
strHTML += L"</html>";
|
||||
|
||||
return strHTML;
|
||||
}
|
||||
std::wstring GetViewerHTML()
|
||||
{
|
||||
std::wstring strHTML = L"<html>";
|
||||
|
||||
strHTML += GetViewerHeader();
|
||||
strHTML += GetViewerBody();
|
||||
|
||||
strHTML += L"</html>";
|
||||
|
||||
return strHTML;
|
||||
}
|
||||
|
||||
std::wstring GetThumbnailBlockHTML(int nPageNum)
|
||||
{
|
||||
std::wstring strPage = std::to_wstring(nPageNum);
|
||||
|
||||
std::wstring strResult = L"<div class=\"blockpage\"><div class=\"blockthumbnail\" align=\"center\"><img align=\"center\" src=\"thumbnails\\page" +
|
||||
strPage + L".png\" onClick=\"OnChangePage(" + strPage + L")\" width=\"100%\" height=\"90%\"/>" + L"page" + strPage + L"</div></div>";
|
||||
return strResult;
|
||||
}
|
||||
std::wstring GetThumbnailsBody()
|
||||
{
|
||||
std::wstring strBody = L"<body bgcolor=\"#FEFEFE\">";
|
||||
|
||||
size_t nCount = m_arrPages.size();
|
||||
for (size_t i = 0; i < nCount; ++i)
|
||||
{
|
||||
strBody += GetThumbnailBlockHTML((int)(i + 1));
|
||||
}
|
||||
|
||||
strBody += L"</body>";
|
||||
return strBody;
|
||||
}
|
||||
|
||||
std::wstring GetThumbnailsHeader()
|
||||
{
|
||||
return L"<head>\
|
||||
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></meta>\
|
||||
<title>thumbnails</title>\
|
||||
<style type=\"text/css\">\
|
||||
.blockpage {\
|
||||
width: 80%;\
|
||||
height: 200px;\
|
||||
background: #FEFEFE;\
|
||||
padding: 10px;\
|
||||
float: none;\
|
||||
text-align: center;\
|
||||
}\
|
||||
.blockthumbnail {\
|
||||
width: 100%;\
|
||||
height: 100%;\
|
||||
background: #FEFEFE;\
|
||||
padding: 0px;\
|
||||
float: none;\
|
||||
}\
|
||||
</style>\
|
||||
<script language=\"JavaScript\">\
|
||||
function OnChangePage(pageNum)\
|
||||
{\
|
||||
top.frames['viewer'].OnChangePage(pageNum);\
|
||||
}\
|
||||
</script>\
|
||||
</head>";
|
||||
}
|
||||
|
||||
std::wstring GetViewerHeader()
|
||||
{
|
||||
return L"<head>\
|
||||
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></meta>\
|
||||
<title>viewer</title>\
|
||||
<style type=\"text/css\">\
|
||||
.blockpage {\
|
||||
position: relative;\
|
||||
left: 20%;\
|
||||
width: 60%;\
|
||||
height: 1200px;\
|
||||
background: #FFFFFF;\
|
||||
padding: 10px;\
|
||||
border-style: outset;\
|
||||
border-color: #F0F0F0;\
|
||||
border-width: 2px 3px 3px 2px;\
|
||||
float: none;\
|
||||
text-align: center;\
|
||||
}\
|
||||
.blockpagebetween {\
|
||||
width: 100%;\
|
||||
height: 20px;\
|
||||
background: #FEFEFE;\
|
||||
padding: 0px;\
|
||||
float: none;\
|
||||
text-align: center;\
|
||||
}\
|
||||
.blockpagenatural {\
|
||||
width: 100%;\
|
||||
height: 100%;\
|
||||
background: #FEFEFE;\
|
||||
padding: 0px;\
|
||||
float: none;\
|
||||
}\
|
||||
</style>\
|
||||
<script language=\"JavaScript\">\
|
||||
function OnChangePage(pageNum)\
|
||||
{\
|
||||
var nPage = Number(pageNum);\
|
||||
var position = ((nPage - 1) * 1225 + (nPage - 1) * 20);\
|
||||
scroll(0, position);\
|
||||
}\
|
||||
</script>\
|
||||
</head>";
|
||||
}
|
||||
|
||||
std::wstring GetViewerBlockHTML(int nPageNum)
|
||||
{
|
||||
std::wstring strPage = std::to_wstring(nPageNum);
|
||||
|
||||
std::wstring strResult = L"<div class=\"blockpage\">\n<div class=\"blockpagenatural\" align=\"center\">\n<img align=\"center\" src=\"thumbnails\\page" +
|
||||
strPage + L".png\" onClick=\"OnChangePage(" + strPage + L")\" width=\"100%\" height=\"100%\"/>\n" + L"</div>\n</div>\n" + L"<div class=\"blockpagebetween\"></div>\n";
|
||||
return strResult;
|
||||
}
|
||||
std::wstring GetViewerBody()
|
||||
{
|
||||
std::wstring strBody = L"<body bgcolor=\"#FEFEFE\">";
|
||||
|
||||
size_t nCount = m_arrPages.size();
|
||||
for (size_t i = 0; i < nCount; ++i)
|
||||
{
|
||||
strBody += GetViewerBlockHTML((int)(i + 1));
|
||||
}
|
||||
|
||||
strBody += L"</body>";
|
||||
|
||||
return strBody;
|
||||
}
|
||||
|
||||
std::wstring GetMenuHTML()
|
||||
{
|
||||
return L"<html>\
|
||||
<head>\
|
||||
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></meta>\
|
||||
<title>menu</title>\
|
||||
</head>\
|
||||
<body bgcolor=\"#5F5F5F\">\
|
||||
</body>\
|
||||
</html>";
|
||||
}
|
||||
std::wstring GetDocumentHTML()
|
||||
{
|
||||
return L"<html>\
|
||||
<head>\
|
||||
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></meta>\
|
||||
<title>document viewer</title>\
|
||||
</head>\
|
||||
<frameset rows=\"50,*\" framespacing=\"0\" frameborder=\"0\">\
|
||||
<frame src=\"menu.html\" name=\"menu\" noresize border=\"1\" bordercolor=\"#F0F0F0\" scrolling=\"no\"></frame>\
|
||||
<frameset cols=\"*,200\">\
|
||||
<frame id=\"id_viewer\" src=\"viewer.html\" name=\"viewer\" noresize></frame>\
|
||||
<frame id=\"id_thumbnails\" src=\"thumbnails.html\" name=\"thumbnail\"></frame>\
|
||||
</frameset>\
|
||||
</frameset>\
|
||||
</html>";
|
||||
}
|
||||
|
||||
void CreateDirectories(std::wstring strHTML)
|
||||
{
|
||||
NSDirectory::CreateDirectory(strHTML);
|
||||
NSDirectory::CreateDirectory(strHTML + L"/thumbnails");
|
||||
}
|
||||
|
||||
void CreateHTMLs(std::wstring strHTML)
|
||||
{
|
||||
NSFile::CFileBinary::SaveToFile(strHTML + L"/docviewer.html", GetDocumentHTML(), true);
|
||||
NSFile::CFileBinary::SaveToFile(strHTML + L"/menu.html", GetMenuHTML(), true);
|
||||
NSFile::CFileBinary::SaveToFile(strHTML + L"/viewer.html", GetViewerHTML(), true);
|
||||
NSFile::CFileBinary::SaveToFile(strHTML + L"/thumbnails.html", GetThumbnailsHTML(), true);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class CThumbnails
|
||||
{
|
||||
private:
|
||||
NSGraphics::IGraphicsRenderer* m_pRenderer;
|
||||
CBgraFrame* m_pFrame;
|
||||
|
||||
LONG m_lWidth;
|
||||
LONG m_lHeight;
|
||||
|
||||
public:
|
||||
CThumbnails()
|
||||
{
|
||||
m_pRenderer = NULL;
|
||||
m_pFrame = NULL;
|
||||
m_lWidth = 0;
|
||||
m_lHeight = 0;
|
||||
}
|
||||
~CThumbnails()
|
||||
{
|
||||
RELEASEOBJECT(m_pRenderer);
|
||||
RELEASEOBJECT(m_pFrame);
|
||||
}
|
||||
|
||||
public:
|
||||
void Create(const double& dWidth, const double& dHeight, LONG lSizeMax = 200)
|
||||
{
|
||||
LONG lWidthNew = 0;
|
||||
LONG lHeightNew = 0;
|
||||
|
||||
if (dWidth >= dHeight)
|
||||
{
|
||||
lWidthNew = lSizeMax;
|
||||
lHeightNew = (LONG)((dHeight / dWidth) * lWidthNew);
|
||||
}
|
||||
else
|
||||
{
|
||||
lHeightNew = lSizeMax;
|
||||
lWidthNew = (LONG)((dWidth / dHeight) * lHeightNew);
|
||||
}
|
||||
|
||||
if ((m_lWidth == lWidthNew) && (m_lHeight == lHeightNew) && (NULL != m_pFrame))
|
||||
{
|
||||
// размер не поменялся - значит и память перевыделять не нужно
|
||||
BYTE* pBuffer = m_pFrame->get_Data();
|
||||
memset(pBuffer, 0xFF, 4 * m_lWidth * m_lHeight);
|
||||
|
||||
CreateRenderer();
|
||||
return;
|
||||
}
|
||||
|
||||
RELEASEOBJECT(m_pFrame);
|
||||
m_lWidth = lWidthNew;
|
||||
m_lHeight = lHeightNew;
|
||||
|
||||
CreateMediaData();
|
||||
CreateRenderer();
|
||||
|
||||
m_pRenderer->put_Width(dWidth);
|
||||
m_pRenderer->put_Height(dHeight);
|
||||
}
|
||||
inline void Save(std::wstring& strFile)
|
||||
{
|
||||
SaveFrame(strFile);
|
||||
}
|
||||
|
||||
protected:
|
||||
void CreateMediaData()
|
||||
{
|
||||
RELEASEOBJECT(m_pFrame);
|
||||
|
||||
m_pFrame = new CBgraFrame();
|
||||
m_pFrame->put_Width(m_lWidth);
|
||||
m_pFrame->put_Height(m_lHeight);
|
||||
m_pFrame->put_Stride(4 * m_lWidth);
|
||||
BYTE* pBuffer = new BYTE[4 * m_lWidth * m_lHeight];
|
||||
memset(pBuffer, 0xFF, 4 * m_lWidth * m_lHeight);
|
||||
m_pFrame->put_Data(pBuffer);
|
||||
}
|
||||
void CreateRenderer()
|
||||
{
|
||||
// теперь на всякий случай (сбросить все состояния) - пересоздадим рендерер
|
||||
RELEASEINTERFACE(m_pRenderer);
|
||||
|
||||
m_pRenderer = NSGraphics::Create();
|
||||
m_pRenderer->CreateFromBgraFrame(m_pFrame);
|
||||
}
|
||||
|
||||
void SaveFrame(const std::wstring& strFile)
|
||||
{
|
||||
m_pFrame->SaveFile(strFile, 4);
|
||||
}
|
||||
|
||||
public:
|
||||
inline HRESULT get_Type(LONG* lType)
|
||||
{
|
||||
return m_pRenderer->get_Type(lType);
|
||||
}
|
||||
|
||||
//-------- Функции для работы со страницей --------------------------------------------------
|
||||
inline HRESULT NewPage()
|
||||
{
|
||||
if (NULL == m_pRenderer)
|
||||
return S_OK;
|
||||
|
||||
return m_pRenderer->NewPage();
|
||||
}
|
||||
inline HRESULT get_Height(double* dHeight)
|
||||
{
|
||||
return m_pRenderer->get_Height(dHeight);
|
||||
}
|
||||
inline HRESULT put_Height(const double& dHeight)
|
||||
{
|
||||
if (NULL == m_pRenderer)
|
||||
return S_OK;
|
||||
|
||||
return m_pRenderer->put_Height(dHeight);
|
||||
}
|
||||
inline HRESULT get_Width(double* dWidth)
|
||||
{
|
||||
return m_pRenderer->get_Width(dWidth);
|
||||
}
|
||||
inline HRESULT put_Width(const double& dWidth)
|
||||
{
|
||||
if (NULL == m_pRenderer)
|
||||
return S_OK;
|
||||
|
||||
return m_pRenderer->put_Width(dWidth);
|
||||
}
|
||||
inline HRESULT get_DpiX(double* dDpiX)
|
||||
{
|
||||
return m_pRenderer->get_DpiX(dDpiX);
|
||||
}
|
||||
inline HRESULT get_DpiY(double* dDpiY)
|
||||
{
|
||||
return m_pRenderer->get_DpiY(dDpiY);
|
||||
}
|
||||
|
||||
// pen --------------------------------------------------------------------------------------
|
||||
inline HRESULT get_PenColor(LONG* lColor)
|
||||
{
|
||||
return m_pRenderer->get_PenColor(lColor);
|
||||
}
|
||||
inline HRESULT put_PenColor(const LONG& lColor)
|
||||
{
|
||||
return m_pRenderer->put_PenColor(lColor);
|
||||
}
|
||||
inline HRESULT get_PenAlpha(LONG* lAlpha)
|
||||
{
|
||||
return m_pRenderer->get_PenAlpha(lAlpha);
|
||||
}
|
||||
inline HRESULT put_PenAlpha(const LONG& lAlpha)
|
||||
{
|
||||
return m_pRenderer->put_PenAlpha(lAlpha);
|
||||
}
|
||||
inline HRESULT get_PenSize(double* dSize)
|
||||
{
|
||||
return m_pRenderer->get_PenSize(dSize);
|
||||
}
|
||||
inline HRESULT put_PenSize(const double& dSize)
|
||||
{
|
||||
return m_pRenderer->put_PenSize(dSize);
|
||||
}
|
||||
inline HRESULT get_PenDashStyle(BYTE* val)
|
||||
{
|
||||
return m_pRenderer->get_PenDashStyle(val);
|
||||
}
|
||||
inline HRESULT put_PenDashStyle(const BYTE& val)
|
||||
{
|
||||
return m_pRenderer->put_PenDashStyle(val);
|
||||
}
|
||||
inline HRESULT get_PenLineStartCap(BYTE* val)
|
||||
{
|
||||
return m_pRenderer->get_PenLineStartCap(val);
|
||||
}
|
||||
inline HRESULT put_PenLineStartCap(const BYTE& val)
|
||||
{
|
||||
return m_pRenderer->put_PenLineStartCap(val);
|
||||
}
|
||||
inline HRESULT get_PenLineEndCap(BYTE* val)
|
||||
{
|
||||
return m_pRenderer->get_PenLineEndCap(val);
|
||||
}
|
||||
inline HRESULT put_PenLineEndCap(const BYTE& val)
|
||||
{
|
||||
return m_pRenderer->put_PenLineEndCap(val);
|
||||
}
|
||||
inline HRESULT get_PenLineJoin(BYTE* val)
|
||||
{
|
||||
return m_pRenderer->get_PenLineJoin(val);
|
||||
}
|
||||
inline HRESULT put_PenLineJoin(const BYTE& val)
|
||||
{
|
||||
return m_pRenderer->put_PenLineJoin(val);
|
||||
}
|
||||
inline HRESULT get_PenDashOffset(double* val)
|
||||
{
|
||||
return m_pRenderer->get_PenDashOffset(val);
|
||||
}
|
||||
inline HRESULT put_PenDashOffset(const double& val)
|
||||
{
|
||||
return m_pRenderer->put_PenDashOffset(val);
|
||||
}
|
||||
inline HRESULT get_PenAlign(LONG* val)
|
||||
{
|
||||
return m_pRenderer->get_PenAlign(val);
|
||||
}
|
||||
inline HRESULT put_PenAlign(const LONG& val)
|
||||
{
|
||||
return m_pRenderer->put_PenAlign(val);
|
||||
}
|
||||
inline HRESULT get_PenMiterLimit(double* val)
|
||||
{
|
||||
return m_pRenderer->get_PenMiterLimit(val);
|
||||
}
|
||||
inline HRESULT put_PenMiterLimit(const double& val)
|
||||
{
|
||||
return m_pRenderer->put_PenMiterLimit(val);
|
||||
}
|
||||
inline HRESULT PenDashPattern(double* pPattern, LONG lCount)
|
||||
{
|
||||
return m_pRenderer->PenDashPattern(pPattern, lCount);
|
||||
}
|
||||
|
||||
// brush ------------------------------------------------------------------------------------
|
||||
inline HRESULT get_BrushType(LONG* lType)
|
||||
{
|
||||
return m_pRenderer->get_BrushType(lType);
|
||||
}
|
||||
inline HRESULT put_BrushType(const LONG& lType)
|
||||
{
|
||||
return m_pRenderer->put_BrushType(lType);
|
||||
}
|
||||
inline HRESULT get_BrushColor1(LONG* lColor)
|
||||
{
|
||||
return m_pRenderer->get_BrushColor1(lColor);
|
||||
}
|
||||
inline HRESULT put_BrushColor1(const LONG& lColor)
|
||||
{
|
||||
return m_pRenderer->put_BrushColor1(lColor);
|
||||
}
|
||||
inline HRESULT get_BrushAlpha1(LONG* lAlpha)
|
||||
{
|
||||
return m_pRenderer->get_BrushAlpha1(lAlpha);
|
||||
}
|
||||
inline HRESULT put_BrushAlpha1(const LONG& lAlpha)
|
||||
{
|
||||
return m_pRenderer->put_BrushAlpha1(lAlpha);
|
||||
}
|
||||
inline HRESULT get_BrushColor2(LONG* lColor)
|
||||
{
|
||||
return m_pRenderer->get_BrushColor2(lColor);
|
||||
}
|
||||
inline HRESULT put_BrushColor2(const LONG& lColor)
|
||||
{
|
||||
return m_pRenderer->put_BrushColor2(lColor);
|
||||
}
|
||||
inline HRESULT get_BrushAlpha2(LONG* lAlpha)
|
||||
{
|
||||
return m_pRenderer->get_BrushAlpha2(lAlpha);
|
||||
}
|
||||
inline HRESULT put_BrushAlpha2(const LONG& lAlpha)
|
||||
{
|
||||
return m_pRenderer->put_BrushAlpha2(lAlpha);
|
||||
}
|
||||
inline HRESULT get_BrushTexturePath(std::wstring* sPath)
|
||||
{
|
||||
return m_pRenderer->get_BrushTexturePath(sPath);
|
||||
}
|
||||
inline HRESULT put_BrushTexturePath(const std::wstring& bsPath)
|
||||
{
|
||||
return m_pRenderer->put_BrushTexturePath(bsPath);
|
||||
}
|
||||
inline HRESULT get_BrushTextureMode(LONG* lMode)
|
||||
{
|
||||
return m_pRenderer->get_BrushTextureMode(lMode);
|
||||
}
|
||||
inline HRESULT put_BrushTextureMode(const LONG& lMode)
|
||||
{
|
||||
return m_pRenderer->put_BrushTextureMode(lMode);
|
||||
}
|
||||
inline HRESULT get_BrushTextureAlpha(LONG* lTxAlpha)
|
||||
{
|
||||
return m_pRenderer->get_BrushTextureAlpha(lTxAlpha);
|
||||
}
|
||||
inline HRESULT put_BrushTextureAlpha(const LONG lTxAlpha)
|
||||
{
|
||||
return m_pRenderer->put_BrushTextureAlpha(lTxAlpha);
|
||||
}
|
||||
inline HRESULT get_BrushLinearAngle(double* dAngle)
|
||||
{
|
||||
return m_pRenderer->get_BrushLinearAngle(dAngle);
|
||||
}
|
||||
inline HRESULT put_BrushLinearAngle(const double& dAngle)
|
||||
{
|
||||
return m_pRenderer->put_BrushLinearAngle(dAngle);
|
||||
}
|
||||
inline HRESULT BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height)
|
||||
{
|
||||
return m_pRenderer->BrushRect(val, left, top, width, height);
|
||||
}
|
||||
|
||||
inline HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height)
|
||||
{
|
||||
return m_pRenderer->BrushBounds(left, top, width, height);
|
||||
}
|
||||
|
||||
inline HRESULT put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount)
|
||||
{
|
||||
return m_pRenderer->put_BrushGradientColors(lColors, pPositions, nCount);
|
||||
}
|
||||
|
||||
// font -------------------------------------------------------------------------------------
|
||||
inline HRESULT get_FontName(std::wstring* bsName)
|
||||
{
|
||||
return m_pRenderer->get_FontName(bsName);
|
||||
}
|
||||
inline HRESULT put_FontName(const std::wstring& bsName)
|
||||
{
|
||||
return m_pRenderer->put_FontName(bsName);
|
||||
}
|
||||
inline HRESULT get_FontPath(std::wstring* bsName)
|
||||
{
|
||||
return m_pRenderer->get_FontPath(bsName);
|
||||
}
|
||||
inline HRESULT put_FontPath(const std::wstring& bsName)
|
||||
{
|
||||
return m_pRenderer->put_FontPath(bsName);
|
||||
}
|
||||
inline HRESULT get_FontSize(double* dSize)
|
||||
{
|
||||
return m_pRenderer->get_FontSize(dSize);
|
||||
}
|
||||
inline HRESULT put_FontSize(const double& dSize)
|
||||
{
|
||||
return m_pRenderer->put_FontSize(dSize);
|
||||
}
|
||||
inline HRESULT get_FontStyle(LONG* lStyle)
|
||||
{
|
||||
return m_pRenderer->get_FontStyle(lStyle);
|
||||
}
|
||||
inline HRESULT put_FontStyle(const LONG& lStyle)
|
||||
{
|
||||
return m_pRenderer->put_FontStyle(lStyle);
|
||||
}
|
||||
inline HRESULT get_FontStringGID(INT* bGID)
|
||||
{
|
||||
return m_pRenderer->get_FontStringGID(bGID);
|
||||
}
|
||||
inline HRESULT put_FontStringGID(const INT& bGID)
|
||||
{
|
||||
return m_pRenderer->put_FontStringGID(bGID);
|
||||
}
|
||||
inline HRESULT get_FontCharSpace(double* dSpace)
|
||||
{
|
||||
return m_pRenderer->get_FontCharSpace(dSpace);
|
||||
}
|
||||
inline HRESULT put_FontCharSpace(const double& dSpace)
|
||||
{
|
||||
return m_pRenderer->put_FontCharSpace(dSpace);
|
||||
}
|
||||
inline HRESULT get_FontFaceIndex(int* lFaceIndex)
|
||||
{
|
||||
return m_pRenderer->get_FontFaceIndex(lFaceIndex);
|
||||
}
|
||||
inline HRESULT put_FontFaceIndex(const int& lFaceIndex)
|
||||
{
|
||||
return m_pRenderer->put_FontFaceIndex(lFaceIndex);
|
||||
}
|
||||
|
||||
//-------- Функции для вывода текста --------------------------------------------------------
|
||||
virtual HRESULT CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
return m_pRenderer->CommandDrawTextCHAR(c, x, y, w, h);
|
||||
}
|
||||
virtual HRESULT CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
return m_pRenderer->CommandDrawText(bsText, x, y, w, h);
|
||||
}
|
||||
virtual HRESULT CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
return m_pRenderer->CommandDrawTextExCHAR(c, gid, x, y, w, h);
|
||||
}
|
||||
virtual HRESULT CommandDrawTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
return m_pRenderer->CommandDrawTextEx(bsUnicodeText, pGids, nGidsCount, x, y, w, h);
|
||||
}
|
||||
|
||||
|
||||
//-------- Маркеры для команд ---------------------------------------------------------------
|
||||
inline HRESULT BeginCommand(const DWORD& lType)
|
||||
{
|
||||
return m_pRenderer->BeginCommand(lType);
|
||||
}
|
||||
inline HRESULT EndCommand(const DWORD& lType)
|
||||
{
|
||||
return m_pRenderer->EndCommand(lType);
|
||||
}
|
||||
|
||||
//-------- Функции для работы с Graphics Path -----------------------------------------------
|
||||
inline HRESULT PathCommandMoveTo(const double& fX, const double& fY)
|
||||
{
|
||||
return m_pRenderer->PathCommandMoveTo(fX, fY);
|
||||
}
|
||||
inline HRESULT PathCommandLineTo(const double& fX, const double& fY)
|
||||
{
|
||||
return m_pRenderer->PathCommandLineTo(fX, fY);
|
||||
}
|
||||
inline HRESULT PathCommandLinesTo(double* points, const int& count)
|
||||
{
|
||||
return m_pRenderer->PathCommandLinesTo(points, count);
|
||||
}
|
||||
inline HRESULT PathCommandCurveTo(const double& fX1, const double& fY1, const double& fX2, const double& fY2, const double& fX3, const double& fY3)
|
||||
{
|
||||
return m_pRenderer->PathCommandCurveTo(fX1, fY1, fX2, fY2, fX3, fY3);
|
||||
}
|
||||
inline HRESULT PathCommandCurvesTo(double* points, const int& count)
|
||||
{
|
||||
return m_pRenderer->PathCommandCurvesTo(points, count);
|
||||
}
|
||||
inline HRESULT PathCommandArcTo(const double& fX, const double& fY, const double& fWidth, const double& fHeight, const double& fStartAngle, const double& fSweepAngle)
|
||||
{
|
||||
return m_pRenderer->PathCommandArcTo(fX, fY, fWidth, fHeight, fStartAngle, fSweepAngle);
|
||||
}
|
||||
inline HRESULT PathCommandClose()
|
||||
{
|
||||
return m_pRenderer->PathCommandClose();
|
||||
}
|
||||
inline HRESULT PathCommandEnd()
|
||||
{
|
||||
return m_pRenderer->PathCommandEnd();
|
||||
}
|
||||
inline HRESULT DrawPath(const LONG& nType)
|
||||
{
|
||||
return m_pRenderer->DrawPath(nType);
|
||||
}
|
||||
inline HRESULT PathCommandStart()
|
||||
{
|
||||
return m_pRenderer->PathCommandStart();
|
||||
}
|
||||
inline HRESULT PathCommandGetCurrentPoint(double* fX, double* fY)
|
||||
{
|
||||
return m_pRenderer->PathCommandGetCurrentPoint(fX, fY);
|
||||
}
|
||||
|
||||
inline HRESULT PathCommandTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
return m_pRenderer->PathCommandTextCHAR(c, x, y, w, h);
|
||||
}
|
||||
inline HRESULT PathCommandText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
return m_pRenderer->PathCommandText(bsText, x, y, w, h);
|
||||
}
|
||||
inline HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
return m_pRenderer->PathCommandTextExCHAR(c, gid, x, y, w, h);
|
||||
}
|
||||
inline HRESULT PathCommandTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
return m_pRenderer->PathCommandTextEx(bsUnicodeText, pGids, nGidsCount, x, y, w, h);
|
||||
}
|
||||
|
||||
//-------- Функции для вывода изображений ---------------------------------------------------
|
||||
inline HRESULT DrawImage(IGrObject* pInterface, const double& fX, const double& fY, const double& fWidth, const double& fHeight)
|
||||
{
|
||||
return m_pRenderer->DrawImage(pInterface, fX, fY, fWidth, fHeight);
|
||||
}
|
||||
inline HRESULT DrawImageFromFile(const std::wstring& sPath, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha = 255)
|
||||
{
|
||||
return m_pRenderer->DrawImageFromFile(sPath, x, y, w, h, lAlpha);
|
||||
}
|
||||
|
||||
// transform --------------------------------------------------------------------------------
|
||||
inline HRESULT SetTransform(const double& dA, const double& dB, const double& dC, const double& dD, const double& dE, const double& dF)
|
||||
{
|
||||
return m_pRenderer->SetTransform(dA, dB, dC, dD, dE, dF);
|
||||
}
|
||||
inline HRESULT GetTransform(double *pdA, double *pdB, double *pdC, double *pdD, double *pdE, double *pdF)
|
||||
{
|
||||
return m_pRenderer->GetTransform(pdA, pdB, pdC, pdD, pdE, pdF);
|
||||
}
|
||||
inline HRESULT ResetTransform(void)
|
||||
{
|
||||
return m_pRenderer->ResetTransform();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------
|
||||
inline HRESULT get_ClipMode(LONG* plMode)
|
||||
{
|
||||
return m_pRenderer->get_ClipMode(plMode);
|
||||
}
|
||||
inline HRESULT put_ClipMode(const LONG& lMode)
|
||||
{
|
||||
return m_pRenderer->put_ClipMode(lMode);
|
||||
}
|
||||
|
||||
// additiaonal params ----------------------------------------------------------------------
|
||||
inline HRESULT CommandLong(const LONG& lType, const LONG& lCommand)
|
||||
{
|
||||
return m_pRenderer->CommandLong(lType, lCommand);
|
||||
}
|
||||
inline HRESULT CommandDouble(const LONG& lType, const double& dCommand)
|
||||
{
|
||||
return m_pRenderer->CommandDouble(lType, dCommand);
|
||||
}
|
||||
inline HRESULT CommandString(const LONG& lType, const std::wstring& sCommand)
|
||||
{
|
||||
return m_pRenderer->CommandString(lType, sCommand);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _ASC_HTMLRENDERER_DOCUMENT_H_
|
@ -1,120 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef _ASC_HTMLRENDERER_FM_H_
|
||||
#define _ASC_HTMLRENDERER_FM_H_
|
||||
|
||||
#include "FontManagerBase.h"
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
using namespace NSFontManager;
|
||||
|
||||
const long g_lNewNoJustifySpace = 5;
|
||||
|
||||
class CFontManager : public CFontManagerBase
|
||||
{
|
||||
public:
|
||||
NSStructures::CFont* m_pFont;
|
||||
Aggplus::CMatrix* m_pTransform;
|
||||
|
||||
double m_dSpaceWidthMM;
|
||||
|
||||
public:
|
||||
CFontManager() : m_pFont(NULL), CFontManagerBase()
|
||||
{
|
||||
m_pTransform = NULL;
|
||||
m_dSpaceWidthMM = 0;
|
||||
}
|
||||
virtual ~CFontManager()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void LoadFont(long lFaceIndex = 0, bool bIsNeedAddToMap = true)
|
||||
{
|
||||
if (NULL == m_pManager)
|
||||
return;
|
||||
|
||||
double dSize = m_pFont->Size;
|
||||
double dSizeFont = dSize * ((m_pTransform->sx() + m_pTransform->sy()) / 2);
|
||||
|
||||
m_pFont->Size = dSizeFont;
|
||||
|
||||
if (IsEqual2(m_pFont, &m_oFont.m_oFont))
|
||||
{
|
||||
m_pFont->Size = dSize;
|
||||
return;
|
||||
}
|
||||
|
||||
m_oFont.m_oFont = *m_pFont;
|
||||
m_pFont->Size = dSize;
|
||||
|
||||
bool bIsPath = false;
|
||||
|
||||
if (L"" == m_pFont->Path)
|
||||
{
|
||||
CFontManagerBase::LoadFontByName(m_oFont.m_oFont.Name, m_oFont.m_oFont.Size, m_oFont.m_oFont.GetStyle());
|
||||
}
|
||||
else
|
||||
{
|
||||
CFontManagerBase::LoadFontByFile(m_oFont.m_oFont.Path, m_oFont.m_oFont.Size, lFaceIndex);
|
||||
|
||||
m_pFont->SetStyle(m_oFont.m_oProperties.m_lStyle);
|
||||
m_oFont.m_oFont.SetStyle(m_oFont.m_oProperties.m_lStyle);
|
||||
|
||||
bIsPath = true;
|
||||
}
|
||||
|
||||
CalculateSpace();
|
||||
}
|
||||
|
||||
inline void CalculateSpace()
|
||||
{
|
||||
LONG lGid = m_pManager->GetStringGID();
|
||||
m_pManager->SetStringGID(FALSE);
|
||||
|
||||
m_pManager->LoadString1(L" ", 0, 0);
|
||||
|
||||
TBBox _box = m_pManager->MeasureString2();
|
||||
|
||||
m_dSpaceWidthMM = (double)(_box.fMaxX - _box.fMinX) * c_dPixToMM;
|
||||
if (0 >= m_dSpaceWidthMM)
|
||||
{
|
||||
m_dSpaceWidthMM = 1.0;
|
||||
}
|
||||
|
||||
m_pManager->SetStringGID(lGid);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _ASC_HTMLRENDERER_FM_H_
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,551 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#include "../include/HTMLRendererText.h"
|
||||
#include "./Text.h"
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
class CHTMLRendererText_Private
|
||||
{
|
||||
public:
|
||||
double m_dWidth;
|
||||
double m_dHeght;
|
||||
|
||||
NSStructures::CBrush m_oBrush;
|
||||
NSStructures::CBrush m_oLastBrush;
|
||||
|
||||
NSStructures::CFont m_oFont;
|
||||
NSStructures::CFont* m_pFont;
|
||||
NSStructures::CFont m_oInstalledFont;
|
||||
LONG m_lCurrentFont;
|
||||
double m_dCurrentFontSize;
|
||||
|
||||
Aggplus::CMatrix m_oTransform;
|
||||
Aggplus::CMatrix m_oLastTransform;
|
||||
|
||||
bool m_bIsChangedFontParamBetweenDrawText;
|
||||
LONG m_lCurrentCommandType;
|
||||
LONG m_lSrcFileType;
|
||||
|
||||
CHText m_oSmartText;
|
||||
CMetafile m_oPage;
|
||||
|
||||
int* m_pTempUnicodes;
|
||||
int m_nTempUnicodesAlloc;
|
||||
int m_nTempUnicodesLen;
|
||||
|
||||
bool m_bIsFontsInit;
|
||||
|
||||
public:
|
||||
CHTMLRendererText_Private()
|
||||
{
|
||||
m_bIsChangedFontParamBetweenDrawText = true;
|
||||
m_lSrcFileType = 0;
|
||||
m_pTempUnicodes = NULL;
|
||||
m_nTempUnicodesLen = 0;
|
||||
m_nTempUnicodesAlloc = 0;
|
||||
|
||||
m_bIsFontsInit = false;
|
||||
|
||||
m_lCurrentFont = 0;
|
||||
m_dCurrentFontSize = 0;
|
||||
m_pFont = &m_oFont;
|
||||
}
|
||||
~CHTMLRendererText_Private()
|
||||
{
|
||||
RELEASEARRAYOBJECTS(m_pTempUnicodes);
|
||||
}
|
||||
|
||||
public:
|
||||
void GetUnicodes(const std::wstring& sText)
|
||||
{
|
||||
int nLen = (int)sText.length();
|
||||
if (nLen > m_nTempUnicodesAlloc)
|
||||
{
|
||||
RELEASEARRAYOBJECTS(m_pTempUnicodes);
|
||||
m_nTempUnicodesAlloc = nLen;
|
||||
m_pTempUnicodes = new int[m_nTempUnicodesAlloc];
|
||||
}
|
||||
|
||||
m_nTempUnicodesLen = 0;
|
||||
const wchar_t* pWchars = sText.c_str();
|
||||
|
||||
if (sizeof(wchar_t) == 2)
|
||||
{
|
||||
for (int nIndex = 0, nGlyphIndex = 0; nIndex < nLen; ++nIndex, ++nGlyphIndex)
|
||||
{
|
||||
int code = (int)pWchars[nIndex];
|
||||
if (code >= 0xD800 && code <= 0xDFFF && (nIndex + 1) < nLen)
|
||||
{
|
||||
++nIndex;
|
||||
code = 0x10000 + (((code & 0x3FF) << 10) | (0x03FF & pWchars[nIndex]));
|
||||
}
|
||||
|
||||
m_pTempUnicodes[m_nTempUnicodesLen++] = code;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int nIndex = 0; nIndex < nLen; ++nIndex )
|
||||
{
|
||||
m_pTempUnicodes[m_nTempUnicodesLen++] = (int)pWchars[nIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WriteText(const int* pUnicodes, const int* pGids, const int& nCount, const double& x, const double& y,
|
||||
const double& width, const double& height, const bool& bIsChangedFontParamBetweenDrawText)
|
||||
{
|
||||
bool bIsDumpFont = false;
|
||||
if (!m_oInstalledFont.IsEqual(&m_oFont))
|
||||
{
|
||||
m_oInstalledFont = m_oFont;
|
||||
bIsDumpFont = true;
|
||||
|
||||
m_dCurrentFontSize = m_oInstalledFont.Size;
|
||||
}
|
||||
|
||||
m_oSmartText.CommandText(pUnicodes, pGids, nCount, x, y, width, height, bIsDumpFont, this);
|
||||
}
|
||||
};
|
||||
|
||||
CHTMLRendererText::CHTMLRendererText()
|
||||
{
|
||||
m_pInternal = new CHTMLRendererText_Private();
|
||||
}
|
||||
CHTMLRendererText::~CHTMLRendererText()
|
||||
{
|
||||
RELEASEOBJECT(m_pInternal);
|
||||
}
|
||||
|
||||
void CHTMLRendererText::Init(IOfficeDrawingFile* pFile, int nCacheSize)
|
||||
{
|
||||
m_pInternal->m_oBrush.SetDefaultParams();
|
||||
m_pInternal->m_oLastBrush.SetDefaultParams();
|
||||
|
||||
m_pInternal->m_oFont.SetDefaultParams();
|
||||
m_pInternal->m_oInstalledFont.SetDefaultParams();
|
||||
m_pInternal->m_oInstalledFont.Name = L"";
|
||||
|
||||
m_pInternal->m_oTransform.Reset();
|
||||
m_pInternal->m_oLastTransform.Reset();
|
||||
|
||||
m_pInternal->m_oLastBrush.Color1 = -1;
|
||||
m_pInternal->m_dCurrentFontSize = 0.0;
|
||||
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = false;
|
||||
m_pInternal->m_lCurrentCommandType = -1;
|
||||
|
||||
m_pInternal->m_oSmartText.NewPage();
|
||||
|
||||
if (!m_pInternal->m_bIsFontsInit)
|
||||
{
|
||||
m_pInternal->m_oSmartText.m_oFontManager.m_pFont = &m_pInternal->m_oFont;
|
||||
|
||||
m_pInternal->m_oSmartText.m_pLastBrush = &m_pInternal->m_oLastBrush;
|
||||
m_pInternal->m_oSmartText.m_pBrush = &m_pInternal->m_oBrush;
|
||||
|
||||
m_pInternal->m_oSmartText.m_pFont = &m_pInternal->m_oFont;
|
||||
|
||||
m_pInternal->m_oSmartText.m_pTransform = &m_pInternal->m_oTransform;
|
||||
m_pInternal->m_oSmartText.m_pLastTransform = &m_pInternal->m_oLastTransform;
|
||||
|
||||
m_pInternal->m_oSmartText.m_pPageMeta = &m_pInternal->m_oPage;
|
||||
|
||||
OfficeDrawingFileType eType = pFile->GetType();
|
||||
switch (eType)
|
||||
{
|
||||
case odftPDF:
|
||||
{
|
||||
m_pInternal->m_lSrcFileType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF;
|
||||
m_pInternal->m_oSmartText.m_dTextSpaceEps = 0.1;
|
||||
break;
|
||||
}
|
||||
case odftDJVU:
|
||||
{
|
||||
m_pInternal->m_lSrcFileType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU;
|
||||
m_pInternal->m_oSmartText.m_dTextSpaceEps = 0.1;
|
||||
break;
|
||||
}
|
||||
case odftXPS:
|
||||
{
|
||||
m_pInternal->m_lSrcFileType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS;
|
||||
m_pInternal->m_oSmartText.m_dTextSpaceEps = 0.1;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_pInternal->m_bIsFontsInit = true;
|
||||
m_pInternal->m_oSmartText.Init(pFile->GetFonts(), nCacheSize);
|
||||
}
|
||||
|
||||
m_pInternal->m_oPage.ClearNoAttack();
|
||||
m_pInternal->m_oPage.WriteLONG(0);
|
||||
|
||||
// статистика
|
||||
m_pInternal->m_oPage.WriteLONG(0);
|
||||
m_pInternal->m_oPage.WriteLONG(0);
|
||||
m_pInternal->m_oPage.WriteLONG(0);
|
||||
m_pInternal->m_oPage.WriteLONG(0);
|
||||
|
||||
}
|
||||
|
||||
BYTE* CHTMLRendererText::GetBuffer()
|
||||
{
|
||||
m_pInternal->m_oSmartText.ClosePage();
|
||||
LONG lPos = m_pInternal->m_oPage.GetPosition();
|
||||
m_pInternal->m_oPage.Seek(0);
|
||||
// len
|
||||
m_pInternal->m_oPage.WriteLONG(lPos);
|
||||
// stat
|
||||
m_pInternal->m_oPage.WriteLONG(m_pInternal->m_oSmartText.m_lCountParagraphs);
|
||||
m_pInternal->m_oPage.WriteLONG(m_pInternal->m_oSmartText.m_lCountWords);
|
||||
m_pInternal->m_oPage.WriteLONG(m_pInternal->m_oSmartText.m_lCountSymbols);
|
||||
m_pInternal->m_oPage.WriteLONG(m_pInternal->m_oSmartText.m_lCountSpaces);
|
||||
// seek to end
|
||||
m_pInternal->m_oPage.Seek(lPos);
|
||||
|
||||
m_pInternal->m_oSmartText.ClearStatistics();
|
||||
return m_pInternal->m_oPage.GetData();
|
||||
}
|
||||
|
||||
HRESULT CHTMLRendererText::get_Type(LONG* lType)
|
||||
{
|
||||
*lType = c_nHtmlRendrererText;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
//-------- Функции для работы со страницей --------------------------------------------------
|
||||
HRESULT CHTMLRendererText::NewPage()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_Height(double* dHeight)
|
||||
{
|
||||
*dHeight = m_pInternal->m_dHeght;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::put_Height(const double& dHeight)
|
||||
{
|
||||
m_pInternal->m_dHeght = dHeight;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_Width(double* dWidth)
|
||||
{
|
||||
*dWidth = m_pInternal->m_dWidth;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::put_Width(const double& dWidth)
|
||||
{
|
||||
m_pInternal->m_dWidth = dWidth;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_DpiX(double* dDpiX)
|
||||
{
|
||||
*dDpiX = 96;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_DpiY(double* dDpiY)
|
||||
{
|
||||
*dDpiY = 96;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// pen --------------------------------------------------------------------------------------
|
||||
HRESULT CHTMLRendererText::get_PenColor(LONG* lColor) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_PenColor(const LONG& lColor) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_PenAlpha(LONG* lAlpha) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_PenAlpha(const LONG& lAlpha) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_PenSize(double* dSize) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_PenSize(const double& dSize) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_PenDashStyle(BYTE* val) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_PenDashStyle(const BYTE& val) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_PenLineStartCap(BYTE* val) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_PenLineStartCap(const BYTE& val) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_PenLineEndCap(BYTE* val) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_PenLineEndCap(const BYTE& val) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_PenLineJoin(BYTE* val) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_PenLineJoin(const BYTE& val) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_PenDashOffset(double* dOffset) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_PenDashOffset(const double& dOffset) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_PenAlign(LONG* lAlign) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_PenAlign(const LONG& lAlign) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_PenMiterLimit(double* dOffset) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_PenMiterLimit(const double& dOffset) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::PenDashPattern(double* pPattern, LONG lCount) { return S_OK; }
|
||||
|
||||
HRESULT CHTMLRendererText::get_BrushTextureImage(Aggplus::CImage** pImage) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_BrushTextureImage(Aggplus::CImage* pImage) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_BrushTransform(Aggplus::CMatrix& oMatrix) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_BrushTransform(const Aggplus::CMatrix& oMatrix) { return S_OK; }
|
||||
|
||||
// brush ------------------------------------------------------------------------------------
|
||||
HRESULT CHTMLRendererText::get_BrushType(LONG* lType)
|
||||
{
|
||||
*lType = m_pInternal->m_oBrush.Type;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::put_BrushType(const LONG& lType)
|
||||
{
|
||||
m_pInternal->m_oBrush.Type = lType;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_BrushColor1(LONG* lColor)
|
||||
{
|
||||
*lColor = m_pInternal->m_oBrush.Color1;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::put_BrushColor1(const LONG& lColor)
|
||||
{
|
||||
m_pInternal->m_oBrush.Color1 = lColor;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_BrushAlpha1(LONG* lAlpha)
|
||||
{
|
||||
*lAlpha = m_pInternal->m_oBrush.Alpha1;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::put_BrushAlpha1(const LONG& lAlpha)
|
||||
{
|
||||
m_pInternal->m_oBrush.Alpha1 = lAlpha;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_BrushColor2(LONG* lColor) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_BrushColor2(const LONG& lColor) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_BrushAlpha2(LONG* lAlpha) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_BrushAlpha2(const LONG& lAlpha) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_BrushTexturePath(std::wstring* bsPath) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_BrushTexturePath(const std::wstring& bsPath) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_BrushTextureMode(LONG* lMode) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_BrushTextureMode(const LONG& lMode) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_BrushTextureAlpha(LONG* lTxAlpha) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_BrushTextureAlpha(const LONG& lTxAlpha) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_BrushLinearAngle(double* dAngle) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_BrushLinearAngle(const double& dAngle) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::BrushBounds(const double& left, const double& top, const double& width, const double& height) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount) { return S_OK; }
|
||||
|
||||
// font -------------------------------------------------------------------------------------
|
||||
HRESULT CHTMLRendererText::get_FontName(std::wstring* bsName)
|
||||
{
|
||||
*bsName = m_pInternal->m_oFont.Name;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::put_FontName(const std::wstring& bsName)
|
||||
{
|
||||
m_pInternal->m_oFont.Name = bsName;
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = true;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_FontPath(std::wstring* bsName)
|
||||
{
|
||||
*bsName = m_pInternal->m_oFont.Path;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::put_FontPath(const std::wstring& bsName)
|
||||
{
|
||||
m_pInternal->m_oFont.Path = bsName;
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = true;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_FontSize(double* dSize)
|
||||
{
|
||||
*dSize = m_pInternal->m_oFont.Size;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::put_FontSize(const double& dSize)
|
||||
{
|
||||
if (m_pInternal->m_oFont.Size != dSize)
|
||||
{
|
||||
m_pInternal->m_oFont.Size = dSize;
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = true;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_FontStyle(LONG* lStyle)
|
||||
{
|
||||
*lStyle = m_pInternal->m_oFont.GetStyle();
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::put_FontStyle(const LONG& lStyle)
|
||||
{
|
||||
LONG lOld = m_pInternal->m_oFont.GetStyle();
|
||||
if (lOld != lStyle)
|
||||
{
|
||||
m_pInternal->m_oFont.SetStyle(lStyle);
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = true;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_FontStringGID(INT* bGID)
|
||||
{
|
||||
*bGID = m_pInternal->m_oFont.StringGID;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::put_FontStringGID(const INT& bGID)
|
||||
{
|
||||
m_pInternal->m_oFont.StringGID = bGID;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_FontCharSpace(double* dSpace)
|
||||
{
|
||||
*dSpace = m_pInternal->m_oFont.CharSpace;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::put_FontCharSpace(const double& dSpace)
|
||||
{
|
||||
m_pInternal->m_oFont.CharSpace = dSpace;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_FontFaceIndex(int* lFaceIndex)
|
||||
{
|
||||
*lFaceIndex = m_pInternal->m_oFont.FaceIndex;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::put_FontFaceIndex(const int& lFaceIndex)
|
||||
{
|
||||
m_pInternal->m_oFont.FaceIndex = lFaceIndex;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
//-------- Функции для вывода текста --------------------------------------------------------
|
||||
HRESULT CHTMLRendererText::CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
if (c_nHyperlinkType == m_pInternal->m_lCurrentCommandType)
|
||||
return S_OK;
|
||||
|
||||
int _c = (int)c;
|
||||
m_pInternal->WriteText(&_c, NULL, 1, x, y, w, h, m_pInternal->m_bIsChangedFontParamBetweenDrawText);
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = false;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
if (c_nHyperlinkType == m_pInternal->m_lCurrentCommandType)
|
||||
return S_OK;
|
||||
|
||||
m_pInternal->GetUnicodes(bsText);
|
||||
m_pInternal->WriteText(m_pInternal->m_pTempUnicodes, NULL, m_pInternal->m_nTempUnicodesLen, x, y, w, h, m_pInternal->m_bIsChangedFontParamBetweenDrawText);
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = false;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
if (c_nHyperlinkType == m_pInternal->m_lCurrentCommandType)
|
||||
return S_OK;
|
||||
|
||||
int _c = (int)c;
|
||||
int _g = (int)gid;
|
||||
|
||||
m_pInternal->WriteText(&_c, &_g, 1, x, y, w, h, m_pInternal->m_bIsChangedFontParamBetweenDrawText);
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = false;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::CommandDrawTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
if (c_nHyperlinkType == m_pInternal->m_lCurrentCommandType)
|
||||
return S_OK;
|
||||
|
||||
m_pInternal->GetUnicodes(bsUnicodeText);
|
||||
m_pInternal->WriteText(m_pInternal->m_pTempUnicodes, (const int*)pGids, m_pInternal->m_nTempUnicodesLen, x, y, w, h, m_pInternal->m_bIsChangedFontParamBetweenDrawText);
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = false;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
//-------- Маркеры для команд ---------------------------------------------------------------
|
||||
HRESULT CHTMLRendererText::BeginCommand(const DWORD& lType)
|
||||
{
|
||||
m_pInternal->m_lCurrentCommandType = lType;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::EndCommand(const DWORD& lType)
|
||||
{
|
||||
m_pInternal->m_lCurrentCommandType = -1;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
//-------- Функции для работы с Graphics Path -----------------------------------------------
|
||||
HRESULT CHTMLRendererText::PathCommandMoveTo(const double& x, const double& y) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::PathCommandLineTo(const double& x, const double& y) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::PathCommandLinesTo(double* points, const int& count) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::PathCommandCurveTo(const double& x1, const double& y1, const double& x2, const double& y2, const double& x3, const double& y3) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::PathCommandCurvesTo(double* points, const int& count) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::PathCommandArcTo(const double& x, const double& y, const double& w, const double& h, const double& startAngle, const double& sweepAngle) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::PathCommandClose() { return S_OK; }
|
||||
HRESULT CHTMLRendererText::PathCommandEnd() { return S_OK; }
|
||||
HRESULT CHTMLRendererText::DrawPath(const LONG& nType) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::PathCommandStart() { return S_OK; }
|
||||
HRESULT CHTMLRendererText::PathCommandGetCurrentPoint(double* x, double* y) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::PathCommandTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::PathCommandText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::PathCommandTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) { return S_OK; }
|
||||
|
||||
//-------- Функции для вывода изображений ---------------------------------------------------
|
||||
HRESULT CHTMLRendererText::DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h) { return S_OK; }
|
||||
|
||||
HRESULT CHTMLRendererText::DrawImageFromFile(const std::wstring& sPath, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha) { return S_OK; }
|
||||
|
||||
// transform --------------------------------------------------------------------------------
|
||||
HRESULT CHTMLRendererText::SetTransform(const double& m1, const double& m2, const double& m3, const double& m4, const double& m5, const double& m6)
|
||||
{
|
||||
m_pInternal->m_oTransform.SetElements(m1, m2, m3, m4, m5, m6);
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::GetTransform(double *pdA, double *pdB, double *pdC, double *pdD, double *pdE, double *pdF)
|
||||
{
|
||||
*pdA = m_pInternal->m_oTransform.sx();
|
||||
*pdB = m_pInternal->m_oTransform.shy();
|
||||
*pdC = m_pInternal->m_oTransform.shx();
|
||||
*pdD = m_pInternal->m_oTransform.sy();
|
||||
*pdE = m_pInternal->m_oTransform.tx();
|
||||
*pdF = m_pInternal->m_oTransform.ty();
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::ResetTransform()
|
||||
{
|
||||
m_pInternal->m_oTransform.Reset();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------
|
||||
HRESULT CHTMLRendererText::get_ClipMode(LONG* plMode) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_ClipMode(const LONG& lMode) { return S_OK; }
|
||||
|
||||
// additiaonal params ----------------------------------------------------------------------
|
||||
HRESULT CHTMLRendererText::CommandLong(const LONG& lType, const LONG& lCommand) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::CommandDouble(const LONG& lType, const double& dCommand) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::CommandString(const LONG& lType, const std::wstring& sCommand) { return S_OK; }
|
||||
}
|
@ -1,492 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef _ASC_HTMLRENDERER_META_H_
|
||||
#define _ASC_HTMLRENDERER_META_H_
|
||||
|
||||
#include "../../DesktopEditor/common/Types.h"
|
||||
#include "../../DesktopEditor/graphics/Matrix.h"
|
||||
#include <memory>
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
inline bool IsEqualMain(const Aggplus::CMatrix* pMatrix, const Aggplus::CMatrix* pMatrix2)
|
||||
{
|
||||
return Aggplus::CMatrix::IsEqual(pMatrix, pMatrix2, 0.001, true);
|
||||
}
|
||||
|
||||
class CMetafile
|
||||
{
|
||||
public:
|
||||
enum CommandType
|
||||
{
|
||||
// pen
|
||||
ctPenXML = 0,
|
||||
ctPenColor = 1,
|
||||
ctPenAlpha = 2,
|
||||
ctPenSize = 3,
|
||||
ctPenDashStyle = 4,
|
||||
ctPenLineStartCap = 5,
|
||||
ctPenLineEndCap = 6,
|
||||
ctPenLineJoin = 7,
|
||||
ctPenDashPatern = 8,
|
||||
ctPenDashPatternCount = 9,
|
||||
ctPenDashOffset = 10,
|
||||
ctPenAlign = 11,
|
||||
ctPenMiterLimit = 12,
|
||||
|
||||
// brush
|
||||
ctBrushXML = 20,
|
||||
ctBrushType = 21,
|
||||
ctBrushColor1 = 22,
|
||||
ctBrushColor2 = 23,
|
||||
ctBrushAlpha1 = 24,
|
||||
ctBrushAlpha2 = 25,
|
||||
ctBrushTexturePath = 26,
|
||||
ctBrushTextureAlpha = 27,
|
||||
ctBrushTextureMode = 28,
|
||||
ctBrushRectable = 29,
|
||||
ctBrushAngle = 30,
|
||||
ctBrushSubColors = 31,
|
||||
|
||||
// font
|
||||
ctFontXML = 40,
|
||||
ctFontName = 41,
|
||||
ctFontSize = 42,
|
||||
ctFontStyle = 43,
|
||||
ctFontPath = 44,
|
||||
ctFontGID = 45,
|
||||
ctFontCharSpace = 46,
|
||||
|
||||
// shadow
|
||||
ctShadowXML = 50,
|
||||
ctShadowVisible = 51,
|
||||
ctShadowDistanceX = 52,
|
||||
ctShadowDistanceY = 53,
|
||||
ctShadowBlurSize = 54,
|
||||
ctShadowColor = 55,
|
||||
ctShadowAlpha = 56,
|
||||
|
||||
// edge
|
||||
ctEdgeXML = 70,
|
||||
ctEdgeVisible = 71,
|
||||
ctEdgeDistance = 72,
|
||||
ctEdgeColor = 73,
|
||||
ctEdgeAlpha = 74,
|
||||
|
||||
// text
|
||||
ctDrawText = 80,
|
||||
ctDrawTextEx = 81,
|
||||
|
||||
// pathcommands
|
||||
ctPathCommandMoveTo = 91,
|
||||
ctPathCommandLineTo = 92,
|
||||
ctPathCommandLinesTo = 93,
|
||||
ctPathCommandCurveTo = 94,
|
||||
ctPathCommandCurvesTo = 95,
|
||||
ctPathCommandArcTo = 96,
|
||||
ctPathCommandClose = 97,
|
||||
ctPathCommandEnd = 98,
|
||||
ctDrawPath = 99,
|
||||
ctPathCommandStart = 100,
|
||||
ctPathCommandGetCurrentPoint = 101,
|
||||
ctPathCommandText = 102,
|
||||
ctPathCommandTextEx = 103,
|
||||
|
||||
// image
|
||||
ctDrawImage = 110,
|
||||
ctDrawImageFromFile = 111,
|
||||
|
||||
ctSetParams = 120,
|
||||
|
||||
ctBeginCommand = 121,
|
||||
ctEndCommand = 122,
|
||||
|
||||
ctSetTransform = 130,
|
||||
ctResetTransform = 131,
|
||||
|
||||
ctClipMode = 140,
|
||||
|
||||
ctCommandLong1 = 150,
|
||||
ctCommandDouble1 = 151,
|
||||
ctCommandString1 = 152,
|
||||
ctCommandLong2 = 153,
|
||||
ctCommandDouble2 = 154,
|
||||
ctCommandString2 = 155,
|
||||
|
||||
ctCommandTextLine = 160,
|
||||
ctCommandTextTransform = 161,
|
||||
ctCommandTextLineEnd = 162,
|
||||
|
||||
ctCommandTextClipRectReset = 163,
|
||||
ctCommandTextClipRect = 164,
|
||||
|
||||
ctError = 255
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
// сам метафайл
|
||||
BYTE* m_pBuffer;
|
||||
BYTE* m_pBufferMem;
|
||||
|
||||
size_t m_lPosition;
|
||||
size_t m_lSize;
|
||||
|
||||
LONG m_lSizeofDouble;
|
||||
LONG m_lSizeofFloat;
|
||||
LONG m_lSizeofLONG;
|
||||
LONG m_lSizeofBYTE;
|
||||
|
||||
public:
|
||||
double m_fWidth;
|
||||
double m_fHeight;
|
||||
|
||||
public:
|
||||
CMetafile()
|
||||
{
|
||||
Clear();
|
||||
|
||||
m_lSizeofDouble = sizeof(double);
|
||||
m_lSizeofFloat = sizeof(float);
|
||||
m_lSizeofLONG = sizeof(int);
|
||||
m_lSizeofBYTE = sizeof(BYTE);
|
||||
}
|
||||
~CMetafile()
|
||||
{
|
||||
RELEASEARRAYOBJECTS(m_pBuffer);
|
||||
}
|
||||
|
||||
public:
|
||||
template<typename T>
|
||||
inline void write_value(const T& value)
|
||||
{
|
||||
#if 0
|
||||
printf("write (%d): %d, %d\n", sizeof(T), (int)value, (int)m_lPosition);
|
||||
#endif
|
||||
//*((T*)(m_pBuffer + m_lPosition)) = value;
|
||||
memcpy(m_pBuffer + m_lPosition, &value, sizeof(T));
|
||||
m_lPosition += sizeof(T);
|
||||
}
|
||||
|
||||
public:
|
||||
inline LONG GetPosition()
|
||||
{
|
||||
return (LONG)m_lPosition;
|
||||
}
|
||||
inline BYTE* GetData()
|
||||
{
|
||||
return m_pBuffer;
|
||||
}
|
||||
inline void ClearNoAttack()
|
||||
{
|
||||
m_lPosition = 0;
|
||||
m_pBufferMem = m_pBuffer;
|
||||
}
|
||||
|
||||
inline void Clear()
|
||||
{
|
||||
m_lSize = 0;
|
||||
m_lPosition = 0;
|
||||
|
||||
m_pBuffer = NULL;
|
||||
m_pBufferMem = NULL;
|
||||
}
|
||||
inline void Seek(LONG lPos)
|
||||
{
|
||||
m_lPosition = (size_t)lPos;
|
||||
m_pBufferMem = m_pBuffer + m_lPosition;
|
||||
}
|
||||
|
||||
inline void CheckBufferSize(size_t lPlus)
|
||||
{
|
||||
if (NULL != m_pBuffer)
|
||||
{
|
||||
size_t nNewSize = m_lPosition + lPlus;
|
||||
|
||||
if (nNewSize >= m_lSize)
|
||||
{
|
||||
while (nNewSize >= m_lSize)
|
||||
{
|
||||
m_lSize *= 2;
|
||||
}
|
||||
|
||||
BYTE* pNew = new BYTE[m_lSize];
|
||||
memcpy(pNew, m_pBuffer, m_lPosition);
|
||||
|
||||
RELEASEARRAYOBJECTS(m_pBuffer);
|
||||
m_pBuffer = pNew;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lSize = 1000;
|
||||
m_pBuffer = new BYTE[m_lSize];
|
||||
|
||||
CheckBufferSize(lPlus);
|
||||
}
|
||||
}
|
||||
|
||||
inline void WriteCommandType(const CommandType& eType)
|
||||
{
|
||||
CheckBufferSize(m_lSizeofBYTE);
|
||||
|
||||
*(m_pBuffer + m_lPosition) = (BYTE)eType;
|
||||
m_lPosition += m_lSizeofBYTE;
|
||||
}
|
||||
|
||||
//
|
||||
inline void WriteBYTE_nocheck(const BYTE& lValue)
|
||||
{
|
||||
*(m_pBuffer + m_lPosition) = lValue;
|
||||
m_lPosition += m_lSizeofBYTE;
|
||||
}
|
||||
inline void WriteLONG_nocheck(const int& lValue)
|
||||
{
|
||||
write_value(lValue);
|
||||
}
|
||||
inline void WriteUSHORT_nocheck(const USHORT& lValue)
|
||||
{
|
||||
write_value(lValue);
|
||||
}
|
||||
inline void WriteWCHAR_nocheck(const WCHAR& lValue)
|
||||
{
|
||||
write_value(lValue);
|
||||
}
|
||||
inline void WriteWCHAR_nocheck2(const int& lValue)
|
||||
{
|
||||
if (lValue < 0x10000)
|
||||
{
|
||||
write_value((USHORT)lValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
int code = lValue - 0x10000;
|
||||
write_value((USHORT)(0xD800 | ((code >> 10) & 0x03FF)));
|
||||
write_value((USHORT)(0xDC00 | (code & 0x03FF)));
|
||||
}
|
||||
}
|
||||
inline void WriteDouble_nocheck(const double& dValue)
|
||||
{
|
||||
// здесь никаких даблов. Сплошные округления
|
||||
LONG lValue = (LONG)(dValue * 10000);
|
||||
WriteLONG_nocheck(lValue);
|
||||
}
|
||||
inline void WriteDouble2_nocheck(const double& dValue)
|
||||
{
|
||||
write_value((SHORT)(dValue * 100));
|
||||
}
|
||||
//
|
||||
inline void WriteBYTE(const BYTE& lValue)
|
||||
{
|
||||
CheckBufferSize(m_lSizeofBYTE);
|
||||
|
||||
m_pBuffer[m_lPosition] = lValue;
|
||||
m_lPosition += m_lSizeofBYTE;
|
||||
}
|
||||
inline void WriteLONG(const int& lValue)
|
||||
{
|
||||
CheckBufferSize(m_lSizeofLONG);
|
||||
write_value(lValue);
|
||||
}
|
||||
inline void WriteUSHORT(const USHORT& lValue)
|
||||
{
|
||||
CheckBufferSize(sizeof(USHORT));
|
||||
write_value(lValue);
|
||||
|
||||
}
|
||||
inline void WriteWCHAR(const WCHAR& lValue)
|
||||
{
|
||||
CheckBufferSize(sizeof(WCHAR));
|
||||
write_value(lValue);
|
||||
}
|
||||
inline void WriteDouble(const double& dValue)
|
||||
{
|
||||
// здесь никаких даблов. Сплошные округления
|
||||
int lValue = (int)(dValue * 10000);
|
||||
WriteLONG(lValue);
|
||||
return;
|
||||
|
||||
CheckBufferSize(m_lSizeofDouble);
|
||||
|
||||
*((double*)(m_pBuffer + m_lPosition)) = dValue;
|
||||
m_lPosition += m_lSizeofDouble;
|
||||
}
|
||||
inline void WriteDouble2(const double& dValue)
|
||||
{
|
||||
CheckBufferSize(sizeof(SHORT));
|
||||
write_value((SHORT)(dValue * 100));
|
||||
}
|
||||
inline void WriteFloat(const float& fValue)
|
||||
{
|
||||
CheckBufferSize(m_lSizeofFloat);
|
||||
write_value(fValue);
|
||||
}
|
||||
inline void WriteString(wchar_t* bstrValue)
|
||||
{
|
||||
int lSize = (int)wcslen(bstrValue) + 1;
|
||||
|
||||
int lSizeMem = lSize * sizeof(wchar_t);
|
||||
|
||||
CheckBufferSize(m_lSizeofLONG + lSizeMem);
|
||||
write_value(lSizeMem);
|
||||
|
||||
memcpy(m_pBuffer + m_lPosition, bstrValue, lSizeMem);
|
||||
m_lPosition += lSizeMem;
|
||||
}
|
||||
|
||||
inline void WriteBYTE(const CommandType& eType, const BYTE& lValue)
|
||||
{
|
||||
CheckBufferSize(2 * m_lSizeofBYTE);
|
||||
|
||||
*(m_pBuffer + m_lPosition) = (BYTE)eType;
|
||||
m_lPosition += m_lSizeofBYTE;
|
||||
|
||||
*(m_pBuffer + m_lPosition) = lValue;
|
||||
m_lPosition += m_lSizeofBYTE;
|
||||
}
|
||||
inline void WriteLONG(const CommandType& eType, const int& lValue)
|
||||
{
|
||||
CheckBufferSize(m_lSizeofBYTE + m_lSizeofLONG);
|
||||
|
||||
*(m_pBuffer + m_lPosition) = (BYTE)eType;
|
||||
m_lPosition += m_lSizeofBYTE;
|
||||
|
||||
write_value(lValue);
|
||||
}
|
||||
inline void WriteDouble(const CommandType& eType, const double& dValue)
|
||||
{
|
||||
CheckBufferSize(m_lSizeofBYTE + m_lSizeofDouble);
|
||||
|
||||
*(m_pBuffer + m_lPosition) = (BYTE)eType;
|
||||
m_lPosition += m_lSizeofBYTE;
|
||||
|
||||
write_value(dValue);
|
||||
}
|
||||
inline void WriteFloat(const CommandType& eType, const float& fValue)
|
||||
{
|
||||
CheckBufferSize(m_lSizeofBYTE + m_lSizeofFloat);
|
||||
|
||||
*(m_pBuffer + m_lPosition) = (BYTE)eType;
|
||||
m_lPosition += m_lSizeofBYTE;
|
||||
|
||||
write_value(fValue);
|
||||
}
|
||||
inline void WriteString(const CommandType& eType, wchar_t* bstrValue)
|
||||
{
|
||||
int lSize = (int)wcslen(bstrValue) + 1;
|
||||
|
||||
int lSizeMem = lSize * sizeof(wchar_t);
|
||||
|
||||
CheckBufferSize(m_lSizeofBYTE + m_lSizeofLONG + lSizeMem);
|
||||
|
||||
*(m_pBuffer + m_lPosition) = (BYTE)eType;
|
||||
m_lPosition += m_lSizeofBYTE;
|
||||
|
||||
write_value(lSizeMem);
|
||||
|
||||
memcpy(m_pBuffer + m_lPosition, bstrValue, lSizeMem);
|
||||
m_lPosition += lSizeMem;
|
||||
}
|
||||
|
||||
inline void Write(const BYTE* pData, const LONG& lLen)
|
||||
{
|
||||
CheckBufferSize((size_t)lLen);
|
||||
memcpy(m_pBuffer + m_lPosition, pData, lLen);
|
||||
m_lPosition += lLen;
|
||||
}
|
||||
|
||||
inline void Write(const CommandType& eCommand, const double& f1, const double& f2)
|
||||
{
|
||||
size_t lMem = m_lSizeofBYTE + 2 * m_lSizeofDouble;
|
||||
|
||||
CheckBufferSize(lMem);
|
||||
|
||||
*(m_pBuffer + m_lPosition) = (BYTE)eCommand; m_lPosition += m_lSizeofBYTE;
|
||||
write_value(f1);
|
||||
write_value(f2);
|
||||
}
|
||||
|
||||
inline void Write(const CommandType& eCommand, const double& f1, const double& f2, const double& f3, const double& f4, const double& f5, const double& f6)
|
||||
{
|
||||
size_t lMem = m_lSizeofBYTE + 6 * m_lSizeofDouble;
|
||||
|
||||
CheckBufferSize(lMem);
|
||||
|
||||
*(m_pBuffer + m_lPosition) = (BYTE)eCommand; m_lPosition += m_lSizeofBYTE;
|
||||
|
||||
write_value(f1);
|
||||
write_value(f2);
|
||||
write_value(f3);
|
||||
write_value(f4);
|
||||
write_value(f5);
|
||||
write_value(f6);
|
||||
}
|
||||
|
||||
inline void Write(const CommandType& eCommand, const int& lCount, float* pData)
|
||||
{
|
||||
size_t lFloats = lCount * m_lSizeofFloat;
|
||||
size_t lMem = m_lSizeofBYTE + m_lSizeofLONG + lFloats;
|
||||
|
||||
CheckBufferSize(lMem);
|
||||
|
||||
*(m_pBuffer + m_lPosition) = (BYTE)eCommand; m_lPosition += m_lSizeofBYTE;
|
||||
write_value(lCount);
|
||||
|
||||
memcpy(m_pBuffer + m_lPosition, pData, lFloats);
|
||||
m_lPosition += lFloats;
|
||||
}
|
||||
inline void Write(const CommandType& eCommand, const int& lCount, double* pData)
|
||||
{
|
||||
size_t lFloats = lCount * m_lSizeofDouble;
|
||||
size_t lMem = m_lSizeofBYTE + m_lSizeofLONG + lFloats;
|
||||
|
||||
CheckBufferSize(lMem);
|
||||
|
||||
*(m_pBuffer + m_lPosition) = (BYTE)eCommand; m_lPosition += m_lSizeofBYTE;
|
||||
write_value(lCount);
|
||||
|
||||
memcpy(m_pBuffer + m_lPosition, pData, lFloats);
|
||||
m_lPosition += lFloats;
|
||||
}
|
||||
|
||||
inline void Write(CMetafile& oMeta)
|
||||
{
|
||||
LONG lPos = oMeta.GetPosition();
|
||||
CheckBufferSize(lPos);
|
||||
|
||||
memcpy(m_pBuffer + m_lPosition, oMeta.GetData(), lPos);
|
||||
m_lPosition += lPos;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _ASC_HTMLRENDERER_META_H_
|
@ -1,853 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef _ASC_HTMLRENDERER_SVGWRITER_H_
|
||||
#define _ASC_HTMLRENDERER_SVGWRITER_H_
|
||||
|
||||
#include "Common.h"
|
||||
#include <vector>
|
||||
#include <math.h>
|
||||
#include "../../DesktopEditor/graphics/GraphicsPath.h"
|
||||
#include "../../DesktopEditor/graphics/pro/Graphics.h"
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
class CClipSVG
|
||||
{
|
||||
public:
|
||||
std::vector<std::wstring> m_arPaths;
|
||||
std::vector<LONG> m_arTypes;
|
||||
|
||||
LONG m_lWidth;
|
||||
LONG m_lHeight;
|
||||
|
||||
CClipSVG() : m_arPaths(), m_arTypes()
|
||||
{
|
||||
m_lWidth = 0;
|
||||
m_lHeight = 0;
|
||||
}
|
||||
~CClipSVG()
|
||||
{
|
||||
}
|
||||
|
||||
void Write(NSStringUtils::CStringBuilder& oWriter, LONG& lCurrentClipPath)
|
||||
{
|
||||
// сначала запишем все пути
|
||||
size_t nCount = m_arPaths.size();
|
||||
|
||||
for (size_t i = 0; i < nCount; ++i)
|
||||
{
|
||||
oWriter.WriteString(L"<clipPath id=\"clip", 18);
|
||||
oWriter.AddInt(lCurrentClipPath);
|
||||
oWriter.WriteString(L"\"><path id=\"path", 16);
|
||||
oWriter.AddInt(lCurrentClipPath);
|
||||
oWriter.WriteString(L"\" d=\"", 5);
|
||||
|
||||
oWriter.WriteString(m_arPaths[i]);
|
||||
|
||||
if (c_nClipRegionTypeWinding == m_arTypes[i])
|
||||
oWriter.WriteString(L"\" clip-rule=\"nonzero\" /></clipPath>", 35);
|
||||
else
|
||||
oWriter.WriteString(L"\" clip-rule=\"evenodd\" /></clipPath>", 35);
|
||||
|
||||
++lCurrentClipPath;
|
||||
}
|
||||
|
||||
LONG lWritePathID = (LONG)lCurrentClipPath - 2;
|
||||
// теперь запишем пересечения
|
||||
for (size_t i = 1; i < nCount; ++i)
|
||||
{
|
||||
oWriter.WriteString(L"<clipPath id=\"clip", 18);
|
||||
oWriter.AddInt(lCurrentClipPath);
|
||||
oWriter.WriteString(L"\" clip-path=\"url(#clip", 22);
|
||||
oWriter.AddInt(lCurrentClipPath - 1);
|
||||
WriteFormatted(L")\"><use x=\"0\" y=\"0\" width=\"", (int)m_lWidth, L"\" height=\"", (int)m_lHeight, L"\" xlink:href=\"#path", (int)lWritePathID, L"\"/></clipPath>", &oWriter);
|
||||
|
||||
++lCurrentClipPath;
|
||||
--lWritePathID;
|
||||
}
|
||||
}
|
||||
|
||||
void Write2(NSStringUtils::CStringBuilder& oWriter, LONG& lCurrentClipPath)
|
||||
{
|
||||
// сначала запишем все пути
|
||||
size_t nCount = m_arPaths.size();
|
||||
double dMemoryClipTypes = 0;
|
||||
for (size_t i = 0; i < nCount; ++i)
|
||||
{
|
||||
dMemoryClipTypes += m_arTypes[i];
|
||||
}
|
||||
dMemoryClipTypes /= nCount;
|
||||
if (0 != dMemoryClipTypes && 1 != dMemoryClipTypes)
|
||||
return Write(oWriter, lCurrentClipPath);
|
||||
|
||||
oWriter.WriteString(L"<clipPath id=\"clip", 18);
|
||||
oWriter.AddInt(lCurrentClipPath);
|
||||
oWriter.WriteString(L"\"><path id=\"path", 16);
|
||||
oWriter.AddInt(lCurrentClipPath);
|
||||
oWriter.WriteString(L"\" d=\"", 5);
|
||||
|
||||
for (size_t i = 0; i < nCount; ++i)
|
||||
{
|
||||
oWriter.WriteString(m_arPaths[i]);
|
||||
}
|
||||
|
||||
if (dMemoryClipTypes == 0)
|
||||
oWriter.WriteString(L"\" clip-rule=\"nonzero\" /></clipPath>", 35);
|
||||
else
|
||||
oWriter.WriteString(L"\" clip-rule=\"evenodd\" /></clipPath>", 35);
|
||||
|
||||
++lCurrentClipPath;
|
||||
}
|
||||
|
||||
inline void Clear()
|
||||
{
|
||||
m_arPaths.clear();
|
||||
m_arTypes.clear();
|
||||
}
|
||||
inline bool IsInit()
|
||||
{
|
||||
return (0 != m_arPaths.size());
|
||||
}
|
||||
};
|
||||
|
||||
class CClipSVG2
|
||||
{
|
||||
public:
|
||||
std::vector<std::wstring> m_arPaths;
|
||||
std::vector<LONG> m_arTypes;
|
||||
|
||||
LONG m_lWidth;
|
||||
LONG m_lHeight;
|
||||
|
||||
LONG m_lCountWriteClips;
|
||||
|
||||
CClipSVG2() : m_arPaths(), m_arTypes()
|
||||
{
|
||||
m_lWidth = 0;
|
||||
m_lHeight = 0;
|
||||
|
||||
m_lCountWriteClips = 0;
|
||||
}
|
||||
~CClipSVG2()
|
||||
{
|
||||
}
|
||||
|
||||
void Write(NSStringUtils::CStringBuilder& oWriter, LONG& lCurrentClipPath)
|
||||
{
|
||||
// сначала запишем все пути
|
||||
size_t nCount = m_arPaths.size();
|
||||
|
||||
LONG lOld = lCurrentClipPath;
|
||||
for (size_t i = 0; i < nCount; ++i)
|
||||
{
|
||||
oWriter.WriteString(L"<clipPath id=\"clip", 18);
|
||||
oWriter.AddInt(lCurrentClipPath);
|
||||
oWriter.WriteString(L"\"><path id=\"path", 16);
|
||||
oWriter.AddInt(lCurrentClipPath);
|
||||
oWriter.WriteString(L"\" d=\"", 5);
|
||||
|
||||
oWriter.WriteString(m_arPaths[i]);
|
||||
|
||||
if (c_nClipRegionTypeWinding == m_arTypes[i])
|
||||
oWriter.WriteString(L"\" clip-rule=\"nonzero\" /></clipPath>", 35);
|
||||
else
|
||||
oWriter.WriteString(L"\" clip-rule=\"evenodd\" /></clipPath>", 35);
|
||||
|
||||
++lCurrentClipPath;
|
||||
}
|
||||
|
||||
m_lCountWriteClips = (LONG)nCount;
|
||||
|
||||
for (LONG i = 0; i < m_lCountWriteClips; i++)
|
||||
{
|
||||
oWriter.WriteString(L"<g clip-path=\"url(#clip", 23);
|
||||
oWriter.AddInt(lOld++);
|
||||
oWriter.WriteString(L")\">", 3);
|
||||
}
|
||||
}
|
||||
|
||||
void WriteEnd(NSStringUtils::CStringBuilder& oWriter)
|
||||
{
|
||||
while (m_lCountWriteClips > 0)
|
||||
{
|
||||
oWriter.WriteString(L"</g>\n", 5);
|
||||
--m_lCountWriteClips;
|
||||
}
|
||||
}
|
||||
|
||||
inline void Clear()
|
||||
{
|
||||
m_arPaths.clear();
|
||||
m_arTypes.clear();
|
||||
}
|
||||
inline bool IsInit()
|
||||
{
|
||||
return (0 != m_arPaths.size());
|
||||
}
|
||||
};
|
||||
|
||||
class CSVGWriter
|
||||
{
|
||||
public:
|
||||
NSStringUtils::CStringBuilder m_oPath;
|
||||
NSStringUtils::CStringBuilder m_oDocument;
|
||||
|
||||
LONG m_lCurDocumentID;
|
||||
LONG m_lClippingPath;
|
||||
LONG m_lPatternID;
|
||||
|
||||
bool m_bIsClipping;
|
||||
bool m_bIsNeedUpdateClip;
|
||||
LONG m_lClipMode;
|
||||
|
||||
NSStructures::CPen* m_pPen;
|
||||
NSStructures::CBrush* m_pBrush;
|
||||
|
||||
int m_lWidth;
|
||||
int m_lHeight;
|
||||
|
||||
double m_dDpiX;
|
||||
double m_dDpiY;
|
||||
|
||||
CClipSVG m_oClip;
|
||||
|
||||
public:
|
||||
CSVGWriter() : m_oPath(), m_oDocument()
|
||||
{
|
||||
m_lCurDocumentID = 0;
|
||||
m_lClippingPath = 0;
|
||||
m_lPatternID = 0;
|
||||
|
||||
m_pPen = NULL;
|
||||
m_pBrush = NULL;
|
||||
|
||||
m_dDpiX = 96;
|
||||
m_dDpiY = 96;
|
||||
|
||||
m_lClipMode = c_nClipRegionTypeWinding;
|
||||
|
||||
m_bIsClipping = false;
|
||||
m_bIsNeedUpdateClip = false;
|
||||
}
|
||||
|
||||
void ReInit()
|
||||
{
|
||||
m_oClip.Clear();
|
||||
m_oPath.ClearNoAttack();
|
||||
m_oDocument.ClearNoAttack();
|
||||
|
||||
m_lCurDocumentID = 0;
|
||||
m_lClippingPath = 0;
|
||||
m_lPatternID = 0;
|
||||
|
||||
m_dDpiX = 96;
|
||||
m_dDpiY = 96;
|
||||
|
||||
m_lClipMode = c_nClipRegionTypeWinding;
|
||||
|
||||
m_bIsClipping = false;
|
||||
m_bIsNeedUpdateClip = false;
|
||||
}
|
||||
|
||||
void SetSettings(NSStructures::CPen* pPen, NSStructures::CBrush* pBrush)
|
||||
{
|
||||
m_pPen = pPen;
|
||||
m_pBrush = pBrush;
|
||||
}
|
||||
|
||||
void CloseFile(std::wstring strFile = L"")
|
||||
{
|
||||
if (!strFile.empty())
|
||||
{
|
||||
m_oDocument.WriteString(L"</svg>", 5);
|
||||
NSFile::CFileBinary::SaveToFile(strFile, m_oDocument.GetData());
|
||||
}
|
||||
|
||||
if (3000000 < m_oDocument.GetSize())
|
||||
m_oDocument.Clear();
|
||||
|
||||
m_oDocument.ClearNoAttack();
|
||||
m_oPath.ClearNoAttack();
|
||||
|
||||
m_oClip.Clear();
|
||||
m_lClippingPath = 0;
|
||||
m_lPatternID = 0;
|
||||
m_bIsClipping = false;
|
||||
}
|
||||
void NewDocument(double& dWidth, double& dHeigth, LONG& lPageNumber)
|
||||
{
|
||||
m_lWidth = (int)dWidth;
|
||||
m_lHeight = (int)dHeigth;
|
||||
|
||||
m_oClip.m_lWidth = m_lWidth;
|
||||
m_oClip.m_lHeight = m_lHeight;
|
||||
|
||||
m_lCurDocumentID = lPageNumber;
|
||||
|
||||
WriteFormatted(L"<svg width=\"", m_lWidth, L"px\" height=\"", m_lHeight, L"px\" viewBox=\"0 0 ", m_lWidth, L" ", m_lHeight,
|
||||
L"\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", &m_oDocument);
|
||||
|
||||
m_oClip.Clear();
|
||||
|
||||
m_lClippingPath = 0;
|
||||
m_bIsClipping = false;
|
||||
m_bIsNeedUpdateClip = false;
|
||||
}
|
||||
void NewDocument(int& lWidth, int& lHeigth)
|
||||
{
|
||||
m_lWidth = lWidth;
|
||||
m_lHeight = lHeigth;
|
||||
|
||||
m_oClip.m_lWidth = m_lWidth;
|
||||
m_oClip.m_lHeight = m_lHeight;
|
||||
|
||||
WriteFormatted(L"<svg width=\"", m_lWidth, L"px\" height=\"", m_lHeight, L"px\" viewBox=\"0 0 ", m_lWidth, L" ", m_lHeight,
|
||||
L"\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", &m_oDocument);
|
||||
|
||||
m_oClip.Clear();
|
||||
|
||||
m_lClippingPath = 0;
|
||||
m_bIsClipping = false;
|
||||
m_bIsNeedUpdateClip = false;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
inline void WritePathEnd()
|
||||
{
|
||||
m_oPath.ClearNoAttack();
|
||||
}
|
||||
inline void WritePathStart()
|
||||
{
|
||||
m_oPath.ClearNoAttack();
|
||||
}
|
||||
void WritePathClose()
|
||||
{
|
||||
m_oPath.AddSize(2);
|
||||
m_oPath.AddCharNoCheck('Z');
|
||||
m_oPath.AddSpaceNoCheck();
|
||||
}
|
||||
|
||||
void WritePathMoveTo(double& x, double& y)
|
||||
{
|
||||
m_oPath.AddSize(30);
|
||||
m_oPath.AddCharNoCheck('M');
|
||||
m_oPath.AddSpaceNoCheck();
|
||||
|
||||
m_oPath.AddIntNoCheck(round2(x));
|
||||
m_oPath.AddCharNoCheck(',');
|
||||
m_oPath.AddIntNoCheck(round2(y));
|
||||
m_oPath.AddSpaceNoCheck();
|
||||
}
|
||||
void WritePathLineTo(double& x, double& y)
|
||||
{
|
||||
if (0 == m_oPath.GetCurSize())
|
||||
{
|
||||
WritePathMoveTo(x, y);
|
||||
}
|
||||
|
||||
m_oPath.AddSize(30);
|
||||
m_oPath.AddCharNoCheck('L');
|
||||
m_oPath.AddSpaceNoCheck();
|
||||
|
||||
m_oPath.AddIntNoCheck(round2(x));
|
||||
m_oPath.AddCharNoCheck(',');
|
||||
m_oPath.AddIntNoCheck(round2(y));
|
||||
m_oPath.AddSpaceNoCheck();
|
||||
}
|
||||
void WritePathCurveTo(double& x1, double& y1, double& x2, double& y2, double& x3, double& y3)
|
||||
{
|
||||
if (0 == m_oPath.GetCurSize())
|
||||
{
|
||||
WritePathMoveTo(x1, y1);
|
||||
}
|
||||
|
||||
m_oPath.AddSize(80);
|
||||
m_oPath.AddCharNoCheck('C');
|
||||
m_oPath.AddSpaceNoCheck();
|
||||
|
||||
m_oPath.AddIntNoCheck(round2(x1));
|
||||
m_oPath.AddCharNoCheck(',');
|
||||
m_oPath.AddIntNoCheck(round2(y1));
|
||||
m_oPath.AddSpaceNoCheck();
|
||||
|
||||
m_oPath.AddIntNoCheck(round2(x2));
|
||||
m_oPath.AddCharNoCheck(',');
|
||||
m_oPath.AddIntNoCheck(round2(y2));
|
||||
m_oPath.AddSpaceNoCheck();
|
||||
|
||||
m_oPath.AddIntNoCheck(round2(x3));
|
||||
m_oPath.AddCharNoCheck(',');
|
||||
m_oPath.AddIntNoCheck(round2(y3));
|
||||
m_oPath.AddSpaceNoCheck();
|
||||
}
|
||||
void WriteHatchPattern()
|
||||
{
|
||||
std::wstring sPatternId = std::to_wstring(m_lPatternID++);
|
||||
|
||||
m_oDocument.WriteString(L"<pattern id=\"hatch" + sPatternId + L"\" x=\"0\" y=\"0\" width=\"800\" height=\"800\" patternUnits=\"userSpaceOnUse\">");
|
||||
m_oDocument.WriteString(L"<image preserveAspectRatio=\"none\" x=\"0\" y=\"0\" width=\"800\" height=\"800\" xlink:href=\"data:image/png;base64,");
|
||||
|
||||
std::string sHatchPattern = NSGraphics::GetHatchBase64(m_pBrush->TexturePath,
|
||||
m_pBrush->Color1 & 0xFF, (m_pBrush->Color1 >> 8) & 0xFF, (m_pBrush->Color1 >> 16) & 0xFF, m_pBrush->Alpha1 & 0xFF,
|
||||
m_pBrush->Color2 & 0xFF, (m_pBrush->Color2 >> 8) & 0xFF, (m_pBrush->Color2 >> 16) & 0xFF, m_pBrush->Alpha2 & 0xFF);
|
||||
|
||||
m_oDocument.WriteString(UTF8_TO_U(sHatchPattern));
|
||||
|
||||
m_oDocument.WriteString(L"\" /></pattern>");
|
||||
}
|
||||
void WriteDrawPath(LONG nType, Aggplus::CMatrix* pTransform, Aggplus::CGraphicsPathSimpleConverter* pConverter, CImageInfo& oInfo, const double& dAngle)
|
||||
{
|
||||
if (m_oPath.GetCurSize() < 3)
|
||||
return;
|
||||
|
||||
WriteClip();
|
||||
|
||||
double dScaleTransform = (pTransform->sx() + pTransform->sy()) / 2.0;
|
||||
int nPenW = int(m_pPen->Size * dScaleTransform * SVG_WRITER_SCALE);
|
||||
|
||||
if (0 == nPenW)
|
||||
nPenW = 1;
|
||||
|
||||
if (0 == m_pPen->Alpha)
|
||||
nType &= 0xFF00;
|
||||
|
||||
if (c_BrushTypeTexture == m_pBrush->Type)
|
||||
{
|
||||
if (0 == m_pBrush->TextureAlpha)
|
||||
nType &= 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 == m_pBrush->Alpha1)
|
||||
nType &= 0xFF;
|
||||
}
|
||||
|
||||
bool bStroke = (0x01 == (0x01 & nType));
|
||||
bool bFill = (0x01 < nType);
|
||||
|
||||
if (!bFill)
|
||||
{
|
||||
// stroke
|
||||
m_oDocument.WriteString(L"<path ", 6);
|
||||
m_oDocument.WriteString(L"style=\"fill:none;stroke:", 24);
|
||||
m_oDocument.WriteHexColor3(m_pPen->Color);
|
||||
m_oDocument.WriteString(L";stroke-width:", 14);
|
||||
m_oDocument.AddInt(nPenW);
|
||||
m_oDocument.WriteString(L"px;stroke-opacity:", 18);
|
||||
m_oDocument.AddIntDel100(100 * m_pPen->Alpha / 255);
|
||||
|
||||
if (m_pPen->DashStyle == 0)
|
||||
{
|
||||
m_oDocument.WriteString(L";\" ", 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oDocument.WriteString(L";stroke-dasharray: 2,2;\" ", 25);
|
||||
}
|
||||
|
||||
WriteStyleClip();
|
||||
m_oDocument.WriteString(L" d=\"", 4);
|
||||
m_oDocument.Write(m_oPath);
|
||||
m_oDocument.WriteString(L"\" />\n", 5);
|
||||
return;
|
||||
}
|
||||
else if (c_BrushTypeTexture == m_pBrush->Type)
|
||||
{
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
double r = 0;
|
||||
double b = 0;
|
||||
|
||||
pConverter->PathCommandGetBounds(x, y, r, b);
|
||||
r += x;
|
||||
b += y;
|
||||
|
||||
if (0 == dAngle)
|
||||
{
|
||||
pTransform->TransformPoint(x, y);
|
||||
pTransform->TransformPoint(r, b);
|
||||
}
|
||||
else
|
||||
{
|
||||
Aggplus::CMatrix oTemp = *pTransform;
|
||||
|
||||
double dCx = (x + r) / 2;
|
||||
double dCy = (y + b) / 2;
|
||||
pTransform->TransformPoint(dCx, dCy);
|
||||
oTemp.RotateAt(-dAngle, dCx, dCy, Aggplus::MatrixOrderAppend);
|
||||
|
||||
oTemp.TransformPoint(x, y);
|
||||
oTemp.TransformPoint(r, b);
|
||||
}
|
||||
|
||||
// пока заглушка
|
||||
return WriteImage(oInfo, x, y, r - x, b - y, dAngle);
|
||||
|
||||
#if 0
|
||||
CString strPattern = _T("");
|
||||
|
||||
/*
|
||||
if (itJPG == oInfo.m_eType)
|
||||
{
|
||||
strPattern.Format(g_svg_string_pattern_jpg, m_lPatternID, _w, _h, _w, _h, _x, _y, _w, _h, oInfo.m_lID);
|
||||
}
|
||||
else
|
||||
{
|
||||
strPattern.Format(g_svg_string_pattern_png, m_lPatternID, _w, _h, _w, _h, _x, _y, _w, _h, oInfo.m_lID);
|
||||
}
|
||||
*/
|
||||
|
||||
m_oDocument.WriteString(strPattern);
|
||||
|
||||
CString strMode = _T("nonzero");
|
||||
if (nType & c_nEvenOddFillMode)
|
||||
strMode = _T("evenodd");
|
||||
|
||||
if (!bStroke)
|
||||
{
|
||||
CString strStyle = _T("");
|
||||
strStyle.Format(g_svg_string_vml_StyleFillTx, m_lPatternID, (double)m_pBrush->Alpha1 / 255, strMode);
|
||||
|
||||
m_oDocument.WriteString(g_svg_bstr_vml_Path);
|
||||
m_oDocument.WriteString(strStyle);
|
||||
WriteStyleClip();
|
||||
m_oDocument.WriteString(g_svg_bstr_path_d);
|
||||
m_oDocument.Write(m_oPath);
|
||||
m_oDocument.WriteString(g_svg_bstr_path_d_end);
|
||||
m_oDocument.WriteString(g_svg_bstr_nodeClose);
|
||||
}
|
||||
else
|
||||
{
|
||||
int nPenColor = ConvertColor(m_pPen->Color);
|
||||
|
||||
CString strStyle = _T("");
|
||||
strStyle.Format(g_svg_string_vml_StyleTx, m_lPatternID, (double)m_pBrush->Alpha1 / 255, strMode, nPenColor, nPenW, (double)m_pPen->Alpha / 255);
|
||||
|
||||
m_oDocument.WriteString(g_svg_bstr_vml_Path);
|
||||
m_oDocument.WriteString(strStyle);
|
||||
WriteStyleClip();
|
||||
m_oDocument.WriteString(g_svg_bstr_path_d);
|
||||
m_oDocument.Write(m_oPath);
|
||||
m_oDocument.WriteString(g_svg_bstr_path_d_end);
|
||||
m_oDocument.WriteString(g_svg_bstr_nodeClose);
|
||||
}
|
||||
|
||||
++m_lPatternID;
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!bStroke)
|
||||
{
|
||||
if (c_BrushTypeHatch1 == m_pBrush->Type)
|
||||
WriteHatchPattern();
|
||||
|
||||
m_oDocument.WriteString(L"<path ", 6);
|
||||
m_oDocument.WriteString(L"style=\"fill:", 12);
|
||||
|
||||
if (c_BrushTypeHatch1 == m_pBrush->Type)
|
||||
{
|
||||
m_oDocument.WriteString(L"url(#hatch" + std::to_wstring(m_lPatternID - 1) + L")");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oDocument.WriteHexColor3(m_pBrush->Color1);
|
||||
m_oDocument.WriteString(L";fill-opacity:", 14);
|
||||
m_oDocument.AddIntDel100(100 * m_pBrush->Alpha1 / 255);
|
||||
}
|
||||
|
||||
if (nType & c_nEvenOddFillMode)
|
||||
m_oDocument.WriteString(L";fill-rule:evenodd;stroke:none\"", 31);
|
||||
else
|
||||
m_oDocument.WriteString(L";fill-rule:nonzero;stroke:none\"", 31);
|
||||
|
||||
WriteStyleClip();
|
||||
m_oDocument.WriteString(L" d=\"", 4);
|
||||
m_oDocument.Write(m_oPath);
|
||||
m_oDocument.WriteString(L"\" />\n", 5);
|
||||
return;
|
||||
}
|
||||
|
||||
if (c_BrushTypeHatch1 == m_pBrush->Type)
|
||||
WriteHatchPattern();
|
||||
|
||||
m_oDocument.WriteString(L"<path ", 6);
|
||||
m_oDocument.WriteString(L"style=\"fill:", 12);
|
||||
|
||||
if (c_BrushTypeHatch1 == m_pBrush->Type)
|
||||
{
|
||||
m_oDocument.WriteString(L"url(#hatch" + std::to_wstring(m_lPatternID - 1) + L")");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oDocument.WriteHexColor3(m_pBrush->Color1);
|
||||
m_oDocument.WriteString(L";fill-opacity:", 14);
|
||||
m_oDocument.AddIntDel100(100 * m_pBrush->Alpha1 / 255);
|
||||
}
|
||||
|
||||
if (nType & c_nEvenOddFillMode)
|
||||
m_oDocument.WriteString(L";fill-rule:evenodd;stroke:", 26);
|
||||
else
|
||||
m_oDocument.WriteString(L";fill-rule:nonzero;stroke:", 26);
|
||||
m_oDocument.WriteHexColor3(m_pPen->Color);
|
||||
m_oDocument.WriteString(L";stroke-width:", 14);
|
||||
m_oDocument.AddInt(nPenW);
|
||||
m_oDocument.WriteString(L";stroke-opacity:", 16);
|
||||
m_oDocument.AddIntDel100(100 * m_pPen->Alpha / 255);
|
||||
m_oDocument.WriteString(L"\" ", 2);
|
||||
|
||||
WriteStyleClip();
|
||||
m_oDocument.WriteString(L" d=\"", 4);
|
||||
m_oDocument.Write(m_oPath);
|
||||
m_oDocument.WriteString(L"\" />\n", 5);
|
||||
}
|
||||
|
||||
void WritePathClip()
|
||||
{
|
||||
m_bIsClipping = true;
|
||||
m_bIsNeedUpdateClip = true;
|
||||
}
|
||||
void WritePathClipEnd()
|
||||
{
|
||||
if (0 == m_oPath.GetCurSize())
|
||||
return;
|
||||
|
||||
std::wstring sNewClip = m_oPath.GetData();
|
||||
int nSizeCurrent = m_oClip.m_arPaths.size();
|
||||
if (nSizeCurrent != 0)
|
||||
{
|
||||
if (m_oClip.m_arTypes[nSizeCurrent - 1] == m_lClipMode && m_oClip.m_arPaths[nSizeCurrent - 1] == sNewClip)
|
||||
return;
|
||||
}
|
||||
|
||||
m_oClip.m_arPaths.push_back(sNewClip);
|
||||
m_oClip.m_arTypes.push_back(m_lClipMode);
|
||||
}
|
||||
void WritePathResetClip()
|
||||
{
|
||||
m_bIsClipping = false;
|
||||
m_bIsNeedUpdateClip = false;
|
||||
m_oClip.Clear();
|
||||
}
|
||||
|
||||
void WriteImage(CImageInfo& oInfo, const double& x, const double& y, const double& w, const double& h, const double& dAngle)
|
||||
{
|
||||
bool bIsClipping = false;
|
||||
if ((1 < h) && (1 < w) && (1 > fabs(dAngle)))
|
||||
{
|
||||
WriteClip();
|
||||
bIsClipping = m_bIsClipping;
|
||||
}
|
||||
|
||||
double dCentreX = x + w / 2.0;
|
||||
double dCentreY = y + h / 2.0;
|
||||
|
||||
dCentreX *= SVG_WRITER_SCALE;
|
||||
dCentreY *= SVG_WRITER_SCALE;
|
||||
|
||||
bool bIsRotate = (abs(dAngle) > 1) ? true : false;
|
||||
|
||||
if (itJPG == oInfo.m_eType)
|
||||
{
|
||||
if (bIsClipping)
|
||||
{
|
||||
m_oDocument.WriteString(L"<image x=\"", 10);
|
||||
m_oDocument.AddInt(round2(x));
|
||||
m_oDocument.WriteString(L"\" y=\"", 5);
|
||||
m_oDocument.AddInt(round2(y));
|
||||
m_oDocument.WriteString(L"\" width=\"", 10);
|
||||
m_oDocument.AddInt(round2(w));
|
||||
m_oDocument.WriteString(L"\" height=\"", 11);
|
||||
m_oDocument.AddInt(round2(h));
|
||||
m_oDocument.WriteString(L"\" clip-path=\"url(#clip", 22);
|
||||
m_oDocument.AddInt(m_lClippingPath - 1);
|
||||
m_oDocument.WriteString(L")\" xlink:href=\"media/image", 26);
|
||||
m_oDocument.AddInt(oInfo.m_lID);
|
||||
if (!bIsRotate)
|
||||
{
|
||||
m_oDocument.WriteString(L".jpg\" preserveAspectRatio=\"none\"/>", 34);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oDocument.WriteString(L".jpg\" preserveAspectRatio=\"none\" transform=\"rotate(", 51);
|
||||
m_oDocument.AddDouble(dAngle, 4);
|
||||
m_oDocument.AddCharSafe(',');
|
||||
m_oDocument.AddDouble(dCentreX, 2);
|
||||
m_oDocument.AddCharSafe(',');
|
||||
m_oDocument.AddDouble(dCentreY, 2);
|
||||
m_oDocument.WriteString(L")\"/>", 4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oDocument.WriteString(L"<image x=\"", 10);
|
||||
m_oDocument.AddInt(round2(x));
|
||||
m_oDocument.WriteString(L"\" y=\"", 5);
|
||||
m_oDocument.AddInt(round2(y));
|
||||
m_oDocument.WriteString(L"\" width=\"", 10);
|
||||
m_oDocument.AddInt(round2(w));
|
||||
m_oDocument.WriteString(L"\" height=\"", 11);
|
||||
m_oDocument.AddInt(round2(h));
|
||||
m_oDocument.WriteString(L"\" xlink:href=\"media/image", 25);
|
||||
m_oDocument.AddInt(oInfo.m_lID);
|
||||
|
||||
if (!bIsRotate)
|
||||
{
|
||||
m_oDocument.WriteString(L".jpg\" preserveAspectRatio=\"none\"/>", 34);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oDocument.WriteString(L".jpg\" preserveAspectRatio=\"none\" transform=\"rotate(", 51);
|
||||
m_oDocument.AddDouble(dAngle, 4);
|
||||
m_oDocument.AddCharSafe(',');
|
||||
m_oDocument.AddDouble(dCentreX, 2);
|
||||
m_oDocument.AddCharSafe(',');
|
||||
m_oDocument.AddDouble(dCentreY, 2);
|
||||
m_oDocument.WriteString(L")\"/>", 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bIsClipping)
|
||||
{
|
||||
m_oDocument.WriteString(L"<image x=\"", 10);
|
||||
m_oDocument.AddInt(round2(x));
|
||||
m_oDocument.WriteString(L"\" y=\"", 5);
|
||||
m_oDocument.AddInt(round2(y));
|
||||
m_oDocument.WriteString(L"\" width=\"", 10);
|
||||
m_oDocument.AddInt(round2(w));
|
||||
m_oDocument.WriteString(L"\" height=\"", 11);
|
||||
m_oDocument.AddInt(round2(h));
|
||||
m_oDocument.WriteString(L"\" clip-path=\"url(#clip", 22);
|
||||
m_oDocument.AddInt(m_lClippingPath - 1);
|
||||
m_oDocument.WriteString(L")\" xlink:href=\"media/image", 26);
|
||||
m_oDocument.AddInt(oInfo.m_lID);
|
||||
if (!bIsRotate)
|
||||
{
|
||||
m_oDocument.WriteString(L".png\" preserveAspectRatio=\"none\"/>", 34);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oDocument.WriteString(L".png\" preserveAspectRatio=\"none\" transform=\"rotate(", 51);
|
||||
m_oDocument.AddDouble(dAngle, 4);
|
||||
m_oDocument.AddCharSafe(',');
|
||||
m_oDocument.AddDouble(dCentreX, 2);
|
||||
m_oDocument.AddCharSafe(',');
|
||||
m_oDocument.AddDouble(dCentreY, 2);
|
||||
m_oDocument.WriteString(L")\"/>", 4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oDocument.WriteString(L"<image x=\"", 10);
|
||||
m_oDocument.AddInt(round2(x));
|
||||
m_oDocument.WriteString(L"\" y=\"", 5);
|
||||
m_oDocument.AddInt(round2(y));
|
||||
m_oDocument.WriteString(L"\" width=\"", 10);
|
||||
m_oDocument.AddInt(round2(w));
|
||||
m_oDocument.WriteString(L"\" height=\"", 11);
|
||||
m_oDocument.AddInt(round2(h));
|
||||
m_oDocument.WriteString(L"\" xlink:href=\"media/image", 25);
|
||||
m_oDocument.AddInt(oInfo.m_lID);
|
||||
|
||||
if (!bIsRotate)
|
||||
{
|
||||
m_oDocument.WriteString(L".png\" preserveAspectRatio=\"none\"/>", 34);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oDocument.WriteString(L".png\" preserveAspectRatio=\"none\" transform=\"rotate(", 51);
|
||||
m_oDocument.AddDouble(dAngle, 4);
|
||||
m_oDocument.AddCharSafe(',');
|
||||
m_oDocument.AddDouble(dCentreX, 2);
|
||||
m_oDocument.AddCharSafe(',');
|
||||
m_oDocument.AddDouble(dCentreY, 2);
|
||||
m_oDocument.WriteString(L")\"/>", 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void WriteClip()
|
||||
{
|
||||
if (m_bIsClipping && m_bIsNeedUpdateClip && (m_oClip.IsInit()))
|
||||
{
|
||||
m_oClip.Write(m_oDocument, m_lClippingPath);
|
||||
//m_oClip.Clear();
|
||||
m_bIsNeedUpdateClip = false;
|
||||
}
|
||||
}
|
||||
|
||||
inline void WriteToMainHtml_1(NSStringUtils::CStringBuilder* pWriter, const CDstInfo& oInfo)
|
||||
{
|
||||
if (!oInfo.m_bIsWeb)
|
||||
{
|
||||
pWriter->WriteString(L"<object class=\"_svg\" data=\"page", 31);
|
||||
pWriter->AddInt(m_lCurDocumentID);
|
||||
pWriter->WriteString(L".svg\" type=\"image/svg+xml\">", 27);
|
||||
|
||||
CloseFile(oInfo.m_strDstFilePath + L"/page" + std::to_wstring(m_lCurDocumentID) + L".svg");
|
||||
}
|
||||
else
|
||||
{
|
||||
pWriter->WriteString(L"<object class=\"_svg\" data=\"", 27);
|
||||
pWriter->WriteString(oInfo.m_strAdditionalPath);
|
||||
pWriter->WriteString(L"/page", 5);
|
||||
pWriter->AddInt(m_lCurDocumentID);
|
||||
pWriter->WriteString(L".svg\" type=\"image/svg+xml\">", 27);
|
||||
|
||||
CloseFile(oInfo.m_strDstFilePath + L"/page" + std::to_wstring(m_lCurDocumentID) + L".svg");
|
||||
}
|
||||
}
|
||||
inline void WriteToMainHtml_2(NSStringUtils::CStringBuilder* pWriter)
|
||||
{
|
||||
pWriter->WriteString(L"</object>", 9);
|
||||
}
|
||||
|
||||
inline void WriteStyleClip()
|
||||
{
|
||||
if (m_bIsClipping)
|
||||
{
|
||||
if (!m_oDocument.IsSpace())
|
||||
m_oDocument.AddCharSafe(' ');
|
||||
|
||||
m_oDocument.WriteString(L"clip-path=\"url(#clip", 20);
|
||||
m_oDocument.AddInt(m_lClippingPath - 1);
|
||||
m_oDocument.WriteString(L")\" ", 3);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _ASC_HTMLRENDERER_SVGWRITER_H_
|
File diff suppressed because it is too large
Load Diff
@ -1,975 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef _ASC_HTMLRENDERER_TEXT_H_
|
||||
#define _ASC_HTMLRENDERER_TEXT_H_
|
||||
|
||||
#include "FontManager.h"
|
||||
#include "../../Common/OfficeFileFormats.h"
|
||||
#include "Meta.h"
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
#include <algorithm>
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
class CHChar
|
||||
{
|
||||
public:
|
||||
int unicode; // юникодное значение
|
||||
int gid; // индекс глифа в файле
|
||||
double x; // сдвиг по baseline
|
||||
double width; // ширина символа (сдвиг до след буквы)
|
||||
double* matrix; // матрица преобразования (!!! без сдвига)
|
||||
|
||||
public:
|
||||
CHChar()
|
||||
{
|
||||
unicode = 0;
|
||||
gid = 0;
|
||||
width = 0;
|
||||
matrix = NULL;
|
||||
}
|
||||
CHChar(const CHChar& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
CHChar& operator=(const CHChar& oSrc)
|
||||
{
|
||||
unicode = oSrc.unicode;
|
||||
gid = oSrc.gid;
|
||||
width = oSrc.width;
|
||||
matrix = NULL;
|
||||
if (NULL != oSrc.matrix)
|
||||
{
|
||||
matrix = new double[4];
|
||||
memcpy(matrix, oSrc.matrix, 4 * sizeof(double));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
~CHChar()
|
||||
{
|
||||
RELEASEARRAYOBJECTS(matrix);
|
||||
}
|
||||
|
||||
inline void Clear()
|
||||
{
|
||||
unicode = 0;
|
||||
gid = 0;
|
||||
width = 0;
|
||||
|
||||
RELEASEARRAYOBJECTS(matrix);
|
||||
}
|
||||
};
|
||||
|
||||
class CHLine
|
||||
{
|
||||
public:
|
||||
double m_dAscent;
|
||||
double m_dDescent;
|
||||
double m_dX;
|
||||
double m_dY;
|
||||
|
||||
double m_dEndX;
|
||||
double m_dEndY;
|
||||
|
||||
// baseline ruler: y = k*x + b
|
||||
double m_dK;
|
||||
double m_dB;
|
||||
double m_ex;
|
||||
double m_ey;
|
||||
bool m_bIsConstX;
|
||||
|
||||
// symbols
|
||||
// не менять на списки. постоянное создание объектов и их удаление -
|
||||
// плохо влияет на скорость
|
||||
CHChar* m_pChars;
|
||||
LONG m_lSizeChars;
|
||||
LONG m_lCharsTail;
|
||||
|
||||
bool m_bIsSetUpTransform;
|
||||
double m_sx;
|
||||
double m_sy;
|
||||
double m_shx;
|
||||
double m_shy;
|
||||
|
||||
public:
|
||||
CHLine()
|
||||
{
|
||||
m_dAscent = 0;
|
||||
m_dDescent = 0;
|
||||
m_dX = 0;
|
||||
m_dY = 0;
|
||||
|
||||
m_dK = 0;
|
||||
m_dB = 0;
|
||||
m_bIsConstX = false;
|
||||
|
||||
m_ex = 0;
|
||||
m_ey = 0;
|
||||
|
||||
m_lSizeChars = 1000;
|
||||
m_lCharsTail = 0;
|
||||
m_pChars = new CHChar[m_lSizeChars];
|
||||
|
||||
m_bIsSetUpTransform = false;
|
||||
m_sx = 1;
|
||||
m_sy = 1;
|
||||
m_shx = 0;
|
||||
m_shy = 0;
|
||||
}
|
||||
CHLine& operator=(const CHLine& oLine)
|
||||
{
|
||||
m_dAscent = oLine.m_dAscent;
|
||||
m_dDescent = oLine.m_dDescent;
|
||||
m_dX = oLine.m_dX;
|
||||
m_dY = oLine.m_dY;
|
||||
|
||||
m_dK = oLine.m_dK;
|
||||
m_dB = oLine.m_dB;
|
||||
|
||||
m_lSizeChars = oLine.m_lSizeChars;
|
||||
m_lCharsTail = oLine.m_lCharsTail;
|
||||
|
||||
RELEASEARRAYOBJECTS(m_pChars);
|
||||
m_pChars = new CHChar[m_lSizeChars];
|
||||
|
||||
for (LONG i = 0; i < m_lSizeChars; ++i)
|
||||
m_pChars[i] = oLine.m_pChars[i];
|
||||
|
||||
m_bIsSetUpTransform = oLine.m_bIsSetUpTransform;
|
||||
m_sx = oLine.m_sx;
|
||||
m_sy = oLine.m_sy;
|
||||
m_shx = oLine.m_shx;
|
||||
m_shy = oLine.m_shy;
|
||||
|
||||
return *this;
|
||||
}
|
||||
~CHLine()
|
||||
{
|
||||
RELEASEARRAYOBJECTS(m_pChars);
|
||||
}
|
||||
|
||||
inline void Clear()
|
||||
{
|
||||
m_dAscent = 0;
|
||||
m_dDescent = 0;
|
||||
m_dX = 0;
|
||||
m_dY = 0;
|
||||
|
||||
m_dK = 0;
|
||||
m_dB = 0;
|
||||
m_bIsConstX = false;
|
||||
|
||||
m_ex = 0;
|
||||
m_ey = 0;
|
||||
|
||||
m_lCharsTail = 0;
|
||||
|
||||
m_bIsSetUpTransform = false;
|
||||
m_sx = 1;
|
||||
m_sy = 1;
|
||||
m_shx = 0;
|
||||
m_shy = 0;
|
||||
}
|
||||
|
||||
inline CHChar* AddTail()
|
||||
{
|
||||
if (m_lCharsTail >= m_lSizeChars)
|
||||
{
|
||||
CHChar* pNews = new CHChar[2 * m_lSizeChars];
|
||||
for (LONG i = 0; i < m_lSizeChars; ++i)
|
||||
{
|
||||
pNews[i] = m_pChars[i];
|
||||
}
|
||||
|
||||
RELEASEARRAYOBJECTS(m_pChars);
|
||||
m_pChars = pNews;
|
||||
m_lSizeChars *= 2;
|
||||
}
|
||||
|
||||
CHChar* pChar = &m_pChars[m_lCharsTail];
|
||||
++m_lCharsTail;
|
||||
pChar->Clear();
|
||||
|
||||
return pChar;
|
||||
}
|
||||
|
||||
inline CHChar* GetTail()
|
||||
{
|
||||
if (0 == m_lCharsTail)
|
||||
return NULL;
|
||||
|
||||
return &m_pChars[m_lCharsTail - 1];
|
||||
}
|
||||
|
||||
inline LONG GetCountChars()
|
||||
{
|
||||
return m_lCharsTail;
|
||||
}
|
||||
};
|
||||
|
||||
const BYTE g_lfHorizontal = 0x01;
|
||||
const BYTE g_lfGids = 0x02;
|
||||
const BYTE g_lfWidth = 0x04;
|
||||
|
||||
class CHFontInfo
|
||||
{
|
||||
public:
|
||||
USHORT m_lAscent;
|
||||
USHORT m_lDescent;
|
||||
USHORT m_lLineHeight;
|
||||
USHORT m_lUnitsPerEm;
|
||||
|
||||
public:
|
||||
CHFontInfo()
|
||||
{
|
||||
m_lAscent = 0;
|
||||
m_lDescent = 0;
|
||||
m_lLineHeight = 0;
|
||||
m_lUnitsPerEm = 0;
|
||||
}
|
||||
|
||||
CHFontInfo(const CHFontInfo& oSrc)
|
||||
{
|
||||
m_lAscent = oSrc.m_lAscent;
|
||||
m_lDescent = oSrc.m_lDescent;
|
||||
m_lLineHeight = oSrc.m_lLineHeight;
|
||||
m_lUnitsPerEm = oSrc.m_lUnitsPerEm;
|
||||
}
|
||||
|
||||
CHFontInfo& operator=(const CHFontInfo& oSrc)
|
||||
{
|
||||
m_lAscent = oSrc.m_lAscent;
|
||||
m_lDescent = oSrc.m_lDescent;
|
||||
m_lLineHeight = oSrc.m_lLineHeight;
|
||||
m_lUnitsPerEm = oSrc.m_lUnitsPerEm;
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
class CFontMapInfo
|
||||
{
|
||||
public:
|
||||
std::wstring Path;
|
||||
int FaceIndex;
|
||||
|
||||
public:
|
||||
CFontMapInfo()
|
||||
{
|
||||
Path = L"";
|
||||
FaceIndex = 0;
|
||||
}
|
||||
CFontMapInfo(const CFontMapInfo& oSrc)
|
||||
{
|
||||
Path = oSrc.Path;
|
||||
FaceIndex = oSrc.FaceIndex;
|
||||
}
|
||||
CFontMapInfo& operator=(const CFontMapInfo& oSrc)
|
||||
{
|
||||
Path = oSrc.Path;
|
||||
FaceIndex = oSrc.FaceIndex;
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
class CFontManagerWrapper
|
||||
{
|
||||
private:
|
||||
NSFonts::IFontManager* m_pManager;
|
||||
public:
|
||||
CHFontInfo m_oCurrentInfo;
|
||||
NSStructures::CFont* m_pFont;
|
||||
|
||||
std::map<std::wstring, CHFontInfo> m_mapInfos;
|
||||
|
||||
public:
|
||||
CFontManagerWrapper()
|
||||
{
|
||||
m_pManager = NULL;
|
||||
}
|
||||
void Init(NSFonts::IApplicationFonts* pApplicationFonts, int nCacheSize = 0)
|
||||
{
|
||||
RELEASEOBJECT(m_pManager);
|
||||
m_pManager = pApplicationFonts->GenerateFontManager();
|
||||
|
||||
if (0 != nCacheSize)
|
||||
{
|
||||
NSFonts::IFontsCache* pFontCache = NSFonts::NSFontCache::Create();
|
||||
pFontCache->SetStreams(pApplicationFonts->GetStreams());
|
||||
pFontCache->SetCacheSize(nCacheSize);
|
||||
m_pManager->SetOwnerCache(pFontCache);
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~CFontManagerWrapper()
|
||||
{
|
||||
RELEASEOBJECT(m_pManager);
|
||||
}
|
||||
|
||||
void SetStringGID(INT bGid)
|
||||
{
|
||||
m_pManager->SetStringGID(bGid);
|
||||
}
|
||||
|
||||
public:
|
||||
inline void LoadCurrentFont(bool bIsAttack, int lFaceIndex = 0)
|
||||
{
|
||||
if (m_pFont->Path.empty())
|
||||
{
|
||||
std::wstring sFind = m_pFont->Name + L"__ASC_FONT__" + std::to_wstring(m_pFont->GetStyle());
|
||||
|
||||
std::map<std::wstring, CHFontInfo>::const_iterator pPair = m_mapInfos.find(sFind);
|
||||
if (m_mapInfos.end() != pPair)
|
||||
{
|
||||
if (bIsAttack)
|
||||
{
|
||||
LoadFontByName(m_pFont->Name, m_pFont->Size, m_pFont->GetStyle());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oCurrentInfo = pPair->second;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadFontByName(m_pFont->Name, m_pFont->Size, m_pFont->GetStyle());
|
||||
m_mapInfos.insert(std::pair<std::wstring, CHFontInfo>(sFind, m_oCurrentInfo));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::map<std::wstring, CHFontInfo>::const_iterator pPair = m_mapInfos.find(m_pFont->Path);
|
||||
if (m_mapInfos.end() != pPair)
|
||||
{
|
||||
if (bIsAttack)
|
||||
{
|
||||
LoadFontByFile(m_pFont->Path, m_pFont->Size, lFaceIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oCurrentInfo = pPair->second;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadFontByFile(m_pFont->Path, m_pFont->Size, lFaceIndex);
|
||||
m_mapInfos.insert(std::pair<std::wstring, CHFontInfo>(m_pFont->Path, m_oCurrentInfo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void LoadFontByName(const std::wstring& strName, const double& dSize, const LONG& lStyle)
|
||||
{
|
||||
m_pManager->LoadFontByName(strName, dSize, lStyle, c_dDpi, c_dDpi);
|
||||
LoadFontMetrics();
|
||||
}
|
||||
|
||||
inline void LoadFontByFile(const std::wstring& strPath, const double& dSize, const int& lFaceIndex)
|
||||
{
|
||||
m_pManager->LoadFontFromFile(strPath, lFaceIndex, dSize, c_dDpi, c_dDpi);
|
||||
LoadFontMetrics();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
double MeasureString(const unsigned int* symbols, const int& count, double x, double y, double& dBoxX, double& dBoxY, double& dBoxWidth, double& dBoxHeight)
|
||||
{
|
||||
dBoxX = 0;
|
||||
dBoxY = 0;
|
||||
dBoxWidth = 0;
|
||||
dBoxHeight = 0;
|
||||
|
||||
if (NULL == m_pManager)
|
||||
return 0;
|
||||
|
||||
m_pManager->LoadString1(symbols, count, (float)x, (float)y);
|
||||
|
||||
TBBox _box = m_pManager->MeasureString2();
|
||||
|
||||
dBoxX = (double)(_box.fMinX);
|
||||
dBoxY = (double)(_box.fMinY);
|
||||
dBoxWidth = (double)(_box.fMaxX - _box.fMinX);
|
||||
dBoxHeight = (double)(_box.fMaxY - _box.fMinY);
|
||||
|
||||
if (dBoxWidth < 0)
|
||||
dBoxWidth = -dBoxWidth;
|
||||
if (dBoxHeight < 0)
|
||||
dBoxHeight = -dBoxHeight;
|
||||
|
||||
// переводим в миллиметры
|
||||
dBoxX *= c_dPixToMM;
|
||||
dBoxY *= c_dPixToMM;
|
||||
dBoxWidth *= c_dPixToMM;
|
||||
dBoxHeight *= c_dPixToMM;
|
||||
|
||||
return dBoxWidth;
|
||||
}
|
||||
|
||||
public:
|
||||
void LoadFontMetrics()
|
||||
{
|
||||
m_pManager->AfterLoad();
|
||||
int lA = m_pManager->GetAscender();
|
||||
int lD = m_pManager->GetDescender();
|
||||
int lL = m_pManager->GetLineHeight();
|
||||
int lU = m_pManager->GetUnitsPerEm();
|
||||
|
||||
if (lA < 0)
|
||||
lA = -lA;
|
||||
if (lD < 0)
|
||||
lD = -lD;
|
||||
if (lL < 0)
|
||||
lL = -lL;
|
||||
if (lU < 0)
|
||||
lU = -lU;
|
||||
|
||||
m_oCurrentInfo.m_lAscent = (USHORT)(lA);
|
||||
m_oCurrentInfo.m_lDescent = (USHORT)(lD);
|
||||
m_oCurrentInfo.m_lLineHeight = (USHORT)(lL);
|
||||
m_oCurrentInfo.m_lUnitsPerEm = (USHORT)(lU);
|
||||
}
|
||||
};
|
||||
|
||||
class CHText
|
||||
{
|
||||
public:
|
||||
CFontManagerWrapper m_oFontManager;
|
||||
|
||||
CHLine m_oLine;
|
||||
CMetafile* m_pMeta;
|
||||
|
||||
NSStructures::CBrush* m_pBrush;
|
||||
NSStructures::CFont* m_pFont;
|
||||
|
||||
NSStructures::CBrush* m_pLastBrush;
|
||||
|
||||
Aggplus::CMatrix* m_pTransform;
|
||||
Aggplus::CMatrix* m_pLastTransform;
|
||||
|
||||
CMetafile m_oMeta;
|
||||
CMetafile* m_pPageMeta;
|
||||
|
||||
double m_dTextSpaceEps;
|
||||
|
||||
LONG m_lCountParagraphs;
|
||||
LONG m_lCountWords;
|
||||
LONG m_lCountSymbols;
|
||||
LONG m_lCountSpaces;
|
||||
|
||||
public:
|
||||
CHText() : m_oFontManager(), m_oLine()
|
||||
{
|
||||
m_dTextSpaceEps = 0.1;
|
||||
|
||||
m_lCountParagraphs = 0;
|
||||
m_lCountWords = 0;
|
||||
m_lCountSymbols = 0;
|
||||
m_lCountSpaces = 0;
|
||||
}
|
||||
void Init(NSFonts::IApplicationFonts* pApplicationFonts, int nCacheSize = 0)
|
||||
{
|
||||
m_oFontManager.Init(pApplicationFonts, nCacheSize);
|
||||
}
|
||||
|
||||
void ClearStatistics()
|
||||
{
|
||||
m_lCountParagraphs = 0;
|
||||
m_lCountWords = 0;
|
||||
m_lCountSymbols = 0;
|
||||
m_lCountSpaces = 0;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void SetParams(T writer)
|
||||
{
|
||||
m_oFontManager.m_pFont = writer->m_pFont;
|
||||
|
||||
m_pBrush = writer->m_pBrush;
|
||||
m_pFont = writer->m_pFont;
|
||||
|
||||
m_pLastBrush = &writer->m_oLastBrush;
|
||||
|
||||
m_pTransform = writer->m_pTransform;
|
||||
m_pLastTransform = &writer->m_oLastTransform;
|
||||
|
||||
m_pPageMeta = &writer->m_oPage;
|
||||
|
||||
switch (writer->m_lSrcFileType)
|
||||
{
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF:
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS:
|
||||
break;
|
||||
default:
|
||||
m_dTextSpaceEps = 0.1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
~CHText()
|
||||
{
|
||||
}
|
||||
|
||||
void NewPage()
|
||||
{
|
||||
m_oMeta.ClearNoAttack();
|
||||
}
|
||||
void ClosePage()
|
||||
{
|
||||
LONG nCount = m_oLine.GetCountChars();
|
||||
if (0 != nCount)
|
||||
DumpLine();
|
||||
}
|
||||
|
||||
public:
|
||||
template<typename T>
|
||||
void CommandText(const int* pUnicodes, const int* pGids, const int& nCount,
|
||||
const double& x, const double& y, const double& width, const double& height, bool bIsDumpFont, T writer)
|
||||
{
|
||||
// 1) сначала определяем точку отсчета и направление baseline
|
||||
double _x1 = x;
|
||||
double _y1 = y;
|
||||
double _x2 = x + 1;
|
||||
double _y2 = y;
|
||||
m_pTransform->TransformPoint(_x1, _y1);
|
||||
m_pTransform->TransformPoint(_x2, _y2);
|
||||
|
||||
double _k = 0;
|
||||
double _b = 0;
|
||||
bool _isConstX = false;
|
||||
if (fabs(_x1 - _x2) < 0.001)
|
||||
{
|
||||
_isConstX = true;
|
||||
_b = _x1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_k = (_y1 - _y2) / (_x1 - _x2);
|
||||
_b = _y1 - _k * _x1;
|
||||
}
|
||||
|
||||
double dAbsVec = sqrt((_x1 - _x2) * (_x1 - _x2) + (_y1 - _y2) * (_y1 - _y2));
|
||||
if (dAbsVec == 0)
|
||||
dAbsVec = 1;
|
||||
|
||||
LONG nCountChars = m_oLine.GetCountChars();
|
||||
|
||||
bool bIsNewLine = true;
|
||||
|
||||
if (0 != nCountChars)
|
||||
{
|
||||
if (_isConstX && m_oLine.m_bIsConstX && fabs(_b - m_oLine.m_dB) < 0.001)
|
||||
bIsNewLine = false;
|
||||
else if (!_isConstX && !m_oLine.m_bIsConstX && fabs(_k - m_oLine.m_dK) < 0.001 && fabs(_b - m_oLine.m_dB) < 0.001)
|
||||
bIsNewLine = false;
|
||||
}
|
||||
|
||||
if (bIsNewLine && (0 != nCountChars))
|
||||
{
|
||||
// не совпала baseline. поэтому просто скидываем линию в поток
|
||||
DumpLine();
|
||||
}
|
||||
|
||||
// теперь нужно определить сдвиг по baseline относительно destination точки
|
||||
nCountChars = m_oLine.GetCountChars();
|
||||
double dOffsetX = 0;
|
||||
if (0 == nCountChars)
|
||||
{
|
||||
m_oLine.m_bIsConstX = _isConstX;
|
||||
m_oLine.m_dK = _k;
|
||||
m_oLine.m_dB = _b;
|
||||
|
||||
m_oLine.m_dX = _x1;
|
||||
m_oLine.m_dY = _y1;
|
||||
|
||||
m_oLine.m_ex = (_x2 - _x1) / dAbsVec;
|
||||
m_oLine.m_ey = (_y2 - _y1) / dAbsVec;
|
||||
|
||||
m_oLine.m_dEndX = _x1;
|
||||
m_oLine.m_dEndY = _y1;
|
||||
}
|
||||
else
|
||||
{
|
||||
double sx = _x1 - m_oLine.m_dEndX;
|
||||
double sy = _y1 - m_oLine.m_dEndY;
|
||||
double len = sqrt(sx*sx + sy*sy);
|
||||
|
||||
if (sx*m_oLine.m_ex >= 0 && sy*m_oLine.m_ey >= 0)
|
||||
{
|
||||
// продолжаем линию
|
||||
dOffsetX = len;
|
||||
|
||||
// теперь посмотрим, может быть нужно вставить пробел??
|
||||
CHChar* pLastChar = m_oLine.GetTail();
|
||||
if (dOffsetX > (pLastChar->width + 0.5))
|
||||
{
|
||||
// вставляем пробел. Пробел у нас будет не совсем пробел. А специфический
|
||||
CHChar* pSpaceChar = m_oLine.AddTail();
|
||||
pSpaceChar->x = pLastChar->width;
|
||||
pSpaceChar->width = dOffsetX - pLastChar->width;
|
||||
pSpaceChar->unicode = 0xFFFF;
|
||||
pSpaceChar->gid = 0xFFFF;
|
||||
dOffsetX -= pLastChar->width;
|
||||
|
||||
m_oMeta.WriteBYTE(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// буква сдвинута влево относительно предыдущей буквы
|
||||
// на такую ситуацию реагируем просто - просто начинаем новую линию,
|
||||
// предварительно сбросив старую
|
||||
DumpLine();
|
||||
|
||||
m_oLine.m_bIsConstX = _isConstX;
|
||||
|
||||
m_oLine.m_dX = _x1;
|
||||
m_oLine.m_dY = _y1;
|
||||
|
||||
m_oLine.m_dK = _k;
|
||||
m_oLine.m_dB = _b;
|
||||
|
||||
m_oLine.m_ex = (_x2 - _x1) / dAbsVec;
|
||||
m_oLine.m_ey = (_y2 - _y1) / dAbsVec;
|
||||
}
|
||||
|
||||
m_oLine.m_dEndX = _x1;
|
||||
m_oLine.m_dEndY = _y1;
|
||||
}
|
||||
|
||||
// смотрим, совпадает ли главная часть матрицы.
|
||||
bool bIsTransform = !IsEqualMain(m_pLastTransform, m_pTransform);
|
||||
if (bIsTransform)
|
||||
bIsDumpFont = true;
|
||||
|
||||
bool bIsColor = ((m_pBrush->Color1 != m_pLastBrush->Color1) || (m_pBrush->Alpha1 != m_pLastBrush->Alpha1));
|
||||
|
||||
BYTE nLenMetaCommands = 0;
|
||||
if (bIsColor)
|
||||
nLenMetaCommands += 5;
|
||||
if (bIsTransform)
|
||||
nLenMetaCommands += 17;
|
||||
if (bIsDumpFont)
|
||||
nLenMetaCommands += 13;
|
||||
|
||||
m_oMeta.WriteBYTE(nLenMetaCommands);
|
||||
|
||||
double _dumpSize = writer->m_dCurrentFontSize;
|
||||
double _dumpMtx[4];
|
||||
_dumpMtx[0] = m_pTransform->sx();
|
||||
_dumpMtx[1] = m_pTransform->shy();
|
||||
_dumpMtx[2] = m_pTransform->shx();
|
||||
_dumpMtx[3] = m_pTransform->sy();
|
||||
|
||||
double dTextScale = std::min( sqrt( _dumpMtx[2] * _dumpMtx[2] + _dumpMtx[3] * _dumpMtx[3] ), sqrt( _dumpMtx[0] * _dumpMtx[0] + _dumpMtx[1] * _dumpMtx[1] ) );
|
||||
|
||||
if ((_dumpSize < 0.1 && dTextScale > 10) || (_dumpSize > 10 && dTextScale < 0.1))
|
||||
{
|
||||
_dumpSize *= dTextScale;
|
||||
|
||||
_dumpMtx[0] /= dTextScale;
|
||||
_dumpMtx[1] /= dTextScale;
|
||||
_dumpMtx[2] /= dTextScale;
|
||||
_dumpMtx[3] /= dTextScale;
|
||||
}
|
||||
|
||||
if (bIsDumpFont)
|
||||
{
|
||||
m_oMeta.WriteCommandType(CMetafile::ctFontName);
|
||||
m_oMeta.WriteLONG(writer->m_lCurrentFont);
|
||||
m_oMeta.WriteLONG(writer->m_pFont->GetStyle());
|
||||
m_oMeta.WriteDouble(_dumpSize/*writer->m_dCurrentFontSize*/);
|
||||
}
|
||||
if (bIsTransform)
|
||||
{
|
||||
m_pLastTransform->SetElements(m_pTransform->sx(), m_pTransform->shy(), m_pTransform->shx(), m_pTransform->sy(), m_pLastTransform->tx(), m_pLastTransform->ty());
|
||||
|
||||
m_oLine.m_bIsSetUpTransform = true;
|
||||
m_oLine.m_sx = m_pTransform->sx();
|
||||
m_oLine.m_shx = m_pTransform->shx();
|
||||
m_oLine.m_shy = m_pTransform->shy();
|
||||
m_oLine.m_sy = m_pTransform->sy();
|
||||
|
||||
m_oMeta.WriteBYTE(CMetafile::ctCommandTextTransform);
|
||||
//m_oMeta.WriteDouble(_dst->sx);
|
||||
//m_oMeta.WriteDouble(_dst->shy);
|
||||
//m_oMeta.WriteDouble(_dst->shx);
|
||||
//m_oMeta.WriteDouble(_dst->sy);
|
||||
|
||||
m_oMeta.WriteDouble(_dumpMtx[0]);
|
||||
m_oMeta.WriteDouble(_dumpMtx[1]);
|
||||
m_oMeta.WriteDouble(_dumpMtx[2]);
|
||||
m_oMeta.WriteDouble(_dumpMtx[3]);
|
||||
}
|
||||
if (bIsColor)
|
||||
{
|
||||
m_pLastBrush->Color1 = m_pBrush->Color1;
|
||||
m_pLastBrush->Alpha1 = m_pBrush->Alpha1;
|
||||
|
||||
m_oMeta.WriteBYTE(CMetafile::ctBrushColor1);
|
||||
|
||||
LONG lBGR = m_pBrush->Color1;
|
||||
m_oMeta.WriteBYTE((BYTE)(lBGR & 0xFF));
|
||||
m_oMeta.WriteBYTE((BYTE)((lBGR >> 8) & 0xFF));
|
||||
m_oMeta.WriteBYTE((BYTE)((lBGR >> 16) & 0xFF));
|
||||
m_oMeta.WriteBYTE((BYTE)m_pBrush->Alpha1);
|
||||
}
|
||||
|
||||
// все, baseline установлен. теперь просто продолжаем линию
|
||||
LONG lTextLen = nCount;
|
||||
bool bIsLoadFontAttack = true;
|
||||
|
||||
// плохие значения приходят из пдф
|
||||
/*
|
||||
if (1 == lTextLen && 0 <= width)
|
||||
bIsLoadFontAttack = false;
|
||||
*/
|
||||
|
||||
if (bIsDumpFont)
|
||||
m_oFontManager.LoadCurrentFont(bIsLoadFontAttack);
|
||||
|
||||
double dKoef = m_oFontManager.m_pFont->Size * 25.4 / (72 * m_oFontManager.m_oCurrentInfo.m_lUnitsPerEm);
|
||||
double dKoefMetr = dAbsVec;
|
||||
double dAscender = m_oFontManager.m_oCurrentInfo.m_lAscent * dKoef * dKoefMetr;
|
||||
double dDescender = m_oFontManager.m_oCurrentInfo.m_lDescent * dKoef * dKoefMetr;
|
||||
|
||||
if (m_oLine.m_dAscent < dAscender)
|
||||
m_oLine.m_dAscent = dAscender;
|
||||
if (m_oLine.m_dDescent < dDescender)
|
||||
m_oLine.m_dDescent = dDescender;
|
||||
|
||||
if (!bIsLoadFontAttack)
|
||||
{
|
||||
CHChar* pChar = m_oLine.AddTail();
|
||||
|
||||
pChar->unicode = pUnicodes[0];
|
||||
pChar->gid = (NULL == pGids) ? 0xFFFF : pGids[0];
|
||||
pChar->width = width;
|
||||
pChar->x = dOffsetX;
|
||||
}
|
||||
else
|
||||
{
|
||||
double dPlusOffset = 0;
|
||||
|
||||
const int* input = NULL;
|
||||
if (NULL != pGids)
|
||||
{
|
||||
input = pGids;
|
||||
m_oFontManager.SetStringGID(TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
input = pUnicodes;
|
||||
m_oFontManager.SetStringGID(FALSE);
|
||||
}
|
||||
|
||||
double dBoxX = 0;
|
||||
double dBoxY = 0;
|
||||
double dBoxW = 0;
|
||||
double dBoxH = 0;
|
||||
|
||||
double dPrevW = dOffsetX;
|
||||
for (LONG lIndex = 0; lIndex < lTextLen; ++lIndex)
|
||||
{
|
||||
double dW = m_oFontManager.MeasureString((const unsigned int*)(input + lIndex), 1, 0, 0, dBoxX, dBoxY, dBoxW, dBoxH);
|
||||
|
||||
CHChar* pChar = m_oLine.AddTail();
|
||||
pChar->unicode = pUnicodes[lIndex];
|
||||
pChar->gid = (NULL == pGids) ? 0xFFFF : pGids[lIndex];
|
||||
|
||||
pChar->x = dPrevW;
|
||||
if (lIndex != 0)
|
||||
dPlusOffset += dPrevW;
|
||||
dPrevW = dW;
|
||||
|
||||
pChar->width = dW * dAbsVec;
|
||||
|
||||
if (0 != lIndex)
|
||||
m_oMeta.WriteBYTE(0);
|
||||
|
||||
if (lIndex == (lTextLen - 1))
|
||||
{
|
||||
m_oLine.m_dEndX += dPlusOffset * m_oLine.m_ex;
|
||||
m_oLine.m_dEndY += dPlusOffset * m_oLine.m_ey;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DumpLine()
|
||||
{
|
||||
if (m_oLine.m_bIsSetUpTransform)
|
||||
{
|
||||
// выставится трансформ!!!
|
||||
// cравнивать нужно с ним!!!
|
||||
m_pLastTransform->SetElements(m_oLine.m_sx, m_oLine.m_shy, m_oLine.m_shx, m_oLine.m_sy);
|
||||
}
|
||||
|
||||
// скидываем линию в поток pMeta
|
||||
BYTE mask = 0;
|
||||
if (fabs(m_oLine.m_ex - 1.0) < 0.001 && fabs(m_oLine.m_ey) < 0.001)
|
||||
mask |= g_lfHorizontal;
|
||||
|
||||
LONG lCountSpaces = 0;
|
||||
LONG lCountSymbols = 0;
|
||||
LONG lCountWords = 0;
|
||||
bool bIsLastSymbol = false;
|
||||
|
||||
bool bIsGidExist = false;
|
||||
|
||||
LONG nCount = m_oLine.GetCountChars();
|
||||
for (LONG i = 0; i < nCount; ++i)
|
||||
{
|
||||
CHChar* pChar = &m_oLine.m_pChars[i];
|
||||
if (pChar->gid != 0xFFFF)
|
||||
{
|
||||
mask |= g_lfGids;
|
||||
bIsGidExist = true;
|
||||
}
|
||||
|
||||
if (0xFFFF == pChar->unicode || ((WCHAR)' ') == pChar->unicode || ((WCHAR)'\t') == pChar->unicode)
|
||||
{
|
||||
lCountSpaces++;
|
||||
if (bIsLastSymbol)
|
||||
{
|
||||
bIsLastSymbol = false;
|
||||
lCountWords++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lCountSymbols++;
|
||||
bIsLastSymbol = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (bIsLastSymbol)
|
||||
lCountWords++;
|
||||
|
||||
if (0 == nCount)
|
||||
{
|
||||
m_oLine.Clear();
|
||||
m_oMeta.ClearNoAttack();
|
||||
return;
|
||||
}
|
||||
|
||||
m_lCountParagraphs += 1;
|
||||
m_lCountWords += lCountWords;
|
||||
m_lCountSymbols += lCountSymbols;
|
||||
m_lCountSpaces += lCountSpaces;
|
||||
|
||||
if (nCount > 1)
|
||||
mask |= g_lfWidth;
|
||||
|
||||
m_pPageMeta->CheckBufferSize(60);
|
||||
|
||||
m_pPageMeta->WriteBYTE_nocheck(CMetafile::ctCommandTextLine);
|
||||
m_pPageMeta->WriteBYTE_nocheck(mask);
|
||||
|
||||
m_pPageMeta->WriteDouble_nocheck(m_oLine.m_dX);
|
||||
m_pPageMeta->WriteDouble_nocheck(m_oLine.m_dY);
|
||||
|
||||
if ((mask & g_lfHorizontal) == 0)
|
||||
{
|
||||
m_pPageMeta->WriteDouble_nocheck(m_oLine.m_ex);
|
||||
m_pPageMeta->WriteDouble_nocheck(m_oLine.m_ey);
|
||||
}
|
||||
|
||||
m_pPageMeta->WriteDouble_nocheck(m_oLine.m_dAscent);
|
||||
m_pPageMeta->WriteDouble_nocheck(m_oLine.m_dDescent);
|
||||
|
||||
LONG _position = 0;
|
||||
if (nCount > 1)
|
||||
{
|
||||
_position = m_pPageMeta->GetPosition();
|
||||
m_pPageMeta->WriteLONG_nocheck(0);
|
||||
}
|
||||
|
||||
BYTE* pBufferMeta = m_oMeta.GetData();
|
||||
double dWidthLine = 0;
|
||||
|
||||
double dCurrentGlyphLineOffset = 0;
|
||||
for (LONG lIndexChar = 0; lIndexChar < nCount; ++lIndexChar)
|
||||
{
|
||||
CHChar* pChar = &m_oLine.m_pChars[lIndexChar];
|
||||
|
||||
// все настроки буквы (m_oMeta)
|
||||
BYTE lLen = *pBufferMeta;
|
||||
++pBufferMeta;
|
||||
if (lLen > 0)
|
||||
{
|
||||
m_pPageMeta->Write(pBufferMeta, lLen);
|
||||
}
|
||||
pBufferMeta += lLen;
|
||||
// смещение относительно предыдущей буквы (у всех, кроме первой)
|
||||
// юникодное значение
|
||||
// гид (если bIsGidExist == true)
|
||||
// ширина буквы
|
||||
|
||||
m_pPageMeta->CheckBufferSize(20);
|
||||
|
||||
m_pPageMeta->WriteBYTE_nocheck(CMetafile::ctDrawText);
|
||||
if (0 != lIndexChar)
|
||||
{
|
||||
m_pPageMeta->WriteDouble2_nocheck(pChar->x);
|
||||
}
|
||||
|
||||
m_pPageMeta->WriteWCHAR_nocheck2(pChar->unicode);
|
||||
if (bIsGidExist)
|
||||
m_pPageMeta->WriteUSHORT_nocheck(pChar->gid);
|
||||
m_pPageMeta->WriteDouble2_nocheck(pChar->width);
|
||||
|
||||
if (lIndexChar != 0)
|
||||
dCurrentGlyphLineOffset += pChar->x;
|
||||
|
||||
if (lIndexChar == (nCount - 1))
|
||||
dWidthLine = dCurrentGlyphLineOffset + pChar->width;
|
||||
}
|
||||
|
||||
if (nCount > 1)
|
||||
{
|
||||
int nWidthBuf = (int)(dWidthLine * 10000);
|
||||
memcpy(m_pPageMeta->GetData() + _position, &nWidthBuf, 4);
|
||||
}
|
||||
|
||||
m_oLine.Clear();
|
||||
m_oMeta.ClearNoAttack();
|
||||
|
||||
m_pPageMeta->WriteBYTE(CMetafile::ctCommandTextLineEnd);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _ASC_HTMLRENDERER_TEXT_H_
|
@ -1,381 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef _ASC_HTMLRENDERER_VMLWRITER_H_
|
||||
#define _ASC_HTMLRENDERER_VMLWRITER_H_
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
class CVMLWriter
|
||||
{
|
||||
public:
|
||||
NSStringUtils::CStringBuilder m_oPath;
|
||||
NSStringUtils::CStringBuilder m_oDocument;
|
||||
|
||||
LONG m_lCurDocumentID;
|
||||
LONG m_lClippingPath;
|
||||
|
||||
bool m_bIsClipping;
|
||||
LONG m_lClipMode;
|
||||
bool m_bIsClippingNow;
|
||||
|
||||
NSStructures::CPen* m_pPen;
|
||||
NSStructures::CBrush* m_pBrush;
|
||||
|
||||
double m_lWidth;
|
||||
double m_lHeight;
|
||||
|
||||
double m_dDpiX;
|
||||
double m_dDpiY;
|
||||
|
||||
public:
|
||||
CVMLWriter() : m_oPath(), m_oDocument()
|
||||
{
|
||||
m_lCurDocumentID = 0;
|
||||
m_lClippingPath = 0;
|
||||
|
||||
m_pPen = NULL;
|
||||
m_pBrush = NULL;
|
||||
|
||||
m_dDpiX = 96;
|
||||
m_dDpiY = 96;
|
||||
|
||||
m_lClipMode = c_nWindingFillMode;
|
||||
|
||||
m_bIsClipping = false;
|
||||
m_bIsClippingNow = false;
|
||||
}
|
||||
|
||||
void SetSettings(NSStructures::CPen* pPen, NSStructures::CBrush* pBrush)
|
||||
{
|
||||
m_pPen = pPen;
|
||||
m_pBrush = pBrush;
|
||||
}
|
||||
|
||||
void CloseFile(std::wstring strFile = L"")
|
||||
{
|
||||
if (L"" != strFile)
|
||||
{
|
||||
m_oDocument.WriteString(L"</v:group>\n</xml>", 17);
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(strFile);
|
||||
BYTE* pData;
|
||||
LONG nDataSize;
|
||||
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(m_oDocument.GetBuffer(), m_oDocument.GetCurSize(), pData, nDataSize);
|
||||
oFile.WriteFile(pData, nDataSize);
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
}
|
||||
|
||||
if (3000000 < m_oDocument.GetSize())
|
||||
m_oDocument.Clear();
|
||||
|
||||
m_oDocument.ClearNoAttack();
|
||||
m_oPath.ClearNoAttack();
|
||||
}
|
||||
void NewDocument(double& dWidth, double& dHeigth, LONG& lPageNumber)
|
||||
{
|
||||
CloseFile(L"");
|
||||
|
||||
m_lWidth = (int)dWidth;
|
||||
m_lHeight = (int)dHeigth;
|
||||
|
||||
m_lCurDocumentID = lPageNumber;
|
||||
|
||||
m_oDocument.AddSize(150);
|
||||
m_oDocument.WriteString(L"<xml xmlns:v=\"urn:schemas-microsoft-com:vml\">\n<v:group id=\"page", 63);
|
||||
m_oDocument.AddIntNoCheck((int)m_lCurDocumentID);
|
||||
m_oDocument.WriteString(L"\" style=\"position: absolute; width:1; height:1;\" coordsize=\"1 1\">\n", 66);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
inline void WritePathEnd()
|
||||
{
|
||||
m_oPath.ClearNoAttack();
|
||||
}
|
||||
inline void WritePathStart()
|
||||
{
|
||||
m_oPath.ClearNoAttack();
|
||||
}
|
||||
void WritePathClose()
|
||||
{
|
||||
if (m_bIsClippingNow)
|
||||
return;
|
||||
|
||||
m_oPath.AddCharSafe('x');
|
||||
}
|
||||
|
||||
void WritePathMoveTo(double& x, double& y)
|
||||
{
|
||||
if (m_bIsClippingNow)
|
||||
return;
|
||||
|
||||
m_oPath.AddSize(30);
|
||||
m_oPath.AddCharNoSafe('m');
|
||||
m_oPath.AddIntNoCheck(round(x));
|
||||
m_oPath.AddCharNoSafe(',');
|
||||
m_oPath.AddIntNoCheck(round(y));
|
||||
m_oPath.AddCharNoSafe(' ');
|
||||
}
|
||||
void WritePathLineTo(double& x, double& y)
|
||||
{
|
||||
if (m_bIsClippingNow)
|
||||
return;
|
||||
|
||||
if (0 == m_oPath.GetCurSize())
|
||||
{
|
||||
WritePathMoveTo(x, y);
|
||||
}
|
||||
m_oPath.AddSize(30);
|
||||
m_oPath.AddCharNoSafe('l');
|
||||
m_oPath.AddIntNoCheck(round(x));
|
||||
m_oPath.AddCharNoSafe(',');
|
||||
m_oPath.AddIntNoCheck(round(y));
|
||||
m_oPath.AddCharNoSafe(' ');
|
||||
}
|
||||
void WritePathCurveTo(double& x1, double& y1, double& x2, double& y2, double& x3, double& y3)
|
||||
{
|
||||
if (0 == m_oPath.GetCurSize())
|
||||
{
|
||||
WritePathMoveTo(x1, y1);
|
||||
}
|
||||
|
||||
m_oPath.AddSize(80);
|
||||
m_oPath.AddCharNoSafe('c');
|
||||
m_oPath.AddIntNoCheck(round(x1));
|
||||
m_oPath.AddCharNoSafe(',');
|
||||
m_oPath.AddIntNoCheck(round(y1));
|
||||
m_oPath.AddCharNoSafe(',');
|
||||
m_oPath.AddIntNoCheck(round(x2));
|
||||
m_oPath.AddCharNoSafe(',');
|
||||
m_oPath.AddIntNoCheck(round(y2));
|
||||
m_oPath.AddCharNoSafe(',');
|
||||
m_oPath.AddIntNoCheck(round(x3));
|
||||
m_oPath.AddCharNoSafe(',');
|
||||
m_oPath.AddIntNoCheck(round(y3));
|
||||
m_oPath.AddCharNoSafe(' ');
|
||||
}
|
||||
void WriteDrawPath(LONG lType, Aggplus::CMatrix* pTransform, Aggplus::CGraphicsPathSimpleConverter* pConverter, CImageInfo& oInfo, const double& dAngle)
|
||||
{
|
||||
if (m_oPath.GetCurSize() < 3)
|
||||
return;
|
||||
|
||||
int nStrokeColor = ConvertColor(m_pPen->Color);
|
||||
|
||||
m_oDocument.WriteString(L"<v:shape style=\"position:absolute; width:1; height:1\" stroked=\"", 63);
|
||||
|
||||
bool bStroke = false;
|
||||
bool bFilled = false;
|
||||
|
||||
if (m_pPen->Alpha == 0)
|
||||
lType &= 0xFF00;
|
||||
|
||||
if ((-1 == oInfo.m_lID) && (0 == m_pBrush->Alpha1))
|
||||
lType &= 0xFF;
|
||||
|
||||
// canvas
|
||||
if ((lType & 0x01) == 0x01)
|
||||
{
|
||||
bStroke = true;
|
||||
}
|
||||
if (lType > 0x01)
|
||||
{
|
||||
bFilled = true;
|
||||
}
|
||||
|
||||
if (bStroke)
|
||||
m_oDocument.WriteString(L"true", 4);
|
||||
else
|
||||
m_oDocument.WriteString(L"false", 5);
|
||||
|
||||
m_oDocument.WriteString(L"\" strokecolor=\"", 15);
|
||||
m_oDocument.WriteHexColor3(nStrokeColor);
|
||||
|
||||
m_oDocument.WriteString(L"\" filled=\"", 10);
|
||||
|
||||
if (bFilled)
|
||||
m_oDocument.WriteString(L"true", 4);
|
||||
else
|
||||
m_oDocument.WriteString(L"false", 5);
|
||||
|
||||
m_oDocument.WriteString(L"\" ", 2);
|
||||
|
||||
if (-1 != oInfo.m_lID)
|
||||
{
|
||||
if (itJPG == oInfo.m_eType)
|
||||
{
|
||||
m_oDocument.WriteString(L"path=\"", 6);
|
||||
m_oDocument.Write(m_oPath);
|
||||
m_oDocument.WriteString(L"\"><v:fill src=\"media/image", 26);
|
||||
m_oDocument.AddSize(10);
|
||||
m_oDocument.AddIntNoCheck(oInfo.m_lID);
|
||||
m_oDocument.WriteString(L".jpg\" type=\"frame\" opacity=\"", 28);
|
||||
m_oDocument.AddIntNoCheckDel100((100 * m_pBrush->TextureAlpha) / 255);
|
||||
m_oDocument.WriteString(L"\"/></v:shape>\n", 14);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oDocument.WriteString(L"path=\"", 6);
|
||||
m_oDocument.Write(m_oPath);
|
||||
m_oDocument.WriteString(L"\"><v:fill src=\"media/image", 26);
|
||||
m_oDocument.AddSize(10);
|
||||
m_oDocument.AddIntNoCheck(oInfo.m_lID);
|
||||
m_oDocument.WriteString(L".png\" type=\"frame\" opacity=\"", 28);
|
||||
m_oDocument.AddIntNoCheckDel100((100 * m_pBrush->TextureAlpha) / 255);
|
||||
m_oDocument.WriteString(L"\"/></v:shape>\n", 14);
|
||||
}
|
||||
}
|
||||
else if (0xFF == m_pBrush->Alpha1)
|
||||
{
|
||||
if (0x00 == (lType & 0xFF) || (0 == m_pPen->DashStyle))
|
||||
{
|
||||
m_oDocument.WriteString(L"fillcolor=\"", 11);
|
||||
m_oDocument.WriteHexColor3(ConvertColor(m_pBrush->Color1));
|
||||
m_oDocument.WriteString(L"\" path=\"", 8);
|
||||
m_oDocument.Write(m_oPath);
|
||||
m_oDocument.WriteString(L"\" />\n", 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oDocument.WriteString(L"fillcolor=\"", 11);
|
||||
m_oDocument.WriteHexColor3(ConvertColor(m_pBrush->Color1));
|
||||
m_oDocument.WriteString(L"\" path=\"", 8);
|
||||
m_oDocument.Write(m_oPath);
|
||||
m_oDocument.WriteString(L"\"><v:stroke dashstyle=\"dot\"/></v:shape>\n", 40);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0x00 == (lType & 0xFF) || (0 == m_pPen->DashStyle))
|
||||
{
|
||||
m_oDocument.WriteString(L"fillcolor=\"", 11);
|
||||
m_oDocument.WriteHexColor3(ConvertColor(m_pBrush->Color1));
|
||||
m_oDocument.WriteString(L"\" path=\"", 8);
|
||||
m_oDocument.Write(m_oPath);
|
||||
m_oDocument.WriteString(L"\"><v:fill opacity=\"", 19);
|
||||
m_oDocument.AddIntNoCheckDel100((100 * m_pBrush->Alpha1) / 255);
|
||||
m_oDocument.WriteString(L"\" />\n", 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oDocument.WriteString(L"fillcolor=\"", 11);
|
||||
m_oDocument.WriteHexColor3(ConvertColor(m_pBrush->Color1));
|
||||
m_oDocument.WriteString(L"\" path=\"", 8);
|
||||
m_oDocument.Write(m_oPath);
|
||||
m_oDocument.WriteString(L"\"><v:fill opacity=\"", 19);
|
||||
m_oDocument.AddIntNoCheckDel100((100 * m_pBrush->Alpha1) / 255);
|
||||
m_oDocument.WriteString(L"\"><v:stroke dashstyle=\"dot\"/></v:shape>\n", 40);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WriteImage(CImageInfo oInfo, const double& x, const double& y, const double& w, const double& h, const double& dAngle)
|
||||
{
|
||||
m_oDocument.WriteString(L"<v:image src=\"media/image", 25);
|
||||
m_oDocument.AddSize(100);
|
||||
m_oDocument.AddIntNoCheck(oInfo.m_lID);
|
||||
if (itJPG == oInfo.m_eType)
|
||||
m_oDocument.WriteString(L".jpg\" style=\"left:", 18);
|
||||
else
|
||||
m_oDocument.WriteString(L".png\" style=\"left:", 18);
|
||||
m_oDocument.AddIntNoCheck(round(x));
|
||||
m_oDocument.WriteString(L";top:", 5);
|
||||
m_oDocument.AddIntNoCheck(round(y));
|
||||
m_oDocument.WriteString(L";width:", 7);
|
||||
m_oDocument.AddIntNoCheck(round(w));
|
||||
m_oDocument.WriteString(L";height:", 8);
|
||||
m_oDocument.AddIntNoCheck(round(h));
|
||||
m_oDocument.WriteString(L";\"/>", 4);
|
||||
}
|
||||
|
||||
void WritePathClip()
|
||||
{
|
||||
m_bIsClipping = true;
|
||||
m_bIsClippingNow = true;
|
||||
++m_lClippingPath;
|
||||
}
|
||||
void WritePathClipEnd()
|
||||
{
|
||||
m_bIsClippingNow = false;
|
||||
}
|
||||
void WritePathResetClip()
|
||||
{
|
||||
m_bIsClipping = false;
|
||||
}
|
||||
|
||||
inline void WriteStyleClip()
|
||||
{
|
||||
}
|
||||
|
||||
void WriteToMainHtml(NSStringUtils::CStringBuilder* pWriter, const CDstInfo& oInfo)
|
||||
{
|
||||
if (!oInfo.m_bIsWeb)
|
||||
{
|
||||
pWriter->WriteString(L"<v:vmlframe clip=\"true\" origin=\"0,0\" size=\"", 43);
|
||||
pWriter->AddSize(100);
|
||||
pWriter->AddIntNoCheck((int)m_lWidth);
|
||||
pWriter->AddCharNoSafe(',');
|
||||
pWriter->AddIntNoCheck((int)m_lHeight);
|
||||
pWriter->WriteString(L"\" src=\"page", 11);
|
||||
pWriter->AddIntNoCheck(m_lCurDocumentID);
|
||||
pWriter->WriteString(L".vml#page", 9);
|
||||
pWriter->AddIntNoCheck(m_lCurDocumentID);
|
||||
pWriter->WriteString(L"\" unselectable=\"on\"/>\n", 22);
|
||||
|
||||
std::wstring sPath = oInfo.m_strDstFilePath + L"\\page" + std::to_wstring(m_lCurDocumentID) + L".vml";
|
||||
CloseFile(sPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
pWriter->WriteString(L"<v:vmlframe clip=\"true\" origin=\"0,0\" size=\"", 43);
|
||||
pWriter->AddSize(100);
|
||||
pWriter->AddIntNoCheck((int)m_lWidth);
|
||||
pWriter->AddCharNoSafe(',');
|
||||
pWriter->AddIntNoCheck((int)m_lHeight);
|
||||
pWriter->WriteString(L"\" src=\"", 7);
|
||||
pWriter->WriteString(oInfo.m_strAdditionalPath);
|
||||
pWriter->WriteString(L"/page", 5);
|
||||
pWriter->AddIntNoCheck(m_lCurDocumentID);
|
||||
pWriter->WriteString(L".vml#page", 9);
|
||||
pWriter->AddIntNoCheck(m_lCurDocumentID);
|
||||
pWriter->WriteString(L"\" unselectable=\"on\"/>\n", 22);
|
||||
|
||||
std::wstring sPath = oInfo.m_strDstFilePath + L"\\page" + std::to_wstring(m_lCurDocumentID) + L".vml";
|
||||
CloseFile(sPath);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _ASC_HTMLRENDERER_VMLWRITER_H_
|
@ -1,760 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef _ASC_HTMLRENDERER_VGW_H_
|
||||
#define _ASC_HTMLRENDERER_VGW_H_
|
||||
|
||||
#include "Common.h"
|
||||
#include "../../DesktopEditor/graphics/GraphicsPath.h"
|
||||
#include <vector>
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
// приходится в html разруливать простую графику.
|
||||
// (линии (горизонтальные/вектикальные), ректы (не повернутые)).
|
||||
// для них не нужно генерить html5-код, который генерит тяжелую картинку
|
||||
// и подгружает ее в память
|
||||
|
||||
const LONG g_lSimpleCommandsCountMax = 100;
|
||||
|
||||
class CVectorGraphicsWriter
|
||||
{
|
||||
public:
|
||||
enum SimpleCommand
|
||||
{
|
||||
scMoveTo = 0,
|
||||
scLineTo = 1,
|
||||
scClose = 2
|
||||
};
|
||||
class CSimpleCommand
|
||||
{
|
||||
public:
|
||||
SimpleCommand m_eType;
|
||||
double m_dX;
|
||||
double m_dY;
|
||||
};
|
||||
|
||||
public:
|
||||
NSStringUtils::CStringBuilder m_oWriterSimpleGraphics;
|
||||
NSStringUtils::CStringBuilder m_oWriterVMLPath;
|
||||
NSStringUtils::CStringBuilder m_oWriterCanvas;
|
||||
NSStringUtils::CStringBuilder m_oWriterVML;
|
||||
|
||||
Aggplus::CGraphicsPathSimpleConverter* m_pSimpleConverter;
|
||||
|
||||
NSStructures::CPen* m_pPen;
|
||||
NSStructures::CBrush* m_pBrush;
|
||||
|
||||
Aggplus::CMatrix* m_pFullTransform;
|
||||
|
||||
double m_dCurrentMoveToX;
|
||||
double m_dCurrentMoveToY;
|
||||
|
||||
bool m_bIsSimpleGraphics;
|
||||
|
||||
public:
|
||||
bool m_bIsSimple;
|
||||
|
||||
bool m_bIsClip;
|
||||
bool m_bIsClipping;
|
||||
|
||||
CSimpleCommand* m_arSimpleCommands;
|
||||
LONG m_lCountSC;
|
||||
|
||||
public:
|
||||
CVectorGraphicsWriter() : m_oWriterVML(), m_oWriterCanvas(), m_oWriterSimpleGraphics(), m_oWriterVMLPath()
|
||||
{
|
||||
m_bIsClip = FALSE;
|
||||
m_bIsClipping = FALSE;
|
||||
|
||||
m_bIsSimple = TRUE;
|
||||
|
||||
m_pSimpleConverter = NULL;
|
||||
|
||||
m_pPen = NULL;
|
||||
m_pBrush = NULL;
|
||||
|
||||
m_pFullTransform = NULL;
|
||||
|
||||
m_dCurrentMoveToX = 0;
|
||||
m_dCurrentMoveToY = 0;
|
||||
|
||||
m_lCountSC = 0;
|
||||
|
||||
m_bIsSimpleGraphics = true;
|
||||
|
||||
m_arSimpleCommands = new CSimpleCommand[g_lSimpleCommandsCountMax];
|
||||
}
|
||||
~CVectorGraphicsWriter()
|
||||
{
|
||||
RELEASEARRAYOBJECTS(m_arSimpleCommands);
|
||||
}
|
||||
|
||||
inline void EndPage()
|
||||
{
|
||||
m_oWriterSimpleGraphics.ClearNoAttack();
|
||||
m_oWriterVMLPath.ClearNoAttack();
|
||||
m_oWriterCanvas.ClearNoAttack();
|
||||
m_oWriterVML.ClearNoAttack();
|
||||
|
||||
m_bIsSimpleGraphics = true;
|
||||
}
|
||||
|
||||
inline void WriteBeginPath()
|
||||
{
|
||||
m_oWriterCanvas.WriteString(L"b(c);\n", 6);
|
||||
}
|
||||
|
||||
inline void WriteEndPath()
|
||||
{
|
||||
m_oWriterVMLPath.ClearNoAttack();
|
||||
|
||||
m_bIsSimple = true;
|
||||
m_lCountSC = 0;
|
||||
}
|
||||
|
||||
void WritePathStart()
|
||||
{
|
||||
m_oWriterCanvas.WriteString(L"b(c);\n", 6);
|
||||
}
|
||||
void WritePathClose()
|
||||
{
|
||||
m_oWriterCanvas.WriteString(L"x(c);\n", 6);
|
||||
|
||||
if (!m_bIsClipping)
|
||||
{
|
||||
m_oWriterVMLPath.AddCharSafe('x');
|
||||
}
|
||||
|
||||
if (m_bIsSimple)
|
||||
{
|
||||
if (0 < m_lCountSC)
|
||||
{
|
||||
m_arSimpleCommands[m_lCountSC].m_eType = scLineTo;
|
||||
m_arSimpleCommands[m_lCountSC].m_dX = m_dCurrentMoveToX;
|
||||
m_arSimpleCommands[m_lCountSC].m_dY = m_dCurrentMoveToY;
|
||||
|
||||
++m_lCountSC;
|
||||
|
||||
if (m_lCountSC == g_lSimpleCommandsCountMax)
|
||||
{
|
||||
m_bIsSimple = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WritePathMoveTo(double& x, double& y)
|
||||
{
|
||||
m_oWriterCanvas.WriteString(L"m(c,", 4);
|
||||
WriteIntsToStringBuilder(round(x), round(y), &m_oWriterCanvas);
|
||||
m_oWriterCanvas.WriteString(L");\n", 3);
|
||||
|
||||
if (!m_bIsClipping)
|
||||
{
|
||||
m_oWriterVMLPath.AddCharSafe('m');
|
||||
WriteIntsToStringBuilder(round(x), round(y), &m_oWriterVMLPath);
|
||||
m_oWriterVMLPath.AddCharSafe(' ');
|
||||
}
|
||||
|
||||
if (m_bIsSimple)
|
||||
{
|
||||
m_arSimpleCommands[m_lCountSC].m_eType = scMoveTo;
|
||||
m_arSimpleCommands[m_lCountSC].m_dX = x;
|
||||
m_arSimpleCommands[m_lCountSC].m_dY = y;
|
||||
|
||||
m_dCurrentMoveToX = x;
|
||||
m_dCurrentMoveToY = y;
|
||||
|
||||
++m_lCountSC;
|
||||
if (m_lCountSC == g_lSimpleCommandsCountMax)
|
||||
{
|
||||
m_bIsSimple = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
void WritePathLineTo(double& x, double& y)
|
||||
{
|
||||
if (0 == m_oWriterVMLPath.GetCurSize())
|
||||
{
|
||||
m_oWriterCanvas.WriteString(L"m(c,", 4);
|
||||
WriteIntsToStringBuilder(round(x), round(y), &m_oWriterCanvas);
|
||||
m_oWriterCanvas.WriteString(L");\n", 3);
|
||||
|
||||
m_oWriterVMLPath.AddCharSafe('m');
|
||||
WriteIntsToStringBuilder(round(x), round(y), &m_oWriterVMLPath);
|
||||
m_oWriterVMLPath.AddCharSafe(' ');
|
||||
}
|
||||
|
||||
m_oWriterCanvas.WriteString(L"l(c,", 4);
|
||||
WriteIntsToStringBuilder(round(x), round(y), &m_oWriterCanvas);
|
||||
m_oWriterCanvas.WriteString(L");\n", 3);
|
||||
|
||||
if (!m_bIsClipping)
|
||||
{
|
||||
m_oWriterVMLPath.AddCharSafe('l');
|
||||
WriteIntsToStringBuilder(round(x), round(y), &m_oWriterVMLPath);
|
||||
m_oWriterVMLPath.AddCharSafe(' ');
|
||||
}
|
||||
|
||||
if (m_bIsSimple)
|
||||
{
|
||||
if (0 == m_lCountSC)
|
||||
{
|
||||
m_arSimpleCommands[m_lCountSC].m_eType = scMoveTo;
|
||||
m_arSimpleCommands[m_lCountSC].m_dX = x;
|
||||
m_arSimpleCommands[m_lCountSC].m_dY = y;
|
||||
|
||||
m_dCurrentMoveToX = x;
|
||||
m_dCurrentMoveToY = y;
|
||||
|
||||
++m_lCountSC;
|
||||
}
|
||||
else
|
||||
{
|
||||
double _x = m_arSimpleCommands[m_lCountSC - 1].m_dX;
|
||||
double _y = m_arSimpleCommands[m_lCountSC - 1].m_dY;
|
||||
|
||||
if ((FABS(_x - x) < 0.01) || (FABS(_y - y) < 0.01))
|
||||
{
|
||||
// продолжаем симпл!
|
||||
m_arSimpleCommands[m_lCountSC].m_eType = scLineTo;
|
||||
m_arSimpleCommands[m_lCountSC].m_dX = x;
|
||||
m_arSimpleCommands[m_lCountSC].m_dY = y;
|
||||
|
||||
++m_lCountSC;
|
||||
|
||||
if (m_lCountSC == g_lSimpleCommandsCountMax)
|
||||
{
|
||||
m_bIsSimple = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void WritePathCurveTo(double& x1, double& y1, double& x2, double& y2, double& x3, double& y3)
|
||||
{
|
||||
if (0 == m_oWriterVMLPath.GetCurSize())
|
||||
{
|
||||
m_oWriterCanvas.WriteString(L"m(c,", 4);
|
||||
WriteIntsToStringBuilder(round(x), round(y), &m_oWriterCanvas);
|
||||
m_oWriterCanvas.WriteString(L");\n", 3);
|
||||
|
||||
m_oWriterVMLPath.AddCharSafe('m');
|
||||
WriteIntsToStringBuilder(round(x), round(y), &m_oWriterVMLPath);
|
||||
m_oWriterVMLPath.AddCharSafe(' ');
|
||||
}
|
||||
|
||||
m_oWriterCanvas.WriteString(L"cu(c,", 5);
|
||||
WriteIntsToStringBuilder(round(x1), round(y1), round(x2), round(y2), round(x3), round(y3), &m_oWriterCanvas);
|
||||
m_oWriterCanvas.WriteString(L");\n", 3);
|
||||
|
||||
if (!m_bIsClipping)
|
||||
{
|
||||
m_oWriterVMLPath.AddCharSafe('c');
|
||||
WriteIntsToStringBuilder(round(x1), round(y1), round(x2), round(y2), round(x3), round(y3), &m_oWriterVMLPath);
|
||||
m_oWriterVMLPath.AddCharSafe(' ');
|
||||
}
|
||||
|
||||
m_bIsSimple = false;
|
||||
}
|
||||
void WriteDrawPath(LONG lType, LONG lIDTx, LONG& lCurTxNumber, LONG& lPageNumber)
|
||||
{
|
||||
if (m_bIsSimple && (-1 == lIDTx))
|
||||
{
|
||||
// пишем по-крутому
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
double w = 0;
|
||||
double h = 0;
|
||||
|
||||
bool bIsRect = IsRect(x, y, w, h);
|
||||
|
||||
if (bIsRect)
|
||||
{
|
||||
if ((0 == w && 0 == h))
|
||||
return;
|
||||
|
||||
w = max(1, w);
|
||||
h = max(1, h);
|
||||
|
||||
if (bIsRect)
|
||||
{
|
||||
CString strLineColor = GetStringColor(m_pPen->Color);
|
||||
CString strFillColor = GetStringColor(m_pBrush->Color1);
|
||||
|
||||
if (0 == m_pBrush->Alpha1)
|
||||
strFillColor = _T("transparent");
|
||||
|
||||
if ((1 >= w) || (1 >= h) && (lType < 0xFF))
|
||||
{
|
||||
m_oWriterSimpleGraphics.WriteString(L"<div class=\"rt\" style=\"border-width: 0px; background-color: ", 60);
|
||||
SetStringColor(m_pPen->Color, &m_oWriterSimpleGraphics);
|
||||
m_oWriterSimpleGraphics.WriteString(L"; border-color: ", 16);
|
||||
SetStringColor(m_pPen->Color, &m_oWriterSimpleGraphics);
|
||||
m_oWriterSimpleGraphics.WriteString(L"; opacity:", 10);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheckDel100(100 * m_pPen->Alpha / 255);
|
||||
m_oWriterSimpleGraphics.AddSize(100);
|
||||
m_oWriterSimpleGraphics.WriteString(L"; left: ", 8);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheck(round(x));
|
||||
m_oWriterSimpleGraphics.WriteString(L"px; top: ", 9);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheck(round(y));
|
||||
m_oWriterSimpleGraphics.WriteString(L"px; width: ", 11);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheck(round(w));
|
||||
m_oWriterSimpleGraphics.WriteString(L"px; height: ", 12);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheck(round(h));
|
||||
m_oWriterSimpleGraphics.WriteString(L"px;\"></div>\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0x00 == (lType & 0xFF))
|
||||
{
|
||||
m_oWriterSimpleGraphics.WriteString(L"<div class=\"rt\" style=\"border-width: 0px; background-color: ", 60);
|
||||
if (0 == m_pBrush->Alpha1)
|
||||
m_oWriterSimpleGraphics.WriteString(L"transparent", 11);
|
||||
else
|
||||
SetStringColor(m_pBrush->Color1, &m_oWriterSimpleGraphics);
|
||||
m_oWriterSimpleGraphics.WriteString(L"; border-color: ", 16);
|
||||
SetStringColor(m_pPen->Color, &m_oWriterSimpleGraphics);
|
||||
m_oWriterSimpleGraphics.WriteString(L"; opacity:", 10);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheckDel100(100 * m_pBrush->Alpha1 / 255);
|
||||
m_oWriterSimpleGraphics.AddSize(100);
|
||||
m_oWriterSimpleGraphics.WriteString(L"; left: ", 8);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheck(round(x));
|
||||
m_oWriterSimpleGraphics.WriteString(L"px; top: ", 9);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheck(round(y));
|
||||
m_oWriterSimpleGraphics.WriteString(L"px; width: ", 11);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheck(round(w));
|
||||
m_oWriterSimpleGraphics.WriteString(L"px; height: ", 12);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheck(round(h));
|
||||
m_oWriterSimpleGraphics.WriteString(L"px;\"></div>\n");
|
||||
}
|
||||
else if (lType < 0xFF)
|
||||
{
|
||||
m_oWriterSimpleGraphics.WriteString(L"<div class=\"rt\" style=\"border-width: 1px; background-color: ", 60);
|
||||
if (0 == m_pBrush->Alpha1)
|
||||
m_oWriterSimpleGraphics.WriteString(L"transparent", 11);
|
||||
else
|
||||
SetStringColor(m_pBrush->Color1, &m_oWriterSimpleGraphics);
|
||||
m_oWriterSimpleGraphics.WriteString(L"; border-color: ", 16);
|
||||
SetStringColor(m_pPen->Color, &m_oWriterSimpleGraphics);
|
||||
m_oWriterSimpleGraphics.WriteString(L"; opacity:", 10);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheckDel100(100 * m_pPen->Alpha / 255);
|
||||
m_oWriterSimpleGraphics.AddSize(100);
|
||||
m_oWriterSimpleGraphics.WriteString(L"; left: ", 8);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheck(round(x));
|
||||
m_oWriterSimpleGraphics.WriteString(L"px; top: ", 9);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheck(round(y));
|
||||
m_oWriterSimpleGraphics.WriteString(L"px; width: ", 11);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheck(round(w));
|
||||
m_oWriterSimpleGraphics.WriteString(L"px; height: ", 12);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheck(round(h));
|
||||
m_oWriterSimpleGraphics.WriteString(L"px;\"></div>\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oWriterSimpleGraphics.WriteString(L"<div class=\"rt\" style=\"border-width: 1px; background-color: ", 60);
|
||||
if (0 == m_pBrush->Alpha1)
|
||||
m_oWriterSimpleGraphics.WriteString(L"transparent", 11);
|
||||
else
|
||||
SetStringColor(m_pBrush->Color1, &m_oWriterSimpleGraphics);
|
||||
m_oWriterSimpleGraphics.WriteString(L"; border-color: ", 16);
|
||||
SetStringColor(m_pPen->Color, &m_oWriterSimpleGraphics);
|
||||
m_oWriterSimpleGraphics.WriteString(L"; opacity:", 10);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheckDel100(100 * m_pBrush->Alpha1 / 255);
|
||||
m_oWriterSimpleGraphics.AddSize(100);
|
||||
m_oWriterSimpleGraphics.WriteString(L"; left: ", 8);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheck(round(x));
|
||||
m_oWriterSimpleGraphics.WriteString(L"px; top: ", 9);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheck(round(y));
|
||||
m_oWriterSimpleGraphics.WriteString(L"px; width: ", 11);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheck(round(w));
|
||||
m_oWriterSimpleGraphics.WriteString(L"px; height: ", 12);
|
||||
m_oWriterSimpleGraphics.AddIntNoCheck(round(h));
|
||||
m_oWriterSimpleGraphics.WriteString(L"px;\"></div>\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bIsSimpleGraphics = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bIsSimpleGraphics = false;
|
||||
}
|
||||
|
||||
std::wstring strStroked = L"false";
|
||||
std::wstring strFilled = L"false";
|
||||
|
||||
//if (0x00 != (0x02 & (lType >> 8)) && ((lType & 0xFF) == 0x00))
|
||||
//{
|
||||
// lType = 1;
|
||||
// m_pPen->Color = m_pBrush->Color1;
|
||||
// m_pPen->Alpha = m_pBrush->Alpha1;
|
||||
//}
|
||||
|
||||
bool bStroke = false;
|
||||
|
||||
if (m_pPen->Alpha == 0)
|
||||
lType &= 0xFF00;
|
||||
|
||||
if ((-1 == lIDTx) && (0 == m_pBrush->Alpha1))
|
||||
lType &= 0xFF;
|
||||
|
||||
// canvas
|
||||
if ((lType & 0x01) == 0x01)
|
||||
{
|
||||
SetStrokeColor(m_pPen->Color, m_pPen->Alpha, &m_oWriterCanvas);
|
||||
|
||||
bStroke = true;
|
||||
|
||||
if (0x00 != m_pPen->Alpha)
|
||||
{
|
||||
strStroked = L"true";
|
||||
}
|
||||
}
|
||||
if (lType > 0x01)
|
||||
{
|
||||
if (-1 != lIDTx)
|
||||
{
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
double w = 0;
|
||||
double h = 0;
|
||||
|
||||
m_pSimpleConverter->PathCommandGetBounds(&x, &y, &w, &h);
|
||||
|
||||
double r = x + w;
|
||||
double b = y + h;
|
||||
|
||||
m_pFullTransform->TransformPoint(x, y);
|
||||
m_pFullTransform->TransformPoint(r, b);
|
||||
|
||||
w = r - x;
|
||||
h = b - y;
|
||||
|
||||
m_oWriterCanvas.WriteString(L"img", 3);
|
||||
m_oWriterCanvas.AddInt(lIDTx);
|
||||
m_oWriterCanvas.WriteString(L".src = \"media\\\\image", 20);
|
||||
m_oWriterCanvas.AddInt(lIDTx);
|
||||
m_oWriterCanvas.WriteString(L".jpg\";img", 9);
|
||||
m_oWriterCanvas.AddInt(lIDTx);
|
||||
m_oWriterCanvas.WriteString(L".onload = function(){c.drawImage(img", 36);
|
||||
WriteIntsToStringBuilder(lIDTx, round(x), round(y), round(w), round(h), &m_oWriterCanvas);
|
||||
m_oWriterCanvas.WriteString(L");drawpage", 10);
|
||||
m_oWriterCanvas.AddInt(lPageNumber);
|
||||
m_oWriterCanvas.AddCharSafe('_');
|
||||
m_oWriterCanvas.AddInt(lCurTxNumber);
|
||||
m_oWriterCanvas.WriteString(L"(c);};\n}\nfunction drawpage", 26);
|
||||
m_oWriterCanvas.AddInt(lPageNumber);
|
||||
m_oWriterCanvas.AddCharSafe('_');
|
||||
m_oWriterCanvas.AddInt(lCurTxNumber);
|
||||
m_oWriterCanvas.WriteString(L"(c)\n{\n", 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFillColor(m_pBrush->Color1, m_pBrush->Alpha1, &m_oWriterCanvas);
|
||||
m_oWriterCanvas.WriteString(L"f(c);\n", 6);
|
||||
}
|
||||
|
||||
strFilled = L"true";
|
||||
}
|
||||
|
||||
if (bStroke)
|
||||
{
|
||||
m_oWriterCanvas.WriteString(L"s(c);\n", 6);
|
||||
}
|
||||
|
||||
if (-1 != lIDTx)
|
||||
{
|
||||
m_oWriterVML.WriteString(L"<v:shape style=\"position:absolute; width:1; height:1\" coordsize=\"1 1\" stroked=\"", 79);
|
||||
m_oWriterVML.WriteString(strStroked);
|
||||
m_oWriterVML.WriteString(L"\" strokecolor=\"", 15);
|
||||
m_oWriterVML.WriteHexColor3(ConvertColor(m_pPen->Color));
|
||||
m_oWriterVML.WriteString(L"\" filled=\"", 10);
|
||||
m_oWriterVML.WriteString(strFilled);
|
||||
m_oWriterVML.WriteString(L"\" path=\"", 8);
|
||||
m_oWriterVML.Write(m_oWriterVMLPath);
|
||||
m_oWriterVML.WriteString(L"\"><v:fill src=\"media\\image", 26);
|
||||
m_oWriterVML.AddInt(lIDTx);
|
||||
m_oWriterVML.WriteString(L".jpg\" type=\"frame\" opacity=\"", 28);
|
||||
m_oWriterVML.AddIntDel100(100 * m_pBrush->Alpha1 / 255);
|
||||
m_oWriterVML.WriteString(L"\"/></v:shape>\n", 14);
|
||||
|
||||
}
|
||||
else if (0xFF == m_pBrush->Alpha1)
|
||||
{
|
||||
m_oWriterVML.WriteString(L"<v:shape style=\"position:absolute; width:1; height:1\" coordsize=\"1 1\" stroked=\"", 79);
|
||||
m_oWriterVML.WriteString(strStroked);
|
||||
m_oWriterVML.WriteString(L"\" strokecolor=\"", 15);
|
||||
m_oWriterVML.WriteHexColor3(ConvertColor(m_pPen->Color));
|
||||
m_oWriterVML.WriteString(L"\" filled=\"", 10);
|
||||
m_oWriterVML.WriteString(strFilled);
|
||||
m_oWriterVML.WriteString(L"\" fillcolor=\"", 13);
|
||||
m_oWriterVML.WriteHexColor3(ConvertColor(m_pBrush->Color1));
|
||||
m_oWriterVML.WriteString(L"\" path=\"", 8);
|
||||
m_oWriterVML.Write(m_oWriterVMLPath);
|
||||
m_oWriterVML.WriteString(L"\" />\n", 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oWriterVML.WriteString(L"<v:shape style=\"position:absolute; width:1; height:1\" coordsize=\"1 1\" stroked=\"", 79);
|
||||
m_oWriterVML.WriteString(strStroked);
|
||||
m_oWriterVML.WriteString(L"\" strokecolor=\"", 15);
|
||||
m_oWriterVML.WriteHexColor3(ConvertColor(m_pPen->Color));
|
||||
m_oWriterVML.WriteString(L"\" filled=\"", 10);
|
||||
m_oWriterVML.WriteString(strFilled);
|
||||
m_oWriterVML.WriteString(L"\" fillcolor=\"", 13);
|
||||
m_oWriterVML.WriteHexColor3(ConvertColor(m_pBrush->Color1));
|
||||
m_oWriterVML.WriteString(L"\" path=\"", 8);
|
||||
m_oWriterVML.Write(m_oWriterVMLPath);
|
||||
m_oWriterVML.WriteString(L"\"><v:fill opacity=\"", 19);
|
||||
m_oWriterVML.AddIntDel100(100 * m_pBrush->Alpha1 / 255);
|
||||
m_oWriterVML.WriteString(L"\"/></v:shape>\n", 14);
|
||||
}
|
||||
m_oWriterVML.WriteString(strVML);
|
||||
|
||||
if (-1 != lIDTx)
|
||||
{
|
||||
++lCurTxNumber;
|
||||
}
|
||||
}
|
||||
|
||||
void WritePathClip()
|
||||
{
|
||||
m_bIsClipping = true;
|
||||
}
|
||||
void WritePathClipEnd()
|
||||
{
|
||||
m_bIsClipping = false;
|
||||
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
double w = 0;
|
||||
double h = 0;
|
||||
|
||||
m_pSimpleConverter->PathCommandGetBounds(&x, &y, &w, &h);
|
||||
if ((0 > w) || (0 > h))
|
||||
{
|
||||
// никакого клипа нет!
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_bIsClip)
|
||||
{
|
||||
m_oWriterCanvas.WriteString(L"c.save();\n", 10);
|
||||
}
|
||||
m_bIsClip = true;
|
||||
m_oWriterCanvas.WriteString(L"c.clip();\n", 10);
|
||||
}
|
||||
}
|
||||
void WritePathResetClip()
|
||||
{
|
||||
if (m_bIsClip)
|
||||
{
|
||||
m_oWriterCanvas.WriteString(L"c.restore();\n", 13);
|
||||
}
|
||||
|
||||
m_bIsClip = false;
|
||||
m_bIsClipping = false;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
bool IsRect(double& x, double& y, double& w, double& h)
|
||||
{
|
||||
if (1 >= m_lCountSC)
|
||||
return false;
|
||||
|
||||
double dPrevX = m_arSimpleCommands[0].m_dX;
|
||||
double dPrevY = m_arSimpleCommands[0].m_dY;
|
||||
|
||||
long lCurDirection = 0;
|
||||
|
||||
std::vector<double> arX;
|
||||
std::vector<double> arY;
|
||||
|
||||
arX.push_back(dPrevX);
|
||||
arY.push_back(dPrevY);
|
||||
|
||||
double dXmin = dPrevX;
|
||||
double dXmax = dPrevX;
|
||||
double dYmin = dPrevY;
|
||||
double dYmax = dPrevY;
|
||||
|
||||
double _dX = m_arSimpleCommands[m_lCountSC - 1].m_dX;
|
||||
double _dY = m_arSimpleCommands[m_lCountSC - 1].m_dY;
|
||||
|
||||
for (LONG i = 1; i < m_lCountSC; ++i)
|
||||
{
|
||||
CSimpleCommand* pComm = &m_arSimpleCommands[i];
|
||||
|
||||
if (scLineTo != pComm->m_eType)
|
||||
return false;
|
||||
|
||||
long lDir = SkipCurDirection(lCurDirection, i, dPrevX, dPrevY);
|
||||
|
||||
double dX = _dX;
|
||||
double dY = _dY;
|
||||
|
||||
if (i < m_lCountSC)
|
||||
{
|
||||
dX = m_arSimpleCommands[i - 1].m_dX;
|
||||
dY = m_arSimpleCommands[i - 1].m_dY;
|
||||
}
|
||||
|
||||
if (dX > dXmax)
|
||||
dXmax = dX;
|
||||
else if (dX < dXmin)
|
||||
dXmin = dX;
|
||||
|
||||
if (dY > dYmax)
|
||||
dYmax = dY;
|
||||
else if (dY < dYmin)
|
||||
dYmin = dY;
|
||||
|
||||
arX.push_back(dX);
|
||||
arY.push_back(dY);
|
||||
|
||||
lCurDirection = lDir;
|
||||
}
|
||||
|
||||
// все, массивы заполнены.
|
||||
// теперь осталось определить, рект ли это
|
||||
// должно:
|
||||
// 1) кроме минимумов и максимумов ничего не может быть.
|
||||
// 2) все точки ректа должны присутствовать
|
||||
|
||||
bool b1 = false;
|
||||
bool b2 = false;
|
||||
bool b3 = false;
|
||||
bool b4 = false;
|
||||
|
||||
int lCount = (int)arX.size();
|
||||
for (int i = 0; i < lCount; ++i)
|
||||
{
|
||||
double ___x = arX[i];
|
||||
double ___y = arY[i];
|
||||
bool bBreak = false;
|
||||
|
||||
if (IsEqualPoint(___x, ___y, dXmin, dYmin))
|
||||
b1 = true;
|
||||
else if (IsEqualPoint(___x, ___y, dXmax, dYmin))
|
||||
b2 = true;
|
||||
else if (IsEqualPoint(___x, ___y, dXmin, dYmax))
|
||||
b4 = true;
|
||||
else if (IsEqualPoint(___x, ___y, dXmax, dYmax))
|
||||
b3 = true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
x = dXmin;
|
||||
y = dYmin;
|
||||
w = dXmax - dXmin;
|
||||
h = dYmax - dYmin;
|
||||
|
||||
if (b1 && b2 && !b3 && !b4)
|
||||
return true;
|
||||
if (b1 && !b2 && !b3 && b4)
|
||||
return true;
|
||||
if (!b1 && b2 && b3 && !b4)
|
||||
return true;
|
||||
if (!b1 && !b2 && b3 && b4)
|
||||
return true;
|
||||
if (b1 && b2 && b3 && b4)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// direction: (0 - вправо, 1 - вниз, 2 - влево, 3 - вверх)
|
||||
inline long SkipCurDirection(const long& lDirection, long& lIndexCur, double& dPrevX, double& dPrevY)
|
||||
{
|
||||
for (; lIndexCur < m_lCountSC; ++lIndexCur)
|
||||
{
|
||||
long lDir = GetCurDirection(lIndexCur, dPrevX, dPrevY);
|
||||
|
||||
dPrevX = m_arSimpleCommands[lIndexCur].m_dX;
|
||||
dPrevY = m_arSimpleCommands[lIndexCur].m_dY;
|
||||
|
||||
if ((-1 == lDir) || (lDir == lDirection))
|
||||
continue;
|
||||
|
||||
return lDir;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
inline long GetCurDirection(const long& lIndex, const double& dPrevX, const double& dPrevY)
|
||||
{
|
||||
double x = m_arSimpleCommands[lIndex].m_dX;
|
||||
double y = m_arSimpleCommands[lIndex].m_dY;
|
||||
|
||||
if (FABS(y - dPrevY) < 0.01)
|
||||
{
|
||||
if (FABS(x - dPrevX) < 0.01)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (x >= dPrevX) ? 0 : 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (y >= dPrevY) ? 1 : 3;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool IsEqualPoint(double& x, double&y, double& _x, double& _y)
|
||||
{
|
||||
if ((FABS(x - _x) < 0.1) && (FABS(y - _y) < 0.1))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsTwoRectOneDirection()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
LONG SkipRect(LONG& lStart, LONG& lEnd)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _ASC_HTMLRENDERER_VGW_H_
|
@ -1,349 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef _ASC_HTMLRENDERER_VGW2_H_
|
||||
#define _ASC_HTMLRENDERER_VGW2_H_
|
||||
|
||||
#include "Common.h"
|
||||
#include "SVGWriter.h"
|
||||
#include "VMLWriter.h"
|
||||
#include "../../DesktopEditor/graphics/GraphicsPath.h"
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
class CVectorGraphicsWriter
|
||||
{
|
||||
public:
|
||||
CSVGWriter m_oSVG;
|
||||
CVMLWriter m_oVML;
|
||||
//CCanvasWriter m_oCanvas;
|
||||
|
||||
Aggplus::CGraphicsPathSimpleConverter* m_pSimpleConverter;
|
||||
|
||||
NSStructures::CPen* m_pPen;
|
||||
NSStructures::CBrush* m_pBrush;
|
||||
|
||||
Aggplus::CMatrix* m_pFullTransform;
|
||||
|
||||
LONG m_lCurrentObjectInPage;
|
||||
|
||||
LONG m_lCurrentPageNumber;
|
||||
double m_dWidth;
|
||||
double m_dHeight;
|
||||
|
||||
public:
|
||||
CVectorGraphicsWriter() : m_oSVG(), m_oVML()/*, m_oCanvas()*/
|
||||
{
|
||||
m_pSimpleConverter = NULL;
|
||||
m_lCurrentObjectInPage = 0;
|
||||
}
|
||||
~CVectorGraphicsWriter()
|
||||
{
|
||||
}
|
||||
|
||||
void SetSettings(NSStructures::CPen* pPen, NSStructures::CBrush* pBrush, Aggplus::CGraphicsPathSimpleConverter* pSimpleConverter)
|
||||
{
|
||||
m_pPen = pPen;
|
||||
m_pBrush = pBrush;
|
||||
m_pSimpleConverter = pSimpleConverter;
|
||||
|
||||
m_oSVG.SetSettings(m_pPen, m_pBrush);
|
||||
m_oVML.SetSettings(m_pPen, m_pBrush);
|
||||
//m_oCanvas.SetSettings(m_pPen, m_pBrush, m_pSimpleConverter);
|
||||
}
|
||||
|
||||
|
||||
inline void NewPage(double& dW, double& dH, const LONG& lPageNumber)
|
||||
{
|
||||
m_lCurrentPageNumber = lPageNumber;
|
||||
m_dWidth = dW;
|
||||
m_dHeight = dH;
|
||||
|
||||
m_oSVG.NewDocument(m_dWidth, m_dHeight, m_lCurrentPageNumber);
|
||||
m_oVML.NewDocument(m_dWidth, m_dHeight, m_lCurrentPageNumber);
|
||||
}
|
||||
inline void EndPage()
|
||||
{
|
||||
m_oSVG.CloseFile();
|
||||
m_oVML.CloseFile();
|
||||
//m_oCanvas.CloseFile();
|
||||
|
||||
m_lCurrentObjectInPage = 0;
|
||||
}
|
||||
|
||||
inline void WriteEndPath()
|
||||
{
|
||||
m_oSVG.WritePathEnd();
|
||||
m_oVML.WritePathEnd();
|
||||
//m_oCanvas.WritePathEnd();
|
||||
}
|
||||
|
||||
inline void WritePathStart()
|
||||
{
|
||||
m_oSVG.WritePathStart();
|
||||
m_oVML.WritePathStart();
|
||||
//m_oCanvas.WritePathStart();
|
||||
}
|
||||
inline void WritePathClose()
|
||||
{
|
||||
m_oSVG.WritePathClose();
|
||||
m_oVML.WritePathClose();
|
||||
//m_oCanvas.WritePathClose();
|
||||
}
|
||||
|
||||
inline void WritePathMoveTo(double& x, double& y)
|
||||
{
|
||||
m_oSVG.WritePathMoveTo(x, y);
|
||||
m_oVML.WritePathMoveTo(x, y);
|
||||
//m_oCanvas.WritePathMoveTo(x,y);
|
||||
}
|
||||
inline void WritePathLineTo(double& x, double& y)
|
||||
{
|
||||
m_oSVG.WritePathLineTo(x, y);
|
||||
m_oVML.WritePathLineTo(x, y);
|
||||
//m_oCanvas.WritePathLineTo(x, y);
|
||||
}
|
||||
inline void WritePathCurveTo(double& x1, double& y1, double& x2, double& y2, double& x3, double& y3)
|
||||
{
|
||||
m_oSVG.WritePathCurveTo(x1, y1, x2, y2, x3, y3);
|
||||
m_oVML.WritePathCurveTo(x1, y1, x2, y2, x3, y3);
|
||||
//m_oCanvas.WritePathCurveTo(x1, y1, x2, y2, x3, y3);
|
||||
}
|
||||
inline void WriteDrawPath(LONG lType, CImageInfo& oInfo, const double& dAngle)
|
||||
{
|
||||
// вот мега заглушка под некоторые таблицы из pdf
|
||||
// проблема в том, что приходит path нулевой толщины - а след-но он не рисуется.
|
||||
// здесь это отслеживаем и правим пат. Не очень хорошо, так как всякие пунктирности
|
||||
// в таких патах - теряются при таком подходе
|
||||
if (0x00 == (lType & 0xFF))
|
||||
{
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
double r = 0;
|
||||
double b = 0;
|
||||
m_pSimpleConverter->PathCommandGetBounds(x, y, r, b);
|
||||
|
||||
r += x;
|
||||
b += y;
|
||||
|
||||
if ((fabs(r - x) < 0.5) || (fabs(b - y) < 0.5))
|
||||
{
|
||||
m_pFullTransform->TransformPoint(x, y);
|
||||
m_pFullTransform->TransformPoint(r, b);
|
||||
|
||||
int _x = round(x);
|
||||
int _y = round(y);
|
||||
int _r = round(r);
|
||||
int _b = round(b);
|
||||
|
||||
if ((_x == _r) || (_y == _b))
|
||||
{
|
||||
LONG lPenColor = m_pPen->Color;
|
||||
LONG lPenAlpha = m_pPen->Alpha;
|
||||
double dPenW = m_pPen->Size;
|
||||
|
||||
m_pPen->Color = m_pBrush->Color1;
|
||||
m_pPen->Alpha = m_pBrush->Alpha1;
|
||||
m_pPen->Size = c_ag_1pxWidth;
|
||||
|
||||
WriteEndPath();
|
||||
WritePathStart();
|
||||
WritePathMoveTo(x, y);
|
||||
WritePathLineTo(r, b);
|
||||
|
||||
WriteDrawPath(0x01, oInfo, dAngle);
|
||||
|
||||
m_pPen->Color = lPenColor;
|
||||
m_pPen->Alpha = lPenAlpha;
|
||||
m_pPen->Size = dPenW;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_oSVG.WriteDrawPath(lType, m_pFullTransform, m_pSimpleConverter, oInfo, dAngle);
|
||||
m_oVML.WriteDrawPath(lType, m_pFullTransform, m_pSimpleConverter, oInfo, dAngle);
|
||||
|
||||
m_pSimpleConverter->PathCommandEnd();
|
||||
//m_oCanvas.WriteDrawPath(lType, m_pFullTransform, m_pSimpleConverter, lIdTx);
|
||||
}
|
||||
|
||||
inline void WritePathClip()
|
||||
{
|
||||
m_oSVG.WritePathClip();
|
||||
m_oVML.WritePathClip();
|
||||
//m_oCanvas.WritePathClip();
|
||||
}
|
||||
inline void WritePathClipEnd()
|
||||
{
|
||||
m_oSVG.WritePathClipEnd();
|
||||
m_oVML.WritePathClipEnd();
|
||||
//m_oCanvas.WritePathClipEnd();
|
||||
}
|
||||
inline void SetClipMode(LONG lClipMode)
|
||||
{
|
||||
m_oSVG.m_lClipMode = lClipMode;
|
||||
m_oVML.m_lClipMode = lClipMode;
|
||||
}
|
||||
inline void WriteImage(double& x, double& y, double& width, double& height, CImageInfo& oInfo, double dAngle)
|
||||
{
|
||||
m_oSVG.WriteImage(oInfo, x, y, width, height, dAngle);
|
||||
m_oVML.WriteImage(oInfo, x, y, width, height, dAngle);
|
||||
}
|
||||
inline void WritePathResetClip()
|
||||
{
|
||||
m_oSVG.WritePathResetClip();
|
||||
m_oVML.WritePathResetClip();
|
||||
//m_oCanvas.WritePathResetClip();
|
||||
}
|
||||
|
||||
inline bool IsGraphics()
|
||||
{
|
||||
// 10 цифр на номер страницы
|
||||
// LEN(<xml xmlns:v=\"urn:schemas-microsoft-com:vml\">\n<v:group id=\"page%d\" style=\"position: absolute; width:1; height:1;\" coordsize=\"1 1\">\n) = 131
|
||||
return ((131 + 10) < (int)m_oVML.m_oDocument.GetCurSize());
|
||||
}
|
||||
|
||||
inline void WriteToDocument(NSStringUtils::CStringBuilder* pDocument, const CDstInfo& oInfo)
|
||||
{
|
||||
m_oSVG.WriteToMainHtml_1(pDocument, oInfo);
|
||||
m_oVML.WriteToMainHtml(pDocument, oInfo);
|
||||
m_oSVG.WriteToMainHtml_2(pDocument);
|
||||
}
|
||||
};
|
||||
|
||||
class CSVGGraphicsWriter
|
||||
{
|
||||
public:
|
||||
CSVGWriter m_oSVG;
|
||||
Aggplus::CGraphicsPathSimpleConverter* m_pSimpleConverter;
|
||||
|
||||
NSStructures::CPen* m_pPen;
|
||||
NSStructures::CBrush* m_pBrush;
|
||||
|
||||
Aggplus::CMatrix* m_pFullTransform;
|
||||
|
||||
double m_dWidth;
|
||||
double m_dHeight;
|
||||
|
||||
public:
|
||||
CSVGGraphicsWriter() : m_oSVG()
|
||||
{
|
||||
m_pSimpleConverter = NULL;
|
||||
}
|
||||
~CSVGGraphicsWriter()
|
||||
{
|
||||
}
|
||||
|
||||
void SetSettings(NSStructures::CPen* pPen, NSStructures::CBrush* pBrush, Aggplus::CGraphicsPathSimpleConverter* pSimpleConverter)
|
||||
{
|
||||
m_pPen = pPen;
|
||||
m_pBrush = pBrush;
|
||||
m_pSimpleConverter = pSimpleConverter;
|
||||
|
||||
m_oSVG.SetSettings(m_pPen, m_pBrush);
|
||||
}
|
||||
|
||||
|
||||
inline void NewPage(double& dW, double& dH)
|
||||
{
|
||||
m_dWidth = dW;
|
||||
m_dHeight = dH;
|
||||
}
|
||||
inline void EndPage()
|
||||
{
|
||||
m_oSVG.CloseFile();
|
||||
}
|
||||
|
||||
inline void WriteEndPath()
|
||||
{
|
||||
m_oSVG.WritePathEnd();
|
||||
}
|
||||
|
||||
inline void WritePathStart()
|
||||
{
|
||||
m_oSVG.WritePathStart();
|
||||
}
|
||||
inline void WritePathClose()
|
||||
{
|
||||
m_oSVG.WritePathClose();
|
||||
}
|
||||
|
||||
inline void WritePathMoveTo(double& x, double& y)
|
||||
{
|
||||
m_oSVG.WritePathMoveTo(x, y);
|
||||
}
|
||||
inline void WritePathLineTo(double& x, double& y)
|
||||
{
|
||||
m_oSVG.WritePathLineTo(x, y);
|
||||
}
|
||||
inline void WritePathCurveTo(double& x1, double& y1, double& x2, double& y2, double& x3, double& y3)
|
||||
{
|
||||
m_oSVG.WritePathCurveTo(x1, y1, x2, y2, x3, y3);
|
||||
}
|
||||
inline void WriteDrawPath(LONG lType)
|
||||
{
|
||||
CImageInfo oInfo;
|
||||
m_oSVG.WriteDrawPath(lType, m_pFullTransform, m_pSimpleConverter, oInfo, 0.0);
|
||||
m_pSimpleConverter->PathCommandEnd();
|
||||
}
|
||||
|
||||
inline void WritePathClip()
|
||||
{
|
||||
m_oSVG.WritePathClip();
|
||||
}
|
||||
inline void WritePathClipEnd()
|
||||
{
|
||||
m_oSVG.WritePathClipEnd();
|
||||
}
|
||||
inline void SetClipMode(LONG lClipMode)
|
||||
{
|
||||
m_oSVG.m_lClipMode = lClipMode;
|
||||
}
|
||||
inline void WriteImage(double& x, double& y, double& width, double& height, CImageInfo& oInfo, double dAngle)
|
||||
{
|
||||
m_oSVG.WriteImage(oInfo, x, y, width, height, dAngle);
|
||||
}
|
||||
inline void WritePathResetClip()
|
||||
{
|
||||
m_oSVG.WritePathResetClip();
|
||||
}
|
||||
|
||||
inline bool IsGraphics()
|
||||
{
|
||||
// 10 цифр на номер страницы
|
||||
// LEN(<xml xmlns:v=\"urn:schemas-microsoft-com:vml\">\n<v:group id=\"page%d\" style=\"position: absolute; width:1; height:1;\" coordsize=\"1 1\">\n) = 131
|
||||
return ((131 + 10) < (int)m_oSVG.m_oDocument.GetCurSize());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _ASC_HTMLRENDERER_VGW2_H_
|
File diff suppressed because it is too large
Load Diff
@ -1,228 +0,0 @@
|
||||
<?xml version="1.0" encoding="windows-1251"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Name="HtmlRenderer_vs2005"
|
||||
ProjectGUID="{811FE980-5E2F-4B34-8EEC-5589FE6EC86F}"
|
||||
RootNamespace="HtmlRenderer_vs2005"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\DesktopEditor\agg-2.4\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="2"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\src\ASCSVGWriter.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\HTMLRenderer3.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\include\ASCSVGWriter.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\CanvasWriter.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\Common.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\Common2.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\Document.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\FontManager.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\FontManagerBase.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\HTMLRenderer3.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\SVGWriter.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\SVGWriter2.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\Text.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\VectorGraphicsWriter.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\VectorGraphicsWriter2.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\VMLWriter.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\Writer.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
@ -1,422 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
//#include <QCoreApplication>
|
||||
|
||||
#include "../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
#include "../../DesktopEditor/graphics/pro/Graphics.h"
|
||||
#include "../../DesktopEditor/fontengine/ApplicationFontsWorker.h"
|
||||
|
||||
#include "../../DjVuFile/DjVu.h"
|
||||
#include "../../XpsFile/XpsFile.h"
|
||||
#include "../../PdfFile/PdfFile.h"
|
||||
#include "../include/HTMLRenderer3.h"
|
||||
|
||||
#include "../../DesktopEditor/raster/BgraFrame.h"
|
||||
#include "../../DesktopEditor/common/Directory.h"
|
||||
|
||||
#include "../include/ASCSVGWriter.h"
|
||||
|
||||
#include "../../Common/Network/FileTransporter/include/FileTransporter.h"
|
||||
|
||||
|
||||
void Download_OnComplete(int error)
|
||||
{
|
||||
int y = error;
|
||||
return;
|
||||
}
|
||||
|
||||
//#define RASTER_TEST
|
||||
//#define METAFILE_TEST
|
||||
//#define METAFILE_TEST_X2T
|
||||
//#define METAFILE_TEST_RASTER
|
||||
#define ONLINE_WORD_TO_PDF
|
||||
//#define TO_PDF
|
||||
//#define TO_HTML_RENDERER
|
||||
//#define ONLY_TEXT
|
||||
//#define DOWNLOADER_TEST
|
||||
|
||||
#include "Windows.h"
|
||||
#include <wininet.h>
|
||||
#undef CreateDirectory
|
||||
|
||||
bool DownloadFilePS(const std::wstring& sFileURL, const std::wstring& strFileOutput)
|
||||
{
|
||||
STARTUPINFO sturtupinfo;
|
||||
ZeroMemory(&sturtupinfo,sizeof(STARTUPINFO));
|
||||
sturtupinfo.cb = sizeof(STARTUPINFO);
|
||||
|
||||
std::wstring sFileDst = strFileOutput;
|
||||
size_t posn = 0;
|
||||
while (std::wstring::npos != (posn = sFileDst.find('\\', posn)))
|
||||
{
|
||||
sFileDst.replace(posn, 1, L"/");
|
||||
posn += 1;
|
||||
}
|
||||
|
||||
std::wstring sApp = L"powershell.exe –c \"(new-object System.Net.WebClient).DownloadFile('" + sFileURL + L"','" + sFileDst + L"')\"";
|
||||
|
||||
wchar_t* pCommandLine = new wchar_t[sApp.length() + 1];
|
||||
memcpy(pCommandLine, sApp.c_str(), sApp.length() * sizeof(wchar_t));
|
||||
pCommandLine[sApp.length()] = (wchar_t)'\0';
|
||||
|
||||
HANDLE ghJob = CreateJobObject(NULL, NULL);
|
||||
|
||||
if (ghJob)
|
||||
{
|
||||
JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = { 0 };
|
||||
|
||||
// Configure all child processes associated with the job to terminate when the
|
||||
jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
|
||||
if ( 0 == SetInformationJobObject( ghJob, JobObjectExtendedLimitInformation, &jeli, sizeof(jeli)))
|
||||
{
|
||||
CloseHandle(ghJob);
|
||||
ghJob = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_INFORMATION processinfo;
|
||||
ZeroMemory(&processinfo,sizeof(PROCESS_INFORMATION));
|
||||
BOOL bResult = CreateProcessW(NULL, pCommandLine, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &sturtupinfo, &processinfo);
|
||||
|
||||
if (bResult && ghJob)
|
||||
{
|
||||
AssignProcessToJobObject(ghJob, processinfo.hProcess);
|
||||
}
|
||||
|
||||
::WaitForSingleObject(processinfo.hProcess, INFINITE);
|
||||
|
||||
RELEASEARRAYOBJECTS(pCommandLine);
|
||||
|
||||
return NSFile::CFileBinary::Exists(sFileDst);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//DownloadFilePS(L"https://natworld.info/wp-content/uploads/2018/02/vodosvinka-ili-kapibara.jpg", L"D:/222.jpg");
|
||||
|
||||
#ifdef DOWNLOADER_TEST
|
||||
NSNetwork::NSFileTransport::CFileDownloader oDownloader(L"https://natworld.info/wp-content/uploads/2018/02/vodosvinka-ili-kapibara.jpg", false);
|
||||
oDownloader.SetFilePath(L"D:\\111.jpg");
|
||||
oDownloader.SetEvent_OnComplete(Download_OnComplete);
|
||||
oDownloader.DownloadSync();
|
||||
#endif
|
||||
|
||||
#ifdef RASTER_TEST
|
||||
CBgraFrame oFrame;
|
||||
oFrame.OpenFile(L"D:\\22.png");
|
||||
oFrame.SaveFile(L"D:\\oleg.png", 4);
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
CApplicationFontsWorker oWorker;
|
||||
oWorker.m_sDirectory = NSFile::GetProcessDirectory() + L"/fonts_cache";
|
||||
//oWorker.m_arAdditionalFolders.push_back(L"D:\\GIT\\core-fonts");
|
||||
oWorker.m_bIsNeedThumbnails = false;
|
||||
|
||||
if (!NSDirectory::Exists(oWorker.m_sDirectory))
|
||||
NSDirectory::CreateDirectory(oWorker.m_sDirectory);
|
||||
|
||||
NSFonts::IApplicationFonts* pFonts = oWorker.Check();
|
||||
|
||||
#if 0
|
||||
NSFonts::CFontSelectFormat oFormat;
|
||||
oFormat.wsName = new std::wstring(L"@ËÎÌå");
|
||||
|
||||
NSFonts::IFontManager* pTestManager = pFonts->GenerateFontManager();
|
||||
|
||||
NSFonts::CFontInfo* pFontInfo = pTestManager->GetFontInfoByParams(oFormat);
|
||||
|
||||
pTestManager->Release();
|
||||
#endif
|
||||
|
||||
#ifdef METAFILE_TEST_X2T
|
||||
|
||||
MetaFile::IMetaFile* pMetafile = MetaFile::Create(pFonts);
|
||||
if (pMetafile->LoadFromFile(L"image.emf"))
|
||||
{
|
||||
NSFonts::IFontManager* pFontManager = pFonts->GenerateFontManager();
|
||||
|
||||
double x = 0, y = 0, w = 0, h = 0;
|
||||
pMetafile->GetBounds(&x, &y, &w, &h);
|
||||
|
||||
double _max = (w >= h) ? w : h;
|
||||
double dKoef = 1000.0 / _max;
|
||||
|
||||
int WW = (int)(dKoef * w + 0.5);
|
||||
int HH = (int)(dKoef * h + 0.5);
|
||||
|
||||
NSHtmlRenderer::CASCSVGWriter oWriterSVG;
|
||||
oWriterSVG.SetFontManager(pFontManager);
|
||||
oWriterSVG.put_Width(WW);
|
||||
oWriterSVG.put_Height(HH);
|
||||
|
||||
bool bRes = true;
|
||||
bool bIsBigestSVG = false;
|
||||
bool bIsRaster = true;
|
||||
try
|
||||
{
|
||||
bRes = pMetafile->DrawOnRenderer(&oWriterSVG, 0, 0, WW, HH);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
bRes = false;
|
||||
}
|
||||
|
||||
if (bRes)
|
||||
{
|
||||
oWriterSVG.IsRaster(&bIsRaster);
|
||||
|
||||
LONG lSvgDataSize = 0;
|
||||
oWriterSVG.GetSVGDataSize(&lSvgDataSize);
|
||||
|
||||
bIsBigestSVG = (lSvgDataSize > 5 * 1024 * 1024);
|
||||
}
|
||||
|
||||
if (bIsRaster || bIsBigestSVG || !bRes)
|
||||
{
|
||||
int nWidth = 0;
|
||||
int nHeight = 0;
|
||||
|
||||
int nMaxPixSize = 1000;
|
||||
|
||||
double dKoef = nMaxPixSize / _max;
|
||||
|
||||
nWidth = (int)(dKoef * w + 0.5);
|
||||
nHeight = (int)(dKoef * h + 0.5);
|
||||
|
||||
pMetafile->ConvertToRaster(L"image.png", 4 /*CXIMAGE_FORMAT_PNG*/, nWidth, nHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
oWriterSVG.SaveFile(L"image.svg");
|
||||
}
|
||||
|
||||
RELEASEINTERFACE(pFontManager);
|
||||
}
|
||||
RELEASEOBJECT(pMetafile);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef METAFILE_TEST
|
||||
|
||||
NSFonts::IFontManager* pManager = pFonts->GenerateFontManager();
|
||||
|
||||
NSHtmlRenderer::CASCSVGWriter oWriterSVG;
|
||||
oWriterSVG.SetFontManager(pManager);
|
||||
|
||||
MetaFile::IMetaFile* pMetafile = MetaFile::Create(pFonts);
|
||||
|
||||
//pMetafile->LoadFromFile(L"D:\\2\\ppt\\media\\image4.wmf");
|
||||
pMetafile->LoadFromFile(L"D:\\SVG\\Disigner 2.svg");
|
||||
|
||||
double x = 0, y = 0, w = 0, h = 0;
|
||||
pMetafile->GetBounds(&x, &y, &w, &h);
|
||||
|
||||
double _max = (w >= h) ? w : h;
|
||||
double dKoef = 100000.0 / _max;
|
||||
|
||||
int WW = (int)(dKoef * w + 0.5);
|
||||
int HH = (int)(dKoef * h + 0.5);
|
||||
|
||||
oWriterSVG.put_Width(WW);
|
||||
oWriterSVG.put_Height(HH);
|
||||
pMetafile->DrawOnRenderer(&oWriterSVG, 0, 0, WW, HH);
|
||||
|
||||
oWriterSVG.SaveFile(L"D:\\SVG\\out.png");
|
||||
|
||||
RELEASEOBJECT(pMetafile);
|
||||
RELEASEINTERFACE(pManager);
|
||||
RELEASEOBJECT(pFonts);
|
||||
return 0;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef METAFILE_TEST_RASTER
|
||||
|
||||
NSFonts::IFontManager* pManager = pFonts->GenerateFontManager();
|
||||
|
||||
NSGraphics::IGraphicsRenderer* pRasterRenderer = NSGraphics::Create();
|
||||
pRasterRenderer->SetFontManager(pManager);
|
||||
|
||||
int nRasterW = 1000;
|
||||
int nRasterH = 1000;
|
||||
BYTE* pData = new BYTE[4 * nRasterW * nRasterH];
|
||||
//memset(pData, 255, 4 * nRasterW * nRasterH);
|
||||
|
||||
unsigned int back = 0xffffff;
|
||||
unsigned int* pData32 = (unsigned int*)pData;
|
||||
unsigned int* pData32End = pData32 + nRasterW * nRasterH;
|
||||
//дефолтный тон должен быть прозрачным, а не белым
|
||||
while (pData32 < pData32End)
|
||||
*pData32++ = back;
|
||||
|
||||
CBgraFrame oFrame;
|
||||
oFrame.put_Data(pData);
|
||||
oFrame.put_Width(nRasterW);
|
||||
oFrame.put_Height(nRasterH);
|
||||
oFrame.put_Stride(4 * nRasterW);
|
||||
|
||||
pRasterRenderer->CreateFromBgraFrame(&oFrame);
|
||||
pRasterRenderer->SetSwapRGB(false);
|
||||
|
||||
double dW_MM = nRasterW * 25.4 / 96;
|
||||
double dH_MM = nRasterH * 25.4 / 96;
|
||||
|
||||
pRasterRenderer->put_Width(dW_MM);
|
||||
pRasterRenderer->put_Height(dH_MM);
|
||||
|
||||
MetaFile::IMetaFile* pMetafile = MetaFile::Create(pFonts);
|
||||
pMetafile->LoadFromFile(L"D:\\test\\123.svg");
|
||||
|
||||
double x = 0, y = 0, w = 0, h = 0;
|
||||
pMetafile->GetBounds(&x, &y, &w, &h);
|
||||
|
||||
pMetafile->DrawOnRenderer(pRasterRenderer, dW_MM / 4, dW_MM / 4, dW_MM / 2, dH_MM / 2);
|
||||
pMetafile->ConvertToRaster(L"D:\\SVG\\out2.png", 4, 1000);
|
||||
|
||||
oFrame.SaveFile(L"D:\\SVG\\out.png", 4);
|
||||
|
||||
RELEASEOBJECT(pMetafile);
|
||||
RELEASEINTERFACE(pManager);
|
||||
RELEASEINTERFACE(pRasterRenderer);
|
||||
return 0;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ONLINE_WORD_TO_PDF
|
||||
CPdfFile oPdfW(pFonts);
|
||||
oPdfW.CreatePdf();
|
||||
oPdfW.SetTempDirectory(L"C:\\Git\\Test\\Temp");
|
||||
oPdfW.OnlineWordToPdf(L"C:\\Git\\Test\\123.txt", L"C:\\Git\\Test\\123.pdf");
|
||||
RELEASEOBJECT(pFonts);
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
|
||||
//std::wstring sFile = L"\\\\KIRILLOV8\\_Office\\PDF\\Android intro(2p).pdf";
|
||||
//std::wstring sFile = L"D:\\activex\\Pi(1p).pdf";
|
||||
//std::wstring sFile = L"\\\\192.168.3.208\\allusers\\Files\\PDF\\AllPDF\\asia.pdf";
|
||||
//std::wstring sFile = L"D:\\knut.djvu";
|
||||
//std::wstring sFile = L"D:\\bankomats.xps";
|
||||
//std::wstring sFile = L"\\\\kirillov8\\_Office\\DJVU\\Основы разработки приложений на платформе Microsoft .NET Framework. Учебный курс Microsoft экзамен 70-536.djvu";
|
||||
//std::wstring sFile = L"D:\\TESTFILES\\Алгоритмы - построение и анализ.djvu";
|
||||
#ifndef WIN32
|
||||
std::wstring sFile = L"/home/oleg/GIT/ddd/ZfAvCwDsowJALpClgmE_/source/ZfAvCwDsowJALpClgmE_.pdf";
|
||||
#else
|
||||
//std::wstring sFile = L"D:\\ddd\\ZfAvCwDsowJALpClgmE_\\source\\ZfAvCwDsowJALpClgmE_.pdf";
|
||||
//std::wstring sFile = L"D:\\2.pdf";
|
||||
std::wstring sFile = L"D:\\OoPdfFormExample2.pdf";
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
std::wstring sDst = L"D:\\test\\Document";
|
||||
#else
|
||||
std::wstring sDst = L"/home/oleg/test/Document";
|
||||
#endif
|
||||
|
||||
//std::wstring sFile = L"/home/oleg/activex/Android intro(2p).pdf";
|
||||
//std::wstring sFile = L"/home/oleg/activex/Pi(1p).pdf";
|
||||
//std::wstring sFile = L"/home/oleg/activex/knut.djvu";
|
||||
//std::wstring sFile = L"/home/oleg/activex/bankomats.xps";
|
||||
//std::wstring sDst = L"/home/oleg/activex/1";
|
||||
|
||||
//NSFonts::NSApplicationFontStream::SetGlobalMemoryStorage(NSFonts::NSApplicationFontStream::CreateDefaultGlobalMemoryStorage());
|
||||
|
||||
IOfficeDrawingFile* pReader = NULL;
|
||||
pReader = new CPdfFile(pFonts);
|
||||
//pReader = new CDjVuFile(pFonts);
|
||||
//pReader = new CXpsFile(pFonts);
|
||||
|
||||
pReader->SetTempDirectory(sDst);
|
||||
pReader->LoadFromFile(sFile);
|
||||
|
||||
pReader->ConvertToRaster(0, L"D:\\111.png", 4);
|
||||
|
||||
#ifdef TO_HTML_RENDERER
|
||||
NSHtmlRenderer::CASCHTMLRenderer3 oRenderer;
|
||||
#ifdef ONLY_TEXT
|
||||
oRenderer.SetOnlyTextMode(true);
|
||||
oRenderer.CreateOfficeFile(L"temp/temp");
|
||||
#else
|
||||
oRenderer.CreateOfficeFile(sDst);
|
||||
#endif
|
||||
#else
|
||||
CPdfFile oRenderer(pFonts);
|
||||
oRenderer.SetTempDirectory(sDst);
|
||||
#endif
|
||||
|
||||
int nPagesCount = pReader->GetPagesCount();
|
||||
for (int i = 0; i < nPagesCount; ++i)
|
||||
{
|
||||
oRenderer.NewPage();
|
||||
oRenderer.BeginCommand(c_nPageType);
|
||||
|
||||
double dPageDpiX, dPageDpiY;
|
||||
double dWidth, dHeight;
|
||||
pReader->GetPageInfo(i, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
|
||||
|
||||
dWidth *= 25.4 / dPageDpiX;
|
||||
dHeight *= 25.4 / dPageDpiY;
|
||||
|
||||
oRenderer.put_Width(dWidth);
|
||||
oRenderer.put_Height(dHeight);
|
||||
|
||||
#ifdef ONLY_TEXT
|
||||
oRenderer.SetAdditionalParam("DisablePageEnd", L"yes");
|
||||
#endif
|
||||
pReader->DrawPageOnRenderer(&oRenderer, i, NULL);
|
||||
|
||||
#ifdef ONLY_TEXT
|
||||
oRenderer.SetAdditionalParam("DisablePageEnd", L"no");
|
||||
|
||||
int paragraphs = 0;
|
||||
int words = 0;
|
||||
int symbols = 0;
|
||||
int spaces = 0;
|
||||
std::string info;
|
||||
oRenderer.GetLastPageInfo(paragraphs, words, symbols, spaces, info);
|
||||
#endif
|
||||
|
||||
oRenderer.EndCommand(c_nPageType);
|
||||
}
|
||||
|
||||
#ifdef TO_HTML_RENDERER
|
||||
#ifndef ONLY_TEXT
|
||||
oRenderer.CloseFile();
|
||||
#endif
|
||||
#else
|
||||
oRenderer.SaveToFile(L"D:/11.pdf");
|
||||
#endif
|
||||
|
||||
RELEASEOBJECT(pFonts);
|
||||
return 0;
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2015-07-21T18:28:42
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT -= core
|
||||
|
||||
QT -= gui
|
||||
|
||||
TARGET = test
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
DEFINES += PDFREADER_USE_DYNAMIC_LIBRARY
|
||||
DEFINES += PDFWRITER_USE_DYNAMIC_LIBRARY
|
||||
DEFINES += XPS_USE_DYNAMIC_LIBRARY
|
||||
DEFINES += DJVU_USE_DYNAMIC_LIBRARY
|
||||
DEFINES += HTMLRENDERER_USE_DYNAMIC_LIBRARY
|
||||
|
||||
DEFINES += KERNEL_USE_DYNAMIC_LIBRARY
|
||||
DEFINES += GRAPHICS_USE_DYNAMIC_LIBRARY
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
include($$PWD/../../Common/3dParty/icu/icu.pri)
|
||||
|
||||
ADD_DEPENDENCY(UnicodeConverter kernel graphics kernel_network HtmlRenderer PdfFile DjVuFile XpsFile)
|
||||
|
||||
win32 {
|
||||
LIBS += -lgdi32 \
|
||||
-ladvapi32 \
|
||||
-luser32 \
|
||||
-lshell32
|
||||
}
|
||||
|
||||
linux-g++ | linux-g++-64 | linux-g++-32 {
|
||||
LIBS += -lz
|
||||
}
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
SOURCES += \
|
||||
../src/ASCSVGWriter.cpp
|
||||
|
||||
HEADERS += ../include/ASCSVGWriter.h
|
@ -47,12 +47,6 @@
|
||||
|
||||
#include "../../Base/Unit.h"
|
||||
|
||||
// как все протестируем - уберем
|
||||
#define SUPPORT_OLD_SVG_CONVERTATION
|
||||
#ifdef SUPPORT_OLD_SVG_CONVERTATION
|
||||
#include "../../../HtmlRenderer/include/ASCSVGWriter.h"
|
||||
#endif
|
||||
|
||||
namespace NSShapeImageGen
|
||||
{
|
||||
const long c_nMaxImageSize = 2000;
|
||||
@ -545,54 +539,7 @@ namespace NSShapeImageGen
|
||||
return oInfo;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_OLD_SVG_CONVERTATION
|
||||
// пробуем сохранить в svg. большие/сложные файлы
|
||||
// сохраняем в растр
|
||||
NSHtmlRenderer::CASCSVGWriter oWriterSVG;
|
||||
oWriterSVG.SetFontManager(m_pFontManager);
|
||||
oWriterSVG.put_Width(lWidth);
|
||||
oWriterSVG.put_Height(lHeight);
|
||||
|
||||
bool bRes = true;
|
||||
try
|
||||
{
|
||||
bRes = pMetafile->DrawOnRenderer(&oWriterSVG, 0, 0, dWidth, dHeight);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
bRes = false;
|
||||
}
|
||||
|
||||
if (bRes)
|
||||
{
|
||||
bool bIsComplex = false;
|
||||
|
||||
// растровые - сложные
|
||||
oWriterSVG.IsRaster(&bIsComplex);
|
||||
|
||||
if (!bIsComplex)
|
||||
{
|
||||
LONG lSvgDataSize = 0;
|
||||
oWriterSVG.GetSVGDataSize(&lSvgDataSize);
|
||||
|
||||
// больше 5 метров - сложные
|
||||
bIsComplex = (lSvgDataSize > 5 * 1024 * 1024);
|
||||
}
|
||||
|
||||
if (!bIsComplex)
|
||||
{
|
||||
oInfo.m_eType = itSVG;
|
||||
|
||||
oWriterSVG.SaveFile(strSaveItemWE + L".svg");
|
||||
m_mapMediaFiles.insert(std::make_pair(sMapKey, oInfo));
|
||||
|
||||
RELEASEOBJECT(pMetafile);
|
||||
return oInfo;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// не смогли (или не захотели? (SUPPORT_OLD_SVG_CONVERTATION)) сконвертировать в svg.
|
||||
// не смогли сконвертировать в svg.
|
||||
// пробуем в png
|
||||
|
||||
std::wstring strSaveItem = strSaveItemWE + L".png";
|
||||
|
@ -83,7 +83,6 @@ SOURCES += \
|
||||
\
|
||||
../../../PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp \
|
||||
../../../PPTXFormat/DrawingConverter/ASCOfficePPTXFileRealization.cpp \
|
||||
../../../../HtmlRenderer/src/ASCSVGWriter.cpp \
|
||||
\
|
||||
../../../PPTXFormat/ViewProps/CSldViewPr.cpp \
|
||||
../../../PPTXFormat/ViewProps/CViewPr.cpp \
|
||||
@ -127,13 +126,12 @@ HEADERS += \
|
||||
pptx_format.h \
|
||||
\
|
||||
../../../Base/Nullable.h \
|
||||
../../../../HtmlRenderer/include/ASCSVGWriter.h \
|
||||
../../../../Common/FileDownloader/FileDownloader.h \
|
||||
\
|
||||
../../../../MsBinaryFile/Common/Vml/Common.h \
|
||||
../../../../MsBinaryFile/Common/Vml/BaseShape.h \
|
||||
../../../../MsBinaryFile/Common/Vml/toVmlConvert.h \
|
||||
../../../../MsBinaryFile/Common/Vml/VmlPath.h \
|
||||
../../../../MsBinaryFile/Common/Vml/VmlPath.h \
|
||||
../../../../MsBinaryFile/Common/Vml/GraphicsPath.h \
|
||||
\
|
||||
../../../../MsBinaryFile/Common/Vml/PPTShape/PptShape.h \
|
||||
|
@ -669,7 +669,6 @@
|
||||
<ClInclude Include="..\..\..\PPTXFormat\WritingVector.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\..\HtmlRenderer\src\ASCSVGWriter.cpp" />
|
||||
<ClCompile Include="..\..\..\..\MsBinaryFile\Common\Base\XmlTools.cpp" />
|
||||
<ClCompile Include="..\..\..\..\MsBinaryFile\Common\Vml\BaseShape.cpp" />
|
||||
<ClCompile Include="..\..\..\..\MsBinaryFile\Common\Vml\GraphicsPath.cpp" />
|
||||
|
@ -3728,9 +3728,6 @@
|
||||
<ClCompile Include="..\..\..\PPTXFormat\DrawingConverter\ASCOfficeDrawingConverter.cpp">
|
||||
<Filter>Binary</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\HtmlRenderer\src\ASCSVGWriter.cpp">
|
||||
<Filter>Binary</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Limits">
|
||||
|
@ -105,17 +105,7 @@ use_external_jpeg2000 {
|
||||
SOURCES += SrcReader/JPXStream2.cpp
|
||||
}
|
||||
|
||||
#CONFIG += build_viewer_module
|
||||
build_viewer_module {
|
||||
DEFINES += BUILDING_WASM_MODULE \
|
||||
TEST_CPP_BINARY
|
||||
|
||||
HEADERS += $$CORE_ROOT_DIR/HtmlRenderer/include/HTMLRendererText.h
|
||||
SOURCES += $$CORE_ROOT_DIR/HtmlRenderer/src/HTMLRendererText.cpp
|
||||
}
|
||||
|
||||
# PdfWriter
|
||||
|
||||
DEFINES += CRYPTOPP_DISABLE_ASM \
|
||||
NOMINMAX
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib
|
||||
|
@ -16,5 +16,5 @@ PWD_ROOT_DIR = $$PWD
|
||||
CORE_ROOT_DIR = $$PWD/../../../../../core
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
ADD_DEPENDENCY(kernel, graphics, UnicodeConverter, HtmlRenderer, PdfFile)
|
||||
ADD_DEPENDENCY(kernel, graphics, UnicodeConverter, PdfFile)
|
||||
core_linux:include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
|
@ -70,7 +70,7 @@ set(CORE_DIR ${ARG_PATH_SRC_CORE})
|
||||
set(X2T_CONVERTER_LIBS ${ARG_PATH_LIB_BUILD_TOOLS}/${ANDROID_ABI})
|
||||
message(STATUS "Prebuild libraries path: ${X2T_CONVERTER_LIBS}")
|
||||
|
||||
SET(new_list libUnicodeConverter.so libkernel.so libkernel_network.so libgraphics.so libPdfFile.so libDjVuFile.so libXpsFile.so libHtmlFile2.so libFb2File.so libEpubFile.so libHtmlRenderer.so libDocxRenderer.so libdoctrenderer.so libx2t.so)
|
||||
SET(new_list libUnicodeConverter.so libkernel.so libkernel_network.so libgraphics.so libPdfFile.so libDjVuFile.so libXpsFile.so libHtmlFile2.so libFb2File.so libEpubFile.so libIWorkFile.so libDocxRenderer.so libdoctrenderer.so libx2t.so)
|
||||
|
||||
SET(libs_list "")
|
||||
FOREACH(file_path ${new_list})
|
||||
|
@ -33,7 +33,6 @@ DEFINES += UNICODE \
|
||||
DEFINES += PDFFILE_USE_DYNAMIC_LIBRARY
|
||||
DEFINES += XPS_USE_DYNAMIC_LIBRARY
|
||||
DEFINES += DJVU_USE_DYNAMIC_LIBRARY
|
||||
DEFINES += HTMLRENDERER_USE_DYNAMIC_LIBRARY
|
||||
DEFINES += HTMLFILE_USE_DYNAMIC_LIBRARY
|
||||
DEFINES += UNICODECONVERTER_USE_DYNAMIC_LIBRARY
|
||||
DEFINES += FILE_FORMAT_CHECKER_WITH_MACRO
|
||||
@ -129,7 +128,7 @@ LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib
|
||||
|
||||
#All dynamic libs
|
||||
|
||||
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, kernel_network, Fb2File, PdfFile, HtmlFile2, EpubFile, XpsFile, DjVuFile, HtmlRenderer, doctrenderer, DocxRenderer, IWorkFile)
|
||||
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, kernel_network, Fb2File, PdfFile, HtmlFile2, EpubFile, XpsFile, DjVuFile, doctrenderer, DocxRenderer, IWorkFile)
|
||||
|
||||
|
||||
#####################################################
|
||||
|
@ -39,12 +39,6 @@ libHtmlFile.dylib \
|
||||
@executable_path/libHtmlFile.dylib \
|
||||
"${dst}"/${TARGET_NAME}.app/${TARGET_NAME}
|
||||
|
||||
install_name_tool \
|
||||
-change \
|
||||
libHtmlRenderer.dylib \
|
||||
@executable_path/libHtmlRenderer.dylib \
|
||||
"${dst}"/${TARGET_NAME}.app/${TARGET_NAME}
|
||||
|
||||
install_name_tool \
|
||||
-change \
|
||||
libPdfReader.dylib \
|
||||
@ -114,25 +108,6 @@ libgraphics.dylib \
|
||||
@executable_path/libgraphics.dylib \
|
||||
"${dst}"/${TARGET_NAME}.app/libdoctrenderer.dylib
|
||||
|
||||
# htmlrenderer
|
||||
install_name_tool \
|
||||
-change \
|
||||
libkernel.dylib \
|
||||
@executable_path/libkernel.dylib \
|
||||
"${dst}"/${TARGET_NAME}.app/libHtmlRenderer.dylib
|
||||
|
||||
install_name_tool \
|
||||
-change \
|
||||
libUnicodeConverter.dylib \
|
||||
@executable_path/libUnicodeConverter.dylib \
|
||||
"${dst}"/${TARGET_NAME}.app/libHtmlRenderer.dylib
|
||||
|
||||
install_name_tool \
|
||||
-change \
|
||||
libgraphics.dylib \
|
||||
@executable_path/libgraphics.dylib \
|
||||
"${dst}"/${TARGET_NAME}.app/libHtmlRenderer.dylib
|
||||
|
||||
# pdfwriter
|
||||
install_name_tool \
|
||||
-change \
|
||||
@ -221,12 +196,6 @@ libgraphics.dylib \
|
||||
@executable_path/libgraphics.dylib \
|
||||
"${dst}"/${TARGET_NAME}.app/libPdfReader.dylib
|
||||
|
||||
install_name_tool \
|
||||
-change \
|
||||
libHtmlRenderer.dylib \
|
||||
@executable_path/libHtmlRenderer.dylib \
|
||||
"${dst}"/${TARGET_NAME}.app/libPdfReader.dylib
|
||||
|
||||
# x2t
|
||||
install_name_tool \
|
||||
-change \
|
||||
@ -264,12 +233,6 @@ libHtmlFile.dylib \
|
||||
@executable_path/libHtmlFile.dylib \
|
||||
"${dst}"/${TARGET_NAME}.app/libx2t.dylib
|
||||
|
||||
install_name_tool \
|
||||
-change \
|
||||
libHtmlRenderer.dylib \
|
||||
@executable_path/libHtmlRenderer.dylib \
|
||||
"${dst}"/${TARGET_NAME}.app/libx2t.dylib
|
||||
|
||||
install_name_tool \
|
||||
-change \
|
||||
libPdfReader.dylib \
|
||||
|
@ -36,7 +36,6 @@
|
||||
|
||||
#include "../../../DjVuFile/DjVu.h"
|
||||
#include "../../../DocxRenderer/DocxRenderer.h"
|
||||
#include "../../../HtmlRenderer/include/HTMLRenderer3.h"
|
||||
#include "../../../PdfFile/PdfFile.h"
|
||||
#include "../../../XpsFile/XpsFile.h"
|
||||
#include "../../../OfficeUtils/src/ZipFolder.h"
|
||||
|
@ -33,7 +33,6 @@
|
||||
#if defined(_WIN64)
|
||||
#if defined(_DEBUG)
|
||||
#pragma comment(lib, "../../../build/lib/win_64/DEBUG/doctrenderer.lib")
|
||||
#pragma comment(lib, "../../../build/lib/win_64/DEBUG/HtmlRenderer.lib")
|
||||
#pragma comment(lib, "../../../build/lib/win_64/DEBUG/DocxRenderer.lib")
|
||||
#pragma comment(lib, "../../../build/lib/win_64/DEBUG/PdfFile.lib")
|
||||
#pragma comment(lib, "../../../build/lib/win_64/DEBUG/XpsFile.lib")
|
||||
@ -49,7 +48,6 @@
|
||||
#pragma comment(lib, "../../../build/lib/win_64/DEBUG/CryptoPPLib.lib")
|
||||
#else
|
||||
#pragma comment(lib, "../../../build/lib/win_64/doctrenderer.lib")
|
||||
#pragma comment(lib, "../../../build/lib/win_64/HtmlRenderer.lib")
|
||||
#pragma comment(lib, "../../../build/lib/win_64/PdfFile.lib")
|
||||
#pragma comment(lib, "../../../build/lib/win_64/XpsFile.lib")
|
||||
#pragma comment(lib, "../../../build/lib/win_64/EpubFile.lib")
|
||||
@ -67,7 +65,6 @@
|
||||
#elif defined (_WIN32)
|
||||
#if defined(_DEBUG)
|
||||
#pragma comment(lib, "../../../build/lib/win_32/DEBUG/doctrenderer.lib")
|
||||
#pragma comment(lib, "../../../build/lib/win_32/DEBUG/HtmlRenderer.lib")
|
||||
#pragma comment(lib, "../../../build/lib/win_32/DEBUG/DocxRenderer.lib")
|
||||
#pragma comment(lib, "../../../build/lib/win_32/DEBUG/PdfFile.lib")
|
||||
#pragma comment(lib, "../../../build/lib/win_32/DEBUG/XpsFile.lib")
|
||||
@ -83,7 +80,6 @@
|
||||
#pragma comment(lib, "../../../build/lib/win_32/DEBUG/CryptoPPLib.lib")
|
||||
#else
|
||||
#pragma comment(lib, "../../../build/lib/win_32/doctrenderer.lib")
|
||||
#pragma comment(lib, "../../../build/lib/win_32/HtmlRenderer.lib")
|
||||
#pragma comment(lib, "../../../build/lib/win_32/DocxRenderer.lib")
|
||||
#pragma comment(lib, "../../../build/lib/win_32/PdfFile.lib")
|
||||
#pragma comment(lib, "../../../build/lib/win_32/XpsFile.lib")
|
||||
|
@ -43,11 +43,3 @@ SOURCES += \
|
||||
XpsLib/StaticResources.cpp \
|
||||
XpsLib/Utils.cpp \
|
||||
XpsLib/WString.cpp
|
||||
|
||||
#CONFIG += build_viewer_module
|
||||
build_viewer_module {
|
||||
DEFINES += BUILDING_WASM_MODULE
|
||||
|
||||
HEADERS += $$CORE_ROOT_DIR/HtmlRenderer/include/HTMLRendererText.h
|
||||
SOURCES += $$CORE_ROOT_DIR/HtmlRenderer/src/HTMLRendererText.cpp
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user