mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-03-03 09:11:45 +08:00
Compare commits
23 Commits
fix/bug597
...
feature/do
| Author | SHA1 | Date | |
|---|---|---|---|
| 8550bdeed6 | |||
| 5aae57aad8 | |||
| 1d4f825ea6 | |||
| 0527472fef | |||
| c911733bd7 | |||
| 46f254c85d | |||
| a6a7d919e6 | |||
| 755d6cd970 | |||
| 604dc14d23 | |||
| 2263d7bf80 | |||
| ef415aad3f | |||
| 6744c172f4 | |||
| 6ea3a9551e | |||
| f48ab0351c | |||
| 632ddf9805 | |||
| 2c61e84e94 | |||
| 375b37e9aa | |||
| bb3e2e3bc2 | |||
| 1a5b8b4bbd | |||
| 901c44b486 | |||
| 88eadd9955 | |||
| b5f88cebaf | |||
| e0e7e31568 |
141
Apple/IWork.cpp
141
Apple/IWork.cpp
@ -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;
|
||||
}
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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;
|
||||
}
|
||||
@ -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
|
||||
1
Common/.gitignore
vendored
1
Common/.gitignore
vendored
@ -1 +0,0 @@
|
||||
**/module.version
|
||||
8
Common/3dParty/apple/.gitignore
vendored
8
Common/3dParty/apple/.gitignore
vendored
@ -1,8 +0,0 @@
|
||||
# Ignore everything in this directory
|
||||
glm
|
||||
mdds
|
||||
librevenge
|
||||
libodfgen
|
||||
libetonyek
|
||||
# Except this file
|
||||
!.gitignore
|
||||
@ -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)
|
||||
|
||||
@ -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
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -4,7 +4,6 @@ CORE_BOOST_LIBS = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib
|
||||
core_ios:CONFIG += disable_enum_constexpr_conversion
|
||||
core_android:CONFIG += disable_enum_constexpr_conversion
|
||||
core_mac:CONFIG += disable_enum_constexpr_conversion
|
||||
core_linux_clang:CONFIG += disable_enum_constexpr_conversion
|
||||
|
||||
core_android {
|
||||
INCLUDEPATH += $$PWD/build/android/include
|
||||
@ -26,21 +25,14 @@ bundle_xcframeworks {
|
||||
}
|
||||
}
|
||||
|
||||
core_win_arm64 {
|
||||
DEFINES += MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS=0
|
||||
}
|
||||
|
||||
core_windows {
|
||||
VS_VERSION=140
|
||||
VS_DEBUG=
|
||||
VS_ARCH=x64
|
||||
core_debug:VS_DEBUG=gd-
|
||||
core_win_32:VS_ARCH=x32
|
||||
core_win_arm64:VS_ARCH=a64
|
||||
vs2019:VS_VERSION=142
|
||||
|
||||
DEFINES += BOOST_USE_WINDOWS_H BOOST_WINAPI_NO_REDECLARATIONS
|
||||
|
||||
BOOST_POSTFIX = -vc$${VS_VERSION}-mt-$${VS_DEBUG}$${VS_ARCH}-1_72
|
||||
|
||||
core_boost_libs:LIBS += -L$$CORE_BOOST_LIBS -llibboost_system$$BOOST_POSTFIX -llibboost_filesystem$$BOOST_POSTFIX
|
||||
|
||||
@ -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
|
||||
|
||||
2
Common/3dParty/brotli/.gitignore
vendored
2
Common/3dParty/brotli/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
brotli/
|
||||
module.version
|
||||
@ -1,9 +0,0 @@
|
||||
SRC_DIR = $$PWD/brotli/c
|
||||
DEFINES += FT_CONFIG_OPTION_USE_BROTLI
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$SRC_DIR/include
|
||||
|
||||
SOURCES += $$files($$SRC_DIR/common/*.c)
|
||||
SOURCES += $$files($$SRC_DIR/dec/*.c)
|
||||
#SOURCES += $$files($$SRC_DIR/enc/*.c)
|
||||
@ -1,20 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.append("../../../../build_tools/scripts")
|
||||
import base
|
||||
|
||||
def clear_module():
|
||||
if base.is_dir("brotli"):
|
||||
base.delete_dir_with_access_error("brotli")
|
||||
return
|
||||
|
||||
base.check_module_version("1", clear_module)
|
||||
|
||||
# fetch harfbuzz
|
||||
if not base.is_dir("brotli"):
|
||||
base.cmd("git", ["clone", "https://github.com/google/brotli.git"])
|
||||
os.chdir("brotli")
|
||||
base.cmd("git", ["checkout", "a47d7475063eb223c87632eed806c0070e70da29"])
|
||||
os.chdir("../")
|
||||
@ -1,818 +0,0 @@
|
||||
// https://android.googlesource.com/platform/external/harfbuzz/+/ics-mr0/contrib/tables/script-properties.h
|
||||
|
||||
/*
|
||||
* https://unicode.org/reports/tr29/
|
||||
|
||||
As far as a user is concerned, the underlying representation of text is not important,
|
||||
but it is important that an editing interface present a uniform implementation of what
|
||||
the user thinks of as characters. Grapheme clusters can be treated as units, by default,
|
||||
for processes such as the formatting of drop caps, as well as the implementation of text
|
||||
selection, arrow key movement or backspacing through text, and so forth. For example,
|
||||
when a grapheme cluster is represented internally by a character sequence consisting of
|
||||
base character + accents, then using the right arrow key would skip from the start of the
|
||||
base character to the end of the last accent.
|
||||
|
||||
This document defines a default specification for grapheme clusters. It may be customized
|
||||
for particular languages, operations, or other situations. For example, arrow key movement
|
||||
could be tailored by language, or could use knowledge specific to particular fonts to move
|
||||
in a more granular manner, in circumstances where it would be useful to edit individual
|
||||
components. This could apply, for example, to the complex editorial requirements for the
|
||||
Northern Thai script Tai Tham (Lanna). Similarly, editing a grapheme cluster element by
|
||||
element may be preferable in some circumstances. For example, on a given system the backspace
|
||||
key might delete by code point, while the delete key may delete an entire cluster.
|
||||
* */
|
||||
|
||||
#include "../../../core/DesktopEditor/common/File.h"
|
||||
#include "../../../core/DesktopEditor/raster/BgraFrame.h"
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
#include FT_OUTLINE_H
|
||||
|
||||
#include <hb-ft.h>
|
||||
#include <hb-ot.h>
|
||||
#include <hb.h>
|
||||
|
||||
class CDrawer
|
||||
{
|
||||
public:
|
||||
CBgraFrame m_oFrame;
|
||||
BYTE *pixels;
|
||||
int width;
|
||||
int height;
|
||||
int pitch;
|
||||
BYTE Rshift;
|
||||
BYTE Gshift;
|
||||
BYTE Bshift;
|
||||
BYTE Ashift;
|
||||
|
||||
public:
|
||||
CDrawer(int w, int h)
|
||||
{
|
||||
width = w;
|
||||
height = h;
|
||||
pitch = 4 * width;
|
||||
m_oFrame.put_Width(width);
|
||||
m_oFrame.put_Height(height);
|
||||
m_oFrame.put_Stride(pitch);
|
||||
|
||||
int size = 4 * width * height;
|
||||
BYTE *pPixels = new BYTE[size];
|
||||
for (int i = 0; i < size; i += 4)
|
||||
{
|
||||
pPixels[i] = 0xFF;
|
||||
pPixels[i + 1] = 0xFF;
|
||||
pPixels[i + 2] = 0xFF;
|
||||
pPixels[i + 3] = 0xFF;
|
||||
}
|
||||
pixels = pPixels;
|
||||
m_oFrame.put_Data(pPixels);
|
||||
|
||||
Bshift = 24;
|
||||
Gshift = 16;
|
||||
Rshift = 8;
|
||||
Ashift = 0;
|
||||
}
|
||||
void Save()
|
||||
{
|
||||
m_oFrame.SaveFile(NSFile::GetProcessDirectory() + L"/output.png", 4);
|
||||
}
|
||||
};
|
||||
|
||||
#define NUM_EXAMPLES 3
|
||||
|
||||
/* fonts */
|
||||
const char *fonts_paths[NUM_EXAMPLES] = {
|
||||
"C:/Windows/Fonts/calibri.ttf",
|
||||
//"C:/Windows/Fonts/arial.ttf",
|
||||
"C:/Users/korol/AppData/Local/Microsoft/Windows/Fonts/ArabicTest.ttf",
|
||||
"C:/Windows/Fonts/simsun.ttc"
|
||||
};
|
||||
|
||||
#define NUM_GLYPH_TYPES 5
|
||||
const char *num_glyph_types[NUM_GLYPH_TYPES] = {"UNCLASSIFIED", "BASE_GLYPH", "LIGATURE", "MARK", "COMPONENT"};
|
||||
|
||||
/* tranlations courtesy of google */
|
||||
const char *texts[NUM_EXAMPLES] = {
|
||||
"fi",
|
||||
"لا لآ لأ لا",
|
||||
"懶惰的姜貓"
|
||||
};
|
||||
|
||||
const hb_direction_t text_directions[NUM_EXAMPLES] = {
|
||||
HB_DIRECTION_LTR,
|
||||
HB_DIRECTION_RTL,
|
||||
HB_DIRECTION_TTB,
|
||||
};
|
||||
|
||||
const int text_skip[NUM_EXAMPLES] = {
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
};
|
||||
|
||||
/* XXX: These are not correct, though it doesn't seem to break anything
|
||||
* regardless of their value. */
|
||||
const char *languages[NUM_EXAMPLES] = {
|
||||
"en",
|
||||
"ar",
|
||||
"ch",
|
||||
};
|
||||
|
||||
const hb_script_t scripts[NUM_EXAMPLES] = {
|
||||
HB_SCRIPT_LATIN,
|
||||
HB_SCRIPT_ARABIC,
|
||||
HB_SCRIPT_HAN,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ENGLISH = 0,
|
||||
ARABIC,
|
||||
CHINESE
|
||||
};
|
||||
|
||||
typedef struct _spanner_baton_t
|
||||
{
|
||||
/* rendering part - assumes 32bpp surface */
|
||||
uint32_t *pixels; // set to the glyph's origin.
|
||||
uint32_t *first_pixel, *last_pixel; // bounds check
|
||||
uint32_t pitch;
|
||||
uint32_t rshift;
|
||||
uint32_t gshift;
|
||||
uint32_t bshift;
|
||||
uint32_t ashift;
|
||||
|
||||
/* sizing part */
|
||||
int min_span_x;
|
||||
int max_span_x;
|
||||
int min_y;
|
||||
int max_y;
|
||||
} spanner_baton_t;
|
||||
|
||||
/* This spanner is write only, suitable for write-only mapped buffers,
|
||||
but can cause dark streaks where glyphs overlap, like in arabic scripts.
|
||||
|
||||
Note how spanners don't clip against surface width - resize the window
|
||||
and see what it leads to. */
|
||||
void spanner_wo(int y, int count, const FT_Span *spans, void *user)
|
||||
{
|
||||
spanner_baton_t *baton = (spanner_baton_t *)user;
|
||||
uint32_t *scanline = baton->pixels - y * ((int)baton->pitch / 4);
|
||||
if (scanline < baton->first_pixel)
|
||||
return;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
uint32_t color = ((spans[i].coverage / 2) << baton->rshift) | ((spans[i].coverage / 2) << baton->gshift) | ((spans[i].coverage / 2) << baton->bshift);
|
||||
|
||||
uint32_t *start = scanline + spans[i].x;
|
||||
if (start + spans[i].len > baton->last_pixel)
|
||||
return;
|
||||
|
||||
for (int x = 0; x < spans[i].len; x++)
|
||||
*start++ = color;
|
||||
}
|
||||
}
|
||||
|
||||
/* This spanner does read/modify/write, trading performance for accuracy.
|
||||
The color here is simply half coverage value in all channels,
|
||||
effectively mid-gray.
|
||||
Suitable for when artifacts mostly do come up and annoy.
|
||||
This might be optimized if one does rmw only for some values of x.
|
||||
But since the whole buffer has to be rw anyway, and the previous value
|
||||
is probably still in the cache, there's little point to. */
|
||||
void spanner_rw(int y, int count, const FT_Span *spans, void *user)
|
||||
{
|
||||
spanner_baton_t *baton = (spanner_baton_t *)user;
|
||||
uint32_t *scanline = baton->pixels - y * ((int)baton->pitch / 4);
|
||||
if (scanline < baton->first_pixel)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
uint32_t color = ((spans[i].coverage / 2) << baton->rshift) | ((spans[i].coverage / 2) << baton->gshift) | ((spans[i].coverage / 2) << baton->bshift);
|
||||
uint32_t *start = scanline + spans[i].x;
|
||||
if (start + spans[i].len > baton->last_pixel)
|
||||
return;
|
||||
|
||||
for (int x = 0; x < spans[i].len; x++)
|
||||
*start++ |= color;
|
||||
}
|
||||
}
|
||||
|
||||
/* This spanner is for obtaining exact bounding box for the string.
|
||||
Unfortunately this can't be done without rendering it (or pretending to).
|
||||
After this runs, we get min and max values of coordinates used.
|
||||
*/
|
||||
void spanner_sizer(int y, int count, const FT_Span *spans, void *user)
|
||||
{
|
||||
spanner_baton_t *baton = (spanner_baton_t *)user;
|
||||
|
||||
if (y < baton->min_y)
|
||||
baton->min_y = y;
|
||||
if (y > baton->max_y)
|
||||
baton->max_y = y;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (spans[i].x + spans[i].len > baton->max_span_x)
|
||||
baton->max_span_x = spans[i].x + spans[i].len;
|
||||
if (spans[i].x < baton->min_span_x)
|
||||
baton->min_span_x = spans[i].x;
|
||||
}
|
||||
}
|
||||
|
||||
FT_SpanFunc spanner = spanner_wo;
|
||||
|
||||
void ftfdump(FT_Face ftf)
|
||||
{
|
||||
for (int i = 0; i < ftf->num_charmaps; i++)
|
||||
{
|
||||
printf(
|
||||
"%d: %s %s %c%c%c%c plat=%hu id=%hu\n", i, ftf->family_name, ftf->style_name, ftf->charmaps[i]->encoding >> 24, (ftf->charmaps[i]->encoding >> 16) & 0xff,
|
||||
(ftf->charmaps[i]->encoding >> 8) & 0xff, (ftf->charmaps[i]->encoding) & 0xff, ftf->charmaps[i]->platform_id, ftf->charmaps[i]->encoding_id);
|
||||
}
|
||||
}
|
||||
|
||||
/* See http://www.microsoft.com/typography/otspec/name.htm
|
||||
for a list of some possible platform-encoding pairs.
|
||||
We're interested in 0-3 aka 3-1 - UCS-2.
|
||||
Otherwise, fail. If a font has some unicode map, but lacks
|
||||
UCS-2 - it is a broken or irrelevant font. What exactly
|
||||
Freetype will select on face load (it promises most wide
|
||||
unicode, and if that will be slower that UCS-2 - left as
|
||||
an excercise to check. */
|
||||
int force_ucs2_charmap(FT_Face ftf)
|
||||
{
|
||||
for (int i = 0; i < ftf->num_charmaps; i++)
|
||||
if (((ftf->charmaps[i]->platform_id == 0) && (ftf->charmaps[i]->encoding_id == 3)) || ((ftf->charmaps[i]->platform_id == 3) && (ftf->charmaps[i]->encoding_id == 1)))
|
||||
return FT_Set_Charmap(ftf, ftf->charmaps[i]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void hline(CDrawer *s, int min_x, int max_x, int y, uint32_t color)
|
||||
{
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
uint32_t *pix = (uint32_t *)s->pixels + (y * s->pitch) / 4 + min_x;
|
||||
uint32_t *end = (uint32_t *)s->pixels + (y * s->pitch) / 4 + max_x;
|
||||
|
||||
while (pix - 1 != end)
|
||||
*pix++ = color;
|
||||
}
|
||||
|
||||
void vline(CDrawer *s, int min_y, int max_y, int x, uint32_t color)
|
||||
{
|
||||
if (min_y < 0)
|
||||
min_y = 0;
|
||||
|
||||
uint32_t *pix = (uint32_t *)s->pixels + (min_y * s->pitch) / 4 + x;
|
||||
uint32_t *end = (uint32_t *)s->pixels + (max_y * s->pitch) / 4 + x;
|
||||
|
||||
while (pix - s->pitch / 4 != end)
|
||||
{
|
||||
*pix = color;
|
||||
pix += s->pitch / 4;
|
||||
}
|
||||
}
|
||||
|
||||
void assert(const bool &valid)
|
||||
{
|
||||
// TODO:
|
||||
}
|
||||
|
||||
#define MAIN_CC_NO_PRIVATE_API
|
||||
#ifndef MAIN_CC_NO_PRIVATE_API
|
||||
/* Only this part of this mini app uses private API */
|
||||
#include "hb-open-file.hh"
|
||||
#include "hb-ot-layout-gdef-table.hh"
|
||||
#include "hb-ot-layout-gsubgpos.hh"
|
||||
#include "hb-static.cc"
|
||||
|
||||
using namespace OT;
|
||||
|
||||
static void print_layout_info_using_private_api(hb_blob_t *blob)
|
||||
{
|
||||
const char *font_data = hb_blob_get_data(blob, nullptr);
|
||||
hb_blob_t *font_blob = hb_sanitize_context_t().sanitize_blob<OpenTypeFontFile>(blob);
|
||||
const OpenTypeFontFile *sanitized = font_blob->as<OpenTypeFontFile>();
|
||||
if (!font_blob->data)
|
||||
{
|
||||
printf("Sanitization of the file wasn't successful. Exit");
|
||||
exit(1);
|
||||
}
|
||||
const OpenTypeFontFile &ot = *sanitized;
|
||||
|
||||
switch (ot.get_tag())
|
||||
{
|
||||
case OpenTypeFontFile::TrueTypeTag:
|
||||
printf("OpenType font with TrueType outlines\n");
|
||||
break;
|
||||
case OpenTypeFontFile::CFFTag:
|
||||
printf("OpenType font with CFF (Type1) outlines\n");
|
||||
break;
|
||||
case OpenTypeFontFile::TTCTag:
|
||||
printf("TrueType Collection of OpenType fonts\n");
|
||||
break;
|
||||
case OpenTypeFontFile::TrueTag:
|
||||
printf("Obsolete Apple TrueType font\n");
|
||||
break;
|
||||
case OpenTypeFontFile::Typ1Tag:
|
||||
printf("Obsolete Apple Type1 font in SFNT container\n");
|
||||
break;
|
||||
case OpenTypeFontFile::DFontTag:
|
||||
printf("DFont Mac Resource Fork\n");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown font format\n");
|
||||
break;
|
||||
}
|
||||
|
||||
unsigned num_faces = hb_face_count(blob);
|
||||
printf("%d font(s) found in file\n", num_faces);
|
||||
for (unsigned n_font = 0; n_font < num_faces; ++n_font)
|
||||
{
|
||||
const OpenTypeFontFace &font = ot.get_face(n_font);
|
||||
printf("Font %d of %d:\n", n_font, num_faces);
|
||||
|
||||
unsigned num_tables = font.get_table_count();
|
||||
printf(" %d table(s) found in font\n", num_tables);
|
||||
for (unsigned n_table = 0; n_table < num_tables; ++n_table)
|
||||
{
|
||||
const OpenTypeTable &table = font.get_table(n_table);
|
||||
printf(" Table %2d of %2d: %.4s (0x%08x+0x%08x)\n", n_table, num_tables, (const char *)table.tag, (unsigned)table.offset, (unsigned)table.length);
|
||||
|
||||
switch (table.tag)
|
||||
{
|
||||
|
||||
case HB_OT_TAG_GSUB:
|
||||
case HB_OT_TAG_GPOS:
|
||||
{
|
||||
|
||||
const GSUBGPOS &g = *reinterpret_cast<const GSUBGPOS *>(font_data + table.offset);
|
||||
|
||||
unsigned num_scripts = g.get_script_count();
|
||||
printf(" %d script(s) found in table\n", num_scripts);
|
||||
for (unsigned n_script = 0; n_script < num_scripts; ++n_script)
|
||||
{
|
||||
const Script &script = g.get_script(n_script);
|
||||
printf(" Script %2d of %2d: %.4s\n", n_script, num_scripts, (const char *)g.get_script_tag(n_script));
|
||||
|
||||
if (!script.has_default_lang_sys())
|
||||
printf(" No default language system\n");
|
||||
int num_langsys = script.get_lang_sys_count();
|
||||
printf(" %d language system(s) found in script\n", num_langsys);
|
||||
for (int n_langsys = script.has_default_lang_sys() ? -1 : 0; n_langsys < num_langsys; ++n_langsys)
|
||||
{
|
||||
const LangSys &langsys = n_langsys == -1 ? script.get_default_lang_sys() : script.get_lang_sys(n_langsys);
|
||||
if (n_langsys == -1)
|
||||
printf(" Default Language System\n");
|
||||
else
|
||||
printf(" Language System %2d of %2d: %.4s\n", n_langsys, num_langsys, (const char *)script.get_lang_sys_tag(n_langsys));
|
||||
if (!langsys.has_required_feature())
|
||||
printf(" No required feature\n");
|
||||
else
|
||||
printf(" Required feature index: %d\n", langsys.get_required_feature_index());
|
||||
|
||||
unsigned num_features = langsys.get_feature_count();
|
||||
printf(" %d feature(s) found in language system\n", num_features);
|
||||
for (unsigned n_feature = 0; n_feature < num_features; ++n_feature)
|
||||
{
|
||||
printf(" Feature index %2d of %2d: %d\n", n_feature, num_features, langsys.get_feature_index(n_feature));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned num_features = g.get_feature_count();
|
||||
printf(" %d feature(s) found in table\n", num_features);
|
||||
for (unsigned n_feature = 0; n_feature < num_features; ++n_feature)
|
||||
{
|
||||
const Feature &feature = g.get_feature(n_feature);
|
||||
unsigned num_lookups = feature.get_lookup_count();
|
||||
printf(" Feature %2d of %2d: %c%c%c%c\n", n_feature, num_features, HB_UNTAG(g.get_feature_tag(n_feature)));
|
||||
|
||||
printf(" %d lookup(s) found in feature\n", num_lookups);
|
||||
for (unsigned n_lookup = 0; n_lookup < num_lookups; ++n_lookup)
|
||||
{
|
||||
printf(" Lookup index %2d of %2d: %d\n", n_lookup, num_lookups, feature.get_lookup_index(n_lookup));
|
||||
}
|
||||
}
|
||||
|
||||
unsigned num_lookups = g.get_lookup_count();
|
||||
printf(" %d lookup(s) found in table\n", num_lookups);
|
||||
for (unsigned n_lookup = 0; n_lookup < num_lookups; ++n_lookup)
|
||||
{
|
||||
const Lookup &lookup = g.get_lookup(n_lookup);
|
||||
printf(" Lookup %2d of %2d: type %d, props 0x%04X\n", n_lookup, num_lookups, lookup.get_type(), lookup.get_props());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GDEF::tableTag:
|
||||
{
|
||||
|
||||
const GDEF &gdef = *reinterpret_cast<const GDEF *>(font_data + table.offset);
|
||||
|
||||
printf(" Has %sglyph classes\n", gdef.has_glyph_classes() ? "" : "no ");
|
||||
printf(" Has %smark attachment types\n", gdef.has_mark_attachment_types() ? "" : "no ");
|
||||
printf(" Has %sattach points\n", gdef.has_attach_points() ? "" : "no ");
|
||||
printf(" Has %slig carets\n", gdef.has_lig_carets() ? "" : "no ");
|
||||
printf(" Has %smark sets\n", gdef.has_mark_sets() ? "" : "no ");
|
||||
|
||||
hb_position_t caret_array[16];
|
||||
unsigned int caret_count = 16;
|
||||
|
||||
unsigned int num_carets = gdef.get_lig_carets(nullptr, HB_DIRECTION_LTR, 302, 0, &caret_count, caret_array);
|
||||
int y = 0;
|
||||
++y;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* end of private API use */
|
||||
#endif
|
||||
|
||||
struct hb_feature_test {
|
||||
hb_tag_t tag;
|
||||
uint32_t value;
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// hb_blob_t* blobFileTest = hb_blob_create_from_file("C:/Windows/Fonts/calibri.ttf");
|
||||
// print_layout_info_using_private_api(blobFileTest);
|
||||
|
||||
int ptSize = 40 * 64;
|
||||
int device_hdpi = 72;
|
||||
int device_vdpi = 72;
|
||||
|
||||
/* Init freetype */
|
||||
FT_Library ft_library;
|
||||
assert(!FT_Init_FreeType(&ft_library));
|
||||
|
||||
/* Load our fonts */
|
||||
FT_Face ft_face[NUM_EXAMPLES];
|
||||
assert(!FT_New_Face(ft_library, fonts_paths[0], 0, &ft_face[ENGLISH]));
|
||||
assert(!FT_Set_Char_Size(ft_face[ENGLISH], 0, ptSize, device_hdpi, device_vdpi));
|
||||
ftfdump(ft_face[ENGLISH]); // wonderful world of encodings ...
|
||||
// force_ucs2_charmap(ft_face[ENGLISH]); // which we ignore.
|
||||
|
||||
assert(!FT_New_Face(ft_library, fonts_paths[1], 0, &ft_face[ARABIC]));
|
||||
assert(!FT_Set_Char_Size(ft_face[ARABIC], 0, ptSize, device_hdpi, device_vdpi));
|
||||
ftfdump(ft_face[ARABIC]);
|
||||
// force_ucs2_charmap(ft_face[ARABIC]);
|
||||
|
||||
assert(!FT_New_Face(ft_library, fonts_paths[2], 0, &ft_face[CHINESE]));
|
||||
assert(!FT_Set_Char_Size(ft_face[CHINESE], 0, ptSize, device_hdpi, device_vdpi));
|
||||
ftfdump(ft_face[CHINESE]);
|
||||
// force_ucs2_charmap(ft_face[CHINESE]);
|
||||
|
||||
/* Get our harfbuzz font structs */
|
||||
hb_font_t *hb_ft_font[NUM_EXAMPLES];
|
||||
hb_ft_font[ENGLISH] = hb_ft_font_create(ft_face[ENGLISH], NULL);
|
||||
|
||||
// hb_blob_t* blobFile = hb_blob_create_from_file(sFont1.c_str());
|
||||
// hb_face_t* faceFile = hb_face_create(blobFile, 0);
|
||||
// hb_ft_font[ENGLISH] = hb_font_create(faceFile);
|
||||
|
||||
hb_ft_font[ARABIC] = hb_ft_font_create(ft_face[ARABIC], NULL);
|
||||
hb_ft_font[CHINESE] = hb_ft_font_create(ft_face[CHINESE], NULL);
|
||||
|
||||
hb_ft_font_set_funcs(hb_ft_font[ENGLISH]);
|
||||
hb_ft_font_set_funcs(hb_ft_font[ARABIC]);
|
||||
hb_ft_font_set_funcs(hb_ft_font[CHINESE]);
|
||||
|
||||
/** Setup our SDL window **/
|
||||
int width = 800;
|
||||
int height = 600;
|
||||
int bpp = 32;
|
||||
|
||||
CDrawer oDrawer(width, height);
|
||||
|
||||
/* Create a buffer for harfbuzz to use */
|
||||
hb_buffer_t *buf = hb_buffer_create();
|
||||
for (int i = 0; i < NUM_EXAMPLES; ++i)
|
||||
{
|
||||
if (text_skip[i])
|
||||
continue;
|
||||
|
||||
hb_buffer_set_direction(buf, text_directions[i]); /* or LTR */
|
||||
hb_buffer_set_script(buf, scripts[i]); /* see hb-unicode.h */
|
||||
hb_buffer_set_language(buf, hb_language_from_string(languages[i], strlen(languages[i])));
|
||||
// hb_buffer_set_cluster_level (buf, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES);
|
||||
// hb_buffer_set_cluster_level (buf, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
|
||||
hb_buffer_set_cluster_level(buf, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES);
|
||||
|
||||
hb_feature_test features[] {
|
||||
{HB_TAG('r','l','i','g'), 1},
|
||||
{HB_TAG('l','i','g','a'), 0},
|
||||
{HB_TAG('c','l','i','g'), 1},
|
||||
{HB_TAG('h','l','i','g'), 1},
|
||||
{HB_TAG('d','l','i','g'), 1},
|
||||
{HB_TAG('k','e','r','n'), 2},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
int userfeatures_count = 0;
|
||||
hb_feature_t userfeatures[100];
|
||||
|
||||
hb_feature_test* current_feature = features;
|
||||
while (current_feature->tag != 0)
|
||||
{
|
||||
if (current_feature->value != 2)
|
||||
{
|
||||
userfeatures[userfeatures_count].tag = current_feature->tag;
|
||||
userfeatures[userfeatures_count].value = current_feature->value;
|
||||
userfeatures[userfeatures_count].start = HB_FEATURE_GLOBAL_START;
|
||||
userfeatures[userfeatures_count].end = HB_FEATURE_GLOBAL_END;
|
||||
userfeatures_count++;
|
||||
}
|
||||
current_feature++;
|
||||
}
|
||||
|
||||
/* Layout the text */
|
||||
hb_buffer_add_utf8(buf, texts[i], strlen(texts[i]), 0, strlen(texts[i]));
|
||||
|
||||
// detect script by codes
|
||||
hb_buffer_guess_segment_properties(buf);
|
||||
|
||||
// const char*const pHbShapers[] = { "graphite2", "coretext_aat", "ot", "fallback", nullptr };
|
||||
// bool ok = hb_shape_full(hb_ft_font[i], buf, userfeatures, userfeatures_count, pHbShapers);
|
||||
|
||||
hb_shape(hb_ft_font[i], buf, (userfeatures_count != 0) ? userfeatures : NULL, userfeatures_count);
|
||||
|
||||
unsigned int glyph_count;
|
||||
hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos(buf, &glyph_count);
|
||||
hb_glyph_position_t *glyph_pos = hb_buffer_get_glyph_positions(buf, &glyph_count);
|
||||
|
||||
#if 1
|
||||
hb_position_t caret_array[16];
|
||||
unsigned int caret_count = 16;
|
||||
|
||||
unsigned int num_carets = hb_ot_layout_get_ligature_carets(hb_ft_font[i], text_directions[i], glyph_info[0].codepoint, -1, &caret_count, caret_array);
|
||||
#endif
|
||||
|
||||
/* set up rendering via spanners */
|
||||
spanner_baton_t stuffbaton;
|
||||
|
||||
FT_Raster_Params ftr_params;
|
||||
ftr_params.target = 0;
|
||||
ftr_params.flags = FT_RASTER_FLAG_DIRECT | FT_RASTER_FLAG_AA;
|
||||
ftr_params.user = &stuffbaton;
|
||||
ftr_params.black_spans = 0;
|
||||
ftr_params.bit_set = 0;
|
||||
ftr_params.bit_test = 0;
|
||||
|
||||
/* Calculate string bounding box in pixels */
|
||||
ftr_params.gray_spans = spanner_sizer;
|
||||
|
||||
/* See http://www.freetype.org/freetype2/docs/glyphs/glyphs-3.html */
|
||||
|
||||
int max_x = INT_MIN; // largest coordinate a pixel has been set at, or the pen was advanced to.
|
||||
int min_x = INT_MAX; // smallest coordinate a pixel has been set at, or the pen was advanced to.
|
||||
int max_y = INT_MIN; // this is max topside bearing along the string.
|
||||
int min_y = INT_MAX; // this is max value of (height - topbearing) along the string.
|
||||
/* Naturally, the above comments swap their meaning between horizontal and vertical scripts,
|
||||
since the pen changes the axis it is advanced along.
|
||||
However, their differences still make up the bounding box for the string.
|
||||
Also note that all this is in FT coordinate system where y axis points upwards.
|
||||
*/
|
||||
|
||||
int sizer_x = 0;
|
||||
int sizer_y = 0; /* in FT coordinate system. */
|
||||
|
||||
printf("----------------------------------------------------\n");
|
||||
for (unsigned j = 0; j < glyph_count; ++j)
|
||||
{
|
||||
hb_ot_layout_glyph_class_t glyph_type = hb_ot_layout_get_glyph_class(hb_font_get_face(hb_ft_font[i]), glyph_info[j].codepoint);
|
||||
hb_glyph_flags_t glyph_type_flags = hb_glyph_info_get_glyph_flags(&glyph_info[j]);
|
||||
printf(
|
||||
"glyph(%s, flags: %d): gid:%d, cluster:%d, [%d, %d, %d, %d, %d]\n", num_glyph_types[glyph_type], glyph_type_flags, (int)glyph_info[j].codepoint, (int)glyph_info[j].cluster,
|
||||
glyph_pos[j].x_advance, glyph_pos[j].y_advance, glyph_pos[j].x_offset, glyph_pos[j].y_offset, glyph_pos[j].var);
|
||||
}
|
||||
|
||||
FT_Error fterr;
|
||||
for (unsigned j = 0; j < glyph_count; ++j)
|
||||
{
|
||||
if ((fterr = FT_Load_Glyph(ft_face[i], glyph_info[j].codepoint, 0)))
|
||||
{
|
||||
printf("load %08x failed fterr=%d.\n", glyph_info[j].codepoint, fterr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ft_face[i]->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
|
||||
{
|
||||
printf("glyph->format = %4s\n", (char *)&ft_face[i]->glyph->format);
|
||||
}
|
||||
else
|
||||
{
|
||||
int gx = sizer_x + (glyph_pos[j].x_offset / 64);
|
||||
int gy = sizer_y + (glyph_pos[j].y_offset / 64); // note how the sign differs from the rendering pass
|
||||
|
||||
stuffbaton.min_span_x = INT_MAX;
|
||||
stuffbaton.max_span_x = INT_MIN;
|
||||
stuffbaton.min_y = INT_MAX;
|
||||
stuffbaton.max_y = INT_MIN;
|
||||
|
||||
if ((fterr = FT_Outline_Render(ft_library, &ft_face[i]->glyph->outline, &ftr_params)))
|
||||
printf("FT_Outline_Render() failed err=%d\n", fterr);
|
||||
|
||||
if (stuffbaton.min_span_x != INT_MAX)
|
||||
{
|
||||
/* Update values if the spanner was actually called. */
|
||||
if (min_x > stuffbaton.min_span_x + gx)
|
||||
min_x = stuffbaton.min_span_x + gx;
|
||||
|
||||
if (max_x < stuffbaton.max_span_x + gx)
|
||||
max_x = stuffbaton.max_span_x + gx;
|
||||
|
||||
if (min_y > stuffbaton.min_y + gy)
|
||||
min_y = stuffbaton.min_y + gy;
|
||||
|
||||
if (max_y < stuffbaton.max_y + gy)
|
||||
max_y = stuffbaton.max_y + gy;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The spanner wasn't called at all - an empty glyph, like space. */
|
||||
if (min_x > gx)
|
||||
min_x = gx;
|
||||
if (max_x < gx)
|
||||
max_x = gx;
|
||||
if (min_y > gy)
|
||||
min_y = gy;
|
||||
if (max_y < gy)
|
||||
max_y = gy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sizer_x += glyph_pos[j].x_advance / 64;
|
||||
sizer_y += glyph_pos[j].y_advance / 64; // note how the sign differs from the rendering pass
|
||||
}
|
||||
/* Still have to take into account last glyph's advance. Or not? */
|
||||
if (min_x > sizer_x)
|
||||
min_x = sizer_x;
|
||||
if (max_x < sizer_x)
|
||||
max_x = sizer_x;
|
||||
if (min_y > sizer_y)
|
||||
min_y = sizer_y;
|
||||
if (max_y < sizer_y)
|
||||
max_y = sizer_y;
|
||||
|
||||
/* The bounding box */
|
||||
int bbox_w = max_x - min_x;
|
||||
int bbox_h = max_y - min_y;
|
||||
|
||||
/* Two offsets below position the bounding box with respect to the 'origin',
|
||||
which is sort of origin of string's first glyph.
|
||||
|
||||
baseline_offset - offset perpendecular to the baseline to the topmost (horizontal),
|
||||
or leftmost (vertical) pixel drawn.
|
||||
|
||||
baseline_shift - offset along the baseline, from the first drawn glyph's origin
|
||||
to the leftmost (horizontal), or topmost (vertical) pixel drawn.
|
||||
|
||||
Thus those offsets allow positioning the bounding box to fit the rendered string,
|
||||
as they are in fact offsets from the point given to the renderer, to the top left
|
||||
corner of the bounding box.
|
||||
|
||||
NB: baseline is defined as y==0 for horizontal and x==0 for vertical scripts.
|
||||
(0,0) here is where the first glyph's origin ended up after shaping, not taking
|
||||
into account glyph_pos[0].xy_offset (yeah, my head hurts too).
|
||||
*/
|
||||
|
||||
int baseline_offset;
|
||||
int baseline_shift;
|
||||
|
||||
if (HB_DIRECTION_IS_HORIZONTAL(hb_buffer_get_direction(buf)))
|
||||
{
|
||||
baseline_offset = max_y;
|
||||
baseline_shift = min_x;
|
||||
}
|
||||
if (HB_DIRECTION_IS_VERTICAL(hb_buffer_get_direction(buf)))
|
||||
{
|
||||
baseline_offset = min_x;
|
||||
baseline_shift = max_y;
|
||||
}
|
||||
|
||||
/* The pen/baseline start coordinates in window coordinate system
|
||||
- with those text placement in the window is controlled.
|
||||
- note that for RTL scripts pen still goes LTR */
|
||||
int x = 0, y = 50 + i * 75;
|
||||
if (i == ENGLISH)
|
||||
{
|
||||
x = 20;
|
||||
} /* left justify */
|
||||
if (i == ARABIC)
|
||||
{
|
||||
x = width - bbox_w - 20;
|
||||
} /* right justify */
|
||||
if (i == CHINESE)
|
||||
{
|
||||
x = width / 2 - bbox_w / 2;
|
||||
} /* center, and for TTB script h_advance is half-width. */
|
||||
|
||||
/* Draw baseline and the bounding box */
|
||||
/* The below is complicated since we simultaneously
|
||||
convert to the window coordinate system. */
|
||||
int left, right, top, bottom;
|
||||
|
||||
if (HB_DIRECTION_IS_HORIZONTAL(hb_buffer_get_direction(buf)))
|
||||
{
|
||||
/* bounding box in window coordinates without offsets */
|
||||
left = x;
|
||||
right = x + bbox_w;
|
||||
top = y - bbox_h;
|
||||
bottom = y;
|
||||
|
||||
/* apply offsets */
|
||||
left += baseline_shift;
|
||||
right += baseline_shift;
|
||||
top -= baseline_offset - bbox_h;
|
||||
bottom -= baseline_offset - bbox_h;
|
||||
|
||||
/* draw the baseline */
|
||||
hline(&oDrawer, x, x + bbox_w, y, 0x0000ff00);
|
||||
}
|
||||
|
||||
if (HB_DIRECTION_IS_VERTICAL(hb_buffer_get_direction(buf)))
|
||||
{
|
||||
left = x;
|
||||
right = x + bbox_w;
|
||||
top = y;
|
||||
bottom = y + bbox_h;
|
||||
|
||||
left += baseline_offset;
|
||||
right += baseline_offset;
|
||||
top -= baseline_shift;
|
||||
bottom -= baseline_shift;
|
||||
|
||||
vline(&oDrawer, y, y + bbox_h, x, 0x0000ff00);
|
||||
}
|
||||
|
||||
/* +1/-1 are for the bbox borders be the next pixel outside the bbox itself */
|
||||
hline(&oDrawer, left - 1, right + 1, top - 1, 0xffff0000);
|
||||
hline(&oDrawer, left - 1, right + 1, bottom + 1, 0xffff0000);
|
||||
vline(&oDrawer, top - 1, bottom + 1, left - 1, 0xffff0000);
|
||||
vline(&oDrawer, top - 1, bottom + 1, right + 1, 0xffff0000);
|
||||
|
||||
/* set rendering spanner */
|
||||
ftr_params.gray_spans = spanner;
|
||||
|
||||
/* initialize rendering part of the baton */
|
||||
stuffbaton.pixels = NULL;
|
||||
stuffbaton.first_pixel = (uint32_t *)oDrawer.pixels;
|
||||
stuffbaton.last_pixel = (uint32_t *)(((uint8_t *)oDrawer.pixels) + oDrawer.pitch * oDrawer.height);
|
||||
stuffbaton.pitch = oDrawer.pitch;
|
||||
stuffbaton.rshift = oDrawer.Rshift;
|
||||
stuffbaton.gshift = oDrawer.Gshift;
|
||||
stuffbaton.bshift = oDrawer.Bshift;
|
||||
|
||||
/* render */
|
||||
for (unsigned j = 0; j < glyph_count; ++j)
|
||||
{
|
||||
if ((fterr = FT_Load_Glyph(ft_face[i], glyph_info[j].codepoint, 0)))
|
||||
{
|
||||
printf("load %08x failed fterr=%d.\n", glyph_info[j].codepoint, fterr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ft_face[i]->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
|
||||
{
|
||||
printf("glyph->format = %4s\n", (char *)&ft_face[i]->glyph->format);
|
||||
}
|
||||
else
|
||||
{
|
||||
int gx = x + (glyph_pos[j].x_offset / 64);
|
||||
int gy = y - (glyph_pos[j].y_offset / 64);
|
||||
|
||||
stuffbaton.pixels = (uint32_t *)(((uint8_t *)oDrawer.pixels) + gy * oDrawer.pitch) + gx;
|
||||
|
||||
if ((fterr = FT_Outline_Render(ft_library, &ft_face[i]->glyph->outline, &ftr_params)))
|
||||
printf("FT_Outline_Render() failed err=%d\n", fterr);
|
||||
}
|
||||
}
|
||||
|
||||
x += glyph_pos[j].x_advance / 64;
|
||||
y -= glyph_pos[j].y_advance / 64;
|
||||
}
|
||||
|
||||
/* clean up the buffer, but don't kill it just yet */
|
||||
hb_buffer_clear_contents(buf);
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
hb_buffer_destroy(buf);
|
||||
for (int i = 0; i < NUM_EXAMPLES; ++i)
|
||||
hb_font_destroy(hb_ft_font[i]);
|
||||
|
||||
FT_Done_FreeType(ft_library);
|
||||
|
||||
oDrawer.Save();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
CONFIG -= qt
|
||||
TARGET = test
|
||||
TEMPLATE = app
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../../../core
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
include($$CORE_ROOT_DIR/DesktopEditor/graphics/pro/freetype.pri)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/harfbuzz/harfbuzz.pri)
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
ADD_DEPENDENCY(UnicodeConverter, kernel, graphics)
|
||||
DESTDIR = $$PWD/build
|
||||
|
||||
|
||||
4
Common/3dParty/heif/.gitignore
vendored
4
Common/3dParty/heif/.gitignore
vendored
@ -1,4 +0,0 @@
|
||||
x265_git
|
||||
libde265
|
||||
libheif
|
||||
ios-cmake
|
||||
@ -1,42 +0,0 @@
|
||||
DEFINES += LIBHEIF_STATIC_BUILD
|
||||
|
||||
HEIF_BUILDS_PLATFORM_PREFIX = $$CORE_BUILDS_PLATFORM_PREFIX
|
||||
core_ios : xcframework_platform_ios_simulator {
|
||||
HEIF_BUILDS_PLATFORM_PREFIX = ios_simulator
|
||||
}
|
||||
|
||||
HEIF_BUILD_PATH = $$PWD/libheif/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$PWD/libheif/libheif/api \
|
||||
$$HEIF_BUILD_PATH # for heif_version.h
|
||||
|
||||
core_windows {
|
||||
core_debug {
|
||||
BUILD_TYPE = Debug
|
||||
} else {
|
||||
BUILD_TYPE = Release
|
||||
}
|
||||
|
||||
LIBS += \
|
||||
-L$$PWD/x265_git/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX/$$BUILD_TYPE -lx265-static \
|
||||
-L$$PWD/libde265/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX/libde265/$$BUILD_TYPE -llibde265 \
|
||||
-L$$HEIF_BUILD_PATH/libheif/$$BUILD_TYPE -lheif
|
||||
}
|
||||
|
||||
core_linux | core_android {
|
||||
# we need to wrap x265 and de265 libraries in `whole-archive` flags to avoid "undefined symbol" errors when later linking with graphics.so
|
||||
LIBS += \
|
||||
-Wl,--whole-archive \
|
||||
-L$$PWD/x265_git/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX -lx265 \
|
||||
-L$$PWD/libde265/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX/libde265 -lde265 \
|
||||
-Wl,--no-whole-archive \
|
||||
-L$$HEIF_BUILD_PATH/libheif -lheif
|
||||
}
|
||||
|
||||
core_mac | core_ios {
|
||||
LIBS += \
|
||||
-L$$PWD/x265_git/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX -lx265 \
|
||||
-L$$PWD/libde265/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX/libde265 -lde265 \
|
||||
-L$$HEIF_BUILD_PATH/libheif -lheif
|
||||
}
|
||||
@ -12,20 +12,20 @@
|
||||
#include "StaticFunctions.h"
|
||||
#include "ConstValues.h"
|
||||
|
||||
#define DEFAULT_FONT_SIZE 12
|
||||
#define DEFAULT_FONT_SIZE 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,13 +44,10 @@ 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;
|
||||
|
||||
m_arParentsStyles.insert(oElement.m_arParentsStyles.begin(), oElement.m_arParentsStyles.end());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -69,9 +66,6 @@ namespace NSCSS
|
||||
m_oPadding = oElement.m_oPadding;
|
||||
m_oText = oElement.m_oText;
|
||||
m_oDisplay = oElement.m_oDisplay;
|
||||
m_oTransform = oElement.m_oTransform;
|
||||
|
||||
m_arParentsStyles = oElement.m_arParentsStyles;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -84,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)
|
||||
@ -97,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)
|
||||
@ -113,8 +105,7 @@ namespace NSCSS
|
||||
bool CCompiledStyle::Empty() const
|
||||
{
|
||||
return m_oBackground.Empty() && m_oBorder.Empty() && m_oFont.Empty() &&
|
||||
m_oMargin.Empty() && m_oPadding.Empty() && m_oText.Empty() &&
|
||||
m_oDisplay.Empty() && m_oTransform.Empty();
|
||||
m_oMargin.Empty() && m_oPadding.Empty() && m_oText.Empty() && m_oDisplay.Empty();
|
||||
}
|
||||
|
||||
void CCompiledStyle::AddPropSel(const std::wstring& sProperty, const std::wstring& sValue, const unsigned int unLevel, const bool& bHardMode)
|
||||
@ -125,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)
|
||||
{
|
||||
@ -140,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"):
|
||||
@ -188,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"):
|
||||
@ -208,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"):
|
||||
@ -218,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"):
|
||||
@ -229,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
|
||||
@ -237,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
|
||||
@ -319,7 +307,6 @@ namespace NSCSS
|
||||
}
|
||||
//BORDER TOP
|
||||
CASE(L"border-top"):
|
||||
CASE(L"mso-border-top-alt"):
|
||||
{
|
||||
m_oBorder.SetTopSide(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
@ -341,7 +328,6 @@ namespace NSCSS
|
||||
}
|
||||
//BORDER RIGHT
|
||||
CASE(L"border-right"):
|
||||
CASE(L"mso-border-right-alt"):
|
||||
{
|
||||
m_oBorder.SetRightSide(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
@ -363,7 +349,6 @@ namespace NSCSS
|
||||
}
|
||||
//BORDER bottom
|
||||
CASE(L"border-bottom"):
|
||||
CASE(L"mso-border-bottom-alt"):
|
||||
{
|
||||
m_oBorder.SetBottomSide(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
@ -385,7 +370,6 @@ namespace NSCSS
|
||||
}
|
||||
//BORDER LEFT
|
||||
CASE(L"border-left"):
|
||||
CASE(L"mso-border-left-alt"):
|
||||
{
|
||||
m_oBorder.SetLeftSide(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
@ -444,17 +428,6 @@ namespace NSCSS
|
||||
m_oDisplay.SetVAlign(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
}
|
||||
CASE(L"white-space"):
|
||||
{
|
||||
m_oDisplay.SetWhiteSpace(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
}
|
||||
//TRANSFORM
|
||||
CASE(L"transform"):
|
||||
{
|
||||
m_oTransform.SetMatrix(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
}
|
||||
default: AddOtherStyle(pPropertie, unLevel, bHardMode);
|
||||
}
|
||||
}
|
||||
@ -535,7 +508,7 @@ namespace NSCSS
|
||||
{
|
||||
return m_sId;
|
||||
}
|
||||
|
||||
|
||||
bool CCompiledStyle::HaveThisParent(const std::wstring &wsParentName) const
|
||||
{
|
||||
return m_arParentsStyles.end() != m_arParentsStyles.find(wsParentName);
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
#ifndef CCOMPILEDSTYLE_H
|
||||
#define CCOMPILEDSTYLE_H
|
||||
|
||||
#include "CssCalculator_global.h"
|
||||
#include "ConstValues.h"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
@ -19,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;
|
||||
@ -28,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);
|
||||
|
||||
@ -13,9 +13,14 @@ namespace NSCSS
|
||||
delete m_pInternal;
|
||||
}
|
||||
|
||||
bool CCssCalculator::CalculateCompiledStyle(std::vector<CNode>& arSelectors) const
|
||||
CCompiledStyle CCssCalculator::GetCompiledStyle(const std::vector<CNode> &arSelectors, const bool& bIsSettings, const UnitMeasure& unitMeasure) const
|
||||
{
|
||||
return m_pInternal->CalculateCompiledStyle(arSelectors);
|
||||
return m_pInternal->GetCompiledStyle(arSelectors, bIsSettings, unitMeasure);
|
||||
}
|
||||
|
||||
bool CCssCalculator::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors, const bool &bIsSettings, const UnitMeasure &unitMeasure) const
|
||||
{
|
||||
return m_pInternal->GetCompiledStyle(oStyle, arSelectors, bIsSettings, unitMeasure);
|
||||
}
|
||||
|
||||
std::wstring CCssCalculator::CalculateStyleId(const CNode& oNode)
|
||||
@ -43,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();
|
||||
@ -58,31 +78,6 @@ namespace NSCSS
|
||||
return m_pInternal->GetDpi();
|
||||
}
|
||||
|
||||
bool CCssCalculator::HaveStylesById(const std::wstring& wsId) const
|
||||
{
|
||||
return m_pInternal->HaveStylesById(wsId);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
@ -2,8 +2,10 @@
|
||||
#define CCSSCALCULATOR_H
|
||||
|
||||
#include "CssCalculator_global.h"
|
||||
#include "StyleProperties.h"
|
||||
#include "CNode.h"
|
||||
#include "CCompiledStyle.h"
|
||||
#include "ConstValues.h"
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
namespace NSCSS
|
||||
@ -17,7 +19,8 @@ namespace NSCSS
|
||||
CCssCalculator();
|
||||
~CCssCalculator();
|
||||
|
||||
bool CalculateCompiledStyle(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);
|
||||
@ -27,17 +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;
|
||||
|
||||
bool HaveStylesById(const std::wstring& wsId) const;
|
||||
|
||||
void ClearPageData();
|
||||
void ClearEmbeddedStyles();
|
||||
void ClearAllowedStyleFiles();
|
||||
void ClearStylesFromFile(const std::wstring& wsFilePath);
|
||||
void Clear();
|
||||
};
|
||||
}
|
||||
|
||||
@ -2,10 +2,15 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <numeric>
|
||||
|
||||
#include "../../katana-parser/src/selector.h"
|
||||
#include "../../../../../UnicodeConverter/UnicodeConverter.h"
|
||||
#include "ConstValues.h"
|
||||
#include "../../../../../DesktopEditor/common/File.h"
|
||||
#include "StaticFunctions.h"
|
||||
|
||||
@ -36,120 +41,61 @@ bool operator<(const std::vector<NSCSS::CNode> &arLeftSelectors, const std::vect
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
CStyleStorage::CStyleStorage()
|
||||
{}
|
||||
CCssCalculator_Private::CCssCalculator_Private() : m_nDpi(96), m_nCountNodes(0), m_UnitMeasure(Point), m_mStatictics(NULL), m_sEncoding(L"UTF-8"){}
|
||||
|
||||
CStyleStorage::~CStyleStorage()
|
||||
CCssCalculator_Private::~CCssCalculator_Private()
|
||||
{
|
||||
Clear();
|
||||
m_arFiles.clear();
|
||||
|
||||
for (std::map<std::wstring, CElement*>::iterator oIter = m_mData.begin(); oIter != m_mData.end(); ++oIter)
|
||||
if (oIter->second != NULL)
|
||||
delete oIter->second;
|
||||
|
||||
m_mData.clear();
|
||||
|
||||
if (NULL != m_mStatictics)
|
||||
delete m_mStatictics;
|
||||
}
|
||||
|
||||
void CStyleStorage::Clear()
|
||||
inline void CCssCalculator_Private::GetOutputData(KatanaOutput *oOutput)
|
||||
{
|
||||
for (TStyleFileData* pStyleFileData : m_arStyleFiles)
|
||||
{
|
||||
if (nullptr == pStyleFileData)
|
||||
continue;
|
||||
|
||||
for (std::map<std::wstring, CElement*>::iterator oIter = pStyleFileData->m_mStyleData.begin(); oIter != pStyleFileData->m_mStyleData.end(); ++oIter)
|
||||
if (oIter->second != nullptr)
|
||||
delete oIter->second;
|
||||
|
||||
delete pStyleFileData;
|
||||
}
|
||||
|
||||
m_arStyleFiles.clear();
|
||||
m_arEmptyStyleFiles.clear();
|
||||
|
||||
ClearEmbeddedStyles();
|
||||
ClearAllowedStyleFiles();
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
ClearPageData();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CStyleStorage::AddStyles(const std::string& sStyle)
|
||||
{
|
||||
if (sStyle.empty())
|
||||
if ( NULL == oOutput )
|
||||
return;
|
||||
|
||||
KatanaOutput *output = katana_parse(sStyle.c_str(), sStyle.length(), KatanaParserModeStylesheet);
|
||||
this->GetOutputData(output, m_mEmbeddedStyleData);
|
||||
katana_destroy_output(output);
|
||||
}
|
||||
|
||||
void CStyleStorage::AddStyles(const std::wstring& wsStyle)
|
||||
{
|
||||
if (wsStyle.empty())
|
||||
return;
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
std::wregex oRegex(L"@page\\s*([^{]*)(\\{[^}]*\\})");
|
||||
std::wsmatch oMatch;
|
||||
std::wstring::const_iterator oSearchStart(wsStyle.cbegin());
|
||||
|
||||
while (std::regex_search(oSearchStart, wsStyle.cend(), oMatch, oRegex))
|
||||
{
|
||||
AddPageData(oMatch[1].str(), oMatch[2].str());
|
||||
oSearchStart = oMatch.suffix().first;
|
||||
switch (oOutput->mode) {
|
||||
case KatanaParserModeStylesheet:
|
||||
GetStylesheet(oOutput->stylesheet);
|
||||
break;
|
||||
case KatanaParserModeRule:
|
||||
GetRule(oOutput->rule);
|
||||
break;
|
||||
case KatanaParserModeKeyframeRule:
|
||||
case KatanaParserModeKeyframeKeyList:
|
||||
case KatanaParserModeMediaList:
|
||||
case KatanaParserModeValue:
|
||||
case KatanaParserModeSelector:
|
||||
case KatanaParserModeDeclarationList:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
AddStyles(U_TO_UTF8(wsStyle));
|
||||
}
|
||||
|
||||
void CStyleStorage::AddStylesFromFile(const std::wstring& wsFileName)
|
||||
{
|
||||
std::set<std::wstring>::const_iterator itEmptyFileFound = m_arEmptyStyleFiles.find(wsFileName);
|
||||
|
||||
if (m_arEmptyStyleFiles.cend() != itEmptyFileFound)
|
||||
return;
|
||||
|
||||
std::vector<TStyleFileData*>::const_iterator itFound = std::find_if(m_arStyleFiles.cbegin(), m_arStyleFiles.cend(),
|
||||
[wsFileName](const TStyleFileData* pStyleFileData)
|
||||
{ return wsFileName == pStyleFileData->m_wsStyleFilepath; });
|
||||
|
||||
m_arAllowedStyleFiles.insert(wsFileName);
|
||||
|
||||
if (m_arStyleFiles.cend() != itFound)
|
||||
return;
|
||||
|
||||
TStyleFileData *pStyleFileData = new TStyleFileData();
|
||||
|
||||
pStyleFileData->m_wsStyleFilepath = wsFileName;
|
||||
|
||||
AddStyles(NS_STATIC_FUNCTIONS::GetContentAsUTF8(wsFileName), pStyleFileData->m_mStyleData);
|
||||
|
||||
if (!pStyleFileData->m_mStyleData.empty())
|
||||
m_arStyleFiles.push_back(pStyleFileData);
|
||||
else
|
||||
{
|
||||
m_arEmptyStyleFiles.insert(wsFileName);
|
||||
delete pStyleFileData;
|
||||
}
|
||||
}
|
||||
|
||||
void CStyleStorage::ClearStylesFromFile(const std::wstring& wsFileName)
|
||||
{
|
||||
std::vector<TStyleFileData*>::const_iterator itFound = std::find_if(m_arStyleFiles.cbegin(), m_arStyleFiles.cend(),
|
||||
[wsFileName](const TStyleFileData* pStyleFileData)
|
||||
{ return wsFileName == pStyleFileData->m_wsStyleFilepath; });
|
||||
|
||||
if (m_arStyleFiles.cend() != itFound)
|
||||
{
|
||||
m_arStyleFiles.erase(itFound);
|
||||
delete *itFound;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
void CStyleStorage::AddPageData(const std::wstring& wsPageName, const std::wstring& wsStyles)
|
||||
std::map<std::wstring, std::wstring> CCssCalculator_Private::GetPageData(const std::wstring &wsPageName)
|
||||
{
|
||||
m_arPageDatas.push_back({NS_STATIC_FUNCTIONS::GetWordsW(wsPageName), NS_STATIC_FUNCTIONS::GetRules(wsStyles)});
|
||||
}
|
||||
if (m_arPageDatas.empty())
|
||||
return {};
|
||||
|
||||
void CStyleStorage::SetPageData(NSProperties::CPage& oPage, const std::map<std::wstring, std::wstring>& mData, unsigned int unLevel, bool bHardMode)
|
||||
for (const TPageData& oPageData : m_arPageDatas)
|
||||
{
|
||||
if (std::find(oPageData.m_wsNames.begin(), oPageData.m_wsNames.end(), wsPageName) != oPageData.m_wsNames.end())
|
||||
return oPageData.m_mData;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::SetPageData(NSProperties::CPage &oPage, const std::map<std::wstring, std::wstring> &mData, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
for (const std::pair<std::wstring, std::wstring> &oData : mData)
|
||||
{
|
||||
@ -164,84 +110,162 @@ namespace NSCSS
|
||||
}
|
||||
}
|
||||
|
||||
std::map<std::wstring, std::wstring> CStyleStorage::GetPageData(const std::wstring& wsPageName)
|
||||
std::vector<std::wstring> CCssCalculator_Private::CalculateAllNodes(const std::vector<CNode> &arSelectors)
|
||||
{
|
||||
if (m_arPageDatas.empty())
|
||||
return {};
|
||||
|
||||
for (const TPageData& oPageData : m_arPageDatas)
|
||||
std::vector<std::wstring> arNodes;
|
||||
|
||||
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend(); ++oNode)
|
||||
{
|
||||
if (std::find(oPageData.m_wsNames.begin(), oPageData.m_wsNames.end(), wsPageName) != oPageData.m_wsNames.end())
|
||||
return oPageData.m_mData;
|
||||
if (!oNode->m_wsName.empty())
|
||||
arNodes.push_back(oNode->m_wsName);
|
||||
|
||||
if (!oNode->m_wsClass.empty())
|
||||
{
|
||||
if (oNode->m_wsClass.find(L' ') != std::wstring::npos)
|
||||
{
|
||||
std::vector<std::wstring> arClasses = NS_STATIC_FUNCTIONS::GetWordsW(oNode->m_wsClass, false, L" ");
|
||||
|
||||
arNodes.push_back(std::accumulate(arClasses.begin(), arClasses.end(), std::wstring(),
|
||||
[](std::wstring sRes, const std::wstring& sClass)
|
||||
{return sRes += L'.' + sClass + L' ';}));
|
||||
}
|
||||
else
|
||||
arNodes.push_back(L'.' + oNode->m_wsClass);
|
||||
}
|
||||
|
||||
if (!oNode->m_wsId.empty())
|
||||
arNodes.push_back(L'#' + oNode->m_wsId);
|
||||
}
|
||||
|
||||
return {};
|
||||
return arNodes;
|
||||
}
|
||||
|
||||
void CStyleStorage::ClearPageData()
|
||||
void CCssCalculator_Private::FindPrevAndKindElements(const CElement *pElement, const std::vector<std::wstring> &arNextNodes, std::vector<CElement*>& arFindedElements, const std::wstring &wsName, const std::vector<std::wstring> &arClasses)
|
||||
{
|
||||
m_arPageDatas.clear();
|
||||
if (arNextNodes.empty())
|
||||
return;
|
||||
|
||||
const std::vector<CElement*> arTempPrev = pElement->GetPrevElements(arNextNodes.crbegin() + 1, arNextNodes.crend());
|
||||
const std::vector<CElement*> arTempKins = pElement->GetNextOfKin(wsName, arClasses);
|
||||
|
||||
if (!arTempPrev.empty())
|
||||
arFindedElements.insert(arFindedElements.end(), arTempPrev.begin(), arTempPrev.end());
|
||||
|
||||
if (!arTempKins.empty())
|
||||
arFindedElements.insert(arFindedElements.end(), arTempKins.begin(), arTempKins.end());
|
||||
}
|
||||
|
||||
std::vector<CElement*> CCssCalculator_Private::FindElements(std::vector<std::wstring> &arNodes, std::vector<std::wstring> &arNextNodes, bool bIsSettings)
|
||||
{
|
||||
if (arNodes.empty())
|
||||
return {};
|
||||
|
||||
std::vector<CElement*> arFindedElements;
|
||||
|
||||
std::wstring wsName, wsId;
|
||||
std::vector<std::wstring> arClasses;
|
||||
|
||||
if (!arNodes.empty() && arNodes.back()[0] == L'#')
|
||||
{
|
||||
wsId = arNodes.back();
|
||||
arNodes.pop_back();
|
||||
arNextNodes.push_back(wsId);
|
||||
}
|
||||
|
||||
if (!arNodes.empty() && arNodes.back()[0] == L'.')
|
||||
{
|
||||
arClasses = NS_STATIC_FUNCTIONS::GetWordsW(arNodes.back(), false, L" ");
|
||||
arNextNodes.push_back(arNodes.back());
|
||||
arNodes.pop_back();
|
||||
}
|
||||
|
||||
if (!arNodes.empty())
|
||||
{
|
||||
wsName = arNodes.back();
|
||||
arNodes.pop_back();
|
||||
arNextNodes.push_back(wsName);
|
||||
}
|
||||
|
||||
const std::map<std::wstring, CElement*>::const_iterator oFindName = m_mData.find(wsName);
|
||||
std::map<std::wstring, CElement*>::const_iterator oFindId;
|
||||
|
||||
if (!wsId.empty())
|
||||
{
|
||||
oFindId = m_mData.find(wsId);
|
||||
|
||||
if (oFindId != m_mData.end() && NULL != m_mStatictics)
|
||||
{
|
||||
std::map<StatistickElement, unsigned int>::const_iterator oFindCountId = m_mStatictics->find(StatistickElement{StatistickElement::IsId, wsId});
|
||||
|
||||
if ((m_mStatictics->end() != oFindCountId) &&
|
||||
(((bIsSettings && oFindCountId->second < MaxNumberRepetitions) ||
|
||||
(!bIsSettings && oFindCountId->second >= MaxNumberRepetitions))))
|
||||
{
|
||||
if (!oFindId->second->Empty())
|
||||
arFindedElements.push_back(oFindId->second);
|
||||
}
|
||||
|
||||
FindPrevAndKindElements(oFindId->second, arNextNodes, arFindedElements, wsName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!arClasses.empty())
|
||||
{
|
||||
if (!bIsSettings)
|
||||
{
|
||||
for (std::vector<std::wstring>::const_reverse_iterator iClass = arClasses.rbegin(); iClass != arClasses.rend(); ++iClass)
|
||||
{
|
||||
const std::map<std::wstring, CElement*>::const_iterator oFindClass = m_mData.find(*iClass);
|
||||
if (oFindClass != m_mData.end())
|
||||
{
|
||||
if (!oFindClass->second->Empty())
|
||||
arFindedElements.push_back(oFindClass->second);
|
||||
|
||||
FindPrevAndKindElements(oFindClass->second, arNextNodes, arFindedElements, wsName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (oFindName != m_mData.end())
|
||||
{
|
||||
if (!bIsSettings)
|
||||
{
|
||||
if (!oFindName->second->Empty())
|
||||
arFindedElements.push_back(oFindName->second);
|
||||
|
||||
FindPrevAndKindElements(oFindName->second, arNextNodes, arFindedElements, wsName, arClasses);
|
||||
}
|
||||
}
|
||||
|
||||
if (arFindedElements.size() > 1)
|
||||
{
|
||||
std::sort(arFindedElements.rbegin(), arFindedElements.rend(),
|
||||
[](CElement* oFirstElement, CElement* oSecondElement)
|
||||
{
|
||||
return oFirstElement->GetWeight() > oSecondElement->GetWeight();
|
||||
});
|
||||
}
|
||||
|
||||
return arFindedElements;
|
||||
}
|
||||
#endif
|
||||
|
||||
const CElement* CStyleStorage::FindElement(const std::wstring& wsSelector) const
|
||||
void CCssCalculator_Private::AddPageData(const std::wstring &wsPageNames, const std::wstring &wsStyles)
|
||||
{
|
||||
if (wsSelector.empty())
|
||||
return nullptr;
|
||||
|
||||
const CElement* pFoundElement = FindSelectorFromStyleData(wsSelector, m_mEmbeddedStyleData);
|
||||
|
||||
if (nullptr != pFoundElement)
|
||||
return pFoundElement;
|
||||
|
||||
for (std::vector<TStyleFileData*>::const_reverse_iterator itIter = m_arStyleFiles.crbegin(); itIter < m_arStyleFiles.crend(); ++itIter)
|
||||
{
|
||||
if (m_arAllowedStyleFiles.cend() == std::find(m_arAllowedStyleFiles.cbegin(), m_arAllowedStyleFiles.cend(), (*itIter)->m_wsStyleFilepath))
|
||||
continue;
|
||||
|
||||
pFoundElement = FindSelectorFromStyleData(wsSelector, (*itIter)->m_mStyleData);
|
||||
|
||||
if (nullptr != pFoundElement)
|
||||
return pFoundElement;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
m_arPageDatas.push_back({NS_STATIC_FUNCTIONS::GetWordsW(wsPageNames), NS_STATIC_FUNCTIONS::GetRules(wsStyles)});
|
||||
}
|
||||
|
||||
void CStyleStorage::AddStyles(const std::string& sStyle, std::map<std::wstring, CElement*>& mStyleData)
|
||||
{
|
||||
if (sStyle.empty())
|
||||
return;
|
||||
|
||||
KatanaOutput *output = katana_parse(sStyle.c_str(), sStyle.length(), KatanaParserModeStylesheet);
|
||||
this->GetOutputData(output, mStyleData);
|
||||
katana_destroy_output(output);
|
||||
}
|
||||
|
||||
void CStyleStorage::ClearEmbeddedStyles()
|
||||
{
|
||||
for (std::map<std::wstring, CElement*>::iterator oIter = m_mEmbeddedStyleData.begin(); oIter != m_mEmbeddedStyleData.end(); ++oIter)
|
||||
if (oIter->second != nullptr)
|
||||
delete oIter->second;
|
||||
|
||||
m_mEmbeddedStyleData.clear();
|
||||
}
|
||||
|
||||
void CStyleStorage::ClearAllowedStyleFiles()
|
||||
{
|
||||
m_arAllowedStyleFiles.clear();
|
||||
}
|
||||
|
||||
void CStyleStorage::GetStylesheet(const KatanaStylesheet* oStylesheet, std::map<std::wstring, CElement*>& mStyleData)
|
||||
|
||||
inline void CCssCalculator_Private::GetStylesheet(const KatanaStylesheet *oStylesheet)
|
||||
{
|
||||
for (size_t i = 0; i < oStylesheet->imports.length; ++i)
|
||||
GetRule((KatanaRule*)oStylesheet->imports.data[i], mStyleData);
|
||||
GetRule((KatanaRule*)oStylesheet->imports.data[i]);
|
||||
|
||||
for (size_t i = 0; i < oStylesheet->rules.length; ++i)
|
||||
GetRule((KatanaRule*)oStylesheet->rules.data[i], mStyleData);
|
||||
GetRule((KatanaRule*)oStylesheet->rules.data[i]);
|
||||
}
|
||||
|
||||
void CStyleStorage::GetRule(const KatanaRule* oRule, std::map<std::wstring, CElement*>& mStyleData)
|
||||
inline void CCssCalculator_Private::GetRule(const KatanaRule *oRule)
|
||||
{
|
||||
if ( NULL == oRule )
|
||||
return;
|
||||
@ -249,7 +273,7 @@ namespace NSCSS
|
||||
switch (oRule->type) {
|
||||
case KatanaRuleStyle:
|
||||
{
|
||||
GetStyleRule((KatanaStyleRule*)oRule, mStyleData);
|
||||
GetStyleRule((KatanaStyleRule*)oRule);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -257,7 +281,7 @@ namespace NSCSS
|
||||
}
|
||||
}
|
||||
|
||||
void CStyleStorage::GetStyleRule(const KatanaStyleRule* oRule, std::map<std::wstring, CElement*>& mStyleData)
|
||||
inline void CCssCalculator_Private::GetStyleRule(const KatanaStyleRule *oRule)
|
||||
{
|
||||
if (oRule->declarations->length == 0)
|
||||
return;
|
||||
@ -273,7 +297,7 @@ namespace NSCSS
|
||||
|
||||
for (std::vector<std::wstring>::reverse_iterator oWord = arWords.rbegin(); oWord != arWords.rend(); ++oWord)
|
||||
{
|
||||
const size_t posPoint = oWord->find(L'.');
|
||||
const size_t posPoint = oWord->find(L'.');
|
||||
const size_t posLattice = oWord->find(L'#');
|
||||
|
||||
const std::wstring sName = (posPoint != std::wstring::npos) ? oWord->substr(0, posPoint) : (posLattice != std::wstring::npos) ? oWord->substr(0, posLattice) : *oWord;
|
||||
@ -289,8 +313,8 @@ namespace NSCSS
|
||||
{
|
||||
if (NULL == oFirstElement && bCreateFirst)
|
||||
{
|
||||
const std::map<std::wstring, CElement*>::const_iterator& oFindId = mStyleData.find(sId);
|
||||
if (oFindId != mStyleData.end())
|
||||
const std::map<std::wstring, CElement*>::const_iterator& oFindId = m_mData.find(sId);
|
||||
if (oFindId != m_mData.end())
|
||||
{
|
||||
oIdElement = oFindId->second;
|
||||
bCreateFirst = false;
|
||||
@ -318,8 +342,8 @@ namespace NSCSS
|
||||
{
|
||||
if (NULL == oFirstElement && bCreateFirst)
|
||||
{
|
||||
const std::map<std::wstring, CElement*>::const_iterator& oFindClass = mStyleData.find(sClass);
|
||||
if (oFindClass != mStyleData.end())
|
||||
const std::map<std::wstring, CElement*>::const_iterator& oFindClass = m_mData.find(sClass);
|
||||
if (oFindClass != m_mData.end())
|
||||
{
|
||||
oClassElement = oFindClass->second;
|
||||
bCreateFirst = false;
|
||||
@ -351,8 +375,8 @@ namespace NSCSS
|
||||
{
|
||||
if (NULL == oFirstElement && bCreateFirst)
|
||||
{
|
||||
const std::map<std::wstring, CElement*>::const_iterator& oFindName = mStyleData.find(sName);
|
||||
if (oFindName != mStyleData.end())
|
||||
const std::map<std::wstring, CElement*>::const_iterator& oFindName = m_mData.find(sName);
|
||||
if (oFindName != m_mData.end())
|
||||
{
|
||||
oNameElement = oFindName->second;
|
||||
bCreateFirst = false;
|
||||
@ -384,16 +408,11 @@ namespace NSCSS
|
||||
oLastElement->AddProperties(mStyle);
|
||||
|
||||
if (NULL != oFirstElement)
|
||||
mStyleData[oFirstElement->GetSelector()] = oFirstElement;
|
||||
m_mData[oFirstElement->GetSelector()] = oFirstElement;
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring CStyleStorage::GetValueList(const KatanaArray* oValues)
|
||||
{
|
||||
return StringifyValueList(oValues);
|
||||
}
|
||||
|
||||
std::vector<std::wstring> CStyleStorage::GetSelectorList(const KatanaArray* oSelectors) const
|
||||
inline std::vector<std::wstring> CCssCalculator_Private::GetSelectorList(const KatanaArray* oSelectors) const
|
||||
{
|
||||
if (oSelectors->length == 0)
|
||||
return std::vector<std::wstring>();
|
||||
@ -406,7 +425,7 @@ namespace NSCSS
|
||||
return arSelectors;
|
||||
}
|
||||
|
||||
std::wstring CStyleStorage::GetSelector(const KatanaSelector* oSelector) const
|
||||
inline std::wstring CCssCalculator_Private::GetSelector(const KatanaSelector *oSelector) const
|
||||
{
|
||||
KatanaParser oParser;
|
||||
oParser.options = &kKatanaDefaultOptions;
|
||||
@ -425,7 +444,7 @@ namespace NSCSS
|
||||
return wsText;
|
||||
}
|
||||
|
||||
std::map<std::wstring, std::wstring> CStyleStorage::GetDeclarationList(const KatanaArray* oDeclarations) const
|
||||
inline std::map<std::wstring, std::wstring> CCssCalculator_Private::GetDeclarationList(const KatanaArray* oDeclarations) const
|
||||
{
|
||||
if(oDeclarations->length == 0)
|
||||
return std::map<std::wstring, std::wstring>();
|
||||
@ -438,7 +457,7 @@ namespace NSCSS
|
||||
return arDeclarations;
|
||||
}
|
||||
|
||||
std::pair<std::wstring, std::wstring> CStyleStorage::GetDeclaration(const KatanaDeclaration* oDecl) const
|
||||
inline std::pair<std::wstring, std::wstring> CCssCalculator_Private::GetDeclaration(const KatanaDeclaration* oDecl) const
|
||||
{
|
||||
std::wstring sValueList = StringifyValueList(oDecl->values);
|
||||
|
||||
@ -448,286 +467,114 @@ namespace NSCSS
|
||||
return std::make_pair(UTF8_TO_U(std::string(oDecl->property)), sValueList);
|
||||
}
|
||||
|
||||
void CStyleStorage::GetOutputData(KatanaOutput* oOutput, std::map<std::wstring, CElement*>& mStyleData)
|
||||
inline std::wstring CCssCalculator_Private::GetValueList(const KatanaArray *oValues)
|
||||
{
|
||||
if ( NULL == oOutput )
|
||||
return;
|
||||
|
||||
switch (oOutput->mode) {
|
||||
case KatanaParserModeStylesheet:
|
||||
GetStylesheet(oOutput->stylesheet, mStyleData);
|
||||
break;
|
||||
case KatanaParserModeRule:
|
||||
GetRule(oOutput->rule, mStyleData);
|
||||
break;
|
||||
case KatanaParserModeKeyframeRule:
|
||||
case KatanaParserModeKeyframeKeyList:
|
||||
case KatanaParserModeMediaList:
|
||||
case KatanaParserModeValue:
|
||||
case KatanaParserModeSelector:
|
||||
case KatanaParserModeDeclarationList:
|
||||
break;
|
||||
}
|
||||
return StringifyValueList(oValues);
|
||||
}
|
||||
|
||||
const CElement* CStyleStorage::FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map<std::wstring, CElement*>& mStyleData) const
|
||||
{
|
||||
std::map<std::wstring, CElement*>::const_iterator itFound = mStyleData.find(wsSelector);
|
||||
|
||||
if (mStyleData.cend() != itFound)
|
||||
return itFound->second;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CCssCalculator_Private::CCssCalculator_Private() : m_nDpi(96), m_nCountNodes(0), m_sEncoding(L"UTF-8"){}
|
||||
|
||||
CCssCalculator_Private::~CCssCalculator_Private()
|
||||
{}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
bool CCssCalculator_Private::CalculateCompiledStyle(std::vector<CNode>& arSelectors)
|
||||
CCompiledStyle CCssCalculator_Private::GetCompiledStyle(const std::vector<CNode>& arSelectors, const bool& bIsSettings, const UnitMeasure& unitMeasure)
|
||||
{
|
||||
if (arSelectors.empty())
|
||||
return CCompiledStyle();
|
||||
|
||||
CCompiledStyle oStyle;
|
||||
|
||||
GetCompiledStyle(oStyle, arSelectors, bIsSettings, unitMeasure);
|
||||
|
||||
return oStyle;
|
||||
}
|
||||
|
||||
bool CCssCalculator_Private::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors, const bool &bIsSettings, const UnitMeasure &unitMeasure)
|
||||
{
|
||||
if (arSelectors.empty())
|
||||
return false;
|
||||
|
||||
if (L"#text" == arSelectors.back().m_wsName)
|
||||
{
|
||||
if (arSelectors.size() > 1 && arSelectors.back().m_pCompiledStyle->Empty())
|
||||
*arSelectors.back().m_pCompiledStyle += *(arSelectors.end() - 2)->m_pCompiledStyle;
|
||||
SetUnitMeasure(unitMeasure);
|
||||
|
||||
if(arSelectors.crend() != std::find_if(arSelectors.crbegin(), arSelectors.crend(),
|
||||
[](const CNode& oNode){ return IsTableElement(oNode.m_wsName); }))
|
||||
if (!bIsSettings)
|
||||
{
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
|
||||
if (oItem != m_mUsedStyles.end())
|
||||
{
|
||||
arSelectors.back().m_pCompiledStyle->m_oBackground.Clear();
|
||||
arSelectors.back().m_pCompiledStyle->m_oBorder.Clear();
|
||||
oStyle = oItem->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
|
||||
if (oItem != m_mUsedStyles.end())
|
||||
else if (NULL == m_mStatictics || m_mStatictics->empty())
|
||||
{
|
||||
arSelectors.back().SetCompiledStyle(new CCompiledStyle(oItem->second));
|
||||
return true;
|
||||
oStyle.SetDpi(m_nDpi);
|
||||
oStyle.SetUnitMeasure(m_UnitMeasure);
|
||||
oStyle.SetID(arSelectors.back().m_wsName + ((!arSelectors.back().m_wsClass.empty()) ? L'.' + arSelectors.back().m_wsClass : L"") + ((arSelectors.back().m_wsId.empty()) ? L"" : L'#' + arSelectors.back().m_wsId) + L'-' + std::to_wstring(++m_nCountNodes));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
arSelectors.back().m_pCompiledStyle->SetDpi(m_nDpi);
|
||||
unsigned int unStart = 0;
|
||||
oStyle.SetDpi(m_nDpi);
|
||||
oStyle.SetUnitMeasure(m_UnitMeasure);
|
||||
|
||||
std::vector<CNode>::const_reverse_iterator itFound = std::find_if(arSelectors.crbegin(), arSelectors.crend(), [](const CNode& oNode){ return !oNode.m_pCompiledStyle->Empty(); });
|
||||
|
||||
if (itFound != arSelectors.crend())
|
||||
unStart = itFound.base() - arSelectors.cbegin();
|
||||
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors, unStart);
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors);
|
||||
std::vector<std::wstring> arPrevNodes;
|
||||
bool bInTable = false;
|
||||
|
||||
for (size_t i = 0; i < unStart; ++i)
|
||||
|
||||
for (size_t i = 0; i < arSelectors.size(); ++i)
|
||||
{
|
||||
if (!bInTable)
|
||||
bInTable = IsTableElement(arSelectors[i].m_wsName);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
for (size_t i = unStart; i < arSelectors.size(); ++i)
|
||||
{
|
||||
if (0 != i)
|
||||
*arSelectors[i].m_pCompiledStyle += *arSelectors[i - 1].m_pCompiledStyle;
|
||||
|
||||
arSelectors[i].m_pCompiledStyle->AddParent(arSelectors[i].m_wsName);
|
||||
oStyle.AddParent(arSelectors[i].m_wsName);
|
||||
|
||||
if (!bInTable)
|
||||
bInTable = IsTableElement(arSelectors[i].m_wsName);
|
||||
|
||||
if (bInTable)
|
||||
{
|
||||
arSelectors[i].m_pCompiledStyle->m_oBackground.Clear();
|
||||
arSelectors[i].m_pCompiledStyle->m_oBorder.Clear();
|
||||
oStyle.m_oBackground.Clear();
|
||||
oStyle.m_oBorder.Clear();
|
||||
}
|
||||
|
||||
arSelectors[i].m_pCompiledStyle->AddStyle(arSelectors[i].m_mAttributes, i + 1);
|
||||
CCompiledStyle oTempStyle;
|
||||
|
||||
for (const CElement* oElement : FindElements(arNodes, arPrevNodes))
|
||||
arSelectors[i].m_pCompiledStyle->AddStyle(oElement->GetStyle(), i + 1);
|
||||
oTempStyle.AddStyle(arSelectors[i].m_mAttributes, i + 1);
|
||||
|
||||
if (!arSelectors[i].m_wsStyle.empty())
|
||||
arSelectors[i].m_pCompiledStyle->AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
for (const CElement* oElement : FindElements(arNodes, arPrevNodes, bIsSettings))
|
||||
oTempStyle.AddStyle(oElement->GetStyle(), i + 1);
|
||||
|
||||
if (NULL != m_mStatictics)
|
||||
{
|
||||
std::map<StatistickElement, unsigned int>::const_iterator oFindCountStyle = m_mStatictics->find(StatistickElement{StatistickElement::IsStyle, arSelectors[i].m_wsStyle});
|
||||
|
||||
if (oFindCountStyle != m_mStatictics->end())
|
||||
{
|
||||
if ((bIsSettings && oFindCountStyle->second < MaxNumberRepetitions) ||
|
||||
(!bIsSettings && oFindCountStyle->second >= MaxNumberRepetitions))
|
||||
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
else if (!bIsSettings)
|
||||
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
}
|
||||
else /*if (bIsSettings)*/
|
||||
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
}
|
||||
else
|
||||
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
|
||||
oStyle += oTempStyle;
|
||||
|
||||
// Скидываем некоторые внешние стили, которые внутри таблицы переопределяются
|
||||
if (bInTable && i < arSelectors.size() - 1)
|
||||
{
|
||||
arSelectors[i].m_pCompiledStyle->m_oFont.GetLineHeight().Clear();
|
||||
arSelectors[i].m_pCompiledStyle->m_oPadding.Clear();
|
||||
arSelectors[i].m_pCompiledStyle->m_oMargin.Clear();
|
||||
oStyle.m_oFont.GetLineHeight().Clear();
|
||||
oStyle.m_oPadding.Clear();
|
||||
oStyle.m_oMargin.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
arSelectors.back().m_pCompiledStyle->SetID(CalculateStyleId(arSelectors.back()));
|
||||
oStyle.SetID(CalculateStyleId(arSelectors.back()));
|
||||
|
||||
if (!arSelectors.back().m_pCompiledStyle->Empty())
|
||||
m_mUsedStyles[arSelectors] = *arSelectors.back().m_pCompiledStyle;
|
||||
if (!bIsSettings && !oStyle.Empty())
|
||||
m_mUsedStyles[arSelectors] = oStyle;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::SetPageData(NSProperties::CPage &oPage, const std::map<std::wstring, std::wstring> &mData, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
//TODO:: пересмотреть данный метод
|
||||
m_oStyleStorage.SetPageData(oPage, mData, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
std::map<std::wstring, std::wstring> CCssCalculator_Private::GetPageData(const std::wstring &wsPageName)
|
||||
{
|
||||
return m_oStyleStorage.GetPageData(wsPageName);
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::ClearPageData()
|
||||
{
|
||||
m_oStyleStorage.ClearPageData();
|
||||
}
|
||||
#endif
|
||||
|
||||
std::vector<std::wstring> CCssCalculator_Private::CalculateAllNodes(const std::vector<CNode> &arSelectors, unsigned int unStart)
|
||||
{
|
||||
std::vector<std::wstring> arNodes;
|
||||
|
||||
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend() - unStart; ++oNode)
|
||||
{
|
||||
if (!oNode->m_wsName.empty())
|
||||
arNodes.push_back(oNode->m_wsName);
|
||||
|
||||
if (!oNode->m_wsClass.empty())
|
||||
{
|
||||
if (oNode->m_wsClass.find(L' ') != std::wstring::npos)
|
||||
{
|
||||
std::vector<std::wstring> arClasses = NS_STATIC_FUNCTIONS::GetWordsW(oNode->m_wsClass, false, L" ");
|
||||
|
||||
arNodes.push_back(std::accumulate(arClasses.begin(), arClasses.end(), std::wstring(),
|
||||
[](std::wstring sRes, const std::wstring& sClass)
|
||||
{return sRes += L'.' + sClass + L' ';}));
|
||||
}
|
||||
else
|
||||
arNodes.push_back(L'.' + oNode->m_wsClass);
|
||||
}
|
||||
|
||||
if (!oNode->m_wsId.empty())
|
||||
arNodes.push_back(L'#' + oNode->m_wsId);
|
||||
}
|
||||
|
||||
return arNodes;
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::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)
|
||||
{
|
||||
if (arNextNodes.empty())
|
||||
return;
|
||||
|
||||
const std::vector<CElement*> arTempPrev = pElement->GetPrevElements(arNextNodes.crbegin() + 1, arNextNodes.crend());
|
||||
const std::vector<CElement*> arTempKins = pElement->GetNextOfKin(wsName, arClasses);
|
||||
|
||||
if (!arTempPrev.empty())
|
||||
arFindedElements.insert(arFindedElements.end(), arTempPrev.begin(), arTempPrev.end());
|
||||
|
||||
if (!arTempKins.empty())
|
||||
arFindedElements.insert(arFindedElements.end(), arTempKins.begin(), arTempKins.end());
|
||||
}
|
||||
|
||||
std::vector<const CElement*> CCssCalculator_Private::FindElements(std::vector<std::wstring> &arNodes, std::vector<std::wstring> &arNextNodes)
|
||||
{
|
||||
if (arNodes.empty())
|
||||
return {};
|
||||
|
||||
std::vector<const CElement*> arFindedElements;
|
||||
|
||||
std::wstring wsName, wsId;
|
||||
std::vector<std::wstring> arClasses;
|
||||
|
||||
if (!arNodes.empty() && arNodes.back()[0] == L'#')
|
||||
{
|
||||
wsId = arNodes.back();
|
||||
arNodes.pop_back();
|
||||
arNextNodes.push_back(wsId);
|
||||
}
|
||||
|
||||
if (!arNodes.empty() && arNodes.back()[0] == L'.')
|
||||
{
|
||||
arClasses = NS_STATIC_FUNCTIONS::GetWordsW(arNodes.back(), false, L" ");
|
||||
arNextNodes.push_back(arNodes.back());
|
||||
arNodes.pop_back();
|
||||
}
|
||||
|
||||
if (!arNodes.empty())
|
||||
{
|
||||
wsName = arNodes.back();
|
||||
arNodes.pop_back();
|
||||
arNextNodes.push_back(wsName);
|
||||
}
|
||||
|
||||
if (!wsId.empty())
|
||||
{
|
||||
const CElement* pFoundId = m_oStyleStorage.FindElement(wsId);
|
||||
|
||||
if(nullptr != pFoundId)
|
||||
{
|
||||
if (!pFoundId->Empty())
|
||||
arFindedElements.push_back(pFoundId);
|
||||
|
||||
FindPrevAndKindElements(pFoundId, arNextNodes, arFindedElements, wsName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!arClasses.empty())
|
||||
{
|
||||
for (std::vector<std::wstring>::const_reverse_iterator iClass = arClasses.rbegin(); iClass != arClasses.rend(); ++iClass)
|
||||
{
|
||||
const CElement* pFoundClass = m_oStyleStorage.FindElement(*iClass);
|
||||
|
||||
if (nullptr != pFoundClass)
|
||||
{
|
||||
if (!pFoundClass->Empty())
|
||||
arFindedElements.push_back(pFoundClass);
|
||||
|
||||
FindPrevAndKindElements(pFoundClass, arNextNodes, arFindedElements, wsName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const CElement* pFoundName = m_oStyleStorage.FindElement(wsName);
|
||||
|
||||
if (nullptr != pFoundName)
|
||||
{
|
||||
if (!pFoundName->Empty())
|
||||
arFindedElements.push_back(pFoundName);
|
||||
|
||||
FindPrevAndKindElements(pFoundName, arNextNodes, arFindedElements, wsName, arClasses);
|
||||
}
|
||||
|
||||
const CElement* pFoundAll = m_oStyleStorage.FindElement(L"*");
|
||||
|
||||
if (nullptr != pFoundAll)
|
||||
{
|
||||
if (!pFoundAll->Empty())
|
||||
arFindedElements.push_back(pFoundAll);
|
||||
|
||||
FindPrevAndKindElements(pFoundAll, arNextNodes, arFindedElements, wsName, arClasses);
|
||||
}
|
||||
|
||||
if (arFindedElements.size() > 1)
|
||||
{
|
||||
std::sort(arFindedElements.rbegin(), arFindedElements.rend(),
|
||||
[](const CElement* oFirstElement, const CElement* oSecondElement)
|
||||
{ return oFirstElement->GetWeight() > oSecondElement->GetWeight(); });
|
||||
}
|
||||
|
||||
return arFindedElements;
|
||||
}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
std::wstring CCssCalculator_Private::CalculateStyleId(const CNode& oNode)
|
||||
{
|
||||
return oNode.m_wsName + ((!oNode.m_wsClass.empty()) ? L'.' + oNode.m_wsClass : L"") + ((oNode.m_wsId.empty()) ? L"" : L'#' + oNode.m_wsId) + L'-' + std::to_wstring(++m_nCountNodes);
|
||||
@ -750,7 +597,7 @@ namespace NSCSS
|
||||
SetPageData(oPageData, GetPageData(mRules[L"page"]), i + 1, true);
|
||||
}
|
||||
|
||||
for (const CElement* oElement : FindElements(arNodes, arNextNodes))
|
||||
for (const CElement* oElement : FindElements(arNodes, arNextNodes, false))
|
||||
{
|
||||
std::map<std::wstring, std::wstring> mRules = oElement->GetStyle();
|
||||
if (mRules.end() != mRules.find(L"page"))
|
||||
@ -764,20 +611,42 @@ namespace NSCSS
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void CCssCalculator_Private::AddStyles(const std::string& sStyle)
|
||||
void CCssCalculator_Private::AddStyles(const std::string &sStyle)
|
||||
{
|
||||
m_oStyleStorage.AddStyles(sStyle);
|
||||
if (sStyle.empty())
|
||||
return;
|
||||
|
||||
KatanaOutput *output = katana_parse(sStyle.c_str(), sStyle.length(), KatanaParserModeStylesheet);
|
||||
this->GetOutputData(output);
|
||||
katana_destroy_output(output);
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::AddStyles(const std::wstring& wsStyle)
|
||||
void CCssCalculator_Private::AddStyles(const std::wstring &wsStyle)
|
||||
{
|
||||
m_oStyleStorage.AddStyles(wsStyle);
|
||||
if (wsStyle.empty())
|
||||
return;
|
||||
|
||||
std::wregex oRegex(L"@page\\s*([^{]*)(\\{[^}]*\\})");
|
||||
std::wsmatch oMatch;
|
||||
std::wstring::const_iterator oSearchStart(wsStyle.cbegin());
|
||||
|
||||
while (std::regex_search(oSearchStart, wsStyle.cend(), oMatch, oRegex))
|
||||
{
|
||||
AddPageData(oMatch[1].str(), oMatch[2].str());
|
||||
oSearchStart = oMatch.suffix().first;
|
||||
}
|
||||
|
||||
AddStyles(U_TO_UTF8(wsStyle));
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::AddStylesFromFile(const std::wstring& wsFileName)
|
||||
{
|
||||
m_oStyleStorage.AddStylesFromFile(wsFileName);
|
||||
if (std::find(m_arFiles.begin(), m_arFiles.end(), wsFileName) != m_arFiles.end())
|
||||
return;
|
||||
|
||||
m_arFiles.push_back(wsFileName);
|
||||
|
||||
AddStyles(NS_STATIC_FUNCTIONS::GetContentAsUTF8(wsFileName));
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::SetDpi(unsigned short int nValue)
|
||||
@ -785,33 +654,32 @@ namespace NSCSS
|
||||
m_nDpi = nValue;
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::SetBodyTree(const CTree &oTree)
|
||||
{
|
||||
if (NULL == m_mStatictics)
|
||||
m_mStatictics = new std::map<StatistickElement, unsigned int>();
|
||||
|
||||
CTree::CountingNumberRepetitions(oTree, *m_mStatictics);
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::SetUnitMeasure(const UnitMeasure& nType)
|
||||
{
|
||||
m_UnitMeasure = nType;
|
||||
}
|
||||
|
||||
unsigned short int CCssCalculator_Private::GetDpi() const
|
||||
{
|
||||
return m_nDpi;
|
||||
}
|
||||
|
||||
bool CCssCalculator_Private::HaveStylesById(const std::wstring& wsId) const
|
||||
const std::map<std::wstring, CElement *> *CCssCalculator_Private::GetData() const
|
||||
{
|
||||
return nullptr != m_oStyleStorage.FindElement(L'#' + wsId);
|
||||
return &m_mData;
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::ClearEmbeddedStyles()
|
||||
UnitMeasure CCssCalculator_Private::GetUnitMeasure() const
|
||||
{
|
||||
m_oStyleStorage.ClearEmbeddedStyles();
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
m_mUsedStyles.clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::ClearAllowedStyleFiles()
|
||||
{
|
||||
m_oStyleStorage.ClearAllowedStyleFiles();
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::ClearStylesFromFile(const std::wstring& wsFilePath)
|
||||
{
|
||||
m_oStyleStorage.ClearStylesFromFile(wsFilePath);
|
||||
return m_UnitMeasure;
|
||||
}
|
||||
|
||||
std::wstring CCssCalculator_Private::GetEncoding() const
|
||||
@ -823,22 +691,12 @@ namespace NSCSS
|
||||
{
|
||||
m_sEncoding = L"UTF-8";
|
||||
m_nDpi = 96;
|
||||
m_UnitMeasure = Point;
|
||||
|
||||
m_oStyleStorage.Clear();
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
m_mUsedStyles.clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IsTableElement(const std::wstring& wsNameTag)
|
||||
{
|
||||
return L"td" == wsNameTag || L"tr" == wsNameTag || L"table" == wsNameTag ||
|
||||
L"tbody" == wsNameTag || L"thead" == wsNameTag || L"tfoot" == wsNameTag ||
|
||||
L"th" == wsNameTag;
|
||||
m_mData.clear();
|
||||
m_arFiles.clear();
|
||||
}
|
||||
}
|
||||
|
||||
inline static std::wstring StringifyValueList(const KatanaArray* oValues)
|
||||
{
|
||||
if (NULL == oValues)
|
||||
@ -941,7 +799,7 @@ inline static std::wstring StringifyValue(const KatanaValue* oValue)
|
||||
|
||||
inline static bool IsTableElement(const std::wstring& wsNameTag)
|
||||
{
|
||||
return L"td" == wsNameTag || L"tr" == wsNameTag || L"table" == wsNameTag ||
|
||||
return L"td" == wsNameTag || L"tr" == wsNameTag || L"table" == wsNameTag ||
|
||||
L"tbody" == wsNameTag || L"thead" == wsNameTag || L"tfoot" == wsNameTag ||
|
||||
L"th" == wsNameTag;
|
||||
}
|
||||
|
||||
@ -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) const;
|
||||
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,61 +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) const;
|
||||
};
|
||||
|
||||
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
|
||||
bool CalculateCompiledStyle(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, unsigned int unStart = 0);
|
||||
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;
|
||||
|
||||
bool HaveStylesById(const std::wstring& wsId) const;
|
||||
const std::map<std::wstring, CElement*>* GetData() const;
|
||||
|
||||
void ClearEmbeddedStyles();
|
||||
void ClearAllowedStyleFiles();
|
||||
void ClearStylesFromFile(const std::wstring& wsFilePath);
|
||||
void Clear();
|
||||
};
|
||||
|
||||
inline bool IsTableElement(const std::wstring& wsNameTag);
|
||||
};
|
||||
}
|
||||
#endif // CCSSCALCULATOR_PRIVATE_H
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,58 +1,19 @@
|
||||
#include "CNode.h"
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
#include "CCompiledStyle.h"
|
||||
#endif
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
CNode::CNode()
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
: m_pCompiledStyle(new CCompiledStyle())
|
||||
#endif
|
||||
{}
|
||||
|
||||
CNode::CNode(const CNode& oNode)
|
||||
: m_wsName(oNode.m_wsName), m_wsClass(oNode.m_wsClass), m_wsId(oNode.m_wsId),
|
||||
m_wsStyle(oNode.m_wsStyle), m_mAttributes(oNode.m_mAttributes)
|
||||
{
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
m_pCompiledStyle = new CCompiledStyle();
|
||||
*m_pCompiledStyle = *oNode.m_pCompiledStyle;
|
||||
#endif
|
||||
}
|
||||
|
||||
CNode::CNode(const std::wstring& wsName, const std::wstring& wsClass, const std::wstring& wsId)
|
||||
: m_wsName(wsName), m_wsClass(wsClass), m_wsId(wsId)
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
, m_pCompiledStyle(new CCompiledStyle())
|
||||
#endif
|
||||
{}
|
||||
|
||||
CNode::~CNode()
|
||||
{
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
if (nullptr != m_pCompiledStyle)
|
||||
delete m_pCompiledStyle;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CNode::Empty() const
|
||||
{
|
||||
return m_wsName.empty() && m_wsClass.empty() && m_wsId.empty() && m_wsStyle.empty();
|
||||
}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
void CNode::SetCompiledStyle(CCompiledStyle* pCompiledStyle)
|
||||
{
|
||||
if (nullptr != m_pCompiledStyle)
|
||||
delete m_pCompiledStyle;
|
||||
|
||||
m_pCompiledStyle = new CCompiledStyle();
|
||||
*m_pCompiledStyle = *pCompiledStyle;
|
||||
}
|
||||
#endif
|
||||
|
||||
void CNode::Clear()
|
||||
{
|
||||
m_wsName .clear();
|
||||
|
||||
@ -7,9 +7,6 @@
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
class CCompiledStyle;
|
||||
#endif
|
||||
class CNode
|
||||
{
|
||||
public:
|
||||
@ -19,21 +16,12 @@ namespace NSCSS
|
||||
std::wstring m_wsStyle; // Стиль тэга
|
||||
std::map<std::wstring, std::wstring> m_mAttributes; // Остальные аттрибуты тэга
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
CCompiledStyle *m_pCompiledStyle;
|
||||
#endif
|
||||
public:
|
||||
CNode();
|
||||
CNode(const CNode& oNode);
|
||||
CNode(const std::wstring& wsName, const std::wstring& wsClass, const std::wstring& wsId);
|
||||
~CNode();
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
void SetCompiledStyle(CCompiledStyle* pCompiledStyle);
|
||||
#endif
|
||||
|
||||
void Clear();
|
||||
|
||||
std::vector<std::wstring> GetData() const;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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())
|
||||
@ -1328,14 +1267,8 @@ namespace NSCSS
|
||||
|
||||
// DISPLAY
|
||||
CDisplay::CDisplay()
|
||||
{
|
||||
m_eWhiteSpace.SetMapping({{L"normal", EWhiteSpace::Normal },
|
||||
{L"nowrap", EWhiteSpace::Nowrap },
|
||||
{L"pre", EWhiteSpace::Pre },
|
||||
{L"pre-line", EWhiteSpace::Pre_Line},
|
||||
{L"pre-wrap", EWhiteSpace::Pre_Wrap}},
|
||||
EWhiteSpace::Normal);
|
||||
}
|
||||
: m_oDisplay(L"inline", 0)
|
||||
{}
|
||||
|
||||
void CDisplay::Equation(CDisplay &oFirstDisplay, CDisplay &oSecondDisplay)
|
||||
{
|
||||
@ -1348,8 +1281,6 @@ namespace NSCSS
|
||||
CString::Equation(oFirstDisplay.m_oHAlign, oSecondDisplay.m_oHAlign);
|
||||
|
||||
CString::Equation(oFirstDisplay.m_oDisplay, oSecondDisplay.m_oDisplay);
|
||||
|
||||
CEnum::Equation(oFirstDisplay.m_eWhiteSpace, oSecondDisplay.m_eWhiteSpace);
|
||||
}
|
||||
|
||||
bool CDisplay::SetX(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
@ -1413,11 +1344,6 @@ namespace NSCSS
|
||||
return m_oDisplay.SetValue(wsValue, NSConstValues::DISPLAY_VALUES, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CDisplay::SetWhiteSpace(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_eWhiteSpace.SetValue(wsValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
const CDigit& CDisplay::GetX() const
|
||||
{
|
||||
return m_oX;
|
||||
@ -1453,42 +1379,34 @@ namespace NSCSS
|
||||
return m_oDisplay;
|
||||
}
|
||||
|
||||
const CEnum& CDisplay::GetWhiteSpace() const
|
||||
{
|
||||
return m_eWhiteSpace;
|
||||
}
|
||||
|
||||
bool CDisplay::Empty() const
|
||||
{
|
||||
return m_oX.Empty() && m_oY.Empty() && m_oWidth.Empty() && m_oHeight.Empty() &&
|
||||
m_oHeight.Empty() && m_oVAlign.Empty() && m_oDisplay.Empty() &&
|
||||
(m_eWhiteSpace.Empty() || m_eWhiteSpace == EWhiteSpace::Normal);
|
||||
m_oHeight.Empty() && m_oVAlign.Empty() && m_oDisplay.Empty();
|
||||
}
|
||||
|
||||
CDisplay &CDisplay::operator+=(const CDisplay &oDisplay)
|
||||
{
|
||||
m_oX += oDisplay.m_oX;
|
||||
m_oY += oDisplay.m_oY;
|
||||
m_oWidth = oDisplay.m_oWidth;
|
||||
m_oHeight = oDisplay.m_oHeight;
|
||||
m_oHAlign += oDisplay.m_oHAlign;
|
||||
m_oVAlign += oDisplay.m_oVAlign;
|
||||
m_oDisplay += oDisplay.m_oDisplay;
|
||||
m_eWhiteSpace += oDisplay.m_eWhiteSpace;
|
||||
m_oX += oDisplay.m_oX;
|
||||
m_oY += oDisplay.m_oY;
|
||||
m_oWidth = oDisplay.m_oWidth;
|
||||
m_oHeight = oDisplay.m_oHeight;
|
||||
m_oHAlign += oDisplay.m_oHAlign;
|
||||
m_oVAlign += oDisplay.m_oVAlign;
|
||||
m_oDisplay += oDisplay.m_oDisplay;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool CDisplay::operator==(const CDisplay &oDisplay) const
|
||||
{
|
||||
return m_oX == oDisplay.m_oX &&
|
||||
m_oY == oDisplay.m_oY &&
|
||||
m_oWidth == oDisplay.m_oWidth &&
|
||||
m_oHeight == oDisplay.m_oHeight &&
|
||||
m_oHAlign == oDisplay.m_oHAlign &&
|
||||
m_oVAlign == oDisplay.m_oVAlign &&
|
||||
m_oDisplay == oDisplay.m_oDisplay &&
|
||||
m_eWhiteSpace == oDisplay.m_eWhiteSpace.ToInt();
|
||||
return m_oX == oDisplay.m_oX &&
|
||||
m_oY == oDisplay.m_oY &&
|
||||
m_oWidth == oDisplay.m_oWidth &&
|
||||
m_oHeight == oDisplay.m_oHeight &&
|
||||
m_oHAlign == oDisplay.m_oHAlign &&
|
||||
m_oVAlign == oDisplay.m_oVAlign &&
|
||||
m_oDisplay == oDisplay.m_oDisplay;
|
||||
}
|
||||
|
||||
// STROKE
|
||||
@ -2383,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
|
||||
@ -2477,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
|
||||
@ -2728,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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -328,15 +325,6 @@ namespace NSCSS
|
||||
};
|
||||
|
||||
// PROPERTIES
|
||||
typedef enum
|
||||
{
|
||||
Normal,
|
||||
Nowrap,
|
||||
Pre,
|
||||
Pre_Line,
|
||||
Pre_Wrap
|
||||
} EWhiteSpace;
|
||||
|
||||
class CDisplay
|
||||
{
|
||||
public:
|
||||
@ -356,8 +344,6 @@ namespace NSCSS
|
||||
|
||||
bool SetDisplay(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
bool SetWhiteSpace(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
const CDigit& GetX() const;
|
||||
const CDigit& GetY() const;
|
||||
const CDigit& GetWidth() const;
|
||||
@ -368,8 +354,6 @@ namespace NSCSS
|
||||
|
||||
const CString& GetDisplay() const;
|
||||
|
||||
const CEnum& GetWhiteSpace() const;
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
CDisplay& operator+=(const CDisplay& oDisplay);
|
||||
@ -384,8 +368,6 @@ namespace NSCSS
|
||||
CString m_oVAlign;
|
||||
|
||||
CString m_oDisplay;
|
||||
|
||||
CEnum m_eWhiteSpace;
|
||||
};
|
||||
|
||||
class CStroke
|
||||
@ -674,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;
|
||||
@ -693,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;
|
||||
@ -720,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();
|
||||
|
||||
|
||||
@ -22,10 +22,10 @@ namespace NSCSS
|
||||
: m_oStyle(oStyle), m_bIsPStyle(bIsPStyle)
|
||||
{}
|
||||
|
||||
bool CheckArrays(const std::vector<std::wstring>& arInitial, const std::set<std::wstring>& arFirst, const std::set<std::wstring>& arSecond)
|
||||
bool CheckArrays(const std::vector<std::wstring>& arInitial, const std::set<std::wstring>& arFirst, const std::set<std::wstring>& arSecond)
|
||||
{
|
||||
std::unordered_set<std::wstring> arInitialSet(arInitial.begin(), arInitial.end());
|
||||
|
||||
|
||||
std::vector<std::wstring> arCommonElements1;
|
||||
std::vector<std::wstring> arCommonElements2;
|
||||
|
||||
@ -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);
|
||||
@ -470,6 +470,9 @@ namespace NSCSS
|
||||
|
||||
int nSpace{0};
|
||||
|
||||
if (NULL != pPadding && !pPadding->Empty() && !pPadding->Zero())
|
||||
nSpace = pPadding->ToInt(NSCSS::Point);
|
||||
|
||||
return L"w:val=\"" + wsStyle + L"\" w:sz=\"" + std::to_wstring(nWidth) + + L"\" w:space=\"" + std::to_wstring(nSpace) + L"\" w:color=\"" + wsColor + L"\"";
|
||||
}
|
||||
|
||||
@ -482,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");
|
||||
@ -556,7 +559,7 @@ namespace NSCSS
|
||||
|
||||
if (oXmlElement.Empty())
|
||||
return false;
|
||||
|
||||
|
||||
m_sStyle += oXmlElement.GetPStyle(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -25,5 +25,3 @@ if not base.is_dir("katana-parser"):
|
||||
base.replaceInFileUtf8(base_directory + "/katana-parser/src/tokenizer.c", "static inline bool2 katana_is_html_space(char c);", "static inline bool katana_is_html_space(char c);")
|
||||
base.replaceInFileUtf8(base_directory + "/katana-parser/src/parser.c", "katanaget_text(parser->scanner)", "/*katanaget_text(parser->scanner)*/\"error\"")
|
||||
base.replaceInFileUtf8(base_directory + "/katana-parser/src/parser.c", "#define KATANA_PARSER_STRING(literal) (KatanaParserString){", "#define KATANA_PARSER_STRING(literal) {")
|
||||
# katana may not be able to handle an empty string correctly in some cases (bug#73485)
|
||||
base.replaceInFileUtf8(base_directory + "/katana-parser/src/foundation.c", "size_t len = strlen(str);", "if (NULL == str)\n return;\n size_t len = strlen(str);")
|
||||
|
||||
@ -15,14 +15,11 @@
|
||||
#include "../../../UnicodeConverter/UnicodeConverter.h"
|
||||
#include "../../../HtmlFile2/src/StringFinder.h"
|
||||
|
||||
#if defined(CreateDirectory)
|
||||
#undef CreateDirectory
|
||||
#endif
|
||||
|
||||
static std::string nonbreaking_inline = "|a|abbr|acronym|b|bdo|big|cite|code|dfn|em|font|i|img|kbd|nobr|s|small|span|strike|strong|sub|sup|tt|";
|
||||
static std::string empty_tags = "|area|base|basefont|bgsound|br|command|col|embed|event-source|frame|hr|image|img|input|keygen|link|menuitem|meta|param|source|spacer|track|wbr|";
|
||||
static std::string preserve_whitespace = "|pre|textarea|script|style|";
|
||||
static std::string special_handling = "|html|body|";
|
||||
static std::string no_entity_sub = ""; //"|style|";
|
||||
static std::string treat_like_inline = "|p|";
|
||||
|
||||
static std::vector<std::string> html_tags = {"div","span","a","img","p","h1","h2","h3","h4","h5","h6",
|
||||
@ -58,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);
|
||||
@ -72,10 +64,10 @@ static std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert)
|
||||
{
|
||||
if (bNeedConvert)
|
||||
{ // Определение кодировки
|
||||
std::string sEncoding = NSStringFinder::FindProperty(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\"", "'"}).m_sValue;
|
||||
std::string sEncoding = NSStringFinder::FindPropety(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\""}).m_sValue;
|
||||
|
||||
if (sEncoding.empty())
|
||||
sEncoding = NSStringFinder::FindProperty(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "}).m_sValue;
|
||||
sEncoding = NSStringFinder::FindPropety(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "}).m_sValue;
|
||||
|
||||
if (!sEncoding.empty() && !NSStringFinder::Equals("utf-8", sEncoding))
|
||||
{
|
||||
@ -214,7 +206,7 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
NSStringFinder::TFoundedData<char> oData;
|
||||
|
||||
// Content-Type
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-type", {":"}, {";", "\\n", "\\r"});
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-type", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentType{oData.m_sValue};
|
||||
|
||||
if (sContentType.empty())
|
||||
@ -230,18 +222,18 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
unCharsetBegin = oData.m_unEndPosition;
|
||||
|
||||
// name
|
||||
// std::string sName = NSStringFinder::FindProperty(sMhtContent, "name", {"="}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
// std::string sName = NSStringFinder::FindPropety(sMhtContent, "name", {"="}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
// unContentPosition = std::max(unContentPosition, unLastPosition);
|
||||
|
||||
// Content-Location
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-location", {":"}, {";", "\\n", "\\r"});
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-location", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentLocation{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
|
||||
// Content-ID
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-id", {":"}, {";", "\\n", "\\r"});
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-id", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentID{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
@ -255,7 +247,7 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
sContentLocation = "cid:" + sContentID;
|
||||
|
||||
// Content-Transfer-Encoding
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-transfer-encoding", {":"}, {";", "\\n", "\\r"});
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-transfer-encoding", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentEncoding{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
@ -269,7 +261,7 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
|
||||
if (std::string::npos != unCharsetEnd && unCharsetBegin < unCharsetEnd)
|
||||
{
|
||||
sCharset = NSStringFinder::FindProperty(sMhtContent.substr(unCharsetBegin, unCharsetEnd - unCharsetBegin), "charset", {"="}, {";", "\\n", "\\r"}).m_sValue;
|
||||
sCharset = NSStringFinder::FindPropety(sMhtContent.substr(unCharsetBegin, unCharsetEnd - unCharsetBegin), "charset", {"="}, {";", "\\n", "\\r"}).m_sValue;
|
||||
NSStringFinder::CutInside<std::string>(sCharset, "\"");
|
||||
}
|
||||
|
||||
@ -341,7 +333,7 @@ static std::string mhtTohtml(const std::string& sFileContent)
|
||||
NSStringUtils::CStringBuilderA oRes;
|
||||
|
||||
// Поиск boundary
|
||||
NSStringFinder::TFoundedData<char> oData{NSStringFinder::FindProperty(sFileContent, "boundary", {"="}, {"\\r", "\\n", "\""})};
|
||||
NSStringFinder::TFoundedData<char> oData{NSStringFinder::FindPropety(sFileContent, "boundary", {"="}, {"\\r", "\\n", "\""})};
|
||||
|
||||
size_t nFound{oData.m_unEndPosition};
|
||||
std::string sBoundary{oData.m_sValue};
|
||||
@ -439,25 +431,9 @@ static void substitute_xml_entities_into_text(std::string& text)
|
||||
replace_all(text, ">", ">");
|
||||
}
|
||||
|
||||
// After running through Gumbo, the values of type "" are replaced with the corresponding code '0x01'
|
||||
// Since the attribute value does not use control characters (value <= 0x09),
|
||||
// then just delete them, otherwise XmlUtils::CXmlLiteReader crashes on them.
|
||||
// bug#73486
|
||||
static void remove_control_symbols(std::string& text)
|
||||
{
|
||||
std::string::iterator itFound = std::find_if(text.begin(), text.end(), [](unsigned char chValue){ return chValue <= 0x09; });
|
||||
|
||||
while (itFound != text.end())
|
||||
{
|
||||
itFound = text.erase(itFound);
|
||||
itFound = std::find_if(itFound, text.end(), [](unsigned char chValue){ return chValue <= 0x09; });
|
||||
}
|
||||
}
|
||||
|
||||
// Заменяет сущности " в text
|
||||
static void substitute_xml_entities_into_attributes(std::string& text)
|
||||
{
|
||||
remove_control_symbols(text);
|
||||
substitute_xml_entities_into_text(text);
|
||||
replace_all(text, "\"", """);
|
||||
}
|
||||
@ -493,7 +469,6 @@ static void build_doctype(GumboNode* node, NSStringUtils::CStringBuilderA& oBuil
|
||||
oBuilder.WriteString("<!DOCTYPE ");
|
||||
oBuilder.WriteString(node->v.document.name);
|
||||
std::string pi(node->v.document.public_identifier);
|
||||
remove_control_symbols(pi);
|
||||
if ((node->v.document.public_identifier != NULL) && !pi.empty())
|
||||
{
|
||||
oBuilder.WriteString(" PUBLIC \"");
|
||||
@ -506,7 +481,7 @@ static void build_doctype(GumboNode* node, NSStringUtils::CStringBuilderA& oBuil
|
||||
}
|
||||
}
|
||||
|
||||
static void build_attributes(const GumboVector* attribs, NSStringUtils::CStringBuilderA& atts)
|
||||
static void build_attributes(const GumboVector* attribs, bool no_entities, NSStringUtils::CStringBuilderA& atts)
|
||||
{
|
||||
std::vector<std::string> arrRepeat;
|
||||
for (size_t i = 0; i < attribs->length; ++i)
|
||||
@ -514,10 +489,6 @@ static void build_attributes(const GumboVector* attribs, NSStringUtils::CStringB
|
||||
GumboAttribute* at = static_cast<GumboAttribute*>(attribs->data[i]);
|
||||
std::string sVal(at->value);
|
||||
std::string sName(at->name);
|
||||
|
||||
remove_control_symbols(sVal);
|
||||
remove_control_symbols(sName);
|
||||
|
||||
atts.WriteString(" ");
|
||||
|
||||
bool bCheck = false;
|
||||
@ -556,7 +527,8 @@ static void build_attributes(const GumboVector* attribs, NSStringUtils::CStringB
|
||||
std::string qs ="\"";
|
||||
atts.WriteString("=");
|
||||
atts.WriteString(qs);
|
||||
substitute_xml_entities_into_attributes(sVal);
|
||||
if(!no_entities)
|
||||
substitute_xml_entities_into_attributes(sVal);
|
||||
atts.WriteString(sVal);
|
||||
atts.WriteString(qs);
|
||||
}
|
||||
@ -565,6 +537,7 @@ static void build_attributes(const GumboVector* attribs, NSStringUtils::CStringB
|
||||
static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA& contents, bool bCheckValidNode)
|
||||
{
|
||||
std::string key = "|" + get_tag_name(node) + "|";
|
||||
bool no_entity_substitution = no_entity_sub.find(key) != std::string::npos;
|
||||
bool keep_whitespace = preserve_whitespace.find(key) != std::string::npos;
|
||||
bool is_inline = nonbreaking_inline.find(key) != std::string::npos;
|
||||
bool is_like_inline = treat_like_inline.find(key) != std::string::npos;
|
||||
@ -578,8 +551,8 @@ static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA
|
||||
if (child->type == GUMBO_NODE_TEXT)
|
||||
{
|
||||
std::string val(child->v.text.text);
|
||||
remove_control_symbols(val);
|
||||
substitute_xml_entities_into_text(val);
|
||||
if(!no_entity_substitution)
|
||||
substitute_xml_entities_into_text(val);
|
||||
|
||||
// Избавление от FF
|
||||
size_t found = val.find_first_of("\014");
|
||||
@ -618,10 +591,6 @@ static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilde
|
||||
}
|
||||
|
||||
std::string tagname = get_tag_name(node);
|
||||
remove_control_symbols(tagname);
|
||||
|
||||
if (NodeIsUnprocessed(tagname))
|
||||
return;
|
||||
|
||||
if (bCheckValidNode)
|
||||
bCheckValidNode = !IsUnckeckedNodes(tagname);
|
||||
@ -636,6 +605,7 @@ static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilde
|
||||
std::string closeTag = "";
|
||||
std::string key = "|" + tagname + "|";
|
||||
bool is_empty_tag = empty_tags.find(key) != std::string::npos;
|
||||
bool no_entity_substitution = no_entity_sub.find(key) != std::string::npos;
|
||||
|
||||
// determine closing tag type
|
||||
if (is_empty_tag)
|
||||
@ -648,7 +618,7 @@ static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilde
|
||||
|
||||
// build attr string
|
||||
const GumboVector* attribs = &node->v.element.attributes;
|
||||
build_attributes(attribs, oBuilder);
|
||||
build_attributes(attribs, no_entity_substitution, oBuilder);
|
||||
oBuilder.WriteString(close + ">");
|
||||
|
||||
// prettyprint your contents
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
import os
|
||||
import glob
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
curDirectory = os.path.dirname(os.path.realpath(__file__))
|
||||
dictionatiesDirectory = curDirectory + "/../../../../../dictionaries"
|
||||
|
||||
all_dictionaties = {}
|
||||
for dir in glob.glob(dictionatiesDirectory + "/*"):
|
||||
if not os.path.isdir(dir):
|
||||
continue
|
||||
dictionaryName = os.path.basename(dir)
|
||||
configFile = dictionatiesDirectory + "/" + dictionaryName + "/" + dictionaryName + ".json"
|
||||
if not os.path.isfile(configFile):
|
||||
continue
|
||||
isHyphen = False
|
||||
hyphenFile = dictionatiesDirectory + "/" + dictionaryName + "/hyph_" + dictionaryName + ".dic"
|
||||
if os.path.isfile(hyphenFile):
|
||||
isHyphen = True
|
||||
with open(configFile, 'r', encoding='utf-8') as file:
|
||||
data = json.loads(file.read())
|
||||
for lang in data["codes"]:
|
||||
all_dictionaties[str(lang)] = {
|
||||
"name": dictionaryName,
|
||||
"hyphen": isHyphen
|
||||
}
|
||||
|
||||
content = ""
|
||||
content += "#define DictionaryRec_count " + str(len(all_dictionaties)) + "\n"
|
||||
content += "typedef struct {\n"
|
||||
content += " const char* m_name;\n"
|
||||
content += " int m_lang;\n"
|
||||
content += "} DictionaryRec;\n\n"
|
||||
content += "static const DictionaryRec Dictionaries[DictionaryRec_count] = {\n"
|
||||
|
||||
for lang in all_dictionaties:
|
||||
info = all_dictionaties[lang]
|
||||
content += " { \"" + info["name"] + "\", " + str(lang) + " },\n"
|
||||
content += "};\n"
|
||||
|
||||
with open("./records.h", 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
@ -1,73 +0,0 @@
|
||||
#define DictionaryRec_count 65
|
||||
typedef struct {
|
||||
const char* m_name;
|
||||
int m_lang;
|
||||
} DictionaryRec;
|
||||
|
||||
static const DictionaryRec Dictionaries[DictionaryRec_count] = {
|
||||
{ "ar", 1025 },
|
||||
{ "ar", 2049 },
|
||||
{ "ar", 3073 },
|
||||
{ "ar", 4097 },
|
||||
{ "ar", 5121 },
|
||||
{ "ar", 6145 },
|
||||
{ "ar", 7169 },
|
||||
{ "ar", 8193 },
|
||||
{ "ar", 9217 },
|
||||
{ "ar", 10241 },
|
||||
{ "ar", 11265 },
|
||||
{ "ar", 12289 },
|
||||
{ "ar", 13313 },
|
||||
{ "ar", 14337 },
|
||||
{ "ar", 15361 },
|
||||
{ "ar", 16385 },
|
||||
{ "az_Latn_AZ", 1068 },
|
||||
{ "bg_BG", 1026 },
|
||||
{ "ca_ES", 1027 },
|
||||
{ "ca_ES_valencia", 2051 },
|
||||
{ "cs_CZ", 1029 },
|
||||
{ "da_DK", 1030 },
|
||||
{ "de_AT", 3079 },
|
||||
{ "de_CH", 2055 },
|
||||
{ "de_DE", 1031 },
|
||||
{ "el_GR", 1032 },
|
||||
{ "en_AU", 3081 },
|
||||
{ "en_CA", 4105 },
|
||||
{ "en_GB", 2057 },
|
||||
{ "en_US", 1033 },
|
||||
{ "en_ZA", 7177 },
|
||||
{ "es_ES", 3082 },
|
||||
{ "eu_ES", 1069 },
|
||||
{ "fr_FR", 1036 },
|
||||
{ "gl_ES", 1110 },
|
||||
{ "hr_HR", 1050 },
|
||||
{ "hu_HU", 1038 },
|
||||
{ "id_ID", 1057 },
|
||||
{ "it_IT", 1040 },
|
||||
{ "kk_KZ", 1087 },
|
||||
{ "ko_KR", 1042 },
|
||||
{ "lb_LU", 1134 },
|
||||
{ "lt_LT", 1063 },
|
||||
{ "lv_LV", 1062 },
|
||||
{ "mn_MN", 1104 },
|
||||
{ "nb_NO", 1044 },
|
||||
{ "nl_NL", 1043 },
|
||||
{ "nl_NL", 2067 },
|
||||
{ "nn_NO", 2068 },
|
||||
{ "oc_FR", 1154 },
|
||||
{ "pl_PL", 1045 },
|
||||
{ "pt_BR", 1046 },
|
||||
{ "pt_PT", 2070 },
|
||||
{ "ro_RO", 1048 },
|
||||
{ "ru_RU", 1049 },
|
||||
{ "sk_SK", 1051 },
|
||||
{ "sl_SI", 1060 },
|
||||
{ "sr_Cyrl_RS", 10266 },
|
||||
{ "sr_Latn_RS", 9242 },
|
||||
{ "sv_SE", 1053 },
|
||||
{ "tr_TR", 1055 },
|
||||
{ "uk_UA", 1058 },
|
||||
{ "uz_Cyrl_UZ", 2115 },
|
||||
{ "uz_Latn_UZ", 1091 },
|
||||
{ "vi_VN", 1066 },
|
||||
};
|
||||
@ -1,4 +1,4 @@
|
||||
ICU_MAJOR_VER = 74
|
||||
ICU_MAJOR_VER = 58
|
||||
|
||||
core_windows {
|
||||
exists($$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/icu) {
|
||||
@ -20,15 +20,8 @@ core_linux {
|
||||
core_mac {
|
||||
INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/include
|
||||
|
||||
ICU_LIBS_PATH_MAC = $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build
|
||||
bundle_dylibs {
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicudata.a
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicui18n.a
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicuuc.a
|
||||
} else {
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicuuc.$${ICU_MAJOR_VER}.dylib
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicudata.$${ICU_MAJOR_VER}.dylib
|
||||
}
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.$${ICU_MAJOR_VER}.dylib
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.$${ICU_MAJOR_VER}.dylib
|
||||
}
|
||||
|
||||
core_ios {
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
ICU_VERSION="58"
|
||||
|
||||
ICU_DIR="$PWD/icu"
|
||||
|
||||
ICU_SOURCE="${ICU_DIR}/source"
|
||||
@ -45,6 +47,8 @@ defines_utypes=(
|
||||
|
||||
function prebuild() {
|
||||
|
||||
svn export http://source.icu-project.org/repos/icu/tags/release-${ICU_VERSION}/icu4c/ ${ICU_DIR} --native-eol LF
|
||||
|
||||
echo "===== REMOVING data from bundle ====="
|
||||
|
||||
#Data bundle reduction
|
||||
|
||||
4
Common/3dParty/md/.gitignore
vendored
4
Common/3dParty/md/.gitignore
vendored
@ -1,4 +0,0 @@
|
||||
# Ignore everything in this directory
|
||||
md4c
|
||||
# Except this file
|
||||
!.gitignore
|
||||
@ -1,13 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
sys.path.append('../../../../build_tools/scripts')
|
||||
import config
|
||||
import base
|
||||
import os
|
||||
|
||||
base_directory = os.getcwd()
|
||||
|
||||
if not base.is_dir("md4c"):
|
||||
base.cmd("git", ["clone", "https://github.com/mity/md4c.git"])
|
||||
base.cmd_in_dir("md4c", "git", ["checkout", "481fbfbdf72daab2912380d62bb5f2187d438408"])
|
||||
@ -1,105 +0,0 @@
|
||||
#include "md2html.h"
|
||||
|
||||
#include "md4c/src/md4c-html.h"
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
|
||||
namespace Md
|
||||
{
|
||||
void ToHtml(const MD_CHAR* pValue, MD_SIZE uSize, void* pData)
|
||||
{
|
||||
if (NULL != pData)
|
||||
(*(std::string*)pData).append(pValue, uSize);
|
||||
}
|
||||
|
||||
std::string ConvertMdStringToHtml(const std::string& sMdString)
|
||||
{
|
||||
std::string sData;
|
||||
md_html(sMdString.c_str(), sMdString.length(), ToHtml, &sData, 0, 0);
|
||||
return sData;
|
||||
}
|
||||
|
||||
void ToHtmlFile(const MD_CHAR* pValue, MD_SIZE uSize, void* pData)
|
||||
{
|
||||
if (NULL != pData)
|
||||
((NSFile::CFileBinary*)pData)->WriteFile(pValue, uSize);
|
||||
}
|
||||
|
||||
void WriteBaseHtmlStyles(NSFile::CFileBinary& oFile)
|
||||
{
|
||||
oFile.WriteStringUTF8(L"<style>");
|
||||
|
||||
// Main styles
|
||||
oFile.WriteStringUTF8(L"* { font-family: Arial; color:black; white-space:pre; }");
|
||||
oFile.WriteStringUTF8(L"p { margin: 0 0 10px; display: block; }");
|
||||
oFile.WriteStringUTF8(L"a { color: #0553c1; text-decoration: underline; } a:visited { color: #954f72; text-decoration: underline; }");
|
||||
oFile.WriteStringUTF8(L"ul { margin-top: 0; margin-bottom: 10px; }");
|
||||
oFile.WriteStringUTF8(L"img { vertical-align: middle; }");
|
||||
|
||||
// Styles for tables
|
||||
oFile.WriteStringUTF8(L"table { margin-bottom: 20px; width: 100%; max-width: 100%; border-spacing:0; border-collapse: collapse; border-color: gray;}");
|
||||
oFile.WriteStringUTF8(L"thead { display: table-header-group; vertical-align: middle; }");
|
||||
oFile.WriteStringUTF8(L"tr { display: table-row; }");
|
||||
oFile.WriteStringUTF8(L"th { text-align: left; display: table-cell; font-weight: bold; }");
|
||||
|
||||
oFile.WriteStringUTF8(L"table thead tr th { vertical-align: bottom; border-bottom: 2px solid #ddd; }");
|
||||
oFile.WriteStringUTF8(L"table thead tr th, table tbody tr th, table thead tr td, table tbody tr td { padding 8px; line-height: 1.4; vertical-align: top; border-top: 1px solid #ddd; }");
|
||||
oFile.WriteStringUTF8(L"table > caption + thead > tr > th, table > colgroup + thead > tr > th, table > thead > tr > th, table > caption + thead > tr > td, table > colgroup + thead > tr > td, table > thead > tr > td { border-top: 0; }");
|
||||
|
||||
// Styles for blockquote
|
||||
oFile.WriteStringUTF8(L"blockquote { border-left: 3px solid #e9e9e9; margin: 1.5em 0; padding: 0.5em 10px 0.5em 24px; font-size: 1.25rem; display: block; margin-top: 8pt; font-style: italic; color: #404040; }");
|
||||
|
||||
// Styles for code
|
||||
oFile.WriteStringUTF8(L"code { padding: 2px 4px; font-size: 90%; color: #c7254e; background-color: #f9f2f4; border-radius: 4px; }");
|
||||
oFile.WriteStringUTF8(L"pre code { padding: 0px; white-space: pre-wrap; border-radius: 0; background-color: #f5f5f5; color:black; }");
|
||||
oFile.WriteStringUTF8(L"pre { display: block; padding: 9.5px; margin: 0 0 10px; line-height: 1.4; word-break: break-all; word-wrap: break-word; background-color: #f5f5f5; border: 1px solid #ccc; border-radius: 4px; font-size: 1em; }");
|
||||
oFile.WriteStringUTF8(L"code, pre { font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace; }");
|
||||
|
||||
// Styles for headings
|
||||
oFile.WriteStringUTF8(L"h1 { font-size: 20pt; color: #0f4761; margin-top: 18pt; margin-bottom: 4pt; }");
|
||||
oFile.WriteStringUTF8(L"h2 { font-size: 16pt; color: #0f4761; margin-top: 8pt; margin-bottom: 4pt; }");
|
||||
oFile.WriteStringUTF8(L"h3 { font-size: 14pt; color: #0f4761; margin-top: 8pt; margin-bottom: 4pt; }");
|
||||
oFile.WriteStringUTF8(L"h4 { font-style: italic; color: #0f4761; margin-top: 4pt; margin-bottom: 2pt; }");
|
||||
oFile.WriteStringUTF8(L"h5 { color: #0f4761; margin-top: 4pt; margin-bottom: 2pt; }");
|
||||
oFile.WriteStringUTF8(L"h6 { font-style: italic; color: #595959; margin-top: 2pt; margin-bottom: 0; }");
|
||||
|
||||
oFile.WriteStringUTF8(L"</style>");
|
||||
}
|
||||
|
||||
bool ConvertMdFileToHtml(const std::wstring& wsPathToMdFile, const std::wstring& wsPathToHtmlFile)
|
||||
{
|
||||
std::string sMdData;
|
||||
|
||||
if (!NSFile::CFileBinary::ReadAllTextUtf8A(wsPathToMdFile, sMdData))
|
||||
return false;
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
|
||||
if (!oFile.CreateFile(wsPathToHtmlFile))
|
||||
return false;
|
||||
|
||||
oFile.WriteStringUTF8(L"<html><body>");
|
||||
|
||||
oFile.WriteStringUTF8(L"<head>");
|
||||
//oFile.WriteStringUTF8(L"<meta charset=\"UTF-8\">");
|
||||
oFile.WriteStringUTF8(L"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
|
||||
WriteBaseHtmlStyles(oFile);
|
||||
oFile.WriteStringUTF8(L"</head>");
|
||||
|
||||
bool bResult = true;
|
||||
|
||||
if (0 != md_html(sMdData.c_str(), sMdData.length(), ToHtmlFile, &oFile,
|
||||
MD_DIALECT_GITHUB | MD_FLAG_NOINDENTEDCODEBLOCKS | MD_HTML_FLAG_SKIP_UTF8_BOM,
|
||||
0))
|
||||
bResult = false;
|
||||
|
||||
oFile.WriteStringUTF8(L"</body></html>");
|
||||
|
||||
oFile.CloseFile();
|
||||
|
||||
if (!bResult)
|
||||
NSFile::CFileBinary::Remove(wsPathToHtmlFile);
|
||||
|
||||
return bResult;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
#ifndef MD2HTML_H
|
||||
#define MD2HTML_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifndef MDCONVERTER_DECL_EXPORT
|
||||
#define MDCONVERTER_DECL_EXPORT
|
||||
#else
|
||||
#include "../../../DesktopEditor/common/base_export.h"
|
||||
#define MDCONVERTER_DECL_EXPORT Q_DECL_EXPORT
|
||||
#endif
|
||||
|
||||
namespace Md
|
||||
{
|
||||
std::string MDCONVERTER_DECL_EXPORT ConvertMdStringToHtml(const std::string& sMdString);
|
||||
bool MDCONVERTER_DECL_EXPORT ConvertMdFileToHtml(const std::wstring& wsPathToMdFile, const std::wstring& wsPathToHtmlFile);
|
||||
}
|
||||
|
||||
#endif // MD2HTML_H
|
||||
@ -1,11 +0,0 @@
|
||||
DEFINES += MD4C_USE_UTF8
|
||||
|
||||
HEADERS += $$PWD/md4c/src/md4c.h \
|
||||
$$PWD/md4c/src/md4c-html.h \
|
||||
$$PWD/md4c/src/entity.h \
|
||||
$$PWD/md2html.h \
|
||||
|
||||
SOURCES += $$PWD/md4c/src/md4c.c \
|
||||
$$PWD/md4c/src/md4c-html.c \
|
||||
$$PWD/md4c/src/entity.c \
|
||||
$$PWD/md2html.cpp
|
||||
@ -1,16 +0,0 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
TARGET = test
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../../
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/md/md2html.pri)
|
||||
|
||||
DESTDIR = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX
|
||||
@ -1 +0,0 @@
|
||||
* foo **bar [link](http://example.com) baz**
|
||||
@ -1,10 +0,0 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "../md2html.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
std::cout << (ConvertMdFileToHtml(L"YOUR_PATH", L"YOUR_PATH") ? "Good" : "Bad") << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -34,8 +34,6 @@
|
||||
#include "../../../../DesktopEditor/common/StringExt.h"
|
||||
|
||||
#include <wininet.h>
|
||||
#include <objbase.h>
|
||||
#include <urlmon.h>
|
||||
#pragma comment(lib, "Wininet")
|
||||
#pragma comment(lib, "Ole32.lib")
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -68,7 +68,6 @@ public:
|
||||
bool isOOXFormatFile(const std::wstring& fileName, bool unpacked = false);
|
||||
bool isOpenOfficeFormatFile(const std::wstring& fileName, std::wstring& documentID);
|
||||
bool isOnlyOfficeFormatFile(const std::wstring& fileName);
|
||||
bool isMacFormatFile(const std::wstring& fileName);
|
||||
|
||||
bool isDocFormatFile(const std::wstring& fileName);
|
||||
bool isXlsFormatFile(const std::wstring& fileName);
|
||||
@ -81,7 +80,6 @@ public:
|
||||
bool isMS_MITCRYPTOFormatFile(POLE::Storage* storage, std::wstring& documentID);
|
||||
bool isVbaProjectFile(POLE::Storage* storage);
|
||||
bool isMS_OFFCRYPTOFormatFile(const std::wstring& fileName, std::wstring& documentID);
|
||||
bool isHwpFile(POLE::Storage* storage);
|
||||
|
||||
bool iXmlFile(const std::wstring& fileName);
|
||||
|
||||
@ -103,11 +101,9 @@ public:
|
||||
bool isBinaryDoctFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isBinaryXlstFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isBinaryPpttFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isBinaryVsdtFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
|
||||
bool isDjvuFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isMobiFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isFB2FormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isXpsFile(const std::wstring& fileName);
|
||||
bool isOFDFile(const std::wstring& fileName);
|
||||
};
|
||||
|
||||
@ -44,7 +44,6 @@
|
||||
|
||||
#include "3dParty/pole/pole.h"
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
#include "OfficeFileFormatDefines.h"
|
||||
|
||||
@ -223,16 +222,6 @@ bool COfficeFileFormatChecker::isBinaryPpttFormatFile(unsigned char *pBuffer, in
|
||||
|
||||
return false;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isBinaryVsdtFormatFile(unsigned char* pBuffer, int dwBytes)
|
||||
{
|
||||
if (pBuffer == NULL)
|
||||
return false;
|
||||
|
||||
if ((4 <= dwBytes) && ('V' == pBuffer[0] && 'S' == pBuffer[1] && 'D' == pBuffer[2] && 'Y' == pBuffer[3]))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isPdfFormatFile(unsigned char *pBuffer, int dwBytes, std::wstring &documentID)
|
||||
{
|
||||
if (pBuffer == NULL)
|
||||
@ -240,7 +229,7 @@ bool COfficeFileFormatChecker::isPdfFormatFile(unsigned char *pBuffer, int dwByt
|
||||
|
||||
documentID.clear();
|
||||
|
||||
if (dwBytes < 5 || (pBuffer[0] == 'P' && pBuffer[1] == 'K'))
|
||||
if (dwBytes < 1)
|
||||
return false;
|
||||
|
||||
pBuffer[dwBytes - 1] = '\0';
|
||||
@ -462,20 +451,6 @@ bool COfficeFileFormatChecker::isVbaProjectFile(POLE::Storage *storage)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isHwpFile(POLE::Storage* storage)
|
||||
{
|
||||
if (storage == NULL)
|
||||
return false;
|
||||
|
||||
unsigned char buffer[10];
|
||||
|
||||
POLE::Stream stream(storage, L"BodyText/Section0");
|
||||
if (stream.read(buffer, 10) < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isXlsFormatFile(POLE::Storage *storage)
|
||||
{
|
||||
if (storage == NULL)
|
||||
@ -746,11 +721,6 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_OTHER_MS_VBAPROJECT;
|
||||
return true;
|
||||
}
|
||||
else if (isHwpFile(&storage))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
NSFile::CFileBinary file;
|
||||
if (!file.OpenFile(fileName))
|
||||
@ -770,47 +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;
|
||||
}
|
||||
else if (isOFDFile(fileName))
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isMacFormatFile(fileName))
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
@ -834,10 +770,6 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION;
|
||||
}
|
||||
else if (isBinaryVsdtFormatFile(bufferDetect, sizeRead)) // min size - 4
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_DRAW;
|
||||
}
|
||||
else if (isOOXFlatFormatFile(bufferDetect, sizeRead))
|
||||
{
|
||||
// nFileType;
|
||||
@ -937,8 +869,6 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
}
|
||||
else if (0 == sExt.compare(L".mht") || 0 == sExt.compare(L".mhtml"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT;
|
||||
else if (0 == sExt.compare(L".md"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MD;
|
||||
else if (0 == sExt.compare(L".csv") || 0 == sExt.compare(L".xls") || 0 == sExt.compare(L".xlsx") || 0 == sExt.compare(L".xlsb"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
|
||||
else if (0 == sExt.compare(L".html") || 0 == sExt.compare(L".htm"))
|
||||
@ -947,18 +877,8 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_PDF;
|
||||
else if (0 == sExt.compare(L".doct")) // случай архива с html viewer
|
||||
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"))
|
||||
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;
|
||||
@ -1174,10 +1094,6 @@ bool COfficeFileFormatChecker::isOnlyOfficeFormatFile(const std::wstring &fileNa
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY;
|
||||
}
|
||||
else if (isBinaryVsdtFormatFile(pBuffer, nBufferSize))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_TEAMLAB_VSDY;
|
||||
}
|
||||
|
||||
delete[] pBuffer;
|
||||
pBuffer = NULL;
|
||||
@ -1187,222 +1103,6 @@ bool COfficeFileFormatChecker::isOnlyOfficeFormatFile(const std::wstring &fileNa
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
struct TIWAField
|
||||
{
|
||||
size_t m_unStart;
|
||||
size_t m_unEnd;
|
||||
unsigned m_uIndex;
|
||||
unsigned m_unWireType;
|
||||
uint64_t m_oValue;
|
||||
};
|
||||
|
||||
bool ReadUVar(BYTE* pBuffer, size_t unEndPos, size_t& unPos, uint64_t& unValue)
|
||||
{
|
||||
std::vector<unsigned char> arBytes;
|
||||
arBytes.reserve(8);
|
||||
|
||||
unValue = 0;
|
||||
|
||||
bool bNext = true;
|
||||
while (unPos < unEndPos && bNext)
|
||||
{
|
||||
const unsigned char c = pBuffer[unPos++];
|
||||
arBytes.push_back((unsigned char)(c & ~0x80));
|
||||
bNext = c & 0x80;
|
||||
}
|
||||
|
||||
if (bNext && unPos == unEndPos)
|
||||
return false;
|
||||
|
||||
for (std::vector<unsigned char>::const_reverse_iterator it = arBytes.rbegin(); it != arBytes.rend(); ++it)
|
||||
{
|
||||
if (std::numeric_limits<uint64_t>::max() >> 7 < unValue ||
|
||||
std::numeric_limits<uint64_t>::max() - (unValue << 7) < *it) // overflow
|
||||
return false;
|
||||
|
||||
unValue = (unValue << 7) + *it;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReadIWAField(BYTE* pBuffer, size_t unEndPos, size_t& unPos, TIWAField& oIWAField)
|
||||
{
|
||||
if (NULL == pBuffer || unPos + 2 > unEndPos)
|
||||
return false;
|
||||
|
||||
unsigned uSpec;
|
||||
|
||||
uSpec = (unsigned)pBuffer[unPos++];
|
||||
oIWAField.m_unWireType = uSpec & 0x7;
|
||||
|
||||
oIWAField.m_unStart = unPos;
|
||||
|
||||
switch (oIWAField.m_unWireType)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (!ReadUVar(pBuffer, unEndPos, unPos, oIWAField.m_oValue))
|
||||
return false;
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
unPos += 4;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
uint64_t unLen;
|
||||
if (!ReadUVar(pBuffer, unEndPos, unPos, unLen) || unPos + unLen > unEndPos)
|
||||
return false;
|
||||
|
||||
oIWAField.m_unStart = unPos;
|
||||
unPos += unLen;
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
unPos += 2;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
oIWAField.m_unEnd = unPos;
|
||||
oIWAField.m_uIndex = uSpec >> 3;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DetectIWorkFormat(const std::wstring& fileName, int &nType)
|
||||
{
|
||||
COfficeUtils OfficeUtils(NULL);
|
||||
|
||||
ULONG unSize = 0;
|
||||
BYTE* pBuffer = NULL;
|
||||
|
||||
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Document.iwa", &pBuffer, unSize);
|
||||
|
||||
if (hresult != S_OK || NULL == pBuffer)
|
||||
return false;
|
||||
|
||||
#define CLEAR_BUFFER_AND_RETURN(return_value)\
|
||||
do{\
|
||||
delete[] pBuffer;\
|
||||
return return_value;\
|
||||
}while(false)
|
||||
|
||||
if (unSize < 13)
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
size_t uPos = 6;
|
||||
|
||||
for (; uPos < 12; ++uPos)
|
||||
{
|
||||
if (0x08 == pBuffer[uPos] && 0x01 == pBuffer[uPos + 1])
|
||||
{
|
||||
--uPos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (12 == uPos)
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
uint64_t unHeaderLen;
|
||||
if (!ReadUVar(pBuffer, unSize, uPos, unHeaderLen))
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
const size_t uStartPos = uPos;
|
||||
|
||||
if (unHeaderLen < 8 || unSize < unHeaderLen + uStartPos)
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
uPos += 2;
|
||||
|
||||
TIWAField oMessageField;
|
||||
|
||||
if (!ReadIWAField(pBuffer, uStartPos + unHeaderLen, uPos, oMessageField) || 2 != oMessageField.m_unWireType ||
|
||||
2 != oMessageField.m_uIndex)
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
size_t uSubPos = oMessageField.m_unStart;
|
||||
TIWAField oField;
|
||||
|
||||
if (!ReadIWAField(pBuffer, oMessageField.m_unEnd, uSubPos, oField) || 0 != oField.m_unWireType ||
|
||||
1 != oField.m_uIndex)
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
switch (oField.m_oValue)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
uint32_t unDataLen = 0;
|
||||
|
||||
TIWAField oTempField;
|
||||
if (ReadIWAField(pBuffer, oMessageField.m_unEnd, uSubPos, oTempField) &&
|
||||
ReadIWAField(pBuffer, oMessageField.m_unEnd, uSubPos, oTempField) && 0 == oTempField.m_unWireType &&
|
||||
3 == oTempField.m_uIndex)
|
||||
unDataLen += oTempField.m_oValue;
|
||||
|
||||
size_t unTempPos = uStartPos + unHeaderLen;
|
||||
|
||||
// keynote: presentation ref in 2
|
||||
// number: sheet ref in 1
|
||||
if (ReadIWAField(pBuffer, uStartPos + unDataLen, unTempPos, oTempField) &&
|
||||
(2 != oTempField.m_unWireType || 1 != oTempField.m_uIndex || oTempField.m_unEnd - oTempField.m_unStart < 2))
|
||||
{
|
||||
nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
|
||||
CLEAR_BUFFER_AND_RETURN(true);
|
||||
}
|
||||
else if (ReadIWAField(pBuffer, uStartPos + unDataLen, unTempPos, oTempField) &&
|
||||
(2 != oTempField.m_unWireType || 2 != oTempField.m_uIndex || oTempField.m_unEnd - oTempField.m_unStart < 2))
|
||||
{
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
|
||||
CLEAR_BUFFER_AND_RETURN(true);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 10000:
|
||||
{
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
CLEAR_BUFFER_AND_RETURN(true);
|
||||
}
|
||||
}
|
||||
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isMacFormatFile(const std::wstring& fileName)
|
||||
{
|
||||
if (DetectIWorkFormat(fileName, nFileType))
|
||||
return true;
|
||||
|
||||
std::wstring::size_type nExtPos = fileName.rfind(L'.');
|
||||
std::wstring sExt = L"unknown";
|
||||
|
||||
if (nExtPos != std::wstring::npos)
|
||||
sExt = fileName.substr(nExtPos);
|
||||
|
||||
std::transform(sExt.begin(), sExt.end(), sExt.begin(), tolower);
|
||||
|
||||
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
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isOpenOfficeFormatFile(const std::wstring &fileName, std::wstring &documentID)
|
||||
{
|
||||
documentID.clear();
|
||||
@ -1601,15 +1301,12 @@ bool COfficeFileFormatChecker::isOOXFlatFormatFile(unsigned char *pBuffer, int d
|
||||
const char *xlsxPackage = "progid=\"Excel.Sheet\"";
|
||||
const char *pptxPackage = "progid=\"PowerPoint.Show\"";
|
||||
const char *packageFormatLine = "xmlns:pkg=\"http://schemas.microsoft.com/office/2006/xmlPackage\"";
|
||||
const char* workbookFormatLine = "<Workbook";
|
||||
const char* htmlFormatLine = "<html";
|
||||
|
||||
if (std::string::npos != xml_string.find(docxFormatLine))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX_FLAT;
|
||||
}
|
||||
else if (std::string::npos != xml_string.find(xlsxFormatLine) && ( std::string::npos != xml_string.find(workbookFormatLine) ||
|
||||
std::string::npos == xml_string.find(htmlFormatLine)))
|
||||
else if (std::string::npos != xml_string.find(xlsxFormatLine))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_FLAT;
|
||||
}
|
||||
@ -1648,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";
|
||||
@ -1670,14 +1366,6 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".fodt";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_OTT:
|
||||
return L".ott";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES:
|
||||
return L".pages";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP:
|
||||
return L".hwp";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX:
|
||||
return L".hwpx";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_MD:
|
||||
return L".md";
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX:
|
||||
return L".pptx";
|
||||
@ -1699,10 +1387,6 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".fodp";
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP:
|
||||
return L".otp";
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_ODG:
|
||||
return L".odg";
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY:
|
||||
return L".key";
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX:
|
||||
return L".xlsx";
|
||||
@ -1724,8 +1408,6 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".fods";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS:
|
||||
return L".ots";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS:
|
||||
return L".numbers";
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF:
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM_PDF:
|
||||
@ -1736,8 +1418,6 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".djvu";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS:
|
||||
return L".xps";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD:
|
||||
return L".ofd";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_SVG:
|
||||
return L".svg";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLR:
|
||||
@ -1779,15 +1459,12 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
case AVS_OFFICESTUDIO_FILE_CANVAS_WORD:
|
||||
case AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET:
|
||||
case AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION:
|
||||
case AVS_OFFICESTUDIO_FILE_CANVAS_DRAW:
|
||||
return L".bin";
|
||||
case AVS_OFFICESTUDIO_FILE_OTHER_OLD_DOCUMENT:
|
||||
case AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY:
|
||||
return L".doct";
|
||||
case AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY:
|
||||
return L".xlst";
|
||||
case AVS_OFFICESTUDIO_FILE_TEAMLAB_VSDY:
|
||||
return L".vsdt";
|
||||
case AVS_OFFICESTUDIO_FILE_OTHER_OLD_PRESENTATION:
|
||||
case AVS_OFFICESTUDIO_FILE_OTHER_OLD_DRAWING:
|
||||
case AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY:
|
||||
@ -1855,14 +1532,6 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT_FLAT;
|
||||
if (L".ott" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_OTT;
|
||||
if (L".pages" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
if (L".hwp" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP;
|
||||
if (L".hwpx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX;
|
||||
if (L".md" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_MD;
|
||||
|
||||
if (L".pptx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX;
|
||||
@ -1884,10 +1553,6 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP_FLAT;
|
||||
if (L".otp" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP;
|
||||
if (L".odg" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_ODG;
|
||||
if (L".key" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
|
||||
|
||||
if (L".xlsx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
|
||||
@ -1915,8 +1580,6 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS;
|
||||
if (L".ods" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS;
|
||||
if (L".numbers" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
|
||||
|
||||
if (L".ooxml" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_OTHER_OOXML;
|
||||
@ -1929,8 +1592,6 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU;
|
||||
if (L".xps" == ext || L".oxps" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS;
|
||||
if (L"ofd" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD;
|
||||
|
||||
if (L".jpg" == ext || L".jpeg" == ext || L".jpe" == ext || L".jfif" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_IMAGE_JPG;
|
||||
@ -1965,8 +1626,6 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY;
|
||||
if (L".pptt" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY;
|
||||
if (L".vsdt" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_TEAMLAB_VSDY;
|
||||
|
||||
if (L".vsdx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DRAW_VSDX;
|
||||
@ -2069,26 +1728,3 @@ bool COfficeFileFormatChecker::isXpsFile(const std::wstring &fileName)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isOFDFile(const std::wstring& fileName)
|
||||
{
|
||||
COfficeUtils OfficeUtils(NULL);
|
||||
|
||||
ULONG nBufferSize = 0;
|
||||
BYTE *pBuffer = NULL;
|
||||
|
||||
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"OFD.xml", &pBuffer, nBufferSize);
|
||||
if (hresult == S_OK && pBuffer != NULL)
|
||||
{
|
||||
if (19 <= nBufferSize && NULL != strstr((char *)pBuffer, "ofd:OFD"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD;
|
||||
|
||||
delete[] pBuffer;
|
||||
pBuffer = NULL;
|
||||
|
||||
if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -56,10 +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 + 0x001a
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_MD AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x001b
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_XML AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0030
|
||||
|
||||
@ -76,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
|
||||
@ -92,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
|
||||
@ -104,7 +98,6 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLRMenu AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0007
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLRCanvas AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0008
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDFA AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0009
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x000a
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_IMAGE 0x0400
|
||||
#define AVS_OFFICESTUDIO_FILE_IMAGE_JPG AVS_OFFICESTUDIO_FILE_IMAGE + 0x0001
|
||||
@ -140,14 +133,12 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY AVS_OFFICESTUDIO_FILE_TEAMLAB + 0x0001
|
||||
#define AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY AVS_OFFICESTUDIO_FILE_TEAMLAB + 0x0002
|
||||
#define AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY AVS_OFFICESTUDIO_FILE_TEAMLAB + 0x0003
|
||||
#define AVS_OFFICESTUDIO_FILE_TEAMLAB_VSDY AVS_OFFICESTUDIO_FILE_TEAMLAB + 0x0004
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS 0x2000
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS_WORD AVS_OFFICESTUDIO_FILE_CANVAS + 0x0001
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET AVS_OFFICESTUDIO_FILE_CANVAS + 0x0002
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION AVS_OFFICESTUDIO_FILE_CANVAS + 0x0003
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS_PDF AVS_OFFICESTUDIO_FILE_CANVAS + 0x0004
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS_DRAW AVS_OFFICESTUDIO_FILE_CANVAS + 0x0005
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW 0x4000
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSDX AVS_OFFICESTUDIO_FILE_DRAW + 0x0001
|
||||
|
||||
146
Common/base.pri
146
Common/base.pri
@ -47,7 +47,7 @@ win32 {
|
||||
DEFINES += COPYRIGHT_YEAR=$${CURRENT_YEAR}
|
||||
|
||||
QMAKE_TARGET_COMPANY = $$PUBLISHER_NAME
|
||||
QMAKE_TARGET_COPYRIGHT = © $${PUBLISHER_NAME} $${CURRENT_YEAR}. All rights reserved.
|
||||
QMAKE_TARGET_COPYRIGHT = Copyright (C) $${PUBLISHER_NAME} $${CURRENT_YEAR}. All rights reserved
|
||||
|
||||
# CONFIGURATION
|
||||
CONFIG(debug, debug|release) {
|
||||
@ -91,10 +91,6 @@ isEqual(QT_MAJOR_VERSION, 5) {
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5) {
|
||||
DEFINES += QT_VERSION_6
|
||||
|
||||
core_windows {
|
||||
QMAKE_CXXFLAGS += /permissive-
|
||||
}
|
||||
}
|
||||
|
||||
ios {
|
||||
@ -112,35 +108,6 @@ win32:contains(QMAKE_TARGET.arch, x86_64): {
|
||||
win32:!contains(QMAKE_TARGET.arch, x86_64): {
|
||||
CONFIG += core_win_32
|
||||
}
|
||||
win32:contains(QMAKE_TARGET.arch, arm64): {
|
||||
CONFIG -= core_win_32
|
||||
CONFIG += core_win_arm64
|
||||
}
|
||||
|
||||
linux-clang-libc++ {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_64
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-64-clang-libc++")
|
||||
}
|
||||
linux-clang-libc++-32 {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_32
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-32-clang-libc++")
|
||||
}
|
||||
linux-clang {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_64
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-64-clang")
|
||||
}
|
||||
linux-clang-32 {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_32
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-32-clang")
|
||||
}
|
||||
|
||||
linux-g++ {
|
||||
CONFIG += core_linux
|
||||
@ -198,8 +165,6 @@ core_windows {
|
||||
DEFINES += WIN32 _WIN32
|
||||
DEFINES += NOMINMAX
|
||||
|
||||
#DEFINES += WIN32_LEAN_AND_MEAN
|
||||
|
||||
# use default _ITERATOR_DEBUG_LEVEL value
|
||||
#core_debug:DEFINES += "_ITERATOR_DEBUG_LEVEL=0"
|
||||
}
|
||||
@ -209,25 +174,6 @@ core_win_64 {
|
||||
|
||||
core_linux {
|
||||
DEFINES += LINUX _LINUX
|
||||
|
||||
QMAKE_CUSTOM_SYSROOT = $$(QMAKE_CUSTOM_SYSROOT)
|
||||
QMAKE_CUSTOM_SYSROOT_BIN = $$(QMAKE_CUSTOM_SYSROOT)/usr/bin/
|
||||
|
||||
core_linux_64 {
|
||||
!linux_arm64 { # x86_64
|
||||
QMAKE_CUSTOM_SYSROOT_LIB = $$(QMAKE_CUSTOM_SYSROOT)/usr/lib/x86_64-linux-gnu
|
||||
!isEmpty(QMAKE_CUSTOM_SYSROOT) {
|
||||
message("using custom sysroot $$QMAKE_CUSTOM_SYSROOT")
|
||||
QMAKE_CC = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "gcc")
|
||||
QMAKE_CXX = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
|
||||
QMAKE_LINK = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
|
||||
QMAKE_LINK_SHLIB = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
|
||||
|
||||
QMAKE_CXXFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
QMAKE_LFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
core_linux_host_arm64 {
|
||||
message("build on arm64")
|
||||
@ -240,11 +186,7 @@ core_mac {
|
||||
QMAKE_LFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH
|
||||
|
||||
# xcode15 add new linker
|
||||
greaterThan(QMAKE_XCODE_VERSION, 1499) {
|
||||
QMAKE_LFLAGS += -Wl,-ld_classic
|
||||
} else {
|
||||
CONFIG += c++14
|
||||
}
|
||||
QMAKE_LFLAGS += -Wl,-ld_classic
|
||||
|
||||
QMAKE_CFLAGS += "-Wno-implicit-function-declaration"
|
||||
|
||||
@ -254,15 +196,11 @@ core_mac {
|
||||
}
|
||||
}
|
||||
|
||||
core_linux_clang {
|
||||
QMAKE_CFLAGS += -Wno-implicit-function-declaration
|
||||
}
|
||||
|
||||
# PREFIXES
|
||||
core_windows {
|
||||
CONFIG -= debug_and_release debug_and_release_target
|
||||
QMAKE_CXXFLAGS_RELEASE += /Zc:strictStrings-
|
||||
QMAKE_CXXFLAGS += /Zc:strictStrings-
|
||||
QMAKE_CXXFLAGS_RELEASE -= -Zc:strictStrings
|
||||
QMAKE_CXXFLAGS -= -Zc:strictStrings
|
||||
QMAKE_CXXFLAGS += /MP
|
||||
|
||||
MSVC_VERSION_DETECT = $$(VisualStudioVersion)
|
||||
@ -318,9 +256,6 @@ core_win_32 {
|
||||
core_win_64 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = win_64
|
||||
}
|
||||
core_win_arm64 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = win_arm64
|
||||
}
|
||||
core_linux_32 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = linux_32
|
||||
}
|
||||
@ -347,8 +282,8 @@ linux_arm64 {
|
||||
|
||||
!isEmpty(ARM64_TOOLCHAIN_BIN){
|
||||
!isEmpty(ARM64_TOOLCHAIN_BIN_PREFIX){
|
||||
|
||||
ARM64_TOOLCHAIN_BIN_FULL = $$ARM64_TOOLCHAIN_BIN/$$ARM64_TOOLCHAIN_BIN_PREFIX
|
||||
message("using arm64 toolchain $$ARM64_TOOLCHAIN_BIN")
|
||||
|
||||
QMAKE_CC = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "gcc")
|
||||
QMAKE_CXX = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "g++")
|
||||
@ -481,12 +416,6 @@ message($$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX)
|
||||
# COMPILER
|
||||
CONFIG += c++11
|
||||
|
||||
#CONFIG += enable_cpp_17
|
||||
enable_cpp_17 {
|
||||
CONFIG += c++1z
|
||||
DEFINES += _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
|
||||
}
|
||||
|
||||
!core_windows {
|
||||
QMAKE_CXXFLAGS += -Wno-register
|
||||
QMAKE_CFLAGS += -Wno-register
|
||||
@ -494,11 +423,7 @@ enable_cpp_17 {
|
||||
|
||||
core_linux {
|
||||
core_static_link_libstd {
|
||||
!core_linux_clang {
|
||||
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
|
||||
} else {
|
||||
# TODO: add libc++abi?
|
||||
}
|
||||
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
|
||||
message(core_static_link_libstd)
|
||||
}
|
||||
plugin {
|
||||
@ -608,45 +533,42 @@ core_windows {
|
||||
DEFINES += CRYPTOPP_DISABLE_ASM
|
||||
}
|
||||
|
||||
core_ios|core_mac {
|
||||
CONFIG += support_bundle_dylibs
|
||||
}
|
||||
core_ios:CONFIG+=support_bundle_dylibs
|
||||
|
||||
!support_bundle_dylibs:CONFIG-=bundle_dylibs
|
||||
|
||||
bundle_dylibs {
|
||||
plugin {
|
||||
CONFIG -= plugin
|
||||
CONFIG += lib_bundle
|
||||
core_ios {
|
||||
bundle_dylibs {
|
||||
plugin {
|
||||
CONFIG -= plugin
|
||||
CONFIG += lib_bundle
|
||||
|
||||
QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
|
||||
#QMAKE_LFLAGS += -Xlinker -rpath -Xlinker @executable_path/Frameworks
|
||||
#QMAKE_LFLAGS += -Xlinker -rpath -Xlinker @loader_path/Frameworks
|
||||
QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
|
||||
#QMAKE_LFLAGS += -Xlinker -rpath -Xlinker @executable_path/Frameworks
|
||||
#QMAKE_LFLAGS += -Xlinker -rpath -Xlinker @loader_path/Frameworks
|
||||
|
||||
# correct version to < 256
|
||||
VERSIONS = $$split(VERSION, ".")
|
||||
VERSION_1 = $$member(VERSIONS, 0)
|
||||
VERSION_2 = $$member(VERSIONS, 1)
|
||||
VERSION_3 = $$member(VERSIONS, 2)
|
||||
VERSION_4 = $$member(VERSIONS, 3)
|
||||
# correct version to < 256
|
||||
VERSIONS = $$split(VERSION, ".")
|
||||
VERSION_1 = $$member(VERSIONS, 0)
|
||||
VERSION_2 = $$member(VERSIONS, 1)
|
||||
VERSION_3 = $$member(VERSIONS, 2)
|
||||
VERSION_4 = $$member(VERSIONS, 3)
|
||||
|
||||
greaterThan(VERSION_1, 255): VERSION_1 = 255
|
||||
greaterThan(VERSION_2, 255): VERSION_2 = 255
|
||||
greaterThan(VERSION_3, 255): VERSION_3 = 255
|
||||
greaterThan(VERSION_4, 255): VERSION_4 = 255
|
||||
greaterThan(VERSION_1, 255): VERSION_1 = 255
|
||||
greaterThan(VERSION_2, 255): VERSION_2 = 255
|
||||
greaterThan(VERSION_3, 255): VERSION_3 = 255
|
||||
greaterThan(VERSION_4, 255): VERSION_4 = 255
|
||||
|
||||
VERSION_CORRECT = $$VERSION_1
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_2)
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_3)
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_4)
|
||||
VERSION_CORRECT = $$VERSION_1
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_2)
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_3)
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_4)
|
||||
|
||||
VERSION = $$VERSION_CORRECT
|
||||
MAJOR_VERSION = $$VERSION_1
|
||||
# set framework version as A
|
||||
QMAKE_FRAMEWORK_VERSION = A
|
||||
VERSION = $$VERSION_CORRECT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1
Common/js/.gitignore
vendored
1
Common/js/.gitignore
vendored
@ -1,2 +1 @@
|
||||
emsdk
|
||||
__pycache__
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -416,16 +416,6 @@ namespace agg
|
||||
{
|
||||
return self_type(rgba::from_wavelength(wl, gamma));
|
||||
}
|
||||
|
||||
bool operator==(const self_type& other)
|
||||
{
|
||||
return a == other.a && r == other.r && g == other.g && b == other.b;
|
||||
}
|
||||
|
||||
bool operator!=(const self_type& other)
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -207,9 +207,9 @@ namespace agg
|
||||
}
|
||||
|
||||
p[Order::A] = (value_type)((alpha + a) - ((alpha * a + base_mask) >> base_shift));
|
||||
if (r != cr) p[Order::R] = (value_type)((alpha * cr + a * r - ((a * r * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
if (g != cg) p[Order::G] = (value_type)((alpha * cg + a * g - ((a * g * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
if (b != cb) p[Order::B] = (value_type)((alpha * cb + a * b - ((a * b * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
p[Order::R] = (value_type)((alpha * cr + a * r - ((a * r * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
p[Order::G] = (value_type)((alpha * cg + a * g - ((a * g * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
p[Order::B] = (value_type)((alpha * cb + a * b - ((a * b * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
}
|
||||
|
||||
static AGG_INLINE void blend_pix_subpix(value_type* p,
|
||||
@ -1465,29 +1465,7 @@ namespace agg
|
||||
}
|
||||
};
|
||||
|
||||
template<class ColorT, class Order> struct comp_op_rgba_draw_on_black
|
||||
{
|
||||
typedef ColorT color_type;
|
||||
typedef Order order_type;
|
||||
typedef typename color_type::value_type value_type;
|
||||
typedef typename color_type::calc_type calc_type;
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask
|
||||
};
|
||||
|
||||
static AGG_INLINE void blend_pix(value_type* p,
|
||||
unsigned sr, unsigned sg, unsigned sb,
|
||||
unsigned sa, unsigned cover)
|
||||
{
|
||||
|
||||
if (0x00 != p[Order::R] || 0x00 != p[Order::G] || 0x00 != p[Order::B])
|
||||
return;
|
||||
|
||||
comp_op_rgba_src_over <ColorT,Order>::blend_pix(p, sr, sg, sb, sa, cover);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1537,9 +1515,6 @@ namespace agg
|
||||
comp_op_rgba_contrast <ColorT,Order>::blend_pix,
|
||||
comp_op_rgba_invert <ColorT,Order>::blend_pix,
|
||||
comp_op_rgba_invert_rgb <ColorT,Order>::blend_pix,
|
||||
|
||||
//Custom function
|
||||
comp_op_rgba_draw_on_black<ColorT,Order>::blend_pix,
|
||||
0
|
||||
};
|
||||
|
||||
@ -1576,9 +1551,6 @@ namespace agg
|
||||
comp_op_invert, //----comp_op_invert
|
||||
comp_op_invert_rgb, //----comp_op_invert_rgb
|
||||
|
||||
//Custom modes
|
||||
comp_op_draw_on_black, //----comp_op_draw_on_black
|
||||
|
||||
end_of_comp_op_e
|
||||
};
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -1000,17 +1032,7 @@ namespace agg
|
||||
{
|
||||
if (i < RES && j < RES)
|
||||
{
|
||||
if (m_oGradientInfo.luminocity)
|
||||
{
|
||||
ColorT fillC;
|
||||
fillC.r = m_oGradientInfo.shading.fill_color.r * c.r / 255 + 255 - c.r;
|
||||
fillC.g = m_oGradientInfo.shading.fill_color.g * c.g / 255 + 255 - c.g;
|
||||
fillC.b = m_oGradientInfo.shading.fill_color.b * c.b / 255 + 255 - c.b;
|
||||
fillC.a = 255;
|
||||
precalc[i][j] = fillC;
|
||||
}
|
||||
else
|
||||
precalc[i][j] = c;
|
||||
precalc[i][j] = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -506,7 +506,7 @@ namespace NSDirectory
|
||||
rmdir((char*)pUtf8);
|
||||
delete [] pUtf8;
|
||||
|
||||
if (deleteRoot == false)CreateDirectory(strDirectory);
|
||||
if (deleteRoot = false)CreateDirectory(strDirectory);
|
||||
#elif MAC
|
||||
BYTE* pUtf8 = NULL;
|
||||
LONG lLen = 0;
|
||||
@ -514,7 +514,7 @@ namespace NSDirectory
|
||||
rmdir((char*)pUtf8);
|
||||
delete [] pUtf8;
|
||||
|
||||
if (deleteRoot == false)CreateDirectory(strDirectory);
|
||||
if (deleteRoot = false)CreateDirectory(strDirectory);
|
||||
#endif
|
||||
}
|
||||
std::wstring GetFolderPath(const std::wstring& wsFolderPath)
|
||||
|
||||
@ -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())
|
||||
@ -1629,10 +1624,6 @@ namespace NSFile
|
||||
{
|
||||
wsTemp = L"";
|
||||
}
|
||||
#if defined(_WIN32) || defined (_WIN64)
|
||||
if (wsTempDir)
|
||||
free(wsTempDir);
|
||||
#endif
|
||||
wsTemp += L"x";
|
||||
int nTime = (int)time(NULL);
|
||||
for (int nIndex = 0; nIndex < 1000; ++nIndex)
|
||||
@ -1868,7 +1859,7 @@ namespace NSFile
|
||||
|
||||
namespace NSFile
|
||||
{
|
||||
bool CBase64Converter::Encode(const BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags)
|
||||
bool CBase64Converter::Encode(BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags)
|
||||
{
|
||||
if (!pDataSrc || nLenSrc < 1)
|
||||
return false;
|
||||
|
||||
@ -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);
|
||||
@ -212,7 +211,7 @@ namespace NSFile
|
||||
class KERNEL_DECL CBase64Converter
|
||||
{
|
||||
public:
|
||||
static bool Encode(const BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags = NSBase64::B64_BASE64_FLAG_NONE);
|
||||
static bool Encode(BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags = NSBase64::B64_BASE64_FLAG_NONE);
|
||||
static bool Decode(const char* pDataSrc, int nLenSrc, BYTE*& pDataDst, int& nLenDst);
|
||||
};
|
||||
|
||||
|
||||
@ -46,7 +46,6 @@ namespace NSProcessEnv
|
||||
static const char* gc_proxy = "proxy";
|
||||
static const char* gc_proxyUser = "proxyUser";
|
||||
static const char* gc_proxyHeader = "proxyHeader";
|
||||
static const char* gc_oformAsPdf = "oformAsPdf";
|
||||
}
|
||||
|
||||
// serialize
|
||||
|
||||
@ -319,14 +319,7 @@ namespace NSStringUtils
|
||||
{
|
||||
WriteEncodeXmlString(sString.c_str(), (int)sString.length());
|
||||
}
|
||||
void CStringBuilder::WriteEncodeXmlString(const std::string& sString)
|
||||
{
|
||||
WriteEncodeXmlString(std::wstring(sString.begin(), sString.end()));
|
||||
}
|
||||
void CStringBuilder::WriteUtf8EncodeXmlString(const std::string& sString)
|
||||
{
|
||||
WriteEncodeXmlString(NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sString.c_str(), sString.size()));
|
||||
}
|
||||
|
||||
void CStringBuilder::WriteEncodeXmlString(const wchar_t* pString, int nCount)
|
||||
{
|
||||
if (sizeof(wchar_t) == 2)
|
||||
@ -689,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;
|
||||
|
||||
@ -110,9 +110,6 @@ namespace NSStringUtils
|
||||
void WriteEncodeXmlString(const std::wstring& sString);
|
||||
void WriteEncodeXmlString(const wchar_t* pString, int nCount = -1);
|
||||
|
||||
void WriteEncodeXmlString(const std::string& sString);
|
||||
void WriteUtf8EncodeXmlString(const std::string& sString);
|
||||
|
||||
void WriteEncodeXmlStringHHHH(const std::wstring& sString);
|
||||
void WriteEncodeXmlStringHHHH(const wchar_t* pString, int nCount = -1);
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
@ -59,7 +59,7 @@ namespace NSSystemUtils
|
||||
static const wchar_t* gc_EnvLastModifiedBy = L"LAST_MODIFIED_BY";
|
||||
static const wchar_t* gc_EnvModified = L"MODIFIED";
|
||||
static const wchar_t* gc_EnvMemoryLimit = L"X2T_MEMORY_LIMIT";
|
||||
static const wchar_t* gc_EnvMemoryLimitDefault = L"3GiB";
|
||||
static const wchar_t* gc_EnvMemoryLimitDefault = L"4GiB";
|
||||
|
||||
KERNEL_DECL std::string GetEnvVariableA(const std::wstring& strName);
|
||||
KERNEL_DECL std::wstring GetEnvVariable(const std::wstring& strName);
|
||||
|
||||
@ -46,10 +46,8 @@
|
||||
#define CXIMAGE_SUPPORT_PSD 1
|
||||
|
||||
#ifndef BUILDING_WASM_MODULE
|
||||
#define CXIMAGE_SUPPORT_HEIF 1
|
||||
#define CXIMAGE_SUPPORT_RAW 1
|
||||
#else
|
||||
#define CXIMAGE_SUPPORT_HEIF 0
|
||||
#define CXIMAGE_SUPPORT_RAW 0
|
||||
#endif
|
||||
|
||||
|
||||
@ -133,17 +133,13 @@ CXIMAGE_FORMAT_PSD = 20,
|
||||
#if CXIMAGE_SUPPORT_PIC
|
||||
CXIMAGE_FORMAR_PIC = 25,
|
||||
#endif
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
CXIMAGE_FORMAT_HEIF = 26,
|
||||
#endif
|
||||
CMAX_IMAGE_FORMATS = CXIMAGE_SUPPORT_BMP + CXIMAGE_SUPPORT_GIF + CXIMAGE_SUPPORT_JPG +
|
||||
CXIMAGE_SUPPORT_PNG + CXIMAGE_SUPPORT_MNG + CXIMAGE_SUPPORT_ICO +
|
||||
CXIMAGE_SUPPORT_TIF + CXIMAGE_SUPPORT_TGA + CXIMAGE_SUPPORT_PCX +
|
||||
CXIMAGE_SUPPORT_WBMP+ CXIMAGE_SUPPORT_WMF + CXIMAGE_SUPPORT_PIC +
|
||||
CXIMAGE_SUPPORT_JBG + CXIMAGE_SUPPORT_JP2 + CXIMAGE_SUPPORT_JPC +
|
||||
CXIMAGE_SUPPORT_PGX + CXIMAGE_SUPPORT_PNM + CXIMAGE_SUPPORT_RAS +
|
||||
CXIMAGE_SUPPORT_SKA + CXIMAGE_SUPPORT_RAW + CXIMAGE_SUPPORT_PSD +
|
||||
CXIMAGE_SUPPORT_HEIF + 1
|
||||
CXIMAGE_SUPPORT_SKA + CXIMAGE_SUPPORT_RAW + CXIMAGE_SUPPORT_PSD + 1
|
||||
};
|
||||
|
||||
#if CXIMAGE_SUPPORT_EXIF
|
||||
|
||||
@ -332,7 +332,6 @@
|
||||
* DBL_MAX Maximum floating point number (can be set to an arbitrary value)
|
||||
*/
|
||||
# include <float.h>
|
||||
# include <math.h>
|
||||
|
||||
# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
|
||||
defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
|
||||
|
||||
@ -23,14 +23,14 @@
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma warning (disable : 4550)
|
||||
|
||||
#pragma warning (disable : 4550)
|
||||
|
||||
/*
|
||||
* TIFF Library
|
||||
*
|
||||
* Read and return a packed RGBA image.
|
||||
*/
|
||||
*/
|
||||
#include "tiffiop.h"
|
||||
#include <stdio.h>
|
||||
|
||||
@ -828,12 +828,11 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
nrowsub = nrow;
|
||||
if ((nrowsub%subsamplingver)!=0)
|
||||
nrowsub+=subsamplingver-nrowsub%subsamplingver;
|
||||
|
||||
if (TIFFReadEncodedStrip(tif,
|
||||
TIFFComputeStrip(tif,row+img->row_offset, 0),
|
||||
buf,
|
||||
((row + img->row_offset)%rowsperstrip + nrowsub) * scanline) < 0
|
||||
&& img->stoponerr)
|
||||
((row + img->row_offset)%rowsperstrip + nrowsub) * scanline) < 0
|
||||
&& img->stoponerr)
|
||||
{
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
@ -33,7 +33,6 @@
|
||||
#include "./../common_deploy.h"
|
||||
#include "../docbuilder.h"
|
||||
#include "../../common/File.h"
|
||||
#include "../../common/SystemUtils.h"
|
||||
|
||||
#ifdef LINUX
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
@ -79,15 +78,6 @@ void parse_args(NSDoctRenderer::CDocBuilder* builder, int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckLicense(const std::wstring& sSrc, const std::wstring& sDst)
|
||||
{
|
||||
if (sDst.empty())
|
||||
return false;
|
||||
NSFile::CFileBinary::Remove(sDst);
|
||||
NSFile::CFileBinary::Copy(sSrc, sDst);
|
||||
return NSFile::CFileBinary::Exists(sDst);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
int wmain(int argc, wchar_t *argv[])
|
||||
#else
|
||||
@ -99,7 +89,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
bool bIsHelp = false;
|
||||
bool bIsFonts = false;
|
||||
bool bIsLicense = false;
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
#ifdef WIN32
|
||||
@ -132,33 +121,6 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
bIsFonts = true;
|
||||
}
|
||||
else if (sParam == "-register")
|
||||
{
|
||||
bIsLicense = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bIsLicense)
|
||||
{
|
||||
std::wstring sLicensePathSrc = UTF8_TO_U(sParam);
|
||||
if (!NSFile::CFileBinary::Exists(sLicensePathSrc))
|
||||
return 1;
|
||||
|
||||
std::wstring sLicensePath = NSSystemUtils::GetEnvVariable(L"ONLYOFFICE_BUILDER_LICENSE");
|
||||
if (CheckLicense(sLicensePathSrc, sLicensePath))
|
||||
return 0;
|
||||
|
||||
sLicensePath = NSFile::GetProcessDirectory() + L"/license.xml";
|
||||
if (CheckLicense(sLicensePathSrc, sLicensePath))
|
||||
return 0;
|
||||
|
||||
sLicensePath = NSSystemUtils::GetAppDataDir() + L"/docbuilder/license.xml";
|
||||
if (CheckLicense(sLicensePathSrc, sLicensePath))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bIsFonts)
|
||||
|
||||
@ -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
|
||||
@ -191,7 +188,7 @@ namespace NSDoctRenderer
|
||||
m_strSdkPath = oNode.ReadNodeText(L"sdkjs");
|
||||
if (!m_strSdkPath.empty())
|
||||
{
|
||||
if (0 == m_strSdkPath.find(L"./") || !NSDirectory::Exists(m_strSdkPath))
|
||||
if (!NSDirectory::Exists(m_strSdkPath))
|
||||
m_strSdkPath = sConfigDir + m_strSdkPath;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -47,6 +47,14 @@ namespace NSDoctRenderer
|
||||
RELEASEOBJECT(m_pInternal);
|
||||
}
|
||||
|
||||
int CDocBuilder::OpenFile(const wchar_t* path, const wchar_t* params)
|
||||
{
|
||||
m_pInternal->m_nFileType = -1;
|
||||
if (!NSDirectory::Exists(m_pInternal->m_sTmpFolder))
|
||||
NSDirectory::CreateDirectory(m_pInternal->m_sTmpFolder);
|
||||
|
||||
return m_pInternal->OpenFile(path, params);
|
||||
}
|
||||
int CDocBuilder::SaveFile(const int& type, const wchar_t* path, const wchar_t* params)
|
||||
{
|
||||
return m_pInternal->SaveFile(type, path, params);
|
||||
@ -57,7 +65,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
bool CDocBuilder::ExecuteCommand(const wchar_t* command, CDocBuilderValue* retValue)
|
||||
{
|
||||
return m_pInternal->ExecuteCommand(command, retValue, false, false);
|
||||
return m_pInternal->ExecuteCommand(command, retValue);
|
||||
}
|
||||
|
||||
CDocBuilderContext CDocBuilder::GetContext(bool enterContext)
|
||||
|
||||
@ -475,13 +475,6 @@ namespace NSDoctRenderer
|
||||
*/
|
||||
void SetPropertyW(const wchar_t* param, const wchar_t* value);
|
||||
|
||||
/**
|
||||
* GetProperty method.
|
||||
* @param param The parameter name in the Unicode format, the value is always --argument.
|
||||
* @return int value for property
|
||||
*/
|
||||
int GetPropertyInt(const wchar_t* param);
|
||||
|
||||
/**
|
||||
* Writes data to the log file. It is used for logs in JS code.
|
||||
* @param path The path to the file where all the logs will be written.
|
||||
@ -533,7 +526,6 @@ namespace NSDoctRenderer
|
||||
CDocBuilder_Private* m_pInternal;
|
||||
|
||||
friend class CBuilderDocumentEmbed;
|
||||
friend class CBuilderEmbed;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -23,30 +23,6 @@ public class NativeLibraryLoader {
|
||||
}
|
||||
}
|
||||
|
||||
private static String libPrefix;
|
||||
private static String libExtension;
|
||||
|
||||
private static boolean loadIfExist(String libPath) {
|
||||
File libFile = new File(libPath);
|
||||
if (libFile.exists()) {
|
||||
System.load(libPath);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void load(Path libDirPath, String libName) {
|
||||
String libPath = libDirPath.resolve(libPrefix + libName + libExtension).toString();
|
||||
if (OSChecker.isMac()) {
|
||||
if (!loadIfExist(libPath)) {
|
||||
// if dylib does not exist, load framework library
|
||||
System.load(libDirPath.resolve(libName + ".framework/" + libName).toString());
|
||||
}
|
||||
} else {
|
||||
System.load(libPath);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
Path libDirPath = getLibPath();
|
||||
@ -55,8 +31,8 @@ public class NativeLibraryLoader {
|
||||
System.load(libDirPath.resolve("icudt58.dll").toString());
|
||||
System.load(libDirPath.resolve("icuuc58.dll").toString());
|
||||
} else if (OSChecker.isMac()) {
|
||||
loadIfExist(libDirPath.resolve("libicudata.58.dylib").toString());
|
||||
loadIfExist(libDirPath.resolve("libicuuc.58.dylib").toString());
|
||||
System.load(libDirPath.resolve("libicudata.58.dylib").toString());
|
||||
System.load(libDirPath.resolve("libicuuc.58.dylib").toString());
|
||||
} else if (OSChecker.isLinux()) {
|
||||
System.load(libDirPath.resolve("libicudata.so.58").toString());
|
||||
System.load(libDirPath.resolve("libicuuc.so.58").toString());
|
||||
@ -66,25 +42,24 @@ public class NativeLibraryLoader {
|
||||
|
||||
String[] libs = {"UnicodeConverter", "kernel", "kernel_network", "graphics", "PdfFile", "XpsFile", "DjVuFile", "DocxRenderer", "doctrenderer", "docbuilder.jni"};
|
||||
|
||||
libPrefix = "";
|
||||
String prefix = "";
|
||||
if (OSChecker.isMac() || OSChecker.isLinux()) {
|
||||
libPrefix = "lib";
|
||||
prefix = "lib";
|
||||
}
|
||||
|
||||
libExtension = "";
|
||||
String extension = "";
|
||||
if (OSChecker.isWindows()) {
|
||||
libExtension = ".dll";
|
||||
extension = ".dll";
|
||||
} else if (OSChecker.isMac()) {
|
||||
libExtension = ".dylib";
|
||||
extension = ".dylib";
|
||||
} else {
|
||||
libExtension = ".so";
|
||||
extension = ".so";
|
||||
}
|
||||
|
||||
for (String lib : libs) {
|
||||
load(libDirPath, lib);
|
||||
System.load(libDirPath.resolve(prefix + lib + extension).toString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
throw new RuntimeException("Cannot load dynamic libraries. Check if JAR file is in the same directory as all docbuilder libraries.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,18 +16,18 @@ static std::wstring wstringFromJavaString(JNIEnv* env, jstring jstr)
|
||||
return wstr;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1Create(JNIEnv* env, jclass cls)
|
||||
jlong Java_docbuilder_CDocBuilder_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilder());
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
void Java_docbuilder_CDocBuilder_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1OpenFile(JNIEnv* env, jclass cls, jlong self, jstring path, jstring params)
|
||||
jint Java_docbuilder_CDocBuilder_c_1OpenFile(JNIEnv* env, jclass cls, jlong self, jstring path, jstring params)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
@ -35,34 +35,34 @@ JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1OpenFile(JNIEnv* env, jcla
|
||||
return (jint)pSelf->OpenFile(strPath.c_str(), strParams.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1CreateFileByType(JNIEnv* env, jclass cls, jlong self, jint type)
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1CreateFileByType(JNIEnv* env, jclass cls, jlong self, jint type)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return (jboolean)pSelf->CreateFile((int)type);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1CreateFileByExtension(JNIEnv* env, jclass cls, jlong self, jstring extension)
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1CreateFileByExtension(JNIEnv* env, jclass cls, jlong self, jstring extension)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strExtension = wstringFromJavaString(env, extension);
|
||||
return (jboolean)pSelf->CreateFile(strExtension.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1SetTmpFolder(JNIEnv* env, jclass cls, jlong self, jstring folder)
|
||||
void Java_docbuilder_CDocBuilder_c_1SetTmpFolder(JNIEnv* env, jclass cls, jlong self, jstring folder)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strFolder = wstringFromJavaString(env, folder);
|
||||
pSelf->SetTmpFolder(strFolder.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByType(JNIEnv* env, jclass cls, jlong self, jint type, jstring path)
|
||||
jint Java_docbuilder_CDocBuilder_c_1SaveFileByType(JNIEnv* env, jclass cls, jlong self, jint type, jstring path)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
return (jint)pSelf->SaveFile((int)type, strPath.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByTypeWithParams(JNIEnv* env, jclass cls, jlong self, jint type, jstring path, jstring params)
|
||||
jint Java_docbuilder_CDocBuilder_c_1SaveFileByTypeWithParams(JNIEnv* env, jclass cls, jlong self, jint type, jstring path, jstring params)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
@ -70,7 +70,7 @@ JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByTypeWithParams(J
|
||||
return (jint)pSelf->SaveFile((int)type, strPath.c_str(), strParams.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByExtension(JNIEnv* env, jclass cls, jlong self, jstring extension, jstring path)
|
||||
jint Java_docbuilder_CDocBuilder_c_1SaveFileByExtension(JNIEnv* env, jclass cls, jlong self, jstring extension, jstring path)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strExtension = wstringFromJavaString(env, extension);
|
||||
@ -78,7 +78,7 @@ JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByExtension(JNIEnv
|
||||
return (jint)pSelf->SaveFile(strExtension.c_str(), strPath.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByExtensionWithParams(JNIEnv* env, jclass cls, jlong self, jstring extension, jstring path, jstring params)
|
||||
jint Java_docbuilder_CDocBuilder_c_1SaveFileByExtensionWithParams(JNIEnv* env, jclass cls, jlong self, jstring extension, jstring path, jstring params)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strExtension = wstringFromJavaString(env, extension);
|
||||
@ -87,20 +87,20 @@ JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByExtensionWithPar
|
||||
return (jint)pSelf->SaveFile(strExtension.c_str(), strPath.c_str(), strParams.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1CloseFile(JNIEnv* env, jclass cls, jlong self)
|
||||
void Java_docbuilder_CDocBuilder_c_1CloseFile(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
pSelf->CloseFile();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1ExecuteCommand(JNIEnv* env, jclass cls, jlong self, jstring command)
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1ExecuteCommand(JNIEnv* env, jclass cls, jlong self, jstring command)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strCommand = wstringFromJavaString(env, command);
|
||||
return (jboolean)pSelf->ExecuteCommand(strCommand.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1ExecuteCommandWithRetValue(JNIEnv* env, jclass cls, jlong self, jstring command, jlong retValue)
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1ExecuteCommandWithRetValue(JNIEnv* env, jclass cls, jlong self, jstring command, jlong retValue)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strCommand = wstringFromJavaString(env, command);
|
||||
@ -108,14 +108,14 @@ JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1ExecuteCommandWithRetV
|
||||
return (jboolean)pSelf->ExecuteCommand(strCommand.c_str(), pRetValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1Run(JNIEnv* env, jclass cls, jlong self, jstring path)
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1Run(JNIEnv* env, jclass cls, jlong self, jstring path)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
return (jboolean)pSelf->Run(strPath.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1RunText(JNIEnv* env, jclass cls, jlong self, jstring commands)
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1RunText(JNIEnv* env, jclass cls, jlong self, jstring commands)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
const char* strUtfCommands = env->GetStringUTFChars(commands, nullptr);
|
||||
@ -124,7 +124,7 @@ JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1RunText(JNIEnv* env, j
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring param, jstring value)
|
||||
void Java_docbuilder_CDocBuilder_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring param, jstring value)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
const char* strUtfParam = env->GetStringUTFChars(param, nullptr);
|
||||
@ -133,7 +133,7 @@ JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1SetProperty(JNIEnv* env, j
|
||||
env->ReleaseStringUTFChars(param, strUtfParam);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1WriteData(JNIEnv* env, jclass cls, jlong self, jstring path, jstring data, jboolean append)
|
||||
void Java_docbuilder_CDocBuilder_c_1WriteData(JNIEnv* env, jclass cls, jlong self, jstring path, jstring data, jboolean append)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
@ -141,13 +141,13 @@ JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1WriteData(JNIEnv* env, jcl
|
||||
pSelf->WriteData(strPath.c_str(), strData.c_str(), (bool)append);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1IsSaveWithDoctrendererMode(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1IsSaveWithDoctrendererMode(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return (jboolean)pSelf->IsSaveWithDoctrendererMode();
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_docbuilder_CDocBuilder_c_1GetVersion(JNIEnv* env, jclass cls, jlong self)
|
||||
jstring Java_docbuilder_CDocBuilder_c_1GetVersion(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
char* strUtfVersion = pSelf->GetVersion();
|
||||
@ -156,30 +156,30 @@ JNIEXPORT jstring JNICALL Java_docbuilder_CDocBuilder_c_1GetVersion(JNIEnv* env,
|
||||
return jstrVersion;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1GetContext(JNIEnv* env, jclass cls, jlong self)
|
||||
jlong Java_docbuilder_CDocBuilder_c_1GetContext(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext(pSelf->GetContext()));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1GetContextWithEnterParam(JNIEnv* env, jclass cls, jlong self, jboolean enterContext)
|
||||
jlong Java_docbuilder_CDocBuilder_c_1GetContextWithEnterParam(JNIEnv* env, jclass cls, jlong self, jboolean enterContext)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext(pSelf->GetContext((bool)enterContext)));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Initialize(JNIEnv* env, jclass cls)
|
||||
void Java_docbuilder_CDocBuilder_c_1Initialize(JNIEnv* env, jclass cls)
|
||||
{
|
||||
CDocBuilder::Initialize();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1InitializeWithDirectory(JNIEnv* env, jclass cls, jstring directory)
|
||||
void Java_docbuilder_CDocBuilder_c_1InitializeWithDirectory(JNIEnv* env, jclass cls, jstring directory)
|
||||
{
|
||||
std::wstring strDirectory = wstringFromJavaString(env, directory);
|
||||
CDocBuilder::Initialize(strDirectory.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Dispose(JNIEnv* env, jclass cls)
|
||||
void Java_docbuilder_CDocBuilder_c_1Dispose(JNIEnv* env, jclass cls)
|
||||
{
|
||||
CDocBuilder::Dispose();
|
||||
}
|
||||
|
||||
@ -4,60 +4,60 @@
|
||||
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1Create(JNIEnv* env, jclass cls)
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext());
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
{
|
||||
CDocBuilderContext* pOther = reinterpret_cast<CDocBuilderContext*>(other);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext(*pOther));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderContext_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
void Java_docbuilder_CDocBuilderContext_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateUndefined(JNIEnv* env, jclass cls, jlong self)
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateUndefined(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->CreateUndefined()));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateNull(JNIEnv* env, jclass cls, jlong self)
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateNull(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->CreateNull()));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateObject(JNIEnv* env, jclass cls, jlong self)
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateObject(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->CreateObject()));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateArray(JNIEnv* env, jclass cls, jlong self, jint length)
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateArray(JNIEnv* env, jclass cls, jlong self, jint length)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->CreateArray((int)length)));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1GetGlobal(JNIEnv* env, jclass cls, jlong self)
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1GetGlobal(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->GetGlobal()));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateScope(JNIEnv* env, jclass cls, jlong self)
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateScope(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContextScope(pSelf->CreateScope()));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderContext_c_1IsError(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderContext_c_1IsError(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return (jboolean)pSelf->IsError();
|
||||
|
||||
@ -4,24 +4,24 @@
|
||||
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Create(JNIEnv* env, jclass cls)
|
||||
jlong Java_docbuilder_CDocBuilderContextScope_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContextScope());
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
jlong Java_docbuilder_CDocBuilderContextScope_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
{
|
||||
CDocBuilderContextScope* pOther = reinterpret_cast<CDocBuilderContextScope*>(other);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContextScope(*pOther));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
void Java_docbuilder_CDocBuilderContextScope_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContextScope* pSelf = reinterpret_cast<CDocBuilderContextScope*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Close(JNIEnv* env, jclass cls, jlong self)
|
||||
void Java_docbuilder_CDocBuilderContextScope_c_1Close(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContextScope* pSelf = reinterpret_cast<CDocBuilderContextScope*>(self);
|
||||
pSelf->Close();
|
||||
|
||||
@ -8,114 +8,114 @@
|
||||
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Create(JNIEnv* env, jclass cls)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue());
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
{
|
||||
CDocBuilderValue* pOther = reinterpret_cast<CDocBuilderValue*>(other);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(*pOther));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
void Java_docbuilder_CDocBuilderValue_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsEmpty(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsEmpty(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsEmpty();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1Clear(JNIEnv* env, jclass cls, jlong self)
|
||||
void Java_docbuilder_CDocBuilderValue_c_1Clear(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
pSelf->Clear();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsNull(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsNull(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsNull();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsUndefined(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsUndefined(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsUndefined();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsBool(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsBool(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsBool();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsInt(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsInt(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsInt();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsDouble();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsString(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsString(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsString();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsFunction(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsFunction(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsFunction();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsObject(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsObject(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsObject();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsArray(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsArray(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsArray();
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilderValue_c_1GetLength(JNIEnv* env, jclass cls, jlong self)
|
||||
jint Java_docbuilder_CDocBuilderValue_c_1GetLength(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jint)pSelf->GetLength();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1ToBool(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1ToBool(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->ToBool();
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilderValue_c_1ToInt(JNIEnv* env, jclass cls, jlong self)
|
||||
jint Java_docbuilder_CDocBuilderValue_c_1ToInt(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jint)pSelf->ToInt();
|
||||
}
|
||||
|
||||
JNIEXPORT jdouble JNICALL Java_docbuilder_CDocBuilderValue_c_1ToDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
jdouble Java_docbuilder_CDocBuilderValue_c_1ToDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jdouble)pSelf->ToDouble();
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_docbuilder_CDocBuilderValue_c_1ToString(JNIEnv* env, jclass cls, jlong self)
|
||||
jstring Java_docbuilder_CDocBuilderValue_c_1ToString(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CString strValue = pSelf->ToString();
|
||||
@ -123,7 +123,7 @@ JNIEXPORT jstring JNICALL Java_docbuilder_CDocBuilderValue_c_1ToString(JNIEnv* e
|
||||
return env->NewStringUTF(strUtfData.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1GetProperty(JNIEnv* env, jclass cls, jlong self, jstring name)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1GetProperty(JNIEnv* env, jclass cls, jlong self, jstring name)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
const char* strUtfName = env->GetStringUTFChars(name, nullptr);
|
||||
@ -132,14 +132,14 @@ JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1GetProperty(JNIEnv*
|
||||
return reinterpret_cast<jlong>(pValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1GetByIndex(JNIEnv* env, jclass cls, jlong self, jint index)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1GetByIndex(JNIEnv* env, jclass cls, jlong self, jint index)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pValue = new CDocBuilderValue(pSelf->Get((int)index));
|
||||
return reinterpret_cast<jlong>(pValue);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring name, jlong value)
|
||||
void Java_docbuilder_CDocBuilderValue_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring name, jlong value)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pValue = reinterpret_cast<CDocBuilderValue*>(value);
|
||||
@ -149,29 +149,29 @@ JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1SetProperty(JNIEnv* e
|
||||
env->ReleaseStringUTFChars(name, strUtfName);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1SetByIndex(JNIEnv* env, jclass cls, jlong self, jint index, jlong value)
|
||||
void Java_docbuilder_CDocBuilderValue_c_1SetByIndex(JNIEnv* env, jclass cls, jlong self, jint index, jlong value)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pValue = reinterpret_cast<CDocBuilderValue*>(value);
|
||||
pSelf->Set((int)index, *pValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithBool(JNIEnv* env, jclass cls, jboolean value)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithBool(JNIEnv* env, jclass cls, jboolean value)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue((bool)value));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithInt(JNIEnv* env, jclass cls, jint value)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithInt(JNIEnv* env, jclass cls, jint value)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue((int)value));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithDouble(JNIEnv* env, jclass cls, jdouble value)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithDouble(JNIEnv* env, jclass cls, jdouble value)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue((double)value));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithString(JNIEnv* env, jclass cls, jstring str)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithString(JNIEnv* env, jclass cls, jstring str)
|
||||
{
|
||||
const char* strUtf = env->GetStringUTFChars(str, nullptr);
|
||||
CDocBuilderValue* pValue = new CDocBuilderValue(strUtf);
|
||||
@ -179,22 +179,22 @@ JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithString(JNI
|
||||
return reinterpret_cast<jlong>(pValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateUndefined(JNIEnv* env, jclass cls)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateUndefined(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(CDocBuilderValue::CreateUndefined()));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateNull(JNIEnv* env, jclass cls)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateNull(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(CDocBuilderValue::CreateNull()));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateArray(JNIEnv* env, jclass cls, jint length)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateArray(JNIEnv* env, jclass cls, jint length)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(CDocBuilderValue::CreateArray((int)length)));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call0(JNIEnv* env, jclass cls, jlong self, jstring name)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call0(JNIEnv* env, jclass cls, jlong self, jstring name)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
const char* strUtfName = env->GetStringUTFChars(name, nullptr);
|
||||
@ -203,7 +203,7 @@ JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call0(JNIEnv* env, j
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call1(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call1(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
@ -213,7 +213,7 @@ JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call1(JNIEnv* env, j
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call2(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call2(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
@ -224,7 +224,7 @@ JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call2(JNIEnv* env, j
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call3(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call3(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
@ -236,7 +236,7 @@ JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call3(JNIEnv* env, j
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call4(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call4(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
@ -249,7 +249,7 @@ JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call4(JNIEnv* env, j
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call5(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4, jlong p5)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call5(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4, jlong p5)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
@ -263,7 +263,7 @@ JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call5(JNIEnv* env, j
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call6(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4, jlong p5, jlong p6)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call6(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4, jlong p5, jlong p6)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
|
||||
@ -1 +0,0 @@
|
||||
deploy/
|
||||
@ -2,7 +2,6 @@ import ctypes
|
||||
import os
|
||||
import platform
|
||||
import atexit
|
||||
import subprocess
|
||||
|
||||
OBJECT_HANDLE = ctypes.c_void_p
|
||||
STRING_HANDLE = ctypes.c_void_p
|
||||
@ -24,10 +23,6 @@ def _loadLibrary(path):
|
||||
library_name = 'libdocbuilder.c.so'
|
||||
elif 'darwin' == os_name:
|
||||
library_name = 'libdocbuilder.c.dylib'
|
||||
# if there is no dylib file, get library from framework
|
||||
if not os.path.exists(path + '/' + library_name):
|
||||
path = path + '/docbuilder.c.framework'
|
||||
library_name = 'docbuilder.c'
|
||||
|
||||
_lib = ctypes.CDLL(path + '/' + library_name)
|
||||
|
||||
@ -387,20 +382,6 @@ class CDocBuilderValue:
|
||||
def __setitem__(self, key, value):
|
||||
self.Set(key, value)
|
||||
|
||||
def __getattr__(self, name):
|
||||
def method(*args):
|
||||
return self.Call(name, *args)
|
||||
return method
|
||||
|
||||
def __len__(self):
|
||||
return self.GetLength()
|
||||
|
||||
def __iter__(self):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not iterable")
|
||||
for i in range(self.GetLength()):
|
||||
yield self.Get(i)
|
||||
|
||||
@staticmethod
|
||||
def CreateUndefined():
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_CreateUndefined()))
|
||||
@ -442,36 +423,6 @@ class CDocBuilderValue:
|
||||
else:
|
||||
raise TypeError("Call() expects at most 6 arguments")
|
||||
|
||||
def append(self, value):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not an array")
|
||||
length = self.GetLength()
|
||||
self.Set(length, value)
|
||||
return self
|
||||
|
||||
def extend(self, iterable):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not an array")
|
||||
length = self.GetLength()
|
||||
for i, value in enumerate(iterable, start=length):
|
||||
self.Set(i, value)
|
||||
return self
|
||||
|
||||
def insert(self, i, x):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not an array")
|
||||
length = self.GetLength()
|
||||
if i < 0:
|
||||
if abs(i) > length:
|
||||
raise IndexError("list index out of range")
|
||||
i = max(0, length + i)
|
||||
if i >= length:
|
||||
raise IndexError("list index out of range")
|
||||
for idx in range(length, i, -1):
|
||||
self.Set(idx, self.Get(idx - 1))
|
||||
self.Set(i, x)
|
||||
|
||||
|
||||
class CDocBuilder:
|
||||
_initialized = False
|
||||
|
||||
@ -483,7 +434,7 @@ class CDocBuilder:
|
||||
# using self._lib instead of global _lib because it might be already garbage collected during this function call
|
||||
self._lib.CDocBuilder_Destroy(self._internal)
|
||||
|
||||
def OpenFile(self, path, params=""):
|
||||
def OpenFile(self, path, params):
|
||||
return _lib.CDocBuilder_OpenFile(self._internal, ctypes.c_wchar_p(path), ctypes.c_wchar_p(params))
|
||||
|
||||
def CreateFile(self, type):
|
||||
@ -657,17 +608,8 @@ class FileTypes:
|
||||
PNG = _IMAGE_MASK + 0x0005
|
||||
BMP = _IMAGE_MASK + 0x0008
|
||||
|
||||
# NOTE: do not change builder_path manually!
|
||||
builder_path = os.path.dirname(os.path.realpath(__file__))
|
||||
_loadLibrary(builder_path)
|
||||
CDocBuilder.Initialize(builder_path)
|
||||
|
||||
def registerLibrary(license_path):
|
||||
docbuilder_bin = os.path.join(builder_path, "docbuilder")
|
||||
if ("windows" == platform.system().lower()):
|
||||
docbuilder_bin += ".exe"
|
||||
return subprocess.call([docbuilder_bin, "-register", license_path], stderr=subprocess.STDOUT, shell=True)
|
||||
command = docbuilder_bin + " -register \"" + license_path.replace('\"', '\\\"') + "\""
|
||||
return subprocess.call(command, stderr=subprocess.STDOUT, shell=True)
|
||||
|
||||
atexit.register(CDocBuilder.Dispose)
|
||||
|
||||
@ -13,16 +13,16 @@ scope = context.CreateScope()
|
||||
globalObj = context.GetGlobal()
|
||||
|
||||
api = globalObj['Api']
|
||||
document = api.GetDocument()
|
||||
paragraph1 = api.CreateParagraph()
|
||||
paragraph1.SetSpacingAfter(1000, False)
|
||||
paragraph1.AddText('Hello from Python!')
|
||||
document = api.Call('GetDocument')
|
||||
paragraph1 = api.Call('CreateParagraph')
|
||||
paragraph1.Call('SetSpacingAfter', 1000, False)
|
||||
paragraph1.Call('AddText', 'Hello from Python!')
|
||||
|
||||
paragraph2 = api.CreateParagraph()
|
||||
paragraph2.AddText('Goodbye!')
|
||||
paragraph2 = api.Call('CreateParagraph')
|
||||
paragraph2.Call('AddText', 'Goodbye!')
|
||||
|
||||
content = [paragraph1, paragraph2]
|
||||
document.InsertContent(content)
|
||||
document.Call('InsertContent', content)
|
||||
|
||||
dstPath = os.getcwd() + '/result.docx'
|
||||
builder.SaveFile(docbuilder.FileTypes.Document.DOCX, dstPath)
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
sys.path.append('path_to_docbuilder')
|
||||
import docbuilder
|
||||
|
||||
builder = docbuilder.CDocBuilder()
|
||||
|
||||
builder.CreateFile(docbuilder.FileTypes.Document.DOCX)
|
||||
|
||||
context = builder.GetContext()
|
||||
scope = context.CreateScope()
|
||||
|
||||
globalObj = context.GetGlobal()
|
||||
|
||||
api = globalObj['Api']
|
||||
document = api.Call('GetDocument')
|
||||
paragraph1 = api.Call('CreateParagraph')
|
||||
paragraph1.Call('SetSpacingAfter', 1000, False)
|
||||
paragraph1.Call('AddText', 'Hello from Python!')
|
||||
|
||||
paragraph2 = api.Call('CreateParagraph')
|
||||
paragraph2.Call('AddText', 'Goodbye!')
|
||||
|
||||
content = [paragraph1, paragraph2]
|
||||
document.Call('InsertContent', content)
|
||||
|
||||
dstPath = os.getcwd() + '/result.docx'
|
||||
builder.SaveFile(docbuilder.FileTypes.Document.DOCX, dstPath)
|
||||
builder.CloseFile()
|
||||
@ -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();
|
||||
@ -74,7 +75,6 @@ CV8RealTimeWorker::CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder, cons
|
||||
global->set("native", oNativeCtrl);
|
||||
|
||||
CBuilderEmbed* pBuilderJSNative = static_cast<CBuilderEmbed*>(oBuilderJS->getNative());
|
||||
pBuilderJSNative->SetExternalize(true);
|
||||
pBuilderJSNative->m_pBuilder = pBuilder;
|
||||
}
|
||||
CV8RealTimeWorker::~CV8RealTimeWorker()
|
||||
@ -83,7 +83,7 @@ CV8RealTimeWorker::~CV8RealTimeWorker()
|
||||
m_context->Dispose();
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue, const bool& isEnterContextSrc)
|
||||
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue)
|
||||
{
|
||||
LOGGER_SPEED_START();
|
||||
|
||||
@ -93,24 +93,14 @@ bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRender
|
||||
std::string commandA = U_TO_UTF8(command);
|
||||
//commandA = "Api." + commandA;
|
||||
|
||||
bool isEnterContext = isEnterContextSrc;
|
||||
if (!isEnterContext && !m_context->IsEntered())
|
||||
isEnterContext = true;
|
||||
|
||||
if (isEnterContext)
|
||||
m_context->Enter();
|
||||
|
||||
CJSContextScope scope(m_context);
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
|
||||
LOGGER_SPEED_LAP("compile_command");
|
||||
|
||||
JSSmart<CJSValue> retNativeVal = m_context->runScript(commandA, try_catch);
|
||||
if(try_catch->Check())
|
||||
{
|
||||
if (isEnterContext)
|
||||
m_context->Exit();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (retValue)
|
||||
{
|
||||
@ -121,9 +111,6 @@ bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRender
|
||||
|
||||
LOGGER_SPEED_LAP("run_command");
|
||||
|
||||
if (isEnterContext)
|
||||
m_context->Exit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -254,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;
|
||||
}
|
||||
|
||||
@ -318,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";
|
||||
|
||||
@ -358,17 +337,7 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri
|
||||
return !bIsBreak;
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::NewSimpleJSInstance()
|
||||
{
|
||||
return InitVariables();
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::IsSimpleJSInstance()
|
||||
{
|
||||
return (-1 == m_nFileType);
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams, const bool& isEnterContext)
|
||||
bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams)
|
||||
{
|
||||
NSDoctRenderer::DoctRendererFormat::FormatFile _formatDst = NSDoctRenderer::DoctRendererFormat::DOCT;
|
||||
if (type & AVS_OFFICESTUDIO_FILE_PRESENTATION)
|
||||
@ -394,9 +363,7 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
}
|
||||
}
|
||||
|
||||
if (isEnterContext)
|
||||
m_context->Enter();
|
||||
|
||||
CJSContextScope scope(m_context);
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
|
||||
NSNativeControl::CNativeControl* pNative = NULL;
|
||||
@ -425,7 +392,7 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
bIsSilentMode = true;
|
||||
|
||||
if (bIsSilentMode)
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(false);", NULL, isEnterContext);
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(false);");
|
||||
|
||||
std::wstring strError;
|
||||
bool bIsError = Doct_renderer_SaveFile_ForBuilder(_formatDst,
|
||||
@ -437,10 +404,7 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
sJsonParams);
|
||||
|
||||
if (bIsSilentMode)
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(true);", NULL, isEnterContext);
|
||||
|
||||
if (isEnterContext)
|
||||
m_context->Exit();
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(true);");
|
||||
|
||||
return bIsError;
|
||||
}
|
||||
@ -1242,13 +1206,13 @@ namespace NSDoctRenderer
|
||||
|
||||
while (true)
|
||||
{
|
||||
while (_currentPos < _commandsLen && !((_commandsPtr[_currentPos] == '\"' || _commandsPtr[_currentPos] == '\'') && _commandsPtr[_currentPos - 1] != '\\'))
|
||||
while (_currentPos < _commandsLen && !(_commandsPtr[_currentPos] == '\"' && _commandsPtr[_currentPos - 1] != '\\'))
|
||||
++_currentPos;
|
||||
|
||||
++_currentPos;
|
||||
size_t _start = _currentPos;
|
||||
|
||||
while (_currentPos < _commandsLen && !((_commandsPtr[_currentPos] == '\"' || _commandsPtr[_currentPos] == '\'') && _commandsPtr[_currentPos - 1] != '\\'))
|
||||
while (_currentPos < _commandsLen && !(_commandsPtr[_currentPos] == '\"' && _commandsPtr[_currentPos - 1] != '\\'))
|
||||
++_currentPos;
|
||||
|
||||
if (_currentPos > _start)
|
||||
@ -1268,29 +1232,8 @@ namespace NSDoctRenderer
|
||||
nCount = nIndex;
|
||||
}
|
||||
|
||||
int CDocBuilder::OpenFile(const wchar_t* path, const wchar_t* params)
|
||||
{
|
||||
if (m_pInternal->m_nFileType != -1 && m_pInternal->m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
m_pInternal->m_bIsOpenedFromSimpleJS = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_pInternal->m_nFileType = -1;
|
||||
if (!NSDirectory::Exists(m_pInternal->m_sTmpFolder))
|
||||
NSDirectory::CreateDirectory(m_pInternal->m_sTmpFolder);
|
||||
|
||||
return m_pInternal->OpenFile(path, params);
|
||||
}
|
||||
|
||||
bool CDocBuilder::CreateFile(const int& type)
|
||||
{
|
||||
if (m_pInternal->m_nFileType != -1 && m_pInternal->m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
m_pInternal->m_bIsOpenedFromSimpleJS = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_pInternal->m_nFileType = -1;
|
||||
if (!NSDirectory::Exists(m_pInternal->m_sTmpFolder))
|
||||
NSDirectory::CreateDirectory(m_pInternal->m_sTmpFolder);
|
||||
@ -1449,7 +1392,7 @@ namespace NSDoctRenderer
|
||||
if (!sJsCommands.empty())
|
||||
{
|
||||
std::wstring sUnicodeCommand = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sJsCommands.c_str(), (LONG)sJsCommands.length());
|
||||
bIsNoError = this->m_pInternal->ExecuteCommand(sUnicodeCommand.c_str(), NULL, bIsBuilderJSCloseFile);
|
||||
bIsNoError = this->ExecuteCommand(sUnicodeCommand.c_str());
|
||||
sJsCommands = "";
|
||||
if (!bIsNoError)
|
||||
return false;
|
||||
@ -1471,10 +1414,6 @@ namespace NSDoctRenderer
|
||||
if (0 == _builder_params[nCheckParam].find(L"jsValue(") && _builder_params[nCheckParam].length() > 9)
|
||||
{
|
||||
std::wstring sParam = _builder_params[nCheckParam].substr(8, _builder_params[nCheckParam].length() - 9);
|
||||
|
||||
if (NULL == m_pInternal->m_pWorker)
|
||||
m_pInternal->CheckWorker();
|
||||
|
||||
_builder_params[nCheckParam] = m_pInternal->m_pWorker->GetJSVariable(sParam);
|
||||
}
|
||||
}
|
||||
@ -1514,8 +1453,7 @@ namespace NSDoctRenderer
|
||||
if (nCountParameters > 2)
|
||||
sParams = _builder_params[2].c_str();
|
||||
|
||||
int nSaveError = this->SaveFile(nFormat, _builder_params[1].c_str(), sParams);
|
||||
bIsNoError = (0 == nSaveError);
|
||||
this->SaveFile(nFormat, _builder_params[1].c_str(), sParams);
|
||||
}
|
||||
else if ("WriteData" == sFuncNum)
|
||||
{
|
||||
@ -1541,7 +1479,7 @@ namespace NSDoctRenderer
|
||||
{
|
||||
// Такого быть не должно!!! Так как результат никуда не сохранится. пустое действие.
|
||||
std::wstring sUnicodeCommand = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sJsCommands.c_str(), (LONG)sJsCommands.length());
|
||||
bool bIsNoError = this->m_pInternal->ExecuteCommand(sUnicodeCommand.c_str(), NULL, true);
|
||||
bool bIsNoError = this->ExecuteCommand(sUnicodeCommand.c_str());
|
||||
sJsCommands = "";
|
||||
if (!bIsNoError)
|
||||
return false;
|
||||
@ -1602,15 +1540,6 @@ namespace NSDoctRenderer
|
||||
return this->SetProperty(sA.c_str(), value);
|
||||
}
|
||||
|
||||
int CDocBuilder::GetPropertyInt(const wchar_t* param)
|
||||
{
|
||||
std::wstring sParam = std::wstring(param);
|
||||
std::string sParamA = U_TO_UTF8(sParam);
|
||||
if ("--save-use-only-names" == sParamA)
|
||||
return m_pInternal->m_bIsServerSafeVersion ? 1 : 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CDocBuilder::Initialize(const wchar_t* directory)
|
||||
{
|
||||
std::wstring sDirectory = L"";
|
||||
|
||||
@ -63,8 +63,6 @@
|
||||
|
||||
#include "../common/ProcessEnv.h"
|
||||
|
||||
#include "docbuilder_addon.h"
|
||||
|
||||
#ifdef CreateFile
|
||||
#undef CreateFile
|
||||
#endif
|
||||
@ -424,7 +422,6 @@ public:
|
||||
int m_nFileType;
|
||||
std::string m_sUtf8ArgumentJSON;
|
||||
std::string m_sGlobalVariable;
|
||||
std::string m_sJSCodeStart;
|
||||
|
||||
CJSContextData m_oContextData;
|
||||
|
||||
@ -437,17 +434,14 @@ public:
|
||||
|
||||
static void _LOGGING_ERROR_(const std::wstring& strType, const std::wstring& strError);
|
||||
|
||||
bool ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue = NULL, const bool& isEnterContext = true);
|
||||
bool ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue = NULL);
|
||||
|
||||
std::string GetGlobalVariable();
|
||||
std::wstring GetJSVariable(std::wstring sParam);
|
||||
|
||||
bool OpenFile(const std::wstring& sBasePath, const std::wstring& path, const NSDoctRenderer::DoctRendererEditorType& editorType, NSDoctRenderer::CDoctRendererConfig* config, CV8Params* pParams = NULL);
|
||||
bool SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams = L"", const bool& isEnterContext = true);
|
||||
bool SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams = L"");
|
||||
bool InitVariables();
|
||||
|
||||
bool NewSimpleJSInstance();
|
||||
bool IsSimpleJSInstance();
|
||||
};
|
||||
|
||||
namespace NSDoctRenderer
|
||||
@ -461,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;
|
||||
|
||||
@ -481,13 +474,11 @@ namespace NSDoctRenderer
|
||||
|
||||
NSDoctRenderer::CDocBuilder* m_pParent;
|
||||
|
||||
bool m_bIsOpenedFromSimpleJS;
|
||||
|
||||
static std::wstring m_sExternalDirectory;
|
||||
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_bIsOpenedFromSimpleJS(false)
|
||||
m_sGlobalVariable(""), m_bIsGlobalVariableUse(false), m_pParent(NULL), m_bJavascriptBeforeEditor(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -547,7 +538,6 @@ namespace NSDoctRenderer
|
||||
CApplicationFontsWorker oWorker;
|
||||
oWorker.m_bIsUseSystemFonts = m_oParams.m_bIsSystemFonts;
|
||||
oWorker.m_arAdditionalFolders = m_oParams.m_arFontDirs;
|
||||
oWorker.m_arAdditionalFolders.push_back(NSFile::GetProcessDirectory() + L"/fonts");
|
||||
oWorker.m_bIsNeedThumbnails = false;
|
||||
oWorker.m_sDirectory = sDirectory;
|
||||
// это не рабочая папка, где только шрифты
|
||||
@ -647,15 +637,11 @@ namespace NSDoctRenderer
|
||||
{
|
||||
NSDirectory::CreateDirectory(m_sFileDir + L"/media");
|
||||
NSDirectory::CreateDirectory(m_sFileDir + L"/changes");
|
||||
|
||||
if (m_pWorker && m_pWorker->IsSimpleJSInstance() && !m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
RELEASEOBJECT(m_pWorker);
|
||||
CheckWorker();
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
if (m_bJavascriptBeforeEditor)
|
||||
CheckWorkerAfterOpen();
|
||||
|
||||
return bRet;
|
||||
#else
|
||||
std::wstring sPath = m_sX2tPath + L"/empty/new.";
|
||||
@ -742,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>");
|
||||
@ -928,7 +923,7 @@ namespace NSDoctRenderer
|
||||
|
||||
COfficeFileFormatChecker oChecker;
|
||||
if (!oChecker.isOfficeFile(sFileCopy))
|
||||
return 1;
|
||||
return false;
|
||||
|
||||
if (oChecker.nFileType & AVS_OFFICESTUDIO_FILE_DOCUMENT)
|
||||
m_nFileType = 0;
|
||||
@ -945,11 +940,8 @@ namespace NSDoctRenderer
|
||||
|
||||
if (0 == nReturnCode)
|
||||
{
|
||||
if (m_pWorker && m_pWorker->IsSimpleJSInstance() && !m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
RELEASEOBJECT(m_pWorker);
|
||||
CheckWorker();
|
||||
}
|
||||
if (m_bJavascriptBeforeEditor)
|
||||
CheckWorkerAfterOpen();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -998,16 +990,10 @@ namespace NSDoctRenderer
|
||||
return _path;
|
||||
}
|
||||
|
||||
int SaveFile(const int& type, const std::wstring& path, const wchar_t* params = NULL, const bool& isEnterContext = true)
|
||||
int SaveFile(const int& type, const std::wstring& path, const wchar_t* params = NULL)
|
||||
{
|
||||
Init();
|
||||
|
||||
CDocBuilderAddon oSaveAddon(m_sX2tPath);
|
||||
|
||||
int nPreSaveError = oSaveAddon.GetX2tPreSaveError(m_pParent, m_nFileType);
|
||||
if (0 != nPreSaveError)
|
||||
return nPreSaveError;
|
||||
|
||||
if (-1 == m_nFileType)
|
||||
{
|
||||
CV8RealTimeWorker::_LOGGING_ERROR_(L"error (save)", L"file not opened!");
|
||||
@ -1046,7 +1032,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
}
|
||||
|
||||
this->m_pWorker->SaveFileWithChanges(type, m_sFileDir + L"/Editor2.bin", sJsonParams, isEnterContext);
|
||||
this->m_pWorker->SaveFileWithChanges(type, m_sFileDir + L"/Editor2.bin", sJsonParams);
|
||||
sFileBin = L"/Editor2.bin";
|
||||
}
|
||||
|
||||
@ -1068,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())
|
||||
{
|
||||
@ -1091,8 +1086,6 @@ namespace NSDoctRenderer
|
||||
if (!sOptions.empty())
|
||||
oBuilder.WriteString(UTF8_TO_U(sOptions));
|
||||
|
||||
oBuilder.WriteString(oSaveAddon.GetX2tSaveAddon(m_pParent, m_nFileType));
|
||||
|
||||
oBuilder.WriteString(L"</TaskQueueDataConvert>");
|
||||
|
||||
std::wstring sXmlConvert = oBuilder.GetData();
|
||||
@ -1245,75 +1238,62 @@ namespace NSDoctRenderer
|
||||
{
|
||||
if (NULL == m_pWorker)
|
||||
{
|
||||
NSDoctRenderer::DoctRendererEditorType editorType = GetEditorType();
|
||||
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_pWorker->m_nFileType = m_nFileType;
|
||||
|
||||
if (-1 != m_nFileType)
|
||||
m_sCommandsBeforeContextCreated = L"";
|
||||
else
|
||||
{
|
||||
m_pWorker->NewSimpleJSInstance();
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
return SaveFile(nType, path, params);
|
||||
}
|
||||
|
||||
bool ExecuteCommand(const std::wstring& command, CDocBuilderValue* retValue = NULL, const bool& forceExecute = false, const bool& isEnterContext = true)
|
||||
bool ExecuteCommand(const std::wstring& command, CDocBuilderValue* retValue = NULL)
|
||||
{
|
||||
if (command.length() < 7 && !retValue) // minimum command (!!!)
|
||||
return true;
|
||||
|
||||
if (m_nFileType == -1 && !forceExecute)
|
||||
{
|
||||
m_sCommandsBeforeContextCreated += command;
|
||||
return true;
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
if (CheckWorker())
|
||||
{
|
||||
bool bIsOpenedFromSimpleJSOld = m_bIsOpenedFromSimpleJS;
|
||||
bool bResult = m_pWorker->ExecuteCommand(command, retValue, isEnterContext);
|
||||
if (!bResult && !bIsOpenedFromSimpleJSOld && m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
RELEASEOBJECT(m_pWorker);
|
||||
CheckWorker();
|
||||
return m_pWorker->ExecuteCommand(command, retValue, isEnterContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bResult;
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -1,130 +0,0 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
VERSION = 1.0.0.3
|
||||
TARGET = doctrenderer
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += shared
|
||||
CONFIG += plugin
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
|
||||
PWD_CUR = $$PWD
|
||||
include($$PWD_CUR/../../Common/base.pri)
|
||||
|
||||
DEFINES += DOCTRENDERER_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
DEFINES += JSBASE_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, kernel_network)
|
||||
|
||||
#CONFIG += build_xp
|
||||
#CONFIG += v8_version_60
|
||||
core_android:DEFINES += DISABLE_MEMORY_LIMITATION
|
||||
|
||||
HEADERS += \
|
||||
$$PWD_CUR/config.h \
|
||||
$$PWD_CUR/editors.h \
|
||||
$$PWD_CUR/doctrenderer.h \
|
||||
$$PWD_CUR/docbuilder.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/editors.cpp \
|
||||
$$PWD_CUR/nativecontrol.cpp \
|
||||
$$PWD_CUR/doctrenderer.cpp \
|
||||
$$PWD_CUR/docbuilder.cpp \
|
||||
$$PWD_CUR/docbuilder_p.cpp \
|
||||
$$PWD_CUR/graphics.cpp \
|
||||
$$PWD_CUR/hash.cpp
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/../../Common/OfficeFileFormatChecker2.cpp \
|
||||
$$PWD_CUR/../../Common/3dParty/pole/pole.cpp \
|
||||
$$PWD_CUR/../../OOXML/Base/unicode_util.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD_CUR/docbuilder_p.h \
|
||||
$$PWD_CUR/nativecontrol.h \
|
||||
$$PWD_CUR/graphics.h \
|
||||
$$PWD_CUR/hash.h \
|
||||
$$PWD_CUR/server.h
|
||||
|
||||
HEADERS += \
|
||||
$$PWD_CUR/embed/PointerEmbed.h \
|
||||
$$PWD_CUR/embed/ZipEmbed.h \
|
||||
$$PWD_CUR/embed/GraphicsEmbed.h \
|
||||
$$PWD_CUR/embed/MemoryStreamEmbed.h \
|
||||
$$PWD_CUR/embed/NativeControlEmbed.h \
|
||||
$$PWD_CUR/embed/NativeBuilderEmbed.h \
|
||||
$$PWD_CUR/embed/NativeBuilderDocumentEmbed.h \
|
||||
$$PWD_CUR/embed/TextMeasurerEmbed.h \
|
||||
$$PWD_CUR/embed/HashEmbed.h \
|
||||
$$PWD_CUR/embed/Default.h \
|
||||
$$PWD_CUR/js_internal/js_base.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/embed/PointerEmbed.cpp \
|
||||
$$PWD_CUR/embed/ZipEmbed.cpp \
|
||||
$$PWD_CUR/embed/GraphicsEmbed.cpp \
|
||||
$$PWD_CUR/embed/MemoryStreamEmbed.cpp \
|
||||
$$PWD_CUR/embed/NativeControlEmbed.cpp \
|
||||
$$PWD_CUR/embed/NativeBuilderEmbed.cpp \
|
||||
$$PWD_CUR/embed/NativeBuilderDocumentEmbed.cpp \
|
||||
$$PWD_CUR/embed/TextMeasurerEmbed.cpp \
|
||||
$$PWD_CUR/embed/HashEmbed.cpp \
|
||||
$$PWD_CUR/embed/Default.cpp
|
||||
|
||||
# Serialize objects to JS
|
||||
HEADERS += \
|
||||
$$PWD_CUR/json/json.h \
|
||||
$$PWD_CUR/json/json_p.h \
|
||||
$$PWD_CUR/json/json_values.h \
|
||||
$$PWD_CUR/json/serialization.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/json/json.cpp \
|
||||
$$PWD_CUR/json/json_values.cpp
|
||||
|
||||
include($$PWD_CUR/js_internal/js_base.pri)
|
||||
|
||||
!use_javascript_core {
|
||||
build_xp:DESTDIR=$$DESTDIR/xp
|
||||
}
|
||||
|
||||
use_javascript_core {
|
||||
OBJECTIVE_SOURCES += $$PWD_CUR/../common/Mac/NSString+StringUtils.mm
|
||||
}
|
||||
|
||||
# files for embedded classes
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/GraphicsEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/HashEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/MemoryStreamEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/NativeBuilderEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/NativeBuilderDocumentEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/NativeControlEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/PointerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/TextMeasurerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/ZipEmbed.h)
|
||||
|
||||
include($$PWD_CUR/../graphics/pro/textshaper.pri)
|
||||
include($$PWD_CUR/../../Common/3dParty/openssl/openssl.pri)
|
||||
|
||||
# downloader
|
||||
DEFINES += BUIDLER_OPEN_DOWNLOAD_ENABLED
|
||||
DEFINES += BUIDLER_OPEN_BASE64_ENABLED
|
||||
|
||||
CONFIG += drawingfile_support
|
||||
drawingfile_support {
|
||||
DEFINES += WASM_SERIALIZER_USE_ALLOCATOR
|
||||
ADD_DEPENDENCY(PdfFile, XpsFile, DjVuFile, DocxRenderer)
|
||||
|
||||
HEADERS += \
|
||||
$$PWD_CUR/drawingfile.h \
|
||||
$$PWD_CUR/embed/DrawingFileEmbed.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/../graphics/pro/js/wasm/src/HTMLRendererText.cpp \
|
||||
$$PWD_CUR/embed/DrawingFileEmbed.cpp
|
||||
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/DrawingFileEmbed.h)
|
||||
}
|
||||
@ -1,3 +1,128 @@
|
||||
INCLUDEPATH += $$PWD/addon
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
include(doctrenderer.pri)
|
||||
VERSION = 1.0.0.3
|
||||
TARGET = doctrenderer
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += shared
|
||||
CONFIG += plugin
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include(../../Common/base.pri)
|
||||
|
||||
DEFINES += DOCTRENDERER_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
DEFINES += JSBASE_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, kernel_network)
|
||||
|
||||
#CONFIG += build_xp
|
||||
#CONFIG += v8_version_60
|
||||
core_android:DEFINES += DISABLE_MEMORY_LIMITATION
|
||||
|
||||
HEADERS += \
|
||||
config.h \
|
||||
editors.h \
|
||||
doctrenderer.h \
|
||||
docbuilder.h
|
||||
|
||||
SOURCES += \
|
||||
editors.cpp \
|
||||
nativecontrol.cpp \
|
||||
doctrenderer.cpp \
|
||||
docbuilder.cpp \
|
||||
docbuilder_p.cpp \
|
||||
graphics.cpp \
|
||||
hash.cpp
|
||||
|
||||
SOURCES += \
|
||||
../../Common/OfficeFileFormatChecker2.cpp \
|
||||
../../Common/3dParty/pole/pole.cpp \
|
||||
../../OOXML/Base/unicode_util.cpp
|
||||
|
||||
HEADERS += \
|
||||
docbuilder_p.h \
|
||||
nativecontrol.h \
|
||||
graphics.h \
|
||||
hash.h \
|
||||
server.h
|
||||
|
||||
HEADERS += \
|
||||
embed/PointerEmbed.h \
|
||||
embed/ZipEmbed.h \
|
||||
embed/GraphicsEmbed.h \
|
||||
embed/MemoryStreamEmbed.h \
|
||||
embed/NativeControlEmbed.h \
|
||||
embed/NativeBuilderEmbed.h \
|
||||
embed/NativeBuilderDocumentEmbed.h \
|
||||
embed/TextMeasurerEmbed.h \
|
||||
embed/HashEmbed.h \
|
||||
embed/Default.h \
|
||||
js_internal/js_base.h
|
||||
|
||||
SOURCES += \
|
||||
embed/PointerEmbed.cpp \
|
||||
embed/ZipEmbed.cpp \
|
||||
embed/GraphicsEmbed.cpp \
|
||||
embed/MemoryStreamEmbed.cpp \
|
||||
embed/NativeControlEmbed.cpp \
|
||||
embed/NativeBuilderEmbed.cpp \
|
||||
embed/NativeBuilderDocumentEmbed.cpp \
|
||||
embed/TextMeasurerEmbed.cpp \
|
||||
embed/HashEmbed.cpp \
|
||||
embed/Default.cpp
|
||||
|
||||
# Serialize objects to JS
|
||||
HEADERS += \
|
||||
json/json.h \
|
||||
json/json_p.h \
|
||||
json/json_values.h \
|
||||
json/serialization.h
|
||||
|
||||
SOURCES += \
|
||||
json/json.cpp \
|
||||
json/json_values.cpp
|
||||
|
||||
include($$PWD/js_internal/js_base.pri)
|
||||
|
||||
!use_javascript_core {
|
||||
build_xp:DESTDIR=$$DESTDIR/xp
|
||||
}
|
||||
|
||||
use_javascript_core {
|
||||
OBJECTIVE_SOURCES += ../common/Mac/NSString+StringUtils.mm
|
||||
}
|
||||
|
||||
# files for embedded classes
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/GraphicsEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/HashEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/MemoryStreamEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/NativeBuilderEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/NativeBuilderDocumentEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/NativeControlEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/PointerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/TextMeasurerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/ZipEmbed.h)
|
||||
|
||||
include(../graphics/pro/textshaper.pri)
|
||||
include(../../Common/3dParty/openssl/openssl.pri)
|
||||
|
||||
# downloader
|
||||
DEFINES += BUIDLER_OPEN_DOWNLOAD_ENABLED
|
||||
DEFINES += BUIDLER_OPEN_BASE64_ENABLED
|
||||
|
||||
CONFIG += drawingfile_support
|
||||
drawingfile_support {
|
||||
DEFINES += WASM_SERIALIZER_USE_ALLOCATOR
|
||||
ADD_DEPENDENCY(PdfFile, XpsFile, DjVuFile, DocxRenderer)
|
||||
|
||||
HEADERS += \
|
||||
drawingfile.h \
|
||||
embed/DrawingFileEmbed.h
|
||||
|
||||
SOURCES += \
|
||||
../../HtmlRenderer/src/HTMLRendererText.cpp \
|
||||
embed/DrawingFileEmbed.cpp
|
||||
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/DrawingFileEmbed.h)
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -171,6 +171,7 @@ public:
|
||||
|
||||
return m_pFile ? true : false;
|
||||
}
|
||||
|
||||
bool OpenFile(BYTE* data, LONG size, const std::wstring& sPassword)
|
||||
{
|
||||
CloseFile();
|
||||
@ -283,34 +284,6 @@ public:
|
||||
return NULL;
|
||||
return m_pFile->ConvertToPixels(nPageIndex, nRasterW, nRasterH, true, m_pFontManager, nBackgroundColor, (nBackgroundColor == 0xFFFFFF) ? false : true);
|
||||
}
|
||||
BYTE* SplitPages(int* arrPageIndex, int nLength, BYTE* data, LONG size)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->SplitPages(arrPageIndex, nLength, data, size);
|
||||
return NULL;
|
||||
}
|
||||
bool MergePages(BYTE* data, LONG size, int nMaxID, const std::string& sPrefixForm, bool bCopy = false)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
{
|
||||
// Память из CDrawingFileEmbed освобождается сразу после вызова функции, поэтому копируем
|
||||
if (bCopy)
|
||||
{
|
||||
BYTE* pCopy = (BYTE*)malloc(size);
|
||||
memcpy(pCopy, data, size);
|
||||
data = pCopy;
|
||||
}
|
||||
// Захватывает полученную память, будет освобождена либо в деструкторе MemStream, либо free в случае неудачи
|
||||
return ((CPdfFile*)m_pFile)->MergePages(data, size, nMaxID, sPrefixForm);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool UnmergePages()
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->UnmergePages();
|
||||
return false;
|
||||
}
|
||||
|
||||
BYTE* GetGlyphs(int nPageIndex)
|
||||
{
|
||||
@ -430,32 +403,22 @@ public:
|
||||
oRenderer.SetExternalImageStorage(m_pImageStorage);
|
||||
oRenderer.SetTextAssociationType(NSDocxRenderer::TextAssociationType::tatParagraphToShape);
|
||||
|
||||
std::vector<std::wstring> arShapes;
|
||||
if (0 == mode)
|
||||
arShapes = oRenderer.ScanPage(m_pFile, nPageIndex);
|
||||
else
|
||||
arShapes = oRenderer.ScanPagePptx(m_pFile, nPageIndex);
|
||||
|
||||
int nLen = (int)arShapes.size();
|
||||
|
||||
NSWasm::CData oRes;
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
{
|
||||
std::vector<std::wstring> arShapes = (0 == mode) ? oRenderer.ScanPage(m_pFile, nPageIndex) : oRenderer.ScanPagePptx(m_pFile, nPageIndex);
|
||||
int nLen = (int)arShapes.size();
|
||||
oRes.SkipLen();
|
||||
oRes.AddInt(nLen);
|
||||
|
||||
oRes.SkipLen();
|
||||
oRes.AddInt(nLen);
|
||||
for (int i = 0; i < nLen; ++i)
|
||||
oRes.WriteString(arShapes[i]);
|
||||
|
||||
for (int i = 0; i < nLen; ++i)
|
||||
oRes.WriteString(arShapes[i]);
|
||||
|
||||
oRes.WriteLen();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
oRes = oRenderer.ScanPageBin(m_pFile, nPageIndex);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
oRes.WriteLen();
|
||||
|
||||
BYTE* res = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
@ -579,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;
|
||||
}
|
||||
|
||||
|
||||
@ -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:
|
||||
{
|
||||
|
||||
@ -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>();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
#include "DrawingFileEmbed.h"
|
||||
#include "../drawingfile.h"
|
||||
#include "../../raster/BgraFrame.h"
|
||||
|
||||
JSSmart<CJSValue> WasmMemoryToJS(BYTE* pWasmData)
|
||||
{
|
||||
@ -166,48 +165,6 @@ JSSmart<CJSValue> CDrawingFileEmbed::FreeWasmData(JSSmart<CJSValue> typedArray)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::SplitPages(JSSmart<CJSValue> arrPageIndexes, JSSmart<CJSValue> data)
|
||||
{
|
||||
JSSmart<CJSArray> arrPages = arrPageIndexes->toArray();
|
||||
CJSDataBuffer changes;
|
||||
if (data->isTypedArray())
|
||||
changes = data->toTypedArray()->getData();
|
||||
|
||||
int nCountPages = arrPages->getCount();
|
||||
int* pPages = NULL;
|
||||
if (0 < nCountPages)
|
||||
pPages = new int[nCountPages];
|
||||
|
||||
for (int i = 0; i < nCountPages; i++)
|
||||
pPages[i] = arrPages->get(i)->toInt32();
|
||||
|
||||
JSSmart<CJSValue> res = WasmMemoryToJS(m_pFile->SplitPages(pPages, nCountPages, changes.Data, (LONG)changes.Len));
|
||||
if (pPages)
|
||||
delete [] pPages;
|
||||
return res;
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::MergePages(JSSmart<CJSValue> data, JSSmart<CJSValue> nMaxID, JSSmart<CJSValue> sPrefixForm)
|
||||
{
|
||||
bool result = false;
|
||||
if (m_pFile)
|
||||
{
|
||||
JSSmart<CJSTypedArray> dataPtr = data->toTypedArray();
|
||||
int maxID = nMaxID->toInt32();
|
||||
std::string prefix = sPrefixForm->toStringA();
|
||||
CJSDataBuffer buffer = dataPtr->getData();
|
||||
result = m_pFile->MergePages(buffer.Data, (LONG)buffer.Len, maxID, prefix, true);
|
||||
if (buffer.IsExternalize)
|
||||
buffer.Free();
|
||||
}
|
||||
return CJSContext::createBool(result);
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::UnmergePages()
|
||||
{
|
||||
if (m_pFile)
|
||||
return CJSContext::createBool(m_pFile->UnmergePages());
|
||||
return CJSContext::createBool(false);
|
||||
}
|
||||
|
||||
bool EmbedDrawingFile(JSSmart<NSJSBase::CJSContext>& context, IOfficeDrawingFile* pFile)
|
||||
{
|
||||
CJSContext::Embed<CDrawingFileEmbed>(false);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user