mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-03-14 00:56:04 +08:00
Compare commits
1 Commits
feature/so
...
feature/gr
| Author | SHA1 | Date | |
|---|---|---|---|
| 5d6f888ae5 |
162
.github/workflows/codeql.yaml
vendored
162
.github/workflows/codeql.yaml
vendored
@ -1,162 +0,0 @@
|
||||
name: "CodeQL Scanner"
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'release/**'
|
||||
- 'hotfix/**'
|
||||
paths-ignore:
|
||||
- '**/README.md'
|
||||
- '**/LICENSE'
|
||||
- '.github/**'
|
||||
#pull_request:
|
||||
# branches:
|
||||
# - 'master'
|
||||
# - 'release/**'
|
||||
# - 'hotfix/**'
|
||||
schedule:
|
||||
- cron: '00 19 * * 5'
|
||||
|
||||
# This job take a lot of time, so if the number of worker
|
||||
# processes from one branch or one PR exceeds 1, all previous
|
||||
# running processes will be automatically canceled to avoid the accumulation
|
||||
# of a large number of concurrent workers
|
||||
concurrency:
|
||||
group: codeql-${{ github.event.pull_request.number || github.ref_name }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
SOURCE_ROOT: "/build/core"
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ${{ 'ubuntu-latest' }}
|
||||
container:
|
||||
image: ${{ matrix.image }}
|
||||
options: --privileged
|
||||
volumes:
|
||||
- /usr/local/lib:/foovolume/android
|
||||
- /usr/local/share:/foovolume/boost
|
||||
- /usr/share:/foovolume/dotnet
|
||||
- /opt:/foovolume/opt
|
||||
- /opt/hostedtoolcache:/foovolume/tool
|
||||
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'c-cpp' ]
|
||||
image: ["ubuntu:20.04"]
|
||||
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
|
||||
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
|
||||
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
|
||||
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: make free space in container
|
||||
run: |
|
||||
rm -rf /foovolume/android/android
|
||||
rm -rf /foovolume/dotnet/dotnet
|
||||
rm -rf /foovolume/boost/boost
|
||||
rm -rf /foovolume/opt/ghc
|
||||
rm -rf /foovolume/tool/*
|
||||
df -h
|
||||
|
||||
# Prepare container environment
|
||||
# Install some deps
|
||||
# Set cache restore keys
|
||||
- name: Prepare environment
|
||||
id: prepare
|
||||
shell: bash
|
||||
env:
|
||||
TZ: Etc/UTC
|
||||
run: |
|
||||
pwd
|
||||
ls -la
|
||||
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
|
||||
echo $TZ > /etc/timezone
|
||||
apt-get update
|
||||
apt-get install -y python3 python2 sudo curl jq git
|
||||
apt-get install -y python || true
|
||||
rm /usr/bin/python || true
|
||||
ln -s /usr/bin/python2 /usr/bin/python
|
||||
mkdir -p /build
|
||||
git clone --depth 1 \
|
||||
--single-branch \
|
||||
--branch ${{ github.base_ref || github.ref_name }} https://github.com/ONLYOFFICE/core.git ${SOURCE_ROOT}
|
||||
git clone --depth 1 \
|
||||
--single-branch \
|
||||
--branch ${{ github.base_ref || github.ref_name }} https://github.com/ONLYOFFICE/build_tools.git /build/build_tools
|
||||
echo "party-key=$(curl -L -H "Accept: application/vnd.github+json" \
|
||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||
"https://api.github.com/repos/ONLYOFFICE/core/commits?per_page=1&path=/Common/3dParty&sha=${{ github.base_ref || github.ref_name }}" | \
|
||||
jq -r '.[].sha')" >> "$GITHUB_OUTPUT"
|
||||
echo "qt-key=$(cat /build/build_tools/tools/linux/automate.py | egrep -m1 -o "qt_source_([0-9])?.([0-9])?.([0-9])?")" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Restore 3dParty from cache if cache key is match
|
||||
- uses: actions/cache/restore@v3
|
||||
id: restore-3d
|
||||
with:
|
||||
path: /build/core/Common/3dParty
|
||||
key: 3dParty-${{ steps.prepare.outputs.party-key }}
|
||||
|
||||
# Restore qt tool from cache if cache key is match
|
||||
- uses: actions/cache/restore@v3
|
||||
id: restore-qt
|
||||
with:
|
||||
path: /build/build_tools/tools/linux/qt_build
|
||||
key: qt-${{ steps.prepare.outputs.qt-key }}
|
||||
|
||||
# NOTE:
|
||||
# init codeql with custom source-root dir
|
||||
# because sources code was checkout with git from cli
|
||||
# NOT with checkout action
|
||||
# Also. Init and scan with codeql only if all cache hit
|
||||
# otherwise will no initialization, just build and cache depends
|
||||
- name: Initialize CodeQL
|
||||
if: >
|
||||
steps.restore-3d.outputs.cache-hit == 'true'
|
||||
&& steps.restore-qt.outputs.cache-hit == 'true'
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
source-root: ${{ env.SOURCE_ROOT }}
|
||||
|
||||
- name: build
|
||||
shell: bash
|
||||
run: |
|
||||
cd /build/build_tools/tools/linux
|
||||
python3 ./automate.py core
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
if: >
|
||||
steps.restore-3d.outputs.cache-hit == 'true'
|
||||
&& steps.restore-qt.outputs.cache-hit == 'true'
|
||||
uses: github/codeql-action/analyze@v3
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
||||
|
||||
# Make new 3dParty cache if restore action do not restore any cache
|
||||
- uses: actions/cache/save@v3
|
||||
if: steps.restore-3d.outputs.cache-hit != 'true'
|
||||
id: save-3d
|
||||
with:
|
||||
path: /build/core/Common/3dParty
|
||||
key: 3dParty-${{ steps.prepare.outputs.party-key }}
|
||||
|
||||
# Make new qt tool cache if restore action do not restore any cache
|
||||
- uses: actions/cache/save@v3
|
||||
if: steps.restore-qt.outputs.cache-hit != 'true'
|
||||
id: save-qt
|
||||
with:
|
||||
path: /build/build_tools/tools/linux/qt_build
|
||||
key: qt-${{ steps.prepare.outputs.qt-key }}
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -46,5 +46,3 @@ DesktopEditor/fontengine/js/common/freetype-2.10.4
|
||||
|
||||
.qtc_clangd
|
||||
Common/3dParty/openssl/openssl/
|
||||
|
||||
msvc_make.bat
|
||||
|
||||
18
3DPARTY.md
18
3DPARTY.md
@ -1,18 +0,0 @@
|
||||
|
||||
## Third-party
|
||||
|
||||
- boost ([BSL](https://raw.githubusercontent.com/boostorg/boost/master/LICENSE_1_0.txt))
|
||||
- icu ([UNICODE LICENSE V3](https://raw.githubusercontent.com/unicode-org/icu/main/LICENSE))
|
||||
- freetype ([FTL](https://raw.githubusercontent.com/freetype/freetype/master/docs/FTL.TXT))
|
||||
- harfbuzz ([MIT](https://raw.githubusercontent.com/harfbuzz/harfbuzz/main/COPYING))
|
||||
- hyphen ([MPL](https://raw.githubusercontent.com/hunspell/hyphen/master/COPYING))
|
||||
- hunspell ([MPL](https://raw.githubusercontent.com/hunspell/hunspell/master/COPYING.MPL))
|
||||
- gumbo ([Apache-2.0](https://raw.githubusercontent.com/google/gumbo-parser/master/COPYING))
|
||||
- katana ([MIT](https://raw.githubusercontent.com/jasenhuang/katana-parser/master/LICENSE))
|
||||
- cximage ([CXIMAGE LICENCE](https://raw.githubusercontent.com/movableink/cximage/master/license.txt))
|
||||
- openjpeg ([2-clause BSD License](https://raw.githubusercontent.com/uclouvain/openjpeg/master/LICENSE))
|
||||
- socket.io-client-cpp ([MIT](https://raw.githubusercontent.com/socketio/socket.io-client-cpp/master/LICENSE))
|
||||
- curl ([CURL LICENCE](https://raw.githubusercontent.com/curl/curl/master/COPYING))
|
||||
- cryptopp ([BSL](https://raw.githubusercontent.com/weidai11/cryptopp/master/License.txt))
|
||||
- openssl ([Apache-2.0](https://raw.githubusercontent.com/openssl/openssl/master/LICENSE.txt))
|
||||
- v8 ([3-clause BSD License](https://raw.githubusercontent.com/v8/v8/main/LICENSE))
|
||||
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,122 +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"])
|
||||
base.replaceInFile("./glm/glm/detail/func_common.inl", "vec<L, T, Q> v;", "vec<L, T, Q> v{};")
|
||||
|
||||
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 < 201703L\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"
|
||||
|
||||
@ -1,21 +1,9 @@
|
||||
INCLUDEPATH += $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/include
|
||||
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
|
||||
CORE_BOOST_LIBS = $$PWD/build/android/lib/$$CORE_BUILDS_PLATFORM_PREFIX
|
||||
|
||||
DEFINES += "_HAS_AUTO_PTR_ETC=0"
|
||||
}
|
||||
|
||||
disable_enum_constexpr_conversion {
|
||||
QMAKE_CFLAGS += -Wno-enum-constexpr-conversion
|
||||
QMAKE_CXXFLAGS += -Wno-enum-constexpr-conversion
|
||||
}
|
||||
|
||||
bundle_xcframeworks {
|
||||
@ -26,21 +14,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
|
||||
|
||||
326
Common/3dParty/boost/boost_android.sh
Executable file
326
Common/3dParty/boost/boost_android.sh
Executable file
@ -0,0 +1,326 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd boost_1_72_0
|
||||
OUTPUT_DIR="../build/android"
|
||||
|
||||
BOOST_LIBS="filesystem system date_time regex"
|
||||
|
||||
CPPSTD="-std=c++11 -frtti -fexceptions"
|
||||
|
||||
# Must set these after parseArgs to fill in overriden values
|
||||
# Todo: -g -DNDEBUG are for debug builds only...
|
||||
# Boost.test defines are needed to build correct instrumentable boost_unit_test_framework static lib
|
||||
# it does not affect the functionality of <boost/test/included/unit_test.hpp> single-header usage.
|
||||
# See http://www.boost.org/doc/libs/1_66_0/libs/test/doc/html/boost_test/adv_scenarios/static_lib_customizations/entry_point.html
|
||||
EXTRA_FLAGS="-DBOOST_AC_USE_PTHREADS -DBOOST_SP_USE_PTHREADS \
|
||||
-DBOOST_TEST_NO_MAIN -DBOOST_TEST_ALTERNATIVE_INIT_API -DANDROID_STL=c++_static \
|
||||
-Wno-unused-local-typedef"
|
||||
EXTRA_ANDROID_FLAGS="$EXTRA_FLAGS"
|
||||
|
||||
if [[ -n "$USE_CXX11_ABI" ]]; then
|
||||
EXTRA_LINUX_FLAGS="$EXTRA_FLAGS -D_GLIBCXX_USE_CXX11_ABI=$USE_CXX11_ABI"
|
||||
else
|
||||
EXTRA_LINUX_FLAGS="$EXTRA_FLAGS"
|
||||
fi
|
||||
|
||||
doneSection()
|
||||
{
|
||||
echo
|
||||
echo "Done"
|
||||
echo "================================================================="
|
||||
echo
|
||||
}
|
||||
|
||||
bootstrapBoost()
|
||||
{
|
||||
BOOTSTRAP_LIBS=$BOOST_LIBS
|
||||
BOOST_LIBS_COMMA=$(echo $BOOTSTRAP_LIBS | sed -e "s/ /,/g")
|
||||
echo "Bootstrapping for $1 (with libs $BOOST_LIBS_COMMA)"
|
||||
./bootstrap.sh --with-libraries=$BOOST_LIBS_COMMA
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
generateAndroidUserConfig()
|
||||
{
|
||||
HOSTOS="$(uname | awk '{ print $1}' | tr [:upper:] [:lower:])-" # darwin or linux
|
||||
OSARCH="$(uname -m)"
|
||||
|
||||
# Boost doesn't build with <compileflags>-Werror
|
||||
# Reported to boost-users@lists.boost.org
|
||||
|
||||
cat > "./tools/build/src/user-config.jam" <<EOF
|
||||
using clang : 5.0~x86
|
||||
: $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOSTOS$OSARCH/bin/clang++ $EXTRA_ANDROID_FLAGS
|
||||
:
|
||||
<architecture>x86 <target-os>android
|
||||
<compileflags>--target=i686-none-linux-android
|
||||
<compileflags>--gcc-toolchain=$ANDROID_NDK_ROOT/toolchains/x86-4.9/prebuilt/$HOSTOS$OSARCH
|
||||
<compileflags>--sysroot=$ANDROID_NDK_ROOT/sysroot
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++abi/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/android/support/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include/i686-linux-android
|
||||
<compileflags>-DANDROID
|
||||
<compileflags>-D__ANDROID_API__=19
|
||||
<compileflags>-ffunction-sections
|
||||
<compileflags>-funwind-tables
|
||||
<compileflags>-fstack-protector-strong
|
||||
<compileflags>-fno-limit-debug-info
|
||||
<compileflags>-fPIC
|
||||
<compileflags>-no-canonical-prefixes
|
||||
<compileflags>-mstackrealign
|
||||
<compileflags>-Wa,--noexecstack
|
||||
<compileflags>-Wformat
|
||||
<compileflags>-Werror=format-security
|
||||
<compileflags>-Wall
|
||||
<compileflags>-Wshadow
|
||||
;
|
||||
using clang : 5.0~x86_64
|
||||
: $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOSTOS$OSARCH/bin/clang++ $EXTRA_ANDROID_FLAGS
|
||||
:
|
||||
<architecture>x86 <target-os>android
|
||||
<compileflags>--target=x86_64-none-linux-android
|
||||
<compileflags>--gcc-toolchain=$ANDROID_NDK_ROOT/toolchains/x86_64-4.9/prebuilt/$HOSTOS$OSARCH
|
||||
<compileflags>--sysroot=$ANDROID_NDK_ROOT/sysroot
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++abi/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/android/support/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include/x86_64-linux-android
|
||||
<compileflags>-DANDROID
|
||||
<compileflags>-D__ANDROID_API__=21
|
||||
<compileflags>-ffunction-sections
|
||||
<compileflags>-funwind-tables
|
||||
<compileflags>-fstack-protector-strong
|
||||
<compileflags>-fno-limit-debug-info
|
||||
<compileflags>-fPIC
|
||||
<compileflags>-no-canonical-prefixes
|
||||
<compileflags>-mstackrealign
|
||||
<compileflags>-Wa,--noexecstack
|
||||
<compileflags>-Wformat
|
||||
<compileflags>-Werror=format-security
|
||||
<compileflags>-Wall
|
||||
<compileflags>-Wshadow
|
||||
;
|
||||
using clang : 5.0~arm
|
||||
: $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOSTOS$OSARCH/bin/clang++ $EXTRA_ANDROID_FLAGS
|
||||
:
|
||||
<architecture>arm <target-os>android
|
||||
<compileflags>--target=armv7-none-linux-androideabi
|
||||
<compileflags>--gcc-toolchain=$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/$HOSTOS$OSARCH
|
||||
<compileflags>--sysroot=$ANDROID_NDK_ROOT/sysroot
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++abi/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/android/support/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include/arm-linux-androideabi
|
||||
<compileflags>-DANDROID
|
||||
<compileflags>-D__ANDROID_API__=19
|
||||
<compileflags>-ffunction-sections
|
||||
<compileflags>-funwind-tables
|
||||
<compileflags>-fstack-protector-strong
|
||||
<compileflags>-fno-limit-debug-info
|
||||
<compileflags>-fPIC
|
||||
<compileflags>-fno-integrated-as
|
||||
<compileflags>-no-canonical-prefixes
|
||||
<compileflags>-Wa,--noexecstack
|
||||
<compileflags>-Wformat
|
||||
<compileflags>-Werror=format-security
|
||||
<compileflags>-Wall
|
||||
<compileflags>-Wshadow
|
||||
<compileflags>-march=armv7-a
|
||||
<compileflags>-mfloat-abi=softfp
|
||||
<compileflags>-mfpu=vfpv3-d16
|
||||
<compileflags>-mthumb
|
||||
;
|
||||
using clang : 5.0~arm64
|
||||
: $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOSTOS$OSARCH/bin/clang++ $EXTRA_ANDROID_FLAGS
|
||||
:
|
||||
<architecture>arm <target-os>android
|
||||
<compileflags>--target=aarch64-none-linux-android
|
||||
<compileflags>--gcc-toolchain=$ANDROID_NDK_ROOT/toolchains/aarch64-linux-android-4.9/prebuilt/$HOSTOS$OSARCH
|
||||
<compileflags>--sysroot=$ANDROID_NDK_ROOT/sysroot
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++abi/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/android/support/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include
|
||||
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include/aarch64-linux-android
|
||||
<compileflags>-DANDROID
|
||||
<compileflags>-D__ANDROID_API__=21
|
||||
<compileflags>-ffunction-sections
|
||||
<compileflags>-funwind-tables
|
||||
<compileflags>-fstack-protector-strong
|
||||
<compileflags>-fno-limit-debug-info
|
||||
<compileflags>-fPIC
|
||||
<compileflags>-no-canonical-prefixes
|
||||
<compileflags>-Wa,--noexecstack
|
||||
<compileflags>-Wformat
|
||||
<compileflags>-Werror=format-security
|
||||
<compileflags>-Wall
|
||||
<compileflags>-Wshadow
|
||||
;
|
||||
EOF
|
||||
}
|
||||
|
||||
buildBoost_Android()
|
||||
{
|
||||
mkdir -p $OUTPUT_DIR
|
||||
echo > ${OUTPUT_DIR}/android-build.log
|
||||
|
||||
if [[ -z "$ANDROID_NDK_ROOT" ]]; then
|
||||
echo "Must specify ANDROID_NDK_ROOT"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export NO_BZIP2=1
|
||||
|
||||
# build libicu if locale requested but not provided
|
||||
# if echo $LIBRARIES | grep locale; then
|
||||
# if [ -e libiconv-libicu-android ]; then
|
||||
# echo "ICONV and ICU already compiled"
|
||||
# else
|
||||
# echo "boost_locale selected - compiling ICONV and ICU"
|
||||
# git clone https://github.com/pelya/libiconv-libicu-android.git
|
||||
# cd libiconv-libicu-android
|
||||
# ./build.sh || exit 1
|
||||
# cd ..
|
||||
# fi
|
||||
# fi
|
||||
|
||||
echo clean
|
||||
./b2 --clean
|
||||
|
||||
echo Building release x86 Boost for Android Emulator
|
||||
|
||||
./b2 --build-dir=android-build --stagedir=android-build/stage \
|
||||
--prefix="$OUTPUT_DIR" \
|
||||
--libdir="$OUTPUT_DIR/lib/x86" toolset=clang-5.0~x86 \
|
||||
architecture=x86 target-os=android define=_LITTLE_ENDIAN \
|
||||
optimization=speed \
|
||||
address-model=32 variant=release cxxflags="${CPPSTD}" \
|
||||
link=static threading=multi install >> "${OUTPUT_DIR}/android-build.log" 2>&1
|
||||
if [ $? != 0 ]; then echo "Error staging Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
|
||||
|
||||
doneSection
|
||||
|
||||
echo Building release x86_64 Boost for Android Emulator
|
||||
|
||||
./b2 --build-dir=android-build --stagedir=android-build/stage \
|
||||
--prefix="$OUTPUT_DIR" \
|
||||
--libdir="$OUTPUT_DIR/lib/x86_64" toolset=clang-5.0~x86_64 \
|
||||
architecture=x86 target-os=android define=_LITTLE_ENDIAN \
|
||||
optimization=speed \
|
||||
address-model=64 variant=release cxxflags="${CPPSTD}" \
|
||||
link=static threading=multi install >> "${OUTPUT_DIR}/android-build.log" 2>&1
|
||||
if [ $? != 0 ]; then echo "Error staging Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
|
||||
|
||||
doneSection
|
||||
|
||||
echo Building release armv7 Boost for Android
|
||||
|
||||
./b2 --build-dir=android-build --stagedir=android-build/stage \
|
||||
--prefix="$OUTPUT_DIR" \
|
||||
--libdir="$OUTPUT_DIR/lib/armeabi-v7a" toolset=clang-5.0~arm \
|
||||
abi=aapcs architecture=arm address-model=32 binary-format=elf threading=multi \
|
||||
optimization=space \
|
||||
target-os=android variant=release cxxflags="${CPPSTD}" \
|
||||
link=static install >> "${OUTPUT_DIR}/android-build.log" 2>&1
|
||||
if [ $? != 0 ]; then echo "Error installing Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
|
||||
|
||||
doneSection
|
||||
|
||||
echo Building release arm64 Boost for Android
|
||||
|
||||
./b2 --build-dir=android-build --stagedir=android-build/stage \
|
||||
--prefix="$OUTPUT_DIR" \
|
||||
--libdir="$OUTPUT_DIR/lib/arm64-v8a" toolset=clang-5.0~arm64 \
|
||||
abi=aapcs architecture=arm address-model=64 binary-format=elf threading=multi \
|
||||
optimization=space \
|
||||
target-os=android variant=release cxxflags="${CPPSTD}" \
|
||||
link=static install >> "${OUTPUT_DIR}/android-build.log" 2>&1
|
||||
if [ $? != 0 ]; then echo "Error installing Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
buildBoost_Android_debug()
|
||||
{
|
||||
mkdir -p $OUTPUT_DIR
|
||||
echo > ${OUTPUT_DIR}/android-build.log
|
||||
|
||||
export NO_BZIP2=1
|
||||
|
||||
# build libicu if locale requested but not provided
|
||||
# if echo $LIBRARIES | grep locale; then
|
||||
# if [ -e libiconv-libicu-android ]; then
|
||||
# echo "ICONV and ICU already compiled"
|
||||
# else
|
||||
# echo "boost_locale selected - compiling ICONV and ICU"
|
||||
# git clone https://github.com/pelya/libiconv-libicu-android.git
|
||||
# cd libiconv-libicu-android
|
||||
# ./build.sh || exit 1
|
||||
# cd ..
|
||||
# fi
|
||||
# fi
|
||||
|
||||
echo Building debug x86 Boost for Android Emulator
|
||||
|
||||
./b2 $THREADS --build-dir=android-build --stagedir=android-build/stage \
|
||||
--prefix="$OUTPUT_DIR" \
|
||||
--libdir="$OUTPUT_DIR/lib/debug/x86" toolset=clang-5.0~x86 \
|
||||
architecture=x86 target-os=android define=_LITTLE_ENDIAN \
|
||||
optimization=speed \
|
||||
address-model=32 variant=debug cxxflags="${CPPSTD}" \
|
||||
link=static threading=multi install >> "${OUTPUT_DIR}/android-build.log" 2>&1
|
||||
if [ $? != 0 ]; then echo "Error staging Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
|
||||
|
||||
doneSection
|
||||
|
||||
echo Building debug x86_64 Boost for Android Emulator
|
||||
|
||||
./b2 $THREADS --build-dir=android-build --stagedir=android-build/stage \
|
||||
--prefix="$OUTPUT_DIR" \
|
||||
--libdir="$OUTPUT_DIR/lib/debug/x86_64" toolset=clang-5.0~x86_64 \
|
||||
architecture=x86 target-os=android define=_LITTLE_ENDIAN \
|
||||
optimization=speed \
|
||||
address-model=64 variant=debug cxxflags="${CPPSTD}" \
|
||||
link=static threading=multi install >> "${OUTPUT_DIR}/android-build.log" 2>&1
|
||||
if [ $? != 0 ]; then echo "Error staging Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
|
||||
|
||||
doneSection
|
||||
|
||||
echo Building debug armv7 Boost for Android
|
||||
|
||||
./b2 $THREADS --build-dir=android-build --stagedir=android-build/stage \
|
||||
--prefix="$OUTPUT_DIR" \
|
||||
--libdir="$OUTPUT_DIR/lib/debug/armeabi-v7a" toolset=clang-5.0~arm \
|
||||
abi=aapcs architecture=arm address-model=32 binary-format=elf threading=multi \
|
||||
optimization=space \
|
||||
target-os=android variant=debug cxxflags="${CPPSTD}" \
|
||||
link=static install >> "${OUTPUT_DIR}/android-build.log" 2>&1
|
||||
if [ $? != 0 ]; then echo "Error installing Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
|
||||
|
||||
doneSection
|
||||
|
||||
echo Building debug arm64 Boost for Android
|
||||
|
||||
./b2 $THREADS --build-dir=android-build --stagedir=android-build/stage \
|
||||
--prefix="$OUTPUT_DIR" \
|
||||
--libdir="$OUTPUT_DIR/lib/debug/arm64-v8a" toolset=clang-5.0~arm64 \
|
||||
abi=aapcs architecture=arm address-model=64 binary-format=elf threading=multi \
|
||||
optimization=space \
|
||||
target-os=android variant=debug cxxflags="${CPPSTD}" \
|
||||
link=static install >> "${OUTPUT_DIR}/android-build.log" 2>&1
|
||||
if [ $? != 0 ]; then echo "Error installing Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
bootstrapBoost
|
||||
generateAndroidUserConfig
|
||||
buildBoost_Android
|
||||
#buildBoost_Android_debug
|
||||
|
||||
echo "Completed successfully"
|
||||
@ -27,7 +27,7 @@ CLEAN=
|
||||
BOOST_VERSION=1.72.0
|
||||
BOOST_VERSION2=1_72_0
|
||||
MIN_IOS_VERSION=8.0
|
||||
IOS_SDK_VERSION=`xcodebuild BITCODE_GENERATION_MODE="bitcode" ENABLE_BITCODE="NO" -showsdks | grep iphoneos | \
|
||||
IOS_SDK_VERSION=`xcodebuild BITCODE_GENERATION_MODE="bitcode" ENABLE_BITCODE="YES" OTHER_CFLAGS="-fembed-bitcode" -showsdks | grep iphoneos | \
|
||||
egrep "[[:digit:]]+\.[[:digit:]]+" -o | tail -1`
|
||||
OSX_SDK_VERSION=`xcodebuild BITCODE_GENERATION_MODE="bitcode" ENABLE_BITCODE="YES" OTHER_CFLAGS="-fembed-bitcode" -showsdks | grep macosx | \
|
||||
egrep "[[:digit:]]+\.[[:digit:]]+" -o | tail -1`
|
||||
@ -42,7 +42,7 @@ XCODE_ROOT=`xcode-select -print-path`
|
||||
#
|
||||
# Should perhaps also consider/use instead: -BOOST_SP_USE_PTHREADS
|
||||
EXTRA_CPPFLAGS="-DBOOST_AC_USE_PTHREADS -DBOOST_SP_USE_PTHREADS -g -DNDEBUG \
|
||||
-std=c++11 -stdlib=libc++ -fvisibility=hidden -fvisibility-inlines-hidden"
|
||||
-std=c++11 -stdlib=libc++ -fvisibility=hidden -fvisibility-inlines-hidden -fembed-bitcode"
|
||||
EXTRA_IOS_CPPFLAGS="$EXTRA_CPPFLAGS -mios-version-min=$MIN_IOS_VERSION"
|
||||
EXTRA_OSX_CPPFLAGS="$EXTRA_CPPFLAGS"
|
||||
|
||||
@ -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="-fembed-bitcode" \
|
||||
--prefix=$PREFIXDIR toolset=darwin architecture=arm target-os=iphone \
|
||||
macosx-version=iphone-${IOS_SDK_VERSION} define=_LITTLE_ENDIAN \
|
||||
link=static stage
|
||||
./b2 -j16 --build-dir=iphone-build --stagedir=iphone-build/stage \
|
||||
--prefix=$PREFIXDIR toolset=darwin architecture=arm \
|
||||
cxxflags="-fembed-bitcode" \
|
||||
target-os=iphone macosx-version=iphone-${IOS_SDK_VERSION} \
|
||||
define=_LITTLE_ENDIAN link=static install
|
||||
doneSection
|
||||
|
||||
echo Building Boost for iPhoneSimulator
|
||||
./b2 -j16 --build-dir=iphonesim-build --stagedir=iphonesim-build/stage \
|
||||
cxxflags="-fembed-bitcode" \
|
||||
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("../")
|
||||
220
Common/3dParty/curl/build-android-common.sh
Executable file
220
Common/3dParty/curl/build-android-common.sh
Executable file
@ -0,0 +1,220 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2016 leenjewel
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
source ./build-common.sh
|
||||
|
||||
export PLATFORM_TYPE="Android"
|
||||
export ARCHS=("arm" "arm64" "x86" "x86_64")
|
||||
export ABIS=("armeabi-v7a" "arm64-v8a" "x86" "x86_64")
|
||||
export ABI_TRIPLES=("arm-linux-androideabi" "aarch64-linux-android" "i686-linux-android" "x86_64-linux-android")
|
||||
export ANDROID_API=21
|
||||
|
||||
# for test
|
||||
# export ARCHS=("x86_64")
|
||||
# export ABIS=("x86_64")
|
||||
# export ABI_TRIPLES=("x86_64-linux-android")
|
||||
|
||||
if [[ -z ${ANDROID_NDK_ROOT} ]]; then
|
||||
echo "ANDROID_NDK_ROOT not defined"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function get_toolchain() {
|
||||
HOST_OS=$(uname -s)
|
||||
case ${HOST_OS} in
|
||||
Darwin) HOST_OS=darwin ;;
|
||||
Linux) HOST_OS=linux ;;
|
||||
FreeBsd) HOST_OS=freebsd ;;
|
||||
CYGWIN* | *_NT-*) HOST_OS=cygwin ;;
|
||||
esac
|
||||
|
||||
HOST_ARCH=$(uname -m)
|
||||
case ${HOST_ARCH} in
|
||||
i?86) HOST_ARCH=x86 ;;
|
||||
x86_64 | amd64) HOST_ARCH=x86_64 ;;
|
||||
esac
|
||||
|
||||
echo "${HOST_OS}-${HOST_ARCH}"
|
||||
}
|
||||
|
||||
function get_android_arch() {
|
||||
local common_arch=$1
|
||||
case ${common_arch} in
|
||||
arm)
|
||||
echo "arm-v7a"
|
||||
;;
|
||||
arm64)
|
||||
echo "arm64-v8a"
|
||||
;;
|
||||
x86)
|
||||
echo "x86"
|
||||
;;
|
||||
x86_64)
|
||||
echo "x86-64"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function get_target_build() {
|
||||
local arch=$1
|
||||
case ${arch} in
|
||||
arm-v7a)
|
||||
echo "arm"
|
||||
;;
|
||||
arm64-v8a)
|
||||
echo "arm64"
|
||||
;;
|
||||
x86)
|
||||
echo "x86"
|
||||
;;
|
||||
x86-64)
|
||||
echo "x86_64"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function get_build_host_internal() {
|
||||
local arch=$1
|
||||
case ${arch} in
|
||||
arm-v7a | arm-v7a-neon)
|
||||
echo "arm-linux-androideabi"
|
||||
;;
|
||||
arm64-v8a)
|
||||
echo "aarch64-linux-android"
|
||||
;;
|
||||
x86)
|
||||
echo "i686-linux-android"
|
||||
;;
|
||||
x86-64)
|
||||
echo "x86_64-linux-android"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function android_get_build_host() {
|
||||
local arch=$(get_android_arch $1)
|
||||
get_build_host_internal $arch
|
||||
}
|
||||
|
||||
function get_clang_target_host() {
|
||||
local arch=$1
|
||||
local api=$2
|
||||
case ${arch} in
|
||||
arm-v7a | arm-v7a-neon)
|
||||
echo "armv7a-linux-androideabi${api}"
|
||||
;;
|
||||
arm64-v8a)
|
||||
echo "aarch64-linux-android${api}"
|
||||
;;
|
||||
x86)
|
||||
echo "i686-linux-android${api}"
|
||||
;;
|
||||
x86-64)
|
||||
echo "x86_64-linux-android${api}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function set_android_toolchain_bin() {
|
||||
export PATH=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/$(get_toolchain)/bin:$PATH
|
||||
echo PATH=$PATH
|
||||
}
|
||||
|
||||
function set_android_toolchain() {
|
||||
local name=$1
|
||||
local arch=$(get_android_arch $2)
|
||||
local api=$3
|
||||
local build_host=$(get_build_host_internal "$arch")
|
||||
local clang_target_host=$(get_clang_target_host "$arch" "$api")
|
||||
|
||||
export AR=${build_host}-ar
|
||||
export CC=${clang_target_host}-clang
|
||||
export CXX=${clang_target_host}-clang++
|
||||
export AS=${build_host}-as
|
||||
export LD=${build_host}-ld
|
||||
export RANLIB=${build_host}-ranlib
|
||||
export STRIP=${build_host}-strip
|
||||
}
|
||||
|
||||
function get_common_includes() {
|
||||
local toolchain=$(get_toolchain)
|
||||
echo "-I${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${toolchain}/sysroot/usr/include -I${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${toolchain}/sysroot/usr/local/include"
|
||||
}
|
||||
function get_common_linked_libraries() {
|
||||
local api=$1
|
||||
local arch=$2
|
||||
local toolchain=$(get_toolchain)
|
||||
local build_host=$(get_build_host_internal "$arch")
|
||||
echo "-L${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${toolchain}/${build_host}/lib -L${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${toolchain}/sysroot/usr/lib/${build_host}/${api} -L${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${toolchain}/lib"
|
||||
}
|
||||
|
||||
function set_android_cpu_feature() {
|
||||
local name=$1
|
||||
local arch=$(get_android_arch $2)
|
||||
local api=$3
|
||||
case ${arch} in
|
||||
arm-v7a | arm-v7a-neon)
|
||||
export CFLAGS="-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wno-unused-function -fno-integrated-as -fstrict-aliasing -fPIC -DANDROID -D__ANDROID_API__=${api} -Os -ffunction-sections -fdata-sections $(get_common_includes)"
|
||||
export CXXFLAGS="-std=c++11 -Os -ffunction-sections -fdata-sections"
|
||||
export LDFLAGS="-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wl,--fix-cortex-a8 -Wl,--gc-sections -Os -ffunction-sections -fdata-sections $(get_common_linked_libraries ${api} ${arch})"
|
||||
export CPPFLAGS=${CFLAGS}
|
||||
;;
|
||||
arm64-v8a)
|
||||
export CFLAGS="-march=armv8-a -Wno-unused-function -fno-integrated-as -fstrict-aliasing -fPIC -DANDROID -D__ANDROID_API__=${api} -Os -ffunction-sections -fdata-sections $(get_common_includes)"
|
||||
export CXXFLAGS="-std=c++11 -Os -ffunction-sections -fdata-sections"
|
||||
export LDFLAGS="-march=armv8-a -Wl,--gc-sections -Os -ffunction-sections -fdata-sections $(get_common_linked_libraries ${api} ${arch})"
|
||||
export CPPFLAGS=${CFLAGS}
|
||||
;;
|
||||
x86)
|
||||
export CFLAGS="-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32 -Wno-unused-function -fno-integrated-as -fstrict-aliasing -fPIC -DANDROID -D__ANDROID_API__=${api} -Os -ffunction-sections -fdata-sections $(get_common_includes)"
|
||||
export CXXFLAGS="-std=c++11 -Os -ffunction-sections -fdata-sections"
|
||||
export LDFLAGS="-march=i686 -Wl,--gc-sections -Os -ffunction-sections -fdata-sections $(get_common_linked_libraries ${api} ${arch})"
|
||||
export CPPFLAGS=${CFLAGS}
|
||||
;;
|
||||
x86-64)
|
||||
export CFLAGS="-march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -Wno-unused-function -fno-integrated-as -fstrict-aliasing -fPIC -DANDROID -D__ANDROID_API__=${api} -Os -ffunction-sections -fdata-sections $(get_common_includes)"
|
||||
export CXXFLAGS="-std=c++11 -Os -ffunction-sections -fdata-sections"
|
||||
export LDFLAGS="-march=x86-64 -Wl,--gc-sections -Os -ffunction-sections -fdata-sections $(get_common_linked_libraries ${api} ${arch})"
|
||||
export CPPFLAGS=${CFLAGS}
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function android_printf_global_params() {
|
||||
local arch=$1
|
||||
local abi=$2
|
||||
local abi_triple=$3
|
||||
local in_dir=$4
|
||||
local out_dir=$5
|
||||
echo -e "arch = $arch"
|
||||
echo -e "abi = $abi"
|
||||
echo -e "abi_triple = $abi_triple"
|
||||
echo -e "PLATFORM_TYPE = $PLATFORM_TYPE"
|
||||
echo -e "ANDROID_API = $ANDROID_API"
|
||||
echo -e "in_dir = $in_dir"
|
||||
echo -e "out_dir = $out_dir"
|
||||
echo -e "AR = $AR"
|
||||
echo -e "CC = $CC"
|
||||
echo -e "CXX = $CXX"
|
||||
echo -e "AS = $AS"
|
||||
echo -e "LD = $LD"
|
||||
echo -e "RANLIB = $RANLIB"
|
||||
echo -e "STRIP = $STRIP"
|
||||
echo -e "CFLAGS = $CFLAGS"
|
||||
echo -e "CXXFLAGS = $CXXFLAGS"
|
||||
echo -e "LDFLAGS = $LDFLAGS"
|
||||
echo -e "CPPFLAGS = $CPPFLAGS"
|
||||
}
|
||||
128
Common/3dParty/curl/build-android-curl.sh
Executable file
128
Common/3dParty/curl/build-android-curl.sh
Executable file
@ -0,0 +1,128 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2016 leenjewel
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# # read -n1 -p "Press any key to continue..."
|
||||
|
||||
set -u
|
||||
|
||||
source ./build-android-common.sh
|
||||
|
||||
init_log_color
|
||||
|
||||
TOOLS_ROOT=$(pwd)
|
||||
|
||||
SOURCE="$0"
|
||||
while [ -h "$SOURCE" ]; do
|
||||
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
||||
done
|
||||
pwd_path="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
||||
|
||||
echo pwd_path=${pwd_path}
|
||||
echo TOOLS_ROOT=${TOOLS_ROOT}
|
||||
|
||||
LIB_VERSION="curl-7_68_0"
|
||||
LIB_NAME="curl-7.68.0"
|
||||
LIB_DEST_DIR="${pwd_path}/build/android/curl-universal"
|
||||
|
||||
echo "https://github.com/curl/curl/releases/download/${LIB_VERSION}/${LIB_NAME}.tar.gz"
|
||||
|
||||
# https://curl.haxx.se/download/${LIB_NAME}.tar.gz
|
||||
# https://github.com/curl/curl/releases/download/curl-7_69_0/curl-7.69.0.tar.gz
|
||||
# https://github.com/curl/curl/releases/download/curl-7_68_0/curl-7.68.0.tar.gz
|
||||
rm -rf "${LIB_DEST_DIR}" "${LIB_NAME}"
|
||||
[ -f "${LIB_NAME}.tar.gz" ] || curl -L -o ${LIB_NAME}.tar.gz https://github.com/curl/curl/releases/download/${LIB_VERSION}/${LIB_NAME}.tar.gz -s
|
||||
[ -f "${LIB_NAME}.tar.gz" ] || log_error "curl download error!"
|
||||
|
||||
set_android_toolchain_bin
|
||||
|
||||
function configure_make() {
|
||||
|
||||
ARCH=$1
|
||||
ABI=$2
|
||||
ABI_TRIPLE=$3
|
||||
|
||||
log_info "configure $ABI start..."
|
||||
|
||||
if [ -d "${LIB_NAME}" ]; then
|
||||
rm -fr "${LIB_NAME}"
|
||||
fi
|
||||
tar xfz "${LIB_NAME}.tar.gz"
|
||||
pushd .
|
||||
cd "${LIB_NAME}"
|
||||
|
||||
PREFIX_DIR="${pwd_path}/build/android/${ABI}"
|
||||
if [ -d "${PREFIX_DIR}" ]; then
|
||||
rm -fr "${PREFIX_DIR}"
|
||||
fi
|
||||
mkdir -p "${PREFIX_DIR}"
|
||||
|
||||
OUTPUT_ROOT=${TOOLS_ROOT}/build/android/${ABI}
|
||||
mkdir -p ${OUTPUT_ROOT}/log
|
||||
|
||||
set_android_toolchain "curl" "${ARCH}" "${ANDROID_API}"
|
||||
set_android_cpu_feature "curl" "${ARCH}" "${ANDROID_API}"
|
||||
|
||||
export ANDROID_NDK_HOME=${ANDROID_NDK_ROOT}
|
||||
echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME}
|
||||
|
||||
OPENSSL_OUT_DIR="${pwd_path}/../openssl/build/android/${ABI}"
|
||||
|
||||
export LDFLAGS="${LDFLAGS} -L${OPENSSL_OUT_DIR}/lib"
|
||||
# export LDFLAGS="-Wl,-rpath-link,-L${OPENSSL_OUT_DIR}/lib $LDFLAGS "
|
||||
|
||||
android_printf_global_params "$ARCH" "$ABI" "$ABI_TRIPLE" "$PREFIX_DIR" "$OUTPUT_ROOT"
|
||||
|
||||
if [[ "${ARCH}" == "x86_64" ]]; then
|
||||
|
||||
./configure --host=$(android_get_build_host "${ARCH}") --prefix="${PREFIX_DIR}" --enable-ipv6 --with-ssl=${OPENSSL_OUT_DIR} --enable-static --disable-shared >"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
|
||||
|
||||
elif [[ "${ARCH}" == "x86" ]]; then
|
||||
|
||||
./configure --host=$(android_get_build_host "${ARCH}") --prefix="${PREFIX_DIR}" --enable-ipv6 --with-ssl=${OPENSSL_OUT_DIR} --enable-static --disable-shared >"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
|
||||
|
||||
elif [[ "${ARCH}" == "arm" ]]; then
|
||||
|
||||
./configure --host=$(android_get_build_host "${ARCH}") --prefix="${PREFIX_DIR}" --enable-ipv6 --with-ssl=${OPENSSL_OUT_DIR} --enable-static --disable-shared >"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
|
||||
|
||||
elif [[ "${ARCH}" == "arm64" ]]; then
|
||||
|
||||
./configure --host=$(android_get_build_host "${ARCH}") --prefix="${PREFIX_DIR}" --enable-ipv6 --with-ssl=${OPENSSL_OUT_DIR} --enable-static --disable-shared >"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
|
||||
|
||||
else
|
||||
log_error "not support" && exit 1
|
||||
fi
|
||||
|
||||
log_info "make $ABI start..."
|
||||
|
||||
make clean >>"${OUTPUT_ROOT}/log/${ABI}.log"
|
||||
if make -j$(get_cpu_count) >>"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1; then
|
||||
make install >>"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
|
||||
fi
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
log_info "${PLATFORM_TYPE} ${LIB_NAME} start..."
|
||||
|
||||
for ((i = 0; i < ${#ARCHS[@]}; i++)); do
|
||||
if [[ $# -eq 0 || "$1" == "${ARCHS[i]}" ]]; then
|
||||
configure_make "${ARCHS[i]}" "${ABIS[i]}" "${ABI_TRIPLES[i]}"
|
||||
fi
|
||||
done
|
||||
|
||||
log_info "${PLATFORM_TYPE} ${LIB_NAME} end..."
|
||||
@ -78,24 +78,24 @@ function set_ios_cpu_feature() {
|
||||
armv7)
|
||||
export CC="xcrun -sdk iphoneos clang -arch armv7"
|
||||
export CXX="xcrun -sdk iphoneos clang++ -arch armv7"
|
||||
export CFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -isysroot ${sysroot} -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -fstrict-aliasing -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export CFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -isysroot ${sysroot} -fembed-bitcode -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -fstrict-aliasing -fembed-bitcode -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
;;
|
||||
arm64)
|
||||
export CC="xcrun -sdk iphoneos clang -arch arm64"
|
||||
export CXX="xcrun -sdk iphoneos clang++ -arch arm64"
|
||||
export CFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -isysroot ${sysroot} -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -fstrict-aliasing -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export CFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -isysroot ${sysroot} -fembed-bitcode -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -fstrict-aliasing -fembed-bitcode -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
;;
|
||||
arm64e)
|
||||
# -march=armv8.3 ???
|
||||
export CC="xcrun -sdk iphoneos clang -arch arm64e"
|
||||
export CXX="xcrun -sdk iphoneos clang++ -arch arm64e"
|
||||
export CFLAGS="-arch arm64e -target aarch64-ios-darwin -Wno-unused-function -fstrict-aliasing -DIOS -isysroot ${sysroot} -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch arm64e -target aarch64-ios-darwin -isysroot ${sysroot} -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch arm64e -target aarch64-ios-darwin -fstrict-aliasing -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export CFLAGS="-arch arm64e -target aarch64-ios-darwin -Wno-unused-function -fstrict-aliasing -DIOS -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch arm64e -target aarch64-ios-darwin -isysroot ${sysroot} -fembed-bitcode -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch arm64e -target aarch64-ios-darwin -fstrict-aliasing -fembed-bitcode -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
;;
|
||||
i386)
|
||||
export CC="xcrun -sdk iphonesimulator clang -arch i386"
|
||||
|
||||
@ -1,10 +1,18 @@
|
||||
core_android {
|
||||
|
||||
ABI_PATH = $$replace(CORE_BUILDS_PLATFORM_PREFIX, "android_", "")
|
||||
contains(ABI_PATH, "armv7" ) {
|
||||
ABI_PATH = $$replace(ABI_PATH, "armv7", "armeabi-v7a")
|
||||
}
|
||||
contains(ABI_PATH, "arm64_v8a" ) {
|
||||
ABI_PATH = $$replace(ABI_PATH, "arm64_v8a", "arm64-v8a")
|
||||
}
|
||||
INCLUDEPATH += \
|
||||
$$PWD/build/android/include \
|
||||
$$PWD/../openssl/build/android/$$CORE_BUILDS_PLATFORM_PREFIX_DST/include
|
||||
$$PWD/build/android/$$ABI_PATH/include \
|
||||
$$PWD/../openssl/build/android/$$ABI_PATH/include \
|
||||
|
||||
LIBS += \
|
||||
$$PWD/build/android/$$CORE_BUILDS_PLATFORM_PREFIX_DST/libcurl.a \
|
||||
$$PWD/../openssl/build/android/$$CORE_BUILDS_PLATFORM_PREFIX_DST/lib/libssl.a \
|
||||
$$PWD/../openssl/build/android/$$CORE_BUILDS_PLATFORM_PREFIX_DST/lib/libcrypto.a \
|
||||
$$PWD/build/android/$$ABI_PATH/lib/libcurl.a \
|
||||
$$PWD/../openssl/build/android/$$ABI_PATH/lib/libssl.a \
|
||||
$$PWD/../openssl/build/android/$$ABI_PATH/lib/libcrypto.a \
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
@ -3,8 +3,6 @@ DEPENDPATH += $$PWD
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../..
|
||||
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/boost/boost.pri)
|
||||
|
||||
css_calculator_without_xhtml {
|
||||
HEADERS += \
|
||||
$$PWD/src/CCssCalculator_Private.h \
|
||||
|
||||
@ -7,26 +7,27 @@
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
|
||||
#include <iostream>
|
||||
#include "../../../../../DesktopEditor/common/File.h"
|
||||
#include "StaticFunctions.h"
|
||||
#include "ConstValues.h"
|
||||
|
||||
#define DEFAULT_FONT_SIZE 12
|
||||
#define DEFAULTFONTSIZE 28 // 14 * 2
|
||||
|
||||
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)
|
||||
{
|
||||
m_oFont.SetSize(std::to_wstring(DEFAULTFONTSIZE), 0, true);
|
||||
}
|
||||
|
||||
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_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)
|
||||
{}
|
||||
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_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){}
|
||||
|
||||
CCompiledStyle::~CCompiledStyle()
|
||||
{
|
||||
@ -35,11 +36,6 @@ namespace NSCSS
|
||||
|
||||
CCompiledStyle& CCompiledStyle::operator+= (const CCompiledStyle &oElement)
|
||||
{
|
||||
m_arParentsStyles.insert(oElement.m_arParentsStyles.begin(), oElement.m_arParentsStyles.end());
|
||||
|
||||
if (oElement.Empty())
|
||||
return *this;
|
||||
|
||||
m_oBackground += oElement.m_oBackground;
|
||||
m_oBorder += oElement.m_oBorder;
|
||||
m_oFont += oElement.m_oFont;
|
||||
@ -47,10 +43,6 @@ namespace NSCSS
|
||||
m_oPadding += oElement.m_oPadding;
|
||||
m_oText += oElement.m_oText;
|
||||
m_oDisplay += oElement.m_oDisplay;
|
||||
m_oTransform += oElement.m_oTransform;
|
||||
|
||||
if (!oElement.m_sId.empty())
|
||||
m_sId += L'+' + oElement.m_sId;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -70,23 +62,21 @@ 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;
|
||||
}
|
||||
|
||||
bool CCompiledStyle::operator== (const CCompiledStyle& oStyle) const
|
||||
{
|
||||
return m_oBackground == oStyle.m_oBackground &&
|
||||
return GetId()[0] == oStyle.GetId()[0] &&
|
||||
m_arParentsStyles == oStyle.m_arParentsStyles &&
|
||||
m_oBackground == oStyle.m_oBackground &&
|
||||
m_oBorder == oStyle.m_oBorder &&
|
||||
m_oFont == oStyle.m_oFont &&
|
||||
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)
|
||||
@ -98,7 +88,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)
|
||||
@ -111,11 +100,20 @@ namespace NSCSS
|
||||
m_UnitMeasure = enUnitMeasure;
|
||||
}
|
||||
|
||||
void CCompiledStyle::SetSizeSourceWindow(const CSizeWindow &oSizeWindow)
|
||||
{
|
||||
m_oSourceWindow = oSizeWindow;
|
||||
}
|
||||
|
||||
void CCompiledStyle::SetSizeDeviceWindow(const CSizeWindow &oSizeWindow)
|
||||
{
|
||||
m_oDeviceWindow = oSizeWindow;
|
||||
}
|
||||
|
||||
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)
|
||||
@ -126,11 +124,8 @@ 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().ToDouble(NSCSS::Twips);
|
||||
|
||||
for (std::pair<std::wstring, std::wstring> pPropertie : mStyle)
|
||||
{
|
||||
std::transform(pPropertie.first.begin(), pPropertie.first.end(), pPropertie.first.begin(), tolower);
|
||||
@ -141,15 +136,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,85 +183,82 @@ namespace NSCSS
|
||||
if (bIsThereBorder)
|
||||
break;
|
||||
|
||||
m_oMargin.SetValues(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateAll(dParentFontSize, m_dCoreFontSize);
|
||||
m_oMargin.AddValue(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateAll(dFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"margin-top"):
|
||||
CASE(L"topmargin"):
|
||||
{
|
||||
if (bIsThereBorder)
|
||||
break;
|
||||
|
||||
m_oMargin.SetTop(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.AddTop(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateTop(dFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"margin-right"):
|
||||
CASE(L"margin-block-end"):
|
||||
CASE(L"rightmargin"):
|
||||
{
|
||||
if (bIsThereBorder)
|
||||
break;
|
||||
|
||||
m_oMargin.SetRight(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateRight(dParentFontSize, m_dCoreFontSize);
|
||||
m_oMargin.AddRight(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateRight(dFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"margin-bottom"):
|
||||
CASE(L"bottommargin"):
|
||||
{
|
||||
if (bIsThereBorder)
|
||||
break;
|
||||
|
||||
m_oMargin.SetBottom(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateBottom(dParentFontSize, m_dCoreFontSize);
|
||||
m_oMargin.AddBottom(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateBottom(dFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"margin-left"):
|
||||
CASE(L"margin-block-start"):
|
||||
CASE(L"leftmargin"):
|
||||
{
|
||||
if (bIsThereBorder)
|
||||
break;
|
||||
|
||||
m_oMargin.SetLeft(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateLeft(dParentFontSize, m_dCoreFontSize);
|
||||
m_oMargin.AddLeft(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateLeft(dFontSize);
|
||||
break;
|
||||
}
|
||||
//PADDING
|
||||
CASE(L"padding"):
|
||||
CASE(L"mso-padding-alt"):
|
||||
{
|
||||
m_oPadding.SetValues(pPropertie.second, unLevel, bHardMode);
|
||||
m_oPadding.UpdateAll(dParentFontSize, m_dCoreFontSize);
|
||||
m_oPadding.AddValue(pPropertie.second, unLevel, bHardMode);
|
||||
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.AddTop(pPropertie.second, unLevel, bHardMode);
|
||||
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.AddRight(pPropertie.second, unLevel, bHardMode);
|
||||
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.AddBottom(pPropertie.second, unLevel, bHardMode);
|
||||
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.AddLeft(pPropertie.second, unLevel, bHardMode);
|
||||
m_oPadding.UpdateLeft(dFontSize);
|
||||
break;
|
||||
}
|
||||
// TEXT
|
||||
@ -313,14 +305,8 @@ namespace NSCSS
|
||||
m_oBorder.SetColor(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
}
|
||||
CASE(L"border-collapse"):
|
||||
{
|
||||
m_oBorder.SetCollapse(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
}
|
||||
//BORDER TOP
|
||||
CASE(L"border-top"):
|
||||
CASE(L"mso-border-top-alt"):
|
||||
{
|
||||
m_oBorder.SetTopSide(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
@ -342,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;
|
||||
@ -364,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;
|
||||
@ -386,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;
|
||||
@ -410,12 +393,20 @@ namespace NSCSS
|
||||
CASE(L"background-color"):
|
||||
{
|
||||
m_oBackground.SetColor(pPropertie.second, unLevel, bHardMode);
|
||||
|
||||
if (bIsThereBorder)
|
||||
m_oBackground.InBorder();
|
||||
|
||||
break;
|
||||
}
|
||||
CASE(L"background"):
|
||||
CASE(L"bgcolor"):
|
||||
{
|
||||
m_oBackground.SetBackground(pPropertie.second, unLevel, bHardMode);
|
||||
|
||||
if (bIsThereBorder)
|
||||
m_oBackground.InBorder();
|
||||
|
||||
break;
|
||||
}
|
||||
//DISPLAY
|
||||
@ -440,22 +431,10 @@ namespace NSCSS
|
||||
break;
|
||||
}
|
||||
CASE(L"vertical-align"):
|
||||
CASE(L"valign"):
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -481,6 +460,9 @@ namespace NSCSS
|
||||
{
|
||||
sValue += *iWord;
|
||||
|
||||
if (L' ' == sValue.front())
|
||||
sValue.erase(0, 1);
|
||||
|
||||
if (!sValue.empty() && ((*iWord).back() == L';' || iWord == (arWords.end() - 1)))
|
||||
{
|
||||
if (sValue.back() == L';')
|
||||
@ -488,10 +470,6 @@ namespace NSCSS
|
||||
|
||||
std::transform(sProperty.begin(), sProperty.end(), sProperty.begin(), tolower);
|
||||
std::transform(sValue.begin(), sValue.end(), sValue.begin(), tolower);
|
||||
|
||||
NS_STATIC_FUNCTIONS::RemoveSpaces(sProperty);
|
||||
NS_STATIC_FUNCTIONS::RemoveSpaces(sValue);
|
||||
|
||||
AddPropSel(sProperty, sValue, unLevel, bHardMode);
|
||||
sProperty.clear();
|
||||
sValue.clear();
|
||||
@ -522,11 +500,6 @@ namespace NSCSS
|
||||
return arParentsName;
|
||||
}
|
||||
|
||||
std::set<std::wstring> CCompiledStyle::GetParentsNamesSet() const
|
||||
{
|
||||
return m_arParentsStyles;
|
||||
}
|
||||
|
||||
void CCompiledStyle::SetID(const std::wstring& sId)
|
||||
{
|
||||
m_sId = sId;
|
||||
@ -536,9 +509,4 @@ 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,9 @@ namespace NSCSS
|
||||
unsigned short int m_nDpi;
|
||||
UnitMeasure m_UnitMeasure;
|
||||
|
||||
double m_dCoreFontSize;
|
||||
CSizeWindow m_oSourceWindow;
|
||||
CSizeWindow m_oDeviceWindow;
|
||||
|
||||
public:
|
||||
NSProperties::CFont m_oFont;
|
||||
NSProperties::CIndent m_oMargin;
|
||||
@ -28,15 +33,16 @@ 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);
|
||||
void SetSizeSourceWindow(const CSizeWindow& oSizeWindow);
|
||||
void SetSizeDeviceWindow(const CSizeWindow& oSizeWindow);
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
@ -47,13 +53,10 @@ namespace NSCSS
|
||||
void AddParent(const std::wstring& sParentName);
|
||||
|
||||
std::vector<std::wstring> GetParentsName() const;
|
||||
std::set<std::wstring> GetParentsNamesSet() const;
|
||||
|
||||
void SetID(const std::wstring& sId);
|
||||
std::wstring GetId() const;
|
||||
|
||||
bool HaveThisParent(const std::wstring& wsParentName) const;
|
||||
|
||||
CCompiledStyle& operator+= (const CCompiledStyle& oElement);
|
||||
CCompiledStyle& operator= (const CCompiledStyle& oElement);
|
||||
bool operator== (const CCompiledStyle& oElement) const;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "CCssCalculator.h"
|
||||
#include "CCssCalculator_Private.h"
|
||||
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
CCssCalculator::CCssCalculator()
|
||||
@ -13,19 +14,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);
|
||||
}
|
||||
|
||||
std::wstring CCssCalculator::CalculateStyleId(const CNode& oNode)
|
||||
bool CCssCalculator::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors, const bool &bIsSettings, const UnitMeasure &unitMeasure) const
|
||||
{
|
||||
return m_pInternal->CalculateStyleId(oNode);
|
||||
}
|
||||
|
||||
bool CCssCalculator::CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors)
|
||||
{
|
||||
return m_pInternal->CalculatePageStyle(oPageData, arSelectors);
|
||||
return m_pInternal->GetCompiledStyle(oStyle, arSelectors, bIsSettings, unitMeasure);
|
||||
}
|
||||
|
||||
void CCssCalculator::AddStyles(const std::string &sStyle)
|
||||
@ -43,11 +39,46 @@ 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);
|
||||
}
|
||||
|
||||
void CCssCalculator::SetSizeSourceWindow(const CSizeWindow &oSizeWindow)
|
||||
{
|
||||
m_pInternal->SetSizeSourceWindow(oSizeWindow);
|
||||
}
|
||||
|
||||
void CCssCalculator::SetSizeDeviceWindow(const CSizeWindow &oSizeWindow)
|
||||
{
|
||||
m_pInternal->SetSizeDeviceWindow(oSizeWindow);
|
||||
}
|
||||
|
||||
CSizeWindow CCssCalculator::GetSizeSourceWindow() const
|
||||
{
|
||||
return m_pInternal->GetSizeSourceWindow();
|
||||
}
|
||||
|
||||
CSizeWindow CCssCalculator::GetSizeDeviceWindow() const
|
||||
{
|
||||
return m_pInternal->GetSizeDeviceWindow();
|
||||
}
|
||||
|
||||
UnitMeasure CCssCalculator::GetUnitMeasure() const
|
||||
{
|
||||
return m_pInternal->GetUnitMeasure();
|
||||
}
|
||||
|
||||
std::wstring CCssCalculator::GetEncoding() const
|
||||
{
|
||||
return m_pInternal->GetEncoding();
|
||||
@ -58,31 +89,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,27 +19,28 @@ namespace NSCSS
|
||||
CCssCalculator();
|
||||
~CCssCalculator();
|
||||
|
||||
bool CalculateCompiledStyle(std::vector<CNode>& arSelectors) const;
|
||||
|
||||
std::wstring CalculateStyleId(const CNode& oNode);
|
||||
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors);
|
||||
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;
|
||||
|
||||
// void AddStyle(const std::vector<std::string>& sSelectors, const std::string& sStyle);
|
||||
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(const unsigned short int& nValue);
|
||||
void SetBodyTree(const CTree &oTree);
|
||||
|
||||
void SetSizeSourceWindow(const CSizeWindow& oSizeWindow);
|
||||
void SetSizeDeviceWindow(const CSizeWindow& oSizeWindow);
|
||||
|
||||
CSizeWindow GetSizeSourceWindow() const;
|
||||
CSizeWindow GetSizeDeviceWindow() const;
|
||||
|
||||
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();
|
||||
};
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -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,61 +16,31 @@
|
||||
|
||||
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 ClearDefaultStyles();
|
||||
void ClearAllowedStyleFiles();
|
||||
void ClearStylesFromFile(const std::wstring& wsFileName);
|
||||
std::map<StatistickElement, unsigned int> *m_mStatictics; // Количество повторений свойств id и style у селекторов
|
||||
|
||||
#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();
|
||||
std::map<std::vector<CNode>, CCompiledStyle*> m_mUsedStyles;
|
||||
#endif
|
||||
|
||||
const CElement* FindElement(const std::wstring& wsSelector) const;
|
||||
const CElement* FindDefaultElement(const std::wstring& wsSelector) const;
|
||||
private:
|
||||
typedef struct
|
||||
{
|
||||
std::wstring m_wsStyleFilepath;
|
||||
std::map<std::wstring, CElement*> m_mStyleData;
|
||||
} TStyleFileData;
|
||||
std::wstring m_sEncoding;
|
||||
|
||||
std::set<std::wstring> m_arEmptyStyleFiles;
|
||||
std::set<std::wstring> m_arAllowedStyleFiles;
|
||||
std::vector<TStyleFileData*> m_arStyleFiles;
|
||||
std::map<std::wstring, CElement*> m_mEmbeddedStyleData;
|
||||
std::map<std::wstring, CElement*> m_mDefaultStyleData;
|
||||
CSizeWindow m_oSourceWindow;
|
||||
CSizeWindow m_oDeviceWindow;
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
typedef struct
|
||||
{
|
||||
std::vector<std::wstring> m_wsNames;
|
||||
std::map<std::wstring, std::wstring> m_mData;
|
||||
} TPageData;
|
||||
void GetStylesheet(const KatanaStylesheet* oStylesheet);
|
||||
void GetRule(const KatanaRule* oRule);
|
||||
|
||||
std::vector<TPageData> m_arPageDatas;
|
||||
#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);
|
||||
|
||||
void GetStyleRule(const KatanaStyleRule* oRule, std::map<std::wstring, CElement*>& mStyleData);
|
||||
void GetStyleRule(const KatanaStyleRule* oRule);
|
||||
|
||||
std::wstring GetValueList(const KatanaArray* oValues);
|
||||
|
||||
@ -78,63 +50,39 @@ 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;
|
||||
|
||||
void InitDefaultStyles();
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
std::wstring CalculateStyleId(const CNode& oNode);
|
||||
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors);
|
||||
|
||||
void ClearPageData();
|
||||
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);
|
||||
#endif
|
||||
|
||||
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors, unsigned int unStart, unsigned int unEnd);
|
||||
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);
|
||||
|
||||
void SetSizeSourceWindow(const CSizeWindow& oSizeWindow);
|
||||
void SetSizeDeviceWindow(const CSizeWindow& oSizeWindow);
|
||||
|
||||
CSizeWindow GetSizeSourceWindow() const;
|
||||
CSizeWindow GetSizeDeviceWindow() const;
|
||||
|
||||
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
|
||||
|
||||
@ -9,13 +9,6 @@ namespace NSCSS
|
||||
CElement::CElement()
|
||||
{
|
||||
}
|
||||
|
||||
CElement::CElement(const std::wstring& wsSelector, std::map<std::wstring, std::wstring> mStyle)
|
||||
: m_mStyle(mStyle), m_sSelector(wsSelector), m_sFullSelector(wsSelector)
|
||||
{
|
||||
UpdateWeight();
|
||||
}
|
||||
|
||||
CElement::~CElement()
|
||||
{
|
||||
for (CElement* oElement : m_arPrevElements)
|
||||
@ -25,6 +18,7 @@ namespace NSCSS
|
||||
continue;
|
||||
|
||||
m_mStyle.clear();
|
||||
|
||||
}
|
||||
|
||||
std::wstring CElement::GetSelector() const
|
||||
@ -46,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)
|
||||
@ -74,7 +67,6 @@ namespace NSCSS
|
||||
|
||||
m_arPrevElements.push_back(oPrevElement);
|
||||
oPrevElement->m_sFullSelector += L' ' + m_sFullSelector;
|
||||
UpdateWeight();
|
||||
}
|
||||
|
||||
void CElement::AddKinElement(CElement *oKinElement)
|
||||
@ -84,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
|
||||
@ -182,26 +173,26 @@ namespace NSCSS
|
||||
return arElements;
|
||||
}
|
||||
|
||||
std::vector<CElement *> CElement::GetPrevElements(const std::vector<std::wstring>::const_iterator& oNodesBegin, const std::vector<std::wstring>::const_iterator& oNodesEnd) const
|
||||
std::vector<CElement *> CElement::GetPrevElements(const std::vector<std::wstring>::reverse_iterator &arNodesRBegin, const std::vector<std::wstring>::reverse_iterator &arNodesREnd) const
|
||||
{
|
||||
if (oNodesBegin >= oNodesEnd || m_arPrevElements.empty())
|
||||
if (arNodesRBegin >= arNodesREnd || m_arPrevElements.empty())
|
||||
return std::vector<CElement*>();
|
||||
|
||||
std::vector<CElement*> arElements;
|
||||
|
||||
for (std::vector<std::wstring>::const_iterator iWord = oNodesBegin; iWord != oNodesEnd; ++iWord)
|
||||
for (std::vector<std::wstring>::reverse_iterator iWord = arNodesRBegin; iWord != arNodesREnd; ++iWord)
|
||||
{
|
||||
if ((*iWord)[0] == L'.' && ((*iWord).find(L" ") != std::wstring::npos))
|
||||
{
|
||||
std::vector<std::wstring> arClasses = NS_STATIC_FUNCTIONS::GetWordsW(*iWord, false, L" ");
|
||||
for (const std::wstring& wsClass : arClasses)
|
||||
for (std::wstring sClass : arClasses)
|
||||
{
|
||||
for (CElement* oPrevElement : m_arPrevElements)
|
||||
{
|
||||
if (oPrevElement->m_sSelector == wsClass)
|
||||
if (oPrevElement->m_sSelector == sClass)
|
||||
{
|
||||
arElements.push_back(oPrevElement);
|
||||
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, oNodesEnd);
|
||||
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, arNodesREnd);
|
||||
arElements.insert(arElements.end(), arTempElements.begin(), arTempElements.end());
|
||||
}
|
||||
}
|
||||
@ -214,8 +205,9 @@ namespace NSCSS
|
||||
if (oPrevElement->m_sSelector == *iWord)
|
||||
{
|
||||
arElements.push_back(oPrevElement);
|
||||
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, oNodesEnd);
|
||||
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, arNodesREnd);
|
||||
arElements.insert(arElements.end(), arTempElements.begin(), arTempElements.end());
|
||||
// return arElements;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -238,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;
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,6 @@ namespace NSCSS
|
||||
|
||||
public:
|
||||
CElement();
|
||||
CElement(const std::wstring& wsSelector, std::map<std::wstring, std::wstring> mStyle);
|
||||
~CElement();
|
||||
|
||||
std::wstring GetSelector() const;
|
||||
@ -40,13 +39,12 @@ namespace NSCSS
|
||||
std::map<std::wstring, std::wstring> GetFullStyle(const std::vector<CNode>& arSelectors) const;
|
||||
std::map<std::wstring, std::wstring> GetFullStyle(const std::vector<std::wstring>& arNodes) const;
|
||||
std::vector<CElement *> GetNextOfKin(const std::wstring& sName, const std::vector<std::wstring>& arClasses = {}) const;
|
||||
std::vector<CElement *> GetPrevElements(const std::vector<std::wstring>::const_iterator& oNodesBegin, const std::vector<std::wstring>::const_iterator& oNodesEnd) const;
|
||||
std::vector<CElement *> GetPrevElements(const std::vector<std::wstring>::reverse_iterator &arNodesRBegin, const std::vector<std::wstring>::reverse_iterator &arNodesREnd) const;
|
||||
std::map<std::wstring, std::wstring> GetConvertStyle(const std::vector<CNode>& arNodes) const;
|
||||
|
||||
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,83 +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(*oNode.m_pCompiledStyle);
|
||||
#endif
|
||||
}
|
||||
|
||||
CNode::CNode(const std::wstring& wsName, const std::wstring& wsClass, const std::wstring& wsId)
|
||||
CNode::CNode(std::wstring wsName, std::wstring wsClass, 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();
|
||||
}
|
||||
|
||||
bool CNode::GetAttributeValue(const std::wstring& wsAttributeName, std::wstring& wsAttributeValue) const
|
||||
{
|
||||
const std::map<std::wstring, std::wstring>::const_iterator itFound{m_mAttributes.find(wsAttributeName)};
|
||||
|
||||
if (m_mAttributes.cend() == itFound)
|
||||
return false;
|
||||
|
||||
wsAttributeValue = itFound->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::wstring CNode::GetAttributeValue(const std::wstring& wsAttributeName) const
|
||||
{
|
||||
const std::map<std::wstring, std::wstring>::const_iterator itFound{m_mAttributes.find(wsAttributeName)};
|
||||
return (m_mAttributes.cend() != itFound) ? itFound->second : std::wstring();
|
||||
}
|
||||
|
||||
#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();
|
||||
m_wsClass .clear();
|
||||
m_wsId .clear();
|
||||
m_wsStyle .clear();
|
||||
m_mAttributes.clear();
|
||||
}
|
||||
|
||||
std::vector<std::wstring> CNode::GetData() const
|
||||
{
|
||||
std::vector<std::wstring> arValues;
|
||||
@ -102,9 +38,6 @@ namespace NSCSS
|
||||
if(m_wsStyle != oNode.m_wsStyle)
|
||||
return m_wsStyle < oNode.m_wsStyle;
|
||||
|
||||
if (m_mAttributes.size() != oNode.m_mAttributes.size())
|
||||
return m_mAttributes.size() < oNode.m_mAttributes.size();
|
||||
|
||||
if (m_mAttributes != oNode.m_mAttributes)
|
||||
return m_mAttributes < oNode.m_mAttributes;
|
||||
|
||||
@ -113,9 +46,10 @@ namespace NSCSS
|
||||
|
||||
bool CNode::operator==(const CNode& oNode) const
|
||||
{
|
||||
return((m_wsName == oNode.m_wsName) &&
|
||||
(m_wsClass == oNode.m_wsClass) &&
|
||||
(m_wsStyle == oNode.m_wsStyle) &&
|
||||
(m_mAttributes == oNode.m_mAttributes));
|
||||
return((m_wsId == oNode.m_wsId) &&
|
||||
(m_wsName == oNode.m_wsName) &&
|
||||
(m_wsClass == oNode.m_wsClass) &&
|
||||
(m_wsStyle == oNode.m_wsStyle) &&
|
||||
(m_mAttributes == oNode.m_mAttributes));
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,9 +7,6 @@
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
class CCompiledStyle;
|
||||
#endif
|
||||
class CNode
|
||||
{
|
||||
public:
|
||||
@ -18,28 +15,13 @@ namespace NSCSS
|
||||
std::wstring m_wsId; // Id тэга
|
||||
std::wstring m_wsStyle; // Стиль тэга
|
||||
std::map<std::wstring, std::wstring> m_mAttributes; // Остальные аттрибуты тэга
|
||||
//TODO:: возможно использование std::wstring излишне
|
||||
|
||||
#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();
|
||||
CNode(std::wstring wsName, std::wstring wsClass, std::wstring wsId);
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
bool GetAttributeValue(const std::wstring& wsAttributeName, std::wstring& wsAttributeValue) const;
|
||||
std::wstring GetAttributeValue(const std::wstring& wsAttributeName) const;
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
void SetCompiledStyle(CCompiledStyle* pCompiledStyle);
|
||||
#endif
|
||||
|
||||
void Clear();
|
||||
|
||||
std::vector<std::wstring> GetData() const;
|
||||
bool operator< (const CNode& oNode) const;
|
||||
bool operator== (const CNode& oNode) const;
|
||||
|
||||
@ -14,21 +14,23 @@ namespace NSCSS
|
||||
{
|
||||
switch (enUnitMeasure)
|
||||
{
|
||||
case NSCSS::Pixel:
|
||||
return dValue;
|
||||
case NSCSS::Point:
|
||||
return dValue * 72. / (double)ushDPI;
|
||||
return 72. / (double)ushDPI * dValue;
|
||||
case NSCSS::Cantimeter:
|
||||
return dValue / (double)ushDPI * 2.54;
|
||||
case NSCSS::Millimeter:
|
||||
return dValue / (double)ushDPI * 25.4;
|
||||
case NSCSS::Inch:
|
||||
return dValue / (double)ushDPI;
|
||||
return 1. / (double)ushDPI * dValue;
|
||||
case NSCSS::Peak:
|
||||
return dValue * 6. / (double)ushDPI; // 1 дюйм = 6 пик
|
||||
return 0.16667 / (double)ushDPI * dValue;
|
||||
case NSCSS::Twips:
|
||||
return dValue * 1440. / (double)ushDPI;
|
||||
default:
|
||||
return dValue;
|
||||
return (dValue / (double)ushDPI) * 144.;
|
||||
}
|
||||
|
||||
return 0.;
|
||||
}
|
||||
|
||||
double CUnitMeasureConverter::ConvertCm(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI)
|
||||
@ -36,20 +38,22 @@ namespace NSCSS
|
||||
switch (enUnitMeasure)
|
||||
{
|
||||
case NSCSS::Point:
|
||||
return dValue * 28.3465 ; // 1 см = (2.54 / 72) пункта
|
||||
return 28.35 * dValue;
|
||||
case NSCSS::Pixel:
|
||||
return dValue * (double)ushDPI / 2.54;
|
||||
return (double)ushDPI / 2.54 * dValue;
|
||||
case NSCSS::Cantimeter:
|
||||
return dValue;
|
||||
case NSCSS::Millimeter:
|
||||
return dValue * 10.;
|
||||
case NSCSS::Inch:
|
||||
return dValue / 2.54; // 1 дюйм = 2.54 см
|
||||
return dValue / 2.54f;
|
||||
case NSCSS::Peak:
|
||||
return dValue * 2.36; // 2.36 = 6 / 2.54
|
||||
return 2.36 * dValue;
|
||||
case NSCSS::Twips:
|
||||
return dValue * 567.; // 1 см = (1440 / 2.54) твипов
|
||||
default:
|
||||
return dValue;
|
||||
return (dValue) * 0.3937 * (double)ushDPI;
|
||||
}
|
||||
|
||||
return 0.;
|
||||
}
|
||||
|
||||
double CUnitMeasureConverter::ConvertMm(double dValue, NSCSS::UnitMeasure enUnitMeasure, unsigned short ushDPI)
|
||||
@ -57,20 +61,22 @@ namespace NSCSS
|
||||
switch (enUnitMeasure)
|
||||
{
|
||||
case NSCSS::Point:
|
||||
return dValue * 2.8346; // 1 мм = (25.4 / 72) пункта
|
||||
return 2.835 * dValue;
|
||||
case NSCSS::Pixel:
|
||||
return dValue * (double)ushDPI / 25.4;
|
||||
return (double)ushDPI / 25.4 * dValue;
|
||||
case NSCSS::Cantimeter:
|
||||
return dValue / 10.;
|
||||
case NSCSS::Millimeter:
|
||||
return dValue;
|
||||
case NSCSS::Inch:
|
||||
return dValue / 25.4;
|
||||
case NSCSS::Peak:
|
||||
return dValue * 0.236; // 0.236 = 6 / 25.4
|
||||
return 0.236 * dValue;
|
||||
case NSCSS::Twips:
|
||||
return dValue * 56.7;
|
||||
default:
|
||||
return dValue;
|
||||
return (dValue / 10.) * 0.3937 * (double)ushDPI;
|
||||
}
|
||||
|
||||
return 0.;
|
||||
}
|
||||
|
||||
double CUnitMeasureConverter::ConvertIn(double dValue, NSCSS::UnitMeasure enUnitMeasure, unsigned short ushDPI)
|
||||
@ -78,41 +84,45 @@ namespace NSCSS
|
||||
switch (enUnitMeasure)
|
||||
{
|
||||
case NSCSS::Point:
|
||||
return dValue / 72.;
|
||||
return dValue / 6.;
|
||||
case NSCSS::Pixel:
|
||||
return dValue * (double)ushDPI;
|
||||
case NSCSS::Cantimeter:
|
||||
return dValue * 2.54; // 1 дюйм = 2.54 см
|
||||
return dValue * 2.54;
|
||||
case NSCSS::Millimeter:
|
||||
return dValue * 25.4;
|
||||
case NSCSS::Peak:
|
||||
return dValue * 6.;
|
||||
case NSCSS::Twips:
|
||||
return dValue * 1440.;
|
||||
default:
|
||||
case NSCSS::Inch:
|
||||
return dValue;
|
||||
case NSCSS::Peak:
|
||||
return dValue / 72.;
|
||||
case NSCSS::Twips:
|
||||
return dValue * 144.;
|
||||
}
|
||||
|
||||
return 0.;
|
||||
}
|
||||
|
||||
double CUnitMeasureConverter::ConvertPt(double dValue, NSCSS::UnitMeasure enUnitMeasure, unsigned short ushDPI)
|
||||
{
|
||||
switch (enUnitMeasure)
|
||||
{
|
||||
case NSCSS::Point:
|
||||
return dValue;
|
||||
case NSCSS::Pixel:
|
||||
return dValue * (double)ushDPI / 72.;
|
||||
return (double)ushDPI / 72. * dValue;
|
||||
case NSCSS::Cantimeter:
|
||||
return dValue * 0.03528; // 0.03528 = 2.54 / 72
|
||||
return dValue * 0.03528;
|
||||
case NSCSS::Millimeter:
|
||||
return dValue * 0.3528;
|
||||
case NSCSS::Inch:
|
||||
return dValue / 72.; // 1 дюйм = 72 пункта
|
||||
return dValue / 72.;
|
||||
case NSCSS::Peak:
|
||||
return dValue * 0.0833; // 0.0833 = 6 / 72 (1 пункт = 1/72 дюйма)
|
||||
return dValue / 12.;
|
||||
case NSCSS::Twips:
|
||||
return dValue * 20.; // 20 = 1440 / 72
|
||||
default:
|
||||
return dValue;
|
||||
return (dValue / 72.) * 144.;
|
||||
}
|
||||
|
||||
return 0.;
|
||||
}
|
||||
|
||||
double CUnitMeasureConverter::ConvertPc(double dValue, NSCSS::UnitMeasure enUnitMeasure, unsigned short ushDPI)
|
||||
@ -120,49 +130,27 @@ namespace NSCSS
|
||||
switch (enUnitMeasure)
|
||||
{
|
||||
case NSCSS::Point:
|
||||
return dValue * 12.; // 12 = 72 / 6
|
||||
return dValue * 12.;
|
||||
case NSCSS::Pixel:
|
||||
return dValue * (double)ushDPI / 6.; // 1 дюйм = 6 пика
|
||||
return (double)ushDPI / 6. * dValue;
|
||||
case NSCSS::Cantimeter:
|
||||
return dValue * 0.423; // 0.423 = 2.54 / 6
|
||||
return dValue * 0.423;
|
||||
case NSCSS::Millimeter:
|
||||
return dValue * 4.233; // 4.23 = 25.4 / 6
|
||||
return dValue * 4.23;
|
||||
case NSCSS::Inch:
|
||||
return dValue / 6.;
|
||||
case NSCSS::Twips:
|
||||
return dValue * 3.333; // 3.333 = 20 / 6
|
||||
default:
|
||||
return dValue;
|
||||
}
|
||||
}
|
||||
|
||||
double CUnitMeasureConverter::ConvertTw(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI)
|
||||
{
|
||||
switch (enUnitMeasure)
|
||||
{
|
||||
case NSCSS::Point:
|
||||
return dValue * 0.05; // 0.05 = 72. / 1440.
|
||||
case NSCSS::Pixel:
|
||||
return dValue * (double)ushDPI / 1440.; // 1 дюйм = 1440 твипов
|
||||
case NSCSS::Cantimeter:
|
||||
return dValue * 0.001764; // 0.001764 = 2.54 / 1440
|
||||
case NSCSS::Millimeter:
|
||||
return dValue * 0.01764;
|
||||
case NSCSS::Inch:
|
||||
return dValue / 1440.;
|
||||
case NSCSS::Peak:
|
||||
return dValue * 0.004167; // 0.004167 = 6 / 1440
|
||||
default:
|
||||
return dValue;
|
||||
case NSCSS::Twips:
|
||||
return dValue * 24.;
|
||||
}
|
||||
|
||||
return 0.;
|
||||
}
|
||||
|
||||
bool CUnitMeasureConverter::GetValue(const std::wstring &wsValue, double &dValue, UnitMeasure &enUnitMeasure)
|
||||
{
|
||||
if (wsValue.empty() || wsValue.end() == std::find_if(wsValue.begin(), wsValue.end(), [](wchar_t wChar) { return iswdigit(wChar);}))
|
||||
return false;
|
||||
|
||||
std::wregex oRegex(LR"((-?\.\d+|-?\d+(\.\d+)?)\s*(px|pt|cm|mm|in|pc|%|em|rem|tw)?)");
|
||||
std::wregex oRegex(LR"((-?\.\d+|-?\d+(\.\d+)?)\s*(px|pt|cm|mm|in|pc|%|em|rem)?)");
|
||||
std::wsmatch oMatches;
|
||||
|
||||
if(!std::regex_search(wsValue, oMatches, oRegex))
|
||||
@ -188,8 +176,6 @@ namespace NSCSS
|
||||
enUnitMeasure = Em;
|
||||
else if (L"rem" == oMatches[3])
|
||||
enUnitMeasure = Rem;
|
||||
else if (L"tw" == oMatches[3])
|
||||
enUnitMeasure = Twips;
|
||||
else
|
||||
enUnitMeasure = None;
|
||||
|
||||
|
||||
@ -30,7 +30,6 @@ namespace NSCSS
|
||||
static double ConvertIn(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI);
|
||||
static double ConvertPt(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI);
|
||||
static double ConvertPc(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI);
|
||||
static double ConvertTw(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI);
|
||||
|
||||
static bool GetValue(const std::wstring& wsValue, double& dValue, UnitMeasure& enUnitMeasure);
|
||||
};
|
||||
|
||||
@ -2,6 +2,51 @@
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
CSizeWindow::CSizeWindow()
|
||||
: m_ushWidth(0), m_ushHeight(0)
|
||||
{}
|
||||
|
||||
CSizeWindow::CSizeWindow(unsigned short unWidth, unsigned short unHeight)
|
||||
: m_ushWidth(unWidth), m_ushHeight(unHeight)
|
||||
{}
|
||||
|
||||
bool CSizeWindow::Empty() const
|
||||
{
|
||||
return ((0 == m_ushWidth) && (0 == m_ushHeight));
|
||||
}
|
||||
|
||||
void CSizeWindow::Clear()
|
||||
{
|
||||
m_ushWidth = m_ushHeight = 0;
|
||||
}
|
||||
|
||||
bool CSizeWindow::operator==(const CSizeWindow &oSizeWindow) const
|
||||
{
|
||||
return ((m_ushWidth == oSizeWindow.m_ushWidth) && (m_ushHeight == oSizeWindow.m_ushHeight));
|
||||
}
|
||||
|
||||
bool CSizeWindow::operator!=(const CSizeWindow &oSizeWindow) const
|
||||
{
|
||||
return ((m_ushWidth != oSizeWindow.m_ushWidth) || (m_ushHeight != oSizeWindow.m_ushHeight));
|
||||
}
|
||||
|
||||
bool StatistickElement::operator<(const StatistickElement &oStatistickElement) const
|
||||
{
|
||||
return sValue < oStatistickElement.sValue;
|
||||
}
|
||||
|
||||
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
|
||||
@ -53,7 +98,7 @@ namespace NSCSS
|
||||
{L"deepskyblue", L"00BFFF"}, {L"dodgerblue", L"1E90FF"}, {L"cornflowerblue",L"6495ED"},
|
||||
{L"mediumdlateblue", L"7B68EE"}, {L"royalblue", L"4169E1"}, {L"blue", L"0000FF"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"},
|
||||
{L"mediumblue", L"0000CD"}, {L"darkblue", L"00008B"}, {L"navy", L"000080"},
|
||||
{L"midnightblue", L"191970"}, {L"navyblue", L"A0B0E0"},
|
||||
{L"midnightblue", L"191970"},
|
||||
/* White tones */
|
||||
{L"white", L"FFFFFF"}, {L"snow", L"FFFAFA"}, {L"honeydew", L"F0FFF0"},
|
||||
{L"mintcream", L"F5FFFA"}, {L"azure", L"F0FFFF"}, {L"aliceblue", L"F0F8FF"},
|
||||
@ -65,7 +110,7 @@ namespace NSCSS
|
||||
{L"gainsboro", L"DCDCDC"}, {L"lightgray", L"D3D3D3"}, {L"silver", L"C0C0C0"},
|
||||
{L"darkgray", L"A9A9A9"}, {L"gray", L"808080"}, {L"dimgray", L"696969"},
|
||||
{L"lightslategray", L"778899"}, {L"slategray", L"708090"}, {L"darkslategray", L"2F4F4F"},
|
||||
{L"black", L"000000"}, {L"grey", L"808080"},
|
||||
{L"black", L"000000"},
|
||||
/* Outdated */
|
||||
{L"windowtext", L"000000"}, {L"transparent", L"000000"}
|
||||
};
|
||||
|
||||
@ -16,6 +16,41 @@ namespace NSCSS
|
||||
ScalingDirectionY = 2
|
||||
} ScalingDirection;
|
||||
|
||||
struct CSizeWindow
|
||||
{
|
||||
unsigned short m_ushWidth;
|
||||
unsigned short m_ushHeight;
|
||||
|
||||
CSizeWindow();
|
||||
CSizeWindow(unsigned short unWidth, unsigned short unHeight);
|
||||
|
||||
bool Empty() const;
|
||||
void Clear();
|
||||
|
||||
bool operator==(const CSizeWindow& oSizeWindow) const;
|
||||
bool operator!=(const CSizeWindow& oSizeWindow) const;
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
static void CountingNumberRepetitions(const CTree &oTree, std::map<StatistickElement, unsigned int> &mStatictics);
|
||||
};
|
||||
|
||||
namespace NSConstValues
|
||||
{
|
||||
extern const std::map<std::wstring, std::wstring> COLORS;
|
||||
@ -26,72 +61,66 @@ namespace NSCSS
|
||||
{
|
||||
typedef enum
|
||||
{
|
||||
B_CustomStyle,
|
||||
B_StyleId,
|
||||
B_Type,
|
||||
B_Default,
|
||||
B_CustomStyle = 0,
|
||||
B_StyleId = 1,
|
||||
B_Type = 2,
|
||||
B_Default = 3,
|
||||
|
||||
B_Name,
|
||||
B_BasedOn,
|
||||
B_QFormat,
|
||||
B_Link,
|
||||
B_UnhideWhenUsed,
|
||||
B_UiPriority,
|
||||
B_SemiHidden
|
||||
B_Name = 4,
|
||||
B_BasedOn = 5,
|
||||
B_QFormat = 6,
|
||||
B_Link = 7,
|
||||
B_UnhideWhenUsed = 8,
|
||||
B_UiPriority = 9,
|
||||
} BasicProperties;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
P_Jc,
|
||||
P_Spacing,
|
||||
P_ContextualSpacing,
|
||||
P_Ind,
|
||||
P_OutlineLvl,
|
||||
P_Shd,
|
||||
P_Jc = 0,
|
||||
P_Spacing = 1,
|
||||
P_ContextualSpacing = 2,
|
||||
P_Ind = 3,
|
||||
P_OutlineLvl = 4,
|
||||
P_Shd = 5,
|
||||
// <pBdr>
|
||||
P_TopBorder,
|
||||
P_LeftBorder,
|
||||
P_BottomBorder,
|
||||
P_RightBorder,
|
||||
P_TopBorder = 6,
|
||||
P_LeftBorder = 7,
|
||||
P_BottomBorder = 8,
|
||||
P_RightBorder = 9,
|
||||
// </pBdr>
|
||||
P_KeepLines,
|
||||
P_KeepNext,
|
||||
P_KeepLines = 10,
|
||||
P_KeepNext = 11,
|
||||
} ParagraphProperties;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
R_RFonts ,
|
||||
R_Sz,
|
||||
R_B,
|
||||
R_I,
|
||||
R_Color,
|
||||
R_U,
|
||||
R_Highlight,
|
||||
R_Shd,
|
||||
R_SmallCaps,
|
||||
R_Kern,
|
||||
R_Vanish,
|
||||
R_Strike,
|
||||
R_VertAlign
|
||||
R_RFonts = 0,
|
||||
R_Sz = 1,
|
||||
R_B = 2,
|
||||
R_I = 3,
|
||||
R_Color = 4,
|
||||
R_U = 5,
|
||||
R_Highlight = 6,
|
||||
R_SmallCaps = 7
|
||||
} RunnerProperties;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
T_TblInd ,
|
||||
T_TblInd = 0,
|
||||
// <tblCellMar>
|
||||
T_CellTop,
|
||||
T_CellLeft,
|
||||
T_CellBottom,
|
||||
T_CellRight,
|
||||
T_CellTop = 1,
|
||||
T_CellLeft = 2,
|
||||
T_CellBottom = 3,
|
||||
T_CellRight = 4,
|
||||
// <tblCellMar>
|
||||
|
||||
// <tblBorders>
|
||||
T_BorderTop ,
|
||||
T_BorderLeft,
|
||||
T_BorderBottom,
|
||||
T_BorderRight,
|
||||
T_BorderInsideH,
|
||||
T_BorderInsideV
|
||||
T_BorderTop = 5,
|
||||
T_BorderLeft = 6,
|
||||
T_BorderBottom = 7,
|
||||
T_BorderRight = 8,
|
||||
T_BorderInsideH = 9,
|
||||
T_BorderInsideV = 10
|
||||
// </tblBorders>
|
||||
} TableProperties;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
@ -79,52 +80,6 @@ namespace NS_STATIC_FUNCTIONS
|
||||
return arValues;
|
||||
}
|
||||
|
||||
std::vector<std::wstring> ParseCSSPropertie(const std::wstring& wsInput)
|
||||
{
|
||||
std::vector<std::wstring> arResult;
|
||||
std::wstring wsCurrent;
|
||||
bool bInQuotes = false;
|
||||
bool bInFunction = false;
|
||||
int nParenDepth = 0;
|
||||
|
||||
for (wchar_t c : wsInput)
|
||||
{
|
||||
if (c == ' ' && !bInQuotes && !bInFunction)
|
||||
{
|
||||
if (!wsCurrent.empty())
|
||||
{
|
||||
arResult.push_back(wsCurrent);
|
||||
wsCurrent.clear();
|
||||
}
|
||||
}
|
||||
else if (c == '"' || c == '\'')
|
||||
{
|
||||
bInQuotes = !bInQuotes;
|
||||
wsCurrent += c;
|
||||
}
|
||||
else if (c == '(')
|
||||
{
|
||||
bInFunction = true;
|
||||
nParenDepth++;
|
||||
wsCurrent += c;
|
||||
}
|
||||
else if (c == ')')
|
||||
{
|
||||
nParenDepth--;
|
||||
if (nParenDepth == 0)
|
||||
bInFunction = false;
|
||||
wsCurrent += c;
|
||||
}
|
||||
else
|
||||
wsCurrent += c;
|
||||
}
|
||||
|
||||
if (!wsCurrent.empty())
|
||||
arResult.push_back(wsCurrent);
|
||||
|
||||
return arResult;
|
||||
}
|
||||
|
||||
std::vector<std::wstring> GetWordsW(const std::wstring& wsLine, bool bWithSigns, const std::wstring& wsDelimiters)
|
||||
{
|
||||
if (wsLine.empty())
|
||||
@ -140,15 +95,12 @@ namespace NS_STATIC_FUNCTIONS
|
||||
|
||||
while (std::wstring::npos != unEnd)
|
||||
{
|
||||
if (unStart != unEnd)
|
||||
arWords.emplace_back(wsLine.data() + unStart, unEnd - unStart + ((bWithSigns) ? 1 : 0));
|
||||
|
||||
arWords.emplace_back(wsLine.data() + unStart, unEnd - unStart + ((bWithSigns) ? 1 : 0));
|
||||
unStart = wsLine.find_first_not_of(wsDelimiters, unEnd);
|
||||
unEnd = wsLine.find_first_of(wsDelimiters, unStart);
|
||||
}
|
||||
|
||||
if (std::wstring::npos != unStart)
|
||||
arWords.emplace_back(wsLine.data() + unStart);
|
||||
arWords.emplace_back(wsLine.data() + unStart);
|
||||
|
||||
return arWords;
|
||||
}
|
||||
@ -188,43 +140,42 @@ namespace NS_STATIC_FUNCTIONS
|
||||
|
||||
std::map<std::wstring, std::wstring> GetRules(const std::wstring& wsStyles)
|
||||
{
|
||||
std::wregex oCssPropertyRegex(L"([a-zA-Z-]+)\\s*:\\s*([^;\t\n\r\f\v]+)");
|
||||
std::wsmatch oMatch;
|
||||
|
||||
std::wstring::const_iterator oSearchStart(wsStyles.cbegin());
|
||||
if (wsStyles.empty())
|
||||
return {};
|
||||
|
||||
std::map<std::wstring, std::wstring> mRules;
|
||||
|
||||
while (std::regex_search(oSearchStart, wsStyles.cend(), oMatch, oCssPropertyRegex))
|
||||
std::wstring::const_iterator oStartProperty = std::find_if_not(wsStyles.begin(), wsStyles.end(), std::iswspace);
|
||||
std::wstring::const_iterator oEndProperty, oStartValue, oEndValue;
|
||||
|
||||
while (wsStyles.end() != oStartProperty)
|
||||
{
|
||||
mRules.insert(std::make_pair<std::wstring, std::wstring>(oMatch[1], oMatch[2]));
|
||||
oSearchStart = oMatch.suffix().first;
|
||||
oEndProperty = std::find_if(oStartProperty, wsStyles.end(), [](const wchar_t &wcChar){ return L':' == wcChar;});
|
||||
oStartValue = std::find_if_not(oEndProperty + 1, wsStyles.end(), std::iswspace);
|
||||
|
||||
if (wsStyles.end() == oEndProperty || wsStyles.end() == oStartValue)
|
||||
break;
|
||||
|
||||
oEndValue = std::find_if(oStartValue, wsStyles.end(), [](const wchar_t &wcChar){ return L';' == wcChar;});
|
||||
|
||||
mRules.insert({std::wstring(oStartProperty, oEndProperty), std::wstring(oStartValue, oEndValue)});
|
||||
|
||||
if (wsStyles.end() == oEndValue)
|
||||
break;
|
||||
|
||||
oStartProperty = std::find_if_not(oEndValue + 1, wsStyles.end(), std::iswspace);
|
||||
}
|
||||
|
||||
return mRules;
|
||||
}
|
||||
|
||||
void RemoveSpaces(std::wstring &wsString)
|
||||
std::wstring RemoveSpaces(std::wstring &wsString)
|
||||
{
|
||||
std::wstring::const_iterator ciStart = std::find_if_not(wsString.begin(), wsString.end(), std::iswspace);
|
||||
|
||||
if (ciStart == wsString.end())
|
||||
return wsString.clear();
|
||||
|
||||
return L"";
|
||||
std::wstring::const_reverse_iterator criEnd = std::find_if_not(wsString.rbegin(),wsString.rend(), std::iswspace);
|
||||
|
||||
wsString = std::wstring(ciStart, criEnd.base());
|
||||
return std::wstring(ciStart, criEnd.base());
|
||||
}
|
||||
|
||||
double CalculatePersentage(const std::wstring &wsValue, double dRelativeValue)
|
||||
{
|
||||
double dValue = ReadDouble(wsValue);
|
||||
|
||||
if (std::wstring::npos != wsValue.find(L'%'))
|
||||
return dValue / 100. * dRelativeValue;
|
||||
|
||||
return dValue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,14 +20,11 @@ namespace NSCSS
|
||||
double ReadDouble(const std::wstring& wsValue);
|
||||
std::vector<double> ReadDoubleValues(const std::wstring& wsValue);
|
||||
|
||||
std::vector<std::wstring> ParseCSSPropertie(const std::wstring& wsInput);
|
||||
std::vector<std::wstring> GetWordsW(const std::wstring& wsLine, bool bWithSigns = false, const std::wstring& wsDelimiters = L" \n\r\t\f\v:;,!");
|
||||
std::vector<unsigned short int> GetWeightSelector(const std::wstring& sSelector);
|
||||
std::map<std::wstring, std::wstring> GetRules(const std::wstring& wsStyles);
|
||||
|
||||
void RemoveSpaces(std::wstring& wsString);
|
||||
|
||||
double CalculatePersentage(const std::wstring& wsValue, double dRelativeValue);
|
||||
std::wstring RemoveSpaces(std::wstring& wsString);
|
||||
}
|
||||
|
||||
#define SWITCH(str) switch(SWITCH_CASE::str_hash_for_switch(str))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -4,49 +4,42 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
#include "../../../../DesktopEditor/graphics/Matrix.h"
|
||||
#include "CUnitMeasureConverter.h"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include "boost/blank.hpp"
|
||||
#include <boost/variant2/variant.hpp>
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
namespace NSProperties
|
||||
{
|
||||
#define NEXT_LEVEL UINT_MAX, true
|
||||
|
||||
template<typename T>
|
||||
class CValueBase
|
||||
class CValue
|
||||
{
|
||||
protected:
|
||||
CValueBase()
|
||||
: m_unLevel(0), m_bImportant(false)
|
||||
{}
|
||||
CValueBase(const CValueBase& oValue)
|
||||
: m_oValue(oValue.m_oValue), m_unLevel(oValue.m_unLevel), m_bImportant(oValue.m_bImportant)
|
||||
{}
|
||||
|
||||
CValueBase(const T& oValue, unsigned int unLevel, bool bImportant)
|
||||
: m_oValue(oValue), m_unLevel(unLevel), m_bImportant(bImportant)
|
||||
{}
|
||||
friend class CString;
|
||||
friend class CMatrix;
|
||||
friend class CDigit;
|
||||
friend class CColor;
|
||||
friend class CEnum;
|
||||
|
||||
T m_oValue;
|
||||
unsigned int m_unLevel;
|
||||
bool m_bImportant;
|
||||
public:
|
||||
virtual bool Empty() const = 0;
|
||||
virtual void Clear() = 0;
|
||||
CValue(const T& oValue, unsigned int unLevel, bool bImportant) :
|
||||
m_oValue(oValue), m_unLevel(unLevel), m_bImportant(bImportant)
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) = 0;
|
||||
|
||||
virtual bool Empty() const = 0;
|
||||
virtual void Clear() = 0;
|
||||
virtual int ToInt() const = 0;
|
||||
virtual double ToDouble() const = 0;
|
||||
virtual std::wstring ToWString() const = 0;
|
||||
|
||||
static void Equation(CValueBase &oFirstValue, CValueBase &oSecondValue)
|
||||
static void Equation(CValue &oFirstValue, CValue &oSecondValue)
|
||||
{
|
||||
if (oFirstValue.m_bImportant && !oSecondValue.m_bImportant && oFirstValue.Empty())
|
||||
oSecondValue.Clear();
|
||||
@ -61,39 +54,13 @@ namespace NSCSS
|
||||
}
|
||||
}
|
||||
|
||||
static bool LevelIsSame(const CValueBase& oFirstValue, const CValueBase& oSecondValue)
|
||||
{
|
||||
return oFirstValue.m_unLevel == oSecondValue.m_unLevel;
|
||||
}
|
||||
bool operator==(const T& oValue) const { return m_oValue == oValue; }
|
||||
bool operator>=(const T& oValue) const { return m_oValue >= oValue; }
|
||||
bool operator<=(const T& oValue) const { return m_oValue <= oValue; }
|
||||
bool operator> (const T& oValue) const { return m_oValue > oValue; }
|
||||
bool operator< (const T& oValue) const { return m_oValue < oValue; }
|
||||
|
||||
friend bool operator==(const CValueBase& oLeftValue, const CValueBase& oRightValue)
|
||||
{
|
||||
if (oLeftValue.Empty() && oRightValue.Empty())
|
||||
return true;
|
||||
|
||||
if (( oLeftValue.Empty() && !oRightValue.Empty()) ||
|
||||
(!oLeftValue.Empty() && oRightValue.Empty()))
|
||||
return false;
|
||||
|
||||
return oLeftValue.m_oValue == oRightValue.m_oValue;
|
||||
}
|
||||
|
||||
friend bool operator!=(const CValueBase& oLeftValue, const CValueBase& oRightValue)
|
||||
{
|
||||
return !(oLeftValue == oRightValue);
|
||||
}
|
||||
|
||||
bool operator==(const T& oValue) const
|
||||
{
|
||||
return m_oValue == oValue;
|
||||
}
|
||||
|
||||
bool operator!=(const T& oValue) const
|
||||
{
|
||||
return m_oValue != oValue;
|
||||
}
|
||||
|
||||
virtual CValueBase& operator =(const CValueBase& oValue)
|
||||
virtual CValue& operator =(const CValue& oValue)
|
||||
{
|
||||
m_oValue = oValue.m_oValue;
|
||||
m_unLevel = oValue.m_unLevel;
|
||||
@ -102,98 +69,68 @@ namespace NSCSS
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual CValueBase& operator =(const T& oValue)
|
||||
CValue& operator =(const T& oValue)
|
||||
{
|
||||
m_oValue = oValue;
|
||||
|
||||
//m_oValue = oValue.m_oValue;
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual CValueBase& operator+=(const CValueBase& oValue)
|
||||
CValue& operator+=(const CValue& oValue)
|
||||
{
|
||||
if (m_unLevel > oValue.m_unLevel || (m_bImportant && !oValue.m_bImportant) || oValue.Empty())
|
||||
return *this;
|
||||
|
||||
*this = oValue;
|
||||
m_oValue = oValue.m_oValue;
|
||||
m_unLevel = std::max(m_unLevel, oValue.m_unLevel);
|
||||
m_bImportant = std::max(m_bImportant, oValue.m_bImportant);
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class CValueOptional : public CValueBase<boost::optional<T>>
|
||||
{
|
||||
protected:
|
||||
CValueOptional() = default;
|
||||
|
||||
CValueOptional(const T& oValue, unsigned int unLevel = 0, bool bImportant = false)
|
||||
: CValueBase<boost::optional<T>>(oValue, unLevel, bImportant)
|
||||
{}
|
||||
public:
|
||||
virtual bool Empty() const override
|
||||
bool operator==(const CValue& oValue) const
|
||||
{
|
||||
return !this->m_oValue.has_value();
|
||||
}
|
||||
void Clear() override
|
||||
{
|
||||
this->m_oValue.reset();
|
||||
this->m_unLevel = 0;
|
||||
this->m_bImportant = false;
|
||||
}
|
||||
|
||||
bool operator==(const T& oValue) const
|
||||
{
|
||||
if (!this->m_oValue.has_value())
|
||||
return false;
|
||||
|
||||
return this->m_oValue.value() == oValue;
|
||||
}
|
||||
|
||||
virtual CValueOptional& operator=(const T& oValue)
|
||||
{
|
||||
this->m_oValue = oValue;
|
||||
|
||||
return *this;
|
||||
return m_oValue == oValue.m_oValue;
|
||||
}
|
||||
};
|
||||
|
||||
class CString : public CValueOptional<std::wstring>
|
||||
class CString : public CValue<std::wstring>
|
||||
{
|
||||
public:
|
||||
CString() = default;
|
||||
CString(const std::wstring& wsValue, unsigned int unLevel = 0, bool bImportant = false);
|
||||
CString();
|
||||
CString(const std::wstring& wsValue, unsigned int unLevel, bool bImportant = false);
|
||||
|
||||
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) override;
|
||||
bool SetValue(const std::wstring& wsValue, const std::vector<std::wstring>& arValiableValues, unsigned int unLevel, bool bHardMode);
|
||||
bool SetValue(const std::wstring& wsValue, const std::map<std::wstring, std::wstring>& arValiableValues, unsigned int unLevel, bool bHardMode);
|
||||
|
||||
bool Empty() const override;
|
||||
void Clear() override;
|
||||
|
||||
int ToInt() const override;
|
||||
double ToDouble() const override;
|
||||
std::wstring ToWString() const override;
|
||||
|
||||
bool operator==(const wchar_t* pValue) const;
|
||||
bool operator!=(const wchar_t* pValue) const;
|
||||
|
||||
using CValueOptional<std::wstring>::operator=;
|
||||
CString& operator+=(const CString& oString);
|
||||
};
|
||||
|
||||
class CDigit : public CValueOptional<double>
|
||||
class CDigit : public CValue<double>
|
||||
{
|
||||
UnitMeasure m_enUnitMeasure;
|
||||
|
||||
double ConvertValue(double dPrevValue, UnitMeasure enUnitMeasure) const;
|
||||
public:
|
||||
CDigit();
|
||||
CDigit(const double& dValue, unsigned int unLevel = 0, bool bImportant = false);
|
||||
CDigit(double dValue);
|
||||
CDigit(double dValue, unsigned int unLevel, bool bImportant = false);
|
||||
|
||||
bool SetValue(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true) override;
|
||||
bool SetValue(const CDigit& oValue);
|
||||
bool SetValue(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel = 0, bool bHardMode = true);
|
||||
|
||||
bool Empty() const override;
|
||||
bool Zero() const;
|
||||
void Clear() override;
|
||||
|
||||
void ConvertTo(UnitMeasure enUnitMeasure, double dPrevValue = 0.);
|
||||
|
||||
|
||||
int ToInt() const override;
|
||||
double ToDouble() const override;
|
||||
std::wstring ToWString() const override;
|
||||
@ -204,12 +141,9 @@ namespace NSCSS
|
||||
|
||||
UnitMeasure GetUnitMeasure() const;
|
||||
|
||||
bool operator==(const double& dValue) const;
|
||||
bool operator==(const double& oValue) const;
|
||||
bool operator==(const CDigit& oDigit) const;
|
||||
|
||||
bool operator!=(const double& oValue) const;
|
||||
bool operator!=(const CDigit& oDigit) const;
|
||||
|
||||
CDigit operator+(const CDigit& oDigit) const;
|
||||
CDigit operator-(const CDigit& oDigit) const;
|
||||
CDigit operator*(const CDigit& oDigit) const;
|
||||
@ -219,19 +153,11 @@ namespace NSCSS
|
||||
|
||||
CDigit& operator+=(const CDigit& oDigit);
|
||||
CDigit& operator-=(const CDigit& oDigit);
|
||||
CDigit& operator+=(const double& dValue);
|
||||
CDigit& operator-=(const double& dValue);
|
||||
CDigit& operator*=(const double& dValue);
|
||||
CDigit& operator/=(const double& dValue);
|
||||
|
||||
using CValueOptional<double>::operator=;
|
||||
private:
|
||||
UnitMeasure m_enUnitMeasure;
|
||||
|
||||
double ConvertValue(double dPrevValue, UnitMeasure enUnitMeasure) const;
|
||||
|
||||
template <typename Operation>
|
||||
CDigit ApplyOperation(const CDigit& oDigit, Operation operation) const;
|
||||
CDigit& operator+=(double dValue);
|
||||
CDigit& operator-=(double dValue);
|
||||
CDigit& operator*=(double dValue);
|
||||
CDigit& operator/=(double dValue);
|
||||
CDigit& operator =(double dValue);
|
||||
};
|
||||
|
||||
struct TRGB
|
||||
@ -242,107 +168,67 @@ namespace NSCSS
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
int ToInt() const;
|
||||
|
||||
bool operator==(const TRGB& oRGB) const;
|
||||
bool operator!=(const TRGB& oRGB) const;
|
||||
};
|
||||
|
||||
class CURL
|
||||
{
|
||||
public:
|
||||
CURL();
|
||||
|
||||
bool Empty() const;
|
||||
bool LinkToId() const;
|
||||
|
||||
void Clear();
|
||||
|
||||
bool SetValue(const std::wstring& wsValue);
|
||||
std::wstring GetValue() const;
|
||||
|
||||
bool operator==(const CURL& oValue) const;
|
||||
bool operator!=(const CURL& oValue) const;
|
||||
private:
|
||||
std::wstring m_wsValue;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ColorEmpty,
|
||||
ColorNone,
|
||||
ColorRGB,
|
||||
ColorHEX,
|
||||
ColorUrl,
|
||||
ColorContextStroke,
|
||||
ColorContextFill
|
||||
} EColorType;
|
||||
ColorUrl
|
||||
} ColorType;
|
||||
|
||||
class CColorValue
|
||||
class Q_DECL_EXPORT CColorValue
|
||||
{
|
||||
using color_value = boost::variant2::variant<boost::blank, std::wstring, TRGB, CURL>;
|
||||
protected:
|
||||
EColorType m_eType;
|
||||
public:
|
||||
CColorValue();
|
||||
CColorValue(const CColorValue& oValue);
|
||||
CColorValue(const std::wstring& wsValue);
|
||||
CColorValue(const TRGB& oValue);
|
||||
CColorValue(const CURL& oValue);
|
||||
CColorValue(const CColorValue& oColorValue);
|
||||
~CColorValue();
|
||||
|
||||
EColorType GetType() const;
|
||||
void SetRGB(unsigned char uchR, unsigned char uchG, unsigned char uchB);
|
||||
void SetRGB(const TRGB& oRGB);
|
||||
void SetHEX(const std::wstring& wsValue);
|
||||
void SetUrl(const std::wstring& wsValue);
|
||||
void SetNone();
|
||||
|
||||
bool operator==(const CColorValue& oValue) const;
|
||||
void Clear();
|
||||
|
||||
color_value m_oValue;
|
||||
bool Empty() const;
|
||||
|
||||
ColorType m_enType;
|
||||
void* m_pColor = NULL;
|
||||
|
||||
std::wstring GetColor() const;
|
||||
|
||||
bool operator==(const CColorValue& oColorValue) const;
|
||||
CColorValue& operator= (const CColorValue& oColorValue);
|
||||
};
|
||||
|
||||
class CColorValueContextStroke : public CColorValue
|
||||
{
|
||||
public:
|
||||
CColorValueContextStroke();
|
||||
};
|
||||
|
||||
class CColorValueContextFill : public CColorValue
|
||||
{
|
||||
public:
|
||||
CColorValueContextFill();
|
||||
};
|
||||
|
||||
class CColor : public CValueOptional<CColorValue>
|
||||
class CColor : public CValue<CColorValue>
|
||||
{
|
||||
CDigit m_oOpacity;
|
||||
static TRGB ConvertHEXtoRGB(const std::wstring& wsValue);
|
||||
static std::wstring ConvertRGBtoHEX(const TRGB& oValue);
|
||||
static std::wstring CutURL(const std::wstring& wsValue);
|
||||
public:
|
||||
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);
|
||||
|
||||
bool None() const;
|
||||
bool Url() const;
|
||||
bool Empty() const override;
|
||||
void Clear() override;
|
||||
|
||||
EColorType GetType() const;
|
||||
ColorType GetType() const;
|
||||
|
||||
double GetOpacity() const;
|
||||
|
||||
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;
|
||||
|
||||
static TRGB ConvertHEXtoRGB(const std::wstring& wsValue);
|
||||
static std::wstring ConvertRGBtoHEX(const TRGB& oValue);
|
||||
|
||||
using CValueOptional<CColorValue>::operator=;
|
||||
private:
|
||||
CDigit m_oOpacity;
|
||||
|
||||
void SetEmpty(unsigned int unLevel = 0);
|
||||
void SetRGB(unsigned char uchR, unsigned char uchG, unsigned char uchB);
|
||||
void SetRGB(const TRGB& oRGB);
|
||||
void SetHEX(const std::wstring& wsValue);
|
||||
bool SetUrl(const std::wstring& wsValue);
|
||||
};
|
||||
|
||||
typedef enum
|
||||
@ -358,7 +244,7 @@ namespace NSCSS
|
||||
|
||||
typedef std::vector<std::pair<std::vector<double>, TransformType>> MatrixValues;
|
||||
|
||||
class CMatrix : public CValueBase<MatrixValues>
|
||||
class CMatrix : public CValue<MatrixValues>
|
||||
{
|
||||
std::vector<std::wstring> CutTransforms(const std::wstring& wsValue) const;
|
||||
public:
|
||||
@ -381,41 +267,32 @@ namespace NSCSS
|
||||
void ApplyTranform(Aggplus::CMatrix& oMatrix, Aggplus::MatrixOrder order = Aggplus::MatrixOrderPrepend) const;
|
||||
|
||||
bool operator==(const CMatrix& oMatrix) const;
|
||||
CMatrix& operator+=(const CMatrix& oMatrix);
|
||||
CMatrix& operator-=(const CMatrix& oMatrix);
|
||||
|
||||
using CValueBase<MatrixValues>::operator=;
|
||||
};
|
||||
|
||||
class CEnum : public CValueOptional<int>
|
||||
class CEnum : public CValue<int>
|
||||
{
|
||||
std::map<std::wstring, int> m_mMap;
|
||||
public:
|
||||
CEnum();
|
||||
|
||||
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) override;
|
||||
void SetMapping(const std::map<std::wstring, int>& mMap, int nDefaulvalue = -1);
|
||||
void SetMapping(const std::map<std::wstring, int>& mMap);
|
||||
|
||||
bool Empty() const override;
|
||||
void Clear() override;
|
||||
|
||||
CEnum &operator =(int nValue);
|
||||
|
||||
bool operator==(int nValue) const;
|
||||
bool operator!=(int nValue) const;
|
||||
|
||||
int ToInt() const override;
|
||||
|
||||
using CValueOptional<int>::operator=;
|
||||
private:
|
||||
double ToDouble() const override;
|
||||
std::wstring ToWString() const override;
|
||||
|
||||
int m_nDefaultValue;
|
||||
std::map<std::wstring, int> m_mMap;
|
||||
};
|
||||
|
||||
// PROPERTIES
|
||||
typedef enum
|
||||
{
|
||||
Normal,
|
||||
Nowrap,
|
||||
Pre,
|
||||
Pre_Line,
|
||||
Pre_Wrap
|
||||
} EWhiteSpace;
|
||||
|
||||
class CDisplay
|
||||
{
|
||||
public:
|
||||
@ -435,8 +312,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;
|
||||
@ -447,10 +322,7 @@ namespace NSCSS
|
||||
|
||||
const CString& GetDisplay() const;
|
||||
|
||||
const CEnum& GetWhiteSpace() const;
|
||||
|
||||
bool Empty() const;
|
||||
void Clear();
|
||||
|
||||
CDisplay& operator+=(const CDisplay& oDisplay);
|
||||
bool operator==(const CDisplay& oDisplay) const;
|
||||
@ -464,8 +336,6 @@ namespace NSCSS
|
||||
CString m_oVAlign;
|
||||
|
||||
CString m_oDisplay;
|
||||
|
||||
CEnum m_eWhiteSpace;
|
||||
};
|
||||
|
||||
class CStroke
|
||||
@ -499,18 +369,19 @@ namespace NSCSS
|
||||
|
||||
bool SetColor (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetBackground(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
void InBorder();
|
||||
|
||||
const CColor& GetColor() const;
|
||||
bool IsInBorder() const;
|
||||
|
||||
void Clear();
|
||||
bool Empty() const;
|
||||
bool IsNone() const;
|
||||
bool Empty() const;
|
||||
|
||||
CBackground& operator =(const CBackground& oBackground);
|
||||
CBackground& operator+=(const CBackground& oBackground);
|
||||
bool operator==(const CBackground& oBackground) const;
|
||||
private:
|
||||
CColor m_oColor;
|
||||
bool m_bInBorder;
|
||||
};
|
||||
|
||||
class CTransform
|
||||
@ -525,11 +396,6 @@ namespace NSCSS
|
||||
bool SetMatrix(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetMatrix(const Aggplus::CMatrix &oMatrix);
|
||||
|
||||
void Translate(double dOffsetX, double dOffsetY);
|
||||
void Scale(double dScaleX, double dScaleY);
|
||||
void Rotate(double dValue);
|
||||
void RotateAt(double dValue, double dX, double dY);
|
||||
|
||||
const CMatrix& GetMatrix() const;
|
||||
|
||||
bool Empty() const;
|
||||
@ -544,20 +410,14 @@ namespace NSCSS
|
||||
{
|
||||
public:
|
||||
CBorderSide();
|
||||
CBorderSide(const CBorderSide& oBorderSide);
|
||||
|
||||
void Clear();
|
||||
|
||||
static void Equation(CBorderSide &oFirstBorderSide, CBorderSide &oSecondBorderSide);
|
||||
|
||||
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidth(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidth(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyle(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColor(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
void SetNone(unsigned int unLevel, bool bHardMode);
|
||||
|
||||
void Block();
|
||||
void Unblock();
|
||||
|
||||
@ -568,13 +428,9 @@ namespace NSCSS
|
||||
const CColor& GetColor() const;
|
||||
|
||||
bool Empty() const;
|
||||
bool Zero() const;
|
||||
bool Valid() const;
|
||||
|
||||
CBorderSide& operator+=(const CBorderSide& oBorderSide);
|
||||
bool operator==(const CBorderSide& oBorderSide) const;
|
||||
bool operator!=(const CBorderSide& oBorderSide) const;
|
||||
CBorderSide& operator =(const CBorderSide& oBorderSide);
|
||||
private:
|
||||
CDigit m_oWidth;
|
||||
CString m_oStyle;
|
||||
@ -583,71 +439,48 @@ namespace NSCSS
|
||||
bool m_bBlock;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Collapse,
|
||||
Separate
|
||||
} BorderCollapse;
|
||||
|
||||
class CBorder
|
||||
{
|
||||
public:
|
||||
CBorder();
|
||||
|
||||
void Clear();
|
||||
void ClearLeftSide();
|
||||
void ClearTopSide();
|
||||
void ClearRightSide();
|
||||
void ClearBottomSide();
|
||||
|
||||
static void Equation(CBorder &oFirstBorder, CBorder &oSecondBorder);
|
||||
|
||||
bool SetSides(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidth(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidth(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyle(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColor(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetCollapse(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetSides(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidth(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyle(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColor(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
//Left Side
|
||||
bool SetLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthLeftSide (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyleLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColorLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
//Top Side
|
||||
bool SetTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthTopSide (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyleTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColorTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
//Right Side
|
||||
bool SetRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthRightSide (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyleRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColorRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
//Bottom Side
|
||||
bool SetBottomSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthBottomSide(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyleBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColorBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
void SetNone(unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
void Block();
|
||||
void Unblock();
|
||||
|
||||
bool Empty() const;
|
||||
bool Zero() const;
|
||||
bool EqualSides() const;
|
||||
|
||||
const CEnum& GetCollapse() const;
|
||||
|
||||
const CBorderSide& GetLeftBorder() const;
|
||||
const CBorderSide& GetTopBorder() const;
|
||||
const CBorderSide& GetRightBorder() const;
|
||||
@ -655,15 +488,11 @@ namespace NSCSS
|
||||
|
||||
CBorder& operator+=(const CBorder& oBorder);
|
||||
bool operator==(const CBorder& oBorder) const;
|
||||
bool operator!=(const CBorder& oBorder) const;
|
||||
CBorder& operator =(const CBorder& oBorder);
|
||||
private:
|
||||
CBorderSide m_oLeft;
|
||||
CBorderSide m_oTop;
|
||||
CBorderSide m_oRight;
|
||||
CBorderSide m_oBottom;
|
||||
|
||||
CEnum m_enCollapse;
|
||||
};
|
||||
|
||||
class CTextDecorationLine
|
||||
@ -683,7 +512,6 @@ namespace NSCSS
|
||||
bool LineThrough() const;
|
||||
|
||||
CTextDecorationLine &operator+=(const CTextDecorationLine& oTextDecoration);
|
||||
bool operator==(const CTextDecorationLine& oTextDecorationLine) const;
|
||||
};
|
||||
|
||||
struct TTextDecoration
|
||||
@ -693,31 +521,6 @@ namespace NSCSS
|
||||
CColor m_oColor;
|
||||
|
||||
TTextDecoration& operator+=(const TTextDecoration& oTextDecoration);
|
||||
bool operator==(const TTextDecoration& oTextDecoration) const;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Baseline,
|
||||
Sub,
|
||||
Super,
|
||||
Percentage,
|
||||
Length
|
||||
} EBaselineShift;
|
||||
|
||||
class CBaselineShift
|
||||
{
|
||||
CEnum m_eType;
|
||||
CDigit m_oValue;
|
||||
public:
|
||||
CBaselineShift();
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
EBaselineShift GetType() const;
|
||||
double GetValue() const;
|
||||
|
||||
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
};
|
||||
|
||||
class CText
|
||||
@ -727,21 +530,15 @@ namespace NSCSS
|
||||
|
||||
static void Equation(CText &oFirstText, CText &oSecondText);
|
||||
|
||||
bool SetIndent (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetAlign (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetDecoration (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColor (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetHighlight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetBaselineShift (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetIndent (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetAlign (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetDecoration(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColor (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
const CDigit& GetIndent() const;
|
||||
const CString& GetAlign() const;
|
||||
const TTextDecoration& GetDecoration() const;
|
||||
const CColor& GetColor() const;
|
||||
const CColor& GetHighlight() const;
|
||||
|
||||
EBaselineShift GetBaselineShiftType() const;
|
||||
double GetBaselineShiftValue() const;
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
@ -752,12 +549,10 @@ namespace NSCSS
|
||||
CText& operator+=(const CText& oText);
|
||||
bool operator==(const CText& oText) const;
|
||||
private:
|
||||
CBaselineShift m_oBaselineShift;
|
||||
TTextDecoration m_oDecoration;
|
||||
CDigit m_oIndent;
|
||||
CString m_oAlign;
|
||||
CColor m_oColor;
|
||||
CColor m_oHighlight;
|
||||
};
|
||||
|
||||
class CIndent
|
||||
@ -765,49 +560,33 @@ namespace NSCSS
|
||||
public:
|
||||
CIndent();
|
||||
|
||||
void Clear();
|
||||
|
||||
static void Equation(CIndent &oFirstMargin, CIndent &oSecondMargin);
|
||||
|
||||
bool Equals() const;
|
||||
|
||||
void SetPermisson(bool bPermission);
|
||||
|
||||
bool SetValues (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetTop (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetRight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetBottom (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetLeft (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
bool SetValues (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetTop (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetRight (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetBottom (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetLeft (const double& dValue, UnitMeasure enUnitMeasure, 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);
|
||||
bool AddValue (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool AddLeft (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool AddTop (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool AddRight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool AddBottom (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
void UpdateAll(double dFontSize);
|
||||
void UpdateLeft(double dFontSize);
|
||||
void UpdateTop(double dFontSize);
|
||||
void UpdateRight(double dFontSize);
|
||||
void UpdateBottom(double dFontSize);
|
||||
|
||||
const CDigit& GetLeft () const;
|
||||
const CDigit& GetTop () const;
|
||||
const CDigit& GetRight () const;
|
||||
const CDigit& GetBottom() const;
|
||||
const CDigit& GetLeft () const;
|
||||
|
||||
bool GetAfterAutospacing () const;
|
||||
bool GetBeforeAutospacing() const;
|
||||
|
||||
bool Empty() const;
|
||||
bool Zero() const;
|
||||
|
||||
CIndent& operator+=(const CIndent& oIndent);
|
||||
bool operator==(const CIndent& oIndent) const;
|
||||
bool operator!=(const CIndent& oIndent) const;
|
||||
CIndent& operator+=(const CIndent& oMargin);
|
||||
bool operator==(const CIndent& oMargin) 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);
|
||||
bool AddValue(CDigit& oValue, const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
CDigit m_oLeft;
|
||||
CDigit m_oTop;
|
||||
@ -826,7 +605,6 @@ namespace NSCSS
|
||||
|
||||
bool SetValue (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetSize (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetSize (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetLineHeight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetFamily (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStretch (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
@ -834,8 +612,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();
|
||||
|
||||
@ -844,7 +622,6 @@ namespace NSCSS
|
||||
|
||||
const CDigit& GetSize() const;
|
||||
const CDigit& GetLineHeight() const;
|
||||
CDigit& GetLineHeight();
|
||||
const CString& GetFamily() const;
|
||||
const CString& GetStretch() const;
|
||||
const CString& GetStyle() const;
|
||||
@ -864,35 +641,8 @@ namespace NSCSS
|
||||
CString m_oStyle;
|
||||
CString m_oVariant;
|
||||
CString m_oWeight;
|
||||
};
|
||||
|
||||
class CPage
|
||||
{
|
||||
public:
|
||||
CPage();
|
||||
|
||||
bool SetMargin (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetSize (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetFooter (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetHeader (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
bool SetWidth (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetHeight (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetMargin (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetFooter (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetHeader (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
const CDigit& GetWidth() const;
|
||||
const CDigit& GetHeight() const;
|
||||
const CIndent& GetMargin() const;
|
||||
const CDigit& GetFooter() const;
|
||||
const CDigit& GetHeader() const;
|
||||
private:
|
||||
CDigit m_oWidth;
|
||||
CDigit m_oHeight;
|
||||
CIndent m_oMargin;
|
||||
CDigit m_oFooter;
|
||||
CDigit m_oHeader;
|
||||
TTextDecoration m_oTextDecoration;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,19 @@
|
||||
#include "CDocumentStyle.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <unordered_set>
|
||||
#include <wchar.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
|
||||
#define DEFAULT_LINEHEIGHT 240
|
||||
#define LINEHEIGHTSCALE 10 // Значение LineHeight в OOXML должно быть в 10 раз больше чем указано в стиле
|
||||
#define LINEHEIGHTCOEF 24 // Используется когда необходимо перевести в twips значение
|
||||
#define POINTCOEF 20 // Используется для конвертации в OOXML значение интервала между абзацами (Измерение в двадцатых долях от точки)
|
||||
|
||||
#define VALUE_TO_INT(value, unit_measure) \
|
||||
(NSCSS::UnitMeasure::None != value.GetUnitMeasure()) ? \
|
||||
value.ToInt(unit_measure) : \
|
||||
static_cast<int>(NSCSS::CUnitMeasureConverter::ConvertPx(value.ToDouble(), unit_measure, 96) + 0.5)
|
||||
#define PAGEWIDTH (12240 / POINTCOEF)
|
||||
#define PAGEHEIGHT (15840 / POINTCOEF)
|
||||
|
||||
#define DOUBLE_TO_INTW(dValue) std::to_wstring(static_cast<int>(dValue + 0.5))
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
@ -22,54 +21,23 @@ namespace NSCSS
|
||||
: m_oStyle(oStyle), m_bIsPStyle(bIsPStyle)
|
||||
{}
|
||||
|
||||
void CStyleUsed::SetFinalId(const std::wstring& wsFinalId)
|
||||
{
|
||||
m_wsFinalId = wsFinalId;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
for (const std::wstring& wsValue : arFirst)
|
||||
{
|
||||
if (arInitialSet.count(wsValue) > 0)
|
||||
arCommonElements1.push_back(wsValue);
|
||||
}
|
||||
|
||||
for (const std::wstring& wsValue : arSecond)
|
||||
{
|
||||
if (arInitialSet.count(wsValue) > 0)
|
||||
arCommonElements2.push_back(wsValue);
|
||||
}
|
||||
|
||||
if (arCommonElements1.size() != arCommonElements2.size())
|
||||
return false;
|
||||
|
||||
std::sort(arCommonElements1.begin(), arCommonElements1.end());
|
||||
std::sort(arCommonElements2.begin(), arCommonElements2.end());
|
||||
|
||||
return arCommonElements1 == arCommonElements2;
|
||||
}
|
||||
|
||||
bool CStyleUsed::operator==(const CStyleUsed &oUsedStyle) const
|
||||
{
|
||||
return m_bIsPStyle == oUsedStyle.m_bIsPStyle &&
|
||||
CheckArrays(Names_Standard_Styles, m_oStyle.GetParentsNamesSet(), oUsedStyle.m_oStyle.GetParentsNamesSet()) &&
|
||||
m_oStyle == oUsedStyle.m_oStyle;
|
||||
return (m_bIsPStyle == oUsedStyle.m_bIsPStyle) && (m_oStyle == oUsedStyle.m_oStyle);
|
||||
}
|
||||
|
||||
std::wstring CStyleUsed::GetId() const
|
||||
std::wstring CStyleUsed::getId()
|
||||
{
|
||||
return m_wsFinalId;
|
||||
return m_sId;
|
||||
}
|
||||
|
||||
CDocumentStyle::CDocumentStyle()
|
||||
: m_arStandardStyles(Names_Standard_Styles)
|
||||
{}
|
||||
void CStyleUsed::setId(const std::wstring &sId)
|
||||
{
|
||||
m_sId = sId;
|
||||
}
|
||||
|
||||
CDocumentStyle::CDocumentStyle() : m_arStandardStyles({L"a", L"li", L"h1", L"h2", L"h3", L"h4", L"h5", L"h6", L"h1-c",
|
||||
L"h2-c", L"h3-c", L"h4-c", L"h5-c", L"h6-c", L"p-c", L"p", L"div-c", L"div", L"a-c"}) {}
|
||||
|
||||
CDocumentStyle::~CDocumentStyle()
|
||||
{
|
||||
@ -85,7 +53,7 @@ namespace NSCSS
|
||||
|
||||
std::wstring CDocumentStyle::GetIdAndClear()
|
||||
{
|
||||
const std::wstring sId = m_sId;
|
||||
std::wstring sId = m_sId;
|
||||
Clear();
|
||||
return sId;
|
||||
}
|
||||
@ -110,10 +78,10 @@ namespace NSCSS
|
||||
m_sId = sId;
|
||||
}
|
||||
|
||||
bool CDocumentStyle::CombineStandardStyles(const std::vector<std::wstring>& arStandartedStyles, CXmlElement& oElement)
|
||||
void CDocumentStyle::CombineStandardStyles(const std::vector<std::wstring>& arStandartedStyles, CXmlElement& oElement)
|
||||
{
|
||||
if (arStandartedStyles.empty())
|
||||
return false;
|
||||
return;
|
||||
|
||||
std::vector<std::wstring> arStyles;
|
||||
for (const std::wstring& sStyleName : arStandartedStyles)
|
||||
@ -123,7 +91,7 @@ namespace NSCSS
|
||||
}
|
||||
|
||||
if (arStyles.empty())
|
||||
return false;
|
||||
return;
|
||||
|
||||
std::wstring sId;
|
||||
for (std::vector<std::wstring>::const_reverse_iterator iStyleName = arStyles.rbegin(); iStyleName != arStyles.rend(); ++iStyleName)
|
||||
@ -142,25 +110,18 @@ namespace NSCSS
|
||||
|
||||
oElement.AddBasicProperties(BProperties::B_Name, sId);
|
||||
oElement.AddBasicProperties(BProperties::B_StyleId, sId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDocumentStyle::CreateStandardStyle(const std::wstring& sNameStyle, CXmlElement& oElement)
|
||||
void CDocumentStyle::CreateStandardStyle(const std::wstring& sNameStyle, CXmlElement& oElement)
|
||||
{
|
||||
if (std::find(m_arStandardStyles.begin(), m_arStandardStyles.end(), sNameStyle) != m_arStandardStyles.end())
|
||||
{
|
||||
oElement.CreateDefaultElement(sNameStyle);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDocumentStyle::ConvertStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle)
|
||||
void CDocumentStyle::ConvertStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle)
|
||||
{
|
||||
if (oStyle.GetId().empty())
|
||||
return false;
|
||||
return;
|
||||
|
||||
std::wstring sName = oStyle.GetId();
|
||||
const size_t posPoint = sName.find(L'.');
|
||||
@ -190,25 +151,24 @@ namespace NSCSS
|
||||
for (std::wstring& sParentName : arParentsName)
|
||||
sParentName += L"-c";
|
||||
|
||||
bool bResult{false};
|
||||
|
||||
if (!arParentsName.empty())
|
||||
{
|
||||
bResult = CombineStandardStyles(arParentsName, oParentStyle);
|
||||
CombineStandardStyles(arParentsName, oParentStyle);
|
||||
|
||||
if (!oParentStyle.Empty())
|
||||
{
|
||||
oParentStyle.AddBasicProperties(BProperties::B_BasedOn, L"normal");
|
||||
oParentStyle.AddBasicProperties(BProperties::B_StyleId, oParentStyle.GetStyleId());
|
||||
oParentStyle.AddBasicProperties(BProperties::B_StyleId, L"(" + oParentStyle.GetStyleId() + L")");
|
||||
if (!bIsPStyle)
|
||||
{
|
||||
oParentStyle.AddBasicProperties(BProperties::B_StyleId, oParentStyle.GetStyleId() + L"-c");
|
||||
oParentStyle.AddBasicProperties(BProperties::B_Type, L"character");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CXmlElement oStandardXmlElement;
|
||||
if (std::find(m_arStandardStyles.begin(), m_arStandardStyles.end(), sName) != m_arStandardStyles.end())
|
||||
if (CreateStandardStyle(sName, oStandardXmlElement))
|
||||
bResult = true;
|
||||
CreateStandardStyle(sName, oStandardXmlElement);
|
||||
|
||||
if (oStandardXmlElement.Empty() && !oParentStyle.Empty())
|
||||
{
|
||||
@ -228,7 +188,7 @@ namespace NSCSS
|
||||
if (oStyle.Empty())
|
||||
{
|
||||
m_sId = sParentsStyleID;
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
oElement.AddBasicProperties(BProperties::B_BasedOn, sParentsStyleID);
|
||||
@ -241,7 +201,7 @@ namespace NSCSS
|
||||
if (oStyle.Empty())
|
||||
{
|
||||
m_sId = sStandPlusParent;
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
oElement.AddBasicProperties(BProperties::B_BasedOn, sStandPlusParent);
|
||||
}
|
||||
@ -265,7 +225,7 @@ namespace NSCSS
|
||||
if (oStyle.Empty())
|
||||
{
|
||||
m_sId = sStandPlusParent;
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
oElement.AddBasicProperties(BProperties::B_BasedOn, oTempElement.GetStyleId());
|
||||
}
|
||||
@ -288,7 +248,7 @@ namespace NSCSS
|
||||
if (oStyle.Empty())
|
||||
{
|
||||
m_sId = sStandartStyleID;
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
oElement.AddBasicProperties(BProperties::B_BasedOn, sStandartStyleID);
|
||||
}
|
||||
@ -296,7 +256,7 @@ namespace NSCSS
|
||||
if (oStyle.Empty() && oElement.Empty())
|
||||
{
|
||||
m_sId = L"normal";
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
m_sId = oStyle.GetId();
|
||||
@ -309,330 +269,252 @@ namespace NSCSS
|
||||
oElement.AddBasicProperties(BProperties::B_Name, m_sId);
|
||||
oElement.AddBasicProperties(BProperties::B_Type, bIsPStyle ? L"paragraph" : L"character");
|
||||
oElement.AddBasicProperties(BProperties::B_CustomStyle, L"1");
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
bool CDocumentStyle::SetPStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite)
|
||||
void CDocumentStyle::SetPStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement)
|
||||
{
|
||||
bool bResult{false};
|
||||
|
||||
if (!bIsLite)
|
||||
bResult = ConvertStyle(oStyle, oXmlElement, true);
|
||||
|
||||
if (oStyle.Empty())
|
||||
return bResult;
|
||||
|
||||
const bool bInTable{oStyle.HaveThisParent(L"table")};
|
||||
|
||||
std::wstring wsTextAlign{oStyle.m_oText.GetAlign().ToWString()};
|
||||
|
||||
if (wsTextAlign.empty())
|
||||
wsTextAlign = oStyle.m_oDisplay.GetHAlign().ToWString();
|
||||
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_Jc, wsTextAlign);
|
||||
ConvertStyle(oStyle, oXmlElement, true);
|
||||
if (oStyle.Empty() && oXmlElement.Empty())
|
||||
return;
|
||||
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_Jc, oStyle.m_oText.GetAlign().ToWString());
|
||||
|
||||
std::wstring sInfValue;
|
||||
sInfValue.reserve(64);
|
||||
|
||||
if (!oStyle.m_oMargin.GetLeft().Empty() && !oStyle.m_oMargin.GetLeft().Zero())
|
||||
sInfValue += L"w:left=\"" + std::to_wstring(oStyle.m_oMargin.GetLeft().ToInt(NSCSS::Twips)) + L"\" ";
|
||||
//TODO:: проверить Permission в Margin
|
||||
if (!oStyle.m_oMargin.Empty() || !oStyle.m_oPadding.Empty() /*&& oStyle.m_oMargin.GetPermission()*/)
|
||||
{
|
||||
const double dLeftSide = oStyle.m_oMargin.GetLeft() .ToDouble(NSCSS::Twips) + oStyle.m_oPadding.GetLeft() .ToDouble(NSCSS::Twips);
|
||||
const double dRightSide = oStyle.m_oMargin.GetRight().ToDouble(NSCSS::Twips) + oStyle.m_oPadding.GetRight().ToDouble(NSCSS::Twips);
|
||||
|
||||
if (!oStyle.m_oMargin.GetRight().Empty() && !oStyle.m_oMargin.GetRight().Zero())
|
||||
sInfValue += L"w:right=\"" + std::to_wstring(oStyle.m_oMargin.GetRight().ToInt(NSCSS::Twips)) + L"\" ";
|
||||
sInfValue += L"w:left=\"" + DOUBLE_TO_INTW(dLeftSide * POINTCOEF) + L"\" ";
|
||||
sInfValue += L"w:right=\"" + DOUBLE_TO_INTW(dRightSide * POINTCOEF) + L"\" ";
|
||||
}
|
||||
|
||||
const int nIndent = oStyle.m_oText.GetIndent().ToInt(NSCSS::Twips);
|
||||
|
||||
if (0 != nIndent)
|
||||
sInfValue += L"w:firstLine=\"" + std::to_wstring(nIndent) + L"\" ";
|
||||
const double dIndent = oStyle.m_oText.GetIndent().ToDouble(NSCSS::Twips);
|
||||
|
||||
if (0. != dIndent)
|
||||
sInfValue += L"w:firstLine=\"" + DOUBLE_TO_INTW(dIndent) + L"\" ";
|
||||
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_Ind, sInfValue);
|
||||
|
||||
std::wstring sSpacingValue;
|
||||
sSpacingValue.reserve(128);
|
||||
|
||||
if (!oStyle.m_oMargin.GetTop().Empty() && !oStyle.m_oMargin.GetTop().Zero())
|
||||
sSpacingValue += L"w:before=\"" + std::to_wstring(VALUE_TO_INT(oStyle.m_oMargin.GetTop(), NSCSS::Twips)) + L"\" w:beforeAutospacing=\"1\"";
|
||||
else if (oStyle.m_oMargin.GetBottom().Zero() || bInTable)
|
||||
sSpacingValue += L"w:before=\"0\" w:beforeAutospacing=\"1\"";
|
||||
|
||||
if (!oStyle.m_oMargin.GetBottom().Empty() && !oStyle.m_oMargin.GetBottom().Zero())
|
||||
sSpacingValue += L" w:after=\"" + std::to_wstring(VALUE_TO_INT(oStyle.m_oMargin.GetBottom(), NSCSS::Twips)) + L"\" w:afterAutospacing=\"1\"";
|
||||
else if (oStyle.m_oMargin.GetBottom().Zero() || bInTable)
|
||||
sSpacingValue += L" w:after=\"0\" w:afterAutospacing=\"1\"";
|
||||
|
||||
if (!oStyle.m_oFont.GetLineHeight().Empty() && !oStyle.m_oFont.GetLineHeight().Zero())
|
||||
//TODO:: проверить Permission в Margin
|
||||
if (!oStyle.m_oMargin.Empty() || !oStyle.m_oPadding.Empty()/*&& oStyle.m_oMargin.GetPermission()*/)
|
||||
{
|
||||
const std::wstring wsLine{std::to_wstring(oStyle.m_oFont.GetLineHeight().ToInt(NSCSS::Twips, DEFAULT_LINEHEIGHT))};
|
||||
const std::wstring wsLineRule{(NSCSS::Percent == oStyle.m_oFont.GetLineHeight().GetUnitMeasure() ? L"auto" : L"atLeast")};
|
||||
|
||||
sSpacingValue += L" w:line=\"" + wsLine + L"\" w:lineRule=\"" + wsLineRule + L"\"";
|
||||
const double dSpacingBottom = oStyle.m_oMargin.GetBottom().ToDouble(NSCSS::Twips) + oStyle.m_oPadding.GetBottom().ToDouble(NSCSS::Twips);
|
||||
const double dSpacingTop = oStyle.m_oMargin.GetTop() .ToDouble(NSCSS::Twips) + oStyle.m_oPadding.GetTop() .ToDouble(NSCSS::Twips);;
|
||||
|
||||
sSpacingValue += L" w:after=\"" + DOUBLE_TO_INTW(dSpacingBottom * POINTCOEF) + L"\" ";
|
||||
sSpacingValue += L" w:before=\"" + DOUBLE_TO_INTW(dSpacingTop * POINTCOEF) + L"\" ";
|
||||
}
|
||||
else if (oStyle.m_oFont.GetLineHeight().Zero() || bInTable)
|
||||
sSpacingValue += L" w:lineRule=\"auto\" w:line=\"240\"";
|
||||
else/* if (!oStyle.m_pBorder.Empty() || !oStyle.m_oMargin.GetPermission())*/
|
||||
sSpacingValue += L"w:after=\"0\" w:before=\"0\"";
|
||||
|
||||
std::wstring wsLineHeight;
|
||||
|
||||
if (!oStyle.m_oFont.GetLineHeight().Empty())
|
||||
{
|
||||
double dLineHeight = oStyle.m_oFont.GetLineHeight().ToDouble(NSCSS::Twips, LINEHEIGHTCOEF) * LINEHEIGHTSCALE;
|
||||
|
||||
if (NSCSS::None == oStyle.m_oFont.GetLineHeight().GetUnitMeasure())
|
||||
dLineHeight *= LINEHEIGHTCOEF;
|
||||
|
||||
if (0. != dLineHeight)
|
||||
wsLineHeight = DOUBLE_TO_INTW(dLineHeight);
|
||||
}
|
||||
|
||||
if (!wsLineHeight.empty())
|
||||
{
|
||||
sSpacingValue += L" w:line=\"" + wsLineHeight + L"\" w:lineRule=\"auto\"";
|
||||
}
|
||||
// else if (!oStyle.m_oBorder.Empty())
|
||||
// {
|
||||
// sSpacingValue += L" w:line=\"" + std::to_wstring(static_cast<short int>(oStyle.m_oFont.GetSize().ToDouble(NSCSS::Twips) * 2 * POINTCOEF + 0.5f)) + L"\" w:lineRule=\"auto\"";
|
||||
// }
|
||||
else if (!oStyle.m_oBorder.Empty())
|
||||
sSpacingValue += L" w:line=\"240\" w:lineRule=\"auto\" ";
|
||||
|
||||
if (!sSpacingValue.empty())
|
||||
{
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_Spacing, sSpacingValue);
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_ContextualSpacing, L"true");
|
||||
}
|
||||
|
||||
if (!oStyle.m_oBackground.Empty() && !bInTable)
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_Shd, oStyle.m_oBackground.IsNone() ? L"auto" : oStyle.m_oBackground.GetColor().ToWString());
|
||||
if (!oStyle.m_oBackground.Empty())
|
||||
{
|
||||
const std::wstring wsColor = oStyle.m_oBackground.GetColor().ToWString();
|
||||
if (wsColor != L"ffffff")
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_Shd, wsColor);
|
||||
}
|
||||
|
||||
if (!oStyle.m_oBorder.Empty() && !bInTable)
|
||||
if (!oStyle.m_oBorder.Empty())
|
||||
{
|
||||
if (oStyle.m_oBorder.EqualSides())
|
||||
{
|
||||
SetBorderStyle(oStyle, oXmlElement, PProperties::P_TopBorder);
|
||||
SetBorderStyle(oStyle, oXmlElement, PProperties::P_LeftBorder);
|
||||
SetBorderStyle(oStyle, oXmlElement, PProperties::P_BottomBorder);
|
||||
SetBorderStyle(oStyle, oXmlElement, PProperties::P_RightBorder);
|
||||
const std::wstring sBorderColor = oStyle.m_oBorder.GetLeftBorder().GetColor().ToWString();
|
||||
const std::wstring sBorderStyle = oStyle.m_oBorder.GetLeftBorder().GetStyle().ToWString();
|
||||
const std::wstring sBorderWidth = oStyle.m_oBorder.GetLeftBorder().GetWidth().ToWString();
|
||||
|
||||
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"0\" w:sz=\"" +
|
||||
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
|
||||
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_TopBorder, sBorder);
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_LeftBorder, sBorder);
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_BottomBorder, sBorder);
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_RightBorder, sBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!oStyle.m_oBorder.GetTopBorder().Empty())
|
||||
SetBorderStyle(oStyle, oXmlElement, PProperties::P_TopBorder);
|
||||
{
|
||||
const std::wstring sBorderColor = oStyle.m_oBorder.GetTopBorder().GetColor().ToWString();
|
||||
const std::wstring sBorderStyle = oStyle.m_oBorder.GetTopBorder().GetStyle().ToWString();
|
||||
const std::wstring sBorderWidth = oStyle.m_oBorder.GetTopBorder().GetWidth().ToWString();
|
||||
|
||||
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
|
||||
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
|
||||
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_TopBorder, sBorder);
|
||||
}
|
||||
|
||||
if (!oStyle.m_oBorder.GetRightBorder().Empty())
|
||||
SetBorderStyle(oStyle, oXmlElement, PProperties::P_RightBorder);
|
||||
{
|
||||
const std::wstring sBorderColor = oStyle.m_oBorder.GetRightBorder().GetColor().ToWString();
|
||||
const std::wstring sBorderStyle = oStyle.m_oBorder.GetRightBorder().GetStyle().ToWString();
|
||||
const std::wstring sBorderWidth = oStyle.m_oBorder.GetRightBorder().GetWidth().ToWString();
|
||||
|
||||
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
|
||||
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
|
||||
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_RightBorder, sBorder);
|
||||
}
|
||||
|
||||
if (!oStyle.m_oBorder.GetBottomBorder().Empty())
|
||||
SetBorderStyle(oStyle, oXmlElement, PProperties::P_BottomBorder);
|
||||
{
|
||||
const std::wstring sBorderColor = oStyle.m_oBorder.GetBottomBorder().GetColor().ToWString();
|
||||
const std::wstring sBorderStyle = oStyle.m_oBorder.GetBottomBorder().GetStyle().ToWString();
|
||||
const std::wstring sBorderWidth = oStyle.m_oBorder.GetBottomBorder().GetWidth().ToWString();
|
||||
|
||||
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
|
||||
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
|
||||
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_BottomBorder, sBorder);
|
||||
}
|
||||
|
||||
if (!oStyle.m_oBorder.GetLeftBorder().Empty())
|
||||
SetBorderStyle(oStyle, oXmlElement, PProperties::P_LeftBorder);
|
||||
{
|
||||
const std::wstring sBorderColor = oStyle.m_oBorder.GetLeftBorder().GetColor().ToWString();
|
||||
const std::wstring sBorderStyle = oStyle.m_oBorder.GetLeftBorder().GetStyle().ToWString();
|
||||
const std::wstring sBorderWidth = oStyle.m_oBorder.GetLeftBorder().GetWidth().ToWString();
|
||||
|
||||
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
|
||||
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
|
||||
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_LeftBorder, sBorder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bResult || !oXmlElement.Empty();
|
||||
}
|
||||
|
||||
void CDocumentStyle::SetBorderStyle(const CCompiledStyle &oStyle, CXmlElement &oXmlElement, const PProperties &enBorderProperty)
|
||||
void CDocumentStyle::SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement)
|
||||
{
|
||||
const NSCSS::NSProperties::CBorderSide* pBorder = NULL;
|
||||
const NSCSS::NSProperties::CDigit* pPadding = NULL;
|
||||
|
||||
switch(enBorderProperty)
|
||||
{
|
||||
case PProperties::P_BottomBorder:
|
||||
{
|
||||
pBorder = &oStyle.m_oBorder.GetBottomBorder();
|
||||
pPadding = &oStyle.m_oPadding.GetBottom();
|
||||
break;
|
||||
}
|
||||
case PProperties::P_LeftBorder:
|
||||
{
|
||||
pBorder = &oStyle.m_oBorder.GetLeftBorder();
|
||||
pPadding = &oStyle.m_oPadding.GetLeft();
|
||||
break;
|
||||
}
|
||||
case PProperties::P_RightBorder:
|
||||
{
|
||||
pBorder = &oStyle.m_oBorder.GetRightBorder();
|
||||
pPadding = &oStyle.m_oPadding.GetRight();
|
||||
break;
|
||||
}
|
||||
case PProperties::P_TopBorder:
|
||||
{
|
||||
pBorder = &oStyle.m_oBorder.GetTopBorder();
|
||||
pPadding = &oStyle.m_oPadding.GetTop();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
oXmlElement.AddPropertiesInP(enBorderProperty, CalculateBorderStyle(*pBorder, pPadding));
|
||||
}
|
||||
|
||||
std::wstring CDocumentStyle::CalculateBorderStyle(const NSProperties::CBorderSide &oBorder, const NSProperties::CDigit *pPadding)
|
||||
{
|
||||
if (oBorder.Empty())
|
||||
return L"";
|
||||
|
||||
std::wstring wsColor = oBorder.GetColor().ToWString();
|
||||
std::wstring wsStyle = oBorder.GetStyle().ToWString();
|
||||
|
||||
int nWidth = static_cast<int>(std::round(oBorder.GetWidth().ToDouble(Point) * 8.));
|
||||
|
||||
if (L"double" == wsStyle)
|
||||
nWidth /= 3; // в ooxml double граница формируется из трёх линий
|
||||
|
||||
if (nWidth <= 3)
|
||||
nWidth = 2;
|
||||
else if (nWidth <= 5)
|
||||
nWidth = 4;
|
||||
else if (nWidth <= 7)
|
||||
nWidth = 6;
|
||||
else if (nWidth <= 9)
|
||||
nWidth = 8;
|
||||
else if (nWidth <= 15)
|
||||
nWidth = 12;
|
||||
else if (nWidth <= 21)
|
||||
nWidth = 18;
|
||||
else if (nWidth <= 29)
|
||||
nWidth = 24;
|
||||
else if (nWidth <= 41)
|
||||
nWidth = 36;
|
||||
else
|
||||
nWidth = 48;
|
||||
|
||||
if (wsColor.empty())
|
||||
wsColor = L"auto";
|
||||
|
||||
if (wsStyle.empty())
|
||||
wsStyle = L"single";
|
||||
|
||||
int nSpace{0};
|
||||
|
||||
return L"w:val=\"" + wsStyle + L"\" w:sz=\"" + std::to_wstring(nWidth) + + L"\" w:space=\"" + std::to_wstring(nSpace) + L"\" w:color=\"" + wsColor + L"\"";
|
||||
}
|
||||
|
||||
bool CDocumentStyle::SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite)
|
||||
{
|
||||
bool bResult{false};
|
||||
|
||||
if (!bIsLite)
|
||||
bResult = ConvertStyle(oStyle, oXmlElement, false);
|
||||
|
||||
ConvertStyle(oStyle, oXmlElement, false);
|
||||
if (oStyle.Empty() && oXmlElement.Empty())
|
||||
return bResult;
|
||||
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
|
||||
|
||||
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");
|
||||
|
||||
if (!oStyle.m_oBackground.GetColor().Empty() && !oStyle.m_oBackground.GetColor().None() && !oStyle.m_oBackground.GetColor().Url())
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Shd, oStyle.m_oBackground.GetColor().ToWString());
|
||||
|
||||
const std::wstring wsHighlight{oStyle.m_oText.GetHighlight().EquateToColor({{{0, 0, 0}, L"black"}, {{0, 0, 255}, L"blue"}, {{0, 255, 255}, L"cyan"},
|
||||
{{0, 255, 0}, L"green"}, {{255, 0, 255}, L"magenta"}, {{255, 0, 0}, L"red"},
|
||||
{{255, 255, 0}, L"yellow"}, {{255, 255, 255}, L"white"}, {{0, 0, 139}, L"darkBlue"},
|
||||
{{0, 139, 139}, L"darkCyan"}, {{0, 100, 0}, L"darkGreen"}, {{139, 0, 139}, L"darkMagenta"},
|
||||
{{139, 0, 0}, L"darkRed"}, {{128, 128, 0}, L"darkYellow"},{{169, 169, 169}, L"darkGray"},
|
||||
{{211, 211, 211}, L"lightGray"}})};
|
||||
|
||||
if (L"none" != wsHighlight)
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Highlight, wsHighlight);
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Sz, DOUBLE_TO_INTW(oStyle.m_oFont.GetSize().ToDouble(NSCSS::Twips)));
|
||||
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Highlight, oStyle.m_oBackground.GetColor().ToWString());
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Color, oStyle.m_oText.GetColor().ToWString());
|
||||
|
||||
std::wstring wsFontFamily{oStyle.m_oFont.GetFamily().ToWString()};
|
||||
|
||||
if (L"sans-serif" == wsFontFamily)
|
||||
wsFontFamily = L"Arial";
|
||||
else if (L"serif" == wsFontFamily)
|
||||
wsFontFamily = L"Times New Roman";
|
||||
|
||||
if (oStyle.m_oDisplay.GetDisplay() == L"none")
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Vanish, L"true");
|
||||
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_U, (oStyle.m_oText.GetDecoration().m_oLine.Underline()) ? L"underline" : L"");
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_RFonts, oStyle.m_oFont.GetFamily().ToWString());
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_I, oStyle.m_oFont.GetStyle().ToWString());
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_B, oStyle.m_oFont.GetWeight().ToWString());
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_SmallCaps, oStyle.m_oFont.GetVariant().ToWString());
|
||||
|
||||
if (oStyle.m_oText.LineThrough())
|
||||
{
|
||||
if (L"double" == oStyle.m_oText.GetDecoration().m_oStyle.ToWString())
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Strike, L"dstrike");
|
||||
else
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Strike, L"strike");
|
||||
}
|
||||
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_VertAlign, oStyle.m_oDisplay.GetVAlign().ToWString());
|
||||
|
||||
return bResult || !oXmlElement.Empty();
|
||||
}
|
||||
|
||||
bool CDocumentStyle::WriteRStyle(const NSCSS::CCompiledStyle& oStyle)
|
||||
void CDocumentStyle::WriteRStyle (const NSCSS::CCompiledStyle& oStyle)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if(oStyle.GetId().empty())
|
||||
return false;
|
||||
{
|
||||
m_sId = L"normal";
|
||||
return;
|
||||
}
|
||||
|
||||
CStyleUsed structStyle(oStyle, false);
|
||||
|
||||
std::vector<CStyleUsed>::iterator oItem = std::find(m_arStyleUsed.begin(), m_arStyleUsed.end(), structStyle);
|
||||
std::list<CStyleUsed>::iterator oItem = std::find(m_arStyleUsed.begin(), m_arStyleUsed.end(), structStyle);
|
||||
|
||||
if (oItem != m_arStyleUsed.end())
|
||||
{
|
||||
m_sId = (*oItem).GetId();
|
||||
return true;
|
||||
m_sId = (*oItem).getId();
|
||||
return;
|
||||
}
|
||||
|
||||
CXmlElement oXmlElement;
|
||||
SetRStyle(oStyle, oXmlElement);
|
||||
|
||||
if (!SetRStyle(oStyle, oXmlElement))
|
||||
return false;
|
||||
|
||||
structStyle.SetFinalId(m_sId);
|
||||
m_arStyleUsed.push_back(structStyle);
|
||||
m_sStyle += oXmlElement.GetRStyle();
|
||||
|
||||
return true;
|
||||
if (!oStyle.Empty() || !oXmlElement.Empty())
|
||||
{
|
||||
structStyle.setId(oXmlElement.GetStyleId());
|
||||
m_arStyleUsed.push_back(structStyle);
|
||||
m_sStyle += oXmlElement.GetRStyle();
|
||||
}
|
||||
}
|
||||
|
||||
bool CDocumentStyle::WriteLitePStyle(const CCompiledStyle &oStyle)
|
||||
void CDocumentStyle::WriteLitePStyle(const CCompiledStyle &oStyle)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if (oStyle.Empty())
|
||||
return false;
|
||||
return;
|
||||
|
||||
CXmlElement oXmlElement;
|
||||
SetPStyle(oStyle, oXmlElement, true);
|
||||
SetPStyle(oStyle, oXmlElement);
|
||||
|
||||
if (oXmlElement.Empty())
|
||||
return false;
|
||||
|
||||
m_sStyle += oXmlElement.GetPStyle(true);
|
||||
return true;
|
||||
if (!oXmlElement.Empty())
|
||||
m_sStyle += oXmlElement.GetPStyle(true);
|
||||
}
|
||||
|
||||
bool CDocumentStyle::WriteLiteRStyle(const CCompiledStyle &oStyle)
|
||||
void CDocumentStyle::WriteLiteRStyle(const CCompiledStyle &oStyle)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if (oStyle.Empty())
|
||||
return false;
|
||||
return;
|
||||
|
||||
CXmlElement oXmlElement;
|
||||
SetRStyle(oStyle, oXmlElement, true);
|
||||
SetRStyle(oStyle, oXmlElement);
|
||||
|
||||
if (oXmlElement.Empty())
|
||||
return false;
|
||||
|
||||
m_sStyle += oXmlElement.GetRStyle(true);
|
||||
return true;
|
||||
if (!oXmlElement.Empty())
|
||||
m_sStyle += oXmlElement.GetRStyle(true);
|
||||
}
|
||||
|
||||
bool CDocumentStyle::WritePStyle(const NSCSS::CCompiledStyle& oStyle)
|
||||
void CDocumentStyle::WritePStyle (const NSCSS::CCompiledStyle& oStyle)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if(oStyle.GetId().empty())
|
||||
return false;
|
||||
{
|
||||
m_sId = L"normal";
|
||||
return;
|
||||
}
|
||||
|
||||
CStyleUsed structStyle(oStyle, true);
|
||||
std::vector<CStyleUsed>::iterator oItem = std::find(m_arStyleUsed.begin(), m_arStyleUsed.end(), structStyle);
|
||||
std::list<CStyleUsed>::iterator oItem = std::find(m_arStyleUsed.begin(), m_arStyleUsed.end(), structStyle);
|
||||
|
||||
if (oItem != m_arStyleUsed.end())
|
||||
{
|
||||
m_sId = (*oItem).GetId();
|
||||
return true;
|
||||
m_sId = (*oItem).getId();
|
||||
return;
|
||||
}
|
||||
|
||||
CXmlElement oXmlElement;
|
||||
SetPStyle(oStyle, oXmlElement);
|
||||
|
||||
if (!SetPStyle(oStyle, oXmlElement))
|
||||
return false;
|
||||
|
||||
structStyle.SetFinalId(m_sId);
|
||||
m_arStyleUsed.push_back(structStyle);
|
||||
m_sStyle += oXmlElement.GetPStyle();
|
||||
|
||||
return true;
|
||||
if (!oStyle.Empty() || !oXmlElement.Empty())
|
||||
{
|
||||
structStyle.setId(oXmlElement.GetStyleId());
|
||||
m_arStyleUsed.push_back(structStyle);
|
||||
m_sStyle += oXmlElement.GetPStyle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,49 +12,45 @@ namespace NSCSS
|
||||
{
|
||||
CCompiledStyle m_oStyle;
|
||||
bool m_bIsPStyle;
|
||||
std::wstring m_wsFinalId;
|
||||
std::wstring m_sId;
|
||||
|
||||
public:
|
||||
CStyleUsed(const CCompiledStyle& oStyle, bool bIsPStyle);
|
||||
|
||||
void SetFinalId(const std::wstring& wsFinalId);
|
||||
|
||||
bool operator==(const CStyleUsed& oUsedStyle) const;
|
||||
|
||||
std::wstring GetId() const;
|
||||
std::wstring getId();
|
||||
void setId(const std::wstring& sId);
|
||||
};
|
||||
|
||||
static const std::vector<std::wstring> Names_Standard_Styles = {L"a", L"a-c", L"li", L"h1", L"h2", L"h3", L"h4", L"h5", L"h6", L"h1-c", L"h2-c", L"h3-c", L"h4-c", L"h5-c", L"h6-c"};
|
||||
|
||||
class CSSCALCULATOR_EXPORT CDocumentStyle
|
||||
{
|
||||
typedef NSConstValues::NSProperties::BasicProperties BProperties;
|
||||
typedef NSConstValues::NSProperties::ParagraphProperties PProperties;
|
||||
typedef NSConstValues::NSProperties::RunnerProperties RProperties;
|
||||
|
||||
std::vector<std::wstring> m_arStandardStylesUsed;
|
||||
std::vector<std::wstring> m_arStandardStyles;
|
||||
std::vector<CStyleUsed> m_arStyleUsed;
|
||||
std::list<std::wstring> m_arStandardStylesUsed;
|
||||
std::list<std::wstring> m_arStandardStyles;
|
||||
std::list<CStyleUsed> m_arStyleUsed;
|
||||
|
||||
std::wstring m_sStyle;
|
||||
std::wstring m_sId;
|
||||
|
||||
bool CombineStandardStyles(const std::vector<std::wstring>& arStandartedStyles, CXmlElement& oElement);
|
||||
bool CreateStandardStyle (const std::wstring& sNameStyle, CXmlElement& oElement);
|
||||
bool ConvertStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle);
|
||||
void CombineStandardStyles(const std::vector<std::wstring>& arStandartedStyles, CXmlElement& oElement);
|
||||
void CreateStandardStyle (const std::wstring& sNameStyle, CXmlElement& oElement);
|
||||
void ConvertStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle);
|
||||
|
||||
bool SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite = false);
|
||||
bool SetPStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite = false);
|
||||
void SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement);
|
||||
void SetPStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement);
|
||||
|
||||
void SetBorderStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, const PProperties& enBorderProperty);
|
||||
public:
|
||||
CDocumentStyle();
|
||||
~CDocumentStyle();
|
||||
|
||||
bool WritePStyle(const NSCSS::CCompiledStyle& oStyle);
|
||||
bool WriteRStyle(const NSCSS::CCompiledStyle& oStyle);
|
||||
bool WriteLitePStyle(const NSCSS::CCompiledStyle& oStyle);
|
||||
bool WriteLiteRStyle(const NSCSS::CCompiledStyle& oStyle);
|
||||
void WritePStyle(const NSCSS::CCompiledStyle& oStyle);
|
||||
void WriteRStyle(const NSCSS::CCompiledStyle& oStyle);
|
||||
void WriteLitePStyle(const NSCSS::CCompiledStyle& oStyle);
|
||||
void WriteLiteRStyle(const NSCSS::CCompiledStyle& oStyle);
|
||||
|
||||
void SetStyle(const std::wstring& sStyle);
|
||||
void SetId (const std::wstring& sId);
|
||||
@ -63,8 +59,6 @@ namespace NSCSS
|
||||
std::wstring GetIdAndClear();
|
||||
|
||||
void Clear();
|
||||
|
||||
static std::wstring CalculateBorderStyle(const NSCSS::NSProperties::CBorderSide& oBorder, const NSCSS::NSProperties::CDigit* pPadding = NULL);
|
||||
};
|
||||
}
|
||||
#endif // CDOCUMENTSTYLE_H
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#include <cwctype>
|
||||
#include <functional>
|
||||
|
||||
#include <iostream>
|
||||
#include "../ConstValues.h"
|
||||
|
||||
#define DEFAULTFONTNAME L"Times New Roman"
|
||||
@ -26,7 +27,7 @@ CXmlElement::CXmlElement(const std::wstring& sNameDefaultElement)
|
||||
|
||||
bool CXmlElement::Empty() const
|
||||
{
|
||||
return m_mPStyleValues.empty() && m_mRStyleValues.empty() && GetBasedOn().empty();
|
||||
return m_mBasicValues.empty() && m_mPStyleValues.empty() && m_mRStyleValues.empty();
|
||||
}
|
||||
|
||||
void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
@ -34,19 +35,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
if (!Empty())
|
||||
Clear();
|
||||
|
||||
/* if (sNameDefaultElement == L"p")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"paragraph");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"p");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Normal (Web)");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_BasedOn, L"normal");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"99");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_SemiHidden, L"true");
|
||||
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else */if (sNameDefaultElement == L"li")
|
||||
if (sNameDefaultElement == L"li")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"paragraph");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"li");
|
||||
@ -66,7 +55,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h1-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"0");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"480\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h2")
|
||||
{
|
||||
@ -77,7 +66,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h2-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"1");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"400\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h3")
|
||||
{
|
||||
@ -88,7 +77,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h3-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"2");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"360\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h4")
|
||||
{
|
||||
@ -99,7 +88,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h4-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"3");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"320\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h5")
|
||||
{
|
||||
@ -110,7 +99,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h5-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"4");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"280\"");
|
||||
|
||||
}
|
||||
else if (sNameDefaultElement == L"h6")
|
||||
@ -122,93 +111,119 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h6-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"5");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"280\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h1-c")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h1-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 1 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 1 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h1");
|
||||
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"48");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Kern, L"36");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"44");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h2-c")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h2-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 2 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 2 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h2");
|
||||
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"36");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"33");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h3-c")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h3-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 3 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 3 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h3");
|
||||
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"27");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"26");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h4-c")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h4-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 4 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 4 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h4");
|
||||
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"24");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"22");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h5-c")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h5-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 5 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 5 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h5");
|
||||
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"20");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"18");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h6-c")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h6-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 6 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 6 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h6");
|
||||
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"15");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"15");
|
||||
}
|
||||
/*else if (sNameDefaultElement == L"div-c")
|
||||
else if (sNameDefaultElement == L"p-c")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"p-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Paragraph character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"p");
|
||||
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
|
||||
}
|
||||
else if (sNameDefaultElement == L"p")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"paragraph");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"p");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Paragraph");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_BasedOn, L"normal");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"p-c");
|
||||
}
|
||||
else if (sNameDefaultElement == L"div-c")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"div-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Div character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"div");
|
||||
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
|
||||
}
|
||||
else if (sNameDefaultElement == L"div")
|
||||
{
|
||||
@ -218,7 +233,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Div paragraph");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_BasedOn, L"normal");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"div-c");
|
||||
}*/
|
||||
}
|
||||
else if (sNameDefaultElement == L"a-c")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
@ -227,9 +242,9 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"99");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"24");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Color, L"0000FF");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_U, L"single");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
|
||||
}
|
||||
else if (sNameDefaultElement == L"a")
|
||||
{
|
||||
@ -297,7 +312,7 @@ CXmlElement& CXmlElement::operator=(const CXmlElement& oElement)
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool CXmlElement::operator==(const CXmlElement &oElement) const
|
||||
bool CXmlElement::operator==(const CXmlElement &oElement)
|
||||
{
|
||||
return m_mBasicValues == oElement.m_mBasicValues &&
|
||||
m_mPStyleValues == oElement.m_mPStyleValues &&
|
||||
@ -349,22 +364,22 @@ std::wstring CXmlElement::ConvertPStyle(bool bIsLite) const
|
||||
|
||||
case CSSProperties::ParagraphProperties::P_TopBorder:
|
||||
{
|
||||
sPBdr += L"<w:top " + oItem.second + L"/>";
|
||||
sPBdr += L"<w:top" + oItem.second + L"/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::ParagraphProperties::P_LeftBorder:
|
||||
{
|
||||
sPBdr += L"<w:left " + oItem.second + L"/>";
|
||||
sPBdr += L"<w:left" + oItem.second + L"/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::ParagraphProperties::P_BottomBorder:
|
||||
{
|
||||
sPBdr += L"<w:bottom " + oItem.second + L"/>";
|
||||
sPBdr += L"<w:bottom" + oItem.second + L"/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::ParagraphProperties::P_RightBorder:
|
||||
{
|
||||
sPBdr += L"<w:right " + oItem.second + L"/>";
|
||||
sPBdr += L"<w:right" + oItem.second + L"/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::ParagraphProperties::P_KeepLines:
|
||||
@ -414,8 +429,8 @@ std::wstring CXmlElement::ConvertRStyle(bool bIsLite) const
|
||||
}
|
||||
case CSSProperties::RunnerProperties::R_Sz:
|
||||
{
|
||||
sRStyle += L"<w:sz w:val=\"" + oItem.second + L"\"/>" +
|
||||
L"<w:szCs w:val=\"" + oItem.second + L"\"/>";
|
||||
sRStyle += L"<w:sz w:val=\"" + oItem.second +
|
||||
L"\"/>" + L"<w:szCs w:val=\"" + oItem.second + L"\"/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::RunnerProperties::R_B:
|
||||
@ -447,18 +462,11 @@ std::wstring CXmlElement::ConvertRStyle(bool bIsLite) const
|
||||
sRStyle += L"<w:u w:val=\"" + oItem.second + L"\"/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::RunnerProperties::R_Highlight:
|
||||
{
|
||||
if (!oItem.second.empty())
|
||||
sRStyle += L"<w:highlight w:val=\"" + oItem.second + L"\"/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::RunnerProperties::R_Shd:
|
||||
{
|
||||
if (!oItem.second.empty())
|
||||
sRStyle += L"<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"" + oItem.second + L"\"/>";
|
||||
break;
|
||||
}
|
||||
// case CSSProperties::RunnerProperties::R_Highlight:
|
||||
// {
|
||||
// sRStyle += L"<w:highlight w:val=\"" + oItem.second + L"\"/>";
|
||||
// break;
|
||||
// }
|
||||
case CSSProperties::RunnerProperties::R_SmallCaps:
|
||||
{
|
||||
if (oItem.second == L"smallCaps")
|
||||
@ -467,30 +475,6 @@ std::wstring CXmlElement::ConvertRStyle(bool bIsLite) const
|
||||
sRStyle += L"<w:smallCaps w:val=\"false\"/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::RunnerProperties::R_Kern:
|
||||
{
|
||||
sRStyle += L"<w:kern w:val=\"" + oItem.second + L"\"/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::RunnerProperties::R_Vanish:
|
||||
{
|
||||
if (oItem.second == L"true")
|
||||
sRStyle += L"<w:vanish/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::RunnerProperties::R_Strike:
|
||||
{
|
||||
sRStyle += L"<w:" + oItem.second + L"/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::RunnerProperties::R_VertAlign:
|
||||
{
|
||||
if (L"top" == oItem.second)
|
||||
sRStyle += L"<w:vertAlign w:val=\"superscript\"/>";
|
||||
else if (L"bottom" == oItem.second)
|
||||
sRStyle += L"<w:vertAlign w:val=\"subscript\"/>";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -535,8 +519,7 @@ std::wstring CXmlElement::ConvertBasicInfoStyle() const
|
||||
}
|
||||
case CSSProperties::BasicProperties::B_UnhideWhenUsed:
|
||||
{
|
||||
if (L"true" == oItem.second)
|
||||
sBasicInfo += L"<w:unhideWhenUsed/>";
|
||||
sBasicInfo += L"<w:unhideWhenUsed/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::BasicProperties::B_UiPriority:
|
||||
@ -544,12 +527,6 @@ std::wstring CXmlElement::ConvertBasicInfoStyle() const
|
||||
sBasicInfo += L"<w:uiPriority w:val=\"" + oItem.second + L"\"/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::BasicProperties::B_SemiHidden:
|
||||
{
|
||||
if (L"true" == oItem.second)
|
||||
sBasicInfo += L"<w:semiHidden/>";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -621,7 +598,7 @@ std::wstring CXmlElement::GetPStyle(bool bIsLite) const
|
||||
{
|
||||
if (bIsLite)
|
||||
return ConvertPStyle(true);
|
||||
|
||||
|
||||
return GetStyle(true, true, false);
|
||||
}
|
||||
|
||||
@ -629,7 +606,7 @@ std::wstring CXmlElement::GetRStyle(bool bIsLite) const
|
||||
{
|
||||
if (bIsLite)
|
||||
return ConvertRStyle(true);
|
||||
|
||||
|
||||
return GetStyle(true, false, true);
|
||||
}
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ public:
|
||||
|
||||
CXmlElement& operator+=(const CXmlElement& oElement);
|
||||
CXmlElement& operator= (const CXmlElement& oelement);
|
||||
bool operator== (const CXmlElement& oElement) const;
|
||||
bool operator== (const CXmlElement& oElement);
|
||||
};
|
||||
|
||||
#endif // CXMLELEMENT_H
|
||||
|
||||
@ -5,6 +5,7 @@ sys.path.append('../../../../build_tools/scripts')
|
||||
import config
|
||||
import base
|
||||
import os
|
||||
import build
|
||||
|
||||
base_directory = os.getcwd()
|
||||
|
||||
@ -25,5 +26,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);")
|
||||
|
||||
@ -7,5 +7,4 @@ core_windows:INCLUDEPATH += $$PWD/gumbo-parser/visualc/include
|
||||
HEADERS += $$files($$PWD/gumbo-parser/src/*.h, true) \
|
||||
$$PWD/htmltoxhtml.h
|
||||
|
||||
SOURCES += $$files($$PWD/gumbo-parser/src/*.c, true) \
|
||||
$$PWD/htmltoxhtml.cpp
|
||||
SOURCES += $$files($$PWD/gumbo-parser/src/*.c, true)
|
||||
|
||||
@ -1,657 +0,0 @@
|
||||
#include "htmltoxhtml.h"
|
||||
|
||||
#include <map>
|
||||
#include <cctype>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "gumbo-parser/src/gumbo.h"
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
#include "../../../DesktopEditor/common/Directory.h"
|
||||
#include "../../../DesktopEditor/common/StringBuilder.h"
|
||||
#include "../../../UnicodeConverter/UnicodeConverter.h"
|
||||
#include "../../../HtmlFile2/src/StringFinder.h"
|
||||
|
||||
namespace HTML
|
||||
{
|
||||
#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 treat_like_inline = "|p|";
|
||||
|
||||
static std::vector<std::string> html_tags = {"div","span","a","img","p","h1","h2","h3","h4","h5","h6",
|
||||
"ul", "ol", "li","td","tr","table","thead","tbody","tfoot","th",
|
||||
"br","form","input","button","section","nav","header","footer",
|
||||
"main","figure","figcaption","strong","em","i", "b", "u","pre",
|
||||
"code","blockquote","hr","script","link","meta","style","title",
|
||||
"head","body","html","legend","optgroup","option","select","dl",
|
||||
"dt","dd","time","data","abbr","address","area","base","bdi",
|
||||
"bdo","cite","col","iframe","video","source","track","textarea",
|
||||
"label","fieldset","colgroup","del","ins","details","summary",
|
||||
"dialog","embed","kbd","map","mark","menu","meter","object",
|
||||
"output","param","progress","q","samp","small","sub","sup","var",
|
||||
"wbr","acronym","applet","article","aside","audio","basefont",
|
||||
"bgsound","big","blink","canvas","caption","center","command",
|
||||
"comment","datalist","dfn","dir","font","frame","frameset",
|
||||
"hgroup","isindex","keygen","marquee","nobr","noembed","noframes",
|
||||
"noscript","plaintext","rp","rt","ruby","s","strike","tt","xmp"};
|
||||
|
||||
static std::vector<std::string> unchecked_nodes_new = {"svg"};
|
||||
|
||||
static void replace_all(std::string& s, const std::string& s1, const std::string& s2)
|
||||
{
|
||||
size_t pos = s.find(s1);
|
||||
while(pos != std::string::npos)
|
||||
{
|
||||
s.replace(pos, s1.length(), s2);
|
||||
pos = s.find(s1, pos + s2.length());
|
||||
}
|
||||
}
|
||||
|
||||
static bool NodeIsUnprocessed(const std::string& sTagName)
|
||||
{
|
||||
return "xml" == sTagName;
|
||||
}
|
||||
|
||||
static bool IsUnckeckedNodes(const std::string& sValue)
|
||||
{
|
||||
return unchecked_nodes_new.end() != std::find(unchecked_nodes_new.begin(), unchecked_nodes_new.end(), sValue);
|
||||
}
|
||||
|
||||
static std::string Base64ToString(const std::string& sContent, const std::string& sCharset)
|
||||
{
|
||||
std::string sRes;
|
||||
int nSrcLen = (int)sContent.length();
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nSrcLen);
|
||||
BYTE* pData = new BYTE[nDecodeLen];
|
||||
if (TRUE == NSBase64::Base64Decode(sContent.c_str(), nSrcLen, pData, &nDecodeLen))
|
||||
{
|
||||
std::wstring sConvert;
|
||||
if(!sCharset.empty() && NSStringFinder::Equals<std::string>("utf-8", sCharset))
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sConvert = oConverter.toUnicode(reinterpret_cast<char *>(pData), (unsigned)nDecodeLen, sCharset.data());
|
||||
}
|
||||
sRes = sConvert.empty() ? std::string(reinterpret_cast<char *>(pData), nDecodeLen) : U_TO_UTF8(sConvert);
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
return sRes;
|
||||
}
|
||||
|
||||
static std::string QuotedPrintableDecode(const std::string& sContent, std::string& sCharset)
|
||||
{
|
||||
NSStringUtils::CStringBuilderA sRes;
|
||||
size_t ip = 0;
|
||||
size_t i = sContent.find('=');
|
||||
|
||||
if(i == 0)
|
||||
{
|
||||
size_t nIgnore = 12;
|
||||
std::string charset = sContent.substr(0, nIgnore);
|
||||
if(charset == "=00=00=FE=FF")
|
||||
sCharset = "UTF-32BE";
|
||||
else if(charset == "=FF=FE=00=00")
|
||||
sCharset = "UTF-32LE";
|
||||
else if(charset == "=2B=2F=76=38" || charset == "=2B=2F=76=39" ||
|
||||
charset == "=2B=2F=76=2B" || charset == "=2B=2F=76=2F")
|
||||
sCharset = "UTF-7";
|
||||
else if(charset == "=DD=73=66=73")
|
||||
sCharset = "UTF-EBCDIC";
|
||||
else if(charset == "=84=31=95=33")
|
||||
sCharset = "GB-18030";
|
||||
else
|
||||
{
|
||||
nIgnore -= 3;
|
||||
charset.erase(nIgnore);
|
||||
if(charset == "=EF=BB=BF")
|
||||
sCharset = "UTF-8";
|
||||
else if(charset == "=F7=64=4C")
|
||||
sCharset = "UTF-1";
|
||||
else if(charset == "=0E=FE=FF")
|
||||
sCharset = "SCSU";
|
||||
else if(charset == "=FB=EE=28")
|
||||
sCharset = "BOCU-1";
|
||||
else
|
||||
{
|
||||
nIgnore -= 3;
|
||||
charset.erase(nIgnore);
|
||||
if(charset == "=FE=FF")
|
||||
sCharset = "UTF-16BE";
|
||||
else if(charset == "=FF=FE")
|
||||
sCharset = "UTF-16LE";
|
||||
else
|
||||
nIgnore -= 6;
|
||||
}
|
||||
}
|
||||
|
||||
ip = nIgnore;
|
||||
i = sContent.find('=', ip);
|
||||
}
|
||||
|
||||
while(i != std::string::npos && i + 2 < sContent.length())
|
||||
{
|
||||
sRes.WriteString(sContent.c_str() + ip, i - ip);
|
||||
std::string str = sContent.substr(i + 1, 2);
|
||||
if(str.front() == '\n' || str.front() == '\r')
|
||||
{
|
||||
char ch = str[1];
|
||||
if(ch != '\n' && ch != '\r')
|
||||
sRes.WriteString(&ch, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
char* err;
|
||||
char ch = (int)strtol(str.data(), &err, 16);
|
||||
if(*err)
|
||||
sRes.WriteString('=' + str);
|
||||
else
|
||||
sRes.WriteString(&ch, 1);
|
||||
}
|
||||
ip = i + 3;
|
||||
i = sContent.find('=', ip);
|
||||
}
|
||||
if(ip != std::string::npos)
|
||||
sRes.WriteString(sContent.c_str() + ip);
|
||||
return sRes.GetData();
|
||||
}
|
||||
|
||||
static std::string mhtTohtml(const std::string& sFileContent);
|
||||
|
||||
static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::string>& sRes, NSStringUtils::CStringBuilderA& oRes)
|
||||
{
|
||||
size_t unContentPosition = 0, unCharsetBegin = 0, unCharsetEnd = std::string::npos;
|
||||
|
||||
NSStringFinder::TFoundedData<char> oData;
|
||||
|
||||
// Content-Type
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-type", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentType{oData.m_sValue};
|
||||
|
||||
if (sContentType.empty())
|
||||
return;
|
||||
|
||||
if (NSStringFinder::Equals(sContentType, "multipart/alternative"))
|
||||
{
|
||||
oRes.WriteString(mhtTohtml(sMhtContent.substr(oData.m_unEndPosition, sMhtContent.length() - oData.m_unEndPosition)));
|
||||
return;
|
||||
}
|
||||
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetBegin = oData.m_unEndPosition;
|
||||
|
||||
// name
|
||||
// std::string sName = NSStringFinder::FindProperty(sMhtContent, "name", {"="}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
// unContentPosition = std::max(unContentPosition, unLastPosition);
|
||||
|
||||
// Content-Location
|
||||
oData = NSStringFinder::FindProperty(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"});
|
||||
std::string sContentID{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
{
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetEnd = std::min(unCharsetEnd, oData.m_unBeginPosition);
|
||||
NSStringFinder::CutInside<std::string>(sContentID, "<", ">");
|
||||
}
|
||||
|
||||
if (sContentLocation.empty() && !sContentID.empty())
|
||||
sContentLocation = "cid:" + sContentID;
|
||||
|
||||
// Content-Transfer-Encoding
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-transfer-encoding", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentEncoding{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
{
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetEnd = std::min(unCharsetEnd, oData.m_unBeginPosition);
|
||||
}
|
||||
|
||||
// charset
|
||||
std::string sCharset = "utf-8";
|
||||
|
||||
if (std::string::npos != unCharsetEnd && unCharsetBegin < unCharsetEnd)
|
||||
{
|
||||
sCharset = NSStringFinder::FindProperty(sMhtContent.substr(unCharsetBegin, unCharsetEnd - unCharsetBegin), "charset", {"="}, {";", "\\n", "\\r"}).m_sValue;
|
||||
NSStringFinder::CutInside<std::string>(sCharset, "\"");
|
||||
}
|
||||
|
||||
// Content
|
||||
std::string sContent = sMhtContent.substr(unContentPosition, sMhtContent.length() - unContentPosition);
|
||||
|
||||
// std::wstring sExtention = NSFile::GetFileExtention(UTF8_TO_U(sName));
|
||||
// std::transform(sExtention.begin(), sExtention.end(), sExtention.begin(), tolower);
|
||||
// Основной документ
|
||||
if (NSStringFinder::Equals(sContentType, "multipart/alternative"))
|
||||
oRes.WriteString(mhtTohtml(sContent));
|
||||
else if ((NSStringFinder::Find(sContentType, "text") /*&& (sExtention.empty() || NSStringFinder::EqualOf(sExtention, {L"htm", L"html", L"xhtml", L"css"}))*/)
|
||||
|| (NSStringFinder::Equals(sContentType, "application/octet-stream") && NSStringFinder::Find(sContentLocation, "css")))
|
||||
{
|
||||
// Стили заключаются в тэг <style>
|
||||
const bool bAddTagStyle = NSStringFinder::Equals(sContentType, "text/css") /*|| NSStringFinder::Equals(sExtention, L"css")*/ || NSStringFinder::Find(sContentLocation, "css");
|
||||
|
||||
if (bAddTagStyle)
|
||||
oRes.WriteString("<style>");
|
||||
|
||||
if (NSStringFinder::Equals(sContentEncoding, "base64"))
|
||||
sContent = Base64ToString(sContent, sCharset);
|
||||
else if (NSStringFinder::EqualOf(sContentEncoding, {"8bit", "7bit"}) || sContentEncoding.empty())
|
||||
{
|
||||
if (!NSStringFinder::Equals(sCharset, "utf-8") && !sCharset.empty())
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sContent = U_TO_UTF8(oConverter.toUnicode(sContent, sCharset.data()));
|
||||
}
|
||||
}
|
||||
else if (NSStringFinder::Equals(sContentEncoding, "quoted-printable"))
|
||||
{
|
||||
sContent = QuotedPrintableDecode(sContent, sCharset);
|
||||
if (!NSStringFinder::Equals(sCharset, "utf-8") && !sCharset.empty())
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sContent = U_TO_UTF8(oConverter.toUnicode(sContent, sCharset.data()));
|
||||
}
|
||||
}
|
||||
|
||||
if (NSStringFinder::Equals(sContentType, "text/html"))
|
||||
sContent = U_TO_UTF8(htmlToXhtml(sContent, false));
|
||||
|
||||
oRes.WriteString(sContent);
|
||||
|
||||
if(bAddTagStyle)
|
||||
oRes.WriteString("</style>");
|
||||
}
|
||||
// Картинки
|
||||
else if ((NSStringFinder::Find(sContentType, "image") /*|| NSStringFinder::Equals(sExtention, L"gif")*/ || NSStringFinder::Equals(sContentType, "application/octet-stream")) &&
|
||||
NSStringFinder::Equals(sContentEncoding, "base64"))
|
||||
{
|
||||
// if (NSStringFinder::Equals(sExtention, L"ico") || NSStringFinder::Find(sContentType, "ico"))
|
||||
// sContentType = "image/jpg";
|
||||
// else if(NSStringFinder::Equals(sExtention, L"gif"))
|
||||
// sContentType = "image/gif";
|
||||
int nSrcLen = (int)sContent.length();
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nSrcLen);
|
||||
BYTE* pData = new BYTE[nDecodeLen];
|
||||
if (TRUE == NSBase64::Base64Decode(sContent.c_str(), nSrcLen, pData, &nDecodeLen))
|
||||
sRes.insert(std::make_pair(sContentLocation, "data:" + sContentType + ";base64," + sContent));
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
}
|
||||
}
|
||||
|
||||
static std::string mhtTohtml(const std::string& sFileContent)
|
||||
{
|
||||
std::map<std::string, std::string> sRes;
|
||||
NSStringUtils::CStringBuilderA oRes;
|
||||
|
||||
// Поиск boundary
|
||||
NSStringFinder::TFoundedData<char> oData{NSStringFinder::FindProperty(sFileContent, "boundary", {"="}, {"\\r", "\\n", "\""})};
|
||||
|
||||
size_t nFound{oData.m_unEndPosition};
|
||||
std::string sBoundary{oData.m_sValue};
|
||||
|
||||
if (sBoundary.empty())
|
||||
{
|
||||
size_t nFoundEnd = sFileContent.length();
|
||||
nFound = 0;
|
||||
ReadMht(sFileContent.substr(nFound, nFoundEnd), sRes, oRes);
|
||||
return oRes.GetData();
|
||||
}
|
||||
|
||||
NSStringFinder::CutInside<std::string>(sBoundary, "\"");
|
||||
|
||||
size_t nFoundEnd{nFound};
|
||||
|
||||
sBoundary = "--" + sBoundary;
|
||||
size_t nBoundaryLength = sBoundary.length();
|
||||
|
||||
nFound = sFileContent.find(sBoundary, nFound) + nBoundaryLength;
|
||||
|
||||
// Цикл по boundary
|
||||
while(nFound != std::string::npos)
|
||||
{
|
||||
nFoundEnd = sFileContent.find(sBoundary, nFound + nBoundaryLength);
|
||||
if(nFoundEnd == std::string::npos)
|
||||
break;
|
||||
|
||||
ReadMht(sFileContent.substr(nFound, nFoundEnd - nFound), sRes, oRes);
|
||||
|
||||
nFound = sFileContent.find(sBoundary, nFoundEnd);
|
||||
}
|
||||
|
||||
std::string sFile = oRes.GetData();
|
||||
for(const std::pair<std::string, std::string>& item : sRes)
|
||||
{
|
||||
std::string sName = item.first;
|
||||
size_t found = sFile.find(sName);
|
||||
size_t sfound = sName.rfind('/');
|
||||
if(found == std::string::npos && sfound != std::string::npos)
|
||||
found = sFile.find(sName.erase(0, sfound + 1));
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
size_t fq = sFile.find_last_of("\"\'>=", found);
|
||||
|
||||
if (std::string::npos == fq)
|
||||
break;
|
||||
|
||||
char ch = sFile[fq];
|
||||
if(ch != '\"' && ch != '\'')
|
||||
fq++;
|
||||
size_t tq = sFile.find_first_of("\"\'<> ", found) + 1;
|
||||
|
||||
if (std::string::npos == tq)
|
||||
break;
|
||||
|
||||
if(sFile[tq] != '\"' && sFile[tq] != '\'')
|
||||
tq--;
|
||||
if(ch != '>')
|
||||
{
|
||||
std::string is = '\"' + item.second + '\"';
|
||||
sFile.replace(fq, tq - fq, is);
|
||||
found = sFile.find(sName, fq + is.length());
|
||||
}
|
||||
else
|
||||
found = sFile.find(sName, tq);
|
||||
}
|
||||
}
|
||||
|
||||
return sFile;
|
||||
}
|
||||
|
||||
// Заменяет сущности &,<,> в text
|
||||
static void substitute_xml_entities_into_text(std::string& text)
|
||||
{
|
||||
// replacing & must come first
|
||||
replace_all(text, "&", "&");
|
||||
replace_all(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, "\"", """);
|
||||
}
|
||||
|
||||
static std::string handle_unknown_tag(GumboStringPiece* text)
|
||||
{
|
||||
if (text->data == NULL)
|
||||
return "";
|
||||
GumboStringPiece gsp = *text;
|
||||
gumbo_tag_from_original_text(&gsp);
|
||||
std::string sAtr = std::string(gsp.data, gsp.length);
|
||||
size_t found = sAtr.find_first_of("-'+,./=?;!*#@$_%<>&;\"\'()[]{}");
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
sAtr.erase(found, 1);
|
||||
found = sAtr.find_first_of("-'+,./=?;!*#@$_%<>&;\"\'()[]{}", found);
|
||||
}
|
||||
return sAtr;
|
||||
}
|
||||
|
||||
static std::string get_tag_name(GumboNode* node)
|
||||
{
|
||||
std::string tagname = (node->type == GUMBO_NODE_DOCUMENT ? "document" : gumbo_normalized_tagname(node->v.element.tag));
|
||||
if (tagname.empty())
|
||||
tagname = handle_unknown_tag(&node->v.element.original_tag);
|
||||
return tagname;
|
||||
}
|
||||
|
||||
static void build_doctype(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilder)
|
||||
{
|
||||
if (node->v.document.has_doctype)
|
||||
{
|
||||
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 \"");
|
||||
oBuilder.WriteString(pi);
|
||||
oBuilder.WriteString("\" \"");
|
||||
oBuilder.WriteString(node->v.document.system_identifier);
|
||||
oBuilder.WriteString("\"");
|
||||
}
|
||||
oBuilder.WriteString(">");
|
||||
}
|
||||
}
|
||||
|
||||
static void build_attributes(const GumboVector* attribs, NSStringUtils::CStringBuilderA& atts)
|
||||
{
|
||||
std::vector<std::string> arrRepeat;
|
||||
for (size_t i = 0; i < attribs->length; ++i)
|
||||
{
|
||||
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;
|
||||
size_t nBad = sName.find_first_of("+,.=?#%<>&;\"\'()[]{}");
|
||||
while(nBad != std::string::npos)
|
||||
{
|
||||
sName.erase(nBad, 1);
|
||||
nBad = sName.find_first_of("+,.=?#%<>&;\"\'()[]{}", nBad);
|
||||
if(sName.empty())
|
||||
break;
|
||||
bCheck = true;
|
||||
}
|
||||
if(sName.empty())
|
||||
continue;
|
||||
while(sName.front() >= '0' && sName.front() <= '9')
|
||||
{
|
||||
sName.erase(0, 1);
|
||||
if(sName.empty())
|
||||
break;
|
||||
bCheck = true;
|
||||
}
|
||||
if(bCheck)
|
||||
{
|
||||
GumboAttribute* check = gumbo_get_attribute(attribs, sName.c_str());
|
||||
if(check || std::find(arrRepeat.begin(), arrRepeat.end(), sName) != arrRepeat.end())
|
||||
continue;
|
||||
else
|
||||
arrRepeat.push_back(sName);
|
||||
}
|
||||
|
||||
if(sName.empty())
|
||||
continue;
|
||||
atts.WriteString(sName);
|
||||
|
||||
// determine original quote character used if it exists
|
||||
std::string qs ="\"";
|
||||
atts.WriteString("=");
|
||||
atts.WriteString(qs);
|
||||
substitute_xml_entities_into_attributes(sVal);
|
||||
atts.WriteString(sVal);
|
||||
atts.WriteString(qs);
|
||||
}
|
||||
}
|
||||
|
||||
static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilder, bool bCheckValidNode = true);
|
||||
|
||||
static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA& contents, bool bCheckValidNode)
|
||||
{
|
||||
std::string key = "|" + get_tag_name(node) + "|";
|
||||
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;
|
||||
|
||||
GumboVector* children = &node->v.element.children;
|
||||
|
||||
for (size_t i = 0; i < children->length; i++)
|
||||
{
|
||||
GumboNode* child = static_cast<GumboNode*> (children->data[i]);
|
||||
|
||||
if (child->type == GUMBO_NODE_TEXT)
|
||||
{
|
||||
std::string val(child->v.text.text);
|
||||
remove_control_symbols(val);
|
||||
substitute_xml_entities_into_text(val);
|
||||
|
||||
// Избавление от FF
|
||||
size_t found = val.find_first_of("\014");
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
val.erase(found, 1);
|
||||
found = val.find_first_of("\014", found);
|
||||
}
|
||||
|
||||
contents.WriteString(val);
|
||||
}
|
||||
else if ((child->type == GUMBO_NODE_ELEMENT) || (child->type == GUMBO_NODE_TEMPLATE))
|
||||
prettyprint(child, contents, bCheckValidNode);
|
||||
else if (child->type == GUMBO_NODE_WHITESPACE)
|
||||
{
|
||||
if (keep_whitespace || is_inline || is_like_inline)
|
||||
contents.WriteString(child->v.text.text);
|
||||
}
|
||||
else if (child->type != GUMBO_NODE_COMMENT)
|
||||
{
|
||||
// Сообщение об ошибке
|
||||
// Does this actually exist: (child->type == GUMBO_NODE_CDATA)
|
||||
// fprintf(stderr, "unknown element of type: %d\n", child->type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilder, bool bCheckValidNode)
|
||||
{
|
||||
// special case the document node
|
||||
if (node->type == GUMBO_NODE_DOCUMENT)
|
||||
{
|
||||
build_doctype(node, oBuilder);
|
||||
prettyprint_contents(node, oBuilder, bCheckValidNode);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string tagname = get_tag_name(node);
|
||||
remove_control_symbols(tagname);
|
||||
|
||||
if (NodeIsUnprocessed(tagname))
|
||||
return;
|
||||
|
||||
if (bCheckValidNode)
|
||||
bCheckValidNode = !IsUnckeckedNodes(tagname);
|
||||
|
||||
if (bCheckValidNode && html_tags.end() == std::find(html_tags.begin(), html_tags.end(), tagname))
|
||||
{
|
||||
prettyprint_contents(node, oBuilder, bCheckValidNode);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string close = "";
|
||||
std::string closeTag = "";
|
||||
std::string key = "|" + tagname + "|";
|
||||
bool is_empty_tag = empty_tags.find(key) != std::string::npos;
|
||||
|
||||
// determine closing tag type
|
||||
if (is_empty_tag)
|
||||
close = "/";
|
||||
else
|
||||
closeTag = "</" + tagname + ">";
|
||||
|
||||
// build results
|
||||
oBuilder.WriteString("<" + tagname);
|
||||
|
||||
// build attr string
|
||||
const GumboVector* attribs = &node->v.element.attributes;
|
||||
build_attributes(attribs, oBuilder);
|
||||
oBuilder.WriteString(close + ">");
|
||||
|
||||
// prettyprint your contents
|
||||
prettyprint_contents(node, oBuilder, bCheckValidNode);
|
||||
oBuilder.WriteString(closeTag);
|
||||
}
|
||||
|
||||
std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert)
|
||||
{
|
||||
if (bNeedConvert)
|
||||
{ // Определение кодировки
|
||||
std::string sEncoding = NSStringFinder::FindProperty(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\"", "'"}).m_sValue;
|
||||
|
||||
if (sEncoding.empty())
|
||||
sEncoding = NSStringFinder::FindProperty(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "}).m_sValue;
|
||||
|
||||
if (!sEncoding.empty() && !NSStringFinder::Equals("utf-8", sEncoding))
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sFileContent = U_TO_UTF8(oConverter.toUnicode(sFileContent, sEncoding.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
// Избавляемся от лишних символов до <...
|
||||
boost::regex oRegex("<[a-zA-Z]");
|
||||
boost::match_results<typename std::string::const_iterator> oResult;
|
||||
|
||||
if (boost::regex_search(sFileContent, oResult, oRegex))
|
||||
sFileContent.erase(0, oResult.position());
|
||||
|
||||
//Избавление от <a ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "a"));
|
||||
//Избавление от <title ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "title"));
|
||||
//Избавление от <script ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "script"));
|
||||
|
||||
// Gumbo
|
||||
GumboOptions options = kGumboDefaultOptions;
|
||||
GumboOutput* output = gumbo_parse_with_options(&options, sFileContent.data(), sFileContent.length());
|
||||
|
||||
// prettyprint
|
||||
NSStringUtils::CStringBuilderA oBuilder;
|
||||
prettyprint(output->document, oBuilder);
|
||||
|
||||
// Конвертирование из string utf8 в wstring
|
||||
return UTF8_TO_U(oBuilder.GetData());
|
||||
}
|
||||
|
||||
std::wstring mhtToXhtml(std::string& sFileContent)
|
||||
{
|
||||
sFileContent = mhtTohtml(sFileContent);
|
||||
|
||||
// Gumbo
|
||||
GumboOptions options = kGumboDefaultOptions;
|
||||
GumboOutput* output = gumbo_parse_with_options(&options, sFileContent.data(), sFileContent.length());
|
||||
|
||||
// prettyprint
|
||||
NSStringUtils::CStringBuilderA oBuilder;
|
||||
prettyprint(output->document, oBuilder);
|
||||
|
||||
// Конвертирование из string utf8 в wstring
|
||||
return UTF8_TO_U(oBuilder.GetData());
|
||||
}
|
||||
}
|
||||
@ -2,11 +2,671 @@
|
||||
#define HTMLTOXHTML_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <cctype>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace HTML
|
||||
#include "gumbo-parser/src/gumbo.h"
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
#include "../../../DesktopEditor/common/Directory.h"
|
||||
#include "../../../DesktopEditor/common/StringBuilder.h"
|
||||
#include "../../../UnicodeConverter/UnicodeConverter.h"
|
||||
|
||||
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 void prettyprint(GumboNode*, NSStringUtils::CStringBuilderA& oBuilder);
|
||||
static std::string mhtTohtml(std::string& sFileContent);
|
||||
|
||||
// Заменяет в строке s все символы s1 на s2
|
||||
static void replace_all(std::string& s, const std::string& s1, const std::string& s2)
|
||||
{
|
||||
std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert);
|
||||
std::wstring mhtToXhtml(std::string& sFileContent);
|
||||
size_t pos = s.find(s1);
|
||||
while(pos != std::string::npos)
|
||||
{
|
||||
s.replace(pos, s1.length(), s2);
|
||||
pos = s.find(s1, pos + s2.length());
|
||||
}
|
||||
}
|
||||
|
||||
static std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert)
|
||||
{
|
||||
// Распознование кодировки
|
||||
if (bNeedConvert)
|
||||
{
|
||||
size_t posEncoding = sFileContent.find("charset=");
|
||||
if (posEncoding == std::string::npos)
|
||||
posEncoding = sFileContent.find("encoding=");
|
||||
if (posEncoding != std::string::npos)
|
||||
{
|
||||
posEncoding = sFileContent.find("=", posEncoding) + 1;
|
||||
char quoteSymbol = '\"';
|
||||
if(sFileContent[posEncoding] == '\"' || sFileContent[posEncoding] == '\'')
|
||||
{
|
||||
quoteSymbol = sFileContent[posEncoding];
|
||||
posEncoding += 1;
|
||||
}
|
||||
|
||||
size_t posEnd = sFileContent.find(quoteSymbol, posEncoding);
|
||||
if (std::string::npos != posEnd)
|
||||
{
|
||||
std::string sEncoding = sFileContent.substr(posEncoding, posEnd - posEncoding);
|
||||
if (sEncoding != "utf-8" && sEncoding != "UTF-8")
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sFileContent = U_TO_UTF8(oConverter.toUnicode(sFileContent, sEncoding.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Избавление от <a/>
|
||||
size_t posA = sFileContent.find("<a ");
|
||||
while(posA != std::string::npos)
|
||||
{
|
||||
size_t nBegin = sFileContent.find('<', posA + 1);
|
||||
size_t nEnd = sFileContent.find("/>", posA);
|
||||
if(nEnd < nBegin)
|
||||
sFileContent.replace(nEnd, 2, "></a>");
|
||||
posA = sFileContent.find("<a ", nBegin);
|
||||
}
|
||||
// Избавление от <title/>
|
||||
posA = sFileContent.find("<title/>");
|
||||
while (posA != std::string::npos)
|
||||
{
|
||||
sFileContent.replace(posA, 8, "<title></title>");
|
||||
posA = sFileContent.find("<title/>", posA);
|
||||
}
|
||||
// Избавление от <script/>
|
||||
posA = sFileContent.find("<script");
|
||||
while (posA != std::string::npos)
|
||||
{
|
||||
size_t nEnd = 0;
|
||||
size_t nEnd1 = sFileContent.find("/>", posA);
|
||||
size_t nEnd2 = sFileContent.find("</script>", posA);
|
||||
if (nEnd1 != std::string::npos)
|
||||
nEnd = nEnd1 + 2;
|
||||
if (nEnd2 != std::string::npos && (nEnd == 0 || (nEnd > 0 && nEnd2 < nEnd)))
|
||||
nEnd = nEnd2 + 9;
|
||||
|
||||
sFileContent.erase(posA, nEnd - posA);
|
||||
|
||||
posA = sFileContent.find("<script", posA);
|
||||
}
|
||||
|
||||
// Gumbo
|
||||
GumboOptions options = kGumboDefaultOptions;
|
||||
GumboOutput* output = gumbo_parse_with_options(&options, sFileContent.data(), sFileContent.length());
|
||||
|
||||
// prettyprint
|
||||
NSStringUtils::CStringBuilderA oBuilder;
|
||||
prettyprint(output->document, oBuilder);
|
||||
|
||||
// Конвертирование из string utf8 в wstring
|
||||
return UTF8_TO_U(oBuilder.GetData());
|
||||
}
|
||||
|
||||
static std::string Base64ToString(const std::string& sContent, const std::string& sCharset)
|
||||
{
|
||||
std::string sRes;
|
||||
int nSrcLen = (int)sContent.length();
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nSrcLen);
|
||||
BYTE* pData = new BYTE[nDecodeLen];
|
||||
if (TRUE == NSBase64::Base64Decode(sContent.c_str(), nSrcLen, pData, &nDecodeLen))
|
||||
{
|
||||
std::wstring sConvert;
|
||||
if(!sCharset.empty() && sCharset != "utf-8" && sCharset != "UTF-8")
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sConvert = oConverter.toUnicode(reinterpret_cast<char *>(pData), (unsigned)nDecodeLen, sCharset.data());
|
||||
}
|
||||
sRes = sConvert.empty() ? std::string(reinterpret_cast<char *>(pData), nDecodeLen) : U_TO_UTF8(sConvert);
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
return sRes;
|
||||
}
|
||||
|
||||
static std::string QuotedPrintableDecode(const std::string& sContent, std::string& sCharset)
|
||||
{
|
||||
NSStringUtils::CStringBuilderA sRes;
|
||||
size_t ip = 0;
|
||||
size_t i = sContent.find('=');
|
||||
|
||||
if(i == 0)
|
||||
{
|
||||
size_t nIgnore = 12;
|
||||
std::string charset = sContent.substr(0, nIgnore);
|
||||
if(charset == "=00=00=FE=FF")
|
||||
sCharset = "UTF-32BE";
|
||||
else if(charset == "=FF=FE=00=00")
|
||||
sCharset = "UTF-32LE";
|
||||
else if(charset == "=2B=2F=76=38" || charset == "=2B=2F=76=39" ||
|
||||
charset == "=2B=2F=76=2B" || charset == "=2B=2F=76=2F")
|
||||
sCharset = "UTF-7";
|
||||
else if(charset == "=DD=73=66=73")
|
||||
sCharset = "UTF-EBCDIC";
|
||||
else if(charset == "=84=31=95=33")
|
||||
sCharset = "GB-18030";
|
||||
else
|
||||
{
|
||||
nIgnore -= 3;
|
||||
charset.erase(nIgnore);
|
||||
if(charset == "=EF=BB=BF")
|
||||
sCharset = "UTF-8";
|
||||
else if(charset == "=F7=64=4C")
|
||||
sCharset = "UTF-1";
|
||||
else if(charset == "=0E=FE=FF")
|
||||
sCharset = "SCSU";
|
||||
else if(charset == "=FB=EE=28")
|
||||
sCharset = "BOCU-1";
|
||||
else
|
||||
{
|
||||
nIgnore -= 3;
|
||||
charset.erase(nIgnore);
|
||||
if(charset == "=FE=FF")
|
||||
sCharset = "UTF-16BE";
|
||||
else if(charset == "=FF=FE")
|
||||
sCharset = "UTF-16LE";
|
||||
else
|
||||
nIgnore -= 6;
|
||||
}
|
||||
}
|
||||
|
||||
ip = nIgnore;
|
||||
i = sContent.find('=', ip);
|
||||
}
|
||||
|
||||
while(i != std::string::npos && i + 2 < sContent.length())
|
||||
{
|
||||
sRes.WriteString(sContent.c_str() + ip, i - ip);
|
||||
std::string str = sContent.substr(i + 1, 2);
|
||||
if(str.front() == '\n' || str.front() == '\r')
|
||||
{
|
||||
char ch = str[1];
|
||||
if(ch != '\n' && ch != '\r')
|
||||
sRes.WriteString(&ch, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
char* err;
|
||||
char ch = (int)strtol(str.data(), &err, 16);
|
||||
if(*err)
|
||||
sRes.WriteString('=' + str);
|
||||
else
|
||||
sRes.WriteString(&ch, 1);
|
||||
}
|
||||
ip = i + 3;
|
||||
i = sContent.find('=', ip);
|
||||
}
|
||||
if(ip != std::string::npos)
|
||||
sRes.WriteString(sContent.c_str() + ip);
|
||||
return sRes.GetData();
|
||||
}
|
||||
|
||||
static void ReadMht(std::string& sFileContent, size_t& nFound, size_t& nNextFound, const std::string& sBoundary,
|
||||
std::map<std::string, std::string>& sRes, NSStringUtils::CStringBuilderA& oRes)
|
||||
{
|
||||
// Content
|
||||
size_t nContentTag = sFileContent.find("\n\n", nFound);
|
||||
if(nContentTag == std::string::npos || nContentTag > nNextFound)
|
||||
{
|
||||
nContentTag = sFileContent.find("\r\r", nFound);
|
||||
if(nContentTag == std::string::npos || nContentTag > nNextFound)
|
||||
{
|
||||
nContentTag = sFileContent.find("\r\n\r\n", nFound);
|
||||
if(nContentTag == std::string::npos || nContentTag > nNextFound)
|
||||
{
|
||||
nFound = nNextFound;
|
||||
return;
|
||||
}
|
||||
else
|
||||
nContentTag += 4;
|
||||
}
|
||||
else
|
||||
nContentTag += 2;
|
||||
}
|
||||
else
|
||||
nContentTag += 2;
|
||||
|
||||
// Content-Type
|
||||
size_t nTag = sFileContent.find("Content-Type: ", nFound);
|
||||
if(nTag == std::string::npos || nTag > nContentTag)
|
||||
{
|
||||
nFound = nNextFound;
|
||||
return;
|
||||
}
|
||||
size_t nTagEnd = sFileContent.find_first_of(";\n\r", nTag);
|
||||
nTag += 14;
|
||||
if(nTagEnd == std::string::npos || nTagEnd > nContentTag)
|
||||
{
|
||||
nFound = nNextFound;
|
||||
return;
|
||||
}
|
||||
std::string sContentType = sFileContent.substr(nTag, nTagEnd - nTag);
|
||||
if(sContentType == "multipart/alternative")
|
||||
nContentTag = nFound;
|
||||
|
||||
// name
|
||||
std::string sName;
|
||||
nTag = sFileContent.find(" name=", nFound);
|
||||
if(nTag != std::string::npos && nTag < nContentTag)
|
||||
{
|
||||
nTagEnd = sFileContent.find_first_of(";\n\r", nTag);
|
||||
nTag += 6;
|
||||
if(nTagEnd != std::string::npos && nTagEnd < nContentTag)
|
||||
sName = sFileContent.substr(nTag, nTagEnd - nTag);
|
||||
}
|
||||
|
||||
// charset
|
||||
std::string sCharset;
|
||||
nTag = sFileContent.find("charset=", nFound);
|
||||
if(nTag != std::string::npos && nTag < nContentTag)
|
||||
{
|
||||
nTagEnd = sFileContent.find_first_of(";\n\r", nTag);
|
||||
nTag += 8;
|
||||
if(nTagEnd != std::string::npos && nTagEnd < nContentTag)
|
||||
{
|
||||
if(sFileContent[nTag] == '\"')
|
||||
{
|
||||
nTag++;
|
||||
nTagEnd--;
|
||||
}
|
||||
sCharset = sFileContent.substr(nTag, nTagEnd - nTag);
|
||||
}
|
||||
}
|
||||
|
||||
// Content-Location
|
||||
std::string sContentLocation;
|
||||
nTag = sFileContent.find("Content-Location: ", nFound);
|
||||
if(nTag != std::string::npos && nTag < nContentTag)
|
||||
{
|
||||
nTagEnd = sFileContent.find_first_of(";\n\r", nTag);
|
||||
nTag += 18;
|
||||
if(nTagEnd != std::string::npos && nTagEnd < nContentTag)
|
||||
sContentLocation = sFileContent.substr(nTag, nTagEnd - nTag);
|
||||
}
|
||||
|
||||
if (sContentLocation.empty())
|
||||
{
|
||||
// Content-ID
|
||||
std::string sContentID;
|
||||
nTag = sFileContent.find("Content-ID: <", nFound);
|
||||
if(nTag != std::string::npos && nTag < nContentTag)
|
||||
{
|
||||
nTagEnd = sFileContent.find_first_of(">", nTag);
|
||||
nTag += 13;
|
||||
if(nTagEnd != std::string::npos && nTagEnd < nContentTag)
|
||||
sContentID = sFileContent.substr(nTag, nTagEnd - nTag);
|
||||
}
|
||||
|
||||
if (!sContentID.empty())
|
||||
sContentLocation = "cid:" + sContentID;
|
||||
}
|
||||
|
||||
// Content-Transfer-Encoding
|
||||
std::string sContentEncoding;
|
||||
nTag = sFileContent.find("Content-Transfer-Encoding: ", nFound);
|
||||
if(nTag != std::string::npos && nTag < nContentTag)
|
||||
{
|
||||
nTagEnd = sFileContent.find_first_of(";\n\r", nTag);
|
||||
nTag += 27;
|
||||
if(nTagEnd != std::string::npos && nTagEnd < nContentTag)
|
||||
sContentEncoding = sFileContent.substr(nTag, nTagEnd - nTag);
|
||||
}
|
||||
|
||||
// Content
|
||||
nTagEnd = nNextFound - 2;
|
||||
if(nTagEnd == std::string::npos || nTagEnd < nContentTag)
|
||||
{
|
||||
nFound = nNextFound;
|
||||
return;
|
||||
}
|
||||
std::string sContent = sFileContent.substr(nContentTag, nTagEnd - nContentTag);
|
||||
|
||||
// Удаляем лишнее
|
||||
sFileContent.erase(0, nNextFound);
|
||||
nFound = sFileContent.find(sBoundary);
|
||||
|
||||
std::wstring sExtention = NSFile::GetFileExtention(UTF8_TO_U(sName));
|
||||
std::transform(sExtention.begin(), sExtention.end(), sExtention.begin(), tolower);
|
||||
// Основной документ
|
||||
if(sContentType == "multipart/alternative")
|
||||
oRes.WriteString(mhtTohtml(sContent));
|
||||
else if((sContentType.find("text") != std::string::npos && (sExtention.empty() || sExtention == L"htm" || sExtention == L"html" || sExtention
|
||||
== L"xhtml" || sExtention == L"css")) || (sContentType == "application/octet-stream" && (sContentLocation.find("css") !=
|
||||
std::string::npos)))
|
||||
{
|
||||
// Стили заключаются в тэг <style>
|
||||
if(sContentType == "text/css" || sExtention == L"css" || sContentLocation.find("css") != std::string::npos)
|
||||
oRes.WriteString("<style>");
|
||||
if(sContentEncoding == "Base64" || sContentEncoding == "base64")
|
||||
oRes.WriteString(Base64ToString(sContent, sCharset));
|
||||
else if(sContentEncoding == "8bit" || sContentEncoding == "7bit" || sContentEncoding.empty())
|
||||
{
|
||||
if (sCharset != "utf-8" && sCharset != "UTF-8" && !sCharset.empty())
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sContent = U_TO_UTF8(oConverter.toUnicode(sContent, sCharset.data()));
|
||||
}
|
||||
oRes.WriteString(sContent);
|
||||
}
|
||||
else if(sContentEncoding == "quoted-printable" || sContentEncoding == "Quoted-Printable")
|
||||
{
|
||||
sContent = QuotedPrintableDecode(sContent, sCharset);
|
||||
if (sCharset != "utf-8" && sCharset != "UTF-8" && !sCharset.empty())
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sContent = U_TO_UTF8(oConverter.toUnicode(sContent, sCharset.data()));
|
||||
}
|
||||
oRes.WriteString(sContent);
|
||||
}
|
||||
if(sContentType == "text/css" || sExtention == L"css" || sContentLocation.find("css") != std::string::npos)
|
||||
oRes.WriteString("</style>");
|
||||
}
|
||||
// Картинки
|
||||
else if((sContentType.find("image") != std::string::npos || sExtention == L"gif" || sContentType == "application/octet-stream") &&
|
||||
(sContentEncoding == "Base64" || sContentEncoding == "base64"))
|
||||
{
|
||||
if(sExtention == L"ico" || sContentType.find("ico") != std::string::npos)
|
||||
sContentType = "image/jpg";
|
||||
else if(sExtention == L"gif")
|
||||
sContentType = "image/gif";
|
||||
int nSrcLen = (int)sContent.length();
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nSrcLen);
|
||||
BYTE* pData = new BYTE[nDecodeLen];
|
||||
if (TRUE == NSBase64::Base64Decode(sContent.c_str(), nSrcLen, pData, &nDecodeLen))
|
||||
sRes.insert(std::make_pair(sContentLocation, "data:" + sContentType + ";base64," + sContent));
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
}
|
||||
}
|
||||
|
||||
static std::string mhtTohtml(std::string& sFileContent)
|
||||
{
|
||||
std::map<std::string, std::string> sRes;
|
||||
NSStringUtils::CStringBuilderA oRes;
|
||||
|
||||
// Поиск boundary
|
||||
size_t nFound = sFileContent.find("boundary=");
|
||||
if(nFound == std::string::npos)
|
||||
{
|
||||
size_t nFoundEnd = sFileContent.length();
|
||||
nFound = 0;
|
||||
ReadMht(sFileContent, nFound, nFoundEnd, "no", sRes, oRes);
|
||||
return oRes.GetData();
|
||||
}
|
||||
size_t nFoundEnd = sFileContent.find_first_of(";\n\r", nFound);
|
||||
if(nFoundEnd == std::string::npos)
|
||||
return "";
|
||||
nFound += 9;
|
||||
if(sFileContent[nFound] == '\"')
|
||||
{
|
||||
nFound++;
|
||||
nFoundEnd--;
|
||||
}
|
||||
if(nFound > nFoundEnd)
|
||||
return "";
|
||||
std::string sBoundary = sFileContent.substr(nFound, nFoundEnd - nFound);
|
||||
size_t nBoundaryLength = sBoundary.length();
|
||||
|
||||
// Удаляем лишнее
|
||||
nFound = sFileContent.find(sBoundary, nFoundEnd);
|
||||
sFileContent.erase(0, nFound);
|
||||
|
||||
// Цикл по boundary
|
||||
nFound = 0;
|
||||
while(nFound != std::string::npos)
|
||||
{
|
||||
// Выход по --boundary--
|
||||
if(sFileContent[nFound + nBoundaryLength + 1] == '-')
|
||||
break;
|
||||
nFoundEnd = sFileContent.find(sBoundary, nFound + nBoundaryLength);
|
||||
if(nFoundEnd == std::string::npos)
|
||||
break;
|
||||
ReadMht(sFileContent, nFound, nFoundEnd, sBoundary, sRes, oRes);
|
||||
}
|
||||
std::string sFile = oRes.GetData();
|
||||
for(const std::pair<std::string, std::string>& item : sRes)
|
||||
{
|
||||
std::string sName = item.first;
|
||||
size_t found = sFile.find(sName);
|
||||
size_t sfound = sName.rfind('/');
|
||||
if(found == std::string::npos && sfound != std::string::npos)
|
||||
found = sFile.find(sName.erase(0, sfound + 1));
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
size_t fq = sFile.find_last_of("\"\'>=", found);
|
||||
char ch = sFile[fq];
|
||||
if(ch != '\"' && ch != '\'')
|
||||
fq++;
|
||||
size_t tq = sFile.find_first_of("\"\'<> ", found) + 1;
|
||||
if(sFile[tq] != '\"' && sFile[tq] != '\'')
|
||||
tq--;
|
||||
if(ch != '>')
|
||||
{
|
||||
std::string is = '\"' + item.second + '\"';
|
||||
sFile.replace(fq, tq - fq, is);
|
||||
found = sFile.find(sName, fq + is.length());
|
||||
}
|
||||
else
|
||||
found = sFile.find(sName, tq);
|
||||
}
|
||||
}
|
||||
return sFile;
|
||||
}
|
||||
|
||||
static std::wstring mhtToXhtml(std::string& sFileContent)
|
||||
{
|
||||
sFileContent = mhtTohtml(sFileContent);
|
||||
|
||||
// Gumbo
|
||||
GumboOptions options = kGumboDefaultOptions;
|
||||
GumboOutput* output = gumbo_parse_with_options(&options, sFileContent.data(), sFileContent.length());
|
||||
|
||||
// prettyprint
|
||||
NSStringUtils::CStringBuilderA oBuilder;
|
||||
prettyprint(output->document, oBuilder);
|
||||
|
||||
// Конвертирование из string utf8 в wstring
|
||||
return UTF8_TO_U(oBuilder.GetData());
|
||||
}
|
||||
|
||||
// Заменяет сущности &,<,> в text
|
||||
static void substitute_xml_entities_into_text(std::string& text)
|
||||
{
|
||||
// replacing & must come first
|
||||
replace_all(text, "&", "&");
|
||||
replace_all(text, "<", "<");
|
||||
replace_all(text, ">", ">");
|
||||
}
|
||||
|
||||
// Заменяет сущности " в text
|
||||
static void substitute_xml_entities_into_attributes(std::string& text)
|
||||
{
|
||||
substitute_xml_entities_into_text(text);
|
||||
replace_all(text, "\"", """);
|
||||
}
|
||||
|
||||
static std::string handle_unknown_tag(GumboStringPiece* text)
|
||||
{
|
||||
if (text->data == NULL)
|
||||
return "";
|
||||
GumboStringPiece gsp = *text;
|
||||
gumbo_tag_from_original_text(&gsp);
|
||||
std::string sAtr = std::string(gsp.data, gsp.length);
|
||||
size_t found = sAtr.find_first_of("-'+,./=?;!*#@$_%<>&;\"\'()[]{}");
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
sAtr.erase(found, 1);
|
||||
found = sAtr.find_first_of("-'+,./=?;!*#@$_%<>&;\"\'()[]{}", found);
|
||||
}
|
||||
return sAtr;
|
||||
}
|
||||
|
||||
static std::string get_tag_name(GumboNode* node)
|
||||
{
|
||||
std::string tagname = (node->type == GUMBO_NODE_DOCUMENT ? "document" : gumbo_normalized_tagname(node->v.element.tag));
|
||||
if (tagname.empty())
|
||||
tagname = handle_unknown_tag(&node->v.element.original_tag);
|
||||
return tagname;
|
||||
}
|
||||
|
||||
static void build_doctype(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilder)
|
||||
{
|
||||
if (node->v.document.has_doctype)
|
||||
{
|
||||
oBuilder.WriteString("<!DOCTYPE ");
|
||||
oBuilder.WriteString(node->v.document.name);
|
||||
std::string pi(node->v.document.public_identifier);
|
||||
if ((node->v.document.public_identifier != NULL) && !pi.empty())
|
||||
{
|
||||
oBuilder.WriteString(" PUBLIC \"");
|
||||
oBuilder.WriteString(pi);
|
||||
oBuilder.WriteString("\" \"");
|
||||
oBuilder.WriteString(node->v.document.system_identifier);
|
||||
oBuilder.WriteString("\"");
|
||||
}
|
||||
oBuilder.WriteString(">");
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
GumboAttribute* at = static_cast<GumboAttribute*>(attribs->data[i]);
|
||||
std::string sVal(at->value);
|
||||
std::string sName(at->name);
|
||||
atts.WriteString(" ");
|
||||
|
||||
bool bCheck = false;
|
||||
size_t nBad = sName.find_first_of("+,.=?#%<>&;\"\'()[]{}");
|
||||
while(nBad != std::string::npos)
|
||||
{
|
||||
sName.erase(nBad, 1);
|
||||
nBad = sName.find_first_of("+,.=?#%<>&;\"\'()[]{}", nBad);
|
||||
if(sName.empty())
|
||||
break;
|
||||
bCheck = true;
|
||||
}
|
||||
if(sName.empty())
|
||||
continue;
|
||||
while(sName.front() >= '0' && sName.front() <= '9')
|
||||
{
|
||||
sName.erase(0, 1);
|
||||
if(sName.empty())
|
||||
break;
|
||||
bCheck = true;
|
||||
}
|
||||
if(bCheck)
|
||||
{
|
||||
GumboAttribute* check = gumbo_get_attribute(attribs, sName.c_str());
|
||||
if(check || std::find(arrRepeat.begin(), arrRepeat.end(), sName) != arrRepeat.end())
|
||||
continue;
|
||||
else
|
||||
arrRepeat.push_back(sName);
|
||||
}
|
||||
|
||||
if(sName.empty())
|
||||
continue;
|
||||
atts.WriteString(sName);
|
||||
|
||||
// determine original quote character used if it exists
|
||||
std::string qs ="\"";
|
||||
atts.WriteString("=");
|
||||
atts.WriteString(qs);
|
||||
if(!no_entities)
|
||||
substitute_xml_entities_into_attributes(sVal);
|
||||
atts.WriteString(sVal);
|
||||
atts.WriteString(qs);
|
||||
}
|
||||
}
|
||||
|
||||
static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA& contents)
|
||||
{
|
||||
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;
|
||||
|
||||
GumboVector* children = &node->v.element.children;
|
||||
|
||||
for (size_t i = 0; i < children->length; i++)
|
||||
{
|
||||
GumboNode* child = static_cast<GumboNode*> (children->data[i]);
|
||||
|
||||
if (child->type == GUMBO_NODE_TEXT)
|
||||
{
|
||||
std::string val(child->v.text.text);
|
||||
if(!no_entity_substitution)
|
||||
substitute_xml_entities_into_text(val);
|
||||
|
||||
// Избавление от FF
|
||||
size_t found = val.find_first_of("\014");
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
val.erase(found, 1);
|
||||
found = val.find_first_of("\014", found);
|
||||
}
|
||||
|
||||
contents.WriteString(val);
|
||||
}
|
||||
else if ((child->type == GUMBO_NODE_ELEMENT) || (child->type == GUMBO_NODE_TEMPLATE))
|
||||
prettyprint(child, contents);
|
||||
else if (child->type == GUMBO_NODE_WHITESPACE)
|
||||
{
|
||||
if (keep_whitespace || is_inline || is_like_inline)
|
||||
contents.WriteString(child->v.text.text);
|
||||
}
|
||||
else if (child->type != GUMBO_NODE_COMMENT)
|
||||
{
|
||||
// Сообщение об ошибке
|
||||
// Does this actually exist: (child->type == GUMBO_NODE_CDATA)
|
||||
// fprintf(stderr, "unknown element of type: %d\n", child->type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilder)
|
||||
{
|
||||
// special case the document node
|
||||
if (node->type == GUMBO_NODE_DOCUMENT)
|
||||
{
|
||||
build_doctype(node, oBuilder);
|
||||
prettyprint_contents(node, oBuilder);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string close = "";
|
||||
std::string closeTag = "";
|
||||
std::string tagname = get_tag_name(node);
|
||||
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)
|
||||
close = "/";
|
||||
else
|
||||
closeTag = "</" + tagname + ">";
|
||||
|
||||
// build results
|
||||
oBuilder.WriteString("<" + tagname);
|
||||
|
||||
// build attr string
|
||||
const GumboVector* attribs = &node->v.element.attributes;
|
||||
build_attributes(attribs, no_entity_substitution, oBuilder);
|
||||
oBuilder.WriteString(close + ">");
|
||||
|
||||
// prettyprint your contents
|
||||
prettyprint_contents(node, oBuilder);
|
||||
oBuilder.WriteString(closeTag);
|
||||
}
|
||||
|
||||
#endif // HTMLTOXHTML_H
|
||||
|
||||
1
Common/3dParty/hunspell/.gitignore
vendored
1
Common/3dParty/hunspell/.gitignore
vendored
@ -2,4 +2,3 @@ emsdk/
|
||||
hunspell/
|
||||
deploy/
|
||||
o
|
||||
hunspell.data
|
||||
|
||||
@ -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 },
|
||||
};
|
||||
@ -14,12 +14,6 @@ def get_hunspell(stable_commit):
|
||||
base.replaceInFile("./src/hunspell/csutil.cxx", "void free_utf_tbl() {", "void free_utf_tbl() { \n return;\n")
|
||||
# bug fix, we need to keep this utf table
|
||||
# free_utf_tbl doesnt delete anything so we can destroy hunspell object
|
||||
|
||||
# replace & add defines to easy control of time limits (CUSTOM_LIMIT)
|
||||
default_tl_defines = "#define TIMELIMIT_GLOBAL (CLOCKS_PER_SEC / 4)\n#define TIMELIMIT_SUGGESTION (CLOCKS_PER_SEC / 10)\n#define TIMELIMIT (CLOCKS_PER_SEC / 20)\n"
|
||||
custom_tl_defines_tl = "#define TIMELIMIT_GLOBAL CUSTOM_TIMELIMIT_GLOBAL\n#define TIMELIMIT_SUGGESTION CUSTOM_TIMELIMIT_SUGGESTION\n#define TIMELIMIT CUSTOM_TIMELIMIT\n"
|
||||
tl_defines = "#ifndef CUSTOM_TIMELIMITS\n" + default_tl_defines + "#else\n" + custom_tl_defines_tl + "#endif\n"
|
||||
base.replaceInFile("./src/hunspell/atypes.hxx", default_tl_defines, tl_defines)
|
||||
os.chdir("../")
|
||||
|
||||
|
||||
|
||||
@ -1,163 +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 "../../../../Common/3dParty/hunspell/hunspell/src/hunspell/hunspell.h"
|
||||
#include "../../../../DesktopEditor/common/StringExt.h"
|
||||
#include "../../../../DesktopEditor/common/Directory.h"
|
||||
#include <iostream>
|
||||
|
||||
bool CheckCaret(std::vector<std::wstring>& words)
|
||||
{
|
||||
bool bIsCaret = false;
|
||||
for (int i = 0, len = (int)words.size(); i < len; ++i)
|
||||
{
|
||||
if (words[i].find('\r') == (words[i].length() - 1))
|
||||
{
|
||||
words[i] = words[i].substr(0, words[i].length() - 1);
|
||||
bIsCaret = true;
|
||||
}
|
||||
}
|
||||
return bIsCaret;
|
||||
}
|
||||
|
||||
std::wstring CheckWord(Hunhandle* pDic, const std::wstring& sWord, const bool& bIsCaret)
|
||||
{
|
||||
std::wstring sResult = sWord;
|
||||
|
||||
std::string sWordA = U_TO_UTF8(sWord);
|
||||
int nSpellResult = Hunspell_spell(pDic, sWordA.c_str());
|
||||
|
||||
if (0 == nSpellResult)
|
||||
{
|
||||
char** pSuggest;
|
||||
int nSuggestCount = Hunspell_suggest(pDic, &pSuggest, sWordA.c_str());
|
||||
|
||||
sResult += L" [";
|
||||
|
||||
for (int i = 0; i < nSuggestCount; ++i)
|
||||
{
|
||||
std::string sSuggestA(pSuggest[i], strlen(pSuggest[i]));
|
||||
std::wstring sSuggest = UTF8_TO_U(sSuggestA);
|
||||
|
||||
sResult += sSuggest;
|
||||
if (i != (nSuggestCount - 1))
|
||||
sResult += (L", ");
|
||||
}
|
||||
|
||||
if (0 < nSuggestCount)
|
||||
Hunspell_free_list(pDic, &pSuggest, nSuggestCount);
|
||||
|
||||
sResult += L"]";
|
||||
}
|
||||
|
||||
if (bIsCaret)
|
||||
sResult += L"\r";
|
||||
sResult += L"\n";
|
||||
|
||||
return sResult;
|
||||
}
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#define USE_WCHAR_ARGC
|
||||
#endif
|
||||
|
||||
#ifdef USE_WCHAR_ARGC
|
||||
std::wstring GetParam(wchar_t* arg)
|
||||
{
|
||||
return std::wstring(arg);
|
||||
}
|
||||
#else
|
||||
std::wstring GetParam(char* arg)
|
||||
{
|
||||
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE *)arg, (LONG)strlen(arg));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_WCHAR_ARGC
|
||||
int wmain(int argc, wchar_t *argv[])
|
||||
#else
|
||||
int main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
std::wstring sSrcDir = NSFile::GetProcessDirectory() + L"/../src";
|
||||
std::wstring sDstDir = NSFile::GetProcessDirectory() + L"/../dst";
|
||||
std::wstring sDictionariesDir = NSFile::GetProcessDirectory() + L"/../../../../../../dictionaries";
|
||||
|
||||
if (argc > 1) sSrcDir = GetParam(argv[1]);
|
||||
if (argc > 2) sDstDir = GetParam(argv[2]);
|
||||
if (argc > 3) sDictionariesDir = GetParam(argv[3]);
|
||||
|
||||
std::vector<std::wstring> arSrcFiles = NSDirectory::GetFiles(sSrcDir);
|
||||
|
||||
for (int i = 0, len = (int)arSrcFiles.size(); i < len; ++i)
|
||||
{
|
||||
std::wstring sFileWords = arSrcFiles[i];
|
||||
std::wstring sName = NSFile::GetFileName(sFileWords);
|
||||
std::wstring::size_type sNamePos = sName.find(L".");
|
||||
if (std::wstring::npos != sNamePos)
|
||||
sName = sName.substr(0, sNamePos);
|
||||
|
||||
std::wstring sFileWordsContent = L"";
|
||||
NSFile::CFileBinary::ReadAllTextUtf8(sFileWords, sFileWordsContent);
|
||||
|
||||
std::vector<std::wstring> arWords = NSStringExt::Split(sFileWordsContent, '\n');
|
||||
bool bIsCaret = CheckCaret(arWords);
|
||||
|
||||
std::wstring sAff = sDictionariesDir + L"/" + sName + L"/" + sName + L".aff";
|
||||
std::wstring sDic = sDictionariesDir + L"/" + sName + L"/" + sName + L".dic";
|
||||
|
||||
// skip check diffs if dictionary is not exists
|
||||
if (!NSFile::CFileBinary::Exists(sAff) || !NSFile::CFileBinary::Exists(sDic))
|
||||
continue;
|
||||
|
||||
std::string sAffA = U_TO_UTF8(sAff);
|
||||
std::string sDicA = U_TO_UTF8(sDic);
|
||||
|
||||
Hunhandle* pDictionary = Hunspell_create(sAffA.c_str(), sDicA.c_str());
|
||||
|
||||
std::wstring sFileDst = sDstDir + L"/" + sName + L".txt";
|
||||
|
||||
std::wstring sResult = L"";
|
||||
for (const std::wstring& word : arWords)
|
||||
{
|
||||
sResult += CheckWord(pDictionary, word, bIsCaret);
|
||||
}
|
||||
|
||||
Hunspell_destroy(pDictionary);
|
||||
|
||||
NSFile::CFileBinary::SaveToFile(sFileDst, sResult, true);
|
||||
|
||||
std::cout << "[" << (i + 1) << " of " << (int)arSrcFiles.size() << "] " << U_TO_UTF8(sName) << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,48 +0,0 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2015-07-21T18:28:42
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT -= core gui
|
||||
|
||||
TARGET = dictionariestester
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
DEFINES += KERNEL_USE_DYNAMIC_LIBRARY
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += hunspell_build_static
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/hunspell/qt/hunspell.pri)
|
||||
|
||||
# custom time limits of hunspell in clocks (if before.py was executed)
|
||||
# when increasing the limit for each case, it is important to consider that the total time will
|
||||
# also increase, so it is good to increase the global limit. this works the same for the candidate limit with suggest limit
|
||||
DEFINES += CUSTOM_TIMELIMITS
|
||||
|
||||
escape_bracket=
|
||||
!core_windows:escape_bracket=\\
|
||||
|
||||
# total time limit per word for all cases. (default is CLOCKS_PER_SEC/4)
|
||||
DEFINES += "CUSTOM_TIMELIMIT_GLOBAL=$${escape_bracket}(20*CLOCKS_PER_SEC$${escape_bracket})"
|
||||
|
||||
# total time limit per "1 case" - forgotten char, double char, moved char and so on for all candidates. (default is CLOCKS_PER_SEC/10)
|
||||
DEFINES += "CUSTOM_TIMELIMIT_SUGGESTION=$${escape_bracket}(5*CLOCKS_PER_SEC$${escape_bracket})"
|
||||
|
||||
# time limit per candidate (default is CLOCKS_PER_SEC/20)
|
||||
DEFINES += "CUSTOM_TIMELIMIT=$${escape_bracket}(CLOCKS_PER_SEC$${escape_bracket}\)"
|
||||
|
||||
ADD_DEPENDENCY(UnicodeConverter kernel)
|
||||
|
||||
core_windows:LIBS += -lgdi32 -ladvapi32 -luser32 -lshell32
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
DESTDIR = $$CORE_BUILDS_BINARY_PATH
|
||||
@ -1,21 +1,13 @@
|
||||
ICU_MAJOR_VER = 74
|
||||
ICU_MAJOR_VER = 58
|
||||
|
||||
core_windows {
|
||||
exists($$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/icu) {
|
||||
INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/icu/include
|
||||
} else {
|
||||
build_xp {
|
||||
INCLUDEPATH += $$PWD/icu58/include
|
||||
} else {
|
||||
INCLUDEPATH += $$PWD/icu/include
|
||||
}
|
||||
INCLUDEPATH += $$PWD/icu/include
|
||||
}
|
||||
|
||||
ICU_LIBS_PATH_WIN = $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build
|
||||
build_xp {
|
||||
ICU_LIBS_PATH_WIN = $$ICU_LIBS_PATH_WIN/xp
|
||||
}
|
||||
LIBS += -L$$ICU_LIBS_PATH_WIN -licuuc
|
||||
LIBS += -L$$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build -licuuc
|
||||
}
|
||||
|
||||
core_linux {
|
||||
@ -28,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 {
|
||||
@ -58,7 +43,8 @@ core_ios {
|
||||
|
||||
core_android {
|
||||
INCLUDEPATH += $$PWD/android/build/include
|
||||
ICU_LIBS_PATH = $$replace(CORE_BUILDS_PLATFORM_PREFIX, "android_", "")
|
||||
|
||||
LIBS += $$PWD/android/build/$$CORE_BUILDS_PLATFORM_PREFIX_DST/libicuuc.a
|
||||
LIBS += $$PWD/android/build/$$CORE_BUILDS_PLATFORM_PREFIX_DST/libicudata.a
|
||||
LIBS += $$PWD/android/build/$$ICU_LIBS_PATH/libicuuc.a
|
||||
LIBS += $$PWD/android/build/$$ICU_LIBS_PATH/libicudata.a
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
ICU_VERSION="58"
|
||||
|
||||
ICU_DIR="$PWD/icu"
|
||||
|
||||
ICU_SOURCE="${ICU_DIR}/source"
|
||||
@ -18,9 +20,9 @@ CONFIG_PREFIX=" --enable-extras=yes \
|
||||
--enable-dyload=no \
|
||||
--with-data-packaging=static"
|
||||
|
||||
CFLAGS="-O3 -D__STDC_INT64__ -fno-exceptions -fno-short-wchar -fno-short-enums"
|
||||
CFLAGS="-O3 -D__STDC_INT64__ -fno-exceptions -fno-short-wchar -fno-short-enums -fembed-bitcode"
|
||||
|
||||
CXXFLAGS="${CFLAGS} -std=c++11"
|
||||
CXXFLAGS="${CFLAGS} -std=c++11 -fembed-bitcode"
|
||||
|
||||
#will set value to 1
|
||||
defines_config_set_1=(
|
||||
@ -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
|
||||
@ -211,9 +215,9 @@ function build() {
|
||||
|
||||
export CXX="$(xcrun -find clang++)"
|
||||
export CC="$(xcrun -find clang)"
|
||||
export CFLAGS="-isysroot $SDKROOT -I$SDKROOT/usr/include/ -I./include/ -arch $ARCH $IOS_MIN_VER $ICU_FLAGS $CFLAGS ${ADDITION_FLAG}"
|
||||
export CXXFLAGS="${CXXFLAGS} -stdlib=libc++ -isysroot $SDKROOT -I$SDKROOT/usr/include/ -I./include/ -arch $ARCH $IOS_MIN_VER $ICU_FLAGS ${ADDITION_FLAG}"
|
||||
export LDFLAGS="-stdlib=libc++ -L$SDKROOT/usr/lib/ -isysroot $SDKROOT -Wl,-dead_strip $IOS_MIN_VER -lstdc++ ${ADDITION_FLAG}"
|
||||
export CFLAGS="-fembed-bitcode -isysroot $SDKROOT -I$SDKROOT/usr/include/ -I./include/ -arch $ARCH $IOS_MIN_VER $ICU_FLAGS $CFLAGS ${ADDITION_FLAG}"
|
||||
export CXXFLAGS="${CXXFLAGS} -fembed-bitcode -stdlib=libc++ -isysroot $SDKROOT -I$SDKROOT/usr/include/ -I./include/ -arch $ARCH $IOS_MIN_VER $ICU_FLAGS ${ADDITION_FLAG}"
|
||||
export LDFLAGS="-fembed-bitcode -stdlib=libc++ -L$SDKROOT/usr/lib/ -isysroot $SDKROOT -Wl,-dead_strip $IOS_MIN_VER -lstdc++ ${ADDITION_FLAG}"
|
||||
|
||||
mkdir -p ${BUILD_DIR}
|
||||
cd ${BUILD_DIR}
|
||||
|
||||
2
Common/3dParty/libvlc/.gitignore
vendored
2
Common/3dParty/libvlc/.gitignore
vendored
@ -1,4 +1,2 @@
|
||||
vlc
|
||||
vlc.*
|
||||
src
|
||||
!build
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* deprecated.h: libvlc deprecated API
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2008 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: 27323a434498604ca281900c3e4087a42d22a5d8 $
|
||||
*
|
||||
* Authors: Clément Stenac <zorglub@videolan.org>
|
||||
* Jean-Paul Saman <jpsaman@videolan.org>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* libvlc.h: libvlc external API
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2009 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: b12d900469fa6438c41421f2ac7697b93ffc8a35 $
|
||||
*
|
||||
* Authors: Clément Stenac <zorglub@videolan.org>
|
||||
* Jean-Paul Saman <jpsaman@videolan.org>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* libvlc_media.h: libvlc external API
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2009 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: 383f366b6940f7b3d89f5945e015793833ea541f $
|
||||
*
|
||||
* Authors: Clément Stenac <zorglub@videolan.org>
|
||||
* Jean-Paul Saman <jpsaman@videolan.org>
|
||||
@ -30,12 +30,6 @@
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <basetsd.h>
|
||||
typedef SSIZE_T ssize_t;
|
||||
#endif
|
||||
|
||||
|
||||
/** \defgroup libvlc_media LibVLC media
|
||||
* \ingroup libvlc
|
||||
* @ref libvlc_media_t is an abstract representation of a playable media.
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* libvlc_media_discoverer.h: libvlc external API
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2009 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: 96c0515ffec98f439867814d68525288b2702b0f $
|
||||
*
|
||||
* Authors: Clément Stenac <zorglub@videolan.org>
|
||||
* Jean-Paul Saman <jpsaman@videolan.org>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* libvlc_media_library.h: libvlc external API
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2009 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: facbf813aa16140461c6e72f166d2985c52b1d6f $
|
||||
*
|
||||
* Authors: Clément Stenac <zorglub@videolan.org>
|
||||
* Jean-Paul Saman <jpsaman@videolan.org>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* libvlc_media_list.h: libvlc_media_list API
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2008 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: fa3b90932be8c3a9cce27925d4867aeddde748d7 $
|
||||
*
|
||||
* Authors: Pierre d'Herbemont
|
||||
*
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* libvlc_media_list_player.h: libvlc_media_list API
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2008 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: 04f7d9b9f0d47e1b8304b51ca20fd2b1045a0ff2 $
|
||||
*
|
||||
* Authors: Pierre d'Herbemont
|
||||
*
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* libvlc_media_player.h: libvlc_media_player external API
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2015 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: c431c235e92ced9e6e7d7712eb7ff0e73dc4f933 $
|
||||
*
|
||||
* Authors: Clément Stenac <zorglub@videolan.org>
|
||||
* Jean-Paul Saman <jpsaman@videolan.org>
|
||||
@ -559,8 +559,6 @@ LIBVLC_API uint32_t libvlc_media_player_get_xwindow ( libvlc_media_player_t *p_m
|
||||
* render its video output. If LibVLC was built without Win32/Win64 API output
|
||||
* support, then this has no effects.
|
||||
*
|
||||
* \warning the HWND must have the WS_CLIPCHILDREN set in its style.
|
||||
*
|
||||
* \param p_mi the Media Player
|
||||
* \param drawable windows handle of the drawable
|
||||
*/
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
# define LIBVLC_VERSION_MINOR (0)
|
||||
|
||||
/** LibVLC revision */
|
||||
# define LIBVLC_VERSION_REVISION (21)
|
||||
# define LIBVLC_VERSION_REVISION (18)
|
||||
|
||||
# define LIBVLC_VERSION_EXTRA (0)
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* libvlc_vlm.h: libvlc_* new external API
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2008 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: cfa2d956463056b287cdb0a4faeb46442040a010 $
|
||||
*
|
||||
* Authors: Clément Stenac <zorglub@videolan.org>
|
||||
* Jean-Paul Saman <jpsaman _at_ m2x _dot_ nl>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* vlc_access.h: Access descriptor, queries and methods
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2006 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: da06554814885d03823aefbf58e858f6941b3400 $
|
||||
*
|
||||
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
|
||||
*
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* vlc_actions.h: handle vlc actions
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2003-2016 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: 404c1662a82ef3f3ffc983a81fa73b90f5773eef $
|
||||
*
|
||||
* Authors: Sigmund Augdal Helberg <dnumgis@videolan.org>
|
||||
*
|
||||
|
||||
@ -129,7 +129,7 @@ struct audio_output
|
||||
/**< Stops the existing stream (optional, may be NULL).
|
||||
* \note A stream must have been started when called.
|
||||
*/
|
||||
int (*time_get)(audio_output_t *, vlc_tick_t *delay);
|
||||
int (*time_get)(audio_output_t *, mtime_t *delay);
|
||||
/**< Estimates playback buffer latency (optional, may be NULL).
|
||||
* \param delay pointer to the delay until the next sample to be written
|
||||
* to the playback buffer is rendered [OUT]
|
||||
@ -140,7 +140,7 @@ struct audio_output
|
||||
/**< Queues a block of samples for playback (mandatory, cannot be NULL).
|
||||
* \note A stream must have been started when called.
|
||||
*/
|
||||
void (*pause)( audio_output_t *, bool pause, vlc_tick_t date);
|
||||
void (*pause)( audio_output_t *, bool pause, mtime_t date);
|
||||
/**< Pauses or resumes playback (optional, may be NULL).
|
||||
* \param pause pause if true, resume from pause if false
|
||||
* \param date timestamp when the pause or resume was requested
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* vlc_aout_volume.h: audio volume module
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2002-2009 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: df85b8fd14e00454e88c08061e3059fa67927dab $
|
||||
*
|
||||
* Authors: Christophe Massiot <massiot@via.ecp.fr>
|
||||
* Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* vlc_arrays.h : Arrays and data structures handling
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2004 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: 39b69952ffce040330da239f52778c3e82024bc4 $
|
||||
*
|
||||
* Authors: Samuel Hocevar <sam@zoy.org>
|
||||
* Clément Stenac <zorglub@videolan.org>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* vlc_bits.h : Bit handling helpers
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2001, 2002, 2003, 2006, 2015 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: 395a789eba46ac42413f5fb5418619332589f824 $
|
||||
*
|
||||
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
|
||||
* Gildas Bazin <gbazin at videolan dot org>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* vlc_block.h: Data blocks management functions
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2003 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: 1c9478301687233398adbb7de7da4ffc4a101f89 $
|
||||
*
|
||||
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
|
||||
*
|
||||
@ -49,7 +49,7 @@
|
||||
* - i_flags may not always be set (ie could be 0, even for a key frame
|
||||
* it depends where you receive the buffer (before/after a packetizer
|
||||
* and the demux/packetizer implementations.
|
||||
* - i_dts/i_pts could be VLC_TICK_INVALID, it means no pts/dts
|
||||
* - i_dts/i_pts could be VLC_TS_INVALID, it means no pts/dts
|
||||
* - i_length: length in microseond of the packet, can be null except in the
|
||||
* sout where it is mandatory.
|
||||
*
|
||||
@ -121,9 +121,9 @@ struct block_t
|
||||
uint32_t i_flags;
|
||||
unsigned i_nb_samples; /* Used for audio */
|
||||
|
||||
vlc_tick_t i_pts;
|
||||
vlc_tick_t i_dts;
|
||||
vlc_tick_t i_length;
|
||||
mtime_t i_pts;
|
||||
mtime_t i_dts;
|
||||
mtime_t i_length;
|
||||
|
||||
/* Rudimentary support for overloading block (de)allocation. */
|
||||
block_free_t pf_release;
|
||||
@ -175,7 +175,7 @@ VLC_API block_t *block_Realloc(block_t *, ssize_t pre, size_t body) VLC_USED;
|
||||
*
|
||||
* @note
|
||||
* If the block is in a chain, this function does <b>not</b> release any
|
||||
* subsequent block in the chain. Use block_ChainRelease() for that purpose.
|
||||
* subsequent block in the chain. Use block_ChainRelease() for that purpose.
|
||||
*
|
||||
* @param block block to release (cannot be NULL)
|
||||
*/
|
||||
@ -364,10 +364,10 @@ static size_t block_ChainExtract( block_t *p_list, void *p_data, size_t i_max )
|
||||
return i_total;
|
||||
}
|
||||
|
||||
static inline void block_ChainProperties( block_t *p_list, int *pi_count, size_t *pi_size, vlc_tick_t *pi_length )
|
||||
static inline void block_ChainProperties( block_t *p_list, int *pi_count, size_t *pi_size, mtime_t *pi_length )
|
||||
{
|
||||
size_t i_size = 0;
|
||||
vlc_tick_t i_length = 0;
|
||||
mtime_t i_length = 0;
|
||||
int i_count = 0;
|
||||
|
||||
while( p_list )
|
||||
@ -390,7 +390,7 @@ static inline void block_ChainProperties( block_t *p_list, int *pi_count, size_t
|
||||
static inline block_t *block_ChainGather( block_t *p_list )
|
||||
{
|
||||
size_t i_total = 0;
|
||||
vlc_tick_t i_length = 0;
|
||||
mtime_t i_length = 0;
|
||||
block_t *g;
|
||||
|
||||
if( p_list->p_next == NULL )
|
||||
@ -534,7 +534,7 @@ VLC_API void vlc_fifo_WaitCond(vlc_fifo_t *, vlc_cond_t *);
|
||||
* Atomically unlocks the FIFO and waits until one thread signals the FIFO up
|
||||
* to a certain date, then locks the FIFO again. See vlc_fifo_Wait().
|
||||
*/
|
||||
int vlc_fifo_TimedWaitCond(vlc_fifo_t *, vlc_cond_t *, vlc_tick_t);
|
||||
int vlc_fifo_TimedWaitCond(vlc_fifo_t *, vlc_cond_t *, mtime_t);
|
||||
|
||||
/**
|
||||
* Queues a linked-list of blocks into a locked FIFO.
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2003-2005 VLC authors and VideoLAN
|
||||
* Copyright © 2005-2010 Rémi Denis-Courmont
|
||||
* $Id$
|
||||
* $Id: c77f19892047f406a69695a255aaf9ef6ef32ec3 $
|
||||
*
|
||||
* Author: Rémi Denis-Courmont
|
||||
*
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* vlc_codec.h: Definition of the decoder and encoder structures
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2003 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: 3499ede27c1dbb94ff665a51d000c55bd45f2794 $
|
||||
*
|
||||
* Authors: Gildas Bazin <gbazin@netcourrier.com>
|
||||
*
|
||||
@ -169,7 +169,7 @@ struct decoder_t
|
||||
|
||||
/* Display date
|
||||
* XXX use decoder_GetDisplayDate */
|
||||
vlc_tick_t (*pf_get_display_date)( decoder_t *, vlc_tick_t );
|
||||
mtime_t (*pf_get_display_date)( decoder_t *, mtime_t );
|
||||
|
||||
/* Display rate
|
||||
* XXX use decoder_GetDisplayRate */
|
||||
@ -409,7 +409,7 @@ VLC_API int decoder_GetInputAttachments( decoder_t *, input_attachment_t ***ppp_
|
||||
* to mdate().
|
||||
* You MUST use it *only* for gathering statistics about speed.
|
||||
*/
|
||||
VLC_API vlc_tick_t decoder_GetDisplayDate( decoder_t *, vlc_tick_t ) VLC_USED;
|
||||
VLC_API mtime_t decoder_GetDisplayDate( decoder_t *, mtime_t ) VLC_USED;
|
||||
|
||||
/**
|
||||
* This function returns the current input rate.
|
||||
|
||||
@ -152,11 +152,7 @@
|
||||
* epoch). Note that date and time intervals can be manipulated using regular
|
||||
* arithmetic operators, and that no special functions are required.
|
||||
*/
|
||||
typedef int64_t vlc_tick_t;
|
||||
typedef vlc_tick_t mtime_t; /* deprecated, use vlc_tick_t */
|
||||
|
||||
#define VLC_TICK_INVALID VLC_TS_INVALID
|
||||
#define VLC_TICK_0 VLC_TS_0
|
||||
typedef int64_t mtime_t;
|
||||
|
||||
/**
|
||||
* The vlc_fourcc_t type.
|
||||
@ -947,11 +943,6 @@ static inline void SetQWLE (void *p, uint64_t qw)
|
||||
# define O_NONBLOCK 0
|
||||
# endif
|
||||
|
||||
/* the mingw32 swab() and win32 _swab() prototypes expect a char* instead of a
|
||||
const void* */
|
||||
# define swab(a,b,c) swab((char*) (a), (char*) (b), (c))
|
||||
|
||||
|
||||
# include <tchar.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* vlc_config_cat.h : Definition of configuration categories
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2003 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: 55d2e468d1ccc3fcd8d165dcecc10ec753021a5e $
|
||||
*
|
||||
* Authors: Clément Stenac <zorglub@videolan.org>
|
||||
* Anil Daoud <anil@videolan.org>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
* It includes functions allowing to declare, get or set configuration options.
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2006 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: 209168615be2a7bc5db889282b32389093ab262e $
|
||||
*
|
||||
* Authors: Gildas Bazin <gbazin@videolan.org>
|
||||
*
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* vlc_demux.h: Demuxer descriptor, queries and methods
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2005 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: f359f547fa79d9818ed74420d906a6683be3d037 $
|
||||
*
|
||||
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
|
||||
*
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* vlc_epg.h: Electronic Program Guide
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2007 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: f7b9044e7c0aa1af4a44066d73f2ead943fc6a46 $
|
||||
*
|
||||
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
|
||||
*
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* vlc_es.h: Elementary stream formats descriptions
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2012 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: 3c8e04e1b15740166df2e0b2d9a651ffb2c5bc2f $
|
||||
*
|
||||
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
|
||||
*
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* vlc_es_out.h: es_out (demuxer output) descriptor, queries and methods
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2004 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: fe53c2a3d34f76eec76d83032cd0d3111be915aa $
|
||||
*
|
||||
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
|
||||
*
|
||||
@ -93,8 +93,8 @@ enum es_out_query_e
|
||||
ES_OUT_SET_META, /* arg1=const vlc_meta_t * */
|
||||
|
||||
/* PCR system clock manipulation for external clock synchronization */
|
||||
ES_OUT_GET_PCR_SYSTEM, /* arg1=vlc_tick_t *, arg2=vlc_tick_t * res=can fail */
|
||||
ES_OUT_MODIFY_PCR_SYSTEM, /* arg1=int is_absolute, arg2=vlc_tick_t, res=can fail */
|
||||
ES_OUT_GET_PCR_SYSTEM, /* arg1=mtime_t *, arg2=mtime_t * res=can fail */
|
||||
ES_OUT_MODIFY_PCR_SYSTEM, /* arg1=int is_absolute, arg2=mtime_t, res=can fail */
|
||||
|
||||
ES_OUT_POST_SUBNODE, /* arg1=input_item_node_t *, res=can fail */
|
||||
|
||||
@ -167,11 +167,11 @@ static inline int es_out_ControlSetMeta( es_out_t *out, const vlc_meta_t *p_meta
|
||||
return es_out_Control( out, ES_OUT_SET_META, p_meta );
|
||||
}
|
||||
|
||||
static inline int es_out_ControlGetPcrSystem( es_out_t *out, vlc_tick_t *pi_system, vlc_tick_t *pi_delay )
|
||||
static inline int es_out_ControlGetPcrSystem( es_out_t *out, mtime_t *pi_system, mtime_t *pi_delay )
|
||||
{
|
||||
return es_out_Control( out, ES_OUT_GET_PCR_SYSTEM, pi_system, pi_delay );
|
||||
}
|
||||
static inline int es_out_ControlModifyPcrSystem( es_out_t *out, bool b_absolute, vlc_tick_t i_system )
|
||||
static inline int es_out_ControlModifyPcrSystem( es_out_t *out, bool b_absolute, mtime_t i_system )
|
||||
{
|
||||
return es_out_Control( out, ES_OUT_MODIFY_PCR_SYSTEM, b_absolute, i_system );
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* Interface used to send events.
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2007 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: 229f4f677029763a837558932dad3e47b283e61c $
|
||||
*
|
||||
* Authors: Pierre d'Herbemont
|
||||
*
|
||||
@ -142,7 +142,7 @@ typedef struct vlc_event_t
|
||||
} input_item_subitem_tree_added;
|
||||
struct vlc_input_item_duration_changed
|
||||
{
|
||||
vlc_tick_t new_duration;
|
||||
mtime_t new_duration;
|
||||
} input_item_duration_changed;
|
||||
struct vlc_input_item_preparsed_changed
|
||||
{
|
||||
|
||||
@ -95,7 +95,7 @@ struct filter_t
|
||||
int, int, int );
|
||||
|
||||
/** Generate a subpicture (sub source) */
|
||||
subpicture_t *(*pf_sub_source)( filter_t *, vlc_tick_t );
|
||||
subpicture_t *(*pf_sub_source)( filter_t *, mtime_t );
|
||||
|
||||
/** Filter a subpicture (sub filter) */
|
||||
subpicture_t *(*pf_sub_filter)( filter_t *, subpicture_t * );
|
||||
@ -431,7 +431,7 @@ VLC_API void filter_chain_VideoFlush( filter_chain_t * );
|
||||
* \param display_date of subpictures
|
||||
*/
|
||||
void filter_chain_SubSource(filter_chain_t *chain, spu_t *,
|
||||
vlc_tick_t display_date);
|
||||
mtime_t display_date);
|
||||
|
||||
/**
|
||||
* Apply filter chain to subpictures.
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* vlc_fourcc.h: Definition of various FOURCC and helpers
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2009 Laurent Aimar
|
||||
* $Id$
|
||||
* $Id: 97827bd4c146461408fbfd5d0aed6e45a91dc89a $
|
||||
*
|
||||
* Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ com>
|
||||
*
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* vlc_http.h: Shared code for HTTP clients
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2001-2008 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: a48ea794963ad476fc059eb3ffcf787186b78b47 $
|
||||
*
|
||||
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
|
||||
* Christophe Massiot <massiot@via.ecp.fr>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* vlc_httpd.h: builtin HTTP/RTSP server.
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2004-2006 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: 29b8229e7b6baa7a8eedf37f6fdb1e97bf6a9ca7 $
|
||||
*
|
||||
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
|
||||
*
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* vlc_image.h : wrapper for image reading/writing facilities
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2004 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
* $Id: 2b308fd0e52f4d4d6e20f95d08e0d63c53822eef $
|
||||
*
|
||||
* Authors: Gildas Bazin <gbazin@videolan.org>
|
||||
*
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user