Compare commits

..

23 Commits

Author SHA1 Message Date
8550bdeed6 Generate all projects if ommited 2024-10-24 18:05:56 +04:00
5aae57aad8 Log generated project files 2024-10-24 17:43:04 +04:00
1d4f825ea6 Add note to change builder directory for cpp & cs 2024-10-23 13:53:30 +04:00
0527472fef Use space indentation for consistency 2024-10-22 22:00:45 +04:00
c911733bd7 Fix crash on mac 2024-10-22 21:51:21 +04:00
46f254c85d Fix incorrect convertation to string 2024-10-22 20:43:03 +04:00
a6a7d919e6 Add README.md 2024-10-21 16:47:52 +04:00
755d6cd970 Add some Java samples 2024-10-21 15:04:22 +04:00
604dc14d23 Add some python samples 2024-10-18 18:00:54 +04:00
2263d7bf80 Fix Makefile for mac 2024-10-18 14:04:30 +04:00
ef415aad3f Fixes for mac 2024-10-17 18:55:42 +04:00
6744c172f4 Remove C++ compile warnings 2024-10-17 17:43:53 +04:00
6ea3a9551e Add generation of Makefile 2024-10-17 17:35:51 +04:00
f48ab0351c Update help message with C# projects 2024-10-17 15:28:29 +04:00
632ddf9805 Remove asterisks due to portability 2024-10-17 15:22:27 +04:00
2c61e84e94 Fix unresolved symbols on linux 2024-10-17 14:38:21 +04:00
375b37e9aa Add include paths for utils 2024-10-16 19:07:29 +04:00
bb3e2e3bc2 Fix issue with relative paths to resources 2024-10-16 18:20:04 +04:00
1a5b8b4bbd Add generation of Qt C++ projects 2024-10-16 18:17:40 +04:00
901c44b486 Add generation of VS .NET projects 2024-10-15 19:00:29 +04:00
88eadd9955 Add remaining C++ samples 2024-10-15 16:04:23 +04:00
b5f88cebaf Fix C++ projects for old VS versions
+ Add spreadsheet test
2024-10-15 14:52:14 +04:00
e0e7e31568 Add generation of VS C++ projects 2024-10-14 20:18:57 +04:00
744 changed files with 28406 additions and 46139 deletions

View File

@ -1,141 +0,0 @@
#include "IWork.h"
#include "../DesktopEditor/common/File.h"
#include "../DesktopEditor/common/Directory.h"
#include <libetonyek/libetonyek.h>
#include <libodfgen/OdtGenerator.hxx>
#include <libodfgen/OdsGenerator.hxx>
#include <libodfgen/OdpGenerator.hxx>
#include <libodfgen/test/StringDocumentHandler.hxx>
#include <memory>
#include <fstream>
class CIWorkFile_Private
{
public:
std::wstring m_sTempDirectory;
public:
CIWorkFile_Private()
{
}
~CIWorkFile_Private()
{
}
};
CIWorkFile::CIWorkFile()
{
m_internal = new CIWorkFile_Private();
}
CIWorkFile::~CIWorkFile()
{
delete m_internal;
}
#if !defined(_WIN32) && !defined(_WIN64)
#define DATA_TYPE_INPUTFILE std::string
#else
#define DATA_TYPE_INPUTFILE std::wstring
#endif
bool GetRVNGInputStream(const DATA_TYPE_INPUTFILE& sFile, std::shared_ptr<librevenge::RVNGInputStream>& oRVNGInputStream, libetonyek::EtonyekDocument::Type& oDocumentType)
{
oRVNGInputStream.reset(new librevenge::RVNGFileStream(sFile.c_str()));
oDocumentType = libetonyek::EtonyekDocument::TYPE_UNKNOWN;
const libetonyek::EtonyekDocument::Confidence confidence = libetonyek::EtonyekDocument::isSupported(oRVNGInputStream.get(), &oDocumentType);
return libetonyek::EtonyekDocument::CONFIDENCE_NONE != confidence;
}
IWorkFileType CIWorkFile::GetType(const std::wstring& sFile) const
{
//TODO:: так как на данный момент мы работает только напрямую с файлом, то работа с директорией нам пока не нужна
if (NSDirectory::PathIsDirectory(sFile))
return IWorkFileType::None;
std::shared_ptr<librevenge::RVNGInputStream> input;
libetonyek::EtonyekDocument::Type oDocumentType;
#if !defined(_WIN32) && !defined(_WIN64)
std::string sFileA = U_TO_UTF8(sFile);
if (!GetRVNGInputStream(sFileA, input, oDocumentType))
return IWorkFileType::None;
#else
if (!GetRVNGInputStream(sFile, input, oDocumentType))
return IWorkFileType::None;
#endif
switch (oDocumentType)
{
case libetonyek::EtonyekDocument::TYPE_PAGES:
return IWorkFileType::Pages;
case libetonyek::EtonyekDocument::TYPE_NUMBERS:
return IWorkFileType::Numbers;
case libetonyek::EtonyekDocument::TYPE_KEYNOTE:
return IWorkFileType::Keynote;
default:
break;
}
return IWorkFileType::None;
}
template<class Generator>
int Convert(const std::wstring& wsOutputFile, std::shared_ptr<librevenge::RVNGInputStream>& ptrInput, const std::wstring& wsPassword = L"", const std::wstring& wsTempDirectory = L"")
{
StringDocumentHandler content;
Generator generator;
generator.addDocumentHandler(&content, ODF_FLAT_XML);
bool bRes = libetonyek::EtonyekDocument::parse(ptrInput.get(), &generator);
if (!bRes)
return 1;
const std::string sOutputFileA = U_TO_UTF8(wsOutputFile);
std::ofstream output(sOutputFileA.c_str());
output << content.cstr();
if (output.bad())
return -1;
return 0;
}
int CIWorkFile::Convert2Odf(const std::wstring& sFile, const std::wstring& sOutputFile) const
{
//TODO:: так как на данный момент мы работает только напрямую с файлом, то работа с директорией нам пока не нужна
if (NSDirectory::PathIsDirectory(sFile))
return -1;
std::shared_ptr<librevenge::RVNGInputStream> input;
libetonyek::EtonyekDocument::Type oDocumentType;
#if !defined(_WIN32) && !defined(_WIN64)
std::string sFileA = U_TO_UTF8(sFile);
if (!GetRVNGInputStream(sFileA, input, oDocumentType))
return -1;
#else
if (!GetRVNGInputStream(sFile, input, oDocumentType))
return -1;
#endif
switch (oDocumentType)
{
case libetonyek::EtonyekDocument::TYPE_PAGES: return Convert<OdtGenerator>(sOutputFile, input);
case libetonyek::EtonyekDocument::TYPE_NUMBERS: return Convert<OdsGenerator>(sOutputFile, input);
case libetonyek::EtonyekDocument::TYPE_KEYNOTE: return Convert<OdpGenerator>(sOutputFile, input);
default:
break;
}
return -1;
}
void CIWorkFile::SetTmpDirectory(const std::wstring& sFolder)
{
m_internal->m_sTempDirectory = sFolder;
}

View File

@ -1,36 +0,0 @@
#ifndef _IWORKFILE_IWORKFILE_H
#define _IWORKFILE_IWORKFILE_H
#include <string>
#ifndef IWORK_USE_DYNAMIC_LIBRARY
#define IWORK_FILE_DECL_EXPORT
#else
#include "../DesktopEditor/common/base_export.h"
#define IWORK_FILE_DECL_EXPORT Q_DECL_EXPORT
#endif
enum class IWorkFileType
{
Pages = 0,
Numbers = 1,
Keynote = 2,
None = 255
};
class CIWorkFile_Private;
class IWORK_FILE_DECL_EXPORT CIWorkFile
{
private:
CIWorkFile_Private* m_internal;
public:
CIWorkFile();
~CIWorkFile();
IWorkFileType GetType(const std::wstring& sFile) const;
int Convert2Odf(const std::wstring& sFile, const std::wstring& sOutputFile) const;
void SetTmpDirectory(const std::wstring& sFolder);
};
#endif // _IWORKFILE_IWORKFILE_H

View File

@ -1,46 +0,0 @@
QT -= core
QT -= gui
VERSION = 0.0.0.1
TARGET = IWorkFile
TEMPLATE = lib
CONFIG += shared
CONFIG += plugin
DEFINES += IWORK_USE_DYNAMIC_LIBRARY
CORE_ROOT_DIR = $$PWD/..
PWD_ROOT_DIR = $$PWD
include($$CORE_ROOT_DIR/Common/base.pri)
ADD_DEPENDENCY(kernel, UnicodeConverter)
INCLUDEPATH += \
$$PWD
core_android:DEFINES += NOT_USE_PTHREAD_CANCEL USE_FILE32API
# BOOST
CONFIG += core_boost_regex
include($$CORE_ROOT_DIR/Common/3dParty/boost/boost.pri)
# ZLIB
CONFIG += build_all_zlib build_zlib_as_sources
include($$PWD/../OfficeUtils/OfficeUtils.pri)
# LIBXML
CONFIG += core_static_link_xml_full
CONFIG += core_only_libxml
include($$PWD/../DesktopEditor/xml/build/qt/libxml2.pri)
#
include($$CORE_ROOT_DIR/Common/3dParty/apple/apple.pri)
# TEST
HEADERS += $$ODF_LIB_ROOT/test/StringDocumentHandler.h
SOURCES += $$ODF_LIB_ROOT/test/StringDocumentHandler.cxx
SOURCES += IWork.cpp
HEADERS += IWork.h

View File

@ -1,45 +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 "../IWork.h"
#include "../../DesktopEditor/common/File.h"
int main(int argc, char *argv[])
{
CIWorkFile oFile;
std::wstring sExamplesDir = NSFile::GetProcessDirectory() + L"/../examples";
oFile.Convert2Odf(sExamplesDir + L"/new.pages", sExamplesDir + L"/out_new.odt");
oFile.Convert2Odf(sExamplesDir + L"/old.pages", sExamplesDir + L"/out_old.odt");
return 0;
}

View File

@ -1,20 +0,0 @@
CONFIG -= qt
QT -= core gui
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
CORE_ROOT_DIR = $$PWD/../..
PWD_ROOT_DIR = $$PWD
include($$CORE_ROOT_DIR/Common/base.pri)
ADD_DEPENDENCY(UnicodeConverter, kernel, IWorkFile)
core_linux:include($$PWD/../../Common/3dParty/icu/icu.pri)
core_windows:LIBS += -lgdi32 -ladvapi32 -luser32 -lshell32
SOURCES += main.cpp
DESTDIR = $$PWD/build

View File

@ -1,8 +0,0 @@
# Ignore everything in this directory
glm
mdds
librevenge
libodfgen
libetonyek
# Except this file
!.gitignore

View File

@ -1,36 +0,0 @@
INCLUDEPATH += $$PWD
# LIBREVENGE
REVENGE_LIB_ROOT = $$PWD/librevenge
INCLUDEPATH += \
$$REVENGE_LIB_ROOT/inc
HEADERS += $$files($$REVENGE_LIB_ROOT/inc/*.h, true)
HEADERS += $$files($$REVENGE_LIB_ROOT/src/lib/*.h, true)
SOURCES += $$files($$REVENGE_LIB_ROOT/src/lib/*.cpp, true)
# LIBODFGEN
ODF_LIB_ROOT = $$PWD/libodfgen
INCLUDEPATH += \
$$ODF_LIB_ROOT/inc
HEADERS += $$files($$ODF_LIB_ROOT/inc/libodfgen/*.hxx, true)
HEADERS += $$files($$ODF_LIB_ROOT/src/*.hxx, true)
SOURCES += $$files($$ODF_LIB_ROOT/src/*.cxx, true)
# LIBETONYEK
ETONYEK_LIB_ROOT = $$PWD/libetonyek
INCLUDEPATH += \
$$ETONYEK_LIB_ROOT/inc \
$$ETONYEK_LIB_ROOT/src/lib \
$$ETONYEK_LIB_ROOT/src/lib/contexts \
$$PWD/mdds/include \
$$PWD/glm
HEADERS += $$files($$ETONYEK_LIB_ROOT/inc/libetonyek/*.h, true)
HEADERS += $$files($$ETONYEK_LIB_ROOT/src/lib/*.h, true)
SOURCES += $$files($$ETONYEK_LIB_ROOT/src/lib/*.cpp, true)

View File

@ -1,121 +0,0 @@
import sys
sys.path.append('../../../../build_tools/scripts')
import base
import os
if not base.is_dir("glm"):
base.cmd("git", ["clone", "https://github.com/g-truc/glm.git"])
base.cmd_in_dir("glm", "git", ["checkout", "33b4a621a697a305bc3a7610d290677b96beb181", "--quiet"])
if not base.is_dir("mdds"):
base.cmd("git", ["clone", "https://github.com/kohei-us/mdds.git"])
base.cmd_in_dir("mdds", "git", ["checkout", "0783158939c6ce4b0b1b89e345ab983ccb0f0ad0"], "--quiet")
fix_cpp_version = "#if __cplusplus < 201402L\n"
fix_cpp_version += "#ifndef _MSC_VER\n"
fix_cpp_version += "namespace std {\n"
fix_cpp_version += " template<bool __v>\n"
fix_cpp_version += " using bool_constant = integral_constant<bool, __v>;\n\n"
fix_cpp_version += " template <class... _Types>\n"
fix_cpp_version += " using void_t = void;\n"
fix_cpp_version += "}\n#endif\n"
fix_cpp_version += "#endif\n\n"
fix_cpp_version += "namespace mdds {"
base.replaceInFile("./mdds/include/mdds/global.hpp", "namespace mdds {", fix_cpp_version)
if not base.is_dir("librevenge"):
base.cmd("git", ["clone", "https://github.com/Distrotech/librevenge.git"])
base.cmd_in_dir("librevenge", "git", ["checkout", "becd044b519ab83893ad6398e3cbb499a7f0aaf4", "--quiet"])
stat_windows = ""
stat_windows += "#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)\n"
stat_windows += "#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)\n"
stat_windows += "#endif\n"
stat_windows += "#if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)\n"
stat_windows += "#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)\n"
stat_windows += "#endif\n"
base.replaceInFile("./librevenge/src/lib/RVNGDirectoryStream.cpp", "#include <librevenge-stream/librevenge-stream.h>",
"#include <librevenge-stream/librevenge-stream.h>\n\n" + stat_windows)
fix_RVNG_H = "explicit RVNGFileStream(const char *filename);\n"
fix_RVNG_H += " #if defined(_WIN32) || defined(_WIN64)\n"
fix_RVNG_H += " explicit RVNGFileStream(const wchar_t *filename);\n"
fix_RVNG_H += " #endif\n"
base.replaceInFile("./librevenge/inc/librevenge-stream/RVNGStreamImplementation.h", "explicit RVNGFileStream(const char *filename);", fix_RVNG_H)
fix_RVNG_CPP_include = "#if defined(_WIN32) || defined(_WIN64)\n"
fix_RVNG_CPP_include += "#include <sys/stat.h>\n\n"
fix_RVNG_CPP_include += "static __inline int wstat(wchar_t const* const _FileName, struct stat* const _Stat)\n"
fix_RVNG_CPP_include += "{\n"
fix_RVNG_CPP_include += " _STATIC_ASSERT(sizeof(struct stat) == sizeof(struct _stat64i32));\n";
fix_RVNG_CPP_include += " return _wstat64i32(_FileName, (struct _stat64i32*)_Stat);\n";
fix_RVNG_CPP_include += "}\n"
fix_RVNG_CPP_include += "#endif\n\n"
fix_RVNG_CPP_include += "namespace librevenge"
base.replaceInFile("./librevenge/src/lib/RVNGStreamImplementation.cpp", "namespace librevenge", fix_RVNG_CPP_include)
fix_RVNG_CPP = "#if defined(_WIN32) || defined(_WIN64)\n"
fix_RVNG_CPP += "RVNGFileStream::RVNGFileStream(const wchar_t *filename) :\n"
fix_RVNG_CPP += " RVNGInputStream(),\n"
fix_RVNG_CPP += " d(new RVNGFileStreamPrivate())\n"
fix_RVNG_CPP += "{\n"
fix_RVNG_CPP += " d->file = _wfopen(filename, L\"rb\");\n"
fix_RVNG_CPP += " if (!d->file || ferror(d->file))\n"
fix_RVNG_CPP += " {\n"
fix_RVNG_CPP += " delete d;\n"
fix_RVNG_CPP += " d = 0;\n"
fix_RVNG_CPP += " return;\n"
fix_RVNG_CPP += " }\n\n"
fix_RVNG_CPP += " struct stat status;\n"
fix_RVNG_CPP += " const int retval = wstat(filename, &status);\n"
fix_RVNG_CPP += " if ((0 != retval) || !S_ISREG(status.st_mode))\n"
fix_RVNG_CPP += " {\n"
fix_RVNG_CPP += " delete d;\n"
fix_RVNG_CPP += " d = 0;\n"
fix_RVNG_CPP += " return;\n"
fix_RVNG_CPP += " }\n\n"
fix_RVNG_CPP += " fseek(d->file, 0, SEEK_END);\n\n"
fix_RVNG_CPP += " d->streamSize = (unsigned long) ftell(d->file);\n"
fix_RVNG_CPP += " if (d->streamSize == (unsigned long)-1)\n"
fix_RVNG_CPP += " d->streamSize = 0;\n"
fix_RVNG_CPP += " if (d->streamSize > (std::numeric_limits<unsigned long>::max)() / 2)\n"
fix_RVNG_CPP += " d->streamSize = (std::numeric_limits<unsigned long>::max)() / 2;\n"
fix_RVNG_CPP += " fseek(d->file, 0, SEEK_SET);\n"
fix_RVNG_CPP += "}\n"
fix_RVNG_CPP += "#endif\n\n"
fix_RVNG_CPP += "RVNGFileStream::~RVNGFileStream()"
base.replaceInFile("./librevenge/src/lib/RVNGStreamImplementation.cpp", "RVNGFileStream::~RVNGFileStream()", fix_RVNG_CPP)
if not base.is_dir("libodfgen"):
base.cmd("git", ["clone", "https://github.com/Distrotech/libodfgen.git"])
base.cmd_in_dir("libodfgen", "git", ["checkout", "8ef8c171ebe3c5daebdce80ee422cf7bb96aa3bc", "--quiet"])
if not base.is_dir("libetonyek"):
base.cmd("git", ["clone", "https://github.com/LibreOffice/libetonyek.git"])
base.cmd_in_dir("libetonyek", "git", ["checkout", "cb396b4a9453a457469b62a740d8fb933c9442c3", "--quiet"])
base.replaceInFile("./libetonyek/src/lib/IWORKTable.cpp", "is_tree_valid", "valid_tree")
cmd_args = sys.argv[1:]
use_gperf = False
for arg in cmd_args:
if '--gperf' == arg:
use_gperf = True
if use_gperf:
base_gperf_args = ["--compare-strncmp", "--enum", "--null-strings", "--readonly-tables", "--language", "C++"]
base_gperf_files = ["IWORKToken.gperf", "KEY1Token.gperf", "KEY2Token.gperf", "NUM1Token.gperf", "PAG1Token.gperf"]
for file in base_gperf_files:
base.cmd_in_dir("./libetonyek/src/lib", "gperf", base_gperf_args + [file, "--output-file", file[0:file.find(".")] + ".inc"])
else:
base.copy_dir_content("./headers", "./libetonyek/src/lib")

File diff suppressed because it is too large Load Diff

View File

@ -1,727 +0,0 @@
/* C++ code produced by gperf version 3.0.1 */
/* Command-line: gperf --compare-strncmp --enum --null-strings --readonly-tables --language C++ --output-file KEY1Token.inc KEY1Token.gperf */
/* Computed positions: -k'1,3,6,9,14,$' */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
/* The character set is not based on ISO-646. */
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
#endif
#line 10 "KEY1Token.gperf"
#if defined __GNUC__
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
using namespace KEY1Token;
#line 18 "KEY1Token.gperf"
struct Token
{
const char *name;
int id;
};
#include <string.h>
/* maximum key range = 602, duplicates = 0 */
class Perfect_Hash
{
private:
static inline unsigned int hash (const char *str, unsigned int len);
public:
static const struct Token *in_word_set (const char *str, unsigned int len);
};
inline unsigned int
Perfect_Hash::hash (register const char *str, register unsigned int len)
{
static const unsigned short asso_values[] =
{
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 220, 612, 0, 612, 612,
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 612, 0, 0, 0, 0,
0, 0, 10, 612, 612, 612, 0, 612, 30, 15,
55, 612, 5, 60, 5, 612, 10, 612, 612, 612,
612, 612, 612, 612, 612, 0, 612, 20, 165, 115,
65, 0, 105, 135, 175, 60, 0, 0, 30, 145,
10, 5, 155, 10, 5, 30, 5, 200, 15, 20,
0, 190, 0, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
612, 612, 612, 612, 612, 612
};
register int hval = len;
switch (hval)
{
default:
hval += asso_values[(unsigned char)str[13]];
/*FALLTHROUGH*/
case 13:
case 12:
case 11:
case 10:
case 9:
hval += asso_values[(unsigned char)str[8]];
/*FALLTHROUGH*/
case 8:
case 7:
case 6:
hval += asso_values[(unsigned char)str[5]];
/*FALLTHROUGH*/
case 5:
case 4:
case 3:
hval += asso_values[(unsigned char)str[2]];
/*FALLTHROUGH*/
case 2:
case 1:
hval += asso_values[(unsigned char)str[0]];
break;
}
return hval + asso_values[(unsigned char)str[len - 1]];
}
const struct Token *
Perfect_Hash::in_word_set (register const char *str, register unsigned int len)
{
enum
{
TOTAL_KEYWORDS = 203,
MIN_WORD_LENGTH = 1,
MAX_WORD_LENGTH = 39,
MIN_HASH_VALUE = 10,
MAX_HASH_VALUE = 611
};
static const struct Token wordlist[] =
{
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0},
#line 199 "KEY1Token.gperf"
{"theme",theme},
{(char*)0},
#line 211 "KEY1Token.gperf"
{"tr",tr},
{(char*)0},
#line 196 "KEY1Token.gperf"
{"text",text},
#line 207 "KEY1Token.gperf"
{"title",title},
{(char*)0},
#line 198 "KEY1Token.gperf"
{"textbox",textbox},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 65 "KEY1Token.gperf"
{"element",element},
{(char*)0},
#line 132 "KEY1Token.gperf"
{"none",none},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0},
#line 175 "KEY1Token.gperf"
{"size",size},
{(char*)0}, {(char*)0},
#line 209 "KEY1Token.gperf"
{"tl",tl},
{(char*)0},
#line 206 "KEY1Token.gperf"
{"tile",tile},
#line 168 "KEY1Token.gperf"
{"serie",serie},
{(char*)0},
#line 221 "KEY1Token.gperf"
{"version",version},
{(char*)0},
#line 112 "KEY1Token.gperf"
{"line",line},
{(char*)0}, {(char*)0}, {(char*)0},
#line 174 "KEY1Token.gperf"
{"showZero",showZero},
{(char*)0},
#line 133 "KEY1Token.gperf"
{"notes",notes},
{(char*)0},
#line 188 "KEY1Token.gperf"
{"stroke-style",stroke_style},
{(char*)0},
#line 32 "KEY1Token.gperf"
{"axes",axes},
#line 172 "KEY1Token.gperf"
{"shape",shape},
{(char*)0},
#line 187 "KEY1Token.gperf"
{"stroke-color",stroke_color},
#line 166 "KEY1Token.gperf"
{"sequence",sequence},
{(char*)0},
#line 183 "KEY1Token.gperf"
{"start",start},
{(char*)0}, {(char*)0}, {(char*)0},
#line 182 "KEY1Token.gperf"
{"span",span},
#line 185 "KEY1Token.gperf"
{"steps",steps},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 93 "KEY1Token.gperf"
{"ident",ident},
{(char*)0}, {(char*)0}, {(char*)0},
#line 134 "KEY1Token.gperf"
{"null",null},
#line 197 "KEY1Token.gperf"
{"text-attributes",text_attributes},
{(char*)0},
#line 130 "KEY1Token.gperf"
{"natural-size",natural_size},
{(char*)0},
#line 131 "KEY1Token.gperf"
{"node",node},
#line 111 "KEY1Token.gperf"
{"level",level},
{(char*)0},
#line 225 "KEY1Token.gperf"
{"visible",visible},
{(char*)0}, {(char*)0},
#line 95 "KEY1Token.gperf"
{"image",image},
{(char*)0},
#line 171 "KEY1Token.gperf"
{"shadow-style",shadow_style},
{(char*)0},
#line 67 "KEY1Token.gperf"
{"end-color",end_color},
{(char*)0}, {(char*)0},
#line 208 "KEY1Token.gperf"
{"titleVisible",titleVisible},
#line 212 "KEY1Token.gperf"
{"tracks-master",tracks_master},
#line 53 "KEY1Token.gperf"
{"data",data},
#line 177 "KEY1Token.gperf"
{"slide",slide},
{(char*)0}, {(char*)0},
#line 62 "KEY1Token.gperf"
{"div",div},
#line 195 "KEY1Token.gperf"
{"tail",tail},
#line 170 "KEY1Token.gperf"
{"seriesDirection",seriesDirection},
#line 169 "KEY1Token.gperf"
{"series",series},
{(char*)0},
#line 162 "KEY1Token.gperf"
{"relative",relative},
#line 60 "KEY1Token.gperf"
{"direction",direction},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 27 "KEY1Token.gperf"
{"altLineVisible",altLineVisible},
{(char*)0}, {(char*)0}, {(char*)0},
#line 173 "KEY1Token.gperf"
{"showGrid",showGrid},
#line 33 "KEY1Token.gperf"
{"axis",axis},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 161 "KEY1Token.gperf"
{"reference",reference},
#line 114 "KEY1Token.gperf"
{"line-tail-style",line_tail_style},
{(char*)0}, {(char*)0}, {(char*)0},
#line 73 "KEY1Token.gperf"
{"font",font},
{(char*)0},
#line 137 "KEY1Token.gperf"
{"offset",offset},
#line 92 "KEY1Token.gperf"
{"id",id},
{(char*)0},
#line 160 "KEY1Token.gperf"
{"rect",rect},
#line 180 "KEY1Token.gperf"
{"solid",solid},
{(char*)0}, {(char*)0},
#line 66 "KEY1Token.gperf"
{"end",end},
#line 77 "KEY1Token.gperf"
{"font-name",font_name},
{(char*)0},
#line 159 "KEY1Token.gperf"
{"radius",radius},
#line 61 "KEY1Token.gperf"
{"display-name",display_name},
{(char*)0},
#line 68 "KEY1Token.gperf"
{"file",file},
{(char*)0},
#line 45 "KEY1Token.gperf"
{"center",center},
{(char*)0}, {(char*)0},
#line 109 "KEY1Token.gperf"
{"left",left},
{(char*)0}, {(char*)0},
#line 51 "KEY1Token.gperf"
{"content",content},
#line 64 "KEY1Token.gperf"
{"duration",duration},
#line 71 "KEY1Token.gperf"
{"fill-type",fill_type},
#line 163 "KEY1Token.gperf"
{"right",right},
#line 139 "KEY1Token.gperf"
{"orientation",orientation},
{(char*)0}, {(char*)0},
#line 78 "KEY1Token.gperf"
{"font-size",font_size},
#line 50 "KEY1Token.gperf"
{"color",color},
{(char*)0}, {(char*)0}, {(char*)0},
#line 129 "KEY1Token.gperf"
{"name",name},
#line 28 "KEY1Token.gperf"
{"angle",angle},
{(char*)0}, {(char*)0}, {(char*)0},
#line 215 "KEY1Token.gperf"
{"type",type},
#line 52 "KEY1Token.gperf"
{"dash-style",dash_style},
{(char*)0}, {(char*)0},
#line 82 "KEY1Token.gperf"
{"gradient",gradient},
#line 56 "KEY1Token.gperf"
{"dataFormatterPrefix",dataFormatterPrefix},
#line 54 "KEY1Token.gperf"
{"dataFormatterHasThousandsSeparators",dataFormatterHasThousandsSeparators},
#line 135 "KEY1Token.gperf"
{"number",number},
#line 38 "KEY1Token.gperf"
{"br",br},
#line 222 "KEY1Token.gperf"
{"vertical",vertical},
#line 57 "KEY1Token.gperf"
{"dataFormatterSuffix",dataFormatterSuffix},
#line 193 "KEY1Token.gperf"
{"table",table},
{(char*)0}, {(char*)0}, {(char*)0},
#line 24 "KEY1Token.gperf"
{"DefaultLegendRelativePosition",DefaultLegendRelativePosition},
{(char*)0}, {(char*)0},
#line 146 "KEY1Token.gperf"
{"pattern",pattern},
{(char*)0},
#line 55 "KEY1Token.gperf"
{"dataFormatterNumberOfDecimals",dataFormatterNumberOfDecimals},
{(char*)0}, {(char*)0},
#line 165 "KEY1Token.gperf"
{"segment",segment},
{(char*)0},
#line 59 "KEY1Token.gperf"
{"dict",dict},
{(char*)0}, {(char*)0},
#line 153 "KEY1Token.gperf"
{"presentation",presentation},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 35 "KEY1Token.gperf"
{"bl",bl},
#line 126 "KEY1Token.gperf"
{"metadata",metadata},
{(char*)0},
#line 86 "KEY1Token.gperf"
{"guide",guide},
{(char*)0},
#line 181 "KEY1Token.gperf"
{"spacing",spacing},
#line 120 "KEY1Token.gperf"
{"majorTickPositions",majorTickPositions},
{(char*)0},
#line 70 "KEY1Token.gperf"
{"fill-style",fill_style},
{(char*)0},
#line 118 "KEY1Token.gperf"
{"lock-aspect-ratio",lock_aspect_ratio},
{(char*)0},
#line 44 "KEY1Token.gperf"
{"byte-size",byte_size},
{(char*)0},
#line 40 "KEY1Token.gperf"
{"bullet",bullet},
#line 25 "KEY1Token.gperf"
{"DefaultLegendSize",DefaultLegendSize},
#line 128 "KEY1Token.gperf"
{"minorTickPositions",minorTickPositions},
{(char*)0},
#line 202 "KEY1Token.gperf"
{"tickLabelsAngle",tickLabelsAngle},
#line 127 "KEY1Token.gperf"
{"middle",middle},
{(char*)0},
#line 152 "KEY1Token.gperf"
{"pos",pos},
#line 155 "KEY1Token.gperf"
{"prototype-data",prototype_data},
#line 31 "KEY1Token.gperf"
{"array",array},
{(char*)0},
#line 122 "KEY1Token.gperf"
{"master-slide",master_slide},
#line 117 "KEY1Token.gperf"
{"location",location},
#line 176 "KEY1Token.gperf"
{"size-technique",size_technique},
{(char*)0},
#line 79 "KEY1Token.gperf"
{"font-superscript",font_superscript},
#line 138 "KEY1Token.gperf"
{"opacity",opacity},
{(char*)0}, {(char*)0}, {(char*)0},
#line 100 "KEY1Token.gperf"
{"interBarGap",interBarGap},
{(char*)0}, {(char*)0},
#line 156 "KEY1Token.gperf"
{"prototype-drawables",prototype_drawables},
{(char*)0},
#line 58 "KEY1Token.gperf"
{"description",description},
#line 43 "KEY1Token.gperf"
{"bullets",bullets},
{(char*)0},
#line 76 "KEY1Token.gperf"
{"font-ligatures",font_ligatures},
{(char*)0},
#line 191 "KEY1Token.gperf"
{"symbol",symbol},
#line 154 "KEY1Token.gperf"
{"prototype-bullets",prototype_bullets},
{(char*)0},
#line 194 "KEY1Token.gperf"
{"tab-stops",tab_stops},
#line 90 "KEY1Token.gperf"
{"horizontal",horizontal},
{(char*)0},
#line 204 "KEY1Token.gperf"
{"tickLabelsVisible",tickLabelsVisible},
{(char*)0},
#line 192 "KEY1Token.gperf"
{"symbolFillMode",symbolFillMode},
#line 74 "KEY1Token.gperf"
{"font-color",font_color},
{(char*)0}, {(char*)0},
#line 124 "KEY1Token.gperf"
{"master-slides",master_slides},
#line 147 "KEY1Token.gperf"
{"pieSliceOffset",pieSliceOffset},
{(char*)0}, {(char*)0}, {(char*)0},
#line 42 "KEY1Token.gperf"
{"bullet-indentation",bullet_indentation},
{(char*)0}, {(char*)0},
#line 87 "KEY1Token.gperf"
{"guides",guides},
{(char*)0}, {(char*)0},
#line 88 "KEY1Token.gperf"
{"head",head},
#line 226 "KEY1Token.gperf"
{"width",width},
#line 89 "KEY1Token.gperf"
{"hidden",hidden},
{(char*)0}, {(char*)0},
#line 46 "KEY1Token.gperf"
{"character",character},
#line 69 "KEY1Token.gperf"
{"fill-color",fill_color},
#line 81 "KEY1Token.gperf"
{"g",g},
#line 75 "KEY1Token.gperf"
{"font-kerning",font_kerning},
{(char*)0},
#line 103 "KEY1Token.gperf"
{"justified",justified},
{(char*)0},
#line 116 "KEY1Token.gperf"
{"lineVisible",lineVisible},
#line 107 "KEY1Token.gperf"
{"labelVisible",labelVisible},
{(char*)0}, {(char*)0}, {(char*)0},
#line 119 "KEY1Token.gperf"
{"locked",locked},
#line 189 "KEY1Token.gperf"
{"stroke-width",stroke_width},
{(char*)0},
#line 200 "KEY1Token.gperf"
{"thumbnail",thumbnail},
#line 201 "KEY1Token.gperf"
{"thumbnails",thumbnails},
#line 190 "KEY1Token.gperf"
{"styles",styles},
{(char*)0}, {(char*)0},
#line 136 "KEY1Token.gperf"
{"numberOfPoints",numberOfPoints},
#line 49 "KEY1Token.gperf"
{"chartFrame",chartFrame},
#line 167 "KEY1Token.gperf"
{"sequence-bullet-style",sequence_bullet_style},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 214 "KEY1Token.gperf"
{"transition-style",transition_style},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 110 "KEY1Token.gperf"
{"legend",legend},
#line 148 "KEY1Token.gperf"
{"pieSlicePercentVisible",pieSlicePercentVisible},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 47 "KEY1Token.gperf"
{"character-bullet-style",character_bullet_style},
{(char*)0},
#line 213 "KEY1Token.gperf"
{"transformation",transformation},
#line 224 "KEY1Token.gperf"
{"visibility",visibility},
#line 186 "KEY1Token.gperf"
{"string",string},
{(char*)0},
#line 39 "KEY1Token.gperf"
{"buildChunkingStyle",buildChunkingStyle},
{(char*)0}, {(char*)0},
#line 184 "KEY1Token.gperf"
{"start-color",start_color},
{(char*)0},
#line 210 "KEY1Token.gperf"
{"top",top},
#line 63 "KEY1Token.gperf"
{"drawables",drawables},
#line 179 "KEY1Token.gperf"
{"slide-size",slide_size},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 113 "KEY1Token.gperf"
{"line-head-style",line_head_style},
#line 157 "KEY1Token.gperf"
{"prototype-plugin",prototype_plugin},
{(char*)0}, {(char*)0},
#line 80 "KEY1Token.gperf"
{"font-underline",font_underline},
{(char*)0},
#line 97 "KEY1Token.gperf"
{"image-scale",image_scale},
{(char*)0},
#line 106 "KEY1Token.gperf"
{"labelPosition",labelPosition},
{(char*)0},
#line 96 "KEY1Token.gperf"
{"image-data",image_data},
{(char*)0}, {(char*)0}, {(char*)0},
#line 145 "KEY1Token.gperf"
{"path",path},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0},
#line 34 "KEY1Token.gperf"
{"background-fill-style",background_fill_style},
#line 158 "KEY1Token.gperf"
{"prototype-plugins",prototype_plugins},
{(char*)0}, {(char*)0},
#line 123 "KEY1Token.gperf"
{"master-slide-id",master_slide_id},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 178 "KEY1Token.gperf"
{"slide-list",slide_list},
#line 121 "KEY1Token.gperf"
{"marker-type",marker_type},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0},
#line 91 "KEY1Token.gperf"
{"http://developer.apple.com/schemas/APXL",NS_URI_KEY},
{(char*)0}, {(char*)0}, {(char*)0},
#line 98 "KEY1Token.gperf"
{"image-bullet-style",image_bullet_style},
#line 30 "KEY1Token.gperf"
{"application-version",application_version},
{(char*)0},
#line 149 "KEY1Token.gperf"
{"plugin",plugin},
#line 151 "KEY1Token.gperf"
{"point_at_top",point_at_top},
#line 104 "KEY1Token.gperf"
{"key",key},
{(char*)0}, {(char*)0},
#line 29 "KEY1Token.gperf"
{"application-name",application_name},
{(char*)0},
#line 223 "KEY1Token.gperf"
{"vertical-alignment",vertical_alignment},
#line 83 "KEY1Token.gperf"
{"gradient-angle",gradient_angle},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0},
#line 144 "KEY1Token.gperf"
{"paragraph-tail-indent",paragraph_tail_indent},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0},
#line 142 "KEY1Token.gperf"
{"paragraph-first-line-indent",paragraph_first_line_indent},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 72 "KEY1Token.gperf"
{"floating-content",floating_content},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 150 "KEY1Token.gperf"
{"plugin-data",plugin_data},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0},
#line 36 "KEY1Token.gperf"
{"body",body},
{(char*)0}, {(char*)0},
#line 41 "KEY1Token.gperf"
{"bullet-characters",bullet_characters},
{(char*)0}, {(char*)0}, {(char*)0},
#line 143 "KEY1Token.gperf"
{"paragraph-head-indent",paragraph_head_indent},
{(char*)0}, {(char*)0},
#line 99 "KEY1Token.gperf"
{"inherited",inherited},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0},
#line 125 "KEY1Token.gperf"
{"match-point",match_point},
{(char*)0},
#line 216 "KEY1Token.gperf"
{"ui-state",ui_state},
#line 102 "KEY1Token.gperf"
{"is-filled",is_filled},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0},
#line 115 "KEY1Token.gperf"
{"lineOpacity",lineOpacity},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0},
#line 37 "KEY1Token.gperf"
{"bottom",bottom},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0},
#line 140 "KEY1Token.gperf"
{"page-number",page_number},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 205 "KEY1Token.gperf"
{"time-stamp",time_stamp},
{(char*)0},
#line 203 "KEY1Token.gperf"
{"tickLabelsOpacity",tickLabelsOpacity},
{(char*)0}, {(char*)0}, {(char*)0},
#line 94 "KEY1Token.gperf"
{"id-ref",id_ref},
{(char*)0}, {(char*)0},
#line 141 "KEY1Token.gperf"
{"paragraph-alignment",paragraph_alignment},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0},
#line 164 "KEY1Token.gperf"
{"scale-to-fit",scale_to_fit},
{(char*)0},
#line 101 "KEY1Token.gperf"
{"interSeriesGap",interSeriesGap},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0},
#line 219 "KEY1Token.gperf"
{"userMaximum",userMaximum},
{(char*)0}, {(char*)0},
#line 217 "KEY1Token.gperf"
{"useUserMaximum",useUserMaximum},
#line 108 "KEY1Token.gperf"
{"layerElementsForShadowing",layerElementsForShadowing},
{(char*)0},
#line 105 "KEY1Token.gperf"
{"labelOpacity",labelOpacity},
{(char*)0}, {(char*)0},
#line 48 "KEY1Token.gperf"
{"chart-prototype",chart_prototype},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0},
#line 220 "KEY1Token.gperf"
{"userMinimum",userMinimum},
{(char*)0}, {(char*)0},
#line 218 "KEY1Token.gperf"
{"useUserMinimum",useUserMinimum},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0},
#line 26 "KEY1Token.gperf"
{"altLineOpacity",altLineOpacity},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0},
#line 85 "KEY1Token.gperf"
{"grow-horizontally",grow_horizontally},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 84 "KEY1Token.gperf"
{"gridOpacity",gridOpacity}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
{
register const char *s = wordlist[key].name;
if (s && *str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
return &wordlist[key];
}
}
return 0;
}
#line 227 "KEY1Token.gperf"

View File

@ -1,300 +0,0 @@
/* C++ code produced by gperf version 3.0.1 */
/* Command-line: gperf --compare-strncmp --enum --null-strings --readonly-tables --language C++ --output-file KEY2Token.inc KEY2Token.gperf */
/* Computed positions: -k'1,4,$' */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
/* The character set is not based on ISO-646. */
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
#endif
#line 10 "KEY2Token.gperf"
#if defined __GNUC__
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
using namespace KEY2Token;
#line 18 "KEY2Token.gperf"
struct Token
{
const char *name;
int id;
};
#include <string.h>
/* maximum key range = 140, duplicates = 0 */
class Perfect_Hash
{
private:
static inline unsigned int hash (const char *str, unsigned int len);
public:
static const struct Token *in_word_set (const char *str, unsigned int len);
};
inline unsigned int
Perfect_Hash::hash (register const char *str, register unsigned int len)
{
static const unsigned char asso_values[] =
{
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 5, 65,
0, 141, 35, 0, 141, 5, 141, 0, 141, 141,
141, 141, 141, 141, 141, 141, 0, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 0, 25, 0,
15, 0, 55, 10, 10, 5, 141, 15, 20, 0,
10, 25, 40, 141, 25, 25, 5, 0, 30, 5,
141, 40, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141
};
register int hval = len;
switch (hval)
{
default:
hval += asso_values[(unsigned char)str[3]];
/*FALLTHROUGH*/
case 3:
case 2:
case 1:
hval += asso_values[(unsigned char)str[0]];
break;
}
return hval + asso_values[(unsigned char)str[len - 1]];
}
const struct Token *
Perfect_Hash::in_word_set (register const char *str, register unsigned int len)
{
enum
{
TOTAL_KEYWORDS = 67,
MIN_WORD_LENGTH = 1,
MAX_WORD_LENGTH = 46,
MIN_HASH_VALUE = 1,
MAX_HASH_VALUE = 140
};
static const struct Token wordlist[] =
{
{(char*)0},
#line 49 "KEY2Token.gperf"
{"c",c},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0},
#line 65 "KEY2Token.gperf"
{"metadata",metadata},
#line 89 "KEY2Token.gperf"
{"type",type},
#line 84 "KEY2Token.gperf"
{"theme",theme},
#line 58 "KEY2Token.gperf"
{"i",i},
#line 50 "KEY2Token.gperf"
{"comment",comment},
#line 41 "KEY2Token.gperf"
{"animationType",animationType},
#line 66 "KEY2Token.gperf"
{"name",name},
#line 26 "KEY2Token.gperf"
{"2005112100",VERSION_STR_3},
{(char*)0},
#line 62 "KEY2Token.gperf"
{"master-slide",master_slide},
{(char*)0},
#line 83 "KEY2Token.gperf"
{"text",text},
#line 85 "KEY2Token.gperf"
{"theme-list",theme_list},
#line 28 "KEY2Token.gperf"
{"92008102400",VERSION_STR_5},
{(char*)0},
#line 36 "KEY2Token.gperf"
{"animationEndOffset",animationEndOffset},
{(char*)0},
#line 39 "KEY2Token.gperf"
{"animationStartOffset",animationStartOffset},
#line 27 "KEY2Token.gperf"
{"72007061400",VERSION_STR_4},
#line 35 "KEY2Token.gperf"
{"animationDuration",animationDuration},
#line 40 "KEY2Token.gperf"
{"animationTimingReferent",animationTimingReferent},
#line 73 "KEY2Token.gperf"
{"size",size},
#line 86 "KEY2Token.gperf"
{"title",title},
{(char*)0}, {(char*)0},
#line 55 "KEY2Token.gperf"
{"headline",headline},
#line 53 "KEY2Token.gperf"
{"direction",direction},
#line 52 "KEY2Token.gperf"
{"depth",depth},
#line 78 "KEY2Token.gperf"
{"sticky-note",sticky_note},
#line 34 "KEY2Token.gperf"
{"animationDelayAutomaticWith",animationDelayAutomaticWith},
#line 30 "KEY2Token.gperf"
{"animationAuto",animationAuto},
{(char*)0},
#line 67 "KEY2Token.gperf"
{"notes",notes},
#line 54 "KEY2Token.gperf"
{"events",events},
#line 42 "KEY2Token.gperf"
{"authors",authors},
#line 63 "KEY2Token.gperf"
{"master-slides",master_slides},
#line 70 "KEY2Token.gperf"
{"page",page},
#line 74 "KEY2Token.gperf"
{"slide",slide},
#line 80 "KEY2Token.gperf"
{"string",string},
#line 56 "KEY2Token.gperf"
{"headlineParagraphStyle",headlineParagraphStyle},
#line 37 "KEY2Token.gperf"
{"animationInterchunkAuto",animationInterchunkAuto},
{(char*)0},
#line 24 "KEY2Token.gperf"
{"2004102100",VERSION_STR_2},
#line 77 "KEY2Token.gperf"
{"slide-style",slide_style},
#line 33 "KEY2Token.gperf"
{"animationDelayAutmaticAfter",animationDelayAutomaticAfter},
#line 61 "KEY2Token.gperf"
{"keywords",keywords},
#line 32 "KEY2Token.gperf"
{"animationDelay",animationDelay},
#line 75 "KEY2Token.gperf"
{"slide-list",slide_list},
{(char*)0},
#line 31 "KEY2Token.gperf"
{"animationAutoPlay",animationAutoPlay},
#line 60 "KEY2Token.gperf"
{"key",key},
#line 51 "KEY2Token.gperf"
{"decimal-number",number},
#line 82 "KEY2Token.gperf"
{"stylesheet",stylesheet},
{(char*)0},
#line 79 "KEY2Token.gperf"
{"sticky-notes",sticky_notes},
#line 29 "KEY2Token.gperf"
{"BGBuildDurationProperty",BGBuildDurationProperty},
#line 38 "KEY2Token.gperf"
{"animationInterchunkDelay",animationInterchunkDelay},
#line 45 "KEY2Token.gperf"
{"build",build},
#line 68 "KEY2Token.gperf"
{"number",number},
#line 87 "KEY2Token.gperf"
{"title-placeholder",title_placeholder},
#line 69 "KEY2Token.gperf"
{"object-placeholder",object_placeholder},
{(char*)0},
#line 64 "KEY2Token.gperf"
{"master-ref",master_ref},
#line 46 "KEY2Token.gperf"
{"build-chunk",build_chunk},
#line 90 "KEY2Token.gperf"
{"version",version},
{(char*)0}, {(char*)0},
#line 25 "KEY2Token.gperf"
{"2005092101",COMPATIBLE_VERSION_STR_3,},
{(char*)0},
#line 48 "KEY2Token.gperf"
{"bullets",bullets},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 47 "KEY2Token.gperf"
{"build-chunks",build_chunks},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 72 "KEY2Token.gperf"
{"presentation",presentation},
{(char*)0},
#line 76 "KEY2Token.gperf"
{"slide-number-placeholder",slide_number_placeholder},
{(char*)0}, {(char*)0}, {(char*)0},
#line 59 "KEY2Token.gperf"
{"info-ref",info_ref},
{(char*)0}, {(char*)0},
#line 57 "KEY2Token.gperf"
{"http://developer.apple.com/namespaces/keynote2",NS_URI_KEY},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 88 "KEY2Token.gperf"
{"title-placeholder-ref",title_placeholder_ref},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 43 "KEY2Token.gperf"
{"body-placeholder",body_placeholder},
{(char*)0}, {(char*)0},
#line 81 "KEY2Token.gperf"
{"style-ref",style_ref},
{(char*)0},
#line 71 "KEY2Token.gperf"
{"parent-build-ref",parent_build_ref},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 44 "KEY2Token.gperf"
{"body-placeholder-ref",body_placeholder_ref}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
{
register const char *s = wordlist[key].name;
if (s && *str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
return &wordlist[key];
}
}
return 0;
}
#line 91 "KEY2Token.gperf"

View File

@ -1,151 +0,0 @@
/* C++ code produced by gperf version 3.0.1 */
/* Command-line: gperf --compare-strncmp --enum --null-strings --readonly-tables --language C++ --output-file NUM1Token.inc NUM1Token.gperf */
/* Computed positions: -k'$' */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
/* The character set is not based on ISO-646. */
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
#endif
#line 10 "NUM1Token.gperf"
#if defined __GNUC__
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
using namespace NUM1Token;
#line 18 "NUM1Token.gperf"
struct Token
{
const char *name;
int id;
};
#include <string.h>
/* maximum key range = 34, duplicates = 0 */
class Perfect_Hash
{
private:
static inline unsigned int hash (const char *str, unsigned int len);
public:
static const struct Token *in_word_set (const char *str, unsigned int len);
};
inline unsigned int
Perfect_Hash::hash (register const char *str, register unsigned int len)
{
static const unsigned char asso_values[] =
{
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 0, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 0, 41, 41, 41, 41, 41, 41, 41, 41,
0, 10, 41, 41, 41, 0, 0, 41, 41, 41,
41, 5, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41
};
return len + asso_values[(unsigned char)str[len - 1]];
}
const struct Token *
Perfect_Hash::in_word_set (register const char *str, register unsigned int len)
{
enum
{
TOTAL_KEYWORDS = 10,
MIN_WORD_LENGTH = 7,
MAX_WORD_LENGTH = 40,
MIN_HASH_VALUE = 7,
MAX_HASH_VALUE = 40
};
static const struct Token wordlist[] =
{
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0},
#line 29 "NUM1Token.gperf"
{"version",version},
#line 25 "NUM1Token.gperf"
{"document",document},
#line 30 "NUM1Token.gperf"
{"workspace",workspace},
#line 28 "NUM1Token.gperf"
{"stylesheet",stylesheet},
#line 24 "NUM1Token.gperf"
{"92008102400",VERSION_STR_2},
{(char*)0}, {(char*)0},
#line 32 "NUM1Token.gperf"
{"workspace-name",workspace_name},
#line 33 "NUM1Token.gperf"
{"workspace-style",workspace_style},
{(char*)0}, {(char*)0}, {(char*)0},
#line 27 "NUM1Token.gperf"
{"page-info",page_info},
#line 31 "NUM1Token.gperf"
{"workspace-array",workspace_array},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0},
#line 26 "NUM1Token.gperf"
{"http://developer.apple.com/namespaces/ls",NS_URI_LS}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
{
register const char *s = wordlist[key].name;
if (s && *str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
return &wordlist[key];
}
}
return 0;
}
#line 34 "NUM1Token.gperf"

View File

@ -1,209 +0,0 @@
/* C++ code produced by gperf version 3.0.1 */
/* Command-line: gperf --compare-strncmp --enum --null-strings --readonly-tables --language C++ --output-file PAG1Token.inc PAG1Token.gperf */
/* Computed positions: -k'1,6' */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
/* The character set is not based on ISO-646. */
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
#endif
#line 10 "PAG1Token.gperf"
#if defined __GNUC__
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
using namespace PAG1Token;
#line 18 "PAG1Token.gperf"
struct Token
{
const char *name;
int id;
};
#include <string.h>
/* maximum key range = 51, duplicates = 0 */
class Perfect_Hash
{
private:
static inline unsigned int hash (const char *str, unsigned int len);
public:
static const struct Token *in_word_set (const char *str, unsigned int len);
};
inline unsigned int
Perfect_Hash::hash (register const char *str, register unsigned int len)
{
static const unsigned char asso_values[] =
{
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 25, 55, 0, 55, 10,
55, 55, 55, 55, 55, 55, 55, 10, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
5, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 5, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 5, 25, 15,
20, 0, 20, 15, 5, 55, 55, 5, 10, 55,
0, 15, 5, 55, 0, 0, 0, 55, 5, 10,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55
};
register int hval = len;
switch (hval)
{
default:
hval += asso_values[(unsigned char)str[5]];
/*FALLTHROUGH*/
case 5:
case 4:
case 3:
case 2:
case 1:
hval += asso_values[(unsigned char)str[0]];
break;
}
return hval;
}
const struct Token *
Perfect_Hash::in_word_set (register const char *str, register unsigned int len)
{
enum
{
TOTAL_KEYWORDS = 31,
MIN_WORD_LENGTH = 4,
MAX_WORD_LENGTH = 40,
MIN_HASH_VALUE = 4,
MAX_HASH_VALUE = 54
};
static const struct Token wordlist[] =
{
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 38 "PAG1Token.gperf"
{"note",note},
#line 49 "PAG1Token.gperf"
{"rpage",rpage},
#line 39 "PAG1Token.gperf"
{"number",number},
{(char*)0}, {(char*)0},
#line 41 "PAG1Token.gperf"
{"page",page},
#line 52 "PAG1Token.gperf"
{"stylesheet",stylesheet},
#line 33 "PAG1Token.gperf"
{"header",header},
#line 51 "PAG1Token.gperf"
{"slprint-info",slprint_info},
{(char*)0},
#line 47 "PAG1Token.gperf"
{"prototype",prototype},
#line 44 "PAG1Token.gperf"
{"page-scale",page_scale},
#line 37 "PAG1Token.gperf"
{"layout",layout},
{(char*)0}, {(char*)0},
#line 27 "PAG1Token.gperf"
{"cell",cell},
#line 40 "PAG1Token.gperf"
{"order",order},
#line 43 "PAG1Token.gperf"
{"page-height",page_height},
#line 53 "PAG1Token.gperf"
{"textbox",textbox},
{(char*)0},
#line 28 "PAG1Token.gperf"
{"date",date},
#line 45 "PAG1Token.gperf"
{"page-width",page_width},
#line 31 "PAG1Token.gperf"
{"footer",footer},
#line 54 "PAG1Token.gperf"
{"version",version},
#line 29 "PAG1Token.gperf"
{"document",document},
#line 26 "PAG1Token.gperf"
{"body",body},
#line 42 "PAG1Token.gperf"
{"page-group",page_group},
#line 24 "PAG1Token.gperf"
{"92008102400",VERSION_STR_4},
#line 25 "PAG1Token.gperf"
{"SLCreationDateProperty",SLCreationDateProperty},
#line 50 "PAG1Token.gperf"
{"section-prototypes",section_prototypes},
#line 35 "PAG1Token.gperf"
{"kSFWPFootnoteGapProperty",kSFWPFootnoteGapProperty},
#line 36 "PAG1Token.gperf"
{"kSFWPFootnoteKindProperty",kSFWPFootnoteKindProperty},
#line 48 "PAG1Token.gperf"
{"publication-info",publication_info},
{(char*)0}, {(char*)0}, {(char*)0},
#line 46 "PAG1Token.gperf"
{"print-info",print_info},
{(char*)0}, {(char*)0},
#line 32 "PAG1Token.gperf"
{"footnote",footnote},
{(char*)0},
#line 34 "PAG1Token.gperf"
{"http://developer.apple.com/namespaces/sl",NS_URI_SL},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 30 "PAG1Token.gperf"
{"drawables",drawables}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
{
register const char *s = wordlist[key].name;
if (s && *str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
return &wordlist[key];
}
}
return 0;
}
#line 55 "PAG1Token.gperf"

View File

@ -259,17 +259,20 @@ buildBoost()
echo Building Boost for iPhone
# Install this one so we can copy the headers for the frameworks...
./b2 -j16 --build-dir=iphone-build --stagedir=iphone-build/stage \
cxxflags="" \
--prefix=$PREFIXDIR toolset=darwin architecture=arm target-os=iphone \
macosx-version=iphone-${IOS_SDK_VERSION} define=_LITTLE_ENDIAN \
link=static stage
./b2 -j16 --build-dir=iphone-build --stagedir=iphone-build/stage \
--prefix=$PREFIXDIR toolset=darwin architecture=arm \
cxxflags="" \
target-os=iphone macosx-version=iphone-${IOS_SDK_VERSION} \
define=_LITTLE_ENDIAN link=static install
doneSection
echo Building Boost for iPhoneSimulator
./b2 -j16 --build-dir=iphonesim-build --stagedir=iphonesim-build/stage \
cxxflags="" \
toolset=darwin-${IOS_SDK_VERSION}~iphonesim architecture=x86 \
target-os=iphone macosx-version=iphonesim-${IOS_SDK_VERSION} \
link=static stage

View File

@ -18,14 +18,14 @@ namespace NSCSS
{
typedef std::map<std::wstring, std::wstring>::const_iterator styles_iterator;
CCompiledStyle::CCompiledStyle() : m_nDpi(96), m_UnitMeasure(Point), m_dCoreFontSize(DEFAULT_FONT_SIZE)
CCompiledStyle::CCompiledStyle() : m_nDpi(96), m_UnitMeasure(Point)
{}
CCompiledStyle::CCompiledStyle(const CCompiledStyle& oStyle) :
m_arParentsStyles(oStyle.m_arParentsStyles), m_sId(oStyle.m_sId),
m_nDpi(oStyle.m_nDpi), m_UnitMeasure(oStyle.m_UnitMeasure), m_dCoreFontSize(oStyle.m_dCoreFontSize),
m_nDpi(oStyle.m_nDpi), m_UnitMeasure(oStyle.m_UnitMeasure),
m_oFont(oStyle.m_oFont), m_oMargin(oStyle.m_oMargin), m_oPadding(oStyle.m_oPadding), m_oBackground(oStyle.m_oBackground),
m_oText(oStyle.m_oText), m_oBorder(oStyle.m_oBorder), m_oDisplay(oStyle.m_oDisplay), m_oTransform(oStyle.m_oTransform){}
m_oText(oStyle.m_oText), m_oBorder(oStyle.m_oBorder), m_oDisplay(oStyle.m_oDisplay){}
CCompiledStyle::~CCompiledStyle()
{
@ -44,7 +44,6 @@ namespace NSCSS
m_oPadding += oElement.m_oPadding;
m_oText += oElement.m_oText;
m_oDisplay += oElement.m_oDisplay;
m_oTransform += oElement.m_oTransform;
if (!oElement.m_sId.empty())
m_sId += L'+' + oElement.m_sId;
@ -67,7 +66,6 @@ namespace NSCSS
m_oPadding = oElement.m_oPadding;
m_oText = oElement.m_oText;
m_oDisplay = oElement.m_oDisplay;
m_oTransform = oElement.m_oTransform;
return *this;
}
@ -80,8 +78,7 @@ namespace NSCSS
m_oMargin == oStyle.m_oMargin &&
m_oPadding == oStyle.m_oPadding &&
m_oText == oStyle.m_oText &&
m_oDisplay == oStyle.m_oDisplay &&
m_oTransform == oStyle.m_oTransform;
m_oDisplay == oStyle.m_oDisplay;
}
void CCompiledStyle::StyleEquation(CCompiledStyle &oFirstStyle, CCompiledStyle &oSecondStyle)
@ -93,7 +90,6 @@ namespace NSCSS
NSProperties::CText ::Equation(oFirstStyle.m_oText, oSecondStyle.m_oText);
NSProperties::CBorder ::Equation(oFirstStyle.m_oBorder, oSecondStyle.m_oBorder);
NSProperties::CDisplay ::Equation(oFirstStyle.m_oDisplay, oSecondStyle.m_oDisplay);
NSProperties::CTransform ::Equation(oFirstStyle.m_oTransform, oSecondStyle.m_oTransform);
}
void CCompiledStyle::SetDpi(const unsigned short &uiDpi)
@ -120,10 +116,7 @@ namespace NSCSS
void CCompiledStyle::AddStyle(const std::map<std::wstring, std::wstring>& mStyle, const unsigned int unLevel, const bool& bHardMode)
{
const bool bIsThereBorder = (m_oBorder.Empty()) ? false : true;
const double dParentFontSize = (!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Point) : DEFAULT_FONT_SIZE;
if (0 == unLevel)
m_dCoreFontSize = dParentFontSize;
const double dFontSize = (!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Point) : DEFAULT_FONT_SIZE;
for (std::pair<std::wstring, std::wstring> pPropertie : mStyle)
{
@ -135,15 +128,15 @@ namespace NSCSS
CASE(L"font"):
{
m_oFont.SetValue(pPropertie.second, unLevel, bHardMode);
m_oFont.UpdateSize(dParentFontSize, m_dCoreFontSize);
m_oFont.UpdateLineHeight(dParentFontSize, m_dCoreFontSize);
m_oFont.UpdateSize(dFontSize);
m_oFont.UpdateLineHeight(dFontSize);
break;
}
CASE(L"font-size"):
CASE(L"font-size-adjust"):
{
m_oFont.SetSize(pPropertie.second, unLevel, bHardMode);
m_oFont.UpdateSize(dParentFontSize, m_dCoreFontSize);
m_oFont.UpdateSize(dFontSize);
break;
}
CASE(L"font-stretch"):
@ -183,7 +176,7 @@ namespace NSCSS
break;
m_oMargin.SetValues(pPropertie.second, unLevel, bHardMode);
m_oMargin.UpdateAll(dParentFontSize, m_dCoreFontSize);
m_oMargin.UpdateAll(dFontSize);
break;
}
CASE(L"margin-top"):
@ -203,7 +196,7 @@ namespace NSCSS
break;
m_oMargin.SetRight(pPropertie.second, unLevel, bHardMode);
m_oMargin.UpdateRight(dParentFontSize, m_dCoreFontSize);
m_oMargin.UpdateRight(dFontSize);
break;
}
CASE(L"margin-bottom"):
@ -213,7 +206,7 @@ namespace NSCSS
break;
m_oMargin.SetBottom(pPropertie.second, unLevel, bHardMode);
m_oMargin.UpdateBottom(dParentFontSize, m_dCoreFontSize);
m_oMargin.UpdateBottom(dFontSize);
break;
}
CASE(L"margin-left"):
@ -224,7 +217,7 @@ namespace NSCSS
break;
m_oMargin.SetLeft(pPropertie.second, unLevel, bHardMode);
m_oMargin.UpdateLeft(dParentFontSize, m_dCoreFontSize);
m_oMargin.UpdateLeft(dFontSize);
break;
}
//PADDING
@ -232,35 +225,35 @@ namespace NSCSS
CASE(L"mso-padding-alt"):
{
m_oPadding.SetValues(pPropertie.second, unLevel, bHardMode);
m_oPadding.UpdateAll(dParentFontSize, m_dCoreFontSize);
m_oPadding.UpdateAll(dFontSize);
break;
}
CASE(L"padding-top"):
CASE(L"mso-padding-top-alt"):
{
m_oPadding.SetTop(pPropertie.second, unLevel, bHardMode);
m_oPadding.UpdateTop(dParentFontSize, m_dCoreFontSize);
m_oPadding.UpdateTop(dFontSize);
break;
}
CASE(L"padding-right"):
CASE(L"mso-padding-right-alt"):
{
m_oPadding.SetRight(pPropertie.second, unLevel, bHardMode);
m_oPadding.UpdateRight(dParentFontSize, m_dCoreFontSize);
m_oPadding.UpdateRight(dFontSize);
break;
}
CASE(L"padding-bottom"):
CASE(L"mso-padding-bottom-alt"):
{
m_oPadding.SetBottom(pPropertie.second, unLevel, bHardMode);
m_oPadding.UpdateBottom(dParentFontSize, m_dCoreFontSize);
m_oPadding.UpdateBottom(dFontSize);
break;
}
CASE(L"padding-left"):
CASE(L"mso-padding-left-alt"):
{
m_oPadding.SetLeft(pPropertie.second, unLevel, bHardMode);
m_oPadding.UpdateLeft(dParentFontSize, m_dCoreFontSize);
m_oPadding.UpdateLeft(dFontSize);
break;
}
// TEXT
@ -435,12 +428,6 @@ namespace NSCSS
m_oDisplay.SetVAlign(pPropertie.second, unLevel, bHardMode);
break;
}
//TRANSFORM
CASE(L"transform"):
{
m_oTransform.SetMatrix(pPropertie.second, unLevel, bHardMode);
break;
}
default: AddOtherStyle(pPropertie, unLevel, bHardMode);
}
}

View File

@ -22,7 +22,6 @@ namespace NSCSS
unsigned short int m_nDpi;
UnitMeasure m_UnitMeasure;
double m_dCoreFontSize;
public:
NSProperties::CFont m_oFont;
NSProperties::CIndent m_oMargin;
@ -31,12 +30,11 @@ namespace NSCSS
NSProperties::CText m_oText;
NSProperties::CBorder m_oBorder;
NSProperties::CDisplay m_oDisplay;
NSProperties::CTransform m_oTransform;
CCompiledStyle();
CCompiledStyle(const CCompiledStyle& oStyle);
virtual ~CCompiledStyle();
~CCompiledStyle();
void SetDpi(const unsigned short& uiDpi);
void SetUnitMeasure(const UnitMeasure& enUnitMeasure);

View File

@ -13,14 +13,14 @@ namespace NSCSS
delete m_pInternal;
}
CCompiledStyle CCssCalculator::GetCompiledStyle(const std::vector<CNode> &arSelectors) const
CCompiledStyle CCssCalculator::GetCompiledStyle(const std::vector<CNode> &arSelectors, const bool& bIsSettings, const UnitMeasure& unitMeasure) const
{
return m_pInternal->GetCompiledStyle(arSelectors);
return m_pInternal->GetCompiledStyle(arSelectors, bIsSettings, unitMeasure);
}
bool CCssCalculator::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors) const
bool CCssCalculator::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors, const bool &bIsSettings, const UnitMeasure &unitMeasure) const
{
return m_pInternal->GetCompiledStyle(oStyle, arSelectors);
return m_pInternal->GetCompiledStyle(oStyle, arSelectors, bIsSettings, unitMeasure);
}
std::wstring CCssCalculator::CalculateStyleId(const CNode& oNode)
@ -48,11 +48,26 @@ namespace NSCSS
m_pInternal->AddStylesFromFile(wsFileName);
}
void CCssCalculator::SetUnitMeasure(const UnitMeasure& nType)
{
m_pInternal->SetUnitMeasure(nType);
}
void CCssCalculator::SetDpi(const unsigned short int& nValue)
{
m_pInternal->SetDpi(nValue);
}
void CCssCalculator::SetBodyTree(const CTree &oTree)
{
m_pInternal->SetBodyTree(oTree);
}
UnitMeasure CCssCalculator::GetUnitMeasure() const
{
return m_pInternal->GetUnitMeasure();
}
std::wstring CCssCalculator::GetEncoding() const
{
return m_pInternal->GetEncoding();
@ -63,26 +78,6 @@ namespace NSCSS
return m_pInternal->GetDpi();
}
void CCssCalculator::ClearPageData()
{
m_pInternal->ClearPageData();
}
void CCssCalculator::ClearEmbeddedStyles()
{
m_pInternal->ClearEmbeddedStyles();
}
void CCssCalculator::ClearAllowedStyleFiles()
{
m_pInternal->ClearAllowedStyleFiles();
}
void CCssCalculator::ClearStylesFromFile(const std::wstring& wsFilePath)
{
m_pInternal->ClearStylesFromFile(wsFilePath);
}
void CCssCalculator::Clear()
{
m_pInternal->Clear();

View File

@ -19,8 +19,8 @@ namespace NSCSS
CCssCalculator();
~CCssCalculator();
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors) const;
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors) const;
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point) const;
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point) const;
std::wstring CalculateStyleId(const CNode& oNode);
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors);
@ -30,15 +30,14 @@ namespace NSCSS
void AddStyles (const std::wstring& wsStyle);
void AddStylesFromFile(const std::wstring& wsFileName);
void SetUnitMeasure(const UnitMeasure& nType);
void SetDpi(const unsigned short int& nValue);
void SetBodyTree(const CTree &oTree);
UnitMeasure GetUnitMeasure() const;
std::wstring GetEncoding() const;
unsigned short int GetDpi() const;
void ClearPageData();
void ClearEmbeddedStyles();
void ClearAllowedStyleFiles();
void ClearStylesFromFile(const std::wstring& wsFilePath);
void Clear();
};
}

File diff suppressed because it is too large Load Diff

View File

@ -3,9 +3,11 @@
#include <vector>
#include <map>
#include <set>
#include <list>
#include <functional>
#include "CElement.h"
#include "StyleProperties.h"
#include "ConstValues.h"
#include "CUnitMeasureConverter.h"
#include "../../katana-parser/src/katana.h"
#ifdef CSS_CALCULATOR_WITH_XHTML
@ -14,43 +16,16 @@
namespace NSCSS
{
class CStyleStorage
class CCssCalculator_Private
{
public:
CStyleStorage();
~CStyleStorage();
unsigned short int m_nDpi;
unsigned short int m_nCountNodes;
UnitMeasure m_UnitMeasure;
void Clear();
std::list<std::wstring> m_arFiles;
void AddStyles(const std::string& sStyle);
void AddStyles(const std::wstring& wsStyle);
void AddStylesFromFile(const std::wstring& wsFileName);
std::map<std::wstring, CElement*> m_mData;
void ClearEmbeddedStyles();
void ClearAllowedStyleFiles();
void ClearStylesFromFile(const std::wstring& wsFileName);
#ifdef CSS_CALCULATOR_WITH_XHTML
void AddPageData(const std::wstring& wsPageName, const std::wstring& wsStyles);
void SetPageData(NSProperties::CPage& oPage, const std::map<std::wstring, std::wstring>& mData, unsigned int unLevel, bool bHardMode = false);
std::map<std::wstring, std::wstring> GetPageData(const std::wstring& wsPageName);
void ClearPageData();
#endif
const CElement* FindElement(const std::wstring& wsSelector);
private:
typedef struct
{
std::wstring m_wsStyleFilepath;
std::map<std::wstring, CElement*> m_mStyleData;
} TStyleFileData;
std::set<std::wstring> m_arEmptyStyleFiles;
std::set<std::wstring> m_arAllowedStyleFiles;
std::vector<TStyleFileData*> m_arStyleFiles;
std::map<std::wstring, CElement*> m_mEmbeddedStyleData;
#ifdef CSS_CALCULATOR_WITH_XHTML
typedef struct
{
std::vector<std::wstring> m_wsNames;
@ -58,14 +33,29 @@ namespace NSCSS
} TPageData;
std::vector<TPageData> m_arPageDatas;
std::map<StatistickElement, unsigned int> *m_mStatictics; // Количество повторений свойств id и style у селекторов
#ifdef CSS_CALCULATOR_WITH_XHTML
std::map<std::vector<CNode>, CCompiledStyle> m_mUsedStyles;
std::map<std::wstring, std::wstring> GetPageData(const std::wstring& wsPageName);
void SetPageData(NSProperties::CPage& oPage, const std::map<std::wstring, std::wstring>& mData, unsigned int unLevel, bool bHardMode = false);
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors);
void FindPrevAndKindElements(const CElement* pElement, const std::vector<std::wstring>& arNextNodes, std::vector<CElement*>& arFindedElements, const std::wstring& wsName, const std::vector<std::wstring>& arClasses = {});
std::vector<CElement*> FindElements(std::vector<std::wstring>& arNodes, std::vector<std::wstring>& arNextNodes, bool bIsSettings);
#endif
private:
void AddStyles(const std::string& sStyle, std::map<std::wstring, CElement*>& mStyleData);
void GetStylesheet(const KatanaStylesheet* oStylesheet, std::map<std::wstring, CElement*>& mStyleData);
void GetRule(const KatanaRule* oRule, std::map<std::wstring, CElement*>& mStyleData);
std::wstring m_sEncoding;
void GetStyleRule(const KatanaStyleRule* oRule, std::map<std::wstring, CElement*>& mStyleData);
void AddPageData(const std::wstring& wsPageName, const std::wstring& wsStyles);
void GetStylesheet(const KatanaStylesheet* oStylesheet);
void GetRule(const KatanaRule* oRule);
void GetStyleRule(const KatanaStyleRule* oRule);
std::wstring GetValueList(const KatanaArray* oValues);
@ -75,60 +65,36 @@ namespace NSCSS
std::map<std::wstring, std::wstring> GetDeclarationList(const KatanaArray* oDeclarations) const;
std::pair<std::wstring, std::wstring> GetDeclaration(const KatanaDeclaration* oDecl) const;
void GetOutputData(KatanaOutput* oOutput, std::map<std::wstring, CElement*>& mStyleData);
void GetOutputData(KatanaOutput* oOutput);
const CElement* FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map<std::wstring, CElement*>& mStyleData);
};
class CCssCalculator_Private
{
unsigned short int m_nDpi;
unsigned short int m_nCountNodes;
CStyleStorage m_oStyleStorage;
#ifdef CSS_CALCULATOR_WITH_XHTML
std::map<std::vector<CNode>, CCompiledStyle> m_mUsedStyles;
void SetPageData(NSProperties::CPage& oPage, const std::map<std::wstring, std::wstring>& mData, unsigned int unLevel, bool bHardMode = false);
std::map<std::wstring, std::wstring> GetPageData(const std::wstring &wsPageName);
#endif
void FindPrevAndKindElements(const CElement* pElement, const std::vector<std::wstring>& arNextNodes, std::vector<const CElement*>& arFindedElements, const std::wstring& wsName, const std::vector<std::wstring>& arClasses = {});
std::wstring m_sEncoding;
public:
CCssCalculator_Private();
~CCssCalculator_Private();
#ifdef CSS_CALCULATOR_WITH_XHTML
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors);
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors);
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point);
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point);
std::wstring CalculateStyleId(const CNode& oNode);
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors);
void ClearPageData();
#endif
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors);
std::vector<const CElement*> FindElements(std::vector<std::wstring>& arNodes, std::vector<std::wstring>& arNextNodes);
void AddStyles(const std::string& sStyle);
void AddStyles(const std::wstring& wsStyle);
void AddStylesFromFile(const std::wstring& wsFileName);
void SetUnitMeasure(const UnitMeasure& nType);
void SetDpi(unsigned short int nValue);
void SetBodyTree(const CTree &oTree);
UnitMeasure GetUnitMeasure() const;
std::wstring GetEncoding() const;
unsigned short int GetDpi() const;
void ClearEmbeddedStyles();
void ClearAllowedStyleFiles();
void ClearStylesFromFile(const std::wstring& wsFilePath);
void Clear();
};
const std::map<std::wstring, CElement*>* GetData() const;
inline bool IsTableElement(const std::wstring& wsNameTag);
void Clear();
};
}
#endif // CCSSCALCULATOR_PRIVATE_H

View File

@ -40,7 +40,6 @@ namespace NSCSS
{
m_sSelector = sSelector;
m_sFullSelector = m_sSelector;
UpdateWeight();
}
void NSCSS::CElement::AddPropertie(const std::wstring &sName, const std::wstring& sValue)
@ -68,7 +67,6 @@ namespace NSCSS
m_arPrevElements.push_back(oPrevElement);
oPrevElement->m_sFullSelector += L' ' + m_sFullSelector;
UpdateWeight();
}
void CElement::AddKinElement(CElement *oKinElement)
@ -78,7 +76,6 @@ namespace NSCSS
m_arKinElements.push_back(oKinElement);
oKinElement->m_sFullSelector += m_sFullSelector;
oKinElement->UpdateWeight();
}
std::map<std::wstring, std::wstring> CElement::GetStyle() const
@ -233,14 +230,11 @@ namespace NSCSS
return NULL;
}
void CElement::UpdateWeight()
std::vector<unsigned short> CElement::GetWeight()
{
if (m_arWeight.empty())
m_arWeight = NS_STATIC_FUNCTIONS::GetWeightSelector(m_sFullSelector);
}
std::vector<unsigned short> CElement::GetWeight() const
{
return m_arWeight;
}

View File

@ -44,8 +44,7 @@ namespace NSCSS
CElement *FindPrevElement(const std::wstring& sSelector) const;
void UpdateWeight();
std::vector<unsigned short int> GetWeight() const;
std::vector<unsigned short int> GetWeight();
void IncreasedWeight();
};
}

View File

@ -2,6 +2,29 @@
namespace NSCSS
{
bool StatistickElement::operator<(const StatistickElement &oStatistickElement) const
{
return sValue < oStatistickElement.sValue;
}
void CTree::Clear()
{
m_arrChild.clear();
m_oNode.Clear();
}
void CTree::CountingNumberRepetitions(const CTree &oTree, std::map<StatistickElement, unsigned int> &mStatictics)
{
if (!oTree.m_oNode.m_wsId.empty())
++mStatictics[StatistickElement{StatistickElement::IsId, L'#' + oTree.m_oNode.m_wsId}];
if (!oTree.m_oNode.m_wsStyle.empty())
++mStatictics[StatistickElement{StatistickElement::IsStyle, oTree.m_oNode.m_wsStyle}];
if (!oTree.m_arrChild.empty())
for (const CTree& oChildren : oTree.m_arrChild)
CountingNumberRepetitions(oChildren, mStatictics);
}
namespace NSConstValues
{
const std::map<std::wstring, std::wstring> COLORS

View File

@ -16,6 +16,28 @@ namespace NSCSS
ScalingDirectionY = 2
} ScalingDirection;
struct StatistickElement
{
enum TypeElement
{
IsStyle = 0,
IsId
} m_enType;
std::wstring sValue;
bool operator<(const StatistickElement& oStatistickElement) const;
};
struct CTree
{
NSCSS::CNode m_oNode;
std::vector<CTree> m_arrChild;
void Clear();
static void CountingNumberRepetitions(const CTree &oTree, std::map<StatistickElement, unsigned int> &mStatictics);
};
namespace NSConstValues
{
extern const std::map<std::wstring, std::wstring> COLORS;

View File

@ -48,6 +48,7 @@ namespace NS_STATIC_FUNCTIONS
if (sEncoding.empty())
sEncoding = "utf-8";
if (!sEncoding.empty() && sEncoding != "utf-8" && sEncoding != "UTF-8")
{
NSUnicodeConverter::CUnicodeConverter oConverter;

View File

@ -513,9 +513,6 @@ namespace NSCSS
return (*static_cast<std::wstring*>(m_oValue)) == (*static_cast<std::wstring*>(oColor.m_oValue));
case ColorUrl:
return (*static_cast<CURL*>(m_oValue)) == (*static_cast<CURL*>(oColor.m_oValue));
case ColorContextStroke:
case ColorContextFill:
return false;
}
}
@ -535,9 +532,6 @@ namespace NSCSS
return (*static_cast<std::wstring*>(m_oValue)) != (*static_cast<std::wstring*>(oColor.m_oValue));
case ColorUrl:
return (*static_cast<CURL*>(m_oValue)) != (*static_cast<CURL*>(oColor.m_oValue));
case ColorContextStroke:
case ColorContextFill:
return false;
}
}
@ -567,9 +561,6 @@ namespace NSCSS
m_oValue = new CURL(*static_cast<CURL*>(oColor.m_oValue));
break;
}
case ColorContextStroke:
case ColorContextFill:
break;
}
return *this;
@ -589,39 +580,6 @@ namespace NSCSS
: CValue(NULL, 0, false), m_oOpacity(1.), m_enType(ColorEmpty)
{}
CColor::CColor(const CColor& oColor)
: CValue(NULL, 0, false), m_oOpacity(oColor.m_oOpacity), m_enType(oColor.m_enType)
{
switch (m_enType)
{
case ColorRGB:
{
TRGB *pRGB = static_cast<TRGB*>(oColor.m_oValue);
m_oValue = new TRGB(*pRGB);
break;
}
case ColorHEX:
{
std::wstring* pValue = static_cast<std::wstring*>(oColor.m_oValue);
m_oValue = new std::wstring(*pValue);
break;
}
case ColorUrl:
{
CURL *pURL = static_cast<CURL*>(oColor.m_oValue);
m_oValue = new CURL(*pURL);
break;
}
default:
break;
}
}
CColor::~CColor()
{
Clear();
}
void CColor::SetEmpty(unsigned int unLevel)
{
Clear();
@ -917,25 +875,6 @@ namespace NSCSS
}
}
std::wstring CColor::ToHEX() const
{
switch(m_enType)
{
case ColorRGB:
{
TRGB* pRGB = static_cast<TRGB*>(m_oValue);
return ConvertRGBtoHEX(*pRGB);
}
case ColorHEX:
{
std::wstring *pValue = static_cast<std::wstring*>(m_oValue);
return *pValue;
}
default:
return std::wstring();
}
}
std::wstring CColor::EquateToColor(const std::vector<std::pair<TRGB, std::wstring>> &arColors) const
{
if (arColors.empty())
@ -2362,32 +2301,32 @@ namespace NSCSS
return m_oLeft.SetValue(dValue, unLevel, bHardMode);
}
void CIndent::UpdateAll(const double& dParentFontSize, const double& dCoreFontSize)
void CIndent::UpdateAll(double dFontSize)
{
UpdateTop (dParentFontSize, dCoreFontSize);
UpdateRight (dParentFontSize, dCoreFontSize);
UpdateBottom(dParentFontSize, dCoreFontSize);
UpdateLeft (dParentFontSize, dCoreFontSize);
UpdateTop (dFontSize);
UpdateRight (dFontSize);
UpdateBottom(dFontSize);
UpdateLeft (dFontSize);
}
void CIndent::UpdateTop(const double& dParentFontSize, const double& dCoreFontSize)
void CIndent::UpdateTop(double dFontSize)
{
UpdateSide(m_oTop, dParentFontSize, dCoreFontSize);
UpdateSide(m_oTop, dFontSize);
}
void CIndent::UpdateRight(const double& dParentFontSize, const double& dCoreFontSize)
void CIndent::UpdateRight(double dFontSize)
{
UpdateSide(m_oRight, dParentFontSize, dCoreFontSize);
UpdateSide(m_oRight, dFontSize);
}
void CIndent::UpdateBottom(const double& dParentFontSize, const double& dCoreFontSize)
void CIndent::UpdateBottom(double dFontSize)
{
UpdateSide(m_oBottom, dParentFontSize, dCoreFontSize);
UpdateSide(m_oBottom, dFontSize);
}
void CIndent::UpdateLeft(const double& dParentFontSize, const double& dCoreFontSize)
void CIndent::UpdateLeft(double dFontSize)
{
UpdateSide(m_oLeft, dParentFontSize, dCoreFontSize);
UpdateSide(m_oLeft, dFontSize);
}
const CDigit &CIndent::GetTop() const
@ -2456,15 +2395,13 @@ namespace NSCSS
return bTopResult || bRightResult || bBottomResult || bLeftResult;
}
void CIndent::UpdateSide(CDigit &oSide, const double& dParentFontSize, const double& dCoreFontSize)
void CIndent::UpdateSide(CDigit &oSide, double dFontSize)
{
if (oSide.Empty())
return;
if (NSCSS::Em == oSide.GetUnitMeasure())
oSide.ConvertTo(NSCSS::Twips, dParentFontSize);
else if (NSCSS::Rem == oSide.GetUnitMeasure())
oSide.ConvertTo(NSCSS::Twips, dCoreFontSize);
if (NSCSS::Em == oSide.GetUnitMeasure() || NSCSS::Rem == oSide.GetUnitMeasure())
oSide.ConvertTo(NSCSS::Twips, dFontSize);
}
// FONT
@ -2707,20 +2644,16 @@ namespace NSCSS
std::make_pair(L"700", L"bold"), std::make_pair(L"800", L"bold"), std::make_pair(L"900", L"bold")}, unLevel, bHardMode);
}
void CFont::UpdateSize(const double& dParentFontSize, const double& dCoreFontSize)
void CFont::UpdateSize(double dFontSize)
{
if (NSCSS::Em == m_oSize.GetUnitMeasure() || NSCSS::Percent == m_oSize.GetUnitMeasure())
m_oSize.ConvertTo(NSCSS::Point, dParentFontSize);
else if (NSCSS::Rem == m_oSize.GetUnitMeasure())
m_oSize.ConvertTo(NSCSS::Point, dCoreFontSize);
if (NSCSS::Em == m_oSize.GetUnitMeasure() || NSCSS::Rem == m_oSize.GetUnitMeasure() || NSCSS::Percent == m_oSize.GetUnitMeasure())
m_oSize.ConvertTo(NSCSS::Point, dFontSize);
}
void CFont::UpdateLineHeight(const double& dParentFontSize, const double& dCoreFontSize)
void CFont::UpdateLineHeight(double dFontSize)
{
if (NSCSS::Em == m_oLineHeight.GetUnitMeasure())
m_oLineHeight.ConvertTo(NSCSS::Twips, dParentFontSize);
else if (NSCSS::Rem == m_oLineHeight.GetUnitMeasure())
m_oLineHeight.ConvertTo(NSCSS::Twips, dCoreFontSize);
if (NSCSS::Em == m_oLineHeight.GetUnitMeasure() || NSCSS::Rem == m_oLineHeight.GetUnitMeasure())
m_oLineHeight.ConvertTo(NSCSS::Twips, dFontSize);
}
bool CFont::Bold() const

View File

@ -224,8 +224,6 @@ namespace NSCSS
{
public:
CColor();
CColor(const CColor& oColor);
~CColor();
bool SetValue(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true) override;
bool SetOpacity(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true);
@ -242,7 +240,6 @@ namespace NSCSS
int ToInt() const override;
double ToDouble() const override;
std::wstring ToWString() const override;
std::wstring ToHEX() const;
std::wstring EquateToColor(const std::vector<std::pair<TRGB, std::wstring>>& arColors) const;
TRGB ToRGB() const;
@ -659,11 +656,11 @@ namespace NSCSS
bool SetLeft (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetLeft (const double& dValue, unsigned int unLevel, bool bHardMode = false);
void UpdateAll (const double& dParentFontSize, const double& dCoreFontSize);
void UpdateTop (const double& dParentFontSize, const double& dCoreFontSize);
void UpdateRight (const double& dParentFontSize, const double& dCoreFontSize);
void UpdateBottom(const double& dParentFontSize, const double& dCoreFontSize);
void UpdateLeft (const double& dParentFontSize, const double& dCoreFontSize);
void UpdateAll (double dFontSize);
void UpdateTop (double dFontSize);
void UpdateRight (double dFontSize);
void UpdateBottom(double dFontSize);
void UpdateLeft (double dFontSize);
const CDigit& GetTop () const;
const CDigit& GetRight () const;
@ -678,7 +675,7 @@ namespace NSCSS
bool operator!=(const CIndent& oIndent) const;
private:
bool SetValues(const std::wstring& wsTopValue, const std::wstring& wsRightValue, const std::wstring& wsBottomValue, const std::wstring& wsLeftValue, unsigned int unLevel, bool bHardMode = false);
void UpdateSide(CDigit& oSide, const double& dParentFontSize, const double& dCoreFontSize);
void UpdateSide(CDigit& oSide, double dFontSize);
CDigit m_oLeft;
CDigit m_oTop;
@ -705,8 +702,8 @@ namespace NSCSS
bool SetVariant (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWeight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
void UpdateSize(const double& dParentFontSize, const double& dCoreFontSize);
void UpdateLineHeight(const double& dParentFontSize, const double& dCoreFontSize);
void UpdateSize(double dFontSize);
void UpdateLineHeight(double dFontSize);
void Clear();

View File

@ -316,7 +316,7 @@ namespace NSCSS
std::wstring wsTextAlign{oStyle.m_oText.GetAlign().ToWString()};
if (wsTextAlign.empty())
if (wsTextAlign.empty() && bInTable)
wsTextAlign = oStyle.m_oDisplay.GetHAlign().ToWString();
oXmlElement.AddPropertiesInP(PProperties::P_Jc, wsTextAlign);
@ -485,7 +485,7 @@ namespace NSCSS
return;
if (!oStyle.m_oFont.GetSize().Empty())
oXmlElement.AddPropertiesInR(RProperties::R_Sz, std::to_wstring(static_cast<int>(oStyle.m_oFont.GetSize().ToDouble(NSCSS::Point) * 2. * oStyle.m_oTransform.GetMatrix().GetFinalValue().sy() + 0.5))); // Значения шрифта увеличивает на 2
oXmlElement.AddPropertiesInR(RProperties::R_Sz, std::to_wstring(static_cast<int>(oStyle.m_oFont.GetSize().ToDouble(NSCSS::Point) * 2. + 0.5))); // Значения шрифта увеличивает на 2
if (oStyle.m_oText.GetDecoration().m_oLine.Underline())
oXmlElement.AddPropertiesInR(RProperties::R_U, (!oStyle.m_oText.GetDecoration().m_oStyle.Empty()) ? oStyle.m_oText.GetDecoration().m_oStyle.ToWString() : L"single");

View File

@ -55,11 +55,6 @@ static void replace_all(std::string& s, const std::string& s1, const std::string
}
}
static bool NodeIsUnprocessed(const std::string& wsTagName)
{
return "xml" == wsTagName;
}
static bool IsUnckeckedNodes(const std::string& sValue)
{
return unchecked_nodes_new.end() != std::find(unchecked_nodes_new.begin(), unchecked_nodes_new.end(), sValue);
@ -597,9 +592,6 @@ static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilde
std::string tagname = get_tag_name(node);
if (NodeIsUnprocessed(tagname))
return;
if (bCheckValidNode)
bCheckValidNode = !IsUnckeckedNodes(tagname);

View File

@ -244,4 +244,3 @@
#define AVS_FILEUTILS_ERROR_CONVERT_LIMITS (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x005d)
#define AVS_FILEUTILS_ERROR_CONVERT_ROWLIMITS (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x005e)
#define AVS_FILEUTILS_ERROR_CONVERT_DETECT (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x005f)
#define AVS_FILEUTILS_ERROR_CONVERT_CELLLIMITS (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x0060)

View File

@ -740,33 +740,13 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
if (OfficeUtils.IsArchive(fileName) == S_OK && (false == isPdfFormatFile(bufferDetect, dwDetectdBytes, sDocumentID)))
{
if (isOOXFormatFile(fileName))
{
if (bufferDetect)
delete[] bufferDetect;
bufferDetect = NULL;
return true;
}
else if (isOpenOfficeFormatFile(fileName, sDocumentID))
{
if (bufferDetect)
delete[] bufferDetect;
bufferDetect = NULL;
return true;
}
return true;
else if (isOnlyOfficeFormatFile(fileName))
{
if (bufferDetect)
delete[] bufferDetect;
bufferDetect = NULL;
return true;
}
return true;
else if (isXpsFile(fileName))
{
if (bufferDetect)
delete[] bufferDetect;
bufferDetect = NULL;
return true;
}
return true;
}
//-----------------------------------------------------------------------------------------------
@ -899,16 +879,6 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
nFileType = AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY;
else if (0 == sExt.compare(L".txt") || 0 == sExt.compare(L".xml") || 0 == sExt.compare(L".rtf") || 0 == sExt.compare(L".doc") || 0 == sExt.compare(L".docx") || 0 == sExt.compare(L".md"))
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT;
else if (0 == sExt.compare(L".pages"))
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
else if (0 == sExt.compare(L".numbers"))
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
else if (0 == sExt.compare(L".key"))
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
else if (0 == sExt.compare(L".hwp"))
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP;
else if (0 == sExt.compare(L".hwpx"))
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX;
if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN)
return true;
@ -1375,7 +1345,6 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM:
return L".dotm";
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC:
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC_FLAT:
return L".doc";
case AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT:
return L".odt";

View File

@ -56,9 +56,6 @@
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0015
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0016
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM_PDF AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0017
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0018
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0019
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0020
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_XML AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0030
@ -75,7 +72,6 @@
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x000a
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX_PACKAGE AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x000b
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_ODG AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x000c
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x000d
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET 0x0100
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0001
@ -91,7 +87,6 @@
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000a
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_FLAT AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000b
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_PACKAGE AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000c
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000d
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM 0x0200
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0001

View File

@ -4,7 +4,6 @@
#include <stdio.h>
#define LOG_BUFFER_SIZE 1000
// not intended for use in production. only for testing/debugging purposes
namespace Logging
{
void logBytes(char* name, unsigned char* str, int len)

View File

@ -847,10 +847,40 @@ namespace agg
if (calculate_tensor_coefs)
calculate_tensor();
float minxres = m_oGradientInfo.shading.patch[0][0].x;
float minyres = m_oGradientInfo.shading.patch[0][0].y;
float maxxres = m_oGradientInfo.shading.patch[0][0].x;
float maxyres = m_oGradientInfo.shading.patch[0][0].y;
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
if (m_oGradientInfo.shading.patch[i][j].x > maxxres)
{
maxxres = m_oGradientInfo.shading.patch[i][j].x;
}
if (m_oGradientInfo.shading.patch[i][j].y > maxyres)
{
maxyres = m_oGradientInfo.shading.patch[i][j].y;
}
if (m_oGradientInfo.shading.patch[i][j].x < minxres)
{
minxres = m_oGradientInfo.shading.patch[i][j].x;
}
if (m_oGradientInfo.shading.patch[i][j].y < minyres)
{
minyres = m_oGradientInfo.shading.patch[i][j].y;
}
}
}
RES = std::max(1.0f, std::max(maxxres - minxres, maxyres - minyres) / 3);
float delta = 1.0 / RES;
float u = 0, v = 0;
auto start_p = get_p_curve(u, v);
xmax_curve = xmin_curve = start_p.x;
ymax_curve = ymin_curve = start_p.y;
precalc = std::vector<std::vector<ColorT>>(RES, std::vector<ColorT>(RES, {0, 0, 0, 0}));
/*
* Небольшая оптимизация основанная на том, что данная фигура не выходит за границы своих опорных точек.
@ -888,7 +918,7 @@ namespace agg
RES = nRES;
}
precalc = std::vector<std::vector<ColorT>>(RES, std::vector<ColorT>(RES, {0, 0, 0, 0}));
float delta = 1.0f / RES;
delta = 1.0f / RES;
std::vector<std::pair<int, int>> next_indexes(RES + 1);
u = 0;
for (int i = 0; i < RES; ++i)
@ -926,6 +956,8 @@ namespace agg
}
ColorT ifswapRGB(const ColorT &c)
{
if (m_bSwapRGB) {
return c;
}

View File

@ -250,123 +250,3 @@ namespace NSBase64
return Base64DecodeBase(szSrc, nSrcLen, pbDest, pnDestLen);
}
}
#include <cstring>
namespace NSBase32
{
const unsigned char PADDING_CHAR_32 = '=';
inline void pad(unsigned char* buf, int len)
{
for (int i = 0; i < len; i++)
buf[i] = PADDING_CHAR_32;
}
inline unsigned char shift_right(unsigned char byte, signed char offset)
{
if (offset > 0)
return byte >> offset;
else
return byte << -offset;
}
inline unsigned char shift_left(unsigned char byte, signed char offset)
{
return shift_right(byte, - offset);
}
unsigned char encode_char(unsigned char c)
{
static unsigned char base32[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
return base32[c & 0x1F];
}
int decode_char(unsigned char c)
{
char retval = -2;
if (c >= 'A' && c <= 'Z')
retval = c - 'A';
else if (c >= '2' && c <= '7')
retval = c - '2' + 26;
else if (c == PADDING_CHAR_32)
retval = -1;
return retval;
}
int decode_sequence(const unsigned char* coded, unsigned char* plain)
{
plain[0] = 0;
for (int block = 0; block < 8; block++)
{
int offset = (8 - 5 - (5*block) % 8);
int octet = (block*5) / 8;
int c = decode_char(coded[block]);
if (c < 0)
return c;
plain[octet] |= shift_left(c, offset);
if (offset < 0)
{ // does this block overflows to next octet?
plain[octet+1] = shift_left(c, 8 + offset);
}
}
return 5;
}
bool Decode(unsigned char* in, int inLen, unsigned char* out)
{
for (size_t i = 0, j = 0; (i + 8) <= inLen; i += 8, j += 5)
{
int n = decode_sequence(&in[i], &out[j]);
if (n == -2)
return false;
if (n < 5)
break;
}
return true;
}
void encode_sequence(const unsigned char* plain, int len, unsigned char* coded)
{
for (int block = 0; block < 8; block++)
{
int octet = (block*5) / 8;
int junk = (8 - 5 - (5*block) % 8);
if (octet >= len)
{
pad(&coded[block], 8 - block);
return;
}
unsigned char c = shift_right(plain[octet], junk); // first part
if (junk < 0 // is there a second part?
&& octet < len - 1) // is there still something to read?
{
c |= shift_right(plain[octet+1], 8 + junk);
}
coded[block] = encode_char(c);
}
}
bool Encode(unsigned char* src, int len, unsigned char* dst)
{
for (int i = 0, j = 0; i < len; i += 5, j += 8)
{
int tmpLen = len - i;
encode_sequence(&src[i], tmpLen > 5 ? 5 : tmpLen, &dst[j]);
}
return true;
}
int DecodeGetRequiredLength(int bytes)
{
return (((bytes)/8)*5);
}
int EncodeGetRequiredLength(int bytes)
{
return (((bytes)/5)*8 + ((bytes) % 5 ? 8 : 0));
}
}

View File

@ -58,13 +58,4 @@ namespace NSBase64
KERNEL_DECL int Base64Decode(const wchar_t* szSrc, int nSrcLen, BYTE *pbDest, int *pnDestLen);
}
namespace NSBase32
{
KERNEL_DECL bool Decode(unsigned char* in, int inLen, unsigned char* out);
KERNEL_DECL bool Encode(unsigned char* in, int inLen, unsigned char* out);
KERNEL_DECL int DecodeGetRequiredLength(int bytes);
KERNEL_DECL int EncodeGetRequiredLength(int bytes);
}
#endif//_BUILD_BASE64_CROSSPLATFORM_DEFINE

View File

@ -1535,11 +1535,6 @@ namespace NSFile
return bIsSuccess;
}
bool CFileBinary::IsGlobalTempPathUse()
{
return g_overrideTmpPath.empty() ? false : true;
}
std::wstring CFileBinary::GetTempPath()
{
if (!g_overrideTmpPath.empty())

View File

@ -189,7 +189,6 @@ namespace NSFile
static void SetTempPath(const std::wstring& strTempPath);
static std::wstring GetTempPath();
static bool IsGlobalTempPathUse();
static std::wstring CreateTempFileWithUniqueName(const std::wstring& strFolderPathRoot, const std::wstring& Prefix);
static bool OpenTempFile(std::wstring *pwsName, FILE **ppFile, wchar_t *wsMode, wchar_t *wsExt, wchar_t *wsFolder, wchar_t* wsName = NULL);

View File

@ -682,10 +682,9 @@ namespace NSStringUtils
}
if (val < 0)
{
if (val == -2147483648)
val = -val;
if (val < 0)
val = 2147483647;
else
val = -val;
*m_pDataCur++ = (wchar_t)'-';
++m_lSizeCur;

View File

@ -38,9 +38,6 @@
#include "../xml/include/xmlutils.h"
#include "../fontengine/TextHyphen.h"
#define VALUE_TO_STRING(x) #x
#define VALUE(x) VALUE_TO_STRING(x)
namespace NSDoctRenderer
{
class CAdditionalData
@ -206,14 +203,28 @@ namespace NSDoctRenderer
char* GetVersion()
{
std::string sVersion = VALUE(INTVER);
std::wstring sFile = m_strSdkPath + L"/word/sdk-all-min.js";
size_t sSrcLen = sVersion.size();
std::string sData;
if (!NSFile::CFileBinary::ReadAllTextUtf8A(sFile, sData))
return NULL;
std::string::size_type startPos = sData.find("Version:");
if (std::string::npos == startPos)
return NULL;
startPos += 8;
std::string::size_type endPos = sData.find(')', startPos);
if (std::string::npos == endPos)
return NULL;
size_t sSrcLen = endPos - startPos + 1;
if (sSrcLen == 0)
return NULL;
char* sRet = new char[sSrcLen + 1];
memcpy(sRet, sVersion.c_str(), sSrcLen);
memcpy(sRet, sData.c_str() + startPos, sSrcLen);
sRet[sSrcLen] = '\0';
return sRet;
}

View File

@ -56,6 +56,7 @@ CV8RealTimeWorker::CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder, cons
CJSContextScope scope(m_context);
CJSContext::Embed<CNativeControlEmbed>(false);
CJSContext::Embed<CGraphicsEmbed>();
NSJSBase::CreateDefaults();
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
@ -240,14 +241,6 @@ bool CV8RealTimeWorker::InitVariables()
if (try_catch->Check())
return false;
}
if (!m_sJSCodeStart.empty())
{
m_context->runScript(m_sJSCodeStart, try_catch);
if (try_catch->Check())
return false;
}
return true;
}
@ -304,7 +297,7 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri
else if (1 == m_nFileType)
pNative->m_strEditorType = L"presentation";
else if (7 == m_nFileType)
pNative->m_strEditorType = L"visio";
pNative->m_strEditorType = L"draw";
else
pNative->m_strEditorType = L"spreadsheet";

View File

@ -422,7 +422,6 @@ public:
int m_nFileType;
std::string m_sUtf8ArgumentJSON;
std::string m_sGlobalVariable;
std::string m_sJSCodeStart;
CJSContextData m_oContextData;
@ -456,8 +455,7 @@ namespace NSDoctRenderer
std::wstring m_sTmpFolder;
std::wstring m_sFileDir;
int m_nFileType;
std::wstring m_sCommandsBeforeContextCreated;
bool m_bJavascriptBeforeEditor;
std::wstring m_sX2tPath;
@ -480,7 +478,7 @@ namespace NSDoctRenderer
public:
CDocBuilder_Private() : CDoctRendererConfig(), m_sTmpFolder(NSFile::CFileBinary::GetTempPath()), m_nFileType(-1),
m_pWorker(NULL), m_pAdditionalData(NULL), m_bIsInit(false), m_bIsServerSafeVersion(false),
m_sGlobalVariable(""), m_bIsGlobalVariableUse(false), m_pParent(NULL), m_sCommandsBeforeContextCreated(L"")
m_sGlobalVariable(""), m_bIsGlobalVariableUse(false), m_pParent(NULL), m_bJavascriptBeforeEditor(false)
{
}
@ -641,6 +639,9 @@ namespace NSDoctRenderer
NSDirectory::CreateDirectory(m_sFileDir + L"/changes");
}
if (m_bJavascriptBeforeEditor)
CheckWorkerAfterOpen();
return bRet;
#else
std::wstring sPath = m_sX2tPath + L"/empty/new.";
@ -727,13 +728,22 @@ namespace NSDoctRenderer
oBuilder.WriteEncodeXmlString(sFolder);
oBuilder.WriteString(L"/Editor.bin</m_sFileTo><m_nFormatTo>8192</m_nFormatTo>");
oBuilder.WriteString(L"<m_sFontDir>");
oBuilder.WriteEncodeXmlString(NSFile::GetDirectoryName(m_strAllFonts));
oBuilder.WriteString(L"</m_sFontDir>");
if (!m_bIsNotUseConfigAllFontsDir)
{
oBuilder.WriteString(L"<m_sFontDir>");
oBuilder.WriteEncodeXmlString(m_sX2tPath + L"/sdkjs/common");
oBuilder.WriteString(L"</m_sFontDir>");
}
else
{
oBuilder.WriteString(L"<m_sFontDir>");
oBuilder.WriteEncodeXmlString(NSFile::GetDirectoryName(m_strAllFonts));
oBuilder.WriteString(L"</m_sFontDir>");
oBuilder.WriteString(L"<m_sAllFontsPath>");
oBuilder.WriteEncodeXmlString(m_strAllFonts);
oBuilder.WriteString(L"</m_sAllFontsPath>");
oBuilder.WriteString(L"<m_sAllFontsPath>");
oBuilder.WriteEncodeXmlString(m_strAllFonts);
oBuilder.WriteString(L"</m_sAllFontsPath>");
}
oBuilder.WriteString(L"<m_bIsNoBase64>true</m_bIsNoBase64>");
oBuilder.WriteString(L"<m_sThemeDir>./sdkjs/slide/themes</m_sThemeDir><m_bDontSaveAdditional>true</m_bDontSaveAdditional>");
@ -929,7 +939,11 @@ namespace NSDoctRenderer
LOGGER_SPEED_LAP("open_convert");
if (0 == nReturnCode)
{
if (m_bJavascriptBeforeEditor)
CheckWorkerAfterOpen();
return 0;
}
NSDirectory::DeleteDirectory(m_sFileDir);
m_sFileDir = L"";
@ -1040,13 +1054,22 @@ namespace NSDoctRenderer
oBuilder.WriteString(L"</m_sThemeDir><m_bFromChanges>true</m_bFromChanges><m_bDontSaveAdditional>true</m_bDontSaveAdditional>");
oBuilder.WriteString(L"<m_nCsvTxtEncoding>46</m_nCsvTxtEncoding><m_nCsvDelimiter>4</m_nCsvDelimiter>");
oBuilder.WriteString(L"<m_sFontDir>");
oBuilder.WriteEncodeXmlString(NSFile::GetDirectoryName(m_strAllFonts));
oBuilder.WriteString(L"</m_sFontDir>");
if (!m_bIsNotUseConfigAllFontsDir)
{
oBuilder.WriteString(L"<m_sFontDir>");
oBuilder.WriteEncodeXmlString(m_sX2tPath + L"/sdkjs/common");
oBuilder.WriteString(L"</m_sFontDir>");
}
else
{
oBuilder.WriteString(L"<m_sFontDir>");
oBuilder.WriteEncodeXmlString(NSFile::GetDirectoryName(m_strAllFonts));
oBuilder.WriteString(L"</m_sFontDir>");
oBuilder.WriteString(L"<m_sAllFontsPath>");
oBuilder.WriteEncodeXmlString(m_strAllFonts);
oBuilder.WriteString(L"</m_sAllFontsPath>");
oBuilder.WriteString(L"<m_sAllFontsPath>");
oBuilder.WriteEncodeXmlString(m_strAllFonts);
oBuilder.WriteString(L"</m_sAllFontsPath>");
}
if (!sConvertionParams.empty())
{
@ -1215,27 +1238,36 @@ namespace NSDoctRenderer
{
if (NULL == m_pWorker)
{
NSDoctRenderer::DoctRendererEditorType editorType = GetEditorType();
if (NSDoctRenderer::DoctRendererEditorType::INVALID == editorType)
return false;
m_pWorker = new CV8RealTimeWorker(m_pParent, editorType, this);
m_pWorker = new CV8RealTimeWorker(m_pParent, GetEditorType(), this);
m_pWorker->m_sUtf8ArgumentJSON = m_oParams.m_sArgumentJSON;
m_pWorker->m_sGlobalVariable = m_sGlobalVariable;
m_pWorker->m_sJSCodeStart = U_TO_UTF8(m_sCommandsBeforeContextCreated);
m_sCommandsBeforeContextCreated = L"";
m_pWorker->m_nFileType = m_nFileType;
CV8Params oParams;
oParams.IsServerSaveVersion = m_bIsServerSafeVersion;
oParams.DocumentDirectory = m_sFileDir;
return m_pWorker->OpenFile(m_sX2tPath, m_sFileDir, editorType, this, &oParams);
return CheckWorkerAfterOpen();
}
return true;
}
bool CheckWorkerAfterOpen()
{
if (!m_pWorker)
return false;
m_pWorker->m_nFileType = m_nFileType;
if (-1 == m_nFileType)
{
m_bJavascriptBeforeEditor = true;
return false;
}
m_bJavascriptBeforeEditor = false;
CV8Params oParams;
oParams.IsServerSaveVersion = m_bIsServerSafeVersion;
oParams.DocumentDirectory = m_sFileDir;
return m_pWorker->OpenFile(m_sX2tPath, m_sFileDir, GetEditorType(), this, &oParams);
}
int SaveFile(const std::wstring& ext, const std::wstring& path, const wchar_t* params = NULL)
{
int nType = GetFormatByTexExtention(ext);
@ -1247,26 +1279,21 @@ namespace NSDoctRenderer
if (command.length() < 7 && !retValue) // minimum command (!!!)
return true;
if (m_nFileType == -1)
{
m_sCommandsBeforeContextCreated += command;
return true;
}
Init();
if (CheckWorker())
return m_pWorker->ExecuteCommand(command, retValue);
bool bRes = CheckWorker();
return false;
if (!bRes && m_pWorker && m_bJavascriptBeforeEditor)
m_pWorker->InitVariables();
return m_pWorker->ExecuteCommand(command, retValue);
}
CDocBuilderContext GetContext(bool enterContext)
{
CDocBuilderContext ctx;
if (!CheckWorker())
return ctx;
CheckWorker();
ctx.m_internal->m_context = m_pWorker->m_context;
ctx.m_internal->m_context_data = &m_pWorker->m_oContextData;

View File

@ -575,6 +575,7 @@ namespace NSDoctRenderer
{
CJSContextScope scope(context);
CJSContext::Embed<CNativeControlEmbed>(false);
CJSContext::Embed<CGraphicsEmbed>();
NSJSBase::CreateDefaults();
JSSmart<CJSTryCatch> try_catch = context->GetExceptions();
@ -986,7 +987,7 @@ namespace NSDoctRenderer
case DoctRendererFormat::IMAGE:
{
editorType = NSDoctRenderer::DoctRendererEditorType::VISIO;
m_pInternal->m_strEditorType = L"visio";
m_pInternal->m_strEditorType = L"draw";
break;
}
default:
@ -1066,6 +1067,7 @@ namespace NSDoctRenderer
{
CJSContextScope scope(context);
CJSContext::Embed<CNativeControlEmbed>();
CJSContext::Embed<CGraphicsEmbed>();
NSJSBase::CreateDefaults();
JSSmart<CJSObject> global = context->GetGlobal();

View File

@ -121,7 +121,7 @@ drawingfile_support {
embed/DrawingFileEmbed.h
SOURCES += \
../graphics/pro/js/wasm/src/HTMLRendererText.cpp \
../../HtmlRenderer/src/HTMLRendererText.cpp \
embed/DrawingFileEmbed.cpp
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/DrawingFileEmbed.h)

View File

@ -38,8 +38,8 @@
#include "../../PdfFile/PdfFile.h"
#include "../../XpsFile/XpsFile.h"
#include "../../DjVuFile/DjVu.h"
#include "../graphics/pro/js/wasm/src/serialize.h"
#include "../graphics/pro/js/wasm/src/HTMLRendererText.h"
#include "../../DesktopEditor/graphics/pro/js/wasm/src/serialize.h"
#include "../../HtmlRenderer/include/HTMLRendererText.h"
#include "../../DocxRenderer/DocxRenderer.h"
#define CHECKER_FILE_BUFFER_LEN 4096
@ -542,8 +542,8 @@ private:
}
if (m_nType == 0)
nRotate = ((CPdfFile*)m_pFile)->GetRotate(nPageIndex);
nWidth = round(dWidth);
nHeight = round(dHeight);
nWidth = dWidth;
nHeight = dHeight;
nPageDpiX = dPageDpiX;
}

View File

@ -6,16 +6,16 @@ namespace NSDoctRenderer
{
namespace
{
bool AppendScript(NSStringUtils::CStringBuilderA* builder, const std::wstring& path, const std::string& header = "", const std::string& footer = "")
void AppendScript(NSStringUtils::CStringBuilderA* builder, const std::wstring& path)
{
NSFile::CFileBinary oFile;
if (!oFile.OpenFile(path))
return false;
return;
int size = (int)oFile.GetFileSize();
if (size < 3)
return false;
return;
BYTE* pData = new BYTE[size];
DWORD dwReadSize = 0;
@ -26,18 +26,9 @@ namespace NSDoctRenderer
if (pData[0] == 0xEF && pData[1] == 0xBB && pData[2] == 0xBF)
nOffset = 3;
if (!header.empty())
builder->WriteString(header);
builder->WriteString((char*)(pData + nOffset), size - nOffset);
if (!footer.empty())
builder->WriteString(footer);
builder->WriteString("\n\n");
RELEASEARRAYOBJECTS(pData);
return true;
}
bool RunScript(JSSmart<NSJSBase::CJSContext>& context, JSSmart<NSJSBase::CJSTryCatch>& try_catch, const std::wstring& path)
@ -109,12 +100,12 @@ namespace NSDoctRenderer
}
case DoctRendererEditorType::VISIO:
{
if (!NSFile::CFileBinary::Exists(config->m_strSdkPath + L"/visio/sdk-all-min.js"))
if (!NSFile::CFileBinary::Exists(config->m_strSdkPath + L"/draw/sdk-all-min.js"))
return L"";
AppendScript(builder, config->m_strSdkPath + L"/visio/sdk-all-min.js");
AppendScript(builder, config->m_strSdkPath + L"/draw/sdk-all-min.js");
AppendScript(builder, sFontsPath);
AppendScript(builder, config->m_strSdkPath + L"/visio/sdk-all.js");
sCachePath = config->m_strSdkPath + L"/visio/sdk-all";
AppendScript(builder, config->m_strSdkPath + L"/draw/sdk-all.js");
sCachePath = config->m_strSdkPath + L"/draw/sdk-all";
break;
}
case DoctRendererEditorType::PDF:
@ -123,7 +114,6 @@ namespace NSDoctRenderer
AppendScript(builder, sFontsPath);
AppendScript(builder, config->m_strSdkPath + L"/word/sdk-all.js");
AppendScript(builder, config->m_strSdkPath + L"/pdf/src/engine/drawingfile_native.js");
AppendScript(builder, config->m_strSdkPath + L"/pdf/src/annotations/stamps.json", "window[\"native_pdf_stamps\"]=", ";");
sCachePath = config->m_strSdkPath + L"/pdf/sdk-all";
break;
}
@ -157,7 +147,7 @@ namespace NSDoctRenderer
}
case DoctRendererEditorType::VISIO:
{
return config->m_strSdkPath + L"/visio/sdk-all.bin";
return config->m_strSdkPath + L"/draw/sdk-all.bin";
}
case DoctRendererEditorType::PDF:
{

View File

@ -4,7 +4,6 @@
#include "./MemoryStreamEmbed.h"
#include "./TextMeasurerEmbed.h"
#include "./HashEmbed.h"
#include "./GraphicsEmbed.h"
namespace NSJSBase
{
@ -14,6 +13,5 @@ namespace NSJSBase
CJSContext::Embed<CMemoryStreamEmbed>();
CJSContext::Embed<CTextMeasurerEmbed>();
CJSContext::Embed<CHashEmbed>();
CJSContext::Embed<CGraphicsEmbed>();
}
}

View File

@ -1,6 +1,5 @@
#include "DrawingFileEmbed.h"
#include "../drawingfile.h"
#include "../../raster/BgraFrame.h"
JSSmart<CJSValue> WasmMemoryToJS(BYTE* pWasmData)
{

View File

@ -1,192 +1,8 @@
#include "../graphics.h"
#include <map>
#include "../../../Common/Network/FileTransporter/include/FileTransporter.h"
// APPLICATION INFO
class CGraphicsAppImage_private
{
public:
NSFonts::IApplicationFonts* m_pFonts;
std::wstring m_sFontsDirectory;
std::wstring m_sImagesDirectory;
std::wstring m_sThemesDirectory;
bool m_bIsRgba;
std::map<std::wstring, std::wstring> m_mapDownloads;
CGraphicsAppImage_private()
{
m_pFonts = NULL;
m_sFontsDirectory = L"";
m_sImagesDirectory = L"";
m_sThemesDirectory = L"";
m_bIsRgba = false;
}
~CGraphicsAppImage_private()
{
RELEASEINTERFACE(m_pFonts);
for (std::map<std::wstring, std::wstring>::iterator i = m_mapDownloads.begin(); i != m_mapDownloads.end(); i++)
{
std::wstring sTmp = i->second;
if (NSFile::CFileBinary::Exists(sTmp))
NSFile::CFileBinary::Remove(sTmp);
}
}
bool IsNeedDownload(const std::wstring& sUrl)
{
if ((0 == sUrl.find(L"www.")) ||
(0 == sUrl.find(L"http://")) ||
(0 == sUrl.find(L"https://")))
return true;
return false;
}
std::wstring GetImagePath(const std::wstring& sUrl)
{
std::map<std::wstring, std::wstring>::iterator find = m_mapDownloads.find(sUrl);
if (find != m_mapDownloads.end())
return find->second;
NSNetwork::NSFileTransport::CFileDownloader oDownloader(sUrl, false);
std::wstring sTmpFile = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"IMG");
if (NSFile::CFileBinary::Exists(sTmpFile))
NSFile::CFileBinary::Remove(sTmpFile);
sTmpFile = sTmpFile + L".png";
oDownloader.SetFilePath(sTmpFile);
oDownloader.Start(0);
while ( oDownloader.IsRunned() )
{
NSThreads::Sleep( 10 );
}
bool bIsDownloaded = oDownloader.IsFileDownloaded();
if (bIsDownloaded)
{
m_mapDownloads.insert(std::pair<std::wstring, std::wstring>(sUrl, sTmpFile));
return sTmpFile;
}
return sUrl;
}
};
CGraphicsAppImage::CGraphicsAppImage()
{
m_internal = new CGraphicsAppImage_private();
}
CGraphicsAppImage::~CGraphicsAppImage()
{
delete m_internal;
}
void CGraphicsAppImage::SetFontsDirectory(const std::wstring& dir)
{
m_internal->m_sFontsDirectory = dir;
}
std::wstring CGraphicsAppImage::GetFontsDirectory()
{
return m_internal->m_sFontsDirectory;
}
void CGraphicsAppImage::SetImagesDirectory(const std::wstring& dir)
{
m_internal->m_sImagesDirectory = dir;
}
std::wstring CGraphicsAppImage::GetImagesDirectory()
{
return m_internal->m_sImagesDirectory;
}
void CGraphicsAppImage::SetThemesDirectory(const std::wstring& dir)
{
m_internal->m_sThemesDirectory = dir;
}
std::wstring CGraphicsAppImage::GetThemesDirectory()
{
return m_internal->m_sThemesDirectory;
}
void CGraphicsAppImage::SetFonts(NSFonts::IApplicationFonts* fonts)
{
m_internal->m_pFonts = fonts;
ADDREFINTERFACE(fonts);
}
NSFonts::IApplicationFonts* CGraphicsAppImage::GetFonts()
{
return m_internal->m_pFonts;
}
void CGraphicsAppImage::SetRgba(const bool& isRgba)
{
m_internal->m_bIsRgba = isRgba;
}
bool CGraphicsAppImage::GetRgba()
{
return m_internal->m_bIsRgba;
}
unsigned char* CGraphicsAppImage::GetBits(int& w, int& h)
{
return NULL;
}
unsigned char* CGraphicsAppImage::AllocBits(const int& w, const int& h)
{
return new unsigned char[4 * w * h];
}
// APPLICATION INFO END
CGraphicsEmbed::CGraphicsEmbed() : m_pInternal(new NSGraphics::CGraphics())
{
}
CGraphicsEmbed::~CGraphicsEmbed()
{
RELEASEOBJECT(m_pInternal);
}
CGraphicsAppImage* CGraphicsEmbed::GetAppImage()
{
return m_pInternal->m_pAppImage;
}
void CGraphicsEmbed::SetAppImage(CGraphicsAppImage* appImage)
{
m_pInternal->m_pAppImage = appImage;
}
#include "GraphicsEmbed.h"
JSSmart<CJSValue> CGraphicsEmbed::create(JSSmart<CJSValue> Native, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm)
{
if (!Native->isNull())
{
JSSmart<CJSObject> pNativeObject = Native->toObject();
CJSEmbedObject* pNativeEmbedObject = pNativeObject->getNative();
if (m_pInternal->m_pAppImage)
delete m_pInternal->m_pAppImage;
m_pInternal->m_pAppImage = new CGraphicsAppImage();
if (pNativeEmbedObject)
{
NSNativeControl::CNativeControl* pControl = (NSNativeControl::CNativeControl*)pNativeEmbedObject->getObject();
m_pInternal->m_pAppImage->SetFontsDirectory(pControl->m_strFontsDirectory);
m_pInternal->m_pAppImage->SetImagesDirectory(pControl->m_strImagesDirectory);
}
else
{
JSSmart<CJSValue> checkResources = pNativeObject->get("isResourcesObject");
if (checkResources->isBool() && true == checkResources->toBool())
{
m_pInternal->m_pAppImage->SetFontsDirectory(pNativeObject->get("fontsDirectory")->toStringW());
m_pInternal->m_pAppImage->SetImagesDirectory(pNativeObject->get("imagesDirectory")->toStringW());
}
}
}
m_pInternal->init(width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble());
m_pInternal->init((NSNativeControl::CNativeControl*)Native->toObject()->getNative()->getObject(), width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble());
return NULL;
}
JSSmart<CJSValue> CGraphicsEmbed::Destroy()
@ -334,19 +150,11 @@ JSSmart<CJSValue> CGraphicsEmbed::ClearLastFont()
}
JSSmart<CJSValue> CGraphicsEmbed::drawImage2(JSSmart<CJSValue> img, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> alpha, JSSmart<CJSValue> srcRect)
{
std::wstring sUrl = img->toStringW();
if (m_pInternal->m_pAppImage && m_pInternal->m_pAppImage->m_internal->IsNeedDownload(sUrl))
sUrl = m_pInternal->m_pAppImage->m_internal->GetImagePath(sUrl);
m_pInternal->drawImage(sUrl, x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32());
m_pInternal->drawImage(img->toStringW(), x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32());
return NULL;
}
JSSmart<CJSValue> CGraphicsEmbed::drawImage (JSSmart<CJSValue> img, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> alpha, JSSmart<CJSValue> srcRect, JSSmart<CJSValue> nativeImage)
{
std::wstring sUrl = img->toStringW();
if (m_pInternal->m_pAppImage && m_pInternal->m_pAppImage->m_internal->IsNeedDownload(sUrl))
sUrl = m_pInternal->m_pAppImage->m_internal->GetImagePath(sUrl);
m_pInternal->drawImage(img->toStringW(), x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32());
return NULL;
}
@ -651,11 +459,7 @@ JSSmart<CJSValue> CGraphicsEmbed::GetBrushColor()
}
JSSmart<CJSValue> CGraphicsEmbed::put_brushTexture(JSSmart<CJSValue> src, JSSmart<CJSValue> type)
{
std::wstring sUrl = src->toStringW();
if (m_pInternal->m_pAppImage && m_pInternal->m_pAppImage->m_internal->IsNeedDownload(sUrl))
sUrl = m_pInternal->m_pAppImage->m_internal->GetImagePath(sUrl);
m_pInternal->put_brushTexture(sUrl, type->toInt32());
m_pInternal->put_brushTexture(src->toStringW(), type->toInt32());
return NULL;
}
JSSmart<CJSValue> CGraphicsEmbed::put_brushTextureMode(JSSmart<CJSValue> mode)

View File

@ -1,57 +1,21 @@
#ifndef _BUILD_NATIVE_GRAPHICS_EMBED_H_
#define _BUILD_NATIVE_GRAPHICS_EMBED_H_
#include "../../graphics/pro/Fonts.h"
#include "../graphics.h"
#include "../js_internal/js_base.h"
class CGraphicsAppImage_private;
class JS_DECL CGraphicsAppImage
{
public:
CGraphicsAppImage();
virtual ~CGraphicsAppImage();
public:
void SetFontsDirectory(const std::wstring& dir);
std::wstring GetFontsDirectory();
void SetImagesDirectory(const std::wstring& dir);
std::wstring GetImagesDirectory();
void SetThemesDirectory(const std::wstring& dir);
std::wstring GetThemesDirectory();
void SetFonts(NSFonts::IApplicationFonts* fonts);
NSFonts::IApplicationFonts* GetFonts();
void SetRgba(const bool& isRgba);
bool GetRgba();
virtual unsigned char* GetBits(int& w, int& h);
virtual unsigned char* AllocBits(const int& w, const int& h);
private:
CGraphicsAppImage_private* m_internal;
friend class CGraphicsEmbed;
};
namespace NSGraphics { class CGraphics; }
using namespace NSJSBase;
class JS_DECL CGraphicsEmbed : public CJSEmbedObject
class CGraphicsEmbed : public CJSEmbedObject
{
public:
NSGraphics::CGraphics* m_pInternal;
public:
CGraphicsEmbed();
~CGraphicsEmbed();
CGraphicsEmbed() : m_pInternal(new NSGraphics::CGraphics()) {}
~CGraphicsEmbed() { RELEASEOBJECT(m_pInternal); }
virtual void* getObject() override { return (void*)m_pInternal; }
CGraphicsAppImage* GetAppImage();
void SetAppImage(CGraphicsAppImage* appImage);
public:
JSSmart<CJSValue> create(JSSmart<CJSValue> Native, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm);
JSSmart<CJSValue> Destroy();

View File

@ -2,7 +2,6 @@
#include "./../docbuilder_p.h"
#include "../../common/Directory.h"
#include "../server.h"
JSSmart<CJSValue> CBuilderDocumentEmbed::IsValid()
{
@ -69,23 +68,13 @@ void CBuilderDocumentEmbed::_OpenFile(const std::wstring& sFile, const std::wstr
int nConvertResult = pBuilder->ConvertToInternalFormat(m_sFolder, sFileCopy, sParams);
if (0 == nConvertResult)
{
if (CServerInstance::getInstance().IsEnable())
CServerInstance::getInstance().AddTmpFile(m_sFolder);
m_bIsValid = true;
}
}
void CBuilderDocumentEmbed::_CloseFile()
{
if (!m_sFolder.empty())
{
NSDirectory::DeleteDirectory(m_sFolder);
if (m_bIsValid && CServerInstance::getInstance().IsEnable())
CServerInstance::getInstance().RemoveTmpFile(m_sFolder);
}
m_bIsValid = false;
m_sFolder = L"";
}

View File

@ -258,64 +258,3 @@ JSSmart<CJSValue> CZipEmbed::getImageType(JSSmart<CJSValue> typedArray)
oBuffer.Free();
return CJSContext::createInt(bIsImageFile ? oChecker.eFileType : 0);
}
JSSmart<CJSValue> CZipEmbed::getImageBuffer(JSSmart<CJSValue> filePath)
{
if (!m_pFolder || !filePath->isString())
return CJSContext::createNull();
std::wstring sFilePath = filePath->toStringW();
IFolder::CBuffer* pBuffer;
if (!m_pFolder->read(sFilePath, pBuffer))
return CJSContext::createNull();
size_t nBufferSize = (size_t)pBuffer->Size;
CImageFileFormatChecker oChecker;
bool bIsImageFile = oChecker.isImageFile(pBuffer->Buffer, (DWORD)pBuffer->Size);
if (!bIsImageFile)
{
RELEASEOBJECT(pBuffer);
return CJSContext::createNull();
}
bool bIsNeedConvertMetfileToSvg = false;
// Make as wasm module
if (oChecker.eFileType == _CXIMAGE_FORMAT_WMF || oChecker.eFileType == _CXIMAGE_FORMAT_EMF)
oChecker.eFileType = _CXIMAGE_FORMAT_SVG;
else
bIsNeedConvertMetfileToSvg = false;
if (!bIsNeedConvertMetfileToSvg)
{
BYTE* pMemory = NSJSBase::NSAllocator::Alloc(nBufferSize);
memcpy(pMemory, pBuffer->Buffer, nBufferSize);
RELEASEOBJECT(pBuffer);
JSSmart<CJSObject> retObject = CJSContext::createObject();
retObject->set("type", CJSContext::createInt(oChecker.eFileType));
retObject->set("data", NSJSBase::CJSContext::createUint8Array(pMemory, (int)nBufferSize, false));
return retObject->toValue();
}
#ifndef GRAPHICS_DISABLE_METAFILE
MetaFile::IMetaFile* pMetaFile = MetaFile::Create(NULL);
pMetaFile->LoadFromBuffer(pBuffer->Buffer, (unsigned int)pBuffer->Size);
std::wstring wsSvg = pMetaFile->ConvertToSvg();
std::string sSvg = U_TO_UTF8(wsSvg);
pMetaFile->Release();
RELEASEOBJECT(pBuffer);
BYTE* pData = NSAllocator::Alloc(sSvg.length());
memcpy(pData, sSvg.c_str(), sSvg.length());
JSSmart<CJSObject> retObject = CJSContext::createObject();
retObject->set("type", CJSContext::createInt(24));
retObject->set("data", NSJSBase::CJSContext::createUint8Array(pData, sSvg.length(), false));
return retObject->toValue();
#else
return CJSContext::createNull();
#endif
}

View File

@ -36,7 +36,6 @@ public:
JSSmart<CJSValue> encodeImageData(JSSmart<CJSValue> typedArray, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> stride, JSSmart<CJSValue> format, JSSmart<CJSValue> isRgba);
JSSmart<CJSValue> encodeImage(JSSmart<CJSValue> typedArray, JSSmart<CJSValue> format);
JSSmart<CJSValue> getImageType(JSSmart<CJSValue> typedArray);
JSSmart<CJSValue> getImageBuffer(JSSmart<CJSValue> path);
DECLARE_EMBED_METHODS
};

View File

@ -17,7 +17,6 @@
-(JSValue*) encodeImageData : (JSValue*)typedArray : (JSValue*)w : (JSValue*)h : (JSValue*)stride : (JSValue*)format : (JSValue*)isRgba;
-(JSValue*) encodeImage : (JSValue*)typedArray : (JSValue*)format;
-(JSValue*) getImageType : (JSValue*)typedArray;
-(JSValue*) getImageBuffer : (JSValue*)path;
@end
@interface CJSCZipEmbed : NSObject<IJSCZipEmbed, JSEmbedObjectProtocol>
@ -42,7 +41,6 @@ FUNCTION_WRAPPER_JS_2(decodeImage, decodeImage)
FUNCTION_WRAPPER_JS_6(encodeImageData, encodeImageData)
FUNCTION_WRAPPER_JS_2(encodeImage, encodeImage)
FUNCTION_WRAPPER_JS_1(getImageType, getImageType)
FUNCTION_WRAPPER_JS_1(getImageBuffer, getImageBuffer)
@end
class CZipEmbedAdapter : public CJSEmbedObjectAdapterJSC

View File

@ -20,7 +20,6 @@ namespace NSZipEmbed
FUNCTION_WRAPPER_V8_6(_encodeImageData, encodeImageData)
FUNCTION_WRAPPER_V8_2(_encodeImage, encodeImage)
FUNCTION_WRAPPER_V8_1(_getImageType, getImageType)
FUNCTION_WRAPPER_V8_1(_getImageBuffer, getImageBuffer)
v8::Handle<v8::ObjectTemplate> CreateTemplate(v8::Isolate* isolate)
{
@ -40,7 +39,6 @@ namespace NSZipEmbed
NSV8Objects::Template_Set(result, "encodeImageData", _encodeImageData);
NSV8Objects::Template_Set(result, "encodeImage", _encodeImage);
NSV8Objects::Template_Set(result, "getImageType", _getImageType);
NSV8Objects::Template_Set(result, "getImageBuffer", _getImageBuffer);
return handle_scope.Escape(result);
}

View File

@ -10,35 +10,18 @@
#define M_PI 3.14159265358979323846
#endif
#ifdef _DEBUG
//#define ENABLE_GR_LOGS
#endif
namespace NSGraphics
{
void CGraphics::init(double width_px, double height_px, double width_mm, double height_mm)
void CGraphics::init(NSNativeControl::CNativeControl* oNative, double width_px, double height_px, double width_mm, double height_mm)
{
if (!m_pAppImage)
return;
if (NULL == m_pAppImage->GetFonts())
{
NSFonts::IApplicationFonts* pFonts = NSFonts::NSApplication::Create();
std::wstring sFontsDir = m_pAppImage->GetFontsDirectory();
pFonts->InitializeFromFolder(sFontsDir.empty() ? NSFile::GetProcessDirectory() : sFontsDir);
m_pAppImage->SetFonts(pFonts);
RELEASEINTERFACE(pFonts);
}
NSFonts::IFontManager* pManager = m_pAppImage->GetFonts()->GenerateFontManager();
#ifdef ENABLE_GR_LOGS
std::wcout << L"init "<<
m_pAppImage->GetImagesDirectory() << L" " <<
m_pAppImage->GetFontsDirectory() << L" " <<
width_px << L" " << height_px << L" " <<
width_mm << L" " << height_mm << std::endl;
m_sApplicationImagesDirectory = oNative->m_strImagesDirectory;
m_sApplicationFontsDirectory = oNative->m_strFontsDirectory;
#ifdef _DEBUG
std::wcout << L"init "<< m_sApplicationImagesDirectory << L" " << m_sApplicationFontsDirectory << L" " << width_px << L" " << height_px << L" " << width_mm << L" " << height_mm << std::endl;
#endif
m_pApplicationFonts = NSFonts::NSApplication::Create();
m_pApplicationFonts->InitializeFromFolder(m_sApplicationFontsDirectory.empty() ? NSFile::GetProcessDirectory() : m_sApplicationFontsDirectory);
NSFonts::IFontManager* pManager = m_pApplicationFonts->GenerateFontManager();
m_pRenderer = NSGraphics::Create();
m_pRenderer->SetFontManager(pManager);
@ -59,19 +42,7 @@ namespace NSGraphics
if (nRasterH < 1) nRasterH = 0;
}
int nExistW = 0;
int nExistH = 0;
BYTE* pData = m_pAppImage->GetBits(nExistW, nExistH);
if (pData != NULL)
{
nRasterW = nExistW;
nRasterH = nExistH;
}
else
{
pData = m_pAppImage->AllocBits(nRasterW, nRasterH);
}
BYTE* pData = new BYTE[4 * nRasterW * nRasterH];
unsigned int back = 0xffffff;
unsigned int* pData32 = (unsigned int*)pData;
unsigned int* pData32End = pData32 + nRasterW * nRasterH;
@ -84,21 +55,21 @@ namespace NSGraphics
m_oFrame.put_Stride(4 * nRasterW);
m_pRenderer->CreateFromBgraFrame(&m_oFrame);
m_pRenderer->SetSwapRGB(m_pAppImage->GetRgba());
m_pRenderer->SetSwapRGB(false);
m_pRenderer->put_Width(width_mm);
m_pRenderer->put_Height(height_mm);
}
void CGraphics::put_GlobalAlpha(bool enable, double alpha)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "put_GlobalAlpha " << enable << " " << alpha << std::endl;
#endif
m_pRenderer->put_GlobalAlphaEnabled(enable, alpha);
}
void CGraphics::End_GlobalAlpha()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "End_GlobalAlpha " << std::endl;
#endif
bool bIsInteger = m_pRenderer->get_IntegerGrid();
@ -115,7 +86,7 @@ namespace NSGraphics
}
void CGraphics::p_color(int r, int g, int b, int a)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "p_color " << r << " " << g << " " << b << " " << a << std::endl;
#endif
m_pRenderer->put_PenColor(r | (g << 8) | (b << 16));
@ -123,14 +94,14 @@ namespace NSGraphics
}
void CGraphics::p_width(double w)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "p_width " << w << std::endl;
#endif
m_pRenderer->put_PenSize(w / 1000.0);
}
void CGraphics::p_dash(size_t length, double* dash)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "p_dash " << length << std::endl;
#endif
if(length > 0)
@ -148,7 +119,7 @@ namespace NSGraphics
}
void CGraphics::b_color1(int r, int g, int b, int a)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "b_color1 " << r << " " << g << " " << b << " " << a << std::endl;
#endif
m_pRenderer->put_BrushType(c_BrushTypeSolid);
@ -157,7 +128,7 @@ namespace NSGraphics
}
void CGraphics::b_color2(int r, int g, int b, int a)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "b_color2 " << r << " " << g << " " << b << " " << a << std::endl;
#endif
m_pRenderer->put_BrushColor2(r | (g << 8) | (b << 16));
@ -165,42 +136,42 @@ namespace NSGraphics
}
void CGraphics::transform(double sx, double shy, double shx, double sy, double tx, double ty)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "transform " << sx << " " << shy << " " << shx << " " << sy << " " << tx << " " << ty << std::endl;
#endif
m_pRenderer->SetTransform(sx, shy, shx, sy, tx, ty);
}
void CGraphics::CalculateFullTransform()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "CalculateFullTransform " << std::endl;
#endif
m_pRenderer->CalculateFullTransform();
}
void CGraphics::_s()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "_s " << std::endl;
#endif
m_pRenderer->PathCommandEnd();
}
void CGraphics::_e()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "_e " << std::endl;
#endif
m_pRenderer->PathCommandEnd();
}
void CGraphics::_z()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "_z " << std::endl;
#endif
m_pRenderer->PathCommandClose();
}
void CGraphics::_m(double x, double y)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "_m " << x << " " << y << std::endl;
#endif
if (!m_pRenderer->get_IntegerGrid())
@ -213,7 +184,7 @@ namespace NSGraphics
}
void CGraphics::_l(double x, double y)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "_l " << x << " " << y << std::endl;
#endif
if (!m_pRenderer->get_IntegerGrid())
@ -226,7 +197,7 @@ namespace NSGraphics
}
void CGraphics::_c (double x1, double y1, double x2, double y2, double x3, double y3)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "_c " << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << std::endl;
#endif
if (!m_pRenderer->get_IntegerGrid())
@ -241,7 +212,7 @@ namespace NSGraphics
}
void CGraphics::_c2(double x1, double y1, double x2, double y2)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "_c2 " << x1 << " " << y1 << " " << x2 << " " << y2 << std::endl;
#endif
if (!m_pRenderer->get_IntegerGrid())
@ -255,28 +226,28 @@ namespace NSGraphics
}
void CGraphics::ds()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "ds " << std::endl;
#endif
m_pRenderer->Stroke();
}
void CGraphics::df()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "df " << std::endl;
#endif
m_pRenderer->Fill();
}
void CGraphics::save()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "save " << std::endl;
#endif
m_oFrame.SaveFile(m_pAppImage->GetImagesDirectory() + L"/img.png", _CXIMAGE_FORMAT_PNG);
m_oFrame.SaveFile(m_sApplicationImagesDirectory + L"/img.png", _CXIMAGE_FORMAT_PNG);
}
void CGraphics::restore()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "restore " << std::endl;
#endif
m_pRenderer->BeginCommand(c_nResetClipType);
@ -284,7 +255,7 @@ namespace NSGraphics
}
void CGraphics::clip()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "clip " << std::endl;
#endif
m_pRenderer->BeginCommand(c_nClipType);
@ -292,46 +263,43 @@ namespace NSGraphics
}
void CGraphics::reset()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "reset " << std::endl;
#endif
m_pRenderer->ResetTransform();
}
void CGraphics::FreeFont()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "FreeFont " << std::endl;
#endif
m_pRenderer->CloseFont();
}
void CGraphics::ClearLastFont()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "ClearLastFont " << std::endl;
#endif
m_pRenderer->ClearInstallFont();
}
void CGraphics::drawImage(const std::wstring& img, double x, double y, double w, double h, BYTE alpha)
{
std::wstring strImage = img;
if (!NSFile::CFileBinary::Exists(img))
strImage = (0 == img.find(L"theme") ? m_pAppImage->GetThemesDirectory() : m_pAppImage->GetImagesDirectory()) + L'/' + img;
#ifdef ENABLE_GR_LOGS
std::wstring strImage = (0 == img.find(L"theme") ? m_sApplicationThemesDirectory : m_sApplicationImagesDirectory) + L'/' + img;
#ifdef _DEBUG
std::wcout << L"drawImage " << strImage << L" " << x << " " << y << L" " << w << L" " << h << L" " << alpha << std::endl;
#endif
m_pRenderer->DrawImageFromFile(strImage, x, y, w, h, alpha);
}
std::wstring CGraphics::GetFont()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "GetFont " << std::endl;
#endif
return m_pRenderer->GetFontManager()->GetName();
}
void CGraphics::SetFont(const std::wstring& name, int face, double size, int style)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::wcout << L"SetFont " << name << L" " << face << L" " << size << L" " << style << std::endl;
#endif
double DpiX, DpiY;
@ -346,21 +314,21 @@ namespace NSGraphics
}
void CGraphics::FillText(double x, double y, int text)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::wcout << L"FillText " << (wchar_t)text << L" " << x << L" " << y << std::endl;
#endif
m_pRenderer->CommandDrawTextCHAR(text, x, y, 0, 0);
}
void CGraphics::t(double x, double y, const std::wstring& text)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::wcout << L"t " << text << L" " << x << L" " << y << std::endl;
#endif
m_pRenderer->CommandDrawText(text, x, y, 0, 0);
}
void CGraphics::tg(int text, double x, double y)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::wcout << L"tg " << text << L" " << x << L" " << y << std::endl;
#endif
m_pRenderer->put_FontStringGID(TRUE);
@ -369,21 +337,21 @@ namespace NSGraphics
}
void CGraphics::SetIntegerGrid(bool param)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "SetIntegerGrid " << param << std::endl;
#endif
m_pRenderer->put_IntegerGrid(param);
}
bool CGraphics::GetIntegerGrid()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "GetIntegerGrid " << std::endl;
#endif
return m_pRenderer->get_IntegerGrid();
}
void CGraphics::DrawStringASCII (const std::wstring& text, double x, double y)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::wcout << L"DrawStringASCII " << text << L" " << x << L" " << y << std::endl;
#endif
double DpiY;
@ -405,7 +373,7 @@ namespace NSGraphics
}
void CGraphics::DrawHeaderEdit(double yPos)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "DrawHeaderEdit " << std::endl;
#endif
m_pRenderer->PathCommandEnd();
@ -448,7 +416,7 @@ namespace NSGraphics
}
void CGraphics::DrawFooterEdit(double yPos)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "DrawFooterEdit " << std::endl;
#endif
m_pRenderer->PathCommandEnd();
@ -491,7 +459,7 @@ namespace NSGraphics
}
void CGraphics::DrawLockParagraph (double x, double y1, double y2)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "DrawLockParagraph " << std::endl;
#endif
m_pRenderer->PathCommandEnd();
@ -563,7 +531,7 @@ namespace NSGraphics
}
void CGraphics::DrawLockObjectRect(double x, double y, double w, double h)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "DrawLockObjectRect " << std::endl;
#endif
m_pRenderer->PathCommandEnd();
@ -589,7 +557,7 @@ namespace NSGraphics
}
void CGraphics::DrawEmptyTableLine(double x1, double y1, double x2, double y2)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "DrawEmptyTableLine " << std::endl;
#endif
m_pRenderer->PathCommandEnd();
@ -674,7 +642,7 @@ namespace NSGraphics
}
void CGraphics::DrawSpellingLine (double y0, double x0, double x1, double w)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "DrawSpellingLine " << std::endl;
#endif
Aggplus::CMatrix* pMatrix = m_pRenderer->GetTransformMatrix();
@ -1020,7 +988,7 @@ namespace NSGraphics
}
void CGraphics::SaveGrState()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "SaveGrState " << std::endl;
#endif
CGrStateState* pState = new CGrStateState();
@ -1036,7 +1004,7 @@ namespace NSGraphics
}
void CGraphics::RestoreGrState()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "RestoreGrState " << std::endl;
#endif
if (m_oGrState.States.empty())
@ -1100,14 +1068,14 @@ namespace NSGraphics
}
void CGraphics::StartClipPath()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "StartClipPath " << std::endl;
#endif
m_pRenderer->BeginCommand(c_nClipType);
}
void CGraphics::EndClipPath()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "EndClipPath " << std::endl;
#endif
m_pRenderer->EndCommand(c_nClipType);
@ -1165,7 +1133,7 @@ namespace NSGraphics
}
std::string CGraphics::toDataURL(std::wstring type)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::wcout << "toDataURL " << type << std::endl;
#endif
std::wstring sFormat = (type.length() > 6) ? type.substr(6) : type;
@ -1210,11 +1178,11 @@ namespace NSGraphics
{
if (src.find(L"data:") == 0)
{
std::wstring strImage = m_pAppImage->GetImagesDirectory() + L"/texture.png";
std::wstring strImage = m_sApplicationImagesDirectory + L"/texture.png";
bool bIsOnlyOfficeHatch = false;
if(src.find(L"onlyoffice_hatch") != std::wstring::npos)
bIsOnlyOfficeHatch = true;
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::wcout << L"put_brushTexture " << src << L" " << type << std::endl;
#endif
src.erase(0, src.find(L',') + 1);
@ -1253,10 +1221,7 @@ namespace NSGraphics
}
else
{
std::wstring strImage = src;
if (!NSFile::CFileBinary::Exists(src))
strImage = (0 == src.find(L"theme") ? m_pAppImage->GetThemesDirectory() : m_pAppImage->GetImagesDirectory()) + L'/' + src;
std::wstring strImage = (0 == src.find(L"theme") ? m_sApplicationThemesDirectory : m_sApplicationImagesDirectory) + L'/' + src;
std::wstring sName = strImage.substr(0, strImage.rfind(L'.') + 1);
std::wstring sExt = src.substr(src.rfind(L'.') + 1);
if (sExt == L"svg")
@ -1266,7 +1231,7 @@ namespace NSGraphics
else if (NSFile::CFileBinary::Exists(sName + L"emf") && src.find(L"display") == 0)
strImage = sName + L"emf";
MetaFile::IMetaFile* pMetafile = MetaFile::Create(m_pAppImage->GetFonts());
MetaFile::IMetaFile* pMetafile = MetaFile::Create(m_pApplicationFonts);
pMetafile->LoadFromFile(strImage.c_str());
double x = 0, y = 0, w = 0, h = 0;
@ -1279,7 +1244,7 @@ namespace NSGraphics
}
else
sName += sExt;
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::wcout << L"put_brushTexture " << sName << L" " << type << std::endl;
#endif
m_pRenderer->put_BrushType(c_BrushTypeTexture);
@ -1289,21 +1254,21 @@ namespace NSGraphics
}
void CGraphics::put_brushTextureMode(int mode)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "put_brushTextureMode " << mode << std::endl;
#endif
m_pRenderer->put_BrushTextureMode(mode);
}
void CGraphics::put_BrushTextureAlpha(int a)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "put_BrushTextureAlpha " << a << std::endl;
#endif
m_pRenderer->put_BrushTextureAlpha(a == 0 ? 255 : a);
}
void CGraphics::put_BrushGradient(LONG* pColors, double* pPositions, size_t nCount, double x0, double y0, double x1, double y1, double r0, double r1)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "put_BrushGradient " << nCount << " " << x0 << " " << y0 << " " << x1 << " " << y1 << " " << r0 << " " << r1 << std::endl;
for (size_t i = 0; i < nCount; i++)
std::cout << pPositions[i] << " " << pColors[i] << " ";
@ -1328,7 +1293,7 @@ namespace NSGraphics
}
double CGraphics::TransformPointX(double x, double y)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "TransformPointX " << std::endl;
#endif
m_pRenderer->GetFullTransform()->TransformPoint(x, y);
@ -1336,7 +1301,7 @@ namespace NSGraphics
}
double CGraphics::TransformPointY(double x, double y)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "TransformPointY " << std::endl;
#endif
m_pRenderer->GetFullTransform()->TransformPoint(x, y);
@ -1344,14 +1309,14 @@ namespace NSGraphics
}
void CGraphics::put_LineJoin(int nJoin)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "put_LineJoin " << std::endl;
#endif
m_pRenderer->put_PenLineJoin(nJoin);
}
int CGraphics::GetLineJoin()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "GetLineJoin " << std::endl;
#endif
BYTE nRes;
@ -1360,7 +1325,7 @@ namespace NSGraphics
}
void CGraphics::put_TextureBounds(double x, double y, double w, double h)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "put_TextureBounds " << x << " " << y << " " << w << " " << h << std::endl;
#endif
if(m_pRenderer->get_IntegerGrid())
@ -1376,7 +1341,7 @@ namespace NSGraphics
}
double CGraphics::GetlineWidth()
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "GetlineWidth " << std::endl;
#endif
double nRes;
@ -1385,7 +1350,7 @@ namespace NSGraphics
}
void CGraphics::DrawPath(int path)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "DrawPath " << path << std::endl;
#endif
if(path == 257)
@ -1398,7 +1363,7 @@ namespace NSGraphics
}
void CGraphics::CoordTransformOffset(double tx, double ty)
{
#ifdef ENABLE_GR_LOGS
#ifdef _DEBUG
std::cout << "CoordTransformOffset " << tx << " " << ty << std::endl;
#endif
m_pRenderer->SetCoordTransformOffset(tx, ty);

View File

@ -7,7 +7,6 @@
#include "../common/File.h"
#include "nativecontrol.h"
#include "../graphics/pro/Graphics.h"
#include "embed/GraphicsEmbed.h"
namespace NSGraphics
{
@ -115,32 +114,28 @@ namespace NSGraphics
class CGraphics
{
public:
CGraphicsAppImage* m_pAppImage;
CBgraFrame m_oFrame;
std::wstring m_sApplicationFontsDirectory;
std::wstring m_sApplicationImagesDirectory;
std::wstring m_sApplicationThemesDirectory;
private:
NSFonts ::IApplicationFonts* m_pApplicationFonts;
NSGraphics::IGraphicsRenderer* m_pRenderer;
CBgraFrame m_oFrame;
CGrState m_oGrState;
public:
CGraphics()
{
m_pAppImage = NULL;
}
CGraphics() {}
~CGraphics()
{
Destroy();
}
void init(double width_px, double height_px, double width_mm, double height_mm);
void init(NSNativeControl::CNativeControl* oNative, double width_px, double height_px, double width_mm, double height_mm);
void Destroy()
{
int w, h;
if (m_pAppImage && m_pAppImage->GetBits(w, h))
m_oFrame.put_Data(NULL);
RELEASEINTERFACE(m_pRenderer);
RELEASEOBJECT(m_pAppImage);
RELEASEINTERFACE(m_pApplicationFonts);
}
void EndDraw() {}
void put_GlobalAlpha(bool enable, double globalAlpha);

View File

@ -374,7 +374,7 @@ namespace NSJSBase
JSSmart<CJSContext> CJSContext::GetCurrent()
{
CJSContext* ret = new CJSContext(false);
CJSContext* ret = new CJSContext();
ret->m_internal->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
return ret;
}

View File

@ -54,9 +54,9 @@ v8::Local<v8::String> CreateV8String(v8::Isolate* i, const std::string& str);
#ifdef __ANDROID__
//#ifdef _DEBUG
#ifdef _DEBUG
#define ANDROID_LOGS
//#endif
#endif
#ifdef ANDROID_LOGS
#include <android/log.h>
@ -488,11 +488,7 @@ namespace NSJSBase
virtual CJSEmbedObject* getNative()
{
if (0 == value->InternalFieldCount())
return NULL;
v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(value->GetInternalField(0));
if (field.IsEmpty())
return NULL;
return (CJSEmbedObject*)field->Value();
}
@ -995,76 +991,67 @@ inline void js_return(const v8::PropertyCallbackInfo<v8::Value>& info, JSSmart<N
#define PROPERTY_GET(NAME, NAME_EMBED) \
void NAME(v8::Local<v8::String> _name, const v8::PropertyCallbackInfo<v8::Value>& info) \
{ \
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(info.Holder())); \
if (!_this) return; \
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(info.Holder()); \
JSSmart<CJSValue> ret = _this->NAME_EMBED(); \
js_return(info, ret); \
}
#define FUNCTION_WRAPPER_V8_0(NAME, NAME_EMBED) \
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
{ \
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
if (!_this) return; \
JSSmart<CJSValue> ret = _this->NAME_EMBED(); \
js_return(args, ret); \
#define FUNCTION_WRAPPER_V8_0(NAME, NAME_EMBED) \
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
{ \
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
JSSmart<CJSValue> ret = _this->NAME_EMBED(); \
js_return(args, ret); \
}
#define FUNCTION_WRAPPER_V8(NAME, NAME_EMBED) FUNCTION_WRAPPER_V8_0(NAME, NAME_EMBED)
#define FUNCTION_WRAPPER_V8_1(NAME, NAME_EMBED) \
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
{ \
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
if (!_this) return; \
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0])); \
js_return(args, ret); \
#define FUNCTION_WRAPPER_V8_1(NAME, NAME_EMBED) \
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
{ \
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0])); \
js_return(args, ret); \
}
#define FUNCTION_WRAPPER_V8_2(NAME, NAME_EMBED) \
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
{ \
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
if (!_this) return; \
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1])); \
js_return(args, ret); \
#define FUNCTION_WRAPPER_V8_2(NAME, NAME_EMBED) \
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
{ \
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1])); \
js_return(args, ret); \
}
#define FUNCTION_WRAPPER_V8_3(NAME, NAME_EMBED) \
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
{ \
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
if (!_this) return; \
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2])); \
js_return(args, ret); \
}
#define FUNCTION_WRAPPER_V8_4(NAME, NAME_EMBED) \
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
{ \
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
if (!_this) return; \
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3])); \
js_return(args, ret); \
}
#define FUNCTION_WRAPPER_V8_5(NAME, NAME_EMBED) \
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
{ \
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
if (!_this) return; \
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4])); \
js_return(args, ret); \
}
#define FUNCTION_WRAPPER_V8_6(NAME, NAME_EMBED) \
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
{ \
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
if (!_this) return; \
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), js_value(args[5])); \
js_return(args, ret); \
}
#define FUNCTION_WRAPPER_V8_7(NAME, NAME_EMBED) \
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
{ \
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
if (!_this) return; \
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), \
js_value(args[5]), js_value(args[6])); \
js_return(args, ret); \
@ -1072,8 +1059,7 @@ inline void js_return(const v8::PropertyCallbackInfo<v8::Value>& info, JSSmart<N
#define FUNCTION_WRAPPER_V8_8(NAME, NAME_EMBED) \
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
{ \
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
if (!_this) return; \
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), \
js_value(args[5]), js_value(args[6]), js_value(args[7])); \
js_return(args, ret); \
@ -1081,8 +1067,7 @@ inline void js_return(const v8::PropertyCallbackInfo<v8::Value>& info, JSSmart<N
#define FUNCTION_WRAPPER_V8_9(NAME, NAME_EMBED) \
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
{ \
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
if (!_this) return; \
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), \
js_value(args[5]), js_value(args[6]), js_value(args[7]), js_value(args[8])); \
js_return(args, ret); \
@ -1090,8 +1075,7 @@ inline void js_return(const v8::PropertyCallbackInfo<v8::Value>& info, JSSmart<N
#define FUNCTION_WRAPPER_V8_10(NAME, NAME_EMBED) \
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
{ \
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
if (!_this) return; \
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), js_value(args[5]), \
js_value(args[6]), js_value(args[7]), js_value(args[8]), js_value(args[9])); \
js_return(args, ret); \
@ -1099,8 +1083,7 @@ inline void js_return(const v8::PropertyCallbackInfo<v8::Value>& info, JSSmart<N
#define FUNCTION_WRAPPER_V8_13(NAME, NAME_EMBED) \
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
{ \
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
if (!_this) return; \
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), js_value(args[5]), \
js_value(args[6]), js_value(args[7]), js_value(args[8]), js_value(args[9]), js_value(args[10]), js_value(args[11]), \
js_value(args[12])); \

View File

@ -99,11 +99,6 @@ namespace NSJSON
return m_internal->m_type == CTypedValue::vtObject;
}
bool IValue::IsImage() const
{
return m_internal->m_type == CTypedValue::vtImage;
}
bool IValue::ToBool() const
{
if (m_internal->m_type != CTypedValue::vtPrimitive)
@ -355,11 +350,6 @@ namespace NSJSON
strRes += "}";
break;
}
case CTypedValue::vtImage:
{
// TODO: implement like typed array?
break;
}
}
return strRes;
@ -507,82 +497,6 @@ namespace NSJSON
return static_cast<CObject*>(m_internal->m_value.get())->getPropertyNames();
}
const BYTE* IValue::GetImageBits() const
{
if (m_internal->m_type != CTypedValue::vtImage)
{
#ifdef JSON_DEBUG
throw std::bad_cast();
#endif
return nullptr;
}
return static_cast<CImage*>(m_internal->m_value.get())->getBits();
}
BYTE* IValue::GetImageBits()
{
return const_cast<BYTE*>(static_cast<const CValue&>(*this).GetImageBits());
}
int IValue::GetImageWidth() const
{
if (m_internal->m_type != CTypedValue::vtImage)
{
#ifdef JSON_DEBUG
throw std::bad_cast();
#endif
return 0;
}
return static_cast<CImage*>(m_internal->m_value.get())->getWidth();
}
int IValue::GetImageHeight() const
{
if (m_internal->m_type != CTypedValue::vtImage)
{
#ifdef JSON_DEBUG
throw std::bad_cast();
#endif
return 0;
}
return static_cast<CImage*>(m_internal->m_value.get())->getHeight();
}
ImageFormat IValue::GetImageFormat() const
{
if (m_internal->m_type != CTypedValue::vtImage)
{
#ifdef JSON_DEBUG
throw std::bad_cast();
#endif
return ImageFormat::ifInvalid;
}
return static_cast<CImage*>(m_internal->m_value.get())->getFormat();
}
void IValue::ImageExternalize()
{
if (m_internal->m_type != CTypedValue::vtImage)
{
#ifdef JSON_DEBUG
throw std::bad_cast();
#endif
return;
}
static_cast<CImage*>(m_internal->m_value.get())->externalize();
}
void IValue::ImageAlloc(const int& width, const int& height, const ImageFormat& format)
{
if (m_internal->m_type != CTypedValue::vtImage)
{
#ifdef JSON_DEBUG
throw std::bad_cast();
#endif
return;
}
static_cast<CImage*>(m_internal->m_value.get())->alloc(width, height, format);
}
CValue::CValue() : IValue()
{
@ -676,35 +590,6 @@ namespace NSJSON
NSJSBase::NSAllocator::Free(data, size);
}
CValue CValue::CreateImage(BYTE* bits, int width, int height, ImageFormat format, bool isExternalize)
{
CValue ret;
if (width <= 0 || height <= 0)
return ret;
ret.m_internal->m_value = std::make_shared<CImage>(bits, width, height, format, isExternalize);
ret.m_internal->m_type = CTypedValue::vtImage;
return ret;
}
CValue CValue::CreateEmptyImage(ImageFormat format)
{
CValue ret;
ret.m_internal->m_value = std::make_shared<CImage>((BYTE*)NULL, 0, 0, format, false);
ret.m_internal->m_type = CTypedValue::vtImage;
return ret;
}
BYTE* CValue::AllocImageBits(int width, int height)
{
return new BYTE[4 * width * height];
}
void CValue::FreeImageBits(BYTE* bits)
{
delete[] bits;
}
CValue CValue::CreateObject()
{
CValue ret;

View File

@ -20,7 +20,7 @@
#endif
// uncomment to enable exceptions throwing
// #define JSON_DEBUG
//#define JSON_DEBUG
#ifdef JSON_DEBUG
#include <stdexcept>
@ -29,14 +29,6 @@
namespace NSJSON
{
typedef unsigned char BYTE;
enum class ImageFormat
{
ifRGBA,
ifBGRA,
ifARGB,
ifInvalid
};
class CValue;
class CValueRef;
@ -96,10 +88,6 @@ namespace NSJSON
* Returns true if the value is an object.
*/
bool IsObject() const;
/**
* Returns true if the value is an image.
*/
bool IsImage() const;
// FUNCTIONS FOR WORKING WITH PRIMITIVE VALUES
/**
@ -205,39 +193,6 @@ namespace NSJSON
*/
std::vector<std::string> GetPropertyNames() const;
// FUNCTIONS FOR WORKING WITH IMAGES
/**
* Gets bits of image.
* @return the pointer to memory, allocated for the image. If current value is not an image, returns nullptr.
*/
const BYTE* GetImageBits() const;
BYTE* GetImageBits();
/**
* Gets width of the image.
* @returns Returns the width of the image. If current value is not an image, returns 0.
*/
int GetImageWidth() const;
/**
* Gets height of the image.
* @returns Returns the height of the image. If current value is not an image, returns 0.
*/
int GetImageHeight() const;
/**
* Gets format of the image.
* @returns Returns the image format. If current value is not an image, returns ImageFormat::ifInvalid.
*/
ImageFormat GetImageFormat() const;
/**
* Make image bits external.
*/
void ImageExternalize();
/**
* Alloc image bits as internal.
*/
void ImageAlloc(const int& width, const int& height, const ImageFormat& format);
protected:
std::shared_ptr<CTypedValue> m_internal;
};
@ -296,30 +251,6 @@ namespace NSJSON
*/
static void FreeTypedArray(BYTE* data, size_t size);
// IMAGE
/**
* Creates and returns new image object.
* @param bits The pointer to image data. The pointer should be acquired with AllocImageBits().
* @param width The width of the image.
* @param height The height of the image.
* @param format The format of the image.
* @param isExternalize If true the memory will not be reclaimed when the created image is destroyed.
* If this parameter is false then the memory will be released using FreeImageBits() during the image object destruction.
*/
static CValue CreateImage(BYTE* bits, int width, int height, ImageFormat format = ImageFormat::ifBGRA, bool isExternalize = true);
static CValue CreateEmptyImage(ImageFormat format = ImageFormat::ifBGRA);
/**
* Allocates the memory for an image.
* @param width The width of the image.
* @param height The height of the image.
*/
static BYTE* AllocImageBits(int width, int height);
/**
* Frees the memory for a image bits.
* @param data The allocated memory to be released.
*/
static void FreeImageBits(BYTE* bits);
// OBJECT CONSTRUCTOR
/**
* Creates and returns empty object.

View File

@ -17,8 +17,7 @@ namespace NSJSON
vtPrimitive,
vtArray,
vtTypedArray,
vtObject,
vtImage
vtObject
};
public:

View File

@ -211,56 +211,4 @@ namespace NSJSON
}
return ret;
}
CImage::CImage(BYTE* bits, const int& width, const int& height, const ImageFormat& format, const bool& isExternalize) :
m_bits(bits), m_width(width), m_height(height), m_format(format), m_isExternalize(isExternalize)
{
}
CImage::~CImage()
{
if (!m_isExternalize)
{
CValue::FreeImageBits(m_bits);
}
}
void CImage::alloc(const int& width, const int& height, const ImageFormat& format)
{
if (!m_isExternalize && m_bits)
{
CValue::FreeImageBits(m_bits);
}
m_bits = CValue::AllocImageBits(width, height);
m_width = width;
m_height = height;
m_format = format;
m_isExternalize = false;
}
BYTE* CImage::getBits()
{
return m_bits;
}
int CImage::getWidth()
{
return m_width;
}
int CImage::getHeight()
{
return m_height;
}
ImageFormat CImage::getFormat()
{
return m_format;
}
void CImage::externalize()
{
m_isExternalize = true;
}
}

View File

@ -113,28 +113,6 @@ namespace NSJSON
private:
storage_t m_values;
};
class CImage : public IBaseValue
{
public:
CImage(BYTE* bits, const int& width, const int& height, const ImageFormat& format, const bool& isExternalize = true);
~CImage();
public:
BYTE* getBits();
int getWidth();
int getHeight();
ImageFormat getFormat();
void externalize();
void alloc(const int& width, const int& height, const ImageFormat& format);
private:
BYTE* m_bits;
int m_width;
int m_height;
ImageFormat m_format;
bool m_isExternalize;
};
} // namespace
}
#endif // JSON_VALUES_H_

View File

@ -3,75 +3,9 @@
#include "json.h"
#include "../js_internal/js_base.h"
#include "../embed/GraphicsEmbed.h"
#include <cmath>
class CAppImageTo : public CGraphicsAppImage
{
private:
NSJSON::CValueRef* m_image;
public:
CAppImageTo(const NSJSON::CValue& image) : CGraphicsAppImage()
{
m_image = new NSJSON::CValueRef(image);
}
virtual ~CAppImageTo()
{
if (m_image)
delete m_image;
}
public:
virtual unsigned char* GetBits(int& w, int& h)
{
unsigned char* bits = m_image->GetImageBits();
if (NULL != bits)
{
w = m_image->GetImageWidth();
h = m_image->GetImageHeight();
}
return bits;
}
virtual unsigned char* AllocBits(const int& w, const int& h)
{
m_image->ImageAlloc(w, h, GetRgba() ? NSJSON::ImageFormat::ifRGBA : NSJSON::ImageFormat::ifBGRA);
return m_image->GetImageBits();
}
};
class CAppImageFrom : public CGraphicsAppImage
{
public:
unsigned char* m_pData;
int m_nW;
int m_nH;
public:
CAppImageFrom() : CGraphicsAppImage()
{
m_pData = NULL;
m_nW = 0;
m_nH = 0;
}
virtual ~CAppImageFrom()
{
}
public:
virtual unsigned char* GetBits(int& w, int& h)
{
return m_pData;
}
virtual unsigned char* AllocBits(const int& w, const int& h)
{
m_nW = w;
m_nH = h;
m_pData = NSJSON::CValue::AllocImageBits(w, h);
return m_pData;
}
};
namespace NSJSON
{
static JSSmart<NSJSBase::CJSValue> toJS(const CValue& value)
@ -116,12 +50,6 @@ namespace NSJSON
JSSmart<NSJSBase::CJSTypedArray> jsTypedArr = NSJSBase::CJSContext::createUint8Array(const_cast<BYTE*>(value.GetData()), value.GetCount());
ret = jsTypedArr->toValue();
}
else if (value.IsImage())
{
JSSmart<CJSObject> wrap = CJSContext::createEmbedObject("CGraphicsEmbed");
((CGraphicsEmbed*)wrap->getNative())->SetAppImage(new CAppImageTo(value));
ret = wrap->toValue();
}
// objects (there is no need for IsObject())
else
{
@ -202,25 +130,6 @@ namespace NSJSON
else if (jsValue->isObject())
{
JSSmart<NSJSBase::CJSObject> jsObj = jsValue->toObject();
CJSEmbedObject* pNative = jsObj->getNative();
if (pNative != NULL)
{
CGraphicsEmbed* pGrEmbed = dynamic_cast<CGraphicsEmbed*>(pNative);
if (pGrEmbed)
{
CAppImageFrom* pAppImage = dynamic_cast<CAppImageFrom*>(pGrEmbed->GetAppImage());
if (pAppImage)
{
return NSJSON::CValue::CreateImage(pAppImage->m_pData,
pAppImage->m_nW,
pAppImage->m_nH,
pAppImage->GetRgba() ? ImageFormat::ifRGBA : ImageFormat::ifBGRA,
false);
}
}
}
std::vector<std::string> properties = jsObj->getPropertyNames();
ret = CValue::CreateObject();
for (const std::string& name : properties)

View File

@ -44,10 +44,7 @@ CImagesWorker::CImagesWorker(const std::wstring& sFolder)
std::wstring CImagesWorker::GetImageLocal(const std::wstring& sUrl)
{
if (CServerInstance::getInstance().IsEnable())
{
if (!CServerInstance::getInstance().CheckTmpDirectory(sUrl))
return L"error";
}
return L"error";
std::wstring sExt = NSFile::GetFileExtention(sUrl);
std::wstring sRet = L"image" + std::to_wstring(m_nIndex++) + L"." + sExt;
m_mapImages.insert(std::make_pair(sUrl, sRet));

View File

@ -0,0 +1,9 @@
!*.vcxproj.user
!Makefile
out/
*.docx
*.pptx
*.xlsx
*.class

View File

@ -0,0 +1,156 @@
- [Document Builder samples](#document-builder-samples)
- [About](#about)
- [Project generator: configure.py](#project-generator-configurepy)
- [Running C++ samples](#running-c-samples)
- [Visual Studio](#visual-studio)
- [Qt](#qt)
- [Makefile](#makefile)
- [Running C# samples](#running-c-samples-1)
- [Visual Studio](#visual-studio-1)
- [Running Python samples](#running-python-samples)
- [Running Java samples](#running-java-samples)
# Document Builder samples
## About
Here you can find some code samples for Document Builder library in different programming languages:
1. [C++](#running-c-samples)
2. [C# (.NET)](#running-c-samples-1)
3. [Python](#running-python-samples)
4. [Java](#running-java-samples)
## Project generator: configure.py
For running C++ and C# code samples use python script `configure/configure.py` which is able to generate:
+ Visual Studio project files
+ Qt project file
+ Makefile
To use `configure.py` you need to specify following options:
1. Which project files to generate: `--vs`, `--qt` or `--make`. Several options are available at the same time, but some of them are not supported on all platforms. In case you provide none of these options, all available projects will be generated.
2. Test samples with `--test TEST`. Some available options:
- `--test all` generate projects for both C++ and C#.
- `--test cpp` generate projects only for C++ samples
- `--test cs` generate projects only for C# samples.
- `--test cpp/creating_basic_form` generate only project for the specified sample.
Several test options are available at the same time. To see all available `TEST` options call `configure.py -l`.
3. Directory to the Document Builder with `--dir DIR`. If Document Builder is not installed in default path you have to provide path to it.
Generated files will be located in the `out` directory inside of the corresponding test folders.
## Running C++ samples
If Document Builder is not installed in `C:/Program Files/ONLYOFFICE/DocumentBuilder`, for every C++ sample you should change the `workDir` variable at the beginning of *main.cpp* to actual location of Document Builder directory.
### Visual Studio
> **NOTE:** Only available on Windows
1. Use `configure.py` to generate VS project files. For example:
```shell
python configure.py --vs --test cpp/creating_basic_form --test cpp/creating_advanced_form
```
2. Open `.sln` file in Visual Studio. It will prompt you to retarget Windows SDK and VS toolset to your installed version click "OK".
3. The solution is ready to be built and run. Documents will be created in the project files directory.
### Qt
1. Use `configure.py` to generate Qt project files. For example:
```shell
python configure.py --qt --test cpp
```
2. Open `.pro` file in Qt Creator.
3. The project is ready to be built and run. Documents will be created in the `build` directory.
### Makefile
> **NOTE:** Only available on Linux and Mac OS.
1. Use `configure.py` to generate Makefile. For example:
```shell
python configure.py --make --test cpp/filling_spreadsheet
```
2. Go to the directory with generated Makefile:
```shell
cd ../out/cpp/filling_spreadsheet
```
3. Call
```shell
make
```
`make` will build and run the executable. Documents will be created in the same directory as Makefile is.
## Running C# samples
> **NOTE:** Only available on Windows with Visual Studio and .NET SDK installed
If Document Builder is not installed in `C:/Program Files/ONLYOFFICE/DocumentBuilder`, for every C# sample you should change the `workDirectory` variable at the beginning of `Main` function to actual location of Document Builder directory.
### Visual Studio
1. Use `configure.py` to generate VS project files. For example:
```shell
python configure.py --vs --test cs
```
2. Open `.sln` file in Visual Studio. Depending on your installed .NET SDK version you may need to set different target framework by setting it in Visual Studio project properties or editing it directly in the `.csproj` file.
3. The solution is ready to be built and run. Documents will be created in the project files directory.
## Running Python samples
1. Go to test directory:
```shell
cd python/creating_basic_form
```
2. If it is needed, edit path to builder directory at the beginning of the python script:
```py
sys.path.append('C:/Program Files/ONLYOFFICE/DocumentBuilder')
```
3. Run the script
```shell
python main.py
```
Documents will be created in the test directory.
## Running Java samples
> **NOTE:** JDK 8 or newer is required
1. Go to test directory:
```shell
cd java/creating_presentation
```
2. Compile the `Program.java` providing the path to ***docbuilder.jar***, located in the Document Builder directory:
```shell
javac -cp "C:\Program Files\ONLYOFFICE\DocumentBuilder\docbuilder.jar" Program.java
```
3. `.class` file should appear in the directory. Run the program:
```shell
java -cp "C:\Program Files\ONLYOFFICE\DocumentBuilder\docbuilder.jar;." Program
```
Note, that on UNIX systems the path separator is `:` instead of `;`. Thus, on Linux or Mac OS it should be:
```shell
java -cp "/opt/onlyoffice/documentbuilder/docbuilder.jar:." Program
```
3. Documents will be created in the test directory.

View File

@ -0,0 +1,293 @@
import os
import argparse
import platform
import uuid
langs = ['cpp', 'cs']
os_name = platform.system().lower()
def mkdir(dir):
if not os.path.exists(dir):
os.mkdir(dir)
def log(level, message):
print('configure.py: ' + level + ': ' + message)
def getDefaultBuilderDir():
dir = ''
if os_name == 'windows':
dir = 'C:\\Program Files\\ONLYOFFICE\\DocumentBuilder'
elif os_name == 'linux':
dir = '/opt/onlyoffice/documentbuilder'
return dir
def getAllTests():
tests = {}
for lang in langs:
tests[lang] = []
test_dirs = os.listdir(lang)
for test_dir in test_dirs:
if not os.path.isdir(lang + '/' + test_dir):
continue
tests[lang].append(lang + '/' + test_dir)
return tests
def printAvailableTests():
all_tests = getAllTests()
print('all')
for lang in langs:
print('-----')
print(lang)
tests = all_tests[lang]
for test in tests:
print(test)
class PrintTestsList(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
printAvailableTests()
exit()
def getSelectedTests(tests):
all_tests = getAllTests()
# make set of all available tests
tests_set = {'all'}
for lang in langs:
tests_set.add(lang)
tests_set.update(all_tests[lang])
# make dict with set of selected tests
tests_selected = {lang: set() for lang in langs}
# filter tests through only available ones
for test in tests:
if not test in tests_set:
log('warning', 'wrong test "' + test + '". Call script with --list (or -l) to see all available tests')
continue
if test == 'all':
for lang in langs:
tests_selected[lang].update(all_tests[lang])
elif not '/' in test:
lang = test
tests_selected[lang].update(all_tests[lang])
else:
lang = test.split('/')[0]
tests_selected[lang].add(test)
# delete empty tests
for lang in langs:
if not tests_selected[lang]:
del tests_selected[lang]
return tests_selected
def replacePlaceholders(template_file, output_file, replacements):
content = ''
# open and read template file
with open(template_file, 'r') as file:
content = file.read()
# replace all placeholders with corresponding values
for placeholder, replacement in replacements.items():
content = content.replace(placeholder, replacement)
# write result to output file
with open(output_file, 'w') as file:
file.write(content)
def genVSProjectsCPP(tests, builder_dir):
for test in tests:
test_dir = 'out/' + test
mkdir(test_dir)
test_name = test.split('/')[1]
if os.path.exists(test_dir + '/' + test_name + '.vcxproj'):
log('info', 'VS C++ project for sample "' + test + '" already exists. Skipping.')
continue
else:
log('info', 'generating VS C++ project for sample "' + test + '"...')
# .vcxproj
project_guid = str(uuid.uuid4())
replacements = {
'[PROJECT_GUID]': project_guid,
'[TEST_NAME]': test_name,
'[BUILDER_DIR]': builder_dir,
'[ROOT_DIR]': os.getcwd()
}
replacePlaceholders('configure/project_templates/cpp/template.vcxproj', test_dir + '/' + test_name + '.vcxproj', replacements)
# .sln
replacements = {
'[SOLUTION_GUID]': str(uuid.uuid4()).upper(),
'[TEST_NAME]': test_name,
'[PROJECT_GUID]': project_guid.upper(),
'[EXT_GLOBALS_GUID]': str(uuid.uuid4()).upper()
}
replacePlaceholders('configure/project_templates/cpp/template.sln', test_dir + '/' + test_name + '.sln', replacements)
# .vcxproj.filters
replacements = {
'[GUID_SOURCE_FILES]': str(uuid.uuid4()).upper(),
'[GUID_HEADER_FILES]': str(uuid.uuid4()).upper(),
'[GUID_RESOURCE_FILES]': str(uuid.uuid4()).upper(),
'[TEST_NAME]': test_name
}
replacePlaceholders('configure/project_templates/cpp/template.vcxproj.filters', test_dir + '/' + test_name + '.vcxproj.filters', replacements)
# .vcxproj.user
replacements = {
'[BUILDER_DIR]': builder_dir
}
replacePlaceholders('configure/project_templates/cpp/template.vcxproj.user', test_dir + '/' + test_name + '.vcxproj.user', replacements)
def genVSProjectsCS(tests, builder_dir):
for test in tests:
test_dir = 'out/' + test
mkdir(test_dir)
test_name = test.split('/')[1]
if os.path.exists(test_dir + '/' + test_name + '.csproj'):
log('info', 'VS C# project for sample "' + test + '" already exists. Skipping.')
continue
else:
log('info', 'generating VS C# project for sample "' + test + '"...')
# .csproj
project_guid = str(uuid.uuid4())
replacements = {
'[TEST_NAME]': test_name,
'[BUILDER_DIR]': builder_dir,
}
replacePlaceholders('configure/project_templates/cs/template.csproj', test_dir + '/' + test_name + '.csproj', replacements)
# .sln
replacements = {
'[SOLUTION_GUID]': str(uuid.uuid4()).upper(),
'[TEST_NAME]': test_name,
'[PROJECT_GUID]': project_guid.upper(),
'[EXT_GLOBALS_GUID]': str(uuid.uuid4()).upper()
}
replacePlaceholders('configure/project_templates/cs/template.sln', test_dir + '/' + test_name + '.sln', replacements)
def genVSProjects(tests_selected, builder_dir):
if os_name != 'windows':
log('warning', 'generating Visual Studio projects is only available on Windows')
return
builder_dir = builder_dir.replace('/', '\\')
for lang, tests in tests_selected.items():
mkdir('out/' + lang)
if lang == 'cpp':
genVSProjectsCPP(tests, builder_dir)
elif lang == 'cs':
genVSProjectsCS(tests, builder_dir)
def genQtProjects(tests_selected, builder_dir):
# only for C++ projects
if 'cpp' not in tests_selected:
return
root_dir = os.getcwd()
if os_name == 'windows':
builder_dir = builder_dir.replace('\\', '/')
root_dir = root_dir.replace('\\', '/')
tests = tests_selected['cpp']
mkdir('out/cpp')
for test in tests:
test_dir = 'out/' + test
mkdir(test_dir)
test_name = test.split('/')[1]
if os.path.exists(test_dir + '/' + test_name + '.pro'):
log('info', 'Qt project for sample "' + test + '" already exists. Skipping.')
continue
else:
log('info', 'generating Qt C++ project for sample "' + test + '"...')
# .pro
replacements = {
'[TEST_NAME]': test_name,
'[BUILDER_DIR]': builder_dir,
'[ROOT_DIR]': root_dir
}
replacePlaceholders('configure/project_templates/cpp/template.pro', test_dir + '/' + test_name + '.pro', replacements)
def genMakefile(tests_selected, builder_dir):
# only for C++ projects
if 'cpp' not in tests_selected:
return
if os_name == 'windows':
log('warning', 'generating Makefile is not available on Windows')
return
# initialize variables
compiler = ''
lflags = ''
env_lib_path = ''
if os_name == 'linux':
compiler = 'g++'
lflags = '-Wl,--unresolved-symbols=ignore-in-shared-libs'
env_lib_path = 'LD_LIBRARY_PATH'
elif os_name == 'darwin':
compiler = 'clang++'
env_lib_path = 'DYLD_LIBRARY_PATH'
root_dir = os.getcwd()
tests = tests_selected['cpp']
mkdir('out/cpp')
for test in tests:
test_dir = 'out/' + test
mkdir(test_dir)
test_name = test.split('/')[1]
if os.path.exists(test_dir + '/Makefile'):
log('info', 'Makefile for sample "' + test + '" already exists. Skipping.')
else:
log('info', 'generating Makefile for C++ sample "' + test + '"...')
continue
# Makefile
replacements = {
'[TEST_NAME]': test_name,
'[BUILDER_DIR]': builder_dir,
'[ROOT_DIR]': root_dir,
'[COMPILER]': compiler,
'[LFLAGS]': lflags,
'[ENV_LIB_PATH]': env_lib_path
}
replacePlaceholders('configure/project_templates/cpp/Makefile', test_dir + '/Makefile', replacements)
if __name__ == '__main__':
# go to root dir
file_dir = os.path.dirname(os.path.realpath(__file__))
os.chdir(file_dir + '/..')
# initialize argument parser
parser = argparse.ArgumentParser(description='Generate project files for Document Builder samples')
parser.add_argument('--vs', action='store_true', help='create Visual Studio (.vcxproj and .csproj) project files')
parser.add_argument('--qt', action='store_true', help='create Qt (.pro) project files')
parser.add_argument('--make', action='store_true', help='create Makefile')
parser.add_argument('-t', '--test', dest='tests', action='append', help='specifies tests to generate project files', required=True)
parser.add_argument('-l', '--list', action=PrintTestsList, nargs=0, help='show list of available tests and exit')
builder_dir = getDefaultBuilderDir()
if builder_dir:
parser.add_argument('--dir', action='store', help='specifies Document Builder directory (default: ' + builder_dir + ')', default=builder_dir)
else:
parser.add_argument('--dir', action='store', help='specifies Document Builder directory', required=True)
args = parser.parse_args()
# validate arguments
if not os.path.exists(args.dir):
log('error', 'Document Builder directory doesn\'t exist: ' + args.dir)
exit(1)
if not (args.vs or args.qt or args.make):
if os_name == 'windows':
args.vs = True
args.qt = True
if os_name != 'windows':
args.make = True
# filter tests
tests_selected = getSelectedTests(args.tests)
# generate projects
mkdir('out')
# VS
if args.vs:
genVSProjects(tests_selected, args.dir)
elif 'cs' in tests_selected:
log('warning', 'generating C# projects only available ' + ('on Windows ' if os_name != 'windows' else '') + 'with --vs')
# Qt
if args.qt:
genQtProjects(tests_selected, args.dir)
# Makefile
if args.make:
genMakefile(tests_selected, args.dir)

View File

@ -0,0 +1,29 @@
CXX = [COMPILER]
CXXFLAGS = -std=gnu++11 -Wall -W -fPIC
INCPATH = -I[BUILDER_DIR]/include -I[ROOT_DIR]
LINK = [COMPILER]
LFLAGS = [LFLAGS]
LIBS = -L[BUILDER_DIR] -ldoctrenderer
BUILD_DIR = build
SRC = ../../../cpp/[TEST_NAME]/main.cpp
OBJ = $(BUILD_DIR)/main.o
TARGET = $(BUILD_DIR)/[TEST_NAME]
.PHONY: all run clean
all: $(TARGET) run
$(TARGET): $(OBJ)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJ) $(LIBS)
$(OBJ): $(SRC)
@test -d $(BUILD_DIR) || mkdir -p $(BUILD_DIR)
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $(OBJ) $(SRC)
run: $(TARGET)
[ENV_LIB_PATH]="[BUILDER_DIR]" ./$(TARGET)
clean:
@rm -rf $(BUILD_DIR)

View File

@ -0,0 +1,17 @@
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
TARGET = [TEST_NAME]
DESTDIR = $$PWD/build
BUILDER_DIR = "[BUILDER_DIR]"
ROOT_DIR = "[ROOT_DIR]"
INCLUDEPATH += $$BUILDER_DIR/include
INCLUDEPATH += $$ROOT_DIR
LIBS += -L$$BUILDER_DIR -ldoctrenderer
linux: QMAKE_LFLAGS += -Wl,--unresolved-symbols=ignore-in-shared-libs
SOURCES += ../../../cpp/[TEST_NAME]/main.cpp

View File

@ -0,0 +1,29 @@

Microsoft Visual Studio Solution File, Format Version 12.00
MinimumVisualStudioVersion = 10.0.40219.1
Project("{[SOLUTION_GUID]}") = "[TEST_NAME]", "[TEST_NAME].vcxproj", "{[PROJECT_GUID]}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{[PROJECT_GUID]}.Debug|x64.ActiveCfg = Debug|x64
{[PROJECT_GUID]}.Debug|x64.Build.0 = Debug|x64
{[PROJECT_GUID]}.Debug|x86.ActiveCfg = Debug|Win32
{[PROJECT_GUID]}.Debug|x86.Build.0 = Debug|Win32
{[PROJECT_GUID]}.Release|x64.ActiveCfg = Release|x64
{[PROJECT_GUID]}.Release|x64.Build.0 = Release|x64
{[PROJECT_GUID]}.Release|x86.ActiveCfg = Release|Win32
{[PROJECT_GUID]}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {[EXT_GLOBALS_GUID]}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,147 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{[PROJECT_GUID]}</ProjectGuid>
<RootNamespace>[TEST_NAME]</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>[BUILDER_DIR]\include;[ROOT_DIR];$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>[BUILDER_DIR]\include;[ROOT_DIR];$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>[BUILDER_DIR];%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>doctrenderer.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>[BUILDER_DIR];%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>doctrenderer.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\cpp\[TEST_NAME]\main.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{[GUID_SOURCE_FILES]}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{[GUID_HEADER_FILES]}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{[GUID_RESOURCE_FILES]}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\cpp\[TEST_NAME]\main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerEnvironment>PATH=[BUILDER_DIR];%PATH%
$(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerEnvironment>PATH=[BUILDER_DIR];%PATH%
$(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\..\cs\[TEST_NAME]\Program.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="[BUILDER_DIR]\docbuilder.net.dll" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,23 @@

Microsoft Visual Studio Solution File, Format Version 12.00
MinimumVisualStudioVersion = 10.0.40219.1
Project("{[SOLUTION_GUID]}") = "[TEST_NAME]", "[TEST_NAME].csproj", "{[PROJECT_GUID]}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{[PROJECT_GUID]}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{[PROJECT_GUID]}.Debug|Any CPU.Build.0 = Debug|Any CPU
{[PROJECT_GUID]}.Release|Any CPU.ActiveCfg = Release|Any CPU
{[PROJECT_GUID]}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {[EXT_GLOBALS_GUID]}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,90 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <string>
#include "common.h"
#include "docbuilder.h"
#include "resources/utils/utils.h"
using namespace std;
using namespace NSDoctRenderer;
const wchar_t* workDir = L"C:\\Program Files\\ONLYOFFICE\\DocumentBuilder";
const wchar_t* resultPath = L"result.xlsx";
// Helper functions
void CheckCell(CValue oWorksheet, wstring cell, int row, int col)
{
if (cell.find('#') != std::wstring::npos)
{
wstring commentMsg = L"Error: " + cell;
CValue errorCell = oWorksheet.Call("GetRangeByNumber", row, col);
errorCell.Call("AddComment", commentMsg.c_str());
}
}
// Main function
int main()
{
// Init DocBuilder
CDocBuilder::Initialize(workDir);
CDocBuilder oBuilder;
oBuilder.SetProperty("--work-directory", workDir);
// Open file and get context
wstring templatePath = NSUtils::GetResourcesDirectory() + L"/docs/spreadsheet_with_errors.xlsx";
oBuilder.OpenFile(templatePath.c_str(), L"");
CContext oContext = oBuilder.GetContext();
CContextScope oScope = oContext.CreateScope();
CValue oGlobal = oContext.GetGlobal();
CValue oApi = oGlobal["Api"];
// Find and comment formula errors
CValue oWorksheet = oApi.Call("GetActiveSheet");
CValue oRange = oWorksheet.Call("GetUsedRange");
CValue data = oRange.Call("GetValue");
for (int row = 0; row < (int)data.GetLength(); row++)
{
for (int col = 0; col < (int)data[0].GetLength(); col++)
{
CheckCell(oWorksheet, data[row][col].ToString().c_str(), row, col);
}
}
// Save and close
oBuilder.SaveFile(OFFICESTUDIO_FILE_SPREADSHEET_XLSX, resultPath);
oBuilder.CloseFile();
CDocBuilder::Dispose();
return 0;
}

View File

@ -0,0 +1,206 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <string>
#include "common.h"
#include "docbuilder.h"
using namespace std;
using namespace NSDoctRenderer;
const wchar_t* workDir = L"C:\\Program Files\\ONLYOFFICE\\DocumentBuilder";
const wchar_t* resultPath = L"result.docx";
// Helper functions
string cValueToString(CValue value)
{
wchar_t* txt = value.ToString().c_str();
wstring ws(txt);
string str(ws.begin(), ws.end());
return str;
}
void setTableBorders(CValue oTable, int borderColor)
{
oTable.Call("SetTableBorderTop", "single", 4, 0, borderColor, borderColor, borderColor);
oTable.Call("SetTableBorderBottom", "single", 4, 0, borderColor, borderColor, borderColor);
oTable.Call("SetTableBorderLeft", "single", 4, 0, borderColor, borderColor, borderColor);
oTable.Call("SetTableBorderRight", "single", 4, 0, borderColor, borderColor, borderColor);
oTable.Call("SetTableBorderInsideV", "single", 4, 0, borderColor, borderColor, borderColor);
oTable.Call("SetTableBorderInsideH", "single", 4, 0, borderColor, borderColor, borderColor);
}
CValue createFullWidthTable(CValue oApi, int rows, int cols, int borderColor)
{
CValue oTable = oApi.Call("CreateTable", cols, rows);
oTable.Call("SetWidth", "percent", 100);
setTableBorders(oTable, borderColor);
return oTable;
}
CValue getTableCellParagraph(CValue oTable, int row, int col)
{
return oTable.Call("GetCell", row, col).Call("GetContent").Call("GetElement", 0);
}
void addTextToParagraph(CValue oParagraph, std::string text, int fontSize, bool isBold)
{
oParagraph.Call("AddText", text.c_str());
oParagraph.Call("SetFontSize", fontSize);
oParagraph.Call("SetBold", isBold);
}
void setPictureFormProperties(CValue oPictureForm, std::string key, std::string tip, bool required, std::string placeholder, std::string scaleFlag, bool lockAspectRatio, bool respectBorders, int shiftX, int shiftY, std::string imageUrl)
{
oPictureForm.Call("SetFormKey", key.c_str());
oPictureForm.Call("SetTipText", tip.c_str());
oPictureForm.Call("SetRequired", required);
oPictureForm.Call("SetPlaceholderText", placeholder.c_str());
oPictureForm.Call("SetScaleFlag", scaleFlag.c_str());
oPictureForm.Call("SetLockAspectRatio", lockAspectRatio);
oPictureForm.Call("SetRespectBorders", respectBorders);
oPictureForm.Call("SetPicturePosition", shiftX, shiftY);
oPictureForm.Call("SetImage", imageUrl.c_str());
}
void setTextFormProperties(CValue oTextForm, string key, string tip, bool required, string placeholder, bool comb, int maxCharacters, int cellWidth, bool multiLine, bool autoFit)
{
oTextForm.Call("SetFormKey", key.c_str());
oTextForm.Call("SetTipText", tip.c_str());
oTextForm.Call("SetRequired", required);
oTextForm.Call("SetPlaceholderText", placeholder.c_str());
oTextForm.Call("SetComb", comb);
oTextForm.Call("SetCharactersLimit", maxCharacters);
oTextForm.Call("SetCellWidth", cellWidth);
oTextForm.Call("SetCellWidth", multiLine);
oTextForm.Call("SetMultiline", autoFit);
}
void addTextFormToParagraph(CValue oParagraph, CValue oTextForm, int fontSize, string jc, bool hasBorder, int borderColor)
{
if (hasBorder)
{
oTextForm.Call("SetBorderColor", borderColor, borderColor, borderColor);
}
oParagraph.Call("AddElement", oTextForm);
oParagraph.Call("SetFontSize", fontSize);
oParagraph.Call("SetJc", jc.c_str());
}
// Main function
int main()
{
// Init DocBuilder
CDocBuilder::Initialize(workDir);
CDocBuilder oBuilder;
oBuilder.SetProperty("--work-directory", workDir);
oBuilder.CreateFile(OFFICESTUDIO_FILE_DOCUMENT_DOCX);
CContext oContext = oBuilder.GetContext();
CContextScope oScope = oContext.CreateScope();
CValue oGlobal = oContext.GetGlobal();
CValue oApi = oGlobal["Api"];
// Create advanced form
CValue oDocument = oApi.Call("GetDocument");
CValue oTable = createFullWidthTable(oApi, 1, 2, 255);
CValue oParagraph = getTableCellParagraph(oTable, 0, 0);
addTextToParagraph(oParagraph, "PURCHASE ORDER", 36, true);
oParagraph = getTableCellParagraph(oTable, 0, 1);
addTextToParagraph(oParagraph, "Serial # ", 25, true);
CValue oTextForm = oApi.Call("CreateTextForm");
setTextFormProperties(oTextForm, "Serial", "Enter serial number", false, "Serial", true, 6, 1, false, false);
addTextFormToParagraph(oParagraph, oTextForm, 25, "left", true, 255);
oDocument.Call("Push", oTable);
CValue oPictureForm = oApi.Call("CreatePictureForm");
setPictureFormProperties(oPictureForm, "Photo", "Upload company logo", false, "Photo", "tooBig", false, false, 0, 0, "https://api.onlyoffice.com/content/img/docbuilder/examples/user-profile.png");
oParagraph = oApi.Call("CreateParagraph");
oParagraph.Call("AddElement", oPictureForm);
oDocument.Call("Push", oParagraph);
oTextForm = oApi.Call("CreateTextForm");
setTextFormProperties(oTextForm, "Company Name", "Enter company name", false, "Company Name", true, 20, 1, false, false);
oParagraph = oApi.Call("CreateParagraph");
addTextFormToParagraph(oParagraph, oTextForm, 35, "left", false, 255);
oDocument.Call("Push", oParagraph);
oParagraph = oApi.Call("CreateParagraph");
addTextToParagraph(oParagraph, "Date: ", 25, true);
oTextForm = oApi.Call("CreateTextForm");
setTextFormProperties(oTextForm, "Date", "Date", false, "DD.MM.YYYY", true, 10, 1, false, false);
addTextFormToParagraph(oParagraph, oTextForm, 25, "left", true, 255);
oDocument.Call("Push", oParagraph);
oParagraph = oApi.Call("CreateParagraph");
addTextToParagraph(oParagraph, "To:", 35, true);
oDocument.Call("Push", oParagraph);
oTable = createFullWidthTable(oApi, 1, 1, 200);
oParagraph = getTableCellParagraph(oTable, 0, 0);
oTextForm = oApi.Call("CreateTextForm");
setTextFormProperties(oTextForm, "Recipient", "Recipient", false, "Recipient", true, 25, 1, false, false);
addTextFormToParagraph(oParagraph, oTextForm, 32, "left", false, 255);
oDocument.Call("Push", oTable);
oTable = createFullWidthTable(oApi, 10, 2, 200);
oTable.Call("GetRow", 0).Call("SetBackgroundColor", 245, 245, 245, false);
CValue oCell = oTable.Call("GetCell", 0, 0);
oCell.Call("SetWidth", "percent", 30);
oParagraph = getTableCellParagraph(oTable, 0, 0);
addTextToParagraph(oParagraph, "Qty.", 30, true);
oParagraph = getTableCellParagraph(oTable, 0, 1);
addTextToParagraph(oParagraph, "Description", 30, true);
for (int i = 1; i < 10; i++)
{
CValue oTempParagraph = getTableCellParagraph(oTable, i, 0);
CValue oTempTextForm = oApi.Call("CreateTextForm");
setTextFormProperties(oTempTextForm, "Qty" + std::to_string(i), "Qty" + std::to_string(i), false, " ", true, 9, 1, false, false);
addTextFormToParagraph(oTempParagraph, oTempTextForm, 30, "left", false, 255);
oTempParagraph = getTableCellParagraph(oTable, i, 1);
oTempTextForm = oApi.Call("CreateTextForm");
setTextFormProperties(oTempTextForm, "Description" + std::to_string(i), "Description" + std::to_string(i), false, " ", true, 22, 1, false, false);
addTextFormToParagraph(oTempParagraph, oTempTextForm, 30, "left", false, 255);
}
oDocument.Call("Push", oTable);
oDocument.Call("RemoveElement", 0);
oDocument.Call("RemoveElement", 1);
// Save and close
oBuilder.SaveFile(OFFICESTUDIO_FILE_DOCUMENT_DOCX, resultPath);
oBuilder.CloseFile();
CDocBuilder::Dispose();
return 0;
}

View File

@ -0,0 +1,108 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <string>
#include "common.h"
#include "docbuilder.h"
using namespace NSDoctRenderer;
const wchar_t* workDir = L"C:\\Program Files\\ONLYOFFICE\\DocumentBuilder";
const wchar_t* resultPath = L"result.docx";
// Helper functions
void setPictureFormProperties(CValue oPictureForm, std::string key, std::string tip, bool required, std::string placeholder, std::string scaleFlag, bool lockAspectRatio, bool respectBorders, int shiftX, int shiftY, std::string imageUrl)
{
oPictureForm.Call("SetFormKey", key.c_str());
oPictureForm.Call("SetTipText", tip.c_str());
oPictureForm.Call("SetRequired", required);
oPictureForm.Call("SetPlaceholderText", placeholder.c_str());
oPictureForm.Call("SetScaleFlag", scaleFlag.c_str());
oPictureForm.Call("SetLockAspectRatio", lockAspectRatio);
oPictureForm.Call("SetRespectBorders", respectBorders);
oPictureForm.Call("SetPicturePosition", shiftX, shiftY);
oPictureForm.Call("SetImage", imageUrl.c_str());
}
void setTextFormProperties(CValue oTextForm, std::string key, std::string tip, bool required, std::string placeholder, bool comb, int maxCharacters, int cellWidth, bool multiLine, bool autoFit)
{
oTextForm.Call("SetFormKey", key.c_str());
oTextForm.Call("SetTipText", tip.c_str());
oTextForm.Call("SetRequired", required);
oTextForm.Call("SetPlaceholderText", placeholder.c_str());
oTextForm.Call("SetComb", comb);
oTextForm.Call("SetCharactersLimit", maxCharacters);
oTextForm.Call("SetCellWidth", cellWidth);
oTextForm.Call("SetCellWidth", multiLine);
oTextForm.Call("SetMultiline", autoFit);
}
// Main function
int main()
{
// Init DocBuilder
CDocBuilder::Initialize(workDir);
CDocBuilder oBuilder;
oBuilder.SetProperty("--work-directory", workDir);
oBuilder.CreateFile(OFFICESTUDIO_FILE_DOCUMENT_DOCX);
CContext oContext = oBuilder.GetContext();
CContextScope oScope = oContext.CreateScope();
CValue oGlobal = oContext.GetGlobal();
CValue oApi = oGlobal["Api"];
// Create basic form
CValue oDocument = oApi.Call("GetDocument");
CValue oParagraph = oDocument.Call("GetElement", 0);
CValue oHeadingStyle = oDocument.Call("GetStyle", "Heading 3");
oParagraph.Call("AddText", "Employee pass card");
oParagraph.Call("SetStyle", oHeadingStyle);
oDocument.Call("Push", oParagraph);
CValue oPictureForm = oApi.Call("CreatePictureForm");
setPictureFormProperties(oPictureForm, "Photo", "Upload your photo", false, "Photo", "tooBig", true, false, 50, 50, "https://api.onlyoffice.com/content/img/docbuilder/examples/user-profile.png");
oParagraph = oApi.Call("CreateParagraph");
oParagraph.Call("AddElement", oPictureForm);
oDocument.Call("Push", oParagraph);
CValue oTextForm = oApi.Call("CreateTextForm");
setTextFormProperties(oTextForm, "First name", "Enter your first name", false, "First name", true, 13, 3, false, false);
oParagraph = oApi.Call("CreateParagraph");
oParagraph.Call("AddElement", oTextForm);
oDocument.Call("Push", oParagraph);
// Save and close
oBuilder.SaveFile(OFFICESTUDIO_FILE_DOCUMENT_DOCX, resultPath);
oBuilder.CloseFile();
CDocBuilder::Dispose();
return 0;
}

View File

@ -0,0 +1,156 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <string>
#include <vector>
#include "common.h"
#include "docbuilder.h"
#include "resources/utils/utils.h"
using namespace std;
using namespace NSDoctRenderer;
const wchar_t* workDir = L"C:\\Program Files\\ONLYOFFICE\\DocumentBuilder";
const wchar_t* resultPath = L"result.pptx";
void addText(CValue oApi, int fontSize, string text, CValue oSlide, CValue oShape, CValue oParagraph, CValue oFill, string jc)
{
CValue oRun = oApi.Call("CreateRun");
CValue oTextPr = oRun.Call("GetTextPr");
oTextPr.Call("SetFontSize", fontSize);
oTextPr.Call("SetFill", oFill);
oTextPr.Call("SetFontFamily", "Tahoma");
oParagraph.Call("SetJc", jc.c_str());
oRun.Call("AddText", text.c_str());
oRun.Call("AddLineBreak");
oParagraph.Call("AddElement", oRun);
oSlide.Call("AddObject", oShape);
}
// Main function
int main()
{
// Init DocBuilder
CDocBuilder::Initialize(workDir);
CDocBuilder oBuilder;
oBuilder.SetProperty("--work-directory", workDir);
// Read chart data from xlsx
wstring templatePath = NSUtils::GetResourcesDirectory() + L"/docs/chart_data.xlsx";
oBuilder.OpenFile(templatePath.c_str(), L"");
CContext oContext = oBuilder.GetContext();
CContextScope oScope = oContext.CreateScope();
CValue oGlobal = oContext.GetGlobal();
CValue oApi = oGlobal["Api"];
CValue oWorksheet = oApi.Call("GetActiveSheet");
CValue values = oWorksheet.Call("GetUsedRange").Call("GetValue");
int sizeX = values.GetLength();
int sizeY = values[0].GetLength();
vector<vector<wstring>> data(sizeX, vector<wstring>(sizeY));
for (int i = 0; i < sizeX; i++)
{
for (int j = 0; j < sizeY; j++)
{
data[i][j] = values[i][j].ToString().c_str();
}
}
oBuilder.CloseFile();
// Create chart presentation
oBuilder.CreateFile(OFFICESTUDIO_FILE_PRESENTATION_PPTX);
oContext = oBuilder.GetContext();
oScope = oContext.CreateScope();
oGlobal = oContext.GetGlobal();
oApi = oGlobal["Api"];
CValue oPresentation = oApi.Call("GetPresentation");
CValue oSlide = oPresentation.Call("GetSlideByIndex", 0);
oSlide.Call("RemoveAllObjects");
CValue oRGBColor = oApi.Call("CreateRGBColor", 255, 244, 240);
CValue oFill = oApi.Call("CreateSolidFill", oRGBColor);
oSlide.Call("SetBackground", oFill);
CValue oStroke = oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill"));
CValue oShapeTitle = oApi.Call("CreateShape", "rect", 300 * 36000, 20 * 36000, oApi.Call("CreateNoFill"), oStroke);
CValue oShapeText = oApi.Call("CreateShape", "rect", 120 * 36000, 80 * 36000, oApi.Call("CreateNoFill"), oStroke);
oShapeTitle.Call("SetPosition", 20 * 36000, 20 * 36000);
oShapeText.Call("SetPosition", 210 * 36000, 50 * 36000);
CValue oParagraphTitle = oShapeTitle.Call("GetDocContent").Call("GetElement", 0);
CValue oParagraphText = oShapeText.Call("GetDocContent").Call("GetElement", 0);
oRGBColor = oApi.Call("CreateRGBColor", 115, 81, 68);
oFill = oApi.Call("CreateSolidFill", oRGBColor);
string titleContent = "Price Type Report";
string textContent = "This is an overview of price types. As we can see, May was the price peak, but even in June the price went down, the annual upward trend persists.";
addText(oApi, 80, titleContent, oSlide, oShapeTitle, oParagraphTitle, oFill, "center");
addText(oApi, 42, textContent, oSlide, oShapeText, oParagraphText, oFill, "left");
// Transform 2d array into cols names, rows names and data
CValue cols = oContext.CreateArray(sizeY - 1);
for (int col = 1; col < sizeY; col++)
{
cols[col - 1] = data[0][col].c_str();
}
CValue rows = oContext.CreateArray(sizeX - 1);
for (int row = 1; row < sizeX; row++)
{
rows[row - 1] = data[row][0].c_str();
}
CValue vals = oContext.CreateArray(sizeY - 1);
for (int row = 1; row < sizeY; row++)
{
CValue row_data = oContext.CreateArray(sizeX - 1);
for (int col = 1; col < sizeX; col++)
{
row_data[col - 1] = data[col][row].c_str();
}
vals[row - 1] = row_data;
}
// Pass CValue data to the CreateChart method
CValue oChart = oApi.Call("CreateChart", "lineStacked", vals, cols, rows);
oChart.Call("SetSize", 180 * 36000, 100 * 36000);
oChart.Call("SetPosition", 20 * 36000, 50 * 36000);
oChart.Call("ApplyChartStyle", 24);
oChart.Call("SetLegendFontSize", 12);
oChart.Call("SetLegendPos", "top");
oSlide.Call("AddObject", oChart);
// Save and close
oBuilder.SaveFile(OFFICESTUDIO_FILE_PRESENTATION_PPTX, resultPath);
oBuilder.CloseFile();
CDocBuilder::Dispose();
return 0;
}

View File

@ -0,0 +1,156 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <map>
#include <string>
#include "common.h"
#include "docbuilder.h"
using namespace std;
using namespace NSDoctRenderer;
const wchar_t* workDir = L"C:\\Program Files\\ONLYOFFICE\\DocumentBuilder";
const wchar_t* resultPath = L"result.pptx";
// Helper functions
CValue createImageSlide(CValue oApi, CValue oPresentation, string image_url)
{
CValue oSlide = oApi.Call("CreateSlide");
oPresentation.Call("AddSlide", oSlide);
CValue oFill = oApi.Call("CreateBlipFill", image_url.c_str(), "stretch");
oSlide.Call("SetBackground", oFill);
oSlide.Call("RemoveAllObjects");
return oSlide;
}
void addTextToSlideShape(CValue oApi, CValue oContent, string text, int fontSize, bool isBold, string js)
{
CValue oParagraph = oApi.Call("CreateParagraph");
oParagraph.Call("SetSpacingBefore", 0);
oParagraph.Call("SetSpacingAfter", 0);
oContent.Call("Push", oParagraph);
CValue oRun = oParagraph.Call("AddText", text.c_str());
oRun.Call("SetFill", oApi.Call("CreateSolidFill", oApi.Call("CreateRGBColor", 0xff, 0xff, 0xff)));
oRun.Call("SetFontSize", fontSize);
oRun.Call("SetFontFamily", "Georgia");
oRun.Call("SetBold", isBold);
oParagraph.Call("SetJc", js.c_str());
}
// Main function
int main()
{
map<string, string>slideImages;
slideImages["gun"] = "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_gun.png";
slideImages["axe"] = "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_axe.png";
slideImages["knight"] = "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_knight.png";
slideImages["sky"] = "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_sky.png";
// Init DocBuilder
CDocBuilder::Initialize(workDir);
CDocBuilder oBuilder;
oBuilder.SetProperty("--work-directory", workDir);
oBuilder.CreateFile(OFFICESTUDIO_FILE_PRESENTATION_PPTX);
CContext oContext = oBuilder.GetContext();
CContextScope oScope = oContext.CreateScope();
CValue oGlobal = oContext.GetGlobal();
CValue oApi = oGlobal["Api"];
// Create presentation
CValue oPresentation = oApi.Call("GetPresentation");
oPresentation.Call("SetSizes", 9144000, 6858000);
CValue oSlide = createImageSlide(oApi, oPresentation, slideImages["gun"]);
oPresentation.Call("GetSlideByIndex", 0).Call("Delete");
CValue oShape = oApi.Call("CreateShape", "rect", 8056800, 3020400, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
oShape.Call("SetPosition", 608400, 1267200);
CValue oContent = oShape.Call("GetDocContent");
oContent.Call("RemoveAllElements");
addTextToSlideShape(oApi, oContent, "How They", 160, true, "left");
addTextToSlideShape(oApi, oContent, "Throw Out", 132, false, "left");
addTextToSlideShape(oApi, oContent, "a Challenge", 132, false, "left");
oSlide.Call("AddObject", oShape);
oSlide = createImageSlide(oApi, oPresentation, slideImages["axe"]);
oShape = oApi.Call("CreateShape", "rect", 6904800, 1724400, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
oShape.Call("SetPosition", 1764000, 1191600);
oContent = oShape.Call("GetDocContent");
oContent.Call("RemoveAllElements");
addTextToSlideShape(oApi, oContent, "American Indians ", 110, true, "right");
addTextToSlideShape(oApi, oContent, "(XVII century)", 94, false, "right");
oSlide.Call("AddObject", oShape);
oShape = oApi.Call("CreateShape", "rect", 4986000, 2419200, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
oShape.Call("SetPosition", 3834000, 3888000);
oContent = oShape.Call("GetDocContent");
oContent.Call("RemoveAllElements");
addTextToSlideShape(oApi, oContent, "put a tomahawk on the ground in the ", 84, false, "right");
addTextToSlideShape(oApi, oContent, "rival's camp", 84, false, "right");
oSlide.Call("AddObject", oShape);
oSlide = createImageSlide(oApi, oPresentation, slideImages["knight"]);
oShape = oApi.Call("CreateShape", "rect", 6904800, 1724400, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
oShape.Call("SetPosition", 1764000, 1191600);
oContent = oShape.Call("GetDocContent");
oContent.Call("RemoveAllElements");
addTextToSlideShape(oApi, oContent, "European Knights", 110, true, "right");
addTextToSlideShape(oApi, oContent, " (XII-XVI centuries)", 94, false, "right");
oSlide.Call("AddObject", oShape);
oShape = oApi.Call("CreateShape", "rect", 4986000, 2419200, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
oShape.Call("SetPosition", 3834000, 3888000);
oContent = oShape.Call("GetDocContent");
oContent.Call("RemoveAllElements");
addTextToSlideShape(oApi, oContent, "threw a glove", 84, false, "right");
addTextToSlideShape(oApi, oContent, "in the rival's face", 84, false, "right");
oSlide.Call("AddObject", oShape);
oSlide = createImageSlide(oApi, oPresentation, slideImages["sky"]);
oShape = oApi.Call("CreateShape", "rect", 7887600, 3063600, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
oShape.Call("SetPosition", 630000, 1357200);
oContent = oShape.Call("GetDocContent");
oContent.Call("RemoveAllElements");
addTextToSlideShape(oApi, oContent, "OnlyOffice", 176, false, "center");
addTextToSlideShape(oApi, oContent, "stands for Peace", 132, false, "center");
oSlide.Call("AddObject", oShape);
// Save and close
oBuilder.SaveFile(OFFICESTUDIO_FILE_PRESENTATION_PPTX, resultPath);
oBuilder.CloseFile();
CDocBuilder::Dispose();
return 0;
}

View File

@ -0,0 +1,94 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <map>
#include <string>
#include "common.h"
#include "docbuilder.h"
#include "resources/utils/utils.h"
using namespace std;
using namespace NSDoctRenderer;
const wchar_t* workDir = L"C:\\Program Files\\ONLYOFFICE\\DocumentBuilder";
const wchar_t* resultPath = L"result.docx";
// Main function
int main()
{
std::map<wstring, wstring> formData;
formData[L"Photo"] = L"https://api.onlyoffice.com/content/img/docbuilder/examples/blue_cloud.png";
formData[L"Serial"] = L"A1345";
formData[L"Company Name"] = L"Blue Cloud";
formData[L"Date"] = L"25.12.2023";
formData[L"Recipient"] = L"Space Corporation";
formData[L"Qty1"] = L"25";
formData[L"Description1"] = L"Frame";
formData[L"Qty2"] = L"2";
formData[L"Description2"] = L"Stack";
formData[L"Qty3"] = L"34";
formData[L"Description3"] = L"Shifter";
// Init DocBuilder
CDocBuilder::Initialize(workDir);
CDocBuilder oBuilder;
oBuilder.SetProperty("--work-directory", workDir);
wstring templatePath = NSUtils::GetResourcesDirectory() + L"/docs/form.docx";
oBuilder.OpenFile(templatePath.c_str(), L"");
CContext oContext = oBuilder.GetContext();
CContextScope oScope = oContext.CreateScope();
CValue oGlobal = oContext.GetGlobal();
CValue oApi = oGlobal["Api"];
// Fill form
CValue oDocument = oApi.Call("GetDocument");
CValue aForms = oDocument.Call("GetAllForms");
int formNum = 0;
while (formNum < (int)aForms.GetLength())
{
CValue form = aForms[formNum];
wstring type = aForms[formNum].Call("GetFormType").ToString().c_str();
wstring value = formData[aForms[formNum].Call("GetFormKey").ToString().c_str()];
if (type == L"textForm") form.Call("SetText", value.c_str());
if (type == L"pictureForm") form.Call("SetImage", value.c_str());
formNum++;
}
// Save and close
oBuilder.SaveFile(OFFICESTUDIO_FILE_DOCUMENT_DOCX, resultPath);
oBuilder.CloseFile();
CDocBuilder::Dispose();
return 0;
}

View File

@ -0,0 +1,100 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <string>
#include "common.h"
#include "docbuilder.h"
using namespace std;
using namespace NSDoctRenderer;
const wchar_t* workDir = L"C:\\Program Files\\ONLYOFFICE\\DocumentBuilder";
const wchar_t* resultPath = L"result.xlsx";
// Main function
int main()
{
string data[9][4] = {
{ "Id", "Product", "Price", "Available" },
{ "1001", "Item A", "12.2", "true" },
{ "1002", "Item B", "18.8", "true" },
{ "1003", "Item C", "70.1", "false" },
{ "1004", "Item D", "60.6", "true" },
{ "1005", "Item E", "32.6", "true" },
{ "1006", "Item F", "28.3", "false" },
{ "1007", "Item G", "11.1", "false" },
{ "1008", "Item H", "41.4", "true" }
};
// Init DocBuilder
CDocBuilder::Initialize(workDir);
CDocBuilder oBuilder;
oBuilder.SetProperty("--work-directory", workDir);
oBuilder.CreateFile(OFFICESTUDIO_FILE_SPREADSHEET_XLSX);
CContext oContext = oBuilder.GetContext();
CContextScope oScope = oContext.CreateScope();
CValue oGlobal = oContext.GetGlobal();
CValue oApi = oGlobal["Api"];
// Find and comment formula errors
CValue oWorksheet = oApi.Call("GetActiveSheet");
// Create CValue array from data
int rowsLen = sizeof data / sizeof data[0];
int colsLen = sizeof data[0] / sizeof(string);
CValue oArray = oContext.CreateArray(rowsLen);
for (int row = 0; row < rowsLen; row++)
{
CValue oArrayCol = oContext.CreateArray(colsLen);
for (int col = 0; col < colsLen; col++)
{
oArrayCol[col] = data[row][col].c_str();
}
oArray[row] = oArrayCol;
}
// First cell in the range (A1) is equal to (0,0)
CValue startCell = oWorksheet.Call("GetRangeByNumber", 0, 0);
// Last cell in the range is equal to array length -1
CValue endCell = oWorksheet.Call("GetRangeByNumber", oArray.GetLength() - 1, oArray[0].GetLength() - 1);
oWorksheet.Call("GetRange", startCell, endCell).Call("SetValue", oArray);
// Save and close
oBuilder.SaveFile(OFFICESTUDIO_FILE_SPREADSHEET_XLSX, resultPath);
oBuilder.CloseFile();
CDocBuilder::Dispose();
return 0;
}

View File

@ -0,0 +1,98 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using docbuilder_net;
using OfficeFileTypes = docbuilder_net.FileTypes;
using CValue = docbuilder_net.CDocBuilderValue;
using CContext = docbuilder_net.CDocBuilderContext;
using CContextScope = docbuilder_net.CDocBuilderContextScope;
namespace Sample
{
public class CommentingErrors
{
public static void Main(string[] args)
{
string workDirectory = "C:/Program Files/ONLYOFFICE/DocumentBuilder";
string resultPath = "../../../result.xlsx";
string filePath = "../../../../../../resources/docs/spreadsheet_with_errors.xlsx";
// add Docbuilder dlls in path
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + workDirectory);
CommentErrors(workDirectory, resultPath, filePath);
}
public static void CommentErrors(string workDirectory, string resultPath, string filePath)
{
var doctype = (int)OfficeFileTypes.Spreadsheet.XLSX;
// Init DocBuilder
CDocBuilder.Initialize(workDirectory);
CDocBuilder oBuilder = new CDocBuilder();
oBuilder.OpenFile(filePath, "xlsx");
CContext oContext = oBuilder.GetContext();
CContextScope oScope = oContext.CreateScope();
CValue oGlobal = oContext.GetGlobal();
CValue oApi = oGlobal["Api"];
// Find and comment formula errors
CValue oWorksheet = oApi.Call("GetActiveSheet");
CValue oRange = oWorksheet.Call("GetUsedRange");
var data = oRange.Call("GetValue");
for (int row = 0; row < data.GetLength(); row++)
{
for (int col = 0; col < data[0].GetLength(); col++)
{
CheckCell(oWorksheet, data[row][col].ToString(), row, col);
}
}
// Save file and close DocBuilder
oBuilder.SaveFile(doctype, resultPath);
oBuilder.CloseFile();
CDocBuilder.Destroy();
}
public static void CheckCell(CValue oWorksheet, string cell, int row, int col)
{
if (cell.Contains("#"))
{
string comment = "Error" + cell;
CValue errorCell = oWorksheet.Call("GetRangeByNumber", row, col);
errorCell.Call("AddComment", comment);
}
}
}
}

View File

@ -0,0 +1,212 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using docbuilder_net;
using OfficeFileTypes = docbuilder_net.FileTypes;
using CValue = docbuilder_net.CDocBuilderValue;
using CContext = docbuilder_net.CDocBuilderContext;
using CContextScope = docbuilder_net.CDocBuilderContextScope;
namespace Sample
{
public class CreatingAdvancedForm
{
public static void Main(string[] args)
{
string workDirectory = "C:/Program Files/ONLYOFFICE/DocumentBuilder";
string resultPath = "../../../result.docx";
// add Docbuilder dlls in path
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + workDirectory);
CreateAdvancedForm(workDirectory, resultPath);
}
public static void CreateAdvancedForm(string workDirectory, string resultPath)
{
var doctype = (int)OfficeFileTypes.Document.DOCX;
// Init DocBuilder
CDocBuilder.Initialize(workDirectory);
CDocBuilder oBuilder = new CDocBuilder();
oBuilder.CreateFile(doctype);
CContext oContext = oBuilder.GetContext();
CContextScope oScope = oContext.CreateScope();
CValue oGlobal = oContext.GetGlobal();
CValue oApi = oGlobal["Api"];
// Create advanced form
CValue oDocument = oApi.Call("GetDocument");
CValue oTable = createFullWidthTable(oApi, 1, 2, 255);
CValue oParagraph = getTableCellParagraph(oTable, 0, 0);
addTextToParagraph(oParagraph, "PURCHASE ORDER", 36, true);
oParagraph = getTableCellParagraph(oTable, 0, 1);
addTextToParagraph(oParagraph, "Serial # ", 25, true);
CValue oTextForm = oApi.Call("CreateTextForm");
setTextFormProperties(oTextForm, "Serial", "Enter serial number", false, "Serial", true, 6, 1, false, false);
addTextFormToParagraph(oParagraph, oTextForm, 25, "left", true, 255);
oDocument.Call("Push", oTable);
CValue oPictureForm = oApi.Call("CreatePictureForm");
setPictureFormProperties(oPictureForm, "Photo", "Upload company logo", false, "Photo", "tooBig", false, false, 0, 0, "https://api.onlyoffice.com/content/img/docbuilder/examples/user-profile.png");
oParagraph = oApi.Call("CreateParagraph");
oParagraph.Call("AddElement", oPictureForm);
oDocument.Call("Push", oParagraph);
oTextForm = oApi.Call("CreateTextForm");
setTextFormProperties(oTextForm, "Company Name", "Enter company name", false, "Company Name", true, 20, 1, false, false);
oParagraph = oApi.Call("CreateParagraph");
addTextFormToParagraph(oParagraph, oTextForm, 35, "left", false, 255);
oDocument.Call("Push", oParagraph);
oParagraph = oApi.Call("CreateParagraph");
addTextToParagraph(oParagraph, "Date: ", 25, true);
oTextForm = oApi.Call("CreateTextForm");
setTextFormProperties(oTextForm, "Date", "Date", false, "DD.MM.YYYY", true, 10, 1, false, false);
addTextFormToParagraph(oParagraph, oTextForm, 25, "left", true, 255);
oDocument.Call("Push", oParagraph);
oParagraph = oApi.Call("CreateParagraph");
addTextToParagraph(oParagraph, "To:", 35, true);
oDocument.Call("Push", oParagraph);
oTable = createFullWidthTable(oApi, 1, 1, 200);
oParagraph = getTableCellParagraph(oTable, 0, 0);
oTextForm = oApi.Call("CreateTextForm");
setTextFormProperties(oTextForm, "Recipient", "Recipient", false, "Recipient", true, 25, 1, false, false);
addTextFormToParagraph(oParagraph, oTextForm, 32, "left", false, 255);
oDocument.Call("Push", oTable);
oTable = createFullWidthTable(oApi, 10, 2, 200);
oTable.Call("GetRow", 0).Call("SetBackgroundColor", 245, 245, 245, false);
CValue oCell = oTable.Call("GetCell", 0, 0);
oCell.Call("SetWidth", "percent", 30);
oParagraph = getTableCellParagraph(oTable, 0, 0);
addTextToParagraph(oParagraph, "Qty.", 30, true);
oParagraph = getTableCellParagraph(oTable, 0, 1);
addTextToParagraph(oParagraph, "Description", 30, true);
for (var i = 1; i < 10; i++)
{
CValue oTempParagraph = getTableCellParagraph(oTable, i, 0);
CValue oTempTextForm = oApi.Call("CreateTextForm");
setTextFormProperties(oTempTextForm, "Qty" + i, "Qty" + i, false, " ", true, 9, 1, false, false);
addTextFormToParagraph(oTempParagraph, oTempTextForm, 30, "left", false, 255);
oTempParagraph = getTableCellParagraph(oTable, i, 1);
oTempTextForm = oApi.Call("CreateTextForm");
setTextFormProperties(oTempTextForm, "Description" + i, "Description" + i, false, " ", true, 22, 1, false, false);
addTextFormToParagraph(oTempParagraph, oTempTextForm, 30, "left", false, 255);
}
oDocument.Call("Push", oTable);
oDocument.Call("RemoveElement", 0);
oDocument.Call("RemoveElement", 1);
// Save file and close DocBuilder
oBuilder.SaveFile(doctype, resultPath);
oBuilder.CloseFile();
CDocBuilder.Destroy();
}
public static CValue createFullWidthTable(CValue oApi, int rows, int cols, int borderColor)
{
CValue oTable = oApi.Call("CreateTable", cols, rows);
oTable.Call("SetWidth", "percent", 100);
setTableBorders(oTable, borderColor);
return oTable;
}
public static void setTableBorders(CValue oTable, int borderColor)
{
oTable.Call("SetTableBorderTop", "single", 4, 0, borderColor, borderColor, borderColor);
oTable.Call("SetTableBorderBottom", "single", 4, 0, borderColor, borderColor, borderColor);
oTable.Call("SetTableBorderLeft", "single", 4, 0, borderColor, borderColor, borderColor);
oTable.Call("SetTableBorderRight", "single", 4, 0, borderColor, borderColor, borderColor);
oTable.Call("SetTableBorderInsideV", "single", 4, 0, borderColor, borderColor, borderColor);
oTable.Call("SetTableBorderInsideH", "single", 4, 0, borderColor, borderColor, borderColor);
}
public static CValue getTableCellParagraph(CValue oTable, int row, int col)
{
return oTable.Call("GetCell", row, col).Call("GetContent").Call("GetElement", 0);
}
public static void addTextToParagraph(CValue oParagraph, string text, int fontSize, bool isBold)
{
oParagraph.Call("AddText", text);
oParagraph.Call("SetFontSize", fontSize);
oParagraph.Call("SetBold", isBold);
}
public static void setPictureFormProperties(CValue oPictureForm, string key, string tip, bool required, string placeholder, string scaleFlag, bool lockAspectRatio, bool respectBorders, int shiftX, int shiftY, string imageUrl)
{
oPictureForm.Call("SetFormKey", key);
oPictureForm.Call("SetTipText", tip);
oPictureForm.Call("SetRequired", required);
oPictureForm.Call("SetPlaceholderText", placeholder);
oPictureForm.Call("SetScaleFlag", scaleFlag);
oPictureForm.Call("SetLockAspectRatio", lockAspectRatio);
oPictureForm.Call("SetRespectBorders", respectBorders);
oPictureForm.Call("SetPicturePosition", shiftX, shiftY);
oPictureForm.Call("SetImage", imageUrl);
}
public static void setTextFormProperties(CValue oTextForm, string key, string tip, bool required, string placeholder, bool comb, int maxCharacters, int cellWidth, bool multiLine, bool autoFit)
{
oTextForm.Call("SetFormKey", key);
oTextForm.Call("SetTipText", tip);
oTextForm.Call("SetRequired", required);
oTextForm.Call("SetPlaceholderText", placeholder);
oTextForm.Call("SetComb", comb);
oTextForm.Call("SetCharactersLimit", maxCharacters);
oTextForm.Call("SetCellWidth", cellWidth);
oTextForm.Call("SetCellWidth", multiLine);
oTextForm.Call("SetMultiline", autoFit);
}
public static void addTextFormToParagraph(CValue oParagraph, CValue oTextForm, int fontSize, string jc, bool hasBorder, int borderColor)
{
if (hasBorder)
{
oTextForm.Call("SetBorderColor", borderColor, borderColor, borderColor);
}
oParagraph.Call("AddElement", oTextForm);
oParagraph.Call("SetFontSize", fontSize);
oParagraph.Call("SetJc", jc);
}
}
}

View File

@ -0,0 +1,123 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using docbuilder_net;
using OfficeFileTypes = docbuilder_net.FileTypes;
using CValue = docbuilder_net.CDocBuilderValue;
using CContext = docbuilder_net.CDocBuilderContext;
using CContextScope = docbuilder_net.CDocBuilderContextScope;
namespace Sample
{
public class CreatingBasicForm
{
public static void Main(string[] args)
{
string workDirectory = "C:/Program Files/ONLYOFFICE/DocumentBuilder";
string resultPath = "../../../result.docx";
// add Docbuilder dlls in path
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + workDirectory);
CreateBasicForm(workDirectory, resultPath);
}
public static void CreateBasicForm(string workDirectory, string resultPath)
{
var doctype = (int)OfficeFileTypes.Document.DOCX;
// Init DocBuilder
CDocBuilder.Initialize(workDirectory);
CDocBuilder oBuilder = new CDocBuilder();
oBuilder.CreateFile(doctype);
CContext oContext = oBuilder.GetContext();
CContextScope oScope = oContext.CreateScope();
CValue oGlobal = oContext.GetGlobal();
CValue oApi = oGlobal["Api"];
// Create basic form
CValue oDocument = oApi.Call("GetDocument");
CValue oParagraph = oDocument.Call("GetElement", 0);
CValue oHeadingStyle = oDocument.Call("GetStyle", "Heading 3");
oParagraph.Call("AddText", "Employee pass card");
oParagraph.Call("SetStyle", oHeadingStyle);
oDocument.Call("Push", oParagraph);
CValue oPictureForm = oApi.Call("CreatePictureForm");
setPictureFormProperties(oPictureForm, "Photo", "Upload your photo", false, "Photo", "tooBig", true, false, 50, 50, "https://api.onlyoffice.com/content/img/docbuilder/examples/user-profile.png");
oParagraph = oApi.Call("CreateParagraph");
oParagraph.Call("AddElement", oPictureForm);
oDocument.Call("Push", oParagraph);
CValue oTextForm = oApi.Call("CreateTextForm");
setTextFormProperties(oTextForm, "First name", "Enter your first name", false, "First name", true, 13, 3, false, false);
oParagraph = oApi.Call("CreateParagraph");
oParagraph.Call("AddElement", oTextForm);
oDocument.Call("Push", oParagraph);
// Save file and close DocBuilder
oBuilder.SaveFile(doctype, resultPath);
oBuilder.CloseFile();
CDocBuilder.Destroy();
}
public static void setPictureFormProperties(CValue oPictureForm, string key, string tip, bool required, string placeholder, string scaleFlag, bool lockAspectRatio, bool respectBorders, int shiftX, int shiftY, string imageUrl)
{
oPictureForm.Call("SetFormKey", key);
oPictureForm.Call("SetTipText", tip);
oPictureForm.Call("SetRequired", required);
oPictureForm.Call("SetPlaceholderText", placeholder);
oPictureForm.Call("SetScaleFlag", scaleFlag);
oPictureForm.Call("SetLockAspectRatio", lockAspectRatio);
oPictureForm.Call("SetRespectBorders", respectBorders);
oPictureForm.Call("SetPicturePosition", shiftX, shiftY);
oPictureForm.Call("SetImage", imageUrl);
}
public static void setTextFormProperties(CValue oTextForm, string key, string tip, bool required, string placeholder, bool comb, int maxCharacters, int cellWidth, bool multiLine, bool autoFit)
{
oTextForm.Call("SetFormKey", key);
oTextForm.Call("SetTipText", tip);
oTextForm.Call("SetRequired", required);
oTextForm.Call("SetPlaceholderText", placeholder);
oTextForm.Call("SetComb", comb);
oTextForm.Call("SetCharactersLimit", maxCharacters);
oTextForm.Call("SetCellWidth", cellWidth);
oTextForm.Call("SetCellWidth", multiLine);
oTextForm.Call("SetMultiline", autoFit);
}
}
}

View File

@ -0,0 +1,196 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using docbuilder_net;
using OfficeFileTypes = docbuilder_net.FileTypes;
using CValue = docbuilder_net.CDocBuilderValue;
using CContext = docbuilder_net.CDocBuilderContext;
using CContextScope = docbuilder_net.CDocBuilderContextScope;
namespace Sample
{
public class CreatingChartPresentation
{
public static void Main(string[] args)
{
string workDirectory = "C:/Program Files/ONLYOFFICE/DocumentBuilder";
string resultPath = "../../../result.pptx";
string filePath = "../../../../../../resources/docs/chart_data.xlsx";
// add Docbuilder dlls in path
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + workDirectory);
CreateChartPresentation(workDirectory, resultPath, filePath);
}
public static void CreateChartPresentation(string workDirectory, string resultPath, string filePath)
{
var doctype = (int)OfficeFileTypes.Presentation.PPTX;
// Init DocBuilder
CDocBuilder.Initialize(workDirectory);
CDocBuilder oBuilder = new CDocBuilder();
// Read chart data from xlsx
oBuilder.OpenFile(filePath, "xlsx");
CContext oContext = oBuilder.GetContext();
CContextScope oScope = oContext.CreateScope();
CValue oGlobal = oContext.GetGlobal();
CValue oApi = oGlobal["Api"];
CValue oWorksheet = oApi.Call("GetActiveSheet");
CValue oRange = oWorksheet.Call("GetUsedRange").Call("GetValue");
object[,] array = oRangeTo2dArray(oRange, oContext);
oBuilder.CloseFile();
// Create chart presentation
oBuilder.CreateFile(doctype);
oContext = oBuilder.GetContext();
oScope = oContext.CreateScope();
oGlobal = oContext.GetGlobal();
oApi = oGlobal["Api"];
CValue oPresentation = oApi.Call("GetPresentation");
CValue oSlide = oPresentation.Call("GetSlideByIndex", 0);
oSlide.Call("RemoveAllObjects");
CValue oRGBColor = oApi.Call("CreateRGBColor", 255, 244, 240);
CValue oFill = oApi.Call("CreateSolidFill", oRGBColor);
oSlide.Call("SetBackground", oFill);
CValue oStroke = oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill"));
CValue oShapeTitle = oApi.Call("CreateShape", "rect", 300 * 36000, 20 * 36000, oApi.Call("CreateNoFill"), oStroke);
CValue oShapeText = oApi.Call("CreateShape", "rect", 120 * 36000, 80 * 36000, oApi.Call("CreateNoFill"), oStroke);
oShapeTitle.Call("SetPosition", 20 * 36000, 20 * 36000);
oShapeText.Call("SetPosition", 210 * 36000, 50 * 36000);
CValue oParagraphTitle = oShapeTitle.Call("GetDocContent").Call("GetElement", 0);
CValue oParagraphText = oShapeText.Call("GetDocContent").Call("GetElement", 0);
oRGBColor = oApi.Call("CreateRGBColor", 115, 81, 68);
oFill = oApi.Call("CreateSolidFill", oRGBColor);
string titleContent = "Price Type Report";
string textContent = "This is an overview of price types. As we can see, May was the price peak, but even in June the price went down, the annual upward trend persists.";
addText(oApi, 80, titleContent, oSlide, oShapeTitle, oParagraphTitle, oFill, "center");
addText(oApi, 42, textContent, oSlide, oShapeText, oParagraphText, oFill, "left");
// Transform 2d array into cols names, rows names and data
CValue array_cols = colsFromArray(array, oContext);
CValue array_rows = rowsFromArray(array, oContext);
CValue array_data = dataFromArray(array, oContext);
// Pass CValue data to the CreateChart method
CValue oChart = oApi.Call("CreateChart", "lineStacked", array_data, array_cols, array_rows);
oChart.Call("SetSize", 180 * 36000, 100 * 36000);
oChart.Call("SetPosition", 20 * 36000, 50 * 36000);
oChart.Call("ApplyChartStyle", 24);
oChart.Call("SetVertAxisLabelsFontSize", 16);
oChart.Call("SetHorAxisLabelsFontSize", 16);
oChart.Call("SetLegendFontSize", 16);
oChart.Call("SetLegendPos", "top");
oSlide.Call("AddObject", oChart);
// Save file and close DocBuilder
oBuilder.SaveFile(doctype, resultPath);
oBuilder.CloseFile();
CDocBuilder.Destroy();
}
public static object[,] oRangeTo2dArray(CValue oRange, CContext oContext)
{
int rowsLen = (int)oRange.GetLength();
int colsLen = (int)oRange[0].GetLength();
object[,] oArray = new object[rowsLen, colsLen];
for (int col = 0; col < colsLen; col++)
{
CValue oArrayRow = oContext.CreateArray(rowsLen);
for (int row = 0; row < rowsLen; row++)
{
oArray[row, col] = oRange[row][col].ToString();
}
}
return oArray;
}
public static CValue colsFromArray(object[,] array, CContext oContext)
{
int colsLen = array.GetLength(1) - 1;
CValue cols = oContext.CreateArray(colsLen);
for (int col = 1; col <= colsLen; col++)
{
cols[col - 1] = array[0, col].ToString();
}
return cols;
}
public static CValue rowsFromArray(object[,] array, CContext oContext)
{
int rowsLen = array.GetLength(0) - 1;
CValue rows = oContext.CreateArray(rowsLen);
for (int row = 1; row <= rowsLen; row++)
{
rows[row - 1] = array[row, 0].ToString();
}
return rows;
}
public static CValue dataFromArray(object[,] array, CContext oContext)
{
int colsLen = array.GetLength(0) - 1;
int rowsLen = array.GetLength(1) - 1;
CValue data = oContext.CreateArray(rowsLen);
for (int row = 1; row <= rowsLen; row++)
{
CValue row_data = oContext.CreateArray(colsLen);
for (int col = 1; col <= colsLen; col++)
{
row_data[col - 1] = array[col, row].ToString();
}
data[row - 1] = row_data;
}
return data;
}
public static void addText(CValue oApi, int fontSize, string text, CValue oSlide, CValue oShape, CValue oParagraph, CValue oFill, string jc)
{
CValue oRun = oApi.Call("CreateRun");
var oTextPr = oRun.Call("GetTextPr");
oTextPr.Call("SetFontSize", fontSize);
oTextPr.Call("SetFill", oFill);
oTextPr.Call("SetFontFamily", "Tahoma");
oParagraph.Call("SetJc", jc);
oRun.Call("AddText", text);
oRun.Call("AddLineBreak");
oParagraph.Call("AddElement", oRun);
oSlide.Call("AddObject", oShape);
}
}
}

View File

@ -0,0 +1,168 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using docbuilder_net;
using OfficeFileTypes = docbuilder_net.FileTypes;
using CValue = docbuilder_net.CDocBuilderValue;
using CContext = docbuilder_net.CDocBuilderContext;
using CContextScope = docbuilder_net.CDocBuilderContextScope;
using System.Collections.Generic;
namespace Sample
{
public class CreatingPresentation
{
public static void Main(string[] args)
{
string workDirectory = "C:/Program Files/ONLYOFFICE/DocumentBuilder";
string resultPath = "../../../result.pptx";
IDictionary<string, string> slideImages = new Dictionary<string, string>() {
{ "gun", "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_gun.png" },
{ "axe","https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_axe.png" },
{ "knight", "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_knight.png" },
{ "sky","https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_sky.png" }
};
// add Docbuilder dlls in path
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + workDirectory);
CreatePresentation(workDirectory, resultPath, slideImages);
}
public static void CreatePresentation(string workDirectory, string resultPath, IDictionary<string, string> slideImages)
{
var doctype = (int)OfficeFileTypes.Presentation.PPTX;
// Init DocBuilder
CDocBuilder.Initialize(workDirectory);
CDocBuilder oBuilder = new CDocBuilder();
// Create presentation
oBuilder.CreateFile(doctype);
CContext oContext = oBuilder.GetContext();
CContextScope oScope = oContext.CreateScope();
CValue oGlobal = oContext.GetGlobal();
CValue oApi = oGlobal["Api"];
CValue oPresentation = oApi.Call("GetPresentation");
oPresentation.Call("SetSizes", 9144000, 6858000);
CValue oSlide = createImageSlide(oApi, oPresentation, slideImages["gun"]);
oPresentation.Call("GetSlideByIndex", 0).Call("Delete");
CValue oShape = oApi.Call("CreateShape", "rect", 8056800, 3020400, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
oShape.Call("SetPosition", 608400, 1267200);
CValue oContent = oShape.Call("GetDocContent");
oContent.Call("RemoveAllElements");
addTextToSlideShape(oApi, oContent, "How They", 160, true, "left");
addTextToSlideShape(oApi, oContent, "Throw Out", 132, false, "left");
addTextToSlideShape(oApi, oContent, "a Challenge", 132, false, "left");
oSlide.Call("AddObject", oShape);
oSlide = createImageSlide(oApi, oPresentation, slideImages["axe"]);
oShape = oApi.Call("CreateShape", "rect", 6904800, 1724400, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
oShape.Call("SetPosition", 1764000, 1191600);
oContent = oShape.Call("GetDocContent");
oContent.Call("RemoveAllElements");
addTextToSlideShape(oApi, oContent, "American Indians ", 110, true, "right");
addTextToSlideShape(oApi, oContent, "(XVII century)", 94, false, "right");
oSlide.Call("AddObject", oShape);
oShape = oApi.Call("CreateShape", "rect", 4986000, 2419200, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
oShape.Call("SetPosition", 3834000, 3888000);
oContent = oShape.Call("GetDocContent");
oContent.Call("RemoveAllElements");
addTextToSlideShape(oApi, oContent, "put a tomahawk on the ground in the ", 84, false, "right");
addTextToSlideShape(oApi, oContent, "rival's camp", 84, false, "right");
oSlide.Call("AddObject", oShape);
oSlide = createImageSlide(oApi, oPresentation, slideImages["knight"]);
oShape = oApi.Call("CreateShape", "rect", 6904800, 1724400, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
oShape.Call("SetPosition", 1764000, 1191600);
oContent = oShape.Call("GetDocContent");
oContent.Call("RemoveAllElements");
addTextToSlideShape(oApi, oContent, "European Knights", 110, true, "right");
addTextToSlideShape(oApi, oContent, " (XII-XVI centuries)", 94, false, "right");
oSlide.Call("AddObject", oShape);
oShape = oApi.Call("CreateShape", "rect", 4986000, 2419200, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
oShape.Call("SetPosition", 3834000, 3888000);
oContent = oShape.Call("GetDocContent");
oContent.Call("RemoveAllElements");
addTextToSlideShape(oApi, oContent, "threw a glove", 84, false, "right");
addTextToSlideShape(oApi, oContent, "in the rival's face", 84, false, "right");
oSlide.Call("AddObject", oShape);
oSlide = createImageSlide(oApi, oPresentation, slideImages["sky"]);
oShape = oApi.Call("CreateShape", "rect", 7887600, 3063600, oApi.Call("CreateNoFill"), oApi.Call("CreateStroke", 0, oApi.Call("CreateNoFill")));
oShape.Call("SetPosition", 630000, 1357200);
oContent = oShape.Call("GetDocContent");
oContent.Call("RemoveAllElements");
addTextToSlideShape(oApi, oContent, "OnlyOffice", 176, false, "center");
addTextToSlideShape(oApi, oContent, "stands for Peace", 132, false, "center");
oSlide.Call("AddObject", oShape);
// Save file and close DocBuilder
oBuilder.SaveFile(doctype, resultPath);
oBuilder.CloseFile();
CDocBuilder.Destroy();
}
public static CValue createImageSlide(CValue oApi, CValue oPresentation, string image_url)
{
CValue oSlide = oApi.Call("CreateSlide");
oPresentation.Call("AddSlide", oSlide);
var oFill = oApi.Call("CreateBlipFill", image_url, "stretch");
oSlide.Call("SetBackground", oFill);
oSlide.Call("RemoveAllObjects");
return oSlide;
}
public static void addTextToSlideShape(CValue oApi, CValue oContent, string text, int fontSize, bool isBold, string js)
{
var oParagraph = oApi.Call("CreateParagraph");
oParagraph.Call("SetSpacingBefore", 0);
oParagraph.Call("SetSpacingAfter", 0);
oContent.Call("Push", oParagraph);
var oRun = oParagraph.Call("AddText", text);
oRun.Call("SetFill", oApi.Call("CreateSolidFill", oApi.Call("CreateRGBColor", 0xff, 0xff, 0xff)));
oRun.Call("SetFontSize", fontSize);
oRun.Call("SetFontFamily", "Georgia");
oRun.Call("SetBold", isBold);
oParagraph.Call("SetJc", js);
}
}
}

View File

@ -0,0 +1,115 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using docbuilder_net;
using OfficeFileTypes = docbuilder_net.FileTypes;
using CValue = docbuilder_net.CDocBuilderValue;
using CContext = docbuilder_net.CDocBuilderContext;
using CContextScope = docbuilder_net.CDocBuilderContextScope;
using System;
using System.Collections.Generic;
namespace Sample
{
public class FillingForm
{
public static void Main(string[] args)
{
string workDirectory = "C:/Program Files/ONLYOFFICE/DocumentBuilder";
string filePath = "../../../../../../resources/docs/form.docx";
string resultPath = "../../../result.docx";
IDictionary<string, string> formData = new Dictionary<string, string>() {
{ "Photo", "https://api.onlyoffice.com/content/img/docbuilder/examples/blue_cloud.png" },
{ "Serial","A1345" },
{ "Company Name", "Blue Cloud" },
{ "Date", "25.12.2023" },
{ "Recipient", "Space Corporation" },
{ "Qty1", "25" },
{ "Description1", "Frame" },
{ "Qty2", "2" },
{ "Description2", "Stack" },
{ "Qty3", "34" },
{ "Description3", "Shifter" }
};
// add Docbuilder dlls in path
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + workDirectory);
FillForm(workDirectory, resultPath, filePath, formData);
}
public static void FillForm(string workDirectory, string resultPath, string filePath, IDictionary<string, string> formData)
{
var doctype = (int)OfficeFileTypes.Document.DOCX;
// Init DocBuilder
CDocBuilder.Initialize(workDirectory);
CDocBuilder oBuilder = new CDocBuilder();
oBuilder.OpenFile(filePath, "docxf");
CContext oContext = oBuilder.GetContext();
CContextScope oScope = oContext.CreateScope();
CValue oGlobal = oContext.GetGlobal();
CValue oApi = oGlobal["Api"];
// Fill form
CValue oDocument = oApi.Call("GetDocument");
CValue aForms = oDocument.Call("GetAllForms");
int formNum = 0;
while (formNum < aForms.GetLength())
{
CValue form = aForms[formNum];
string type = form.Call("GetFormType").ToString();
string value;
try
{
value = formData[form.Call("GetFormKey").ToString()];
}
catch (Exception e)
{
value = "";
}
if (type == "textForm") form.Call("SetText", value);
if (type == "pictureForm") form.Call("SetImage", value);
formNum++;
}
// Save file and close DocBuilder
oBuilder.SaveFile(doctype, resultPath);
oBuilder.CloseFile();
CDocBuilder.Destroy();
}
}
}

View File

@ -0,0 +1,114 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using docbuilder_net;
using OfficeFileTypes = docbuilder_net.FileTypes;
using CValue = docbuilder_net.CDocBuilderValue;
using CContext = docbuilder_net.CDocBuilderContext;
using CContextScope = docbuilder_net.CDocBuilderContextScope;
namespace Sample
{
public class FillingSpreadsheet
{
public static void Main(string[] args)
{
string workDirectory = "C:/Program Files/ONLYOFFICE/DocumentBuilder";
string resultPath = "../../../result.xlsx";
object[,] data = {
{ "Id", "Product", "Price", "Available"},
{ 1001, "Item A", 12.2, true },
{ 1002, "Item B", 18.8, true },
{ 1003, "Item C", 70.1, false },
{ 1004, "Item D", 60.6, true },
{ 1005, "Item E", 32.6, true },
{ 1006, "Item F", 28.3, false },
{ 1007, "Item G", 11.1, false },
{ 1008, "Item H", 41.4, true }
};
// add Docbuilder dlls in path
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + workDirectory);
FillSpreadsheet(workDirectory, resultPath, data);
}
public static void FillSpreadsheet(string workDirectory, string resultPath, object[,] data)
{
var doctype = (int)OfficeFileTypes.Spreadsheet.XLSX;
// Init DocBuilder
CDocBuilder.Initialize(workDirectory);
CDocBuilder oBuilder = new CDocBuilder();
oBuilder.CreateFile(doctype);
CContext oContext = oBuilder.GetContext();
CContextScope oScope = oContext.CreateScope();
CValue oGlobal = oContext.GetGlobal();
CValue oApi = oGlobal["Api"];
CValue oWorksheet = oApi.Call("GetActiveSheet");
// pass data
CValue oArray = TwoDimArrayToCValue(data, oContext);
// First cell in the range (A1) is equal to (0,0)
CValue startCell = oWorksheet.Call("GetRangeByNumber", 0, 0);
// Last cell in the range is equal to array length -1
CValue endCell = oWorksheet.Call("GetRangeByNumber", oArray.GetLength() - 1, oArray[0].GetLength() - 1);
oWorksheet.Call("GetRange", startCell, endCell).Call("SetValue", oArray);
// Save file and close DocBuilder
oBuilder.SaveFile(doctype, resultPath);
oBuilder.CloseFile();
CDocBuilder.Destroy();
}
public static CValue TwoDimArrayToCValue(object[,] data, CContext oContext)
{
int rowsLen = data.GetLength(0);
int colsLen = data.GetLength(1);
CValue oArray = oContext.CreateArray(rowsLen);
for (int row = 0; row < rowsLen; row++)
{
CValue oArrayCol = oContext.CreateArray(colsLen);
for (int col = 0; col < colsLen; col++)
{
oArrayCol[col] = data[row, col].ToString();
}
oArray[row] = oArrayCol;
}
return oArray;
}
}
}

View File

@ -0,0 +1,76 @@
import docbuilder.*;
public class Program {
public static void main(String[] args) {
String resultPath = "result.docx";
createBasicForm(resultPath);
// Need to explicitly call System.gc() to free up resources
System.gc();
}
public static void createBasicForm(String resultPath) {
int doctype = FileTypes.Document.DOCX;
// Initialize builder with docbuilder.jar directory by passing empty string
CDocBuilder.initialize("");
CDocBuilder builder = new CDocBuilder();
builder.createFile(doctype);
CDocBuilderContext context = builder.getContext();
CDocBuilderValue global = context.getGlobal();
CDocBuilderValue api = global.get("Api");
// Create basic form
CDocBuilderValue document = api.call("GetDocument");
CDocBuilderValue paragraph = document.call("GetElement", 0);
CDocBuilderValue headingStyle = document.call("GetStyle", "Heading 3");
paragraph.call("AddText", "Employee pass card");
paragraph.call("SetStyle", headingStyle);
document.call("Push", paragraph);
CDocBuilderValue pictureForm = api.call("CreatePictureForm");
setPictureFormProperties(pictureForm, "Photo", "Upload your photo", false, "Photo", "tooBig", true, false, 50, 50, "https://api.onlyoffice.com/content/img/docbuilder/examples/user-profile.png");
paragraph = api.call("CreateParagraph");
paragraph.call("AddElement", pictureForm);
document.call("Push", paragraph);
CDocBuilderValue textForm = api.call("CreateTextForm");
setTextFormProperties(textForm, "First name", "Enter your first name", false, "First name", true, 13, 3, false, false);
paragraph = api.call("CreateParagraph");
paragraph.call("AddElement", textForm);
document.call("Push", paragraph);
// Save file and close DocBuilder
builder.saveFile(doctype, resultPath);
builder.closeFile();
CDocBuilder.dispose();
}
public static void setPictureFormProperties(CDocBuilderValue pictureForm, String key, String tip, boolean required, String placeholder, String scaleFlag, boolean lockAspectRatio, boolean respectBorders, int shiftX, int shiftY, String imageUrl) {
pictureForm.call("SetFormKey", key);
pictureForm.call("SetTipText", tip);
pictureForm.call("SetRequired", required);
pictureForm.call("SetPlaceholderText", placeholder);
pictureForm.call("SetScaleFlag", scaleFlag);
pictureForm.call("SetLockAspectRatio", lockAspectRatio);
pictureForm.call("SetRespectBorders", respectBorders);
pictureForm.call("SetPicturePosition", shiftX, shiftY);
pictureForm.call("SetImage", imageUrl);
}
public static void setTextFormProperties(CDocBuilderValue textForm, String key, String tip, boolean required, String placeholder, boolean comb, int maxCharacters, int cellWidth, boolean multiLine, boolean autoFit) {
textForm.call("SetFormKey", key);
textForm.call("SetTipText", tip);
textForm.call("SetRequired", required);
textForm.call("SetPlaceholderText", placeholder);
textForm.call("SetComb", comb);
textForm.call("SetCharactersLimit", maxCharacters);
textForm.call("SetCellWidth", cellWidth);
textForm.call("SetCellWidth", multiLine);
textForm.call("SetMultiline", autoFit);
}
}

View File

@ -0,0 +1,123 @@
import docbuilder.*;
import java.util.HashMap;
public class Program {
public static void main(String[] args) {
String resultPath = "result.pptx";
// Fill slide images
HashMap<String, String> slideImages = new HashMap<String, String>();
slideImages.put("gun", "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_gun.png");
slideImages.put("axe", "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_axe.png");
slideImages.put("knight", "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_knight.png");
slideImages.put("sky", "https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_sky.png");
createPresentation(resultPath, slideImages);
// Need to explicitly call System.gc() to free up resources
System.gc();
}
public static void createPresentation(String resultPath, HashMap<String, String> slideImages) {
int doctype = FileTypes.Presentation.PPTX;
// Initialize builder with docbuilder.jar directory by passing empty String
CDocBuilder.initialize("");
CDocBuilder builder = new CDocBuilder();
builder.createFile(doctype);
CDocBuilderContext context = builder.getContext();
CDocBuilderValue global = context.getGlobal();
CDocBuilderValue api = global.get("Api");
// Create presentation
CDocBuilderValue presentation = api.call("GetPresentation");
presentation.call("SetSizes", 9144000, 6858000);
CDocBuilderValue slide = createImageSlide(api, presentation, slideImages.get("gun"));
presentation.call("GetSlideByIndex", 0).call("Delete");
CDocBuilderValue shape = api.call("CreateShape", "rect", 8056800, 3020400, api.call("CreateNoFill"), api.call("CreateStroke", 0, api.call("CreateNoFill")));
shape.call("SetPosition", 608400, 1267200);
CDocBuilderValue content = shape.call("GetDocContent");
content.call("RemoveAllElements");
addTextToSlideShape(api, content, "How They", 160, true, "left");
addTextToSlideShape(api, content, "Throw Out", 132, false, "left");
addTextToSlideShape(api, content, "a Challenge", 132, false, "left");
slide.call("AddObject", shape);
slide = createImageSlide(api, presentation, slideImages.get("axe"));
shape = api.call("CreateShape", "rect", 6904800, 1724400, api.call("CreateNoFill"), api.call("CreateStroke", 0, api.call("CreateNoFill")));
shape.call("SetPosition", 1764000, 1191600);
content = shape.call("GetDocContent");
content.call("RemoveAllElements");
addTextToSlideShape(api, content, "American Indians ", 110, true, "right");
addTextToSlideShape(api, content, "(XVII century)", 94, false, "right");
slide.call("AddObject", shape);
shape = api.call("CreateShape", "rect", 4986000, 2419200, api.call("CreateNoFill"), api.call("CreateStroke", 0, api.call("CreateNoFill")));
shape.call("SetPosition", 3834000, 3888000);
content = shape.call("GetDocContent");
content.call("RemoveAllElements");
addTextToSlideShape(api, content, "put a tomahawk on the ground in the ", 84, false, "right");
addTextToSlideShape(api, content, "rival's camp", 84, false, "right");
slide.call("AddObject", shape);
slide = createImageSlide(api, presentation, slideImages.get("knight"));
shape = api.call("CreateShape", "rect", 6904800, 1724400, api.call("CreateNoFill"), api.call("CreateStroke", 0, api.call("CreateNoFill")));
shape.call("SetPosition", 1764000, 1191600);
content = shape.call("GetDocContent");
content.call("RemoveAllElements");
addTextToSlideShape(api, content, "European Knights", 110, true, "right");
addTextToSlideShape(api, content, " (XII-XVI centuries)", 94, false, "right");
slide.call("AddObject", shape);
shape = api.call("CreateShape", "rect", 4986000, 2419200, api.call("CreateNoFill"), api.call("CreateStroke", 0, api.call("CreateNoFill")));
shape.call("SetPosition", 3834000, 3888000);
content = shape.call("GetDocContent");
content.call("RemoveAllElements");
addTextToSlideShape(api, content, "threw a glove", 84, false, "right");
addTextToSlideShape(api, content, "in the rival's face", 84, false, "right");
slide.call("AddObject", shape);
slide = createImageSlide(api, presentation, slideImages.get("sky"));
shape = api.call("CreateShape", "rect", 7887600, 3063600, api.call("CreateNoFill"), api.call("CreateStroke", 0, api.call("CreateNoFill")));
shape.call("SetPosition", 630000, 1357200);
content = shape.call("GetDocContent");
content.call("RemoveAllElements");
addTextToSlideShape(api, content, "OnlyOffice", 176, false, "center");
addTextToSlideShape(api, content, "stands for Peace", 132, false, "center");
slide.call("AddObject", shape);
// Save file and close DocBuilder
builder.saveFile(doctype, resultPath);
builder.closeFile();
CDocBuilder.dispose();
}
public static CDocBuilderValue createImageSlide(CDocBuilderValue api, CDocBuilderValue presentation, String imageUrl) {
CDocBuilderValue slide = api.call("CreateSlide");
presentation.call("AddSlide", slide);
CDocBuilderValue fill = api.call("CreateBlipFill", imageUrl, "stretch");
slide.call("SetBackground", fill);
slide.call("RemoveAllObjects");
return slide;
}
public static void addTextToSlideShape(CDocBuilderValue api, CDocBuilderValue content, String text, int fontSize, boolean isBold, String js) {
CDocBuilderValue paragraph = api.call("CreateParagraph");
paragraph.call("SetSpacingBefore", 0);
paragraph.call("SetSpacingAfter", 0);
content.call("Push", paragraph);
CDocBuilderValue run = paragraph.call("AddText", text);
run.call("SetFill", api.call("CreateSolidFill", api.call("CreateRGBColor", 0xff, 0xff, 0xff)));
run.call("SetFontSize", fontSize);
run.call("SetFontFamily", "Georgia");
run.call("SetBold", isBold);
paragraph.call("SetJc", js);
}
}

View File

@ -0,0 +1,54 @@
import docbuilder.*;
public class Program {
public static void main(String[] args) {
String resultPath = "result.xlsx";
// Fill table data
Object[][] data = {
{ "Id", "Product", "Price", "Available" },
{ 1001, "Item A", 12.2, true },
{ 1002, "Item B", 18.8, true },
{ 1003, "Item C", 70.1, false },
{ 1004, "Item D", 60.6, true },
{ 1005, "Item E", 32.6, true },
{ 1006, "Item F", 28.3, false },
{ 1007, "Item G", 11.1, false },
{ 1008, "Item H", 41.4, true }
};
fillSpreadsheet(resultPath, data);
// Need to explicitly call System.gc() to free up resources
System.gc();
}
public static void fillSpreadsheet(String resultPath, Object[][] data) {
int doctype = FileTypes.Spreadsheet.XLSX;
// Initialize builder with docbuilder.jar directory by passing empty String
CDocBuilder.initialize("");
CDocBuilder builder = new CDocBuilder();
builder.createFile(doctype);
CDocBuilderContext context = builder.getContext();
CDocBuilderValue global = context.getGlobal();
CDocBuilderValue api = global.get("Api");
// Create spreadsheet
CDocBuilderValue worksheet = api.call("GetActiveSheet");
// Convert data to array value type
CDocBuilderValue array = new CDocBuilderValue(data);
// First cell in the range (A1) is equal to (0,0)
CDocBuilderValue startCell = worksheet.call("GetRangeByNumber", 0, 0);
// Last cell in the range is equal to array length -1
CDocBuilderValue endCell = worksheet.call("GetRangeByNumber", array.getLength() - 1, array.get(0).getLength() - 1);
worksheet.call("GetRange", startCell, endCell).call("SetValue", array);
// Save file and close DocBuilder
builder.saveFile(doctype, resultPath);
builder.closeFile();
CDocBuilder.dispose();
}
}

View File

@ -0,0 +1,60 @@
import os
import sys
sys.path.append('C:/Program Files/ONLYOFFICE/DocumentBuilder')
import docbuilder
# Helper functions
def setPictureFormProperties(pictureForm, key, tip, required, placeholder, scaleFlag, lockAspectRatio, respectBorders, shiftX, shiftY, imageUrl):
pictureForm.Call('SetFormKey', key)
pictureForm.Call('SetTipText', tip)
pictureForm.Call('SetRequired', required)
pictureForm.Call('SetPlaceholderText', placeholder)
pictureForm.Call('SetScaleFlag', scaleFlag)
pictureForm.Call('SetLockAspectRatio', lockAspectRatio)
pictureForm.Call('SetRespectBorders', respectBorders)
pictureForm.Call('SetPicturePosition', shiftX, shiftY)
pictureForm.Call('SetImage', imageUrl)
def setTextFormProperties(textForm, key, tip, required, placeholder, comb, maxCharacters, cellWidth, multiLine, autoFit):
textForm.Call('SetFormKey', key)
textForm.Call('SetTipText', tip)
textForm.Call('SetRequired', required)
textForm.Call('SetPlaceholderText', placeholder)
textForm.Call('SetComb', comb)
textForm.Call('SetCharactersLimit', maxCharacters)
textForm.Call('SetCellWidth', cellWidth)
textForm.Call('SetCellWidth', multiLine)
textForm.Call('SetMultiline', autoFit)
if __name__ == '__main__':
builder = docbuilder.CDocBuilder()
builder.CreateFile(docbuilder.FileTypes.Document.DOCX)
context = builder.GetContext()
globalObj = context.GetGlobal()
api = globalObj['Api']
document = api.Call('GetDocument')
paragraph = document.Call('GetElement', 0)
headingStyle = document.Call('GetStyle', 'Heading 3')
paragraph.Call('AddText', 'Employee pass card')
paragraph.Call('SetStyle', headingStyle)
document.Call('Push', paragraph)
pictureForm = api.Call('CreatePictureForm')
setPictureFormProperties(pictureForm, 'Photo', 'Upload your photo', False, 'Photo', 'tooBig', True, False, 50, 50, 'https://api.onlyoffice.com/content/img/docbuilder/examples/user-profile.png')
paragraph = api.Call('CreateParagraph')
paragraph.Call('AddElement', pictureForm)
document.Call('Push', paragraph)
textForm = api.Call('CreateTextForm')
setTextFormProperties(textForm, 'First name', 'Enter your first name', False, 'First name', True, 13, 3, False, False)
paragraph = api.Call('CreateParagraph')
paragraph.Call('AddElement', textForm)
document.Call('Push', paragraph)
# Save and close
resultPath = os.getcwd() + '/result.docx'
builder.SaveFile(docbuilder.FileTypes.Document.DOCX, resultPath)
builder.CloseFile()

View File

@ -0,0 +1,105 @@
import os
import sys
sys.path.append('C:/Program Files/ONLYOFFICE/DocumentBuilder')
import docbuilder
def createImageSlide(api, presentation, image_url):
slide = api.Call('CreateSlide')
presentation.Call('AddSlide', slide)
fill = api.Call('CreateBlipFill', image_url, 'stretch')
slide.Call('SetBackground', fill)
slide.Call('RemoveAllObjects')
return slide
def addTextToSlideShape(api, content, text, fontSize, isBold, js):
paragraph = api.Call('CreateParagraph')
paragraph.Call('SetSpacingBefore', 0)
paragraph.Call('SetSpacingAfter', 0)
content.Call('Push', paragraph)
run = paragraph.Call('AddText', text)
run.Call('SetFill', api.Call('CreateSolidFill', api.Call('CreateRGBColor', 0xff, 0xff, 0xff)))
run.Call('SetFontSize', fontSize)
run.Call('SetFontFamily', 'Georgia')
run.Call('SetBold', isBold)
paragraph.Call('SetJc', js)
if __name__ == '__main__':
slideImages = {}
slideImages['gun'] = 'https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_gun.png'
slideImages['axe'] = 'https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_axe.png'
slideImages['knight'] = 'https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_knight.png'
slideImages['sky'] = 'https://api.onlyoffice.com/content/img/docbuilder/examples/presentation_sky.png'
builder = docbuilder.CDocBuilder()
builder.CreateFile(docbuilder.FileTypes.Presentation.PPTX)
context = builder.GetContext()
globalObj = context.GetGlobal()
api = globalObj['Api']
# Create presentation
presentation = api.Call('GetPresentation')
presentation.Call('SetSizes', 9144000, 6858000)
slide = createImageSlide(api, presentation, slideImages['gun'])
presentation.Call('GetSlideByIndex', 0).Call('Delete')
shape = api.Call('CreateShape', 'rect', 8056800, 3020400, api.Call('CreateNoFill'), api.Call('CreateStroke', 0, api.Call('CreateNoFill')))
shape.Call('SetPosition', 608400, 1267200)
content = shape.Call('GetDocContent')
content.Call('RemoveAllElements')
addTextToSlideShape(api, content, 'How They', 160, True, 'left')
addTextToSlideShape(api, content, 'Throw Out', 132, False, 'left')
addTextToSlideShape(api, content, 'a Challenge', 132, False, 'left')
slide.Call('AddObject', shape)
slide = createImageSlide(api, presentation, slideImages['axe'])
shape = api.Call('CreateShape', 'rect', 6904800, 1724400, api.Call('CreateNoFill'), api.Call('CreateStroke', 0, api.Call('CreateNoFill')))
shape.Call('SetPosition', 1764000, 1191600)
content = shape.Call('GetDocContent')
content.Call('RemoveAllElements')
addTextToSlideShape(api, content, 'American Indians ', 110, True, 'right')
addTextToSlideShape(api, content, '(XVII century)', 94, False, 'right')
slide.Call('AddObject', shape)
shape = api.Call('CreateShape', 'rect', 4986000, 2419200, api.Call('CreateNoFill'), api.Call('CreateStroke', 0, api.Call('CreateNoFill')))
shape.Call('SetPosition', 3834000, 3888000)
content = shape.Call('GetDocContent')
content.Call('RemoveAllElements')
addTextToSlideShape(api, content, 'put a tomahawk on the ground in the ', 84, False, 'right')
addTextToSlideShape(api, content, 'rival\'s camp', 84, False, 'right')
slide.Call('AddObject', shape)
slide = createImageSlide(api, presentation, slideImages['knight'])
shape = api.Call('CreateShape', 'rect', 6904800, 1724400, api.Call('CreateNoFill'), api.Call('CreateStroke', 0, api.Call('CreateNoFill')))
shape.Call('SetPosition', 1764000, 1191600)
content = shape.Call('GetDocContent')
content.Call('RemoveAllElements')
addTextToSlideShape(api, content, 'European Knights', 110, True, 'right')
addTextToSlideShape(api, content, ' (XII-XVI centuries)', 94, False, 'right')
slide.Call('AddObject', shape)
shape = api.Call('CreateShape', 'rect', 4986000, 2419200, api.Call('CreateNoFill'), api.Call('CreateStroke', 0, api.Call('CreateNoFill')))
shape.Call('SetPosition', 3834000, 3888000)
content = shape.Call('GetDocContent')
content.Call('RemoveAllElements')
addTextToSlideShape(api, content, 'threw a glove', 84, False, 'right')
addTextToSlideShape(api, content, 'in the rival\'s face', 84, False, 'right')
slide.Call('AddObject', shape)
slide = createImageSlide(api, presentation, slideImages['sky'])
shape = api.Call('CreateShape', 'rect', 7887600, 3063600, api.Call('CreateNoFill'), api.Call('CreateStroke', 0, api.Call('CreateNoFill')))
shape.Call('SetPosition', 630000, 1357200)
content = shape.Call('GetDocContent')
content.Call('RemoveAllElements')
addTextToSlideShape(api, content, 'OnlyOffice', 176, False, 'center')
addTextToSlideShape(api, content, 'stands for Peace', 132, False, 'center')
slide.Call('AddObject', shape)
# Save and close
resultPath = os.getcwd() + '/result.pptx'
builder.SaveFile(docbuilder.FileTypes.Presentation.PPTX, resultPath)
builder.CloseFile()

View File

@ -0,0 +1,42 @@
import os
import sys
sys.path.append('C:/Program Files/ONLYOFFICE/DocumentBuilder')
import docbuilder
if __name__ == '__main__':
data = [
[ 'Id', 'Product', 'Price', 'Available' ],
[ '1001', 'Item A', "12.2", 'true' ],
[ '1002', 'Item B', "18.8", 'true' ],
[ '1003', 'Item C', "70.1", 'false' ],
[ '1004', 'Item D', "60.6", 'true' ],
[ '1005', 'Item E', "32.6", 'true' ],
[ '1006', 'Item F', "28.3", 'false' ],
[ '1007', 'Item G', "11.1", 'false' ],
[ '1008', 'Item H', "41.4", 'true' ]
]
builder = docbuilder.CDocBuilder()
builder.CreateFile(docbuilder.FileTypes.Spreadsheet.XLSX)
context = builder.GetContext()
globalObj = context.GetGlobal()
api = globalObj['Api']
# Find and comment formula errors
worksheet = api.Call('GetActiveSheet')
# Create array from data
array = docbuilder.CDocBuilderValue(data)
# First cell in the range (A1) is equal to (0,0)
startCell = worksheet.Call('GetRangeByNumber', 0, 0)
# Last cell in the range is equal to array length -1
endCell = worksheet.Call('GetRangeByNumber', len(data) - 1, len(data[0]) - 1)
worksheet.Call('GetRange', startCell, endCell).Call('SetValue', array)
# Save and close
resultPath = os.getcwd() + '/result.xlsx'
builder.SaveFile(docbuilder.FileTypes.Spreadsheet.XLSX, resultPath)
builder.CloseFile()

Some files were not shown because too many files have changed in this diff Show More